Commit 8838ce8c authored by wuhao's avatar wuhao 🎯

asder

parent 290f4fdc
...@@ -103,7 +103,6 @@ function InitForm(props) { ...@@ -103,7 +103,6 @@ function InitForm(props) {
}, },
val, val,
} = props; } = props;
console.log(props);
let proformRef = useRef(); let proformRef = useRef();
proformRef = formRef ?? proformRef; proformRef = formRef ?? proformRef;
......
function getcolumns(setdrawer) { function getcolumns(setdrawer) {
return { return {
columns: [ columns: [
...@@ -52,11 +50,11 @@ function getcolumns(setdrawer) { ...@@ -52,11 +50,11 @@ function getcolumns(setdrawer) {
options: [ options: [
{ {
label: '启用', label: '启用',
value: '1', value: 1,
}, },
{ {
label: '停用', label: '停用',
value: '2', value: 2,
}, },
], ],
formItemProps: { formItemProps: {
......
...@@ -4,8 +4,9 @@ import DrawerPro from '@/components/DrawerPro'; ...@@ -4,8 +4,9 @@ import DrawerPro from '@/components/DrawerPro';
import AutoTable from '@/components/AutoTable'; import AutoTable from '@/components/AutoTable';
import PremButton from '@/components/PremButton'; import PremButton from '@/components/PremButton';
import getcolumns from './columns'; import getcolumns from './columns';
import { useRequest } from 'ahooks'; import { useAsyncEffect, useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch'; import { doFetch } from '@/utils/doFetch';
import extraColumns from '@/utils/extraColumns';
function Supplier(props) { function Supplier(props) {
const actionRef = useRef(), const actionRef = useRef(),
...@@ -13,10 +14,19 @@ function Supplier(props) { ...@@ -13,10 +14,19 @@ function Supplier(props) {
const [drawer, setdrawer] = useState({ const [drawer, setdrawer] = useState({
open: false, open: false,
}); });
const [columns, setcolumns] = useState([
{
title: 'asd',
key: 'ads',
},
]);
const pathconfig = useMemo(() => { const pathconfig = useMemo(() => {
let pathconf = getcolumns(setdrawer)?.pathconfig ?? {}; let pathconf = getcolumns(setdrawer)?.pathconfig ?? {};
return pathconf; return pathconf;
}, []); }, []);
const { run, loading } = useRequest(doFetch, { const { run, loading } = useRequest(doFetch, {
manual: true, manual: true,
onSuccess: (res, params) => { onSuccess: (res, params) => {
...@@ -95,19 +105,28 @@ function Supplier(props) { ...@@ -95,19 +105,28 @@ function Supplier(props) {
); );
}; };
const columns = useMemo(() => { useAsyncEffect(async () => {
let defcolumn = getcolumns(setdrawer)?.columns; let extracolumns = await extraColumns({
return defcolumn.concat({ url: '/base/paFormField/queryList',
title: '操作', params: { formId: 4 },
valueType: 'option',
width: 150,
render: (text, row, _, action) => [
pathconfig?.enabledetail && detail(text, row, _, action),
pathconfig?.enableedit && edit(text, row, _, action),
pathconfig?.enabledelete && remove(text, row, _, action),
],
}); });
let defcolumn = getcolumns(setdrawer)?.columns;
setcolumns([
...defcolumn,
...extracolumns,
{
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => [
pathconfig?.enabledetail && detail(text, row, _, action),
pathconfig?.enableedit && edit(text, row, _, action),
pathconfig?.enabledelete && remove(text, row, _, action),
],
},
]);
}, []); }, []);
console.log(columns);
return ( return (
<div style={{ position: 'relative' }}> <div style={{ position: 'relative' }}>
...@@ -117,7 +136,7 @@ function Supplier(props) { ...@@ -117,7 +136,7 @@ function Supplier(props) {
actionRef={actionRef} actionRef={actionRef}
path={pathconfig?.list || '/ngic-auth/sysUser/query/page'} path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
pageextra={pathconfig?.enableadd ? 'add' : null} pageextra={pathconfig?.enableadd ? 'add' : null}
resizeable={true} resizeable={false}
addconfig={{ addconfig={{
// access: 'sysDepartment_save', // access: 'sysDepartment_save',
btn: { btn: {
...@@ -137,6 +156,7 @@ function Supplier(props) { ...@@ -137,6 +156,7 @@ function Supplier(props) {
<DrawerPro <DrawerPro
fields={columns} fields={columns}
extendField="supplierCharList"
params={{ id: drawer?.item?.id }} params={{ id: drawer?.item?.id }}
formRef={formRef} formRef={formRef}
placement="right" placement="right"
...@@ -151,10 +171,23 @@ function Supplier(props) { ...@@ -151,10 +171,23 @@ function Supplier(props) {
}} }}
{...drawer} {...drawer}
onFinish={(vals) => { 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') { if (drawer?.val == 'add') {
run({ url: pathconfig?.add || '/add', params: { ...vals } }); run({ url: pathconfig?.add || '/add', params: { ...newVals } });
} else if (drawer?.val == 'edit') { } 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'; 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 }) { 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; 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