Commit 0b3c170b authored by TZW's avatar TZW

Merge branch 'master' of http://47.100.234.193:9527/wuhao/ems3.3

parents f1f9f22e bc16f269
...@@ -74,6 +74,7 @@ const EditTable = (props) => { ...@@ -74,6 +74,7 @@ const EditTable = (props) => {
if (Array.isArray(it.options)) { if (Array.isArray(it.options)) {
options = { options = {
fieldProps: { fieldProps: {
...it?.fieldProps,
options: [...it.options], options: [...it.options],
}, },
}; };
...@@ -141,20 +142,20 @@ const EditTable = (props) => { ...@@ -141,20 +142,20 @@ const EditTable = (props) => {
scroll={ scroll={
x x
? { ? {
x: x, x: x,
} }
: {} : {}
} }
pagination={ pagination={
ifspagination ifspagination
? false ? false
: { : {
showTotal: (total, range) => <span>{total}</span>, showTotal: (total, range) => <span>{total}</span>,
showQuickJumper: true, showQuickJumper: true,
showSizeChanger: true, showSizeChanger: true,
pageSizeOptions: [5, 10, 15, 30, 50, 100, 200], pageSizeOptions: [5, 10, 15, 30, 50, 100, 200],
defaultPageSize: pageSize || 15, defaultPageSize: pageSize || 15,
} }
} }
editable={{ editable={{
type: 'multiple', type: 'multiple',
......
import { Popconfirm, Switch } from 'antd'; import dayjs from 'dayjs';
function getcolumns(setdrawer, run) { function getcolumns(setdrawer) {
const disabledDate = (current) => {
// Can not select days before today and today
return current && current < dayjs().endOf('day');
};
const columns = [
{
title: '设备编号',
dataIndex: 'equipmentNo',
key: 'equipmentNo',
editable: false,
},
{
title: '设备名称',
dataIndex: 'equipmentName',
key: 'equipmentName',
editable: false,
},
{
title: '工厂名称',
dataIndex: 'factoryName',
key: 'factoryId',
hideInForm: true,
valueType: 'select',
fieldProps: {
placeholder: '请选择',
showSearch: true,
},
options: {
path: '/auth/sysFactory/getAllFactorySelection',
params: {},
},
editable: false,
},
{
title: '车间名称',
dataIndex: 'shopName',
key: 'shopId',
hideInForm: true,
valueType: 'select',
fieldProps: {
placeholder: '请选择',
showSearch: true,
},
options: {
path: '/auth/sysShop/getAllShopSelection',
params: {},
},
editable: false,
},
{
title: '下次点检日期',
dataIndex: 'checkPlanDate',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
fieldProps: {
disabledDate,
},
valueType: 'date',
hideInSearch: true,
},
];
return [ return [
{ {
tab: '未完成', tab: '未完成',
...@@ -48,6 +115,10 @@ function getcolumns(setdrawer, run) { ...@@ -48,6 +115,10 @@ function getcolumns(setdrawer, run) {
key: 'factoryId', key: 'factoryId',
hideInForm: true, hideInForm: true,
valueType: 'select', valueType: 'select',
fieldProps: {
placeholder: '请选择',
showSearch: true,
},
options: { options: {
path: '/auth/sysFactory/getAllFactorySelection', path: '/auth/sysFactory/getAllFactorySelection',
params: {}, params: {},
...@@ -59,8 +130,12 @@ function getcolumns(setdrawer, run) { ...@@ -59,8 +130,12 @@ function getcolumns(setdrawer, run) {
key: 'shopId', key: 'shopId',
hideInForm: true, hideInForm: true,
valueType: 'select', valueType: 'select',
fieldProps: {
placeholder: '请选择',
showSearch: true,
},
options: { options: {
path: '/auth/sysShop/getShopSelectionByFactory', path: '/auth/sysShop/getAllShopSelection',
linkParams: { linkParams: {
factoryId: '', factoryId: '',
}, },
...@@ -122,8 +197,9 @@ function getcolumns(setdrawer, run) { ...@@ -122,8 +197,9 @@ function getcolumns(setdrawer, run) {
hideInSearch: true, hideInSearch: true,
valueType: 'digit', valueType: 'digit',
hideInForm: { hideInForm: {
checkLoop: [1], checkLoop: [1, undefined],
}, },
precision: 0,
}, },
{ {
title: '下次点检日期', title: '下次点检日期',
...@@ -131,6 +207,9 @@ function getcolumns(setdrawer, run) { ...@@ -131,6 +207,9 @@ function getcolumns(setdrawer, run) {
key: 'planCheckDateList', key: 'planCheckDateList',
hideInForm: true, hideInForm: true,
valueType: 'dateRange', valueType: 'dateRange',
render: (text, row, _, action) => {
return <span>{row.planCheckDate}</span>;
},
}, },
{ {
title: '状态', title: '状态',
...@@ -153,32 +232,10 @@ function getcolumns(setdrawer, run) { ...@@ -153,32 +232,10 @@ function getcolumns(setdrawer, run) {
}, },
], ],
}, },
{
title: '启用/停用',
dataIndex: 'checkEnable',
key: 'checkEnable',
hideInForm: true,
hideInSearch: true,
valueType: 'switch',
render: (text, row, _, action) => {
return <Popconfirm
title="是否开启或停用?"
onConfirm={() => {
if (row.checkEnable == 1) {
run({ url: "/check/umEquipmentCheckPlan/enable", params: { id: row.id, checkEnable: 2 } })
}
}}
okText="确定"
cancelText="取消"
>
< Switch checked={row.checkEnable == 1 ? true : false} checkedChildren="开启" unCheckedChildren="停用" defaultChecked={false} />
</Popconfirm>
}
},
{ {
title: '选择设备', title: '选择设备',
dataIndex: 'equipmentId', dataIndex: 'paramList',
key: 'equipmentId', key: 'paramList',
formItemProps: { formItemProps: {
rules: [ rules: [
{ {
...@@ -193,6 +250,9 @@ function getcolumns(setdrawer, run) { ...@@ -193,6 +250,9 @@ function getcolumns(setdrawer, run) {
colProps: { colProps: {
span: 24, span: 24,
}, },
path: '/asset/equipment/list/user/shop',
columns,
hideInDescriptions: true,
}, },
], ],
pathconfig: { pathconfig: {
...@@ -215,6 +275,25 @@ function getcolumns(setdrawer, run) { ...@@ -215,6 +275,25 @@ function getcolumns(setdrawer, run) {
title: '点检计划单号', title: '点检计划单号',
dataIndex: 'checkNo', dataIndex: 'checkNo',
key: 'checkNo', key: 'checkNo',
render: (text, row, _, action) => {
return (
<a
onClick={() => {
setdrawer((s) => ({
...s,
open: true,
title: '详情',
val: 'detail',
type: 'detail',
title: '详细信息',
item: row,
}));
}}
>
{row?.checkNo}
</a>
);
},
}, },
{ {
title: '设备编号', title: '设备编号',
...@@ -230,7 +309,12 @@ function getcolumns(setdrawer, run) { ...@@ -230,7 +309,12 @@ function getcolumns(setdrawer, run) {
title: '工厂名称', title: '工厂名称',
dataIndex: 'factoryName', dataIndex: 'factoryName',
key: 'factoryId', key: 'factoryId',
hideInForm: true,
valueType: 'select', valueType: 'select',
fieldProps: {
placeholder: '请选择',
showSearch: true,
},
options: { options: {
path: '/auth/sysFactory/getAllFactorySelection', path: '/auth/sysFactory/getAllFactorySelection',
params: {}, params: {},
...@@ -240,10 +324,17 @@ function getcolumns(setdrawer, run) { ...@@ -240,10 +324,17 @@ function getcolumns(setdrawer, run) {
title: '车间名称', title: '车间名称',
dataIndex: 'shopName', dataIndex: 'shopName',
key: 'shopId', key: 'shopId',
hideInForm: true,
valueType: 'select', valueType: 'select',
fieldProps: {
placeholder: '请选择',
showSearch: true,
},
options: { options: {
path: '/auth/sysShop/getShopSelectionByFactory', path: '/auth/sysShop/getAllShopSelection',
params: {}, linkParams: {
factoryId: '',
},
}, },
}, },
{ {
...@@ -289,6 +380,9 @@ function getcolumns(setdrawer, run) { ...@@ -289,6 +380,9 @@ function getcolumns(setdrawer, run) {
dataIndex: 'endDate', dataIndex: 'endDate',
key: 'endDateList', key: 'endDateList',
valueType: 'dateRange', valueType: 'dateRange',
render: (text, row, _, action) => {
return <span>{row.endDate}</span>;
},
}, },
{ {
title: '状态', title: '状态',
......
import * as React from 'react'; import * as React from 'react';
import { useState, useMemo, useRef } from 'react'; import { useState, useMemo, useRef } from 'react';
import { message, Popconfirm, Switch } from "antd";
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 { useRequest } from 'ahooks'; import { useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch'; import { doFetch } from '@/utils/doFetch';
import dayjs from 'dayjs';
import InitForm from '@/components/InitForm';
function Plan(props) { function Plan(props) {
const actionRef = useRef(), const actionRef = useRef(),
formRef = useRef(); formRef = useRef();
...@@ -15,7 +17,7 @@ function Plan(props) { ...@@ -15,7 +17,7 @@ function Plan(props) {
}), }),
[activeTabKey, setactiveTabKey] = useState(1); [activeTabKey, setactiveTabKey] = useState(1);
const { run, loading } = useRequest(doFetch, { const { run, loading, runAsync } = useRequest(doFetch, {
manual: true, manual: true,
onSuccess: (res, params) => { onSuccess: (res, params) => {
if (res?.code == '0000') { if (res?.code == '0000') {
...@@ -51,7 +53,7 @@ function Plan(props) { ...@@ -51,7 +53,7 @@ function Plan(props) {
); );
}; };
const edit = (text, row, _, action) => { const editDate = (text, row, _, action) => {
return ( return (
<PremButton <PremButton
btn={{ btn={{
...@@ -61,13 +63,14 @@ function Plan(props) { ...@@ -61,13 +63,14 @@ function Plan(props) {
...s, ...s,
open: true, open: true,
item: row, item: row,
title: '编辑', title: '调整日期',
val: 'edit', val: 'detailaddon',
id: row?.id
})); }));
}, },
}} }}
> >
编辑 调整日期
</PremButton> </PremButton>
); );
}; };
...@@ -79,8 +82,8 @@ function Plan(props) { ...@@ -79,8 +82,8 @@ function Plan(props) {
title: '是否删除?', title: '是否删除?',
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onConfirm: () => { onConfirm: async () => {
run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } }); await runAsync({ url: pathconfig?.delete || '/delete', params: { id: row?.id } });
}, },
}} }}
btn={{ btn={{
...@@ -92,26 +95,202 @@ function Plan(props) { ...@@ -92,26 +95,202 @@ function Plan(props) {
</PremButton> </PremButton>
); );
}; };
const close = (text, row, _, action) => {
return (
<PremButton
pop={{
title: '是否关单?',
okText: '确认',
cancelText: '取消',
onConfirm: async () => {
await runAsync({ url: '/check/umEquipmentCheckPlan/shut', params: { id: row?.id } });
},
}}
btn={{
size: 'small',
type: 'danger',
}}
>
关单
</PremButton>
);
};
const columns = useMemo(() => { const columns = useMemo(() => {
let defcolumn = getcolumns(setdrawer, run).filter((it) => it.key == activeTabKey)[0]?.columns; let defcolumn = getcolumns(setdrawer).filter((it) => it.key == activeTabKey)[0]?.columns;
let defpath = getcolumns(setdrawer, run).filter((it) => it.key == activeTabKey)[0]?.pathconfig ?? {}; let defpath = getcolumns(setdrawer).filter((it) => it.key == activeTabKey)[0]?.pathconfig ?? {};
return activeTabKey == 1 ? defcolumn.concat({ return activeTabKey == 1 ? defcolumn.concat([
title: '操作', {
valueType: 'option', title: '启用/停用',
width: 150, dataIndex: 'checkEnable',
render: (text, row, _, action) => [ key: 'checkEnable',
defpath?.enableedit && edit(text, row, _, action), hideInForm: true,
defpath?.enabledelete && remove(text, row, _, action), hideInSearch: true,
], valueType: 'switch',
}) : defcolumn; render: (text, row, _, action) => {
//"1停用 2启用 *"
return row.checkEnable == 1 ? <Popconfirm
title="是否开启或停用?"
onConfirm={async () => {
if (row.checkEnable == 1) {
await runAsync({
url: '/check/umEquipmentCheckPlan/enable',
params: { id: row.id, checkEnable: 2 },
});
}
}}
okText="确定"
cancelText="取消"
disabled={!(row.status == 1 || (row.status == 2 && row.checkLoop == 2))}
>
<Switch
checked={row.checkEnable == 1 ? true : false}
checkedChildren="开启"
unCheckedChildren="停用"
defaultChecked={false}
disabled={!(row.status == 1 || (row.status == 2 && row.checkLoop == 2))}
/>
</Popconfirm>
:
<Switch
checked={row.checkEnable == 1 ? true : false}
checkedChildren="开启"
unCheckedChildren="停用"
defaultChecked={false}
disabled={!(row.status == 1 || (row.status == 2 && row.checkLoop == 2))}
onChange={(checked) => {
if (checked) {
setdrawer((s) => ({
...s,
open: true,
item: row,
title: '调整日期',
val: 'detailaddon',
id: row?.id
}));
}
}}
/>
;
},
hideInDescriptions: true,
},
{
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => [
(row.status == 1 || (row.status == 2 && row.checkLoop == 2)) && editDate(text, row, _, action),
row.status == 2 && close(text, row, _, action),
defpath?.enabledelete && row.status == 1 && remove(text, row, _, action),
],
}
]) : defcolumn;
}, [activeTabKey]); }, [activeTabKey]);
const editDateColumns = useMemo(() => {
const disabledDate = (current) => {
if (drawer?.item?.status == 1) {
return current && current < dayjs().endOf('day');
} else {
if (dayjs(drawer?.item?.planCheckDate).endOf('day').valueOf() >= dayjs().endOf('day').valueOf()) {
return current && current <= dayjs(drawer?.item?.planCheckDate).endOf('day');
} else {
return current && current < dayjs().endOf('day');
}
}
};
return [
{
title: '基础信息',
valueType: 'split',
hideInForm: true,
},
{
title: '点检计划单号',
dataIndex: 'checkNo',
key: 'checkNo',
hideInForm: true,
},
{
title: '设备编号',
dataIndex: 'equipmentNo',
key: 'equipmentNo',
hideInForm: true,
},
{
title: '设备名称',
dataIndex: 'equipmentName',
key: 'equipmentName',
hideInForm: true,
},
{
title: '点检类型',
dataIndex: 'checkTypeName',
key: 'checkType',
hideInForm: true,
},
{
title: '下次点检日期',
dataIndex: 'planCheckDate',
key: 'planCheckDateList',
hideInForm: true,
},
{
title: '计划类型',
dataIndex: 'checkLoopName',
key: 'checkLoop',
hideInForm: true
},
{
title: '调整信息',
valueType: 'split',
hideInForm: true,
},
{
title: '下次点检日期',
dataIndex: 'planCheckDate',
key: 'planCheckDate',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
fieldProps: {
disabledDate,
},
valueType: 'date',
hideInSearch: true,
hideInDescriptions: true
},
{
title: '周期(天)',
dataIndex: 'checkCycle',
key: 'checkCycle',
hideInSearch: true,
hideInDescriptions: true,
valueType: 'digit',
hideInForm: drawer?.item?.checkLoop == 2 ? false : true,
precision: 0,
},
];
}, [drawer?.item])
const pathconfig = useMemo(() => { const pathconfig = useMemo(() => {
let defpath = getcolumns(setdrawer).filter((it) => it.key == activeTabKey)[0]?.pathconfig ?? {}; let defpath = getcolumns(setdrawer).filter((it) => it.key == activeTabKey)[0]?.pathconfig ?? {};
return defpath; return defpath;
}, [activeTabKey]); }, [activeTabKey]);
const waitTime = (time) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
return ( return (
<div style={{ position: 'relative' }}> <div style={{ position: 'relative' }}>
<AutoTable <AutoTable
...@@ -123,6 +302,7 @@ function Plan(props) { ...@@ -123,6 +302,7 @@ function Plan(props) {
addconfig={{ addconfig={{
// access: 'sysDepartment_save', // access: 'sysDepartment_save',
btn: { btn: {
type: 'primary',
disabled: false, disabled: false,
onClick: () => { onClick: () => {
setdrawer((s) => ({ setdrawer((s) => ({
...@@ -143,7 +323,7 @@ function Plan(props) { ...@@ -143,7 +323,7 @@ function Plan(props) {
/> />
<DrawerPro <DrawerPro
fields={columns} fields={drawer?.val == "detailaddon" ? editDateColumns : columns}
detailpath={pathconfig?.detail || null} detailpath={pathconfig?.detail || null}
detailData={drawer?.item} detailData={drawer?.item}
defaultFormValue={drawer?.item} defaultFormValue={drawer?.item}
...@@ -157,14 +337,35 @@ function Plan(props) { ...@@ -157,14 +337,35 @@ function Plan(props) {
})); }));
}} }}
{...drawer} {...drawer}
onFinish={(vals) => { onFinish={async (vals) => {
let params = JSON.parse(JSON.stringify(vals));
params.paramList = params?.paramList?.map(it => {
return {
equipmentId: it.id,
checkPlanDate: it.checkPlanDate
}
});
let flag = params.paramList?.some(it => !it.checkPlanDate);
if (flag) {
message.warning("下次点检日期必填!")
return;
}
if (drawer?.val == 'add') { if (drawer?.val == 'add') {
run({ url: pathconfig?.add || '/add', params: { ...vals } }); await runAsync({ url: pathconfig?.add || '/add', params: { ...params } });
} else if (drawer?.val == 'edit') { } else if (drawer?.val == 'edit') {
run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } }); await runAsync({ url: pathconfig?.edit || '/edit', params: { ...params, id: drawer?.item?.id } });
} }
}} }}
/> >
<InitForm
fields={editDateColumns}
defaultFormValue={{ checkCycle: drawer?.item?.checkCycle }}
onFinish={async (vals) => {
await runAsync({ url: "/check/umEquipmentCheckPlan/adjustDate", params: { ...vals, id: drawer?.item?.id } });
}}
/>
</DrawerPro>
</div> </div>
); );
} }
......
...@@ -17,7 +17,7 @@ function Project({ equipmentCheckStandardId }) { ...@@ -17,7 +17,7 @@ function Project({ equipmentCheckStandardId }) {
let pathconf = procolumns(setdrawer)?.pathconfig ?? {}; let pathconf = procolumns(setdrawer)?.pathconfig ?? {};
return pathconf; return pathconf;
}, []); }, []);
const { run, loading } = useRequest(doFetch, { const { run, loading, runAsync } = useRequest(doFetch, {
manual: true, manual: true,
onSuccess: (res, params) => { onSuccess: (res, params) => {
if (res?.code == '0000') { if (res?.code == '0000') {
...@@ -82,8 +82,8 @@ function Project({ equipmentCheckStandardId }) { ...@@ -82,8 +82,8 @@ function Project({ equipmentCheckStandardId }) {
title: '是否删除?', title: '是否删除?',
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onConfirm: () => { onConfirm: async () => {
run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } }); await runAsync({ url: pathconfig?.delete || '/delete', params: { id: row?.id } });
}, },
}} }}
btn={{ btn={{
...@@ -120,6 +120,7 @@ function Project({ equipmentCheckStandardId }) { ...@@ -120,6 +120,7 @@ function Project({ equipmentCheckStandardId }) {
addconfig={{ addconfig={{
// access: 'sysDepartment_save', // access: 'sysDepartment_save',
btn: { btn: {
type: 'primary',
disabled: false, disabled: false,
onClick: () => { onClick: () => {
setdrawer((s) => ({ setdrawer((s) => ({
...@@ -152,11 +153,11 @@ function Project({ equipmentCheckStandardId }) { ...@@ -152,11 +153,11 @@ function Project({ equipmentCheckStandardId }) {
})); }));
}} }}
{...drawer} {...drawer}
onFinish={(vals) => { onFinish={async (vals) => {
if (drawer?.val == 'add') { if (drawer?.val == 'add') {
run({ url: pathconfig?.add || '/add', params: { ...vals, equipmentCheckStandardId } }); await runAsync({ url: pathconfig?.add || '/add', params: { ...vals, equipmentCheckStandardId } });
} else if (drawer?.val == 'edit') { } else if (drawer?.val == 'edit') {
run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id, equipmentCheckStandardId } }); await runAsync({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id, equipmentCheckStandardId } });
} }
}} }}
/> />
......
...@@ -17,7 +17,7 @@ function Standard(props) { ...@@ -17,7 +17,7 @@ function Standard(props) {
let pathconf = getcolumns(setdrawer)?.pathconfig ?? {}; let pathconf = getcolumns(setdrawer)?.pathconfig ?? {};
return pathconf; return pathconf;
}, []); }, []);
const { run, loading } = useRequest(doFetch, { const { run, loading, runAsync } = useRequest(doFetch, {
manual: true, manual: true,
onSuccess: (res, params) => { onSuccess: (res, params) => {
if (res?.code == '0000') { if (res?.code == '0000') {
...@@ -103,8 +103,8 @@ function Standard(props) { ...@@ -103,8 +103,8 @@ function Standard(props) {
title: '是否删除?', title: '是否删除?',
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onConfirm: () => { onConfirm: async () => {
run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } }); await runAsync({ url: pathconfig?.delete || '/delete', params: { id: row?.id } });
}, },
}} }}
btn={{ btn={{
...@@ -144,6 +144,7 @@ function Standard(props) { ...@@ -144,6 +144,7 @@ function Standard(props) {
addconfig={{ addconfig={{
// access: 'sysDepartment_save', // access: 'sysDepartment_save',
btn: { btn: {
type: 'primary',
disabled: false, disabled: false,
onClick: () => { onClick: () => {
setdrawer((s) => ({ setdrawer((s) => ({
...@@ -175,11 +176,11 @@ function Standard(props) { ...@@ -175,11 +176,11 @@ function Standard(props) {
})); }));
}} }}
{...drawer} {...drawer}
onFinish={(vals) => { onFinish={async (vals) => {
if (drawer?.val == 'add') { if (drawer?.val == 'add') {
run({ url: pathconfig?.add || '/add', params: { ...vals } }); await runAsync({ url: pathconfig?.add || '/add', params: { ...vals } });
} else if (drawer?.val == 'edit') { } else if (drawer?.val == 'edit') {
run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } }); await runAsync({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } });
} }
}} }}
> >
......
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