Commit f548e09d authored by wuhao's avatar wuhao 🎯

asder

parent cb0aceb6
......@@ -19,7 +19,7 @@ export default {
},
'/token': {
// 要代理的地址
target: 'http://192.168.40.64:28001',
target: 'http://192.168.40.64:8000',
changeOrigin: true,
},
'/staticfile/': {
......
......@@ -52,7 +52,7 @@ function getRule(req: Request, res: Response, u: string) {
const sorter = JSON.parse(params.sorter);
dataSource = dataSource.sort((prev, next) => {
let sortNumber = 0;
Object.keys(sorter).forEach((key) => {
Object.keys(sorter).forEach?.((key) => {
if (sorter[key] === 'descend') {
if (prev[key] - next[key] > 0) {
sortNumber += -1;
......
......@@ -22,7 +22,7 @@ function DetailPro(props) {
let res = await doFetch({ url: props.detailpath, params: props.params });
if (props?.extendField) {
let obj = {};
res?.data?.data[props.extendField]?.forEach((it) => {
res?.data?.data[props.extendField]?.forEach?.((it) => {
obj[it?.fieldId] = it?.fieldRealValue;
});
//console.log('extendField:', obj);
......
......@@ -68,7 +68,7 @@ const App = ({
valueType: 'split',
},
];
res?.data?.dataList?.forEach((el) => {
res?.data?.dataList?.forEach?.((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
......
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useState, useRef, memo, createElement, useEffect } from 'react';
import {
ProForm,
......@@ -320,7 +321,7 @@ function Digit({ item, colProps }) {
placeholder={`请输入${item.title}`}
min={item.min}
max={item.max}
fieldProps={{ precision: item.precision ?? 0, ...(item?.fieldProps ?? {}) }}
fieldProps={{ precision: item.precision ?? 2, ...(item?.fieldProps ?? {}) }}
/>
</>
);
......@@ -1389,7 +1390,7 @@ function Diyrules({ item, colProps, formRef }) {
other: {},
value: [],
};
value?.forEach((it) => {
value?.forEach?.((it) => {
if (it?.noRuleCode == 'increasing_order') {
nrList.other = it;
} else {
......@@ -1509,10 +1510,6 @@ function TableSelect({ item, value, onChange, params = {} }) {
}
/>
);
useEffect(() => {
onChange([]);
actionRef?.current?.reload?.();
}, [params]);
const Todo = (
<EditTable
......
......@@ -123,18 +123,18 @@ function InitForm(props) {
let res = await doFetch({ url: detailpath, params });
if (extendField) {
let obj = {};
res?.data?.data[extendField]?.forEach((it) => {
res?.data?.data[extendField]?.forEach?.((it) => {
obj[it?.fieldId] = it?.fieldRealValue;
});
console.log('dddddd', {
...(res?.data?.data ?? {}),
...obj,
...defaultFormValue,
...(res?.data?.data ?? {}),
});
return {
...(res?.data?.data ?? {}),
...obj,
...defaultFormValue,
...(res?.data?.data ?? {}),
};
}
return {
......
......@@ -47,7 +47,7 @@ const NoticeIcon: React.FC<NoticeIconProps> & {
return null;
}
const panes: React.ReactNode[] = [];
React.Children.forEach(children, (child: React.ReactElement<NoticeIconTabProps>): void => {
React.Children.forEach?.(children, (child: React.ReactElement<NoticeIconTabProps>): void => {
if (!child) {
return;
}
......
......@@ -55,7 +55,7 @@ const getNoticeData = (notices: API.NoticeIconItem[]): Record<string, API.Notice
const getUnreadData = (noticeData: Record<string, API.NoticeIconItem[]>) => {
const unreadMsg: Record<string, number> = {};
Object.keys(noticeData).forEach((key) => {
Object.keys(noticeData).forEach?.((key) => {
const value = noticeData[key];
if (!unreadMsg[key]) {
......
......@@ -85,7 +85,7 @@ const TagView = ({ children, home }) => {
const tagsCopy = tagList.map((el, i) => ({ ...el }));
// 判断关闭标签是否处于打开状态
tagList.forEach((el, i) => {
tagList.forEach?.((el, i) => {
if (el.path === tag.path && tag.active) {
const next = tagList[i - 1];
next.active = true;
......
......@@ -8,7 +8,7 @@ const BASE_URL = `http://localhost:${process.env.PORT || 8001}`;
function formatter(routes: any, parentPath = ''): string[] {
const fixedParentPath = parentPath.replace(/\/{1,}/g, '/');
let result: string[] = [];
routes.forEach((item: { path: string; routes: string }) => {
routes.forEach?.((item: { path: string; routes: string }) => {
if (item.path && !item.path.startsWith('/')) {
result.push(`${fixedParentPath}/${item.path}`.replace(/\/{1,}/g, '/'));
}
......@@ -38,7 +38,7 @@ const testPage = (path: string, page: Page) => async () => {
const routers = formatter(RouterConfig);
routers.forEach((route) => {
routers.forEach?.((route) => {
test(`test route page ${route}`, async ({ page }) => {
await testPage(route, page);
});
......
......@@ -11,7 +11,7 @@ const clearCache = () => {
caches
.keys()
.then((keys) => {
keys.forEach((key) => {
keys.forEach?.((key) => {
caches.delete(key);
});
})
......@@ -78,7 +78,7 @@ if (pwa) {
const { serviceWorker } = navigator;
if (serviceWorker.getRegistrations) {
serviceWorker.getRegistrations().then((sws) => {
sws.forEach((sw) => {
sws.forEach?.((sw) => {
sw.unregister();
});
});
......
......@@ -492,4 +492,13 @@ ol {
top: -162px;
left: 74px;
color: #1890ff;
}
\ No newline at end of file
}
.ant-popover-buttons {
display: flex;
align-items: center;
justify-content: space-between;
}
.ant-input-number {
width: 100%;
}
......@@ -719,7 +719,7 @@ function Model(props) {
});
if (res?.data?.dataList) {
let column = [];
res?.data?.dataList?.forEach((el) => {
res?.data?.dataList?.forEach?.((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
......@@ -737,7 +737,7 @@ function Model(props) {
params: { id: drawer?.item?.id },
});
let obj = {};
res?.data?.data['equipmentCharList']?.forEach((it) => {
res?.data?.data['equipmentCharList']?.forEach?.((it) => {
obj[it?.fieldId] = it?.fieldRealValue;
});
console.log('drawerpro:', {
......
......@@ -199,7 +199,7 @@ function Supplier(props) {
});
if (res?.data?.dataList) {
let column = [];
res?.data?.dataList?.forEach((el) => {
res?.data?.dataList?.forEach?.((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
......@@ -216,7 +216,7 @@ function Supplier(props) {
params: { id: drawer?.item?.id },
});
let obj = {};
res?.data?.data['equipmentSupplierCharList']?.forEach((it) => {
res?.data?.data['equipmentSupplierCharList']?.forEach?.((it) => {
obj[it?.fieldId] = it?.fieldRealValue;
});
......
function getcolumns(setdrawer) {
return {
"pathconfig": {
"enableadd": false,
"enableedit": false,
"enabledelete": false,
"enabledetail": false,
"add": "",
"edit": "",
"list": "/repair/umRepairOrder/queryRepairOrderList",
"delete": "",
"detail": ""
},
"columns": [
{
"title": "维修单号",
"dataIndex": "repairOrderNo",
"key": "repairOrderNo"
},
{
"title": "设备编号",
"dataIndex": "equipmentNo",
"key": "equipmentNo"
},
{
"title": "设备名称",
"dataIndex": "equipmentName",
"key": "equipmentName"
},
{
"title": "故障描述",
"dataIndex": "faultDescription",
"key": "faultDescription"
},
{
"title": "报修人员",
"dataIndex": "repairUserName",
"key": "repairUserName"
},
{
"title": "报修时间",
"dataIndex": "repairTime",
"key": "repairTimeList",
"valueType": "dateTimeRange"
},
{
"title": "报修单号",
"dataIndex": "repairNo",
"key": "repairNo"
},
{
"title": "工单状态",
"dataIndex": "statusName",
"key": "statusName"
}
]
};
columns: [
{
title: '备件料号',
dataIndex: 'sparePartNo',
key: 'sparePartNo',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
title: '备件名称',
dataIndex: 'sparePartName',
key: 'sparePartName',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
title: '备件类型',
dataIndex: 'sparePartTypeName',
key: 'sparePartTypeId',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
valueType: 'treeSelect',
options: {
path: '/sparepart/sparePartType/queryTreeList',
params: {},
},
},
{
title: '库存上限',
dataIndex: 'stockUpper',
key: 'stockUpper',
valueType: 'digit',
},
{
title: '库存下限',
dataIndex: 'stockLower',
key: 'stockLower',
valueType: 'digit',
},
{
title: '库存单位',
dataIndex: 'unit',
key: 'unit',
formItemProps: {
rules: [
{
required: true,
message: '此项为必填项',
},
],
},
},
{
title: '是否寿命件',
dataIndex: 'isLifeName',
key: 'isLife',
valueType: 'select',
options: [
{
label: '是',
value: 1,
},
{
label: '否',
value: 2,
},
],
},
{
title: '供应商信息',
dataIndex: 'relations',
key: 'relations',
valueType: 'split',
},
{
title: '选择供应商',
dataIndex: 'relationSupplierList',
key: 'relationSupplierList',
valueType: 'formSelectList',
colProps: {
span: 24,
},
columns: [
{
title: '供应商编号',
dataIndex: 'supplierNo',
key: 'supplierNo',
editable: false,
},
{
title: '供应商名称',
dataIndex: 'supplierName',
key: 'supplierName',
editable: false,
},
{
title: '保质期(天)',
dataIndex: 'qualityGuarantee',
valueType: 'digit',
precision: 2,
fieldProps: {
precision: 2,
},
},
{
title: '价值',
dataIndex: 'value',
valueType: 'money',
},
],
path: '/sparepart/sparePartSupplier/queryList',
params: { status: 1 },
},
],
pathconfig: {
enableadd: true,
enableedit: true,
enabledelete: true,
enabledetail: true,
add: '/sparepart/sparePart/save',
edit: '/sparepart/sparePart/save',
list: '/sparepart/sparePart/queryList',
delete: '/sparepart/sparePart/deleteById',
detail: '/sparepart/sparePart/queryDetails',
},
};
}
export default getcolumns;
\ No newline at end of file
export default getcolumns;
import * as React from 'react';
import { useState, useMemo, 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 { useState, useMemo, 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 { message } from 'antd';
function Setting(props) {
const actionRef = useRef(),
formRef = useRef();
const [drawer, setdrawer] = useState({
open: false,
});
const pathconfig = useMemo(() => {
let pathconf = getcolumns(setdrawer)?.pathconfig ?? {};
return pathconf;
}, []);
const { run, loading } = useRequest(doFetch, {
manual: true,
onSuccess: (res, params) => {
if (res?.code == '0000') {
actionRef?.current?.reload();
setdrawer((s) => ({
...s,
open: false,
}));
}
},
});
function Setting(props) {
const actionRef = useRef(),
formRef = useRef();
const [drawer, setdrawer] = useState({
open: false,
});
const pathconfig = useMemo(() => {
let pathconf = getcolumns(setdrawer)?.pathconfig ?? {};
return pathconf;
}, []);
const { run, loading } = useRequest(doFetch, {
manual: true,
onSuccess: (res, params) => {
if (res?.code == '0000') {
message.success('操作成功');
actionRef?.current?.reload();
setdrawer((s) => ({
...s,
open: false,
}));
}
},
});
const detail = (text, row, _, action) => {
return (
<PremButton
btn={{
size: 'small',
type: 'link',
onClick: () => {
setdrawer((s) => ({
...s,
open: true,
item: row,
title: '详情',
val: 'detail',
title: '详细信息',
}));
},
}}
>
详情
</PremButton>
);
};
const detail = (text, row, _, action) => {
return (
<PremButton
btn={{
size: 'small',
type: 'link',
onClick: () => {
setdrawer((s) => ({
...s,
open: true,
item: row,
title: '详情',
val: 'detail',
title: '详细信息',
}));
},
}}
>
详情
</PremButton>
);
};
const edit = (text, row, _, action) => {
return (
<PremButton
btn={{
size: 'small',
onClick: () => {
setdrawer((s) => ({
...s,
open: true,
item: row,
title: '编辑',
val: 'edit',
}));
},
}}
>
编辑
</PremButton>
);
};
const remove = (text, row, _, action) => {
return (
<PremButton
pop={{
title: '是否删除?',
okText: '确认',
cancelText: '取消',
onConfirm: () => {
run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } });
},
}}
btn={{
size: 'small',
type: 'danger',
}}
>
删除
</PremButton>
);
};
const edit = (text, row, _, action) => {
return (
<PremButton
btn={{
size: 'small',
const columns = useMemo(() => {
let defcolumn = getcolumns(setdrawer)?.columns;
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),
],
});
}, []);
return (
<div style={{ position: 'relative' }}>
<AutoTable
pagetitle=" 备件设置"
columns={columns}
actionRef={actionRef}
path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
pageextra={pathconfig?.enableadd ? 'add' : null}
resizeable={false}
addconfig={{
// access: 'sysDepartment_save',
btn: {
disabled: false,
onClick: () => {
setdrawer((s) => ({
...s,
open: true,
item: row,
title: '编辑',
val: 'edit',
item: null,
title: '新增',
val: 'add',
}));
},
}}
>
编辑
</PremButton>
);
};
const remove = (text, row, _, action) => {
return (
<PremButton
pop={{
title: '是否删除?',
okText: '确认',
cancelText: '取消',
onConfirm: () => {
run({ url: pathconfig?.delete || '/delete', params: { id: row?.id } });
},
}}
btn={{
size: 'small',
type: 'danger',
}}
>
删除
</PremButton>
);
};
},
}}
/>
const columns = useMemo(() => {
let defcolumn = getcolumns(setdrawer)?.columns;
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),
],
});
}, []);
return (
<div style={{ position: 'relative' }}>
<AutoTable
pagetitle=" 备件设置"
columns={columns}
actionRef={actionRef}
path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
pageextra={pathconfig?.enableadd ? 'add' : null}
resizeable={true}
addconfig={{
// access: 'sysDepartment_save',
btn: {
disabled: false,
onClick: () => {
setdrawer((s) => ({
...s,
open: true,
item: null,
title: '新增',
val: 'add',
}));
},
},
}}
/>
<DrawerPro
fields={columns}
params={{ id: drawer?.item?.id }}
formRef={formRef}
placement="right"
detailpath={pathconfig?.detail || null}
detailData={drawer?.item}
defaultFormValue={drawer?.item}
onClose={() => {
setdrawer((s) => ({
...s,
open: false,
}));
}}
{...drawer}
onFinish={(vals) => {
if (drawer?.val == 'add') {
run({ url: pathconfig?.add || '/add', params: { ...vals } });
} else if (drawer?.val == 'edit') {
run({ url: pathconfig?.edit || '/edit', params: { ...vals, id: drawer?.item?.id } });
}
}}
/>
</div>
);
}
<DrawerPro
fields={columns}
params={{ id: drawer?.item?.id }}
formRef={formRef}
placement="right"
detailpath={pathconfig?.detail || null}
detailData={drawer?.item}
defaultFormValue={drawer?.item}
onClose={() => {
setdrawer((s) => ({
...s,
open: false,
}));
}}
{...drawer}
onFinish={(vals) => {
const relationSupplierList = vals?.relationSupplierList?.map?.((it, i) => {
return {
supplierId: it?.id,
qualityGuarantee: it?.qualityGuarantee,
value: it?.value,
};
});
if (drawer?.val == 'add') {
run({ url: pathconfig?.add || '/add', params: { ...vals, relationSupplierList } });
} else if (drawer?.val == 'edit') {
run({
url: pathconfig?.edit || '/edit',
params: { ...vals, id: drawer?.item?.id, relationSupplierList },
});
}
}}
/>
</div>
);
}
export default Setting;
\ No newline at end of file
export default Setting;
function getcolumns(setdrawer) {
import { Switch } from 'antd';
function getcolumns(changeState) {
return {
columns: [
{
......@@ -24,6 +26,7 @@ function getcolumns(setdrawer) {
dataIndex: 'officialWebsite',
key: 'officialWebsite',
hideInSearch: true,
hideInTable: true,
},
{
title: '联系电话',
......@@ -41,6 +44,22 @@ function getcolumns(setdrawer) {
key: 'address',
hideInSearch: true,
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark',
colProps: {
span: 24,
},
valueType: 'textarea',
hideInSearch: true,
},
{
title: '评分',
dataIndex: 'score',
key: 'score',
valueType: 'rate',
},
{
title: '状态',
dataIndex: 'statusName',
......@@ -65,22 +84,18 @@ function getcolumns(setdrawer) {
},
],
},
},
{
title: '评分',
dataIndex: 'score',
key: 'score',
valueType: 'rate',
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark',
colProps: {
span: 24,
render: (text, row) => {
return (
<Switch
checked={row?.status == 1}
checkedChildren="启用"
unCheckedChildren="停用"
onChange={(e) => {
changeState({ id: row.id, status: e ? 1 : 2 });
}}
/>
);
},
valueType: 'textarea',
hideInSearch: true,
},
{
title: '列表',
......
......@@ -7,6 +7,7 @@ import getcolumns from './columns';
import { useAsyncEffect, useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch';
import extraColumns from '@/utils/extraColumns';
import { message } from 'antd';
function Supplier(props) {
const actionRef = useRef(),
......@@ -23,7 +24,7 @@ function Supplier(props) {
]);
const pathconfig = useMemo(() => {
let pathconf = getcolumns(setdrawer)?.pathconfig ?? {};
let pathconf = getcolumns(changeState)?.pathconfig ?? {};
return pathconf;
}, []);
......@@ -105,12 +106,21 @@ function Supplier(props) {
);
};
function changeState(params) {
doFetch({ url: '/sparepart/sparePartSupplier/stopAndStart', params }).then((res) => {
if (res.code == '0000') {
message.success('操作成功');
actionRef?.current?.reload();
}
});
}
useAsyncEffect(async () => {
let extracolumns = await extraColumns({
url: '/base/paFormField/queryList',
params: { formId: 4 },
});
let defcolumn = getcolumns(setdrawer)?.columns;
let defcolumn = getcolumns(changeState)?.columns;
setcolumns([
...defcolumn,
...extracolumns,
......@@ -126,7 +136,6 @@ function Supplier(props) {
},
]);
}, []);
console.log(columns);
return (
<div style={{ position: 'relative' }}>
......
......@@ -85,7 +85,7 @@ function Rules(props) {
(_, index) => index + 1,
).filter((it) => it !== vals?.nrList.other.sort + 1);
params.nrList.splice(vals?.nrList.other.sort, 0, vals?.nrList.other);
params.nrList.forEach((it, i) => {
params.nrList.forEach?.((it, i) => {
it.sort = i + 1;
});
} else {
......@@ -204,7 +204,7 @@ function Rules(props) {
(_, index) => index + 1,
).filter((it) => it !== vals?.nrList.other.sort + 1);
params.nrList.splice(vals?.nrList.other.sort, 0, vals?.nrList.other);
params.nrList.forEach((it, i) => {
params.nrList.forEach?.((it, i) => {
it.sort = i + 1;
});
} else {
......
......@@ -5,20 +5,24 @@ const selectValueType = (type, options) => {
case 1:
return {
valueType: 'input',
hideInTable: true,
};
case 2:
return {
valueType: 'select',
hideInTable: true,
options,
};
case 3:
return {
valueType: 'radio',
hideInTable: true,
options,
};
case 4:
return {
valueType: 'select',
hideInTable: true,
fieldProps: {
mode: 'multiple',
},
......
......@@ -53,7 +53,7 @@ export default async (fieldscolumns, setdrawer, row, formId, detailpath) => {
valueType: 'split',
},
];
res?.data?.dataList?.forEach((el) => {
res?.data?.dataList?.forEach?.((el) => {
column.push({
...selectValueType(el.fieldChar, el.valueList),
title: el.fieldName,
......
......@@ -3,7 +3,7 @@ import { useEffect, useMemo } from 'react';
function treeToArr(data) {
const result = [];
data?.forEach((item) => {
data?.forEach?.((item) => {
const loop = (data) => {
result.push(data?.path);
let child = data.routes;
......
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