Commit 908e661a authored by TZW's avatar TZW

12011420

parent 8e4441b6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: Li Hanlin * @Author: Li Hanlin
* @Date: 2022-11-29 14:03:07 * @Date: 2022-11-29 14:03:07
* @Last Modified by: Li Hanlin * @Last Modified by: Li Hanlin
* @Last Modified time: 2022-11-29 16:28:29 * @Last Modified time: 2022-12-01 11:06:20
*/ */
import { doFetch } from '@/utils/doFetch'; import { doFetch } from '@/utils/doFetch';
...@@ -10,8 +10,9 @@ import { useRequest } from 'ahooks'; ...@@ -10,8 +10,9 @@ import { useRequest } from 'ahooks';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import InitForm from '../InitForm'; import InitForm from '../InitForm';
export default ({ formId }) => { const App = ({ setDrawer, onFinish, drawer, actionRef, columns, urlParams, formId }) => {
const [columns, setcolumns] = useState([]); const [value, setValue] = useState('');
const [fieldscolumns, setfieldscolumns] = useState(columns);
const selectValueType = (type, options) => { const selectValueType = (type, options) => {
switch (type) { switch (type) {
case 1: case 1:
...@@ -43,29 +44,53 @@ export default ({ formId }) => { ...@@ -43,29 +44,53 @@ export default ({ formId }) => {
let res = await doFetch({ let res = await doFetch({
url: '/base/paFormField/queryList', url: '/base/paFormField/queryList',
params: { params: {
formId, formId: formId,
}, },
}); });
if (res?.data?.dataList) { if (res?.data?.dataList) {
let column = []; let column = [
{
title: '扩展字段',
valueType: 'split',
},
];
res?.data?.dataList?.forEach((el) => { res?.data?.dataList?.forEach((el) => {
column.push({ column.push({
...selectValueType(el.fieldChar, el.valueType), ...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName, title: el.fieldName,
dataIndex: 'title', dataIndex: el.fieldName,
key: el.id, key: el.id,
}); });
}); });
console.log('11111', column); setfieldscolumns(fieldscolumns.concat(column));
setcolumns(column);
} }
}; };
fn(); fn();
}, []); }, []);
const selectextendField = (type) => {
switch (Number(type)) {
case 1:
return 'userCharList';
case 2:
return 'equipmentCharList';
case 3:
return 'equipmentSupplierCharList';
default:
break;
}
};
return ( return (
<> <>
<InitForm fields={columns} /> <InitForm
extendField={selectextendField(formId)}
detailpath={urlParams.detail}
params={{ id: drawer?.item?.id }}
fields={fieldscolumns}
onFinish={onFinish}
/>
</> </>
); );
}; };
export default App;
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: Li Hanlin * @Author: Li Hanlin
* @Date: 2022-11-10 09:39:56 * @Date: 2022-11-10 09:39:56
* @Last Modified by: Li Hanlin * @Last Modified by: Li Hanlin
* @Last Modified time: 2022-11-30 14:36:31 * @Last Modified time: 2022-12-01 13:59:27
*/ */
import * as React from 'react'; import * as React from 'react';
...@@ -16,6 +16,7 @@ import { message, Dropdown, Menu, Layout, Button, Image, Space, Divider, Tabs } ...@@ -16,6 +16,7 @@ import { message, Dropdown, Menu, Layout, Button, Image, Space, Divider, Tabs }
import TreeRender from '@/components/TreeRender'; import TreeRender from '@/components/TreeRender';
import { ProDescriptions } from '@ant-design/pro-components'; import { ProDescriptions } from '@ant-design/pro-components';
import InitForm from '@/components/InitForm'; import InitForm from '@/components/InitForm';
import ExtendField from '@/components/ExtendField';
const { Sider, Content } = Layout; const { Sider, Content } = Layout;
...@@ -474,28 +475,42 @@ function Model(props) { ...@@ -474,28 +475,42 @@ function Model(props) {
...s, ...s,
visible: true, visible: true,
title: '编辑', title: '编辑',
val: 'edit', val: 'only',
detailpath: urlParams.detail, type: 'add',
params: { id: row.id }, item: row,
onFinish: async (vals) => { // detailpath: urlParams.detail,
console.log(1); // params: { id: row.id },
let params = { // onFinish: async (vals) => {
...vals, // console.log(1);
id: row.id, // let equipmentCharList = [];
}; // console.log('id:', row.id);
let res = await doFetch({ // for (let i in vals) {
url: urlParams.save, // if (!isNaN(Number(i))) {
params, // equipmentCharList.push({
}); // fieldId: i,
if (res.code === '0000') { // fieldRealValue: vals[i],
message.success('编辑成功!'); // });
setDrawer((s) => ({ // delete vals[i];
...s, // }
visible: false, // }
})); // let params = {
actionRef.current.reload(); // ...vals,
} // id: row.id,
}, // equipmentCharList,
// };
// let res = await doFetch({
// url: urlParams.save,
// params,
// });
// if (res.code === '0000') {
// message.success('编辑成功!');
// setDrawer((s) => ({
// ...s,
// visible: false,
// }));
// actionRef.current.reload();
// }
// },
})); }));
}, },
}} }}
...@@ -646,20 +661,7 @@ function Model(props) { ...@@ -646,20 +661,7 @@ function Model(props) {
const [activeTab, setactiveTab] = useState(1); const [activeTab, setactiveTab] = useState(1);
// 基础信息 // 基础信息
const BaseInfo = () => { const BaseInfo = () => {
return ( const columns = [
<>
<ProDescriptions
request={async () => {
const { data } = await doFetch({
url: urlParams.detail,
params: { id: drawer?.item?.id },
});
return {
success: true,
data: data?.data,
};
}}
columns={[
{ {
title: '设备编号', title: '设备编号',
dataIndex: 'equipmentNo', dataIndex: 'equipmentNo',
...@@ -743,7 +745,89 @@ function Model(props) { ...@@ -743,7 +745,89 @@ function Model(props) {
key: 'qrCodeUrl', key: 'qrCodeUrl',
render: (text, row) => <Image width={70} src={row.qrCodeUrl} />, render: (text, row) => <Image width={70} src={row.qrCodeUrl} />,
}, },
]} ];
const [newfieldscolumns, setnewfieldscolumns] = useState(columns);
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',
options,
};
default:
break;
}
};
useEffect(() => {
const fn = async () => {
let res = await doFetch({
url: '/base/paFormField/queryList',
params: {
formId: '2',
},
});
if (res?.data?.dataList) {
let column = [
{
title: '扩展字段',
valueType: 'split',
},
];
res?.data?.dataList?.forEach((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
dataIndex: el.id,
key: el.id,
});
});
setnewfieldscolumns(columns.concat(column));
}
};
fn();
}, []);
return (
<>
<ProDescriptions
request={async () => {
const res = await doFetch({
url: urlParams.detail,
params: { id: drawer?.item?.id },
});
let obj = {};
res?.data?.data[equipmentCharList]?.forEach((it) => {
obj[it?.fieldId] = it?.fieldRealValue;
});
console.log('drawerpro:', {
...(res?.data?.data ?? {}),
...obj,
});
return {
success: true,
data:
{
...(res?.data?.data ?? {}),
...obj,
} ?? {},
};
}}
columns={newfieldscolumns}
/> />
<Divider /> <Divider />
<h3 className="page-title">扩展字段</h3> <h3 className="page-title">扩展字段</h3>
...@@ -1932,51 +2016,6 @@ function Model(props) { ...@@ -1932,51 +2016,6 @@ function Model(props) {
}, },
]} ]}
/> />
{/* <Space style={{ marginTop: 16 }}>
<Button
onClick={() => {
console.log(drawer);
setDrawer((s) => ({
...s,
visible: false,
item: null,
detailpath: null,
params: null,
val: null,
onFinish: null,
}));
setSelectArr([]);
}}
>
取消
</Button>
<Button
type="primary"
onClick={async () => {
console.log(selectArr);
let res = await doFetch({
url: urlParams_childEquipment.save,
params: {
equipmentId: drawer?.item?.id,
childrenIdList: selectArr,
},
});
if (res.code === '0000') {
message.success('新增成功!');
setDrawer((s) => ({
...s,
visible: false,
item: null,
}));
setSelectArr([]);
actionRef.current.reload();
}
}}
>
提交
</Button>
</Space> */}
</> </>
); );
}; };
...@@ -2030,6 +2069,51 @@ function Model(props) { ...@@ -2030,6 +2069,51 @@ function Model(props) {
return <Resume />; return <Resume />;
case 'detail': case 'detail':
return <Detail />; return <Detail />;
case 'add':
return (
<ExtendField
setDrawer={setDrawer}
drawer={drawer}
actionRef={actionRef}
columns={columns}
urlParams={urlParams}
formId={'2'}
onFinish={async (vals) => {
let equipmentCharReqList = [];
for (let i in vals) {
if (!isNaN(Number(i))) {
equipmentCharReqList.push({
fieldId: i,
fieldRealValue: vals[i],
});
delete vals[i];
}
}
let params = {
...vals,
id: drawer?.title == '编辑' ? drawer?.item?.id : '',
equipmentCharReqList,
};
console.log(params, '!!!!');
let res = await doFetch({
url: urlParams.save,
params,
});
if (res.code === '0000') {
if (drawer?.title == '编辑') {
message.success('编辑成功!');
} else {
message.success('新增成功!');
}
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
}}
/>
);
default: default:
return null; return null;
} }
...@@ -2068,25 +2152,26 @@ function Model(props) { ...@@ -2068,25 +2152,26 @@ function Model(props) {
visible: true, visible: true,
item: null, item: null,
title: '新增', title: '新增',
val: 'add', val: 'only',
onFinish: async (vals) => { type: 'add',
console.log(vals); // onFinish: async (vals) => {
let params = { // console.log(vals);
...vals, // let params = {
}; // ...vals,
let res = await doFetch({ // };
url: urlParams.save, // let res = await doFetch({
params, // url: urlParams.save,
}); // params,
if (res.code === '0000') { // });
message.success('新增成功!'); // if (res.code === '0000') {
setDrawer((s) => ({ // message.success('新增成功!');
...s, // setDrawer((s) => ({
visible: false, // ...s,
})); // visible: false,
actionRef.current.reload(); // }));
} // actionRef.current.reload();
}, // }
// },
})); }));
}, },
}, },
......
import { doFetch } from '@/utils/doFetch'; import { doFetch } from '@/utils/doFetch';
import { Image } from 'antd'; import { Image } from 'antd';
import fieldsDetail from '@/utils/fieldsDetail';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
function getcolumns(setdrawer) { function getcolumns(setdrawer) {
return [ return [
...@@ -19,9 +20,137 @@ function getcolumns(setdrawer) { ...@@ -19,9 +20,137 @@ function getcolumns(setdrawer) {
render: (text, row) => { render: (text, row) => {
return ( return (
<a <a
onClick={async () => { // onClick={async () => {
let newfieldscolumns = []; // let newfieldscolumns = [];
const fieldscolumns = [ // const fieldscolumns = [
// {
// title: '用户名',
// dataIndex: 'username',
// key: 'username',
// },
// {
// title: '姓名',
// dataIndex: 'fullName',
// key: 'fullName',
// },
// { title: '手机号', dataIndex: 'telephone', key: 'telephone' },
// {
// title: '邮箱',
// dataIndex: 'mailNo',
// key: 'mailNo',
// },
// {
// title: '公司名称',
// dataIndex: 'organizationName',
// key: 'organizationId',
// },
// {
// title: '部门名称',
// dataIndex: 'departmentName',
// key: 'departmentId',
// },
// {
// title: '负责工厂',
// dataIndex: 'factoryNames',
// key: 'factoryNames',
// },
// {
// title: '负责车间',
// dataIndex: 'shopNames',
// key: 'shopNames',
// },
// {
// title: '负责工段',
// dataIndex: 'sectionName',
// key: 'sectionIdList',
// },
// {
// title: '负责产线',
// dataIndex: 'productionLines',
// key: 'productionLineIdList',
// },
// {
// title: '角色配置',
// dataIndex: 'roleNames',
// key: 'roleIdList',
// },
// {
// title: '直属领导',
// dataIndex: 'parentName',
// key: 'parentId',
// },
// {
// title: '状态',
// dataIndex: 'statusName',
// key: 'status',
// },
// ];
// 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',
// options,
// };
// default:
// break;
// }
// };
// let res = await doFetch({
// url: '/base/paFormField/queryList',
// params: {
// formId: '1',
// },
// });
// if (res?.data?.dataList) {
// let column = [
// {
// title: '扩展字段',
// valueType: 'split',
// },
// ];
// res?.data?.dataList?.forEach((el) => {
// column.push({
// ...selectValueType(el.fieldChar, el.valueList),
// title: el.fieldName,
// dataIndex: el.id,
// key: el.id,
// });
// });
// newfieldscolumns = fieldscolumns.concat(column);
// console.log('fieldscolumns', newfieldscolumns);
// }
// setdrawer((s) => ({
// ...s,
// visible: true,
// item: row,
// title: '详情',
// fields: newfieldscolumns,
// extendField: 'userCharList',
// detailpath: '/auth/sysUser/detail',
// params: { id: row.id },
// val: 'detail',
// title: row.fullName + '的详细信息',
// }));
// }}
onClick={() => {
fieldsDetail(
[
{ {
title: '用户名', title: '用户名',
dataIndex: 'username', dataIndex: 'username',
...@@ -83,69 +212,12 @@ function getcolumns(setdrawer) { ...@@ -83,69 +212,12 @@ function getcolumns(setdrawer) {
dataIndex: 'statusName', dataIndex: 'statusName',
key: 'status', key: 'status',
}, },
]; ],
const selectValueType = (type, options) => { setdrawer,
switch (type) { row,
case 1: '1',
return { '/auth/sysUser/detail',
valueType: 'input', );
};
case 2:
return {
valueType: 'select',
options,
};
case 3:
return {
valueType: 'radio',
options,
};
case 4:
return {
valueType: 'select',
options,
};
default:
break;
}
};
let res = await doFetch({
url: '/base/paFormField/queryList',
params: {
formId: '1',
},
});
if (res?.data?.dataList) {
let column = [
{
title: '扩展字段',
valueType: 'split',
},
];
res?.data?.dataList?.forEach((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
dataIndex: el.id,
key: el.id,
});
});
newfieldscolumns = fieldscolumns.concat(column);
console.log('fieldscolumns', newfieldscolumns);
}
setdrawer((s) => ({
...s,
visible: true,
item: row,
title: '详情',
fields: newfieldscolumns,
extendField: 'userCharList',
detailpath: '/auth/sysUser/detail',
params: { id: row.id },
val: 'detail',
title: row.fullName + '的详细信息',
}));
}} }}
> >
{row.fullName} {row.fullName}
...@@ -242,7 +314,7 @@ function getcolumns(setdrawer) { ...@@ -242,7 +314,7 @@ function getcolumns(setdrawer) {
{ {
title: '负责工段', title: '负责工段',
width: 120, width: 120,
dataIndex: 'sectionName', dataIndex: 'sectionNames',
align: 'center', align: 'center',
search: false, search: false,
key: 'sectionIdList', key: 'sectionIdList',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: Li Hanlin * @Author: Li Hanlin
* @Date: 2022-11-09 14:44:44 * @Date: 2022-11-09 14:44:44
* @Last Modified by: Li Hanlin * @Last Modified by: Li Hanlin
* @Last Modified time: 2022-11-30 16:42:10 * @Last Modified time: 2022-12-01 11:13:59
*/ */
import * as React from 'react'; import * as React from 'react';
...@@ -14,6 +14,7 @@ import InitForm from '@/components/InitForm'; ...@@ -14,6 +14,7 @@ import InitForm from '@/components/InitForm';
import getcolumns from './columns'; import getcolumns from './columns';
import { doFetch } from '@/utils/doFetch'; import { doFetch } from '@/utils/doFetch';
import { message, AutoComplete } from 'antd'; import { message, AutoComplete } from 'antd';
import ExtendField from '@/components/ExtendField';
function User(props) { function User(props) {
const actionRef = useRef(), const actionRef = useRef(),
...@@ -298,7 +299,51 @@ function User(props) { ...@@ -298,7 +299,51 @@ function User(props) {
}} }}
{...drawer} {...drawer}
> >
{drawer?.type == 'add' ? <Adduser /> : null} {drawer?.type == 'add' ? (
<ExtendField
setDrawer={setDrawer}
drawer={drawer}
actionRef={actionRef}
columns={columns}
formId={'1'}
urlParams={urlParams}
onFinish={async (vals) => {
let userCharReqList = [];
for (let i in vals) {
if (!isNaN(Number(i))) {
userCharReqList.push({
fieldId: i,
fieldRealValue: vals[i],
});
delete vals[i];
}
}
let params = {
...vals,
id: drawer?.title == '编辑' ? drawer?.item?.id : '',
userCharReqList,
};
delete params.shopId;
console.log(params, '!!!!');
let res = await doFetch({
url: urlParams.save,
params,
});
if (res.code === '0000') {
if (drawer?.title == '编辑') {
message.success('编辑成功!');
} else {
message.success('新增成功!');
}
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
}}
/>
) : null}
</DrawerPro> </DrawerPro>
</div> </div>
); );
......
import { doFetch } from './doFetch';
export default async (fieldscolumns, setdrawer, row, formId, detailpath) => {
let newfieldscolumns = [];
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',
options,
};
default:
break;
}
};
const selectextendField = (type) => {
switch (Number(type)) {
case 1:
return 'userCharList';
case 2:
return 'equipmentCharList';
case 3:
return 'equipmentSupplierCharList';
default:
break;
}
};
let res = await doFetch({
url: '/base/paFormField/queryList',
params: {
formId,
},
});
if (res?.data?.dataList) {
let column = [
{
title: '扩展字段',
valueType: 'split',
},
];
res?.data?.dataList?.forEach((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
dataIndex: el.id,
key: el.id,
});
});
newfieldscolumns = fieldscolumns.concat(column);
console.log('fieldscolumns', newfieldscolumns);
}
setdrawer((s) => ({
...s,
visible: true,
item: row,
title: '详情',
fields: newfieldscolumns,
extendField: selectextendField(formId),
detailpath,
params: { id: row.id },
val: 'detail',
title: row.fullName + '的详细信息',
}));
};
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