Commit f2a736d1 authored by Bill's avatar Bill

fix

parent 60abf477
import React from 'react';
export const productColumns = [
// { title: '订单号', dataIndex: 'orderNo' },
{ title: '商品ID', dataIndex: 'commodityId' },
{ title: '商品名称', dataIndex: 'name' },
{ title: '品类', dataIndex: 'customerCategoryName' },
{ title: '品牌', dataIndex: 'brandName' },
{ title: '单位', dataIndex: 'unitName' },
// { title: '订单数量', dataIndex: 'orderTotal' },
// { title: '剩余加工数量', dataIndex: 'restTotal' },
{ title: '加工数量', dataIndex: 'processNum' },
{ title: '加工单价', dataIndex: 'processUnitPrice' },
{ title: '加工费', dataIndex: 'processTotalPrice'},
]
export const orderColumns = [
{ title: '订单号', dataIndex: 'orderNo' },
{ title: '商品ID', dataIndex: 'commodityId' },
{ title: '商品名称', dataIndex: 'name' },
{ title: '品类', dataIndex: 'customerCategoryName' },
{ title: '品牌', dataIndex: 'brandName' },
{ title: '单位', dataIndex: 'unitName' },
{ title: '订单数量', dataIndex: 'orderTotal' },
{ title: '剩余加工数量', dataIndex: 'restTotal' },
{ title: '加工数量', dataIndex: 'processNum' },
{ title: '加工单价', dataIndex: 'processUnitPrice' },
{ title: '加工费', dataIndex: 'processTotalPrice'},
]
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { PublicApi } from '@/services/api';
const { onFieldValueChange$, onFieldMount$ } = FormEffectHooks
/**
* formEffect, 表单联动操作放这里操作,包括表单的生命周期等操作
*/
export const formEffects = () => {
const formActions = createFormActions()
// 当物流为 物流时,那么填充
onFieldMount$('receivefullAddress').subscribe((state) => {
PublicApi.getLogisticsReceiverAddressPage({current: '1', pageSize: '99'})
.then((res) => {
let options = [];
if(res.code === 1000) {
options = res.data.data.map((item) => {
return {
label: `${item.fullAddress} / ${item.receiverName} / ${item.phone}`,
value: item.id
}}
)
}
formActions.setFieldState("receivefullAddress", (state) => {
state.props["x-component-props"]["options"] = options;
})
})
})
/**
* 当改变物流地址的时候,那么修改隐藏的3个字段,
* 1. receiveAddress 详细的物流地址
* 2. receiveUserName 收货人
* 3. receiveUserTel 收货人电话
*/
onFieldValueChange$('receivefullAddress').subscribe((state) => {
if(state.visible) {
const options = state.props["x-component-props"]["options"];
const target = options.filter((item) => item.value == state.value)[0];
if(target) {
const [receiveAddress, receiveUserName, receiveUserTel] = target.label.split("/");
formActions.setFieldValue("receiveAddress", receiveAddress.trim());
formActions.setFieldValue("receiveUserName", receiveUserName.trim());
formActions.setFieldValue("receiveUserTel", receiveUserTel.trim());
formActions.setFieldValue("receiverAddressId", state.value)
}
}
})
}
...@@ -19,16 +19,16 @@ import { getAuth } from '@/utils/auth'; ...@@ -19,16 +19,16 @@ import { getAuth } from '@/utils/auth';
import { ENTERPRISE_MALL } from '../../common'; import { ENTERPRISE_MALL } from '../../common';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
import moment from 'moment'; import moment from 'moment';
import { productColumns, orderColumns } from './columns';
import { formEffects } from './formEffects';
const formActions = createFormActions(); const formActions = createFormActions();
const { onFieldValueChange$, onFieldMount$ } = FormEffectHooks
const Add: React.FC<{}> = () => { const Add: React.FC<{}> = () => {
const authInfo = getAuth(); const authInfo = getAuth();
const pathname = history.location.pathname; const pathname = history.location.pathname;
const { id } = usePageStatus(); const { id } = usePageStatus();
const [submitLoading, setSubmitLoading] = useState<boolean>(false); const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const [activeSource, setActiveSource] = useState('加工订单')
// 加工企业 modal 框 // 加工企业 modal 框
const [modalEnterPriseVisible, setEnterPriseModalVisible] = useState<boolean>(false); const [modalEnterPriseVisible, setEnterPriseModalVisible] = useState<boolean>(false);
// 加工商品 modal 框 // 加工商品 modal 框
...@@ -72,6 +72,7 @@ const Add: React.FC<{}> = () => { ...@@ -72,6 +72,7 @@ const Add: React.FC<{}> = () => {
disabled: record.purchaseCount - (record.processNum || 0) <= 0, disabled: record.purchaseCount - (record.processNum || 0) <= 0,
}), }),
}); });
const enterpriseTableRowSelection = useRowSelection({primaryKey: 'id', type: 'radio'});
// 选择加工企业 modal 层 // 选择加工企业 modal 层
const connectProduct = ( const connectProduct = (
...@@ -98,9 +99,9 @@ const Add: React.FC<{}> = () => { ...@@ -98,9 +99,9 @@ const Add: React.FC<{}> = () => {
explain.forEach((item, index) => { explain.forEach((item, index) => {
descValue[descArr[index]] = item.value descValue[descArr[index]] = item.value
}) })
setActiveSource(data.source === 1 ? "加工订单" : "加工商品"); const isOrderProcess = data.source === 1;
const someLists = details.map((item) => { const someLists = details.map((item) => {
const orderData = data.source === 1 const orderData = isOrderProcess
? { ? {
id: item.productId, // 当前id是错误的 id: item.productId, // 当前id是错误的
fullId: item.orderDetailId, fullId: item.orderDetailId,
...@@ -123,39 +124,58 @@ const Add: React.FC<{}> = () => { ...@@ -123,39 +124,58 @@ const Add: React.FC<{}> = () => {
processTotalPrice: item.processTotalPrice, processTotalPrice: item.processTotalPrice,
restTotal: item.surplusProcessNum, restTotal: item.surplusProcessNum,
files: item.property.annex, files: item.property.annex,
productProps: item.property.specs,
...orderData ...orderData
} }
}) })
const keys = someLists.map((item) => item.id);
if(isOrderProcess) {
orderTableRowSelection.setSelectedKeys(keys);
orderTableRowSelection.setSelectedRows(someLists);
} else {
productTableRowSelection.setSelectedKeys(keys);
productTableRowSelection.setSelectedRows(someLists);
}
enterpriseTableRowSelection.setSelectedKeys([data.processMemberId]);
enterpriseTableRowSelection.setSelectedRows([{
id: data.processMemberId,
memberId: data.processMemberId,
name: data.processName,
roleId: data.processRoleId
}])
setEditInfo({ setEditInfo({
...descValue,
...rest,
createTime: moment(data.createTime).format('YYYY-MM-DD'),
receivefullAddress: data.receiverAddressId,
deliveryDate: moment(deliveryDate), deliveryDate: moment(deliveryDate),
enclosure: annex, enclosure: annex,
someLists: someLists, orderList: isOrderProcess ? someLists : [],
...descValue, productList: !isOrderProcess ? someLists : [],
...rest outerWorkFlow: data.outerWorkflowRecordsList,
innerWorkFlow: data.innerWorkflowRecordsList
}) })
} }
}) })
} }
}, [id]) }, [id])
const noticesDetailColumn = () => { useEffect(() => {
const blackList = ["orderNo", "orderTotal", "restTotal"]; if(pathname.includes("add")) {
const tempColumns = [ setEditInfo({
{ title: '订单号', dataIndex: 'orderNo' }, source: 1,
{ title: '商品ID', dataIndex: 'commodityId' }, createTime: " ",
{ title: '商品名称', dataIndex: 'name' }, noticeNo: " "
{ title: '品类', dataIndex: 'customerCategoryName' }, })
{ title: '品牌', dataIndex: 'brandName' }, }
{ title: '单位', dataIndex: 'unitName' }, }, [])
{ title: '订单数量', dataIndex: 'orderTotal' },
{ title: '剩余加工数量', dataIndex: 'restTotal' }, const actionColumns = [{
{ title: '加工数量', dataIndex: 'processNum' },
{ title: '加工单价', dataIndex: 'processUnitPrice' },
{ title: '加工费', dataIndex: 'processTotalPrice'},
{
title: '操作', title: '操作',
render: (text, record) => { render: (text, record) => {
const uniqueID = activeSource == '加工订单'? record.fullId : record.id // 只有加工订单才有fullId
const uniqueID = "fullId" in record ? record.fullId : record.id;
const files = record.files || [];
return ( return (
<Space> <Space>
<ProcessDetail <ProcessDetail
...@@ -169,6 +189,7 @@ const Add: React.FC<{}> = () => { ...@@ -169,6 +189,7 @@ const Add: React.FC<{}> = () => {
category={record.customerCategoryName} category={record.customerCategoryName}
productName={record.name} productName={record.name}
unitName={record.unitName} unitName={record.unitName}
files={files}
> >
<a>查看</a> <a>查看</a>
</ProcessDetail> </ProcessDetail>
...@@ -184,6 +205,8 @@ const Add: React.FC<{}> = () => { ...@@ -184,6 +205,8 @@ const Add: React.FC<{}> = () => {
category={record.customerCategoryName} category={record.customerCategoryName}
productName={record.name} productName={record.name}
unitName={record.unitName} unitName={record.unitName}
files={files}
> >
<a>编辑</a> <a>编辑</a>
</ProcessDetail> </ProcessDetail>
...@@ -191,117 +214,60 @@ const Add: React.FC<{}> = () => { ...@@ -191,117 +214,60 @@ const Add: React.FC<{}> = () => {
</Space> </Space>
) )
} }
}, }];
]
return activeSource !== '加工订单' ? tempColumns.filter((item) => !blackList.includes(item.dataIndex)) : tempColumns; const renderProductColumn = () => {
const newColumn = [...productColumns, ...actionColumns];
return newColumn
}
const renderOrderColumn = () => {
const newColumn = [...orderColumns, ...actionColumns];
return newColumn
} }
// 选择弹框 element
const tableAddButton = () => { // 选择弹框 element 订单
const tableProductAddButton = () => {
return ( return (
<div> <div>
<Button <Button
onClick={handleShowProcessModal} onClick={() => setModalProductVisible(true)}
style={{marginBottom: 16}} style={{marginBottom: 16}}
block block
icon={<PlusOutlined/>} icon={<PlusOutlined/>}
type='dashed' type='dashed'
> >
选择{activeSource} 选择加工商品
</Button> </Button>
</div> </div>
) )
} }
// 通知单明细 -> 通知单来源
const source = () => {
return (
<Radio checked={true}>{activeSource}</Radio>
)
}
// 流转记录
const RadioBtnGroup = () => {
return (
<Radio.Group
options={
[
{ label: '外部流转(0)', value: 1 },
{ label: '内部流转(0)', value: 2 }
]
}
optionType="button"
/>
)
}
/** const tableOrderAddButton = () => {
* formEffect, 表单联动操作放这里操作,包括表单的生命周期等操作 return (
*/ <div>
const formEffects = () => () => { <Button
onFieldValueChange$('source').subscribe((state) => { onClick={() => setModalOrderVisible(true)}
if(state.mounted) { style={{marginBottom: 16}}
const value = state.value == 1 ? '加工订单' : '加工商品'; block
setActiveSource(value); icon={<PlusOutlined/>}
formActions.setFieldValue("Tabs.tab-2.layout.someLists", []); type='dashed'
} >
}) 选择加工订单
// 当物流为 物流时,那么填充 </Button>
onFieldMount$('receivefullAddress').subscribe((state) => { </div>
PublicApi.getLogisticsReceiverAddressPage({current: '1', pageSize: '99'})
.then((res) => {
let options = [];
if(res.code === 1000) {
options = res.data.data.map((item) => {
return {
label: `${item.fullAddress} / ${item.receiverName} / ${item.phone}`,
value: item.id
}}
) )
} }
formActions.setFieldState("receivefullAddress", (state) => {
state.props["x-component-props"]["options"] = options;
})
})
})
/**
* 当改变物流地址的时候,那么修改隐藏的3个字段,
* 1. receiveAddress 详细的物流地址
* 2. receiveUserName 收货人
* 3. receiveUserTel 收货人电话
*/
onFieldValueChange$('receivefullAddress').subscribe((state) => {
if(state.visible) {
const options = state.props["x-component-props"]["options"];
const target = options.filter((item) => item.value == state.value)[0];
if(target) {
const [receiveAddress, receiveUserName, receiveUserTel] = target.label.split("/");
formActions.setFieldValue("receiveAddress", receiveAddress.trim());
formActions.setFieldValue("receiveUserName", receiveUserName.trim());
formActions.setFieldValue("receiveUserTel", receiveUserTel.trim());
formActions.setFieldValue("receiverAddressId", state.value)
}
}
})
}
// 选择加工商品弹框控制
const handleShowProcessModal = () => {
const source = formActions.getFieldValue('source');
if(source == 1) {
setModalOrderVisible(true);
} else {
setModalProductVisible(true)
}
}
/** /**
* 加工企业modal框 行勾选 * 加工企业modal框 行勾选
* @param rows * @param rows
*/ */
const enterPriseOnOk = (rows) => { const enterPriseOnOk = () => {
const { memberId, name, roleId } = rows.selectRow[0]; const row = enterpriseTableRowSelection.hasSelectedRows;
const { memberId, name, roleId, id } = row[0];
formActions.setFieldValue('Tabs.tab-1.layout.processName', name); formActions.setFieldValue('Tabs.tab-1.layout.processName', name);
formActions.setFieldValue('Tabs.tab-1.layout.processMemberId', memberId); formActions.setFieldValue('Tabs.tab-1.layout.processMemberId', id);
formActions.setFieldValue('Tabs.tab-1.layout.processRoleId', roleId); formActions.setFieldValue('Tabs.tab-1.layout.processRoleId', roleId);
} }
...@@ -310,7 +276,7 @@ const Add: React.FC<{}> = () => { ...@@ -310,7 +276,7 @@ const Add: React.FC<{}> = () => {
* @param rows * @param rows
*/ */
const processProductSelected = () => { const processProductSelected = () => {
formActions.setFieldValue('Tabs.tab-2.layout.someLists', productTableRowSelection.hasSelectedRows) formActions.setFieldValue('Tabs.tab-2.layout.productList', productTableRowSelection.hasSelectedRows)
} }
/** /**
...@@ -318,7 +284,7 @@ const Add: React.FC<{}> = () => { ...@@ -318,7 +284,7 @@ const Add: React.FC<{}> = () => {
* @param row * @param row
*/ */
const processOrderOnok = () => { const processOrderOnok = () => {
formActions.setFieldValue('Tabs.tab-2.layout.someLists', orderTableRowSelection.hasSelectedRows) formActions.setFieldValue('Tabs.tab-2.layout.orderList', orderTableRowSelection.hasSelectedRows)
} }
/** /**
...@@ -337,10 +303,14 @@ const Add: React.FC<{}> = () => { ...@@ -337,10 +303,14 @@ const Add: React.FC<{}> = () => {
materialDesc = '', materialDesc = '',
packingDesc = '', packingDesc = '',
otherDesc = '', otherDesc = '',
someLists, // someLists,
productList,
orderList,
...rest ...rest
} = values; } = values;
const deliveryDateFormat = deliveryDate.unix() * 1000; const deliveryDateFormat = deliveryDate.unix() * 1000;
const isProcessProduct = values.source === 2;
const someLists = isProcessProduct ? productList : orderList;
const isSomeFieldNotFill = someLists.some((item) => { const isSomeFieldNotFill = someLists.some((item) => {
return typeof item.processNum === 'undefined' || typeof item.processUnitPrice === 'undefined' return typeof item.processNum === 'undefined' || typeof item.processUnitPrice === 'undefined'
}) })
...@@ -349,7 +319,7 @@ const Add: React.FC<{}> = () => { ...@@ -349,7 +319,7 @@ const Add: React.FC<{}> = () => {
message.error("通知单明细中有加工商品的加工数量或加工单价未填写"); message.error("通知单明细中有加工商品的加工数量或加工单价未填写");
return return
} }
console.log(someLists);
const {isSuccess, data} = await judgeSameWorkFlow(someLists); const {isSuccess, data} = await judgeSameWorkFlow(someLists);
console.log(data); console.log(data);
if(!isSuccess) { if(!isSuccess) {
...@@ -414,7 +384,9 @@ const Add: React.FC<{}> = () => { ...@@ -414,7 +384,9 @@ const Add: React.FC<{}> = () => {
delete postData.receiverAddressId delete postData.receiverAddressId
} }
console.log(postData); console.log(postData);
PublicApi.postEnhanceSupplierToBeAddAdd(postData) const service = pathname.includes("edit") ? PublicApi.postEnhanceSupplierToBeAddUpdate : PublicApi.postEnhanceSupplierToBeAddAdd
const withId = pathname.includes("edit") ? { id: editInfo.id, ...postData}: postData;
service(withId)
.then(data => { .then(data => {
setSubmitLoading(false); setSubmitLoading(false);
if(data.code === 1000) { if(data.code === 1000) {
...@@ -426,8 +398,10 @@ const Add: React.FC<{}> = () => { ...@@ -426,8 +398,10 @@ const Add: React.FC<{}> = () => {
} }
const handleChangeSomeList = (values: any) => { const handleChangeSomeList = (values: any) => {
let someList = formActions.getFieldValue('Tabs.tab-2.layout.someLists'); const isProcessProduct = formActions.getFieldValue('source') === 2;
const primaryKey = activeSource === '加工订单' ? 'fullId' : 'id' const keyName = isProcessProduct ? 'Tabs.tab-2.layout.productList' : 'Tabs.tab-2.layout.orderList'
let someList = formActions.getFieldValue(keyName);
const primaryKey = !isProcessProduct ? 'fullId' : 'id'
const index = someList.findIndex((item) => item[primaryKey] == values.uniqueID); const index = someList.findIndex((item) => item[primaryKey] == values.uniqueID);
if(index > -1) { if(index > -1) {
someList[index] = { someList[index] = {
...@@ -439,7 +413,7 @@ const Add: React.FC<{}> = () => { ...@@ -439,7 +413,7 @@ const Add: React.FC<{}> = () => {
files: values.files files: values.files
} }
console.log(someList) console.log(someList)
formActions.setFieldValue('Tabs.tab-2.layout.someLists', [...someList]) formActions.setFieldValue(keyName, [...someList])
} }
} }
...@@ -449,13 +423,15 @@ const Add: React.FC<{}> = () => { ...@@ -449,13 +423,15 @@ const Add: React.FC<{}> = () => {
* @param id * @param id
*/ */
const handleRemoveRow = (id: number) => { const handleRemoveRow = (id: number) => {
const currentList = formActions.getFieldValue('Tabs.tab-2.layout.someLists'); const isProcessProduct = formActions.getFieldValue('source') === 2;
const primaryKey = activeSource === '加工订单' ? 'fullId' : 'id' const keyName = isProcessProduct ? 'Tabs.tab-2.layout.productList' : 'Tabs.tab-2.layout.orderList'
const currentList = formActions.getFieldValue(keyName);
const primaryKey = !isProcessProduct ? 'fullId' : 'id'
const newList = currentList.filter((item) => item[primaryKey] !== id); const newList = currentList.filter((item) => item[primaryKey] !== id);
formActions.setFieldValue('Tabs.tab-2.layout.someLists', newList) formActions.setFieldValue(keyName, newList)
const newSelectedKeys = newList.map((item) => item[primaryKey]); const newSelectedKeys = newList.map((item) => item[primaryKey]);
const newSelectedRows = newList; const newSelectedRows = newList;
if(activeSource === '加工订单') { if(!isProcessProduct) {
orderTableRowSelection.setSelectedRows(newSelectedRows); orderTableRowSelection.setSelectedRows(newSelectedRows);
orderTableRowSelection.setSelectedKeys(newSelectedKeys); orderTableRowSelection.setSelectedKeys(newSelectedKeys);
} else { } else {
...@@ -486,19 +462,22 @@ const Add: React.FC<{}> = () => { ...@@ -486,19 +462,22 @@ const Add: React.FC<{}> = () => {
initialValues={editInfo} initialValues={editInfo}
schema={schema} schema={schema}
actions={formActions} actions={formActions}
components={{WrapUploadFile, DatePicker, Select, Table}} components={{WrapUploadFile, DatePicker, Select, Table, aaa: Radio.Group}}
expressionScope={{ expressionScope={{
connectProduct, connectProduct,
tableAddButton: tableAddButton(), tableOrderAddButton: tableOrderAddButton(),
source: source(), tableProductAddButton: tableProductAddButton(),
RadioBtnGroup: RadioBtnGroup(), renderProductColumn: renderProductColumn(),
noticesDetailColumn: noticesDetailColumn() renderOrderColumn: renderOrderColumn(),
}} }}
onSubmit={handleSubmit} onSubmit={handleSubmit}
effects={formEffects()} effects={() => {
formEffects()
}}
/> />
{/* 加工企业 Modal 框 */} {/* 加工企业 Modal 框 */}
<EnterPrise <EnterPrise
rowSelection={enterpriseTableRowSelection.rowSelection}
visible={modalEnterPriseVisible} visible={modalEnterPriseVisible}
cancel={() => setEnterPriseModalVisible(false)} cancel={() => setEnterPriseModalVisible(false)}
onOk={enterPriseOnOk} onOk={enterPriseOnOk}
......
/* import { innerWorkFlowRecordColumn, outerWorkflowRecordsColumn} from '../detail/columns';
* @Author: your name
* @Date: 2020-10-12 13:37:06
* @LastEditTime: 2020-10-16 16:55:22
* @Description: 新建生产通知单 schema
*/
import React from 'react';
import { Space, Menu, Dropdown } from 'antd';
import { DownOutlined } from '@ant-design/icons';
import ProcessDetail from '../../components/ProcessDetail'
// 流转记录 // 流转记录
export const historyColumn = [ export const historyColumn = [
...@@ -90,7 +80,18 @@ const basicTab = { ...@@ -90,7 +80,18 @@ const basicTab = {
value: 2 value: 2
} }
], ],
default: 1 "x-linkages": [
{
"type": "value:visible",
"target": "*(orderList, orderSource)",
"condition": "{{ $self.value === 1 }}"
},
{
"type": "value:visible",
"target": "*(productList, productSource)",
"condition": "{{ $self.value === 2 }}"
},
]
}, },
deliveryDate: { deliveryDate: {
...@@ -157,17 +158,19 @@ const basicTab = { ...@@ -157,17 +158,19 @@ const basicTab = {
type: 'string', type: 'string',
display: false display: false
}, },
docNo: { noticeNo: {
type: 'string', type: 'string',
title: '通知单号', title: '通知单号',
'x-component': 'Text' editable: false,
// 'x-component': 'Text'
}, },
docTime: { createTime: {
type: 'string', type: 'string',
title: '单据时间', title: '单据时间',
'x-component': 'Text' editable: false
// 'x-component': 'I'
}, },
status: { outerStatus: {
type: 'string', type: 'string',
title: '外部状态', title: '外部状态',
'x-component': 'Children', 'x-component': 'Children',
...@@ -175,7 +178,7 @@ const basicTab = { ...@@ -175,7 +178,7 @@ const basicTab = {
children: '待提交通知单' children: '待提交通知单'
} }
}, },
status2: { innerStatus: {
type: 'string', type: 'string',
title: '内部状态', title: '内部状态',
'x-component': 'Children', 'x-component': 'Children',
...@@ -209,14 +212,32 @@ const detailTab = { ...@@ -209,14 +212,32 @@ const detailTab = {
labelAlign: 'left' labelAlign: 'left'
}, },
properties: { properties: {
selectedSource: { orderSource: {
type: 'string',
title: '通知单来源', title: '通知单来源',
'x-component': 'Children', 'x-component': 'Radio',
'x-component-props': {
options: [{
label: '加工订单',
value: 1,
}],
defaultValue: 1,
},
},
productSource: {
type: 'string',
title: '通知单来源',
'x-component': 'Radio',
'x-component-props': { 'x-component-props': {
children: '{{source}}', options: [{
label: '加工商品',
value: 2,
}],
defaultValue: 2,
}, },
}, },
someLists: { // 加工商品
productList: {
type: 'array:number', type: 'array:number',
'x-mega-props': { 'x-mega-props': {
wrapperCol: 24, wrapperCol: 24,
...@@ -224,8 +245,8 @@ const detailTab = { ...@@ -224,8 +245,8 @@ const detailTab = {
'x-component': 'MultTable', 'x-component': 'MultTable',
'x-component-props': { 'x-component-props': {
rowKey: (record) => record.id + "_" + record.fullId, rowKey: (record) => record.id + "_" + record.fullId,
prefix: "{{tableAddButton}}", prefix: "{{tableProductAddButton}}",
columns: "{{noticesDetailColumn}}" columns: "{{renderProductColumn}}"
// columns: "{{tableColumns}}", // columns: "{{tableColumns}}",
}, },
'x-rules': [ 'x-rules': [
...@@ -233,8 +254,29 @@ const detailTab = { ...@@ -233,8 +254,29 @@ const detailTab = {
required: true, required: true,
message: '请选择要加工的商品' message: '请选择要加工的商品'
} }
] ],
},
// 订单
orderList: {
type: 'array:number',
'x-mega-props': {
wrapperCol: 24,
},
'x-component': 'MultTable',
'x-component-props': {
rowKey: (record) => record.id + "_" + record.fullId,
prefix: "{{tableOrderAddButton}}",
columns: "{{renderOrderColumn}}"
// columns: "{{tableColumns}}",
},
'x-rules': [
{
required: true,
message: '请选择要加工的商品'
} }
]
},
} }
} }
} }
...@@ -380,19 +422,49 @@ const historyRecord = { ...@@ -380,19 +422,49 @@ const historyRecord = {
properties: { properties: {
controller: { controller: {
type: 'object', type: 'object',
'x-component': 'Children', "x-component": 'aaa',
"x-component-props": {
options: [
{ label: '外部流转', value: 1 },
{ label: '内部流转', value: 2 }
],
optionType: 'button',
},
'x-linkages': [
{
type: 'value:visible',
target: 'outerWorkFlow',
condition: '{{$value === 1}}'
},
{
type: 'value:visible',
target: 'innerWorkFlow',
condition: '{{$value === 2}}'
},
],
},
outerWorkFlow: {
type: 'array:number',
'x-mega-props': {
wrapperCol: 24,
},
'x-component': 'MultTable',
'x-component-props': { 'x-component-props': {
children: '{{RadioBtnGroup}}' columns: outerWorkflowRecordsColumn
} }
}, },
historyTable: { innerWorkFlow: {
type: 'object', type: 'array:number',
'x-component': 'Table', 'x-mega-props': {
wrapperCol: 24,
},
'x-component': 'MultTable',
'x-component-props': { 'x-component-props': {
columns: historyColumn rowKey: (record) => record.id ,
} columns: innerWorkFlowRecordColumn
// columns: "{{tableColumns}}",
},
} }
} }
} }
......
...@@ -11,9 +11,9 @@ export const useRowSelection = (options) => { ...@@ -11,9 +11,9 @@ export const useRowSelection = (options) => {
type: type, type: type,
selectedRowKeys: selectedKeys, selectedRowKeys: selectedKeys,
onSelect: async (record: any, selected: boolean, selectedRows: any[], nativeEvent) => { onSelect: async (record: any, selected: boolean, selectedRows: any[], nativeEvent) => {
const tempKey = record[primaryKey]; // const tempKey = record[primaryKey];
if(type === 'radio') { if(type === 'radio') {
setSelectedKeys(record[tempKey]); setSelectedKeys([record[primaryKey]]);
setSelectedRows(selectedRows); setSelectedRows(selectedRows);
return ; return ;
} }
......
...@@ -9,15 +9,15 @@ import { schema } from './schema'; ...@@ -9,15 +9,15 @@ import { schema } from './schema';
const actions = createAsyncFormActions(); const actions = createAsyncFormActions();
const { onFieldInit$, onFieldMount$ } = FormEffectHooks const { onFieldInit$, onFieldMount$ } = FormEffectHooks
const EnterPrise = ({visible, cancel, ...restProps}) => { const EnterPrise = ({visible, cancel, rowSelection, ...restProps}) => {
const [selectRow, memberRowCtl] = useRowSelectionTable({ customKey: 'id', type: 'radio'}); // const [selectRow, memberRowCtl] = useRowSelectionTable({ customKey: 'id', type: 'radio'});
const fetchData = useCallback(async (params: any) => { const fetchData = useCallback(async (params: any) => {
let res = await PublicApi.getMemberManageLowerPageBynamerole(params); let res = await PublicApi.getMemberManageLowerPageBynamerole(params);
return res; return res;
}, []); }, []);
const onOk = () => { const onOk = () => {
restProps.onOk(memberRowCtl) restProps.onOk()
cancel(); cancel();
} }
...@@ -51,7 +51,7 @@ const EnterPrise = ({visible, cancel, ...restProps}) => { ...@@ -51,7 +51,7 @@ const EnterPrise = ({visible, cancel, ...restProps}) => {
schema={schema} schema={schema}
actions={actions} actions={actions}
effects={effects} effects={effects}
expressionScope={{rowSelection: selectRow}} expressionScope={{rowSelection: rowSelection}}
></SearchForm> ></SearchForm>
: null : null
} }
......
...@@ -110,6 +110,9 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -110,6 +110,9 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
const handleFormSubmit = (value) => { const handleFormSubmit = (value) => {
props.formSubmit(value); props.formSubmit(value);
} }
console.log(files);
return ( return (
<div className={styles.container}> <div className={styles.container}>
<div className={styles.menu}> <div className={styles.menu}>
...@@ -165,20 +168,19 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -165,20 +168,19 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
<div className={styles.header}>{"附件"}</div> <div className={styles.header}>{"附件"}</div>
<div className={styles.info}> <div className={styles.info}>
{ {
files.length === 0 && props.type != 'edit' files.length === 0
? <p></p> ? <p></p>
: null : props.type != 'edit'
} ? files.map((item,key) => {
{
files.map((item,key) => {
return ( return (
<FileList name={item.name} url={item.url} key={key} /> <FileList name={item.name} url={item.url} key={key} />
) )
}) })
: null
} }
{ {
props.type == 'edit' props.type == 'edit'
? <UploadFile onChange={props.fileOnChange} fileMaxSize={20*1024} /> ? <UploadFile fileList={files} onChange={props.fileOnChange} fileMaxSize={20*1024} />
: null : null
} }
</div> </div>
......
...@@ -17,6 +17,7 @@ interface Iprops { ...@@ -17,6 +17,7 @@ interface Iprops {
productName: string, productName: string,
unitName: string, unitName: string,
uniqueID: string, uniqueID: string,
files: any[],
} }
interface IfileProps { interface IfileProps {
...@@ -28,7 +29,7 @@ const ProcessDetail: React.FC<Iprops> = (props) => { ...@@ -28,7 +29,7 @@ const ProcessDetail: React.FC<Iprops> = (props) => {
const {skuId, type, productName, ...rest} = props; const {skuId, type, productName, ...rest} = props;
const [visible, setVisible] = useState<boolean>(false); const [visible, setVisible] = useState<boolean>(false);
const [info, setInfo] = useState<any>({}) const [info, setInfo] = useState<any>({})
const [files, setFiles] = useState<IfileProps[]>([]) const [files, setFiles] = useState<IfileProps[]>(() => props.files)
const contentRef = useRef(null) const contentRef = useRef(null)
const onClose = () => { const onClose = () => {
...@@ -68,8 +69,11 @@ const ProcessDetail: React.FC<Iprops> = (props) => { ...@@ -68,8 +69,11 @@ const ProcessDetail: React.FC<Iprops> = (props) => {
} }
} }
useEffect(() => {
setFiles(props.files);
}, [props.files])
const formSubmit = (values) => { const formSubmit = (values) => {
console.log(values);
!!props.submit && props.submit({ !!props.submit && props.submit({
files: files, files: files,
uniqueID: props.uniqueID, uniqueID: props.uniqueID,
......
...@@ -4,7 +4,6 @@ import { Upload, Button, message } from 'antd'; ...@@ -4,7 +4,6 @@ import { Upload, Button, message } from 'antd';
import { UploadOutlined } from '@ant-design/icons' import { UploadOutlined } from '@ant-design/icons'
import { UPLOAD_TYPE } from '@/constants' import { UPLOAD_TYPE } from '@/constants'
import FileListItem from './FileList'; import FileListItem from './FileList';
import url from '*.svg';
const UploadFile = (props) => { const UploadFile = (props) => {
const { fileList = [], onChange, fileMaxSize = 20 } = props const { fileList = [], onChange, fileMaxSize = 20 } = props
...@@ -51,8 +50,7 @@ const UploadFile = (props) => { ...@@ -51,8 +50,7 @@ const UploadFile = (props) => {
}; };
const removeFile = (key) => { const removeFile = (key) => {
const res = fileList.filter((item) => item != key); const res = fileList.filter((item) => item.name != key);
console.log(res);
onChange(res); onChange(res);
} }
...@@ -63,7 +61,7 @@ const UploadFile = (props) => { ...@@ -63,7 +61,7 @@ const UploadFile = (props) => {
fileList.map((item, key) => { fileList.map((item, key) => {
return ( return (
<FileListItem <FileListItem
key={item} key={key}
name={item.name} name={item.name}
url={item.url} url={item.url}
removeFile={removeFile} removeFile={removeFile}
...@@ -77,7 +75,6 @@ const UploadFile = (props) => { ...@@ -77,7 +75,6 @@ const UploadFile = (props) => {
</Upload> </Upload>
<div className={styles.tips}>一次上传一个文件,每个附件大小不能超过{fileMaxSize / 1024}M</div> <div className={styles.tips}>一次上传一个文件,每个附件大小不能超过{fileMaxSize / 1024}M</div>
</div> </div>
) )
} }
......
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