From 346e1142fef6ea3bfda1701ec795f358b123b1f1 Mon Sep 17 00:00:00 2001
From: jiashuai <2051606263@qq.com>
Date: Wed, 17 Sep 2025 10:17:53 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pickm/card/btnClicks/borrowBtnClick.js | 269 ++++++++++++++++++
.../pickmborrow/list/events/headAfterEvent.js | 4 +
.../list/events/headBeforeEvent.js | 15 +
.../pickm/pickmborrow/list/events/index.js | 5 +
.../mmpac/pickm/pickmborrow/list/index.js | 147 ++++++++++
.../pickm/pickmborrow/list/init/index.js | 2 +
.../pickmborrow/list/init/initTemplate.js | 43 +++
7 files changed, 485 insertions(+)
create mode 100644 src/mmpac/mmpac/pickm/card/btnClicks/borrowBtnClick.js
create mode 100644 src/mmpac/mmpac/pickm/pickmborrow/list/events/headAfterEvent.js
create mode 100644 src/mmpac/mmpac/pickm/pickmborrow/list/events/headBeforeEvent.js
create mode 100644 src/mmpac/mmpac/pickm/pickmborrow/list/events/index.js
create mode 100644 src/mmpac/mmpac/pickm/pickmborrow/list/index.js
create mode 100644 src/mmpac/mmpac/pickm/pickmborrow/list/init/index.js
create mode 100644 src/mmpac/mmpac/pickm/pickmborrow/list/init/initTemplate.js
diff --git a/src/mmpac/mmpac/pickm/card/btnClicks/borrowBtnClick.js b/src/mmpac/mmpac/pickm/card/btnClicks/borrowBtnClick.js
new file mode 100644
index 00000000..ce24bb12
--- /dev/null
+++ b/src/mmpac/mmpac/pickm/card/btnClicks/borrowBtnClick.js
@@ -0,0 +1,269 @@
+import { ajax, toast, base } from 'nc-lightapp-front';
+let { NCModal, NCButton, NCTooltip, NCHotKeys } = base;
+import { AREA, URL, DIALOGCODE, FIELD, PAGECARDCODE } from '../../constance';
+import { initLang, getLangByResId } from '../../../../../mmpub/mmpub/pub/tool/multiLangUtil';
+import PickmReplaceDlg from '../../pickmreplace/list';
+import { RownoUtils } from '../../../../../mmpub/mmpub/pub/tool/cardTableTools';
+import { buttonController } from '../viewController/index';
+import { showSuccessInfo, showErrorInfo, showWarningInfo, showWarningDialog } from '../../../../../mmpub/mmpub/pub/tool/messageUtil';
+
+const TABLE_HEAD = 'replace_head';
+const TABLE_BODY = 'replace_body'
+export default function replaceBtnClick(props, data) {
+ let _this = this;
+ this.headDatas = [];
+ this.bodyDatas = {};
+ let setHeadDatas = (val) => {
+ this.headDatas = val;
+ };
+ let setBodyDatas = (val) => {
+ this.bodyDatas = val;
+ };
+ let getBodyDatas = () => {
+ return this.bodyDatas;
+ }
+ this.replaceProps = {};
+ let setReplaceProps = (val) => {
+ this.replaceProps = val;
+ }
+ ajax({
+ url: URL.replaceQueryURL,
+ data: data,
+ success: res => {
+ if (res.success && res.data) {
+ props.modal.show('ReplaceDlg', {
+ size: 'xlg',
+ title: getLangByResId(this, '5008Pickm-000093'),/* 国际化处理: 替代*/
+ content: ,
+ userControl: true,
+ leftBtnName: '',
+ rightBtnName: getLangByResId(this, '5008Pickm-000013'),/* 国际化处理: 取消*/
+ beSureBtnClick: replaceOKBtnClicks.bind(this, props, true),
+ cancelBtnClick: () => {
+ props.modal.close('ReplaceDlg');
+ },
+ showCustomBtns: true,
+ customBtns:
{ autoMatchBtnClick.call(this, props) }}>{getLangByResId(this, '5008Pickm-000103')}
+
+ {
+ replaceOKBtnClicks.call(this, props, true);
+ }}>{getLangByResId(this, '5008Pickm-000102')}(Y){/* 国际化处理: 确定*/}
+
+
+ {
+ props.modal.close('ReplaceDlg');
+ }}>{getLangByResId(this, '5008Pickm-000013')}(N){/* 国际化处理: 取消*/}
+
,
+ hideRightBtn: false, //隐藏足部右边的按钮,默认是false不隐藏,隐藏是true
+ hideLeftBtn: false //隐藏足部左边的按钮,默认是false不隐藏,隐藏是true
+ });
+ }
+ }
+ });
+}
+function autoMatchBtnClick(props) {
+ let repBodys = {};
+ let repHeads = this.replaceProps.editTable.getAllRows('replace_head');
+ let pickmbid;
+ let headbid = repHeads[0].values.cpickm_bid.value;
+ let bodys = [];
+ repHeads.forEach((head) => {
+ pickmbid = head.values.cpickm_bid.value;
+ if (this.bodyDatas && this.bodyDatas[pickmbid]) {
+ bodys = [];
+ this.bodyDatas[pickmbid].forEach((item) => {
+ bodys.push(item);
+ });
+ if (bodys.length > 0) {
+ repBodys[pickmbid] = JSON.stringify({
+ pageid: DIALOGCODE.REPLACEDLG,
+ model: {
+ areaType: "table",
+ pageinfo: null,
+ rows: bodys,
+ areacode: 'replace_body'
+ }
+ });
+ }
+
+ }
+ });
+ let param = {
+ pageid: PAGECARDCODE,
+ repHeads: JSON.stringify({
+ pageid: DIALOGCODE.REPLACEDLG,
+ model: {
+ areaType: "table",
+ pageinfo: null,
+ rows: repHeads,
+ areacode: 'replace_head',
+ }
+ }),
+ repBodys: repBodys
+ }
+ ajax({
+ url: URL.replaceAutoMatchURL,
+ data: param,
+ success: res => {
+ if (res.success && res.data) {
+ this.bodyDatas = res.data.body;
+ this.replaceProps.setBodyDatas(res.data.body)
+ this.replaceProps.setHeadDatas( res.data.head[TABLE_HEAD]);
+ this.replaceProps.editTable.setTableData(TABLE_HEAD, { rows: res.data.head[TABLE_HEAD].rows });
+ let bodys = [];
+ if (res.data.body[headbid]) {
+ bodys = res.data.body[headbid]
+ }
+ this.replaceProps.editTable.setTableData(TABLE_BODY, { rows: bodys });
+ if (res.data.msg) {
+ showWarningInfo(res.data.msg);
+ }
+ else{
+ showSuccessInfo(getLangByResId(this, '5008Pickm-000104'));
+ }
+ }
+ },
+ error: (error) => {
+ toast({
+ color: 'warning',
+ content: error.message
+ });
+ }
+
+ });
+}
+function replaceOKBtnClicks(props, flag) {
+ let repHeads = [];
+ let repBodys = {};
+ let bodys = [];
+ let mainIds = [];
+ let heads = this.replaceProps.editTable.getAllRows('replace_head');
+ if (heads) {
+ let pickmbid;
+ heads.forEach((head) => {
+ pickmbid = head.values.cpickm_bid.value;
+ if (this.bodyDatas && this.bodyDatas[pickmbid]) {
+ bodys = [];
+ this.bodyDatas[pickmbid].forEach((item) => {
+ if (item.values.rep_repnum && item.values.rep_repnum.value && item.values.rep_repnum.value > 0) {
+ bodys.push(item);
+ }
+ });
+ if (bodys.length > 0) {
+ mainIds.push(pickmbid);
+ repHeads.push(head);
+ repBodys[pickmbid] = JSON.stringify({
+ pageid: DIALOGCODE.REPLACEDLG,
+ model: {
+ areaType: "table",
+ pageinfo: null,
+ rows: bodys,
+ areacode: 'replace_body'
+ }
+ });
+ }
+
+ }
+ });
+ }
+ if (repHeads.length < 1) {
+ props.modal.close('ReplaceDlg');
+ return;
+ }
+ let bodyData = props.cardTable.getAllRows(AREA.bodyTable);
+ let oldReplaces=[];
+ let rownos=[];
+ bodyData.map((item, i) => {
+ if(item.values.vrowno && item.values.vrowno.value){
+ rownos.push(item.values.vrowno.value);
+ }
+ if (item.values.creplacesrcid && item.values.creplacesrcid.value && mainIds.includes(item.values.creplacesrcid.value)) {
+ oldReplaces.push(item);
+ }
+ });
+ let param = {
+ pageid: PAGECARDCODE,
+ isCheckAtp: flag,
+ repHeads: JSON.stringify({
+ pageid: DIALOGCODE.REPLACEDLG,
+ model: {
+ areaType: "table",
+ pageinfo: null,
+ rows: repHeads,
+ areacode: 'replace_head',
+ }
+ }),
+ repBodys: repBodys,
+ rownos:rownos,
+ oldRepBodys:JSON.stringify({
+ pageid: PAGECARDCODE,
+ model: {
+ areaType: "table",
+ pageinfo: null,
+ rows: oldReplaces,
+ areacode: AREA.bodyTable,
+ }
+ })
+ }
+ ajax({
+ url: URL.replaceDoURL,
+ data: param,
+ success: res => {
+ if (res.success && res.data) {
+ if (res.data && res.data.isAtpCheckResume && res.data.isAtpCheckResume == true) {
+ showWarningDialog(getLangByResId(this, '5008Pickm-000001')/* 国际化处理: 提示*/, res.data.atpCheckMsg
+ , {
+ beSureBtnClick: replaceOKBtnClicks.bind(this, props, false)
+ });
+ return;
+ }
+ props.modal.close('ReplaceDlg');
+ let len=props.cardTable.getNumberOfRows(AREA.bodyTable);
+ let cpcikmbid;
+ let updateArray = [];
+ let indexs=[];
+ let repItem={};
+ for (let i = 0; i < len; i++) {
+ cpcikmbid=props.cardTable.getValByKeyAndIndex(AREA.bodyTable,i,'cpickm_bid');
+ if(cpcikmbid&&cpcikmbid.value&&res.data[cpcikmbid.value]){
+ let obj = { index: i, data: res.data[cpcikmbid.value].mainItem };
+ updateArray.push(obj);
+ repItem[i]=res.data[cpcikmbid.value].repItems;
+ indexs.push(i);
+ }
+ }
+ if (updateArray.length > 0) {
+ props.cardTable.updateDataByIndexs(AREA.bodyTable, updateArray);
+ for(let j=indexs.length-1;j>=0;j--){
+ props.cardTable.insertRowsAfterIndex(AREA.bodyTable,repItem[indexs[j]],indexs[j]);
+ }
+ RownoUtils.setRowNo(props, AREA.bodyTable, FIELD.vrowno);
+ props.cardTable.selectAllRows(AREA.bodyTable, false);
+ props.cardTable.setAllCheckboxAble(AREA.bodyTable, true);
+ buttonController.lineSelected.call(this);
+ }
+
+ }
+ },
+ error: (error) => {
+ toast({
+ color: 'warning',
+ content: error.message
+ });
+ }
+ });
+
+
+}
\ No newline at end of file
diff --git a/src/mmpac/mmpac/pickm/pickmborrow/list/events/headAfterEvent.js b/src/mmpac/mmpac/pickm/pickmborrow/list/events/headAfterEvent.js
new file mode 100644
index 00000000..7e1ea810
--- /dev/null
+++ b/src/mmpac/mmpac/pickm/pickmborrow/list/events/headAfterEvent.js
@@ -0,0 +1,4 @@
+export default async function headAfterEvent(props, moduleId, key, value, changedrows, i) {
+ let headData = props.editTable.getAllData('replace_head', true);
+ this.props.setHeadDatas(headData);
+}
diff --git a/src/mmpac/mmpac/pickm/pickmborrow/list/events/headBeforeEvent.js b/src/mmpac/mmpac/pickm/pickmborrow/list/events/headBeforeEvent.js
new file mode 100644
index 00000000..6784f955
--- /dev/null
+++ b/src/mmpac/mmpac/pickm/pickmborrow/list/events/headBeforeEvent.js
@@ -0,0 +1,15 @@
+
+export default function headBeforeEvent(props, moduleId, item, index, value, record) {
+ let key = item.attrcode;
+ let editFields = ['freplacetype'];
+ if (!editFields.includes(key)) {
+ return false;
+ }
+ else if (key == 'freplacetype') {
+ //以替代的备料计划表体不能修改替代类型
+ let replaceInfo = props.editTable.getValByKeyAndIndex(moduleId, index, 'freplaceinfo').value;
+ if (replaceInfo == 2) {
+ return false;
+ }
+ } return true;
+}
diff --git a/src/mmpac/mmpac/pickm/pickmborrow/list/events/index.js b/src/mmpac/mmpac/pickm/pickmborrow/list/events/index.js
new file mode 100644
index 00000000..1a4fb416
--- /dev/null
+++ b/src/mmpac/mmpac/pickm/pickmborrow/list/events/index.js
@@ -0,0 +1,5 @@
+import headBeforeEvent from './headBeforeEvent';
+import headAfterEvent from './headAfterEvent';
+import bodyAfterEvent from './bodyAfterEvent';
+import bodyBeforeEvent from './bodyBeforeEvent';
+export { headBeforeEvent,headAfterEvent,bodyAfterEvent, bodyBeforeEvent };
diff --git a/src/mmpac/mmpac/pickm/pickmborrow/list/index.js b/src/mmpac/mmpac/pickm/pickmborrow/list/index.js
new file mode 100644
index 00000000..ec6f12b5
--- /dev/null
+++ b/src/mmpac/mmpac/pickm/pickmborrow/list/index.js
@@ -0,0 +1,147 @@
+import React, { Component } from 'react';
+import ReactDOM from 'react-dom';
+import { createPage, ajax, base, high } from 'nc-lightapp-front';
+const { Refer } = high;
+import { initTemplate } from './init';
+import { initLang, getLangByResId } from '../../../../../mmpub/mmpub/pub/tool/multiLangUtil';
+import { headAfterEvent, headBeforeEvent, bodyAfterEvent, bodyBeforeEvent } from './events';
+import { AREA, URL, DIALOGCODE, FIELD, PAGECARDCODE } from '../../constance';
+const { NCModal } = base;
+const TABLE_HEAD = 'replace_head';
+const TABLE_BODY = 'replace_body'
+
+class PickmReplaceDlg extends Component {
+ constructor(props) {
+ super(props);
+ props.use.editTable(TABLE_HEAD);
+ props.use.editTable(TABLE_BODY);
+ this.state = {
+ totalRepNum: {}
+ };
+ initLang(this, ['5008Pickm'], 'mmpac', initTemplate.bind(this, this.props));
+ }
+
+ componentDidMount() {
+ this.initData();
+ }
+ //请求列表数据
+ initData = () => {
+ let showdata = this.props.showdata;
+ let heads = [];
+ let bodys = [];
+ if (showdata && showdata.head) {
+ heads = showdata.head[TABLE_HEAD].rows;
+ if (showdata.body) {
+ bodys = showdata.body[TABLE_BODY].rows;
+ }
+ let cpickmbid = showdata.head[TABLE_HEAD].rows[0].values.cpickm_bid.value;
+ let bodyData = {};
+ bodyData[cpickmbid] = bodys;
+ this.setState({
+ bodyDatas: bodyData
+ });
+ }
+ this.props.editTable.setTableData(TABLE_HEAD, { rows: heads });
+ this.props.editTable.setTableData(TABLE_BODY, { rows: bodys });
+ this.props.setReplaceProps(this.props);
+ };
+ onRowClick = (props, moduleId, record, index, e) => {
+ this.loadBodyInfo(props, record, index);
+ }
+ loadBodyInfo(props, record, index) {
+ let bodyData = this.props.getBodyDatas();
+ let cpickmbid = this.props.editTable.getValByKeyAndIndex(TABLE_HEAD, index, 'cpickm_bid');
+ let bodys = [];
+ let totalRepNum = this.state.totalRepNum;
+ if (bodyData && bodyData[cpickmbid.value]) {
+ let cmatreilvid;
+ let devOrg;
+ bodys = bodyData[cpickmbid.value];
+ if (bodys && bodys.length > 0) {
+ bodys.forEach(body => {
+ cmatreilvid = body.values.cbmaterialvid.value;
+ devOrg = body.values.cdeliverorgid.value;
+ if (totalRepNum && totalRepNum[devOrg + cmatreilvid]) {
+ body.values.rep_totalrepnum = totalRepNum[devOrg + cmatreilvid].num;
+ body.values.rep_totalrepastnum = totalRepNum[devOrg + cmatreilvid].astNum;
+ }
+ });
+ }
+ this.props.editTable.setTableData(TABLE_BODY, { rows: bodys });
+ }
+ else {
+ let userjson = {};
+ if (totalRepNum) {
+ Object.keys(totalRepNum).forEach(key => {
+ userjson[key] = totalRepNum[key].num.value;
+ })
+ }
+ let param = {
+ pageid: DIALOGCODE.REPLACEDLG,
+ model: {
+ areaType: "table",
+ pageinfo: null,
+ rows: [record],
+ areacode: TABLE_HEAD,
+ },
+ userjson: JSON.stringify(
+ userjson
+ )
+ };
+ ajax({
+ url: URL.replaceBodyQueryURL,
+ data: param,
+ success: res => {
+ if (res.success) {
+ if (res.data) {
+ bodys = res.data[TABLE_BODY].rows;
+ }
+ bodyData[cpickmbid.value] = bodys;
+ this.props.editTable.setTableData(TABLE_BODY, { rows: bodys });
+ }
+ }
+ });
+ }
+ }
+ onRowDoubleClick = (record, index, props, e) => {
+ this.loadBodyInfo(props, record, index);
+ }
+ render() {
+ let { editTable } = this.props;
+ let { createEditTable } = editTable;
+ return
+
+ {createEditTable(TABLE_HEAD, {
+ showIndex: true,
+ // height: 100,
+ onRowClick: this.onRowClick.bind(this),
+ onRowDoubleClick: this.onRowDoubleClick.bind(this),
+ onBeforeEvent: headBeforeEvent.bind(this),
+ onAfterEvent: headAfterEvent.bind(this),
+ isAddRow: false,
+ showCheck: false
+ })}
+
+
+ {createEditTable(TABLE_BODY, {
+ onBeforeEvent: bodyBeforeEvent.bind(this),
+ onAfterEvent: bodyAfterEvent.bind(this),
+ showCheck: false,
+ showIndex: true,
+ hideAdd: false,
+ adaptionHeight: true
+ })}
+
+
;
+ }
+}
+
+PickmReplaceDlg = createPage({
+ billinfo: {
+ billtype: 'grid',
+ pagecode: '50080102_replace',
+ bodycode: 'replace_body'
+ }//,
+})(PickmReplaceDlg);
+
+export default PickmReplaceDlg;
diff --git a/src/mmpac/mmpac/pickm/pickmborrow/list/init/index.js b/src/mmpac/mmpac/pickm/pickmborrow/list/init/index.js
new file mode 100644
index 00000000..54195f48
--- /dev/null
+++ b/src/mmpac/mmpac/pickm/pickmborrow/list/init/index.js
@@ -0,0 +1,2 @@
+import initTemplate from './initTemplate';
+export { initTemplate };
diff --git a/src/mmpac/mmpac/pickm/pickmborrow/list/init/initTemplate.js b/src/mmpac/mmpac/pickm/pickmborrow/list/init/initTemplate.js
new file mode 100644
index 00000000..83fbfdc6
--- /dev/null
+++ b/src/mmpac/mmpac/pickm/pickmborrow/list/init/initTemplate.js
@@ -0,0 +1,43 @@
+import { DIALOGCODE } from '../../../constance';
+import { getLangByResId } from '../../../../../../mmpub/mmpub/pub/tool/multiLangUtil';
+const TABLE_HEAD = 'replace_head';
+const TABLE_BODY = 'replace_body'
+export default function (props) {
+ let appcode = props.getAppCode();
+ if (props.getAppCode().startsWith('5009')) {
+ appcode = '50090102';
+ }
+ else if (props.getAppCode().startsWith('5008')) {
+ appcode = '50080102';
+ }
+ //请求模板数据
+ props.createUIDom(
+ {
+ appcode: appcode,
+ pagecode: DIALOGCODE.REPLACEDLG
+ },
+ (templedata) => {
+ if (templedata.template) {
+ let meta = templedata.template;
+ modifierMeta.call(this, this.props, meta);
+ props.meta.setMeta(meta);
+ props.editTable.setStatus(TABLE_HEAD, 'edit');
+ props.editTable.setStatus(TABLE_BODY, 'edit');
+ }
+ });
+}
+function modifierMeta(props, meta) {
+ meta[TABLE_HEAD].items.map((item) => {
+ if (item.attrcode == 'freplacetype') {
+ item.options = [{
+ display: getLangByResId(this, '5008Pickm-000096')/* 国际化处理: "全部替代"*/,
+ value: "1"
+ }, {
+ display: getLangByResId(this, '5008Pickm-000097')/* 国际化处理: ""部分替代"*/,
+ value: "2"
+ }
+ ];
+ }
+ });
+ return meta;
+}