Commit fe10c73e94da69fe9435c8a40d86d5fd663676bb

Authored by zhongnanhuang
1 parent 5cbe46ae

feat: update 商品新增

src/pages/Order/components/OrderDrawer.tsx
@@ -3,6 +3,8 @@ import { @@ -3,6 +3,8 @@ import {
3 postKingdeeRepCustomer, 3 postKingdeeRepCustomer,
4 postKingdeeRepCustomerDetail, 4 postKingdeeRepCustomerDetail,
5 postKingdeeRepMaterial, 5 postKingdeeRepMaterial,
  6 + postKingdeeRepMaterialUnit,
  7 + postKingdeeRepMeasureUnit,
6 postServiceOrderAddOrder, 8 postServiceOrderAddOrder,
7 postServiceOrderQuerySalesCode, 9 postServiceOrderQuerySalesCode,
8 postServiceOrderUpdateOrder, 10 postServiceOrderUpdateOrder,
@@ -43,6 +45,10 @@ export default ({ onClose, data, subOrders, orderOptType }) => { @@ -43,6 +45,10 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
43 const [customer, setCustomer] = useState({}); 45 const [customer, setCustomer] = useState({});
44 const [kingdeeCstomerModalVisible, setKingdeeCstomerModalVisible] = 46 const [kingdeeCstomerModalVisible, setKingdeeCstomerModalVisible] =
45 useState(false); 47 useState(false);
  48 + const [
  49 + productParametersDisabledFlagList,
  50 + setProductParametersDisabledFlagList,
  51 + ] = useState([]);
46 // const [productInvStockOptionsList, setProductInvStockOptionsList] = useState( 52 // const [productInvStockOptionsList, setProductInvStockOptionsList] = useState(
47 // [], 53 // [],
48 // ); //商品的仓库选项 54 // ); //商品的仓库选项
@@ -249,38 +255,85 @@ export default ({ onClose, data, subOrders, orderOptType }) => { @@ -249,38 +255,85 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
249 currentRowData: any, 255 currentRowData: any,
250 index: any, 256 index: any,
251 ) { 257 ) {
252 - let copyList = form.getFieldValue('list');  
253 - let currentData = copyList[currentRowData.field.key];  
254 - currentData.productCode = option?.number;  
255 - currentData.parameters = option?.model;  
256 - currentData.unit = option?.base_unit_name; 258 + let newProductParametersDisabledFlagList = [
  259 + ...productParametersDisabledFlagList,
  260 + ];
  261 + let newProductUnitOptionsList = [...productUnitOptionsList];
  262 + newProductUnitOptionsList[index] = [];
257 263
258 - //商品id  
259 - currentData.materialId = option?.id; 264 + //是新增商品
  265 + if (option.type === 'add') {
  266 + //商品参数开放权限可以编辑
  267 + newProductParametersDisabledFlagList[index] = false;
260 268
261 - //单位  
262 - currentData.unit = option.base_unit_name;  
263 - currentData.unitId = option.base_unit_id; 269 + //清空商品信息
  270 + let copyList = form.getFieldValue('list');
  271 + let currentData = copyList[index];
  272 + currentData.productCode = undefined;
  273 + currentData.parameters = undefined;
  274 + currentData.unit = undefined;
  275 + currentData.subOrderPayment = undefined;
  276 + currentData.quantity = undefined;
  277 + currentData.notes = undefined;
  278 + currentData.productPrice = undefined;
  279 + form.setFieldValue('list', copyList);
264 280
265 - form.setFieldValue('list', copyList); 281 + //查询计量单价列表
  282 + let res = await postKingdeeRepMeasureUnit({ data: {} });
  283 + if (res && res?.rows) {
  284 + for (let row of res?.rows) {
  285 + newProductUnitOptionsList[index].push({
  286 + label: row.name,
  287 + value: row.id,
  288 + });
  289 + }
  290 + }
  291 + } else {
  292 + //选择的是已有的商品,进行内容自动填充
  293 + let copyList = form.getFieldValue('list');
  294 + let currentData = copyList[index];
  295 + currentData.productCode = option?.number;
  296 + currentData.parameters = option?.model;
  297 + currentData.unit = option?.base_unit_name;
266 298
267 - //商品所在的仓库选项填充  
268 - // let res = await postKingdeeRepMaterialStock({  
269 - // data: {  
270 - // material_id: option.id,  
271 - // },  
272 - // });  
273 - // let newProductInvStockOptionsList = [...productInvStockOptionsList];  
274 - // newProductInvStockOptionsList[index] = res?.rows?.map((item) => {  
275 - // return { label: item.inv_stock, value: item.inv_stock_id };  
276 - // });  
277 - // setProductInvStockOptionsList(newProductInvStockOptionsList); 299 + //商品id
  300 + currentData.materialId = option?.id;
278 301
279 - //商品单位填充,目前一个商品暂时只有一个单位  
280 - let newProductUnitOptionsList = [...productUnitOptionsList];  
281 - newProductUnitOptionsList[index] = [  
282 - { label: option.base_unit_name, value: option.base_unit_id },  
283 - ]; 302 + //单位
  303 + currentData.unit = option.base_unit_name;
  304 + currentData.unitId = option.base_unit_id;
  305 +
  306 + form.setFieldValue('list', copyList);
  307 +
  308 + //商品所在的仓库选项填充
  309 + // let res = await postKingdeeRepMaterialStock({
  310 + // data: {
  311 + // material_id: option.id,
  312 + // },
  313 + // });
  314 + // let newProductInvStockOptionsList = [...productInvStockOptionsList];
  315 + // newProductInvStockOptionsList[index] = res?.rows?.map((item) => {
  316 + // return { label: item.inv_stock, value: item.inv_stock_id };
  317 + // });
  318 + // setProductInvStockOptionsList(newProductInvStockOptionsList);
  319 +
  320 + //商品单位填充,查询商品单位列表
  321 + let res = await postKingdeeRepMaterialUnit({
  322 + data: { material_id: option.id },
  323 + });
  324 + if (res && res.rows) {
  325 + for (let row of res.rows) {
  326 + newProductUnitOptionsList[index].push({
  327 + label: row.unit_name,
  328 + value: row.unit_id,
  329 + });
  330 + }
  331 + }
  332 + //商品参数不允许编辑
  333 + newProductParametersDisabledFlagList[index] = true;
  334 + }
  335 +
  336 + setProductParametersDisabledFlagList(newProductParametersDisabledFlagList);
284 setProductUnitOptionsList(newProductUnitOptionsList); 337 setProductUnitOptionsList(newProductUnitOptionsList);
285 } 338 }
286 339
@@ -308,6 +361,18 @@ export default ({ onClose, data, subOrders, orderOptType }) => { @@ -308,6 +361,18 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
308 } 361 }
309 362
310 /** 363 /**
  364 + * 选择商品单位后自动填充
  365 + * @param option
  366 + * @param index
  367 + */
  368 + function autoFillUnit(option: any, index: any) {
  369 + let copyList = form.getFieldValue('list');
  370 + let currentData = copyList[index];
  371 + currentData.unit = option?.label;
  372 + form.setFieldValue('list', copyList);
  373 + }
  374 +
  375 + /**
311 * 计算子订单金额 376 * 计算子订单金额
312 * @param listMeta 当前商品信息 377 * @param listMeta 当前商品信息
313 */ 378 */
@@ -616,89 +681,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => { @@ -616,89 +681,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
616 }} 681 }}
617 initialValue={data.contactAddress} 682 initialValue={data.contactAddress}
618 options={productCustomerContactOptions} 683 options={productCustomerContactOptions}
619 - // fieldProps={{  
620 - // optionItemRender(item) {  
621 - // if (item.type === 'add') {  
622 - // return (  
623 - // <div title={item.name + '(新增收货人)'}>  
624 - // <span style={{ color: '#333333' }}>{item.name}</span>  
625 - // {' | '}  
626 - // <span style={{ color: 'orange' }}>自定义</span>  
627 - // </div>  
628 - // );  
629 - // }  
630 - // return (  
631 - // <div  
632 - // title={  
633 - // item.name +  
634 - // ' | ' +  
635 - // item.customerContactNumber +  
636 - // ' | ' +  
637 - // (item.customerShippingAddress === undefined  
638 - // ? '无地址'  
639 - // : item.customerShippingAddress) +  
640 - // ' | ' +  
641 - // item.institutionContactName +  
642 - // ' | ' +  
643 - // item.institution  
644 - // }  
645 - // >  
646 - // <span style={{ color: '#333333' }}>{item.name}</span>  
647 - // {' | '}  
648 - // <span style={{ color: '#339999' }}>  
649 - // {item.customerContactNumber === undefined  
650 - // ? '无电话号码'  
651 - // : item.customerContactNumber}  
652 - // </span>  
653 - // {' | '}  
654 - // <span style={{ color: '#666666' }}>  
655 - // {item.customerShippingAddress === undefined  
656 - // ? '无地址'  
657 - // : item.customerShippingAddress}  
658 - // </span>  
659 - // {' | '}  
660 - // <span style={{ color: '#666666' }}>  
661 - // {item.institutionContactName === undefined  
662 - // ? '无课题组'  
663 - // : item.institutionContactName}  
664 - // </span>  
665 - // {' | '}  
666 - // <span style={{ color: '#666666' }}>  
667 - // {item.institution === undefined ? '无单位' : item.institution}  
668 - // </span>  
669 - // </div>  
670 - // );  
671 - // },  
672 - // }}  
673 - // debounceTime={1000}  
674 - // request={async (value, { params }) => {  
675 - // const keywords = value.keyWords;  
676 - // const res = await postKingdeeRepCustomer({  
677 - // data: { search: keywords },  
678 - // params: params,  
679 - // });  
680 - // console.log(res)  
681 - // let options = res?.rows?.map((c: any) => {  
682 - // return {  
683 - // ...c,  
684 - // label: c.name,  
685 - // value: c.id,  
686 - // key: c.id,  
687 - // };  
688 - // });  
689 -  
690 - // //第一个商品默认为要新增的商品  
691 - // if (keywords.trim() !== '') {  
692 - // options.unshift({  
693 - // name: keywords,  
694 - // type: 'add',  
695 - // label: keywords,  
696 - // value: 3.1415926,  
697 - // key: keywords,  
698 - // });  
699 - // }  
700 - // return options;  
701 - // }}  
702 /> 684 />
703 <ProFormText 685 <ProFormText
704 width="lg" 686 width="lg"
@@ -939,7 +921,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -939,7 +921,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
939 return ( 921 return (
940 <div title={item.name + '(新增商品信息)'}> 922 <div title={item.name + '(新增商品信息)'}>
941 <span style={{ color: '#333333' }}> 923 <span style={{ color: '#333333' }}>
942 - {item.name} 924 + {item.label}
943 </span> 925 </span>
944 {' | '} 926 {' | '}
945 <span style={{ color: 'orange' }}>新增商品</span> 927 <span style={{ color: 'orange' }}>新增商品</span>
@@ -1016,7 +998,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -1016,7 +998,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
1016 </span> 998 </span>
1017 </> 999 </>
1018 } 1000 }
1019 - placeholder="未输入商品名称" 1001 + placeholder="商品编码"
1020 />, 1002 />,
1021 // <ProFormSelect 1003 // <ProFormSelect
1022 // key="inv_stock" 1004 // key="inv_stock"
@@ -1033,7 +1015,10 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -1033,7 +1015,10 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
1033 label="商品参数" 1015 label="商品参数"
1034 placeholder="请输入商品参数" 1016 placeholder="请输入商品参数"
1035 rules={[{ required: true, message: '商品参数必填' }]} 1017 rules={[{ required: true, message: '商品参数必填' }]}
1036 - disabled 1018 + disabled={
  1019 + productParametersDisabledFlagList[listMeta.index] !==
  1020 + false
  1021 + }
1037 />, 1022 />,
1038 <ProFormDigit 1023 <ProFormDigit
1039 key={'quantity' + listMeta.index} 1024 key={'quantity' + listMeta.index}
@@ -1071,6 +1056,10 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -1071,6 +1056,10 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
1071 name="unitId" 1056 name="unitId"
1072 width="lg" 1057 width="lg"
1073 label="单位" 1058 label="单位"
  1059 + showSearch
  1060 + onChange={(_, option) => {
  1061 + autoFillUnit(option, listMeta.index);
  1062 + }}
1074 options={productUnitOptionsList[listMeta.index]} 1063 options={productUnitOptionsList[listMeta.index]}
1075 rules={[{ required: true, message: '商品单位必填' }]} 1064 rules={[{ required: true, message: '商品单位必填' }]}
1076 />, 1065 />,
src/services/definition.ts
@@ -720,6 +720,58 @@ export interface MaterialStockRow { @@ -720,6 +720,58 @@ export interface MaterialStockRow {
720 invStockPosition?: string; 720 invStockPosition?: string;
721 } 721 }
722 722
  723 +export interface MaterialUnitListRes {
  724 + count?: string;
  725 + /** @format int32 */
  726 + currentPage?: number;
  727 + /** @format int32 */
  728 + currentPageSize?: number;
  729 + /** @format int32 */
  730 + page?: number;
  731 + /** @format int32 */
  732 + pageSize?: number;
  733 + rows?: Array<MaterialUnitListResRow>;
  734 + /** @format int32 */
  735 + totalPage?: number;
  736 +}
  737 +
  738 +export interface MaterialUnitListResRow {
  739 + /** @format double */
  740 + coefficient?: number;
  741 + conversionUnitId?: string;
  742 + conversionUnitName?: string;
  743 + id?: string;
  744 + /** @format int32 */
  745 + index?: number;
  746 + isDefault?: boolean;
  747 + isFloat?: boolean;
  748 + materialId?: string;
  749 + unitId?: string;
  750 + unitName?: string;
  751 +}
  752 +
  753 +export interface MeasureUnitListRes {
  754 + count?: string;
  755 + /** @format int32 */
  756 + currentPage?: number;
  757 + /** @format int32 */
  758 + currentPageSize?: number;
  759 + /** @format int32 */
  760 + page?: number;
  761 + /** @format int32 */
  762 + pageSize?: number;
  763 + rows?: Array<MeasureUnitListResRow>;
  764 + /** @format int32 */
  765 + totalPage?: number;
  766 +}
  767 +
  768 +export interface MeasureUnitListResRow {
  769 + id?: string;
  770 + name?: string;
  771 + number?: string;
  772 + precision?: string;
  773 +}
  774 +
723 export interface ModelAndView { 775 export interface ModelAndView {
724 empty?: boolean; 776 empty?: boolean;
725 model?: any; 777 model?: any;
@@ -1298,6 +1350,29 @@ export interface Unit { @@ -1298,6 +1350,29 @@ export interface Unit {
1298 unitidName?: string; 1350 unitidName?: string;
1299 } 1351 }
1300 1352
  1353 +export interface UnitMaterialUnitListReq {
  1354 + createEndTime?: string;
  1355 + createStartTime?: string;
  1356 + materialId?: Array<string>;
  1357 + modifyEndTime?: string;
  1358 + modifyStartTime?: string;
  1359 + page?: string;
  1360 + pageSize?: string;
  1361 + search?: string;
  1362 + unPage?: string;
  1363 +}
  1364 +
  1365 +export interface UnitMeasureUnitListReq {
  1366 + createEndTime?: string;
  1367 + createStartTime?: string;
  1368 + enable?: string;
  1369 + modifyEndTime?: string;
  1370 + modifyStartTime?: string;
  1371 + page?: string;
  1372 + pageSize?: string;
  1373 + search?: string;
  1374 +}
  1375 +
1301 export interface UpdateHirePurchaseDto { 1376 export interface UpdateHirePurchaseDto {
1302 /** 1377 /**
1303 * @description 1378 * @description
src/services/request.ts
@@ -36,6 +36,8 @@ import type { @@ -36,6 +36,8 @@ import type {
36 MaterialListReply, 36 MaterialListReply,
37 MaterialMaterialListReq, 37 MaterialMaterialListReq,
38 MaterialStockRes, 38 MaterialStockRes,
  39 + MaterialUnitListRes,
  40 + MeasureUnitListRes,
39 ModelAndView, 41 ModelAndView,
40 OrderAddVO, 42 OrderAddVO,
41 OrderAuditLogQueryVO, 43 OrderAuditLogQueryVO,
@@ -62,6 +64,8 @@ import type { @@ -62,6 +64,8 @@ import type {
62 ServerResult, 64 ServerResult,
63 SysLogQueryVO, 65 SysLogQueryVO,
64 SystemCustomFieldReq, 66 SystemCustomFieldReq,
  67 + UnitMaterialUnitListReq,
  68 + UnitMeasureUnitListReq,
65 UpdateHirePurchaseDto, 69 UpdateHirePurchaseDto,
66 UpdatePwdVO, 70 UpdatePwdVO,
67 } from './definition'; 71 } from './definition';
@@ -983,6 +987,148 @@ export const postKingdeeRepMaterialStock = /* #__PURE__ */ (() =&gt; { @@ -983,6 +987,148 @@ export const postKingdeeRepMaterialStock = /* #__PURE__ */ (() =&gt; {
983 return request; 987 return request;
984 })(); 988 })();
985 989
  990 +/** @description request parameter type for postKingdeeRepMaterialUnit */
  991 +export interface PostKingdeeRepMaterialUnitOption {
  992 + /**
  993 + * @description
  994 + * req
  995 + */
  996 + body: {
  997 + /**
  998 + @description
  999 + req */
  1000 + req: UnitMaterialUnitListReq;
  1001 + };
  1002 +}
  1003 +
  1004 +/** @description response type for postKingdeeRepMaterialUnit */
  1005 +export interface PostKingdeeRepMaterialUnitResponse {
  1006 + /**
  1007 + * @description
  1008 + * OK
  1009 + */
  1010 + 200: MaterialUnitListRes;
  1011 + /**
  1012 + * @description
  1013 + * Created
  1014 + */
  1015 + 201: any;
  1016 + /**
  1017 + * @description
  1018 + * Unauthorized
  1019 + */
  1020 + 401: any;
  1021 + /**
  1022 + * @description
  1023 + * Forbidden
  1024 + */
  1025 + 403: any;
  1026 + /**
  1027 + * @description
  1028 + * Not Found
  1029 + */
  1030 + 404: any;
  1031 +}
  1032 +
  1033 +export type PostKingdeeRepMaterialUnitResponseSuccess =
  1034 + PostKingdeeRepMaterialUnitResponse[200];
  1035 +/**
  1036 + * @description
  1037 + * getMaterialDetail
  1038 + * @tags kingdee-erp-controller
  1039 + * @produces *
  1040 + * @consumes application/json
  1041 + */
  1042 +export const postKingdeeRepMaterialUnit = /* #__PURE__ */ (() => {
  1043 + const method = 'post';
  1044 + const url = '/kingdee/rep/materialUnit';
  1045 + function request(
  1046 + option: PostKingdeeRepMaterialUnitOption,
  1047 + ): Promise<PostKingdeeRepMaterialUnitResponseSuccess> {
  1048 + return requester(request.url, {
  1049 + method: request.method,
  1050 + ...option,
  1051 + }) as unknown as Promise<PostKingdeeRepMaterialUnitResponseSuccess>;
  1052 + }
  1053 +
  1054 + /** http method */
  1055 + request.method = method;
  1056 + /** request url */
  1057 + request.url = url;
  1058 + return request;
  1059 +})();
  1060 +
  1061 +/** @description request parameter type for postKingdeeRepMeasureUnit */
  1062 +export interface PostKingdeeRepMeasureUnitOption {
  1063 + /**
  1064 + * @description
  1065 + * req
  1066 + */
  1067 + body: {
  1068 + /**
  1069 + @description
  1070 + req */
  1071 + req: UnitMeasureUnitListReq;
  1072 + };
  1073 +}
  1074 +
  1075 +/** @description response type for postKingdeeRepMeasureUnit */
  1076 +export interface PostKingdeeRepMeasureUnitResponse {
  1077 + /**
  1078 + * @description
  1079 + * OK
  1080 + */
  1081 + 200: MeasureUnitListRes;
  1082 + /**
  1083 + * @description
  1084 + * Created
  1085 + */
  1086 + 201: any;
  1087 + /**
  1088 + * @description
  1089 + * Unauthorized
  1090 + */
  1091 + 401: any;
  1092 + /**
  1093 + * @description
  1094 + * Forbidden
  1095 + */
  1096 + 403: any;
  1097 + /**
  1098 + * @description
  1099 + * Not Found
  1100 + */
  1101 + 404: any;
  1102 +}
  1103 +
  1104 +export type PostKingdeeRepMeasureUnitResponseSuccess =
  1105 + PostKingdeeRepMeasureUnitResponse[200];
  1106 +/**
  1107 + * @description
  1108 + * getCustomerDetail
  1109 + * @tags kingdee-erp-controller
  1110 + * @produces *
  1111 + * @consumes application/json
  1112 + */
  1113 +export const postKingdeeRepMeasureUnit = /* #__PURE__ */ (() => {
  1114 + const method = 'post';
  1115 + const url = '/kingdee/rep/measureUnit';
  1116 + function request(
  1117 + option: PostKingdeeRepMeasureUnitOption,
  1118 + ): Promise<PostKingdeeRepMeasureUnitResponseSuccess> {
  1119 + return requester(request.url, {
  1120 + method: request.method,
  1121 + ...option,
  1122 + }) as unknown as Promise<PostKingdeeRepMeasureUnitResponseSuccess>;
  1123 + }
  1124 +
  1125 + /** http method */
  1126 + request.method = method;
  1127 + /** request url */
  1128 + request.url = url;
  1129 + return request;
  1130 +})();
  1131 +
986 /** @description request parameter type for postKingdeeRepSystemCustomField */ 1132 /** @description request parameter type for postKingdeeRepSystemCustomField */
987 export interface PostKingdeeRepSystemCustomFieldOption { 1133 export interface PostKingdeeRepSystemCustomFieldOption {
988 /** 1134 /**