|
@@ -1856,53 +1856,75 @@ export const useHooks = (t?: any) => {
|
|
|
resetMergeCellsQd();
|
|
|
};
|
|
|
/**
|
|
|
- * 获取产品配置,产品清单
|
|
|
+ * 刷新产品配置
|
|
|
* @param mattressid 床垫ID
|
|
|
+ * @param isPz 类型 0 - 刷新 1 - 复制 2 - 重新生成
|
|
|
*/
|
|
|
const RefreshMattressInterfaceList = async (mattressid: number, isPz: number, configcodetype: number = 0) => {
|
|
|
let res = await RefreshMattressInterface({ mattressid, isPz: isPz, configcodetype });
|
|
|
- // state.mattressYWList = res.mxList;
|
|
|
|
|
|
- // 获取先有配置信息
|
|
|
const $table = state.YwTableRef?.element;
|
|
|
- if ($table) {
|
|
|
- let { visibleData } = $table.getTableData();
|
|
|
- const copyMap = new Map();
|
|
|
-
|
|
|
- res.mxList.forEach((mx: any) => {
|
|
|
+ let { visibleData } = $table.getTableData();
|
|
|
+ const copyMap = new Map();
|
|
|
+
|
|
|
+ // inputtype 0 - 选择 1 - 录入 2 - 带出
|
|
|
+ if (isPz === 0) {
|
|
|
+ // 刷新配置 FEAT: 只刷新带出类型的配置,只刷新明细名称列,如果有新增的,需要补齐。
|
|
|
+ visibleData.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
|
|
|
+
|
|
|
+ const PRESERVE_PROPS = [
|
|
|
+ "bj_inputtype",
|
|
|
+ "erp_pzname",
|
|
|
+ "erp_pzcode",
|
|
|
+ "bj_pzname",
|
|
|
+ "itemname",
|
|
|
+ "actual_size",
|
|
|
+ "sb_craft",
|
|
|
+ "actual_size_sb",
|
|
|
+ "ss_rate",
|
|
|
+ "ls_rate"
|
|
|
+ ];
|
|
|
+ state.mattressYWList = res.mxList.map(mx => {
|
|
|
const key = `${mx.erp_pzid}`;
|
|
|
- if (!copyMap.has(key)) copyMap.set(key, mx);
|
|
|
+ if (copyMap.has(key)) {
|
|
|
+ PRESERVE_PROPS.forEach(prop => {
|
|
|
+ mx[prop] = copyMap.get(key)[prop];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return mx;
|
|
|
});
|
|
|
+ } else if (isPz === 1) {
|
|
|
+ // 复制配置 FEAT:只复制录入和选择类型的配置,生产信息不覆盖
|
|
|
+ const NEED_PROPS = ["bj_inputtype", "bj_namemx"];
|
|
|
+ res.mxList.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
|
|
|
|
|
|
- visibleData.forEach((mx: any) => {
|
|
|
+ visibleData.forEach(mx => {
|
|
|
const key = `${mx.erp_pzid}`;
|
|
|
- if (mx.erp_pzid > 0 && copyMap.has(key)) {
|
|
|
- const mx2 = copyMap.get(key);
|
|
|
-
|
|
|
- if (mx.bj_inputtype !== 2 || (mx.bj_inputtype === 2 && mx2.bj_inputtype === 1)) {
|
|
|
- mx.bj_namemx = mx2.bj_namemx;
|
|
|
- mx.actual_size = mx2.actual_size;
|
|
|
- mx.sb_craft = mx2.sb_craft;
|
|
|
- mx.actual_size_sb = mx2.actual_size_sb;
|
|
|
- mx.ss_rate = mx2.ss_rate;
|
|
|
- mx.ls_rate = mx2.ls_rate;
|
|
|
-
|
|
|
- if (mx.bj_inputtype === 2 && mx2.bj_inputtype === 1) {
|
|
|
- mx.bj_inputtype = 1;
|
|
|
- }
|
|
|
- } else {
|
|
|
- mx.actual_size = mx2.actual_size;
|
|
|
- mx.sb_craft = mx2.sb_craft;
|
|
|
- mx.actual_size_sb = mx2.actual_size_sb;
|
|
|
- mx.ss_rate = mx2.ss_rate;
|
|
|
- mx.ls_rate = mx2.ls_rate;
|
|
|
- }
|
|
|
+ if (copyMap.has(key) && (mx.bj_inputtype === 1 || mx.bj_inputtype === 0)) {
|
|
|
+ NEED_PROPS.forEach(prop => {
|
|
|
+ mx[prop] = copyMap.get(key)[prop];
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $table.reloadData(visibleData);
|
|
|
+ state.mattressQDList = visibleData.map((mx: any) => mx);
|
|
|
+ } else {
|
|
|
+ const PRESERVE_PROPS = ["actual_size", "sb_craft", "actual_size_sb", "ss_rate", "ls_rate"];
|
|
|
+
|
|
|
+ visibleData.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
|
|
|
+
|
|
|
+ state.mattressYWList = res.mxList.map(mx => {
|
|
|
+ const key = `${mx.erp_pzid}`;
|
|
|
+ if (copyMap.has(key)) {
|
|
|
+ PRESERVE_PROPS.forEach(prop => {
|
|
|
+ mx[prop] = copyMap.get(key)[prop];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return mx;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+ // $table.reloadData(visibleData);
|
|
|
resetMergeCells();
|
|
|
|
|
|
ElNotification({
|
|
@@ -1911,8 +1933,9 @@ export const useHooks = (t?: any) => {
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
- * 获取产品配置,产品清单
|
|
|
+ * 刷新产品清单
|
|
|
* @param mattressid 床垫ID
|
|
|
+ * @param isPz 类型 0 - 刷新 1 - 复制 2 - 重新生成
|
|
|
*/
|
|
|
const RefreshMattressInterfaceQdList = async (mattressid: number, isPz: number, isCheck?: number) => {
|
|
|
isCheck = isCheck ?? 1;
|
|
@@ -1940,46 +1963,67 @@ export const useHooks = (t?: any) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // 获取先有清单信息
|
|
|
const $table = state.QdTableRef?.element;
|
|
|
- if ($table) {
|
|
|
- let { visibleData } = $table.getTableData();
|
|
|
- const copyMap = new Map();
|
|
|
+ let { visibleData } = $table.getTableData();
|
|
|
+ const copyMap = new Map();
|
|
|
+ // qd_actual_size字段不修改
|
|
|
+ const PRESERVE_PROPS = ["qd_actual_size"];
|
|
|
|
|
|
- res.mxList.forEach(mx => {
|
|
|
- const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
|
|
|
+ if (isPz === 0) {
|
|
|
+ // 刷新清单
|
|
|
+ visibleData.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
|
|
|
|
|
|
- if (!copyMap.has(key)) copyMap.set(key, mx);
|
|
|
+ state.mattressQDList = res.mxList.map(mx => {
|
|
|
+ const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
|
|
|
+ if (copyMap.has(key)) {
|
|
|
+ PRESERVE_PROPS.forEach(prop => {
|
|
|
+ mx[prop] = copyMap.get(key)[prop];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return mx;
|
|
|
});
|
|
|
+ } else if (isPz === 1) {
|
|
|
+ // 复制清单
|
|
|
+ const NEED_PROPS = [
|
|
|
+ "erp_mtrlid",
|
|
|
+ "erp_mtrlcode",
|
|
|
+ "erp_mtrlname",
|
|
|
+ "erp_mtrlmode",
|
|
|
+ "erp_unit",
|
|
|
+ "useqty",
|
|
|
+ "actual_useqty",
|
|
|
+ "wrkgrpid",
|
|
|
+ "qd_pfgroupqty",
|
|
|
+ "dscrp"
|
|
|
+ ];
|
|
|
+ res.mxList.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
|
|
|
|
|
|
visibleData.forEach(mx => {
|
|
|
- // 创建复合键(使用模板字符串生成唯一标识)
|
|
|
const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
|
|
|
-
|
|
|
- // 从Map中查找对应值(替代TryGetValue)
|
|
|
if (copyMap.has(key)) {
|
|
|
- const mx2 = copyMap.get(key);
|
|
|
-
|
|
|
- Object.assign(mx, {
|
|
|
- erp_mtrlid: mx2.erp_mtrlid,
|
|
|
- erp_mtrlcode: mx2.erp_mtrlcode,
|
|
|
- erp_mtrlname: mx2.erp_mtrlname,
|
|
|
- erp_mtrlmode: mx2.erp_mtrlmode,
|
|
|
- erp_unit: mx2.erp_unit,
|
|
|
- useqty: mx2.useqty,
|
|
|
- actual_useqty: mx2.actual_useqty,
|
|
|
- wrkgrpid: mx2.wrkgrpid,
|
|
|
- qd_actual_size: mx2.qd_actual_size,
|
|
|
- qd_pfgroupqty: mx2.qd_pfgroupqty,
|
|
|
- dscrp: mx2.dscrp
|
|
|
+ NEED_PROPS.forEach(prop => {
|
|
|
+ mx[prop] = copyMap.get(key)[prop];
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $table.reloadData(visibleData);
|
|
|
+ state.mattressQDList = visibleData.map((mx: any) => mx);
|
|
|
+ } else {
|
|
|
+ // 重新刷新清单
|
|
|
+ visibleData.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
|
|
|
+
|
|
|
+ state.mattressQDList = res.mxList.map(mx => {
|
|
|
+ const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
|
|
|
+ if (copyMap.has(key)) {
|
|
|
+ PRESERVE_PROPS.forEach(prop => {
|
|
|
+ mx[prop] = copyMap.get(key)[prop];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return mx;
|
|
|
+ });
|
|
|
}
|
|
|
- // state.mattressQDList = res.mxList;
|
|
|
|
|
|
+ // $table.reloadData(visibleData);
|
|
|
resetMergeCellsQd();
|
|
|
|
|
|
ElNotification({
|