85 lines
2.4 KiB
JavaScript
85 lines
2.4 KiB
JavaScript
import { Button, Card, Form, InputNumber, Popover } from "antd";
|
|
import React, { useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { connect } from "react-redux";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
|
import { TemplateList } from "../../utils/TemplateConstants";
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
bodyshop: selectBodyshop,
|
|
});
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
|
});
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(PrintCenterJobsLabels);
|
|
|
|
export function PrintCenterJobsLabels({ bodyshop, jobId }) {
|
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
const [loading, setLoading] = useState(false);
|
|
const { t } = useTranslation();
|
|
const [form] = Form.useForm();
|
|
|
|
const handleOk = () => {
|
|
form.submit();
|
|
setIsModalVisible(false);
|
|
};
|
|
|
|
const handleCancel = () => {
|
|
setIsModalVisible(false);
|
|
setLoading(false);
|
|
};
|
|
const handleFinish = async (values) => {
|
|
const { sendtype, ...restVals } = values;
|
|
setLoading(true);
|
|
await GenerateDocument(
|
|
{
|
|
name: TemplateList("job_special").folder_label_multiple.key,
|
|
variables: { id: jobId },
|
|
context: restVals,
|
|
},
|
|
{},
|
|
"p",
|
|
jobId
|
|
);
|
|
setLoading(false);
|
|
setIsModalVisible(false);
|
|
};
|
|
|
|
const content = (
|
|
<Card>
|
|
<Form
|
|
onFinish={handleFinish}
|
|
autoComplete={"off"}
|
|
layout="vertical"
|
|
form={form}
|
|
>
|
|
<Form.Item
|
|
label={t("printcenter.jobs.labels.position")}
|
|
name="position"
|
|
>
|
|
<InputNumber min={1} precision={0} />
|
|
</Form.Item>
|
|
<Form.Item label={t("printcenter.jobs.labels.count")} name="count">
|
|
<InputNumber min={1} precision={0} max={99} />
|
|
</Form.Item>
|
|
<Button type="primary" loading={loading} onClick={handleOk}>
|
|
{t("general.actions.print")}
|
|
</Button>
|
|
<Button onClick={handleCancel}>{t("general.actions.cancel")}</Button>
|
|
</Form>
|
|
</Card>
|
|
);
|
|
return (
|
|
<Popover content={content} visible={isModalVisible}>
|
|
<Button onClick={() => setIsModalVisible(true)}>
|
|
{t("printcenter.jobs.labels.labels")}
|
|
</Button>
|
|
</Popover>
|
|
);
|
|
}
|