Commit 12367ac7 authored by TZW's avatar TZW

12091651

parent 0415b362
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-12-07 11:19:30
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-09 16:05:25
* @Last Modified time: 2022-12-09 16:47:36
*/
import * as React from 'react';
......@@ -15,7 +15,7 @@ import { useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch';
import InitForm from '@/components/InitForm';
import { ProDescriptions } from '@ant-design/pro-components';
import { message } from 'antd';
const pathconfig = {
enableadd: true,
enableedit: true,
......@@ -136,6 +136,79 @@ function Fault(props) {
const FaultName = (props) => {
const [request, setrequest] = useState();
const gzmcref = useRef();
const remove = (text, row, _, action) => {
return (
<PremButton
pop={{
title: '是否删除?',
okText: '确认',
cancelText: '取消',
onConfirm: async () => {
let res = await doFetch({
url: '/repair/umFaultSettingDetail/deleteById',
params: { id: row.id },
});
if (res.code === '0000') {
message.success('删除成功!');
setdrawergz((s) => ({
...s,
open: false,
}));
actionRef.current.reload();
}
},
}}
btn={{
size: 'small',
type: 'danger',
}}
>
删除
</PremButton>
);
};
const edit = (text, row, _, action) => {
return (
<PremButton
btn={{
size: 'small',
onClick: () => {
setdrawergz((s) => ({
...s,
open: true,
title: '编辑',
val: 'edit',
detailpath: '/repair/umFaultSettingDetail/queryById',
params: { id: row.id },
onFinish: async (vals) => {
//console.log(1);
let params = {
...vals,
faultSettingId: drawer?.item.id,
id: row.id,
};
let res = await doFetch({
url: '/repair/umFaultSettingDetail/save',
params,
});
if (res.code === '0000') {
message.success('编辑成功!');
setdrawergz((s) => ({
...s,
open: false,
}));
actionRef.current.reload();
}
},
}));
},
}}
>
编辑
</PremButton>
);
};
const columns = useMemo(() => {
return [
{
......@@ -169,20 +242,23 @@ function Fault(props) {
valueType: 'textarea',
search: false,
},
{
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => [
edit(text, row, _, action),
remove(text, row, _, action),
],
},
];
}, []);
useEffect(() => {
const fn = async () => {
let params = { id: drawer?.item?.id };
let res = await doFetch({ url: '/repair/umFaultSetting/queryById', params });
setrequest(res?.data.data);
};
fn();
}, []);
const renderRef = useRef(true);
return (
<>
<ProDescriptions
dataSource={request}
dataSource={drawer?.item}
columns={[
{
title: '故障类型',
......@@ -206,19 +282,14 @@ function Fault(props) {
title: '设备类型',
dataIndex: 'equipmentTypeName',
key: 'equipmentTypeId',
valueType: 'treeSelect',
options: {
path: '/asset/equipmentType/queryTreeList',
params: {},
},
},
]}
/>
<AutoTable
columns={columns}
formRef={gzmcref}
path="/repair/umFaultSettingDetail/queryById"
params={{ id: drawer?.item.id }}
path="/repair/umFaultSettingDetail/queryList"
extraparams={{ faultSettingId: drawer?.item.id }}
pageextra={'add'}
addconfig={{
// access: 'sysDepartment_save',
......@@ -234,7 +305,7 @@ function Fault(props) {
onFinish: async (vals) => {
let params = {
...vals,
id: drawer?.item.id,
faultSettingId: drawer?.item.id,
};
let res = await doFetch({
url: '/repair/umFaultSettingDetail/save',
......@@ -296,6 +367,7 @@ function Fault(props) {
// access: 'sysDepartment_save',
btn: {
disabled: false,
type: 'primary',
onClick: () => {
setdrawer((s) => ({
...s,
......
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