Commit 394bf9ae authored by TZW's avatar TZW

cc

parent b61e13e4
......@@ -11,6 +11,10 @@ const { Item } = ProDescriptions;
function DetailPro(props) {
let { fields } = props;
if (Object.keys(fields[0]).includes('render')) {
delete fields[0].render;
}
const [curitem, setcuritem] = useState(props.detailData ?? {}); //全部数据
const dataProps = useMemo(() => {
......
......@@ -21,6 +21,8 @@ const EditTable = (props) => {
dataSource,
} = props;
let actionRefs = useRef(),
formRefs = formRef ?? useRef(),
ifspagination = pagination == 'false' || pagination === false,
......@@ -34,9 +36,9 @@ const EditTable = (props) => {
success: true,
total: dataSource?.length ?? 0,
};
console.log('====================================');
console.log(extraparams);
console.log('====================================');
// console.log('====================================');
// console.log(extraparams);
// console.log('====================================');
let newparams = {
...params,
...extraparams, //父组件传参
......
import { doFetch } from '@/utils/doFetch';
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useForceUpdate } from 'react';
import AutoTable from '../../AutoTable/mtable';
import EditTable from '../EditTable';
function Expandables({ value = [], onChange, item }) {
const [allDatasource, setallDatasource] = useState({});
const [nvalue, setnvalue] = useState([]);
return (
<div>
<AutoTable
......@@ -21,6 +21,7 @@ function Expandables({ value = [], onChange, item }) {
? value.filter((it) => it.lifePieceAccountId == record.id)?.[0]
: {};
//value中的list
let curvalist = curvalue?.lineStockUseList ?? [];
doFetch({ url: item.expandablePath, params: { lifePieceAccountId: record.id } }).then(
(res) => {
......@@ -47,131 +48,155 @@ function Expandables({ value = [], onChange, item }) {
let curvalue = value
? value.filter((it) => it.lifePieceAccountId == record.id)?.[0]
: {};
// console.log('nvalue', nvalue);
// console.log('record', record);
// console.log('allDatasource:', allDatasource);
// console.log(
// 'defaultvalue:',
// nvalue?.filter((it) => it.lifePieceAccountId == record.id)?.[0]?.lineStockUseList,
// );
return (
<EditTable
resizeable={false}
alwaysShowAlert={false}
tableAlertRender={false}
tableAlertOptionRender={false}
columns={[
{
title: '线边库',
dataIndex: 'stockName',
search: false,
key: 'stockName',
editable: false,
},
{
title: '供应商编号',
dataIndex: 'supplierNo',
key: 'supplierNo',
search: false,
editable: false,
},
{
title: '供应商名称',
dataIndex: 'supplierName',
search: false,
key: 'supplierName',
editable: false,
},
{
title: '可用数量',
dataIndex: 'usedStock',
search: false,
key: 'usedStock',
editable: false,
},
{
title: (
<div>
更换数量 <span style={{ color: 'red' }}>* </span>
</div>
),
dataIndex: 'operateNum',
search: false,
key: 'operateNum',
valueType: 'digit',
fieldProps: {
precision: 3,
<>
<EditTable
key={nvalue
.filter((it) => it.lifePieceAccountId == record.id)?.[0]
?.lineStockUseList.map((it) => it.lineStockId)}
resizeable={false}
alwaysShowAlert={false}
tableAlertRender={false}
tableAlertOptionRender={false}
defaultValue={nvalue
?.filter((it) => it.lifePieceAccountId == record.id)?.[0]
?.lineStockUseList.map((i) => ({
id: i.lineStockId,
operateNum: i.operateNum,
}))}
columns={[
{
title: '线边库',
dataIndex: 'stockName',
search: false,
key: 'stockName',
editable: false,
},
{
title: '供应商编号',
dataIndex: 'supplierNo',
key: 'supplierNo',
search: false,
editable: false,
},
{
title: '供应商名称',
dataIndex: 'supplierName',
search: false,
key: 'supplierName',
editable: false,
},
},
]}
dataSource={allDatasource[record.id]}
extraparams={allDatasource}
rowSelection={{
getCheckboxProps: (record) => ({
disabled: record.isAsh == '1',
}),
columnWidth: 44,
preserveSelectedRowKeys: true,
selectedRowKeys: curvalue?.lineStockUseList
? curvalue.lineStockUseList?.map?.((it) => it?.lineStockId)
: [],
onChange: (selectedKeys, selectedRows) => {
// debugger;
const curval = curvalue?.lineStockUseList ?? [];
const rowkeylist = curval?.map?.((it) => it?.lineStockId);
{
title: '可用数量',
dataIndex: 'usedStock',
search: false,
key: 'usedStock',
editable: false,
},
{
title: (
<div>
更换数量 <span style={{ color: 'red' }}>* </span>
</div>
),
dataIndex: 'operateNum',
search: false,
key: 'operateNum',
valueType: 'digit',
fieldProps: {
precision: 3,
},
},
]}
dataSource={allDatasource[record.id]}
extraparams={allDatasource}
rowSelection={{
getCheckboxProps: (record) => ({
disabled: record.isAsh == '1',
}),
columnWidth: 44,
preserveSelectedRowKeys: true,
selectedRowKeys: curvalue?.lineStockUseList
? curvalue.lineStockUseList?.map?.((it) => it?.lineStockId)
: [],
onChange: async (selectedKeys, selectedRows) => {
// debugger;
const newValue = selectedRows?.map((its) => {
if (rowkeylist?.includes(its?.id)) {
return curval?.filter((it) => it?.lineStockId == its?.id)[0];
} else {
return {
lineStockId: its.id,
operateNum: its.operateNum,
};
}
});
const curval = curvalue?.lineStockUseList ?? [];
const rowkeylist = curval?.map?.((it) => it?.lineStockId);
let nvalue = value ? [...value] : [];
if (value && value?.some((it) => it.lifePieceAccountId == record?.id)) {
nvalue = value?.map((it, i) => {
if (it.lifePieceAccountId == record.id) {
it.lineStockUseList = newValue;
const newValue = selectedRows?.map((its) => {
if (rowkeylist?.includes(its?.id)) {
return curval?.filter((it) => it?.lineStockId == its?.id)[0];
} else {
return {
lineStockId: its.id,
operateNum: its.operateNum,
};
}
return it;
});
} else {
nvalue.push({
lifePieceAccountId: record?.id,
lineStockUseList: newValue,
});
}
onChange(nvalue);
},
}}
editable={{
onValuesChange: (rower, recordList) => {
const curval = curvalue?.lineStockUseList ?? [];
const newValue = curval?.map((its) => {
if (its?.lineStockId == rower?.id) {
return {
lineStockId: rower.id,
operateNum: rower.operateNum,
};
let nvalue = value ? [...value] : [];
if (value && value?.some((it) => it.lifePieceAccountId == record?.id)) {
nvalue = value?.map((it, i) => {
if (it.lifePieceAccountId == record.id) {
it.lineStockUseList = newValue;
}
return it;
});
} else {
return its;
nvalue.push({
lifePieceAccountId: record?.id,
lineStockUseList: newValue,
});
}
});
let nvalue = value ? [...value] : [];
if (value && value?.some((it) => it.lifePieceAccountId == record?.id)) {
nvalue = value?.map((it, i) => {
if (it.lifePieceAccountId == record.id) {
it.lineStockUseList = newValue;
// console.log('nvalue', nvalue);
nvalue = nvalue.filter((it) => it.lineStockUseList.length !== 0);
await onChange(nvalue);
await setnvalue(nvalue);
},
}}
editable={{
onValuesChange: async (rower, recordList) => {
const curval = curvalue?.lineStockUseList ?? [];
const newValue = curval?.map((its) => {
if (its?.lineStockId == rower?.id) {
return {
lineStockId: rower.id,
operateNum: rower.operateNum,
};
} else {
return its;
}
return it;
});
} else {
nvalue.push({
id: record.id,
lineStockUseList: newValue,
});
}
onChange(nvalue);
},
}}
/>
let nvalue = value ? [...value] : [];
if (value && value?.some((it) => it.lifePieceAccountId == record?.id)) {
nvalue = value?.map((it, i) => {
if (it.lifePieceAccountId == record.id) {
it.lineStockUseList = newValue;
}
return it;
});
} else {
nvalue.push({
lifePieceAccountId: record.id,
lineStockUseList: newValue,
});
}
// console.log('nvalue', nvalue);
await onChange(nvalue);
await setnvalue(nvalue);
},
}}
/>
</>
);
},
}}
......
......@@ -183,7 +183,6 @@ let FormRender = memo(({ fields = [], name, curindex, formRef }) => {
// colProps 默认删格
function Input({ item, colProps }) {
let keys = item?.key ?? item?.dataIndex ?? '';
keys = keys ?? '';
const defaultrule =
keys.indexOf('phone') != -1
? {
......@@ -1448,7 +1447,7 @@ function Expandable({ item, colProps }) {
return (
<Col {...col} style={{ marginBottom: 16 }}>
<ProForm.Item name={curkey} label={item.title} {...item.formItemProps}>
<Expandables item={item} />
<Expandables item={item} key={item} />
</ProForm.Item>
</Col>
);
......@@ -1487,13 +1486,72 @@ function FormList({ item, colProps, formRef }) {
);
}
const Todo = ({ actionRef, value, item, params, rowKey, chooses, onChange }) => {
const Todo = ({ actionRef, value = [], item, params, rowKey, chooses, onChange }) => {
return (
<>
<EditTable
// loading={false}
actionRef={actionRef}
defaultValue={value} //调用接口合并初始值
path={item.path}
extraparams={params ?? {}}
rowKey={rowKey}
key={value}
columns={item.columns}
resizeable={false}
alwaysShowAlert={false}
tableAlertRender={false}
tableAlertOptionRender={false}
rowClassName={(record, index) => {
if (chooses.includes(record[rowKey])) {
return 'lightblue';
} else {
return '';
}
}}
rowSelection={{
...item.rowSelection,
columnWidth: 44,
preserveSelectedRowKeys: true,
selectedRowKeys: value && value?.map((it) => it[rowKey]),
onChange: (selectedKeys, selectedRows) => {
// console.log('row', selectedRows, 'selectkey:', selectedKeys);
// console.log('value:', value);
const rowkeylist = value ? value?.map((it) => it[rowKey]) : [];
// console.log('rowkeyList:', rowkeylist);
const newValue = selectedRows?.map((its) => {
if (rowkeylist.includes(its[rowKey])) {
return value.filter((it) => it[rowKey] == its[rowKey])[0];
} else {
return its;
}
});
// console.log('newValue:', newValue);
onChange(newValue);
},
}}
editable={{
onValuesChange: (record, recordList) => {
const newValue = value?.map((its) => {
if (its[rowKey] == record[rowKey]) {
return record;
} else {
return its;
}
});
// console.log('edit-newvalue:', newValue);
onChange(newValue);
},
}}
/>
</>
);
};
const Done = ({ actionRef, value, item, params, rowKey, chooses, onChange }) => {
return (
<EditTable
actionRef={actionRef}
defaultValue={value} //调用接口合并初始值
path={item.path}
extraparams={params ?? {}}
value={value}
rowKey={rowKey}
columns={item.columns}
resizeable={false}
......@@ -1540,54 +1598,6 @@ const Todo = ({ actionRef, value, item, params, rowKey, chooses, onChange }) =>
);
};
const Done = ({ actionRef, value, item, params, rowKey, chooses, onChange }) => (
<EditTable
value={value}
rowKey={rowKey}
columns={item.columns}
resizeable={false}
alwaysShowAlert={false}
tableAlertRender={false}
tableAlertOptionRender={false}
rowClassName={(record, index) => {
if (chooses.includes(record[rowKey])) {
return 'lightblue';
} else {
return '';
}
}}
rowSelection={{
...item.rowSelection,
columnWidth: 44,
preserveSelectedRowKeys: true,
selectedRowKeys: value && value?.map((it) => it[rowKey]),
onChange: (selectedKeys, selectedRows) => {
const rowkeylist = value ? value?.map((it) => it[rowKey]) : [];
const newValue = selectedRows?.map((its) => {
if (rowkeylist.includes(its[rowKey])) {
return value.filter((it) => it[rowKey] == its[rowKey])[0];
} else {
return its;
}
});
onChange(newValue);
},
}}
editable={{
onValuesChange: (record, recordList) => {
const newValue = value?.map((its) => {
if (its[rowKey] == record[rowKey]) {
return record;
} else {
return its;
}
});
onChange(newValue);
},
}}
/>
);
function TableSelect({ item, value, onChange, params = {} }) {
const rowKey = item?.rowKey ?? 'id';
const [chooses, setchooses] = useState([]); //mark 标记
......
......@@ -15,6 +15,7 @@ import FormItems from './FormItems';
import ExtendField from '@/components/ExtendField';
import { Input, Col } from 'antd';
import { useDebounceFn } from 'ahooks';
import ColumnsTrans from './ColumnsTrans';
function upperCase(str) {
const newStr = str.slice(0, 1).toUpperCase() + str.slice(1);
......@@ -119,7 +120,9 @@ function InitForm(props) {
const { run } = useDebounceFn(onFinish, { wait: 400 });
let proformRef = useRef();
proformRef = formRef ?? proformRef;
return (
return fields?.length == 0 ? (
<ColumnsTrans />
) : (
<ProForm
style={{ overflow: 'hidden', ...style }}
formRef={proformRef}
......
......@@ -21,6 +21,7 @@ function getcolumns(setdrawer) {
hideInSearch: true,
valueType: 'digit',
fieldProps: {
defaultValue:0,
precision: 0,
},
formItemProps: {
......
......@@ -3,7 +3,7 @@
* @Author: Li Hanlin
* @Date: 2022-12-02 11:41:03
* @Last Modified by: Li Hanlin
* @Last Modified time: 2023-02-27 17:17:41
* @Last Modified time: 2023-03-07 11:34:10
*/
import * as React from 'react';
......@@ -991,6 +991,7 @@ function Failure(props) {
}
}}
onFinish={async (vals) => {
console.log(vals);
let params = {
repairComplete: {
faultType: vals.faultSettingId,
......@@ -1655,7 +1656,7 @@ function Failure(props) {
detail: (
<Detail
title="维修单号"
titleno={drawer?.item?.repairNo}
titleno={drawer?.item?.repairOrderNo}
detailpath="/repair/umRepairOperation/queryOperationList"
params={{ repairOrderId: drawer?.item?.id }}
baseRow={drawer?.item}
......
......@@ -124,10 +124,10 @@ function getcolumns(setDrawer, ifs, formRef) {
dataIndex: 'pictureUrl',
key: 'pictureUrl',
render: (text, row) => {
if (row?.pictureUrl == null) {
if (row?.userImgList == null || row?.userImgList.length == 0) {
return '暂无图片';
} else {
return <Image width={70} src={row.pictureUrl} />;
return <Image width={70} src={row.userImgList[0]?.url} />;
}
},
},
......
......@@ -151,38 +151,38 @@ function getcolumns(setdrawer) {
hideInSearch: true,
hideInTable: true,
},
{
title: '供应商信息',
dataIndex: 'relations',
key: 'relations',
valueType: 'split',
},
{
// title: '供应商',
dataIndex: 'relationSupplierList',
key: 'relationSupplierList',
valueType: 'formSelectList',
colProps: {
span: 24,
},
columns,
span: 12,
path: '/sparepart/sparePartSupplier/queryList',
params: { status: 1 },
hideInSearch: true,
hideInTable: true,
render: (text, row) => {
return (
<AutoTable
columns={columns?.map((it) => ({
...it,
hideInSearch: true,
}))}
dataSource={row?.relationSupplierList}
/>
);
},
},
// {
// title: '供应商信息',
// dataIndex: 'relations',
// key: 'relations',
// valueType: 'split',
// },
// {
// // title: '供应商',
// dataIndex: 'relationSupplierList',
// key: 'relationSupplierList',
// valueType: 'formSelectList',
// colProps: {
// span: 24,
// },
// columns,
// span: 12,
// path: '/sparepart/sparePartSupplier/queryList',
// params: { status: 1 },
// hideInSearch: true,
// hideInTable: true,
// render: (text, row) => {
// return (
// <AutoTable
// columns={columns?.map((it) => ({
// ...it,
// hideInSearch: true,
// }))}
// dataSource={row?.relationSupplierList}
// />
// );
// },
// },
],
pathconfig: {
enableadd: true,
......
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