|
|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
import { useEffect } from "react";
|
|
|
|
|
import { Form, Input, Row, Col, Select, DatePicker, Space, Button, Checkbox } from "antd";
|
|
|
|
|
import { objectMapper, at } from "@/utils/commons";
|
|
|
|
|
import { DATE_FORMAT, SMALL_DATETIME_FORMAT } from "@/config";
|
|
|
|
|
import { DATE_FORMAT, SMALL_DATETIME_FORMAT, PERM_AGENCY_ALL } from "@/config";
|
|
|
|
|
import useFormStore from "@/stores/Form";
|
|
|
|
|
import { useDatePresets } from "@/hooks/useDatePresets";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import useAuthStore from '@/stores/Auth'
|
|
|
|
|
|
|
|
|
|
import SearchInput from "./SearchInput";
|
|
|
|
|
import AuditStateSelector from "./AuditStateSelector";
|
|
|
|
|
@ -20,15 +21,19 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f
|
|
|
|
|
const presets = useDatePresets();
|
|
|
|
|
const [formValues, setFormValues] = useFormStore(state => [state.formValues, state.setFormValues]);
|
|
|
|
|
const [formValuesToSub, setFormValuesToSub] = useFormStore(state => [state.formValuesToSub, state.setFormValuesToSub]);
|
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted)
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
const defaultShowFields = isPermitted(PERM_AGENCY_ALL) ? ['agency'] : [];
|
|
|
|
|
const defaultFieldsProps = isPermitted(PERM_AGENCY_ALL) ? { agency: { col: 24 }, } : {};
|
|
|
|
|
const defaultFieldsComProps = isPermitted(PERM_AGENCY_ALL) ? { agency: { mode: null }, } : {};
|
|
|
|
|
const { sort, hides, shows, fieldProps, fieldComProps } = {
|
|
|
|
|
sort: "",
|
|
|
|
|
// initialValue: '',
|
|
|
|
|
fieldProps: "",
|
|
|
|
|
fieldComProps: "",
|
|
|
|
|
hides: [],
|
|
|
|
|
shows: [],
|
|
|
|
|
...props.fieldsConfig,
|
|
|
|
|
shows: [...defaultShowFields, ...(props.fieldsConfig?.shows || [])],
|
|
|
|
|
fieldProps: { ...defaultFieldsProps, ...(props.fieldsConfig?.fieldProps || {}) },
|
|
|
|
|
fieldComProps: { ...defaultFieldsComProps, ...(props.fieldsConfig?.fieldComProps || {}) },
|
|
|
|
|
};
|
|
|
|
|
const readValues = { ...initialValue, ...formValues };
|
|
|
|
|
|
|
|
|
|
@ -46,12 +51,11 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f
|
|
|
|
|
invoiceStatus: { key: "invoiceStatus", transform: value => value?.value || value?.key || "", default: "" },
|
|
|
|
|
invoiceCheckStatus: { key: "invoiceCheckStatus", transform: value => value?.value || value?.key || "", default: "" },
|
|
|
|
|
audit_state: { key: "audit_state", transform: value => value?.value || value?.key || "", default: "" },
|
|
|
|
|
agency: {
|
|
|
|
|
key: "agency",
|
|
|
|
|
transform: value => {
|
|
|
|
|
return Array.isArray(value) ? value.map(ele => ele.key).join(",") : value ? value.value : "";
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
agency: [
|
|
|
|
|
{ key: "agency", transform: value => { return Array.isArray(value) ? value.map(ele => ele.key).join(",") : value ? value.value : ""; }, },
|
|
|
|
|
{ key: "veisn", transform: value => { return Array.isArray(value) ? value.map(ele => ele.key).join(",") : value ? value.value : ""; }, },
|
|
|
|
|
{ key: "VEI_SN", transform: value => { return Array.isArray(value) ? value.map(ele => ele.key).join(",") : value ? value.value : ""; }, },
|
|
|
|
|
],
|
|
|
|
|
year: [{ key: "year", transform: arrVal => (arrVal ? arrVal.format("YYYY") : "") }],
|
|
|
|
|
products_types: {
|
|
|
|
|
key: "products_types",
|
|
|
|
|
@ -102,9 +106,9 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const onFinish = values => {
|
|
|
|
|
//console.log("Received values of form, origin form value: \n", values);
|
|
|
|
|
console.log("Received values of form, origin form value: \n", values);
|
|
|
|
|
const dest = formValuesMapper(values);
|
|
|
|
|
//console.log("form value send to onSubmit:\n", dest);
|
|
|
|
|
console.log("form value send to onSubmit:\n", dest);
|
|
|
|
|
const str = new URLSearchParams(dest).toString();
|
|
|
|
|
setFormValues(values);
|
|
|
|
|
setFormValuesToSub(dest);
|
|
|
|
|
@ -157,7 +161,7 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getFields(props) {
|
|
|
|
|
const { fieldProps, fieldComProps, form, presets, t } = props;
|
|
|
|
|
const { fieldProps, fieldComProps, form, presets, t, shows } = props;
|
|
|
|
|
const bigCol = 4 * 2;
|
|
|
|
|
const midCol = 6;
|
|
|
|
|
const layoutProps = {
|
|
|
|
|
@ -254,7 +258,7 @@ function getFields(props) {
|
|
|
|
|
<Form.Item name="username" label={t("account:username")} {...fieldProps.username}>
|
|
|
|
|
<Input placeholder={t("account:username")} allowClear />
|
|
|
|
|
</Form.Item>,
|
|
|
|
|
fieldProps?.username?.col || 4
|
|
|
|
|
fieldProps?.username?.col || 6
|
|
|
|
|
),
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
@ -269,7 +273,7 @@ function getFields(props) {
|
|
|
|
|
),
|
|
|
|
|
item(
|
|
|
|
|
"agency", //地接社
|
|
|
|
|
99,
|
|
|
|
|
98, // 默认放第一个
|
|
|
|
|
<Form.Item name="agency" label={t("products:Vendor")} {...fieldProps.agency} initialValue={at(props, "initialValue.agency")[0]}>
|
|
|
|
|
<VendorSelector maxTagCount={1} {...fieldComProps.agency} />
|
|
|
|
|
</Form.Item>,
|
|
|
|
|
|