Commit 908e661a authored by TZW's avatar TZW

12011420

parent 8e4441b6
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-11-29 14:03:07
* @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';
......@@ -10,8 +10,9 @@ import { useRequest } from 'ahooks';
import { useState, useEffect } from 'react';
import InitForm from '../InitForm';
export default ({ formId }) => {
const [columns, setcolumns] = useState([]);
const App = ({ setDrawer, onFinish, drawer, actionRef, columns, urlParams, formId }) => {
const [value, setValue] = useState('');
const [fieldscolumns, setfieldscolumns] = useState(columns);
const selectValueType = (type, options) => {
switch (type) {
case 1:
......@@ -43,29 +44,53 @@ export default ({ formId }) => {
let res = await doFetch({
url: '/base/paFormField/queryList',
params: {
formId,
formId: formId,
},
});
if (res?.data?.dataList) {
let column = [];
let column = [
{
title: '扩展字段',
valueType: 'split',
},
];
res?.data?.dataList?.forEach((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueType),
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
dataIndex: 'title',
dataIndex: el.fieldName,
key: el.id,
});
});
console.log('11111', column);
setcolumns(column);
setfieldscolumns(fieldscolumns.concat(column));
}
};
fn();
}, []);
const selectextendField = (type) => {
switch (Number(type)) {
case 1:
return 'userCharList';
case 2:
return 'equipmentCharList';
case 3:
return 'equipmentSupplierCharList';
default:
break;
}
};
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 @@
* @Author: Li Hanlin
* @Date: 2022-11-10 09:39:56
* @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';
......@@ -16,6 +16,7 @@ import { message, Dropdown, Menu, Layout, Button, Image, Space, Divider, Tabs }
import TreeRender from '@/components/TreeRender';
import { ProDescriptions } from '@ant-design/pro-components';
import InitForm from '@/components/InitForm';
import ExtendField from '@/components/ExtendField';
const { Sider, Content } = Layout;
......@@ -474,28 +475,42 @@ function Model(props) {
...s,
visible: true,
title: '编辑',
val: 'edit',
detailpath: urlParams.detail,
params: { id: row.id },
onFinish: async (vals) => {
console.log(1);
let params = {
...vals,
id: row.id,
};
let res = await doFetch({
url: urlParams.save,
params,
});
if (res.code === '0000') {
message.success('编辑成功!');
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
},
val: 'only',
type: 'add',
item: row,
// detailpath: urlParams.detail,
// params: { id: row.id },
// onFinish: async (vals) => {
// console.log(1);
// let equipmentCharList = [];
// console.log('id:', row.id);
// for (let i in vals) {
// if (!isNaN(Number(i))) {
// equipmentCharList.push({
// fieldId: i,
// fieldRealValue: vals[i],
// });
// delete vals[i];
// }
// }
// let params = {
// ...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) {
const [activeTab, setactiveTab] = useState(1);
// 基础信息
const BaseInfo = () => {
return (
<>
<ProDescriptions
request={async () => {
const { data } = await doFetch({
url: urlParams.detail,
params: { id: drawer?.item?.id },
});
return {
success: true,
data: data?.data,
};
}}
columns={[
const columns = [
{
title: '设备编号',
dataIndex: 'equipmentNo',
......@@ -743,7 +745,89 @@ function Model(props) {
key: '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 />
<h3 className="page-title">扩展字段</h3>
......@@ -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) {
return <Resume />;
case '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:
return null;
}
......@@ -2068,25 +2152,26 @@ function Model(props) {
visible: true,
item: null,
title: '新增',
val: 'add',
onFinish: async (vals) => {
console.log(vals);
let params = {
...vals,
};
let res = await doFetch({
url: urlParams.save,
params,
});
if (res.code === '0000') {
message.success('新增成功!');
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
},
val: 'only',
type: 'add',
// onFinish: async (vals) => {
// console.log(vals);
// let params = {
// ...vals,
// };
// let res = await doFetch({
// url: urlParams.save,
// params,
// });
// if (res.code === '0000') {
// message.success('新增成功!');
// setDrawer((s) => ({
// ...s,
// visible: false,
// }));
// actionRef.current.reload();
// }
// },
}));
},
},
......
import { doFetch } from '@/utils/doFetch';
import { Image } from 'antd';
import fieldsDetail from '@/utils/fieldsDetail';
import { useState, useEffect } from 'react';
function getcolumns(setdrawer) {
return [
......@@ -19,9 +20,137 @@ function getcolumns(setdrawer) {
render: (text, row) => {
return (
<a
onClick={async () => {
let newfieldscolumns = [];
const fieldscolumns = [
// onClick={async () => {
// let newfieldscolumns = [];
// 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: '用户名',
dataIndex: 'username',
......@@ -83,69 +212,12 @@ function getcolumns(setdrawer) {
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 + '的详细信息',
}));
],
setdrawer,
row,
'1',
'/auth/sysUser/detail',
);
}}
>
{row.fullName}
......@@ -242,7 +314,7 @@ function getcolumns(setdrawer) {
{
title: '负责工段',
width: 120,
dataIndex: 'sectionName',
dataIndex: 'sectionNames',
align: 'center',
search: false,
key: 'sectionIdList',
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-11-09 14:44:44
* @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';
......@@ -14,6 +14,7 @@ import InitForm from '@/components/InitForm';
import getcolumns from './columns';
import { doFetch } from '@/utils/doFetch';
import { message, AutoComplete } from 'antd';
import ExtendField from '@/components/ExtendField';
function User(props) {
const actionRef = useRef(),
......@@ -298,7 +299,51 @@ function User(props) {
}}
{...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>
</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