Commit 7120c0d2 authored by TZW's avatar TZW

12011738

parent c89192a7
......@@ -27,7 +27,7 @@ export default (props) => {
),
};
//右上角 pageextra 类型 1.reactDom 2.string 以逗号隔开 为none时不显示
//右上角 extra 类型 1.reactDom 2.string 以逗号隔开 为none时不显示
const renderextra = () => {
if (props.pageextra && !isString(props.pageextra)) {
if (typeof props?.pageextra == 'function') {
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-11-10 09:39:56
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-01 15:05:17
* @Last Modified time: 2022-12-01 16:49:23
*/
import * as React from 'react';
......
import { doFetch } from '@/utils/doFetch';
import { Switch } from 'antd';
import fieldsDetail from '@/utils/fieldsDetail';
function getcolumns(setdrawer) {
return [
{
title: '供应商编号',
dataIndex: 'supplierNo',
key: 'supplierNo',
width: 120,
},
{
title: '供应商名称',
dataIndex: 'supplierName',
key: 'supplierName',
width: 150,
formItemProps: {
rules: [
{
......@@ -65,7 +69,7 @@ function getcolumns(setdrawer) {
title: '地址',
dataIndex: 'address',
key: 'address',
width: 300,
width: 320,
formItemProps: {
rules: [
{
......@@ -126,6 +130,7 @@ function getcolumns(setdrawer) {
title: '评分',
dataIndex: 'score',
key: 'score',
width: 50,
valueType: 'rate',
fieldProps: {
defaultValue: 1,
......
......@@ -2,17 +2,20 @@
* @Author: Li Hanlin
* @Date: 2022-11-09 14:44:44
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-11-23 15:43:57
* @Last Modified time: 2022-12-01 17:13:05
*/
import * as React from 'react';
import { useState, useMemo, useRef } from 'react';
import { useState, useMemo, useEffect, useRef } from 'react';
import DrawerPro from '@/components/DrawerPro';
import AutoTable from '@/components/AutoTable';
import PremButton from '@/components/PremButton';
import getcolumns from './columns';
import InitForm from '@/components/InitForm';
import ExtendField from '@/components/ExtendField';
import { doFetch } from '@/utils/doFetch';
import { message } from 'antd';
import { Image, message, Divider } from 'antd';
import { ProDescriptions } from '@ant-design/pro-components';
function Supplier(props) {
const actionRef = useRef(),
......@@ -29,29 +32,6 @@ function Supplier(props) {
detail_nocp: '/asset/equipmentSupplier/queryById',
};
const detail = (text, row, _, action) => {
return (
<PremButton
btn={{
size: 'small',
type: 'link',
onClick: () => {
setDrawer((s) => ({
...s,
visible: true,
item: row,
title: '详情',
val: 'detail',
title: row.userName + '的详细信息',
}));
},
}}
>
详情
</PremButton>
);
};
const edit = (text, row, _, action) => {
return (
<PremButton
......@@ -64,13 +44,27 @@ function Supplier(props) {
detailpath: urlParams.detail,
params: { id: row?.id },
title: '编辑',
val: 'edit',
val: 'only',
type: 'add',
onFinish: async (vals) => {
console.log(1);
let equipmentSupplierCharReqList = [];
console.log('id:', row.id);
for (let i in vals) {
if (!isNaN(Number(i))) {
equipmentSupplierCharReqList.push({
fieldId: i,
fieldRealValue: vals[i],
});
delete vals[i];
}
}
let params = {
...vals,
id: row.id,
id: row?.id,
shopIdList: vals.shopId,
equipmentSupplierCharReqList,
};
delete params.shopId;
let res = await doFetch({
url: urlParams.save,
params,
......@@ -121,7 +115,189 @@ function Supplier(props) {
</PremButton>
);
};
const Details = () => {
const columns = [
{
title: '供应商编号',
dataIndex: 'supplierNo',
key: 'supplierNo',
},
{
title: '供应商名称',
dataIndex: 'supplierName',
key: 'supplierName',
},
{ title: '公司官网', dataIndex: 'officialWebsite', key: 'officialWebsite' },
{
title: '联系电话',
dataIndex: 'telephone',
key: 'telephone',
},
{
title: '公司邮箱',
dataIndex: 'email',
key: 'email',
},
{
title: '地址',
dataIndex: 'address',
key: 'address',
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
},
{
title: '评分',
dataIndex: 'score',
key: 'score',
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark',
},
];
const [newfieldscolumns, setnewfieldscolumns] = 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;
}
};
const [request, setrequest] = useState();
useEffect(() => {
const fn = async () => {
let res = await doFetch({
url: '/base/paFormField/queryList',
params: {
formId: '3',
},
});
if (res?.data?.dataList) {
let column = [];
res?.data?.dataList?.forEach((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
dataIndex: el.id,
key: el.id,
});
});
setnewfieldscolumns(column);
}
},
fn2 = async () => {
const res = await doFetch({
url: urlParams.detail,
params: { id: drawer?.item?.id },
});
console.log(res?.data?.data);
let obj = {};
res?.data?.data['equipmentSupplierCharReqList']?.forEach((it) => {
obj[it?.fieldId] = it?.fieldRealValue;
});
console.log('drawerpro:', {
...(res?.data?.data ?? {}),
...obj,
});
setrequest(
{
...(res?.data?.data ?? {}),
...obj,
} ?? {},
);
};
fn();
fn2();
}, []);
return (
<>
<ProDescriptions dataSource={request} columns={columns} />
<AutoTable
pagetitle="联系信息"
columns={[
{
title: '联系人',
dataIndex: 'userName',
key: 'userName',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
title: '手机号码',
dataIndex: 'telephone',
key: 'telephone',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
title: '邮箱',
dataIndex: 'email',
key: 'email',
},
{
title: '职务',
dataIndex: 'title',
key: 'title',
fieldProps: {
placeholder: '请选择',
},
formItemProps: {
rules: [
{
required: false,
message: '此项为必填项',
},
],
},
},
]}
dataSource={request?.supplierUserList}
resizeable={false}
pagination={false}
/>
<Divider />
<h3 className="page-title" style={{ marginBottom: 16 }}>
扩展字段
</h3>
<ProDescriptions dataSource={request} columns={newfieldscolumns} />
</>
);
};
const columns = useMemo(() => {
let defcolumn = getcolumns(setDrawer);
defcolumn[1].render = (text, row) => {
......@@ -131,11 +307,10 @@ function Supplier(props) {
setDrawer((s) => ({
...s,
visible: true,
title: '查看详情',
fields: columns,
val: 'detail',
detailpath: urlParams.detail,
params: { id: row.id },
type: 'detail',
item: row,
val: 'only',
title: row.supplierName + '的详细信息',
}));
}}
>
......@@ -151,6 +326,59 @@ function Supplier(props) {
});
}, []);
const selectMoreDrawerType = (type) => {
switch (type) {
case 'detail':
return <Details />;
case 'add':
return (
<ExtendField
setDrawer={setDrawer}
drawer={drawer}
actionRef={actionRef}
columns={columns}
formId={'3'}
urlParams={urlParams}
onFinish={async (vals) => {
let equipmentSupplierCharReqList = [];
for (let i in vals) {
if (!isNaN(Number(i))) {
equipmentSupplierCharReqList.push({
fieldId: i,
fieldRealValue: vals[i],
});
delete vals[i];
}
}
let params = {
...vals,
id: drawer?.title == '编辑' ? drawer?.item?.id : '',
equipmentSupplierCharReqList,
};
delete params.shopId;
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;
}
};
return (
<div style={{ position: 'relative' }}>
<AutoTable
......@@ -174,24 +402,8 @@ function Supplier(props) {
},
title: '新增',
detailpath: null,
val: 'add',
onFinish: async (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();
}
},
type: 'add',
val: 'only',
}));
},
},
......@@ -211,7 +423,9 @@ function Supplier(props) {
actionRef.current.reload();
}}
{...drawer}
/>
>
{selectMoreDrawerType(drawer?.type)}
</DrawerPro>
</div>
);
}
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-11-09 14:44:44
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-01 11:13:59
* @Last Modified time: 2022-12-01 15:10:22
*/
import * as React from 'react';
......@@ -136,112 +136,6 @@ function User(props) {
);
};
const Adduser = () => {
const [value, setValue] = useState('');
const [fieldscolumns, setfieldscolumns] = 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: '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.fieldName,
key: el.id,
});
});
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,
id: drawer?.title == '编辑' ? drawer?.item?.id : '',
shopIdList: vals.shopId,
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();
}
}}
/>
</>
);
};
const columns = useMemo(() => {
let defcolumn = getcolumns(setDrawer);
return defcolumn.concat({
......
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