Commit 2f5a7431 authored by TZW's avatar TZW

1115

parent 907b28a4
import { Image } from 'antd';
function getcolumns(setdrawer) { function getcolumns(setdrawer) {
return [ return [
{ {
title: '基础信息', title: '设备编号',
valueType: 'split', dataIndex: 'equipmentNo',
key: 'equipmentNo',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
}, },
{ {
title: '用户名', title: '设备名称',
dataIndex: 'accountName', dataIndex: 'equipmentName',
formItemProps: { key: 'equipmentName',
rules: [ formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
{
required: false,
message: '此项为必填项',
},
],
},
initialValue: '默认值',
hideInForm: false,
search: false,
render: (text, row) => {
return (
<a
onClick={() => {
setdrawer?.((s) => ({
...s,
visible: true,
item: null,
title: '新增',
val: 'add',
}));
}}
>
{text}
</a>
);
},
}, },
{ title: '位置号', dataIndex: 'positionNo', key: 'positionNo' },
{ {
title: '姓名', title: '设备类型',
dataIndex: 'userName', dataIndex: 'equipmentTypeName',
key: 'userId', key: 'equipmentTypeName',
hideInForm: { valueType: 'treeSelect',
accountName: { options: { path: '/asset/equipmentType/queryTreeList', params: {} },
reverse: ['1', '2', '5'], formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
remark: ['3'],
},
search: false,
}, },
{ {
title: '额外信息', title: '设备型号',
valueType: 'split', dataIndex: 'equipmentModelName',
key: 'equipmentModelName',
valueType: 'select',
options: { path: '/asset/equipmentModel/query/selection', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
}, },
{ {
title: '联系电话', title: '公司名称',
dataIndex: 'telephone', dataIndex: 'organizationName',
formItemProps: { key: 'organizationName',
rules: [ valueType: 'select',
{ options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
required: false, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
message: '此项为必填项',
},
],
},
search: false,
}, },
{ {
title: '邮箱', title: '工厂名称',
dataIndex: 'mailNo', dataIndex: 'factoryName',
formItemProps: { key: 'factoryName',
rules: [ valueType: 'select',
{ options: { path: '/auth/sysDepartment/query/depart/selectbox', params: {} },
required: false, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
message: '此项为必填项',
},
],
},
search: false,
}, },
{ title: '部门名称', dataIndex: 'departmentName', key: 'departmentName' },
{ {
title: '备注', title: '车间名称',
dataIndex: 'remark', dataIndex: 'shopName',
valueType: 'editor', key: 'shopName',
search: false, formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
colProps: { span: 24 },
initialValue: '<p>Hello <b>World!</b></p>',
}, },
{ title: '工段名称', dataIndex: 'sectionName', key: 'sectionName' },
{ title: '产线名称', dataIndex: 'productLineName', key: 'productLineName' },
{ title: '供应商', dataIndex: 'supplierName', key: 'supplierName' },
{ title: '设备原值(万元)', dataIndex: 'equipmentWorth', key: 'equipmentWorth' },
{ {
title: '上传样式-图片', title: '图片地址',
dataIndex: 'uploadImage', width: 100,
key: 'uploadImage', dataIndex: 'pictureUrl',
search: false,
key: 'picList',
valueType: 'uploadImage', valueType: 'uploadImage',
fieldProps: { fieldProps: {
limit: 2, limit: 1,
}, },
formItemProps: { formItemProps: {
rules: [ rules: [
{ {
required: false, required: true,
message: '此项为必填项', message: '此项为必填项',
}, },
], ],
}, },
render: (text, row) => <Image width={70} src={row.pictureUrl} />,
},
{
title: '二维码',
width: 80,
dataIndex: 'qrCodeUrl',
key: 'qrCodeUrl',
valueType: 'uploadImage',
search: false,
hideInForm: true,
render: (text, row) => <Image width={70} src={row.pictureUrl} />,
}, },
{ title: '状态名称', fixed: 'right', dataIndex: 'statusName', key: 'statusName' },
{ title: '设备状态', fixed: 'right', dataIndex: 'status', key: 'status' },
]; ];
} }
......
...@@ -2,27 +2,35 @@ ...@@ -2,27 +2,35 @@
* @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-15 13:29:58 * @Last Modified time: 2022-11-15 17:14:29
*/ */
import * as React from 'react'; import * as React from 'react';
import { useState, useMemo, useRef } from 'react'; import { useState, useMemo, useRef } 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';
import getcolumns from './columns'; import getcolumns from './columns';
import TreeRender from '@/components/TreeRender'; import { doFetch } from '@/utils/doFetch';
import { message } from 'antd';
import { Layout } from 'antd'; import { Layout } from 'antd';
import TreeRender from '@/components/TreeRender';
const { Sider, Content } = Layout; const { Sider, Content } = Layout;
function Account(props) { function Model(props) {
const actionRef = useRef(), const actionRef = useRef(),
formRef = useRef(); formRef = useRef();
const [drawer, setdrawer] = useState({ const [drawer, setDrawer] = useState({
visible: false, visible: false,
}); });
const urlParams = {
save: '/asset/equipmentModel/save',
remove: '/asset/equipment/deleteById',
list: '/asset/equipment/queryList',
detail: '/asset/equipmentModel/queryById',
};
const detail = (text, row, _, action) => { const detail = (text, row, _, action) => {
return ( return (
<PremButton <PremButton
...@@ -30,7 +38,7 @@ function Account(props) { ...@@ -30,7 +38,7 @@ function Account(props) {
size: 'small', size: 'small',
type: 'link', type: 'link',
onClick: () => { onClick: () => {
setdrawer((s) => ({ setDrawer((s) => ({
...s, ...s,
visible: true, visible: true,
item: row, item: row,
...@@ -52,12 +60,32 @@ function Account(props) { ...@@ -52,12 +60,32 @@ function Account(props) {
btn={{ btn={{
size: 'small', size: 'small',
onClick: () => { onClick: () => {
setdrawer((s) => ({ setDrawer((s) => ({
...s, ...s,
visible: true, visible: true,
item: row,
title: '编辑', title: '编辑',
val: 'edit', 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();
}
},
})); }));
}, },
}} }}
...@@ -71,11 +99,19 @@ function Account(props) { ...@@ -71,11 +99,19 @@ function Account(props) {
return ( return (
<PremButton <PremButton
pop={{ pop={{
title: '是否删除该用户?', title: '是否删除该设备?',
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onConfirm: () => { onConfirm: async () => {
alert(0); let res = await doFetch({ url: urlParams.remove, params: { id: row.id } });
if (res.code === '0000') {
message.success('删除成功!');
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
}, },
}} }}
btn={{ btn={{
...@@ -89,16 +125,12 @@ function Account(props) { ...@@ -89,16 +125,12 @@ function Account(props) {
}; };
const columns = useMemo(() => { const columns = useMemo(() => {
let defcolumn = getcolumns(setdrawer); let defcolumn = getcolumns(setDrawer);
return defcolumn.concat({ return defcolumn.concat({
title: '操作', title: '操作',
valueType: 'option', valueType: 'option',
width: 150, width: 150,
render: (text, row, _, action) => [ render: (text, row, _, action) => [edit(text, row, _, action), remove(text, row, _, action)],
detail(text, row, _, action),
edit(text, row, _, action),
remove(text, row, _, action),
],
}); });
}, []); }, []);
...@@ -119,7 +151,7 @@ function Account(props) { ...@@ -119,7 +151,7 @@ function Account(props) {
<AutoTable <AutoTable
pagetitle={<h3 style={{ marginBottom: 0, fontWeight: 400 }}>设备台账</h3>} pagetitle={<h3 style={{ marginBottom: 0, fontWeight: 400 }}>设备台账</h3>}
columns={columns} columns={columns}
path="/ngic-auth/sysUser/query/page" path={urlParams.list}
actionRef={actionRef} actionRef={actionRef}
pageextra={'add'} pageextra={'add'}
resizeable={true} resizeable={true}
...@@ -160,4 +192,4 @@ function Account(props) { ...@@ -160,4 +192,4 @@ function Account(props) {
); );
} }
export default Account; export default Model;
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