Commit bc16f269 authored by 左玲玲's avatar 左玲玲 😬

1718

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