Commit f95740a1 authored by TZW's avatar TZW

20221207

parent 12d2fab9
import { useState, useEffect } from 'react';
import { useState, useEffect, useRef } from 'react';
import InitForm from '@/components/InitForm';
import { message } from 'antd';
import { doFetch } from '@/utils/doFetch';
const App = () => {
const App = ({ url, actionRef, setdrawer }) => {
const columns = [
{
title: '选择设备',
......@@ -98,9 +100,49 @@ const App = () => {
},
},
];
const formRef = useRef();
return (
<>
<InitForm fields={columns} />
<InitForm
formRef={formRef}
fields={columns}
onValuesChange={(changedValues, allValues) => {
console.log(changedValues, allValues);
if (Object.keys(changedValues)[0] == 'faultDetailId') {
doFetch({
url: '/repair/umFaultSettingDetail/queryById',
params: {
id: changedValues?.faultDetailId,
},
}).then((res) => {
console.log(res);
formRef?.current?.setFieldsValue({
faultDescription: res?.data?.data.faultPhenomenon,
});
});
}
}}
onFinish={async (vals) => {
console.log(vals);
let params = {
...vals,
};
let res = await doFetch({
url,
params,
});
if (res.code === '0000') {
message.success('新建成功!');
setdrawer((s) => ({
...s,
open: false,
}));
actionRef.current.reload();
}
}}
/>
</>
);
};
......
......@@ -96,6 +96,9 @@ function InitForm({
fields,
extendField = '',
colProps = { xs: 24, sm: 24, md: 12, lg: 12, xl: 12, xxl: 12 },
onValuesChange = (changedValues, allValues) => {
console.log(changedValues, allValues);
},
}) {
let proformRef = useRef();
proformRef = formRef ?? proformRef;
......@@ -145,6 +148,9 @@ function InitForm({
}
}}
autoFocusFirstInput
onValuesChange={(changedValues, allValues) => {
onValuesChange?.(changedValues, allValues);
}}
>
<FormRender
fields={fields.filter((it) => it.valueType != 'option')}
......
......@@ -18,13 +18,13 @@ import moment from 'moment';
* 退出登录,并且将当前的 url 保存
*/
const loginOut = async () => {
await fakeAccountLoginOut();
const { logoutRedirectUrl } = await fakeAccountLoginOut();
const { query = {} } = history.location;
const { redirect } = query; // Note: There may be security issues, please note
if (window.location.pathname !== '/user/login' && !redirect) {
localStorage.clear();
history.replace('/user/login');
history.replace(logoutRedirectUrl);
}
};
......@@ -121,7 +121,6 @@ const AvatarDropdown = ({ menu }) => {
if (!currentUser || !currentUser.username) {
return loadings;
}
let saveData = (values) => {
let newfields = JSON.parse(JSON.stringify(values));
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-11-10 09:39:56
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-01 16:49:23
* @Last Modified time: 2022-12-07 13:43:37
*/
import * as React from 'react';
......
......@@ -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:52:05
* @Last Modified time: 2022-12-07 16:10:34
*/
import * as React from 'react';
......@@ -124,7 +124,9 @@ function Failure(props) {
const selectType = (type) => {
switch (type) {
case 'add':
return <Addform />;
return (
<Addform url="/repair/umFailureRepair/save" actionRef={actionRef} setdrawer={setdrawer} />
);
default:
break;
}
......
......@@ -4,6 +4,14 @@ function getcolumns(setdrawer) {
title: '故障类型',
dataIndex: 'faultType',
key: 'faultType',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
title: '故障代码',
......@@ -25,6 +33,7 @@ function getcolumns(setdrawer) {
dataIndex: 'remark',
key: 'remark',
valueType: 'textarea',
search: false,
},
];
}
......
/* 故障设置
* @Author: Li Hanlin
* @Date: 2022-12-07 11:19:30
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-07 15:12:48
*/
import * as React from 'react';
import { useState, useMemo, useRef } from 'react';
import { useState, useMemo, useEffect, useRef } from 'react';
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 InitForm from '@/components/InitForm';
import { ProDescriptions } from '@ant-design/pro-components';
const pathconfig = {
enableadd: true,
......@@ -39,7 +48,7 @@ function Fault(props) {
},
});
const detail = (text, row, _, action) => {
const gzmc = (text, row, _, action) => {
return (
<PremButton
btn={{
......@@ -50,7 +59,8 @@ function Fault(props) {
open: true,
item: row,
title: '详情',
val: 'detail',
val: 'only',
type: 'gzmc',
title: '详细信息',
}));
},
......@@ -105,18 +115,97 @@ function Fault(props) {
const columns = useMemo(() => {
let defcolumn = getcolumns(setdrawer);
return defcolumn.concat({
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => [
pathconfig?.enabledetail && detail(text, row, _, action),
pathconfig?.enableedit && edit(text, row, _, action),
pathconfig?.enabledelete && remove(text, row, _, action),
],
if (drawer?.type == 'gzmc') {
return defcolumn;
} else {
return defcolumn.concat({
title: '操作',
valueType: 'option',
width: 150,
render: (text, row, _, action) => [
pathconfig?.enabledetail && gzmc(text, row, _, action),
pathconfig?.enableedit && edit(text, row, _, action),
pathconfig?.enabledelete && remove(text, row, _, action),
],
});
}
}, [drawer?.type]);
const FaultName = () => {
const [request, setrequest] = useState();
const [drawergz, setdrawergz] = useState({
open: false,
});
}, []);
useEffect(() => {
const fn = async () => {
let params = { id: drawer?.item?.id };
let res = await doFetch({ url: '/repair/umFaultSetting/queryById', params });
setrequest(res?.data.data);
};
fn();
}, []);
return (
<>
<ProDescriptions dataSource={request} columns={columns} />
<AutoTable
columns={[
{
title: '故障名称',
dataIndex: 'faultDetailName',
key: 'faultDetailName',
},
{
title: '故障代码',
dataIndex: 'faultDetailCode',
key: 'faultDetailCode',
},
{
title: '故障描述',
dataIndex: 'faultPhenomenon',
key: 'faultPhenomenon',
},
{
title: '解决方案',
dataIndex: 'faultSolution',
key: 'faultSolution',
search: false,
},
]}
path="/repair/umFaultSettingDetail/queryById"
params={{ id: drawer?.item.id }}
pageextra={'add'}
addconfig={{
// access: 'sysDepartment_save',
btn: {
disabled: false,
type: 'primary',
onClick: () => {
setdrawergz((s) => ({
...s,
open: true,
item: {
isShutdown: 1,
},
title: '新建追踪工单',
val: 'add',
type: 'add',
}));
},
},
}}
/>
</>
);
};
function selectType(type) {
switch (type) {
case 'gzmc':
return <FaultName />;
default:
break;
}
}
return (
<div style={{ position: 'relative' }}>
<AutoTable
......@@ -125,7 +214,7 @@ function Fault(props) {
actionRef={actionRef}
path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
pageextra={pathconfig?.enableadd ? 'add' : null}
resizeable={true}
resizeable={false}
addconfig={{
// access: 'sysDepartment_save',
btn: {
......@@ -145,16 +234,18 @@ function Fault(props) {
<DrawerPro
fields={columns}
params={{ id: drawer?.item?.id }}
// params={{ id: drawer?.item?.id }}
formRef={formRef}
placement="right"
detailpath={pathconfig?.detail || null}
// detailpath={pathconfig?.detail || null}
detailData={drawer?.item}
defaultFormValue={drawer?.item}
onClose={() => {
setdrawer((s) => ({
...s,
open: false,
type: null,
item: null,
}));
}}
{...drawer}
......@@ -165,7 +256,9 @@ function Fault(props) {
run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } });
}
}}
/>
>
{selectType(drawer?.type)}
</DrawerPro>
</div>
);
}
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-12-02 11:41:03
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-12-07 10:00:30
* @Last Modified time: 2022-12-07 14:31:33
*/
import * as React from 'react';
......@@ -105,6 +105,7 @@ function Failure(props) {
actionRef.current.reload();
}
}}
{...drawer}
/>
</>
);
......@@ -193,6 +194,7 @@ function Failure(props) {
actionRef.current.reload();
}
}}
{...drawer}
/>
</>
);
......@@ -294,6 +296,7 @@ function Failure(props) {
actionRef.current.reload();
}
}}
{...drawer}
/>
</>
);
......@@ -334,7 +337,7 @@ function Failure(props) {
id: row?.id,
};
let res = await doFetch({
url: '/repair/umOtherUnitsOrder/orderReceiving',
url: '/repair/umTrackOrder/orderReceiving',
params,
});
if (res.code === '0000') {
......@@ -356,7 +359,7 @@ function Failure(props) {
id: row?.id,
};
let res = await doFetch({
url: '/repair/umOtherUnitsOrder/dispatchById',
url: '/repair/umTrackOrder/dispatchById',
params,
});
if (res.code === '0000') {
......@@ -386,6 +389,8 @@ function Failure(props) {
item: {
id: row.id,
},
detailpath: null,
params: null,
val: 'only',
title: '追踪信息',
}));
......@@ -403,9 +408,6 @@ function Failure(props) {
setdrawer((s) => ({
...s,
open: true,
// item: {
// id: row.id,
// },
val: 'only',
title: '验证',
detailpath: '/repair/umTrackTraceinfo/queryByTrackOrderId',
......@@ -511,7 +513,9 @@ function Failure(props) {
const selectType = (type) => {
switch (type) {
case 'add':
return <Addform />;
return (
<Addform url={'/repair/umTrackOrder/save'} setdrawer={setdrawer} actionRef={actionRef} />
);
case 'track':
return <TrackForm />;
case 'check':
......@@ -525,7 +529,7 @@ function Failure(props) {
return (
<div style={{ position: 'relative' }} ref={containderef}>
<AutoTable
pagetitle={<h3 className="page-title">外协工单</h3>}
pagetitle={<h3 className="page-title">追踪工单</h3>}
columns={columns}
path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
actionRef={actionRef}
......@@ -543,7 +547,7 @@ function Failure(props) {
item: {
isShutdown: 1,
},
title: '新建外协工单',
title: '新建追踪工单',
val: 'only',
type: 'add',
}));
......
......@@ -382,7 +382,7 @@ function getcolumns(setdrawer) {
},
{
title: '状态',
hideInTable: true,
// hideInTable: true,
dataIndex: 'statusName',
key: 'status',
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
......@@ -398,14 +398,6 @@ function getcolumns(setdrawer) {
},
],
},
// {
// title: '状态',
// width: 50,
// hideInForm: true,
// dataIndex: 'statusName',
// key: 'status',
// search: false,
// },
{
title: '备注',
hideInTable: true,
......@@ -414,7 +406,6 @@ function getcolumns(setdrawer) {
key: 'remarks',
search: false,
},
// { title: '个人图片', hideInTable: true, dataIndex: 'userImgList', key: 'userImgList' },
{
title: '个人图片',
search: false,
......@@ -423,7 +414,7 @@ function getcolumns(setdrawer) {
valueType: 'uploadImage',
hideInTable: true,
fieldProps: {
limit: 2,
limit: 1,
},
render: (text, row) => {
......
function getcolumns(setdrawer) {
function getcolumns(ifs) {
return [
{
title: '车间代码',
......@@ -22,6 +22,9 @@ function getcolumns(setdrawer) {
valueType: 'select',
options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
fieldProps: {
disabled: ifs,
},
},
];
}
......
......@@ -2,7 +2,7 @@
* @Author: Li Hanlin
* @Date: 2022-11-09 14:44:18
* @Last Modified by: Li Hanlin
* @Last Modified time: 2022-11-10 15:36:27
* @Last Modified time: 2022-12-07 16:37:56
*/
import * as React from 'react';
......@@ -56,13 +56,16 @@ function Factory(props) {
<PremButton
btn={{
size: 'small',
onClick: () => {
onClick: async () => {
// let res = await doFetch({ url: '', params: {} });
setdrawer((s) => ({
...s,
visible: true,
item: row,
title: '编辑',
val: 'edit',
fields: getcolumns(true),
onFinish: async (vals) => {
let params = {
...vals,
......@@ -151,6 +154,7 @@ function Factory(props) {
detailpath: null,
title: '新增',
val: 'add',
fields: getcolumns(false),
onFinish: async (vals) => {
let params = {
...vals,
......
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