Commit 83abff4e authored by TZW's avatar TZW

Merge branch 'master' of http://47.100.234.193:9527/wuhao/ems3.3

parents 1d84b278 8838ce8c
......@@ -103,7 +103,6 @@ function InitForm(props) {
},
val,
} = props;
console.log(props);
let proformRef = useRef();
proformRef = formRef ?? proformRef;
......
function getcolumns(setdrawer) {
return {
columns: [
......@@ -52,11 +50,11 @@ function getcolumns(setdrawer) {
options: [
{
label: '启用',
value: '1',
value: 1,
},
{
label: '停用',
value: '2',
value: 2,
},
],
formItemProps: {
......
......@@ -4,8 +4,9 @@ import DrawerPro from '@/components/DrawerPro';
import AutoTable from '@/components/AutoTable';
import PremButton from '@/components/PremButton';
import getcolumns from './columns';
import { useRequest } from 'ahooks';
import { useAsyncEffect, useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch';
import extraColumns from '@/utils/extraColumns';
function Supplier(props) {
const actionRef = useRef(),
......@@ -13,10 +14,19 @@ function Supplier(props) {
const [drawer, setdrawer] = useState({
open: false,
});
const [columns, setcolumns] = useState([
{
title: 'asd',
key: 'ads',
},
]);
const pathconfig = useMemo(() => {
let pathconf = getcolumns(setdrawer)?.pathconfig ?? {};
return pathconf;
}, []);
const { run, loading } = useRequest(doFetch, {
manual: true,
onSuccess: (res, params) => {
......@@ -95,9 +105,16 @@ function Supplier(props) {
);
};
const columns = useMemo(() => {
useAsyncEffect(async () => {
let extracolumns = await extraColumns({
url: '/base/paFormField/queryList',
params: { formId: 4 },
});
let defcolumn = getcolumns(setdrawer)?.columns;
return defcolumn.concat({
setcolumns([
...defcolumn,
...extracolumns,
{
title: '操作',
valueType: 'option',
width: 150,
......@@ -106,8 +123,10 @@ function Supplier(props) {
pathconfig?.enableedit && edit(text, row, _, action),
pathconfig?.enabledelete && remove(text, row, _, action),
],
});
},
]);
}, []);
console.log(columns);
return (
<div style={{ position: 'relative' }}>
......@@ -117,7 +136,7 @@ function Supplier(props) {
actionRef={actionRef}
path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
pageextra={pathconfig?.enableadd ? 'add' : null}
resizeable={true}
resizeable={false}
addconfig={{
// access: 'sysDepartment_save',
btn: {
......@@ -137,6 +156,7 @@ function Supplier(props) {
<DrawerPro
fields={columns}
extendField="supplierCharList"
params={{ id: drawer?.item?.id }}
formRef={formRef}
placement="right"
......@@ -151,10 +171,23 @@ function Supplier(props) {
}}
{...drawer}
onFinish={(vals) => {
const newVals = JSON.parse(JSON.stringify(vals));
const supplierCharReqList = [];
for (let i in newVals) {
if (!isNaN(i)) {
supplierCharReqList.push({
fieldId: i,
fieldRealValue: newVals[i],
});
delete newVals[i];
}
}
newVals.supplierCharReqList = supplierCharReqList;
if (drawer?.val == 'add') {
run({ url: pathconfig?.add || '/add', params: { ...vals } });
run({ url: pathconfig?.add || '/add', params: { ...newVals } });
} else if (drawer?.val == 'edit') {
run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } });
run({ url: pathconfig?.edit || '/edit', params: { ...newVals, id: drawer?.item?.id } });
}
}}
/>
......
import { doFetch } from './doFetch';
const selectValueType = (type, options) => {
switch (type) {
case 1:
return {
valueType: 'input',
};
case 2:
return {
valueType: 'select',
options,
};
case 3:
return {
valueType: 'radio',
options,
};
case 4:
return {
valueType: 'select',
fieldProps: {
mode: 'multiple',
},
options,
};
default:
break;
}
};
async function extraColumns({ url, params }) {
let res = doFetch({ url, params });
let res = await doFetch({ url, params });
if (res?.data?.dataList) {
let column = [
{
title: '扩展字段',
valueType: 'split',
},
res?.data?.dataList?.map?.((el) => {
return {
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
dataIndex: el.id,
key: el.id,
};
}),
];
return column.flat();
}
}
export default extraColumns;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment