Commit 85869e8e authored by Bill's avatar Bill

Merge branch 'dev' into test

parents b0c877be 49848366
...@@ -49,7 +49,7 @@ const common_columns: any = [ ...@@ -49,7 +49,7 @@ const common_columns: any = [
] ]
const MemberSettleAdd: React.FC = () => { const MemberSettleAdd: React.FC = () => {
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'id' }); const [memberRowSelection, memberRowCtl] = useRowSelectionTable({ customKey: 'uniqueId' });
const [initialValue, setInitialValue] = useState({}); const [initialValue, setInitialValue] = useState({});
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
const [submitLoading, setSubmitLoading ] = useState(false); const [submitLoading, setSubmitLoading ] = useState(false);
...@@ -77,7 +77,7 @@ const MemberSettleAdd: React.FC = () => { ...@@ -77,7 +77,7 @@ const MemberSettleAdd: React.FC = () => {
title: '操作', title: '操作',
render: (text, record) => { render: (text, record) => {
return ( return (
<div onClick={() => handleRemove(record.memberId)}>删除</div> <div onClick={() => handleRemove(record.uniqueId)}>删除</div>
) )
} }
} }
...@@ -102,7 +102,11 @@ const MemberSettleAdd: React.FC = () => { ...@@ -102,7 +102,11 @@ const MemberSettleAdd: React.FC = () => {
const fetchMemberData = async (params: any) => { const fetchMemberData = async (params: any) => {
//member/manage/lower/page/bynamerole //member/manage/lower/page/bynamerole
const { data } = await PublicApi.getMemberManageLowerPageBynamerole(params); const { data } = await PublicApi.getMemberManageLowerPageBynamerole(params);
return data return {
...data,
data: data.data.map((v) => ({...v, uniqueId: v.memberId + "_" + v.roleId})),
totalCount: data.totalCount
}
} }
// 获取适用会员下拉搜索框 // 获取适用会员下拉搜索框
...@@ -155,11 +159,11 @@ const MemberSettleAdd: React.FC = () => { ...@@ -155,11 +159,11 @@ const MemberSettleAdd: React.FC = () => {
const handleRemove = (id: number) => { const handleRemove = (id: number) => {
const string = 'Tabs.memberTab.someLists'; const string = 'Tabs.memberTab.someLists';
const chooseList = formActions.getFieldValue(string); const chooseList = formActions.getFieldValue(string);
const res = chooseList.filter((item) => item.memberId !== id); const res = chooseList.filter((item) => item.uniqueId !== id);
formActions.setFieldValue(string, res); formActions.setFieldValue(string, res);
// 必须设置key // 必须设置key
memberRowCtl.setSelectRow(res); memberRowCtl.setSelectRow(res);
memberRowCtl.setSelectedRowKeys(res.map((item) => item.memberId)) memberRowCtl.setSelectedRowKeys(res.map((item) => item.uniqueId))
} }
// 从PAAS平台--规则配置--平台规则配置取已勾选的结算方式决定是否显示结算方式 // 从PAAS平台--规则配置--平台规则配置取已勾选的结算方式决定是否显示结算方式
...@@ -188,10 +192,11 @@ const MemberSettleAdd: React.FC = () => { ...@@ -188,10 +192,11 @@ const MemberSettleAdd: React.FC = () => {
otherValues: [res.data.settlementDays, res.data.settlementDate], otherValues: [res.data.settlementDays, res.data.settlementDate],
} }
}) })
formActions.setFieldValue('Tabs.memberTab.someLists', res.data.memberList); const list = res.data.memberList.map((item) => ({...item, uniqueId: item.memberId + "_" + item.roleId}))
formActions.setFieldValue('Tabs.memberTab.someLists', list);
// 必须设置key // 必须设置key
memberRowCtl.setSelectRow(res.data.memberList); memberRowCtl.setSelectRow(list);
memberRowCtl.setSelectedRowKeys(res.data.memberList.map((item) => item.memberId)) memberRowCtl.setSelectedRowKeys(res.data.memberList.map((item) => item.memberId + "_" + item.roleId))
} else { } else {
message.error({content: res.message}) message.error({content: res.message})
} }
...@@ -238,7 +243,7 @@ const MemberSettleAdd: React.FC = () => { ...@@ -238,7 +243,7 @@ const MemberSettleAdd: React.FC = () => {
rowSelection={memberRowSelection} rowSelection={memberRowSelection}
fetchTableData={params => fetchMemberData(params)} fetchTableData={params => fetchMemberData(params)}
tableProps={{ tableProps={{
rowKey: 'id', rowKey: 'uniqueId',
}} }}
formilyProps={ formilyProps={
{ {
......
...@@ -27,13 +27,13 @@ export const indexSchema = { ...@@ -27,13 +27,13 @@ export const indexSchema = {
}, },
}, },
name: { name: {
type: 'string', type: 'string',
'x-component': 'Search', 'x-component': 'Search',
"x-mega-props": { "x-mega-props": {
"span": 2 "span": 2
}, },
'x-component-props': { 'x-component-props': {
placeholder: '搜索', placeholder: '搜索',
advanced: false, advanced: false,
}, },
}, },
...@@ -44,7 +44,7 @@ export const indexSchema = { ...@@ -44,7 +44,7 @@ export const indexSchema = {
/** /**
* 新增会员结算策略schema * 新增会员结算策略schema
* *
*/ */
export const addSchema = { export const addSchema = {
...@@ -129,7 +129,7 @@ export const addSchema = { ...@@ -129,7 +129,7 @@ export const addSchema = {
}, },
'x-component': 'MultTable', 'x-component': 'MultTable',
'x-component-props': { 'x-component-props': {
rowKey: 'memberId', rowKey: 'uniqueId',
prefix: "{{tableAddButton}}", prefix: "{{tableAddButton}}",
columns: "{{tableColumns}}" columns: "{{tableColumns}}"
// columns: "{{tableColumns}}", // columns: "{{tableColumns}}",
...@@ -176,7 +176,7 @@ export const memberSchema = { ...@@ -176,7 +176,7 @@ export const memberSchema = {
style: {width: '200px'} style: {width: '200px'}
} }
}, },
submit: { submit: {
"x-component": 'Submit', "x-component": 'Submit',
"x-mega-props": { "x-mega-props": {
...@@ -189,4 +189,4 @@ export const memberSchema = { ...@@ -189,4 +189,4 @@ export const memberSchema = {
} }
} }
} }
} }
\ No newline at end of file
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 框
...@@ -41,8 +41,8 @@ const Add: React.FC<{}> = () => { ...@@ -41,8 +41,8 @@ const Add: React.FC<{}> = () => {
const postData = list.map((item) => { const postData = list.map((item) => {
return { return {
productId: "fullId" in item ? item.commodityId : item.id, productId: "fullId" in item ? item.commodityId : item.id,
memberId: item.memberId, memberId: item.memberId || authInfo.memberId,
memberRoleId: item.memberRoleId, memberRoleId: item.memberRoleId || authInfo.memberRoleId,
shopId: ENTERPRISE_MALL[authInfo.memberType], shopId: ENTERPRISE_MALL[authInfo.memberType],
type: 5, type: 5,
} }
...@@ -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: 'uniqueId', 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,183 +124,151 @@ const Add: React.FC<{}> = () => { ...@@ -123,183 +124,151 @@ 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
} }
}) })
if(isOrderProcess) {
const orderDetailkeys = someLists.map((item) => item.fullId);
orderTableRowSelection.setSelectedKeys(orderDetailkeys);
orderTableRowSelection.setSelectedRows(someLists);
} else {
const keys = someLists.map((item) => item.id);
productTableRowSelection.setSelectedKeys(keys);
productTableRowSelection.setSelectedRows(someLists);
}
enterpriseTableRowSelection.setSelectedKeys([data.processMemberId + "_" + data.processRoleId]);
enterpriseTableRowSelection.setSelectedRows([{
memberId: data.processMemberId,
name: data.processName,
roleId: data.processRoleId,
uniqueId: data.processMemberId + "_" + 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,
controller: 1,
}) })
} }
}) })
} }
}, [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' }, controller: 1
{ title: '品牌', dataIndex: 'brandName' }, })
{ title: '单位', dataIndex: 'unitName' }, }
{ title: '订单数量', dataIndex: 'orderTotal' }, }, [])
{ title: '剩余加工数量', dataIndex: 'restTotal' },
{ title: '加工数量', dataIndex: 'processNum' }, const actionColumns = [{
{ title: '加工单价', dataIndex: 'processUnitPrice' }, title: '操作',
{ title: '加工费', dataIndex: 'processTotalPrice'}, render: (text, record) => {
{ // 只有加工订单才有fullId
title: '操作', const uniqueID = "fullId" in record ? record.fullId : record.id;
render: (text, record) => { const files = record.files || [];
const uniqueID = activeSource == '加工订单'? record.fullId : record.id return (
return ( <Space>
<Space> <ProcessDetail
<ProcessDetail skuId={record.id}
skuId={record.id} uniqueID={uniqueID}
uniqueID={uniqueID} type={"view"}
type={"view"} quantity={record.processNum}
quantity={record.processNum} processUnitPrice={record.processUnitPrice}
processUnitPrice={record.processUnitPrice} productId={record.commodityId}
productId={record.commodityId} brand={record.brandName}
brand={record.brandName} 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>
<ProcessDetail <ProcessDetail
skuId={record.id} skuId={record.id}
uniqueID={uniqueID} uniqueID={uniqueID}
type={"edit"} type={"edit"}
submit={handleChangeSomeList} submit={handleChangeSomeList}
quantity={record.processNum} quantity={record.processNum}
processUnitPrice={record.processUnitPrice} processUnitPrice={record.processUnitPrice}
productId={record.commodityId} productId={record.commodityId}
brand={record.brandName} brand={record.brandName}
category={record.customerCategoryName} category={record.customerCategoryName}
productName={record.name} productName={record.name}
unitName={record.unitName} unitName={record.unitName}
> files={files}
<a>编辑</a>
</ProcessDetail> >
<a onClick={() => handleRemoveRow(uniqueID)}>删除</a> <a>编辑</a>
</Space> </ProcessDetail>
) <a onClick={() => handleRemoveRow(uniqueID)}>删除</a>
} </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 = () => { const tableOrderAddButton = () => {
return (
<Radio checked={true}>{activeSource}</Radio>
)
}
// 流转记录
const RadioBtnGroup = () => {
return ( return (
<Radio.Group <div>
options={ <Button
[ onClick={() => setModalOrderVisible(true)}
{ label: '外部流转(0)', value: 1 }, style={{marginBottom: 16}}
{ label: '内部流转(0)', value: 2 } block
] icon={<PlusOutlined/>}
} type='dashed'
optionType="button" >
/> 选择加工订单
</Button>
</div>
) )
} }
/** /**
* formEffect, 表单联动操作放这里操作,包括表单的生命周期等操作
*/
const formEffects = () => () => {
onFieldValueChange$('source').subscribe((state) => {
if(state.mounted) {
const value = state.value == 1 ? '加工订单' : '加工商品';
setActiveSource(value);
formActions.setFieldValue("Tabs.tab-2.layout.someLists", []);
}
})
// 当物流为 物流时,那么填充
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)
}
}
})
}
// 选择加工商品弹框控制
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 } = 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', memberId);
formActions.setFieldValue('Tabs.tab-1.layout.processRoleId', roleId); formActions.setFieldValue('Tabs.tab-1.layout.processRoleId', roleId);
...@@ -310,7 +279,7 @@ const Add: React.FC<{}> = () => { ...@@ -310,7 +279,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 +287,7 @@ const Add: React.FC<{}> = () => { ...@@ -318,7 +287,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)
} }
/** /**
...@@ -329,6 +298,9 @@ const Add: React.FC<{}> = () => { ...@@ -329,6 +298,9 @@ const Add: React.FC<{}> = () => {
const { const {
deliveryDate, deliveryDate,
receivefullAddress, receivefullAddress,
controller,
outerStatus,
innerStatus,
// receiveAddressID, // receiveAddressID,
enclosure = [], enclosure = [],
deliveryDesc = '', deliveryDesc = '',
...@@ -337,10 +309,14 @@ const Add: React.FC<{}> = () => { ...@@ -337,10 +309,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,9 +325,8 @@ const Add: React.FC<{}> = () => { ...@@ -349,9 +325,8 @@ 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);
if(!isSuccess) { if(!isSuccess) {
message.error("您所选择的商品的工作流不一致,请删除不一致的工作流商品"); message.error("您所选择的商品的工作流不一致,请删除不一致的工作流商品");
return return
...@@ -414,7 +389,9 @@ const Add: React.FC<{}> = () => { ...@@ -414,7 +389,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 +403,10 @@ const Add: React.FC<{}> = () => { ...@@ -426,8 +403,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 +418,7 @@ const Add: React.FC<{}> = () => { ...@@ -439,7 +418,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 +428,15 @@ const Add: React.FC<{}> = () => { ...@@ -449,13 +428,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 +467,22 @@ const Add: React.FC<{}> = () => { ...@@ -486,19 +467,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,30 @@ const basicTab = { ...@@ -90,7 +80,30 @@ const basicTab = {
value: 2 value: 2
} }
], ],
default: 1 "x-linkages": [
{
"type": "value:state",
"target": "*(productList, productSource)",
"condition": "{{ $self.value === 1 }}",
state: {
display: false,
},
otherwise:{//条件不满足时控制bbb字段的编辑状态
display:true
}
},
{
"type": "value:state",
"target": "*(orderList, orderSource)",
"condition": "{{ $self.value === 2 }}",
state: {
display: false,
},
otherwise:{//条件不满足时控制bbb字段的编辑状态
display:true
}
},
]
}, },
deliveryDate: { deliveryDate: {
...@@ -157,17 +170,19 @@ const basicTab = { ...@@ -157,17 +170,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 +190,7 @@ const basicTab = { ...@@ -175,7 +190,7 @@ const basicTab = {
children: '待提交通知单' children: '待提交通知单'
} }
}, },
status2: { innerStatus: {
type: 'string', type: 'string',
title: '内部状态', title: '内部状态',
'x-component': 'Children', 'x-component': 'Children',
...@@ -209,14 +224,53 @@ const detailTab = { ...@@ -209,14 +224,53 @@ 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',
'x-mega-props': {
wrapperCol: 24,
},
'x-component': 'MultTable',
'x-component-props': {
rowKey: (record) => record.id + "_" + record.fullId,
prefix: "{{tableProductAddButton}}",
columns: "{{renderProductColumn}}"
// columns: "{{tableColumns}}",
},
'x-rules': [
{
required: true,
message: '请选择要加工的商品'
}
],
},
// 订单
orderList: {
type: 'array:number', type: 'array:number',
'x-mega-props': { 'x-mega-props': {
wrapperCol: 24, wrapperCol: 24,
...@@ -224,8 +278,8 @@ const detailTab = { ...@@ -224,8 +278,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: "{{tableOrderAddButton}}",
columns: "{{noticesDetailColumn}}" columns: "{{renderOrderColumn}}"
// columns: "{{tableColumns}}", // columns: "{{tableColumns}}",
}, },
'x-rules': [ 'x-rules': [
...@@ -234,7 +288,7 @@ const detailTab = { ...@@ -234,7 +288,7 @@ const detailTab = {
message: '请选择要加工的商品' message: '请选择要加工的商品'
} }
] ]
} },
} }
} }
} }
...@@ -380,19 +434,49 @@ const historyRecord = { ...@@ -380,19 +434,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,23 @@ import { schema } from './schema'; ...@@ -9,15 +9,23 @@ 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; console.log(res);
return {
...res,
code: res.code,
data: {
data: res.data.data.map((v) => ({...v, uniqueId: v.memberId + "_" + v.roleId})),
total: res.data.code
}
};
}, []); }, []);
const onOk = () => { const onOk = () => {
restProps.onOk(memberRowCtl) restProps.onOk()
cancel(); cancel();
} }
...@@ -51,7 +59,7 @@ const EnterPrise = ({visible, cancel, ...restProps}) => { ...@@ -51,7 +59,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
} }
......
...@@ -132,7 +132,7 @@ export const schema = { ...@@ -132,7 +132,7 @@ export const schema = {
"x-component": "Table", "x-component": "Table",
"x-component-props": { "x-component-props": {
"columns": columns, "columns": columns,
"rowKey": "id", "rowKey": "uniqueId",
"pagination":false, "pagination":false,
"rowSelection": "{{rowSelection}}" "rowSelection": "{{rowSelection}}"
} }
......
...@@ -93,7 +93,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -93,7 +93,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
height = height + 112; height = height + 112;
flag = true; flag = true;
return { return {
name: item.name, name: item.name,
min: prevHeight, min: prevHeight,
max: height max: height
} }
...@@ -110,6 +110,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -110,6 +110,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
const handleFormSubmit = (value) => { const handleFormSubmit = (value) => {
props.formSubmit(value); props.formSubmit(value);
} }
return ( return (
<div className={styles.container}> <div className={styles.container}>
<div className={styles.menu}> <div className={styles.menu}>
...@@ -123,7 +124,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -123,7 +124,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
}) })
} }
</div> </div>
<div className={styles.body} ref={ref}> <div className={styles.body} ref={ref}>
<div className={styles.common} > <div className={styles.common} >
<div className={styles.header}>{"基本信息"}</div> <div className={styles.header}>{"基本信息"}</div>
...@@ -140,7 +141,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -140,7 +141,7 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
<Col className={styles.label} span={4}>商品品类</Col> <Col className={styles.label} span={4}>商品品类</Col>
<Col span={12}> {category}</Col> <Col span={12}> {category}</Col>
</Row> </Row>
<Row className={styles.infoRow}> <Row className={styles.infoRow}>
<Col className={styles.label} span={4}>商品品牌</Col> <Col className={styles.label} span={4}>商品品牌</Col>
<Col span={12}>{brand}</Col> <Col span={12}>{brand}</Col>
</Row> </Row>
...@@ -165,20 +166,19 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -165,20 +166,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) => {
{ return (
files.map((item,key) => { <FileList name={item.name} url={item.url} key={key} />
return ( )
<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>
...@@ -224,4 +224,4 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => { ...@@ -224,4 +224,4 @@ const Content: React.FC<Iprops> = React.forwardRef((props, conftentRef) => {
) )
}) })
export default React.memo(Content); export default React.memo(Content);
\ No newline at end of file
...@@ -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);
} }
...@@ -62,10 +60,10 @@ const UploadFile = (props) => { ...@@ -62,10 +60,10 @@ 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,8 +75,7 @@ const UploadFile = (props) => { ...@@ -77,8 +75,7 @@ const UploadFile = (props) => {
</Upload> </Upload>
<div className={styles.tips}>一次上传一个文件,每个附件大小不能超过{fileMaxSize / 1024}M</div> <div className={styles.tips}>一次上传一个文件,每个附件大小不能超过{fileMaxSize / 1024}M</div>
</div> </div>
) )
} }
export default UploadFile; export default UploadFile;
\ No newline at end of file
...@@ -520,13 +520,8 @@ export const findLastIndexFlowState = (data: any[], customKey = 'isExecute'): nu ...@@ -520,13 +520,8 @@ export const findLastIndexFlowState = (data: any[], customKey = 'isExecute'): nu
} }
// 循环数据,找到状态值,一直覆盖 // 循环数据,找到状态值,一直覆盖
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (!data[i][customKey]) { if (data[i][customKey]) {
index = i; index = i;
break;
}
// 循环到最后如果 index 还是为 0 的话,说明工作流全部跑完了,此时 index 为 data.length - 1
if (i === data.length - 1 && index === 0) {
index = data.length - 1;
} }
} }
return index; return index;
......
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