Commit e27a667c authored by TZW's avatar TZW

12061947

parent bd57fd24
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-12-02 11:41:03
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-05 09:10:05
* @Last Modified time: 2022-12-06 16:52:05
*/
import * as React from 'react';
......@@ -13,7 +13,7 @@ import PremButton from '@/components/PremButton';
import getcolumns from './columns';
import { useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch';
import Addform from './Addform';
import Addform from '@/components/Addform';
function Failure(props) {
const actionRef = useRef(),
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-12-02 11:41:03
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-06 16:05:58
* @Last Modified time: 2022-12-06 19:43:22
*/
import * as React from 'react';
......@@ -13,9 +13,13 @@ import PremButton from '@/components/PremButton';
import getcolumns from './columns';
import { useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch';
import Addform from '@/components/Addform';
import { Menu, Dropdown, Button, message } from 'antd';
import InitForm from '@/components/InitForm';
function Failure(props) {
const actionRef = useRef(),
containderef = useRef(),
formRef = useRef();
const [drawer, setdrawer] = useState({
open: false,
......@@ -58,24 +62,123 @@ function Failure(props) {
);
};
const edit = (text, row, _, action) => {
// 完成外协
const CompleteOuts = () => {
return (
<PremButton
btn={{
size: 'small',
onClick: () => {
setdrawer((s) => ({
...s,
open: true,
item: row,
title: '编辑',
val: 'edit',
}));
},
}}
>
编辑
</PremButton>
<>
<InitForm
fields={[
{
title: '外协单位',
dataIndex: 'otherUnitsId',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
key: 'otherUnitsId',
valueType: 'select',
options: {
path: '/asset/equipmentSupplier/query/selection',
params: {},
},
},
{
title: '故障原因',
dataIndex: 'causeFailure',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
key: 'causeFailure',
},
{
title: '维修内容',
dataIndex: 'repairContent',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
key: 'repairContent',
},
{
title: '外协时长',
dataIndex: 'otherUnitsHours',
key: 'otherUnitsHours',
// valueType: 'number',
},
{
title: '外协费用',
dataIndex: 'otherUnitsCost',
key: 'otherUnitsCost',
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark',
valueType: 'textarea',
},
]}
onFinish={async (vals) => {
let params = {
otherUnitsFinish: vals,
id: drawer?.item?.id,
};
let res = await doFetch({
url: '/repair/umOtherUnitsOrder/finishOtherUnits',
params,
});
if (res.code === '0000') {
message.success('成功完成外协!');
setdrawer((s) => ({
...s,
open: false,
}));
actionRef.current.reload();
}
}}
/>
</>
);
};
// 重新指派
const Reassig = () => {
return (
<>
<InitForm
fields={[
{
title: '最新外协人员',
dataIndex: 'causeFailure',
valueType: 'textarea',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
key: 'causeFailure',
},
{
title: '外协人员',
dataIndex: 'otherUnitsAssistList',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
key: 'otherUnitsAssistList',
valueType: 'select',
options: {
path: '/repair/umOtherUnitsOrder/selectionAgain',
params: { otherUnitsOrderId: drawer?.item.id },
},
},
]}
onFinish={async (vals) => {
let params = {
otherUnitsFinish: vals,
id: drawer?.item?.id,
};
let res = await doFetch({
url: '/repair/umOtherUnitsOrder/againOtherUnits',
params,
});
if (res.code === '0000') {
message.success('重新外协成功!');
setdrawer((s) => ({
...s,
open: false,
}));
actionRef.current.reload();
}
}}
/>
</>
);
};
......@@ -100,19 +203,164 @@ function Failure(props) {
);
};
// 更多
const more = (text, row, _, action) => {
const menu = (
<Menu
items={[
{
label:
row?.status == 0 || row?.status == 1 ? (
<a
onClick={async () => {
let params = {
id: row?.id,
};
let res = await doFetch({
url: '/repair/umOtherUnitsOrder/orderReceiving',
params,
});
if (res.code === '0000') {
message.success('接单成功!');
setdrawer((s) => ({
...s,
open: false,
}));
actionRef.current.reload();
}
}}
>
接单
</a>
) : (
<a
onClick={async () => {
let params = {
id: row?.id,
};
let res = await doFetch({
url: '/repair/umOtherUnitsOrder/dispatchById',
params,
});
if (res.code === '0000') {
message.success('派单成功!');
setdrawer((s) => ({
...s,
open: false,
}));
actionRef.current.reload();
}
}}
>
派单
</a>
),
key: '0',
// disabled: true,
},
{
label: (
<a
onClick={() => {
setdrawer((s) => ({
...s,
open: true,
type: 'comouts',
item: {
id: row.id,
},
val: 'only',
title: '完成外协',
}));
}}
>
完成外协
</a>
),
key: '1',
},
]}
/>
);
return (
<Dropdown
overlay={menu}
trigger={['click']}
arrow={true}
getPopupContainer={() => containderef.current}
>
<Button size="small">更多</Button>
</Dropdown>
);
};
// 未完成按钮
const unfinishBtn = (text, row, _, action) => {
if (row?.status == 1) {
return (
<PremButton
pop={{
title: '是否删除?',
okText: '确认',
cancelText: '取消',
onConfirm: () => {
run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } });
},
}}
btn={{
size: 'small',
type: 'danger',
}}
>
删除
</PremButton>
);
} else if (row?.status == 2) {
return (
<PremButton
onClick={() => {
setdrawer((s) => ({
...s,
item: row,
type: 'Reassig',
open: true,
}));
}}
btn={{
size: 'small',
}}
>
重新指派
</PremButton>
);
}
};
const columns = useMemo(() => {
let defcolumn = getcolumns(setdrawer).filter((it) => it.key == activeTabKey)[0]?.columns;
console.log(defcolumn);
let defpath = getcolumns(setdrawer).filter((it) => it.key == activeTabKey)[0]?.pathconfig ?? {};
return defcolumn.concat({
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => [
defpath?.enabledetail && detail(text, row, _, action),
defpath?.enableedit && edit(text, row, _, action),
defpath?.enabledelete && remove(text, row, _, action),
],
});
if (activeTabKey == '1') {
return defcolumn.concat({
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => {
return [more(text, row, _, action)];
},
});
} else if (activeTabKey == '2') {
return defcolumn.concat({
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => {
return [unfinishBtn(text, row, _, action)];
},
});
} else if (activeTabKey == '3') {
return defcolumn;
}
}, [activeTabKey]);
const pathconfig = useMemo(() => {
......@@ -123,20 +371,24 @@ function Failure(props) {
const selectType = (type) => {
switch (type) {
case 'add':
return;
return <Addform />;
case 'comouts':
return <CompleteOuts />;
case 'Reassig':
return <Reassig />;
default:
break;
}
};
return (
<div style={{ position: 'relative' }}>
<div style={{ position: 'relative' }} ref={containderef}>
<AutoTable
pagetitle={<h3 className="page-title">外协工单</h3>}
columns={columns}
path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
actionRef={actionRef}
pageextra={pathconfig?.enableadd ? 'add' : null}
resizeable={true}
resizeable={false}
addconfig={{
// access: 'sysDepartment_save',
btn: {
......@@ -146,8 +398,10 @@ function Failure(props) {
setdrawer((s) => ({
...s,
open: true,
item: null,
title: '新增',
item: {
isShutdown: 1,
},
title: '新建外协工单',
val: 'only',
type: 'add',
}));
......@@ -172,6 +426,7 @@ function Failure(props) {
onClose={() => {
setdrawer((s) => ({
...s,
open: false,
}));
}}
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-12-05 10:13:42
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-05 17:32:09
* @Last Modified time: 2022-12-06 16:41:48
*/
import * as React from 'react';
......
......@@ -424,14 +424,7 @@ function getcolumns(setdrawer) {
fieldProps: {
limit: 2,
},
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
render: (text, row) => {
if (row?.pictureUrl == null) {
return '暂无图片';
......
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