Commit 79c1e48d authored by TZW's avatar TZW

1117

parent 7249b9d6
......@@ -295,12 +295,14 @@ function TreeRender({ url, deleteurl, saveurl, onselected, params, noaction, max
key: item.key,
children: loop(item.children),
level: item.level,
type: item.type,
};
}
return {
title: noaction ? title : actiontitle,
key: item.key,
level: item.level,
type: item.type,
};
});
useEffect(() => {
......
......@@ -209,9 +209,9 @@ function getcolumns(setdrawer) {
switch (row.status) {
case 1:
return <Tag color="success">在用</Tag>;
case 2:
return <Tag>报废</Tag>;
case 3:
return <Tag>报废</Tag>;
case 2:
return <Tag color="volcano">借用中</Tag>;
default:
break;
......
......@@ -2,18 +2,19 @@
* @Author: Li Hanlin
* @Date: 2022-11-10 09:39:56
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-11-16 17:19:50
* @Last Modified time: 2022-11-17 17:25:54
*/
import * as React from 'react';
import { useState, useMemo, useRef } from 'react';
import { useState, useMemo, useRef, useEffect } from 'react';
import DrawerPro from '@/components/DrawerPro';
import AutoTable from '@/components/AutoTable';
import PremButton from '@/components/PremButton';
import getcolumns from './columns';
import { doFetch } from '@/utils/doFetch';
import { message, Dropdown, Menu, Layout, Button } from 'antd';
import { message, Dropdown, Menu, Layout, Button, Space } from 'antd';
import TreeRender from '@/components/TreeRender';
import { ProDescriptions } from '@ant-design/pro-components';
const { Sider, Content } = Layout;
function Model(props) {
......@@ -30,6 +31,12 @@ function Model(props) {
detail: '/asset/equipment/detail',
};
const urlParams_childEquipment = {
list: '/asset/equipment/children/queryList',
checked: '/asset/equipment/children/selected/queryList',
save: '/asset/equipmentChildren/save',
};
const detail = (text, row, _, action) => {
return (
<PremButton
......@@ -134,10 +141,32 @@ function Model(props) {
setDrawer((s) => ({
...s,
visible: true,
item: row,
type: 'editChildEquipment',
item: {
id: row.id,
},
title: '详情',
val: 'only',
title: '编辑子设备',
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();
}
},
}));
}}
>
......@@ -173,6 +202,253 @@ function Model(props) {
);
};
const EditChildEquipment = () => {
const [selectArr, setSelectArr] = useState([]);
useEffect(() => {
const fun = async () => {
const result = await doFetch({
url: '/asset/equipment/children/selected/queryList',
params: { id: drawer?.item?.id },
});
// console.log(result);
if (!result?.data?.dataList.length == 0) {
setSelectArr(result?.data?.dataList.map((it) => it.id));
}
};
fun();
}, []);
const columns = [
{
title: '设备编号',
dataIndex: 'equipmentNo',
key: 'equipmentNo',
align: 'center',
width: 120,
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '设备名称',
dataIndex: 'equipmentName',
align: 'center',
width: 120,
key: 'equipmentName',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '公司名称',
align: 'center',
dataIndex: 'organizationName',
width: 120,
key: 'organizationId',
valueType: 'select',
options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '部门名称',
width: 120,
align: 'center',
valueType: 'select',
dataIndex: 'departmentName',
key: 'departmentId',
options: {
path: '/auth/sysDepartment/query/depart/selectbox',
linkParams: {
organizationId: 'parentId',
},
},
},
{
title: '工厂名称',
dataIndex: 'factoryName',
key: 'factoryId',
width: 120,
align: 'center',
valueType: 'select',
options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '车间名称',
dataIndex: 'shopName',
align: 'center',
width: 120,
valueType: 'select',
options: {
path: '/auth/sysShop/getShopSelectionByFactory',
linkParams: {
factoryId: '',
},
},
key: 'shopId',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
},
{
title: '工段名称',
width: 120,
dataIndex: 'sectionName',
align: 'center',
key: 'sectionId',
valueType: 'select',
options: {
path: '/auth/sysSection/getAllSectionSelectionByShop',
linkParams: {
shopId: '',
},
},
},
{
title: '产线名称',
width: 120,
dataIndex: 'productLineName',
valueType: 'select',
key: 'productLineName',
align: 'center',
options: {
path: 'auth/sysProductionLine/getAllProductLineSelectionByShop',
linkParams: {
shopId: '',
},
},
},
];
return (
<>
<ProDescriptions
request={async () => {
const { data } = await doFetch({
url: urlParams.detail,
params: { id: drawer.item.id },
});
return {
success: true,
data: data.data,
};
}}
columns={[
{
title: '设备编号',
dataIndex: 'equipmentNo',
key: 'equipmentNo',
},
{
title: '设备名称',
dataIndex: 'equipmentName',
key: 'equipmentName',
},
{
title: '位置号',
dataIndex: 'positionNo',
key: 'positionNo',
},
{
title: '公司名称',
dataIndex: 'organizationName',
key: 'organizationId',
},
{
title: '部门名称',
dataIndex: 'departmentName',
key: 'departmentId',
},
{
title: '工厂名称',
dataIndex: 'factoryName',
key: 'factoryId',
},
{
title: '车间名称',
dataIndex: 'shopName',
key: 'shopId',
},
{
title: '工段名称',
dataIndex: 'sectionName',
key: 'sectionId',
},
{
title: '产线名称',
dataIndex: 'productLineName',
key: 'productLineName',
},
]}
/>
<AutoTable
pagetitle="选择子设备"
columns={columns}
path={urlParams_childEquipment.list}
params={{ id: drawer?.item?.id }}
resizeable={false}
rowSelection={{
type: 'checkbox',
selectedRowKeys: selectArr,
// defaultSelectedRowKeys: ,
onSelect: (record, selected, selectedRows, nativeEvent) => {
console.log('selectedRowKeys changed: ', record, selected, selectedRows);
setSelectArr(() => {
return selectedRows.map((it) => it.id);
});
},
onSelectAll: (selected, selectedRows, changeRows) => {
console.log(selected, selectedRows, changeRows);
if (selected) {
let arr = selectArr.concat(changeRows.map((it) => it.id));
setSelectArr(arr);
} else {
setSelectArr([]);
}
},
onSelectNone: () => {
console.log(11);
setSelectArr([]);
},
}}
/>
<Space style={{ marginTop: 16 }}>
<Button
onClick={() => {
setDrawer((s) => ({
...s,
visible: false,
item: null,
detailpath: null,
params: 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>
</>
);
};
const columns = useMemo(() => {
let defcolumn = getcolumns(setDrawer);
defcolumn[1].render = (text, row) => {
......@@ -208,6 +484,25 @@ function Model(props) {
});
}, []);
const onselecteTree = async (selectedKeys, e, alldata) => {
console.log(e.node);
let params = {
treeNodeType: e.node.type,
treeNodeKey: e.node.key,
pageSize: '15',
pageIndex: '1',
};
const res = await doFetch({ url: urlParams.list, params });
if (res.code === '0000') {
message.success('新增成功!');
setDrawer((s) => ({
...s,
visible: false,
}));
actionRef.current.reload();
}
};
return (
<div style={{ position: 'relative' }}>
<div className="ant-card-head">
......@@ -219,7 +514,7 @@ function Model(props) {
</div>
<Layout style={{ height: '100%' }}>
<Sider theme="light" width={300}>
<TreeRender url="/auth/sysFactory/getTree" onselected={() => {}} noaction={true} />
<TreeRender url="/auth/sysFactory/getTree" onselected={onselecteTree} noaction={true} />
</Sider>
<Content>
<AutoTable
......@@ -277,10 +572,15 @@ function Model(props) {
setDrawer((s) => ({
...s,
visible: false,
item: null,
detailpath: null,
params: null,
}));
}}
{...drawer}
/>
>
{drawer?.type == 'editChildEquipment' ? <EditChildEquipment /> : null}
</DrawerPro>
</div>
);
}
......
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