Commit 124df178 authored by TZW's avatar TZW

1129

parent 7f8afc0d
/* 扩展字段内容
* @Author: Li Hanlin
* @Date: 2022-11-29 14:03:07
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-11-29 16:28:29
*/
import { doFetch } from '@/utils/doFetch';
import { useRequest } from 'ahooks';
import { useState, useEffect } from 'react';
import InitForm from '../InitForm';
export default ({ formId }) => {
const [columns, setcolumns] = useState([]);
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,
},
});
if (res?.data?.dataList) {
let column = [];
res?.data?.dataList?.forEach((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueType),
title: el.fieldName,
dataIndex: 'title',
key: el.id,
});
});
console.log('11111', column);
setcolumns(column);
}
};
fn();
}, []);
return (
<>
<InitForm fields={columns} />
</>
);
};
...@@ -12,6 +12,7 @@ import moment from 'moment'; ...@@ -12,6 +12,7 @@ import moment from 'moment';
import { doFetch } from '@/utils/doFetch'; import { doFetch } from '@/utils/doFetch';
import styles from './index.less'; import styles from './index.less';
import FormItems from './FormItems'; import FormItems from './FormItems';
import ExtendField from '@/components/ExtendField';
function upperCase(str) { function upperCase(str) {
const newStr = str.slice(0, 1).toUpperCase() + str.slice(1); const newStr = str.slice(0, 1).toUpperCase() + str.slice(1);
...@@ -93,6 +94,7 @@ function InitForm({ ...@@ -93,6 +94,7 @@ function InitForm({
defaultFormValue = {}, defaultFormValue = {},
submitter, submitter,
fields, fields,
extendField = '',
colProps = { xs: 24, sm: 24, md: 12, lg: 12, xl: 12, xxl: 12 }, colProps = { xs: 24, sm: 24, md: 12, lg: 12, xl: 12, xxl: 12 },
}) { }) {
let proformRef = useRef(); let proformRef = useRef();
...@@ -117,6 +119,18 @@ function InitForm({ ...@@ -117,6 +119,18 @@ function InitForm({
...(res?.data?.data ?? {}), ...(res?.data?.data ?? {}),
...defaultFormValue, ...defaultFormValue,
}); });
if (extendField) {
let obj = {};
res?.data?.data[extendField]?.forEach((it) => {
obj[it?.fieldId] = it?.fieldRealValue;
});
console.log('extendField:', obj);
return {
...(res?.data?.data ?? {}),
...obj,
...defaultFormValue,
};
}
return { return {
...(res?.data?.data ?? {}), ...(res?.data?.data ?? {}),
...defaultFormValue, ...defaultFormValue,
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* @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-24 15:02:31 * @Last Modified time: 2022-11-29 18:04:45
*/ */
import * as React from 'react'; import * as React from 'react';
import { useState, useMemo, useRef, useCallback } from 'react'; import { useState, useMemo, useRef, useEffect, useCallback } from 'react';
import DrawerPro from '@/components/DrawerPro'; 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';
...@@ -61,11 +61,10 @@ function User(props) { ...@@ -61,11 +61,10 @@ function User(props) {
setDrawer((s) => ({ setDrawer((s) => ({
...s, ...s,
visible: true, visible: true,
// item: row, item: row,
detailpath: urlParams.detail, type: 'add',
params: { id: row.id },
title: '编辑', title: '编辑',
val: 'edit', val: 'only',
onFinish: async (vals) => { onFinish: async (vals) => {
console.log(1); console.log(1);
let params = { let params = {
...@@ -123,55 +122,115 @@ function User(props) { ...@@ -123,55 +122,115 @@ function User(props) {
); );
}; };
// const Adduser = () => { const Adduser = () => {
// const [value, setValue] = useState(''); const [value, setValue] = useState('');
// const [options, setOptions] = useState([]); const [options, setOptions] = useState([]);
// const debounce = lodash.debounce; const [fieldscolumns, setfieldscolumns] = useState(columns);
// const serchHandle = useCallback( const selectValueType = (type, options) => {
// debounce(async (val) => { switch (type) {
// console.log(val + '!!'); case 1:
// if (val) { return {
// let res = await doFetch({ valueType: 'input',
// url: '/auth/sysUser/queryLikeIotUsername', };
// params: { username: val }, case 2:
// }); return {
// console.log(res); valueType: 'select',
// } options,
// }, 800), };
// [], case 3:
// ); return {
// const onSearch = (val) => { valueType: 'radio',
// serchHandle(val); options,
// }; };
// const onSelect = (data) => { case 4:
// console.log('onSelect', data); return {
// }; valueType: 'select',
// const onChange = (data) => { options,
// setValue(data); };
// }; default:
// return ( break;
// <> }
// <div style={{ marginBottom: 22 }}> };
// <div style={{ marginBottom: 8 }}>用户名</div>
// <AutoComplete useEffect(() => {
// options={options} const fn = async () => {
// style={{ let res = await doFetch({
// width: '50%', url: '/base/paFormField/queryList',
// }} params: {
// onSelect={onSelect} formId: '1',
// onSearch={onSearch} },
// placeholder="请输入用户名" });
// /> if (res?.data?.dataList) {
// </div> let column = [
// <InitForm {
// fields={columns} title: '扩展字段',
// onFinish={() => { valueType: 'split',
// console.log(1); },
// }} ];
// /> res?.data?.dataList?.forEach((el) => {
// </> column.push({
// ); ...selectValueType(el.fieldChar, el.valueType),
// }; title: el.fieldName,
dataIndex: el.fieldName,
key: el.id,
});
});
console.log('11111', column);
setfieldscolumns(fieldscolumns.concat(column));
}
};
fn();
}, []);
return (
<>
<InitForm
extendField="userCharList"
detailpath={urlParams.detail}
params={{ id: drawer?.item?.id }}
fields={fieldscolumns}
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,
factoryIdList: vals.factoryNames,
shopIdList: vals.shopId,
sectionIdList: vals.sectionId,
productionLineIdList: vals.productLineName,
roleIdList: vals.roleNames,
userCharReqList,
};
delete params.factoryNames;
delete params.shopId;
delete params.sectionId;
delete params.productLineName;
delete params.roleNames;
console.log(params, '!!!!');
let res = await doFetch({
url: urlParams.save,
params,
});
if (res.code === '0000') {
message.success('新增成功!');
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
}}
/>
</>
);
};
const columns = useMemo(() => { const columns = useMemo(() => {
let defcolumn = getcolumns(setDrawer); let defcolumn = getcolumns(setDrawer);
...@@ -204,40 +263,11 @@ function User(props) { ...@@ -204,40 +263,11 @@ function User(props) {
item: { item: {
status: 1, status: 1,
}, },
detailpath: null, detailpath: '',
params: {},
title: '新增', title: '新增',
// type: 'add', type: 'add',
val: 'add', val: 'only',
onFinish: async (vals) => {
console.log(vals);
let params = {
...vals,
factoryIdList: vals.factoryNames,
shopIdList: vals.shopId,
sectionIdList: vals.sectionId,
productionLineIdList: vals.productLineName,
roleIdList: vals.roleNames,
userCharReqList: [],
};
delete params.factoryNames;
delete params.shopId;
delete params.sectionId;
delete params.productLineName;
delete params.roleNames;
console.log(params, '!!!!');
let res = await doFetch({
url: urlParams.save,
params,
});
if (res.code === '0000') {
message.success('新增成功!');
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
},
})); }));
}, },
}, },
...@@ -259,7 +289,7 @@ function User(props) { ...@@ -259,7 +289,7 @@ function User(props) {
}} }}
{...drawer} {...drawer}
> >
{/* {drawer?.type == 'add' ? <Adduser /> : null} */} {drawer?.type == 'add' ? <Adduser /> : null}
</DrawerPro> </DrawerPro>
</div> </div>
); );
......
function getcolumns(setdrawer) { function getcolumns(setdrawer) {
return [ return [
{ title: '单号类型', dataIndex: 'noTypeName', key: 'noTypeId' }, {
title: '单号类型',
dataIndex: 'noTypeName',
key: 'noTypeId',
valueType: 'select',
options: { path: '/base/bmNoType/queryAllSelect', params: {} },
formItemProps: {
rules: [
{
required: false,
message: '此项为必填项',
},
],
},
},
{ {
title: '预览', title: '预览',
dataIndex: 'ruleNames', dataIndex: 'ruleNames',
......
...@@ -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-28 17:56:41 * @Last Modified time: 2022-11-29 10:02:24
*/ */
import * as React from 'react'; import * as React from 'react';
...@@ -33,7 +33,6 @@ function Rules(props) { ...@@ -33,7 +33,6 @@ function Rules(props) {
<PremButton <PremButton
btn={{ btn={{
size: 'small', size: 'small',
type: 'link',
onClick: () => { onClick: () => {
setDrawer((s) => ({ setDrawer((s) => ({
...s, ...s,
...@@ -135,6 +134,7 @@ function Rules(props) { ...@@ -135,6 +134,7 @@ function Rules(props) {
<AutoTable <AutoTable
pagetitle={<h3 className="page-title">编号规则</h3>} pagetitle={<h3 className="page-title">编号规则</h3>}
columns={columns} columns={columns}
pagination={false}
path={urlParams.list} path={urlParams.list}
actionRef={actionRef} actionRef={actionRef}
pageextra={'add'} pageextra={'add'}
......
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