@gct-paas/word 0.1.47 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -53934,29 +53934,36 @@ class MCDataUtil {
53934
53934
  const { row, keys: keys2 = this.allFields, disabled = true } = opts;
53935
53935
  this.editMCTable(row, { fieldDisabled: this.arrToObj(keys2, disabled) });
53936
53936
  }
53937
+ static _updateDisablement(option) {
53938
+ const { dataManager, rowPath, fields, disabled } = option;
53939
+ const config = { newDisabled: disabled };
53940
+ fields.forEach((field) => {
53941
+ dataManager.setFieldRuntimeSpecificConfig(`${rowPath}.${field}`, config);
53942
+ });
53943
+ }
53937
53944
  /**
53938
- * 物料消耗表 需求数量、已消耗数量 不可修改
53945
+ * 物料消耗表[需求数量、已消耗数量]一直禁用
53939
53946
  * @param rowPath $.f_sub[n] n 必须为数字
53940
53947
  */
53941
53948
  static disableQtyFields(dataManager, rowPath) {
53942
- const config = { newDisabled: true };
53943
- dataManager.setFieldRuntimeSpecificConfig(`${rowPath}.qty_required_`, config);
53944
- dataManager.setFieldRuntimeSpecificConfig(`${rowPath}.qty_consumed_`, config);
53949
+ const fields = ["qty_consumed_", "qty_required_"];
53950
+ this._updateDisablement({ dataManager, rowPath, fields, disabled: true });
53945
53951
  }
53946
53952
  /**
53947
- * 物料消耗表 更新部分字段是否禁用
53953
+ * 物料消耗表 物料类型是否是[查看物料]时需要更新[物料批号、数量]字段是否禁用
53948
53954
  * @param rowPath $.f_sub[n] n 必须为数字
53949
53955
  */
53950
- static updateOtherFieldsDisabled(option) {
53951
- const { dataManager, rowPath, disabled } = option;
53952
- const config = { newDisabled: disabled };
53953
- [
53954
- "product_id_",
53955
- "material_no_",
53956
- "routing_operation_id_"
53957
- ].forEach((key) => {
53958
- dataManager.setFieldRuntimeSpecificConfig(`${rowPath}.${key}`, config);
53959
- });
53956
+ static updateViewFieldsDisablement(option) {
53957
+ const fields = ["material_no_", "qty_"];
53958
+ this._updateDisablement({ ...option, fields });
53959
+ }
53960
+ /**
53961
+ * 物料消耗表 更新固定几个字段是否禁用
53962
+ * @param rowPath $.f_sub[n] n 必须为数字
53963
+ */
53964
+ static updateFixedFieldsDisablement(option) {
53965
+ const fields = ["product_id_", "material_no_", "routing_operation_id_"];
53966
+ this._updateDisablement({ ...option, fields });
53960
53967
  }
53961
53968
  /**
53962
53969
  * 设置行数据的编辑状态
@@ -53972,7 +53979,7 @@ class MCDataUtil {
53972
53979
  const rows = dataManager.getRawData()[subFieldKey] ?? [];
53973
53980
  rows[rowIndex] = row;
53974
53981
  dataManager.set(subFieldKey, rows);
53975
- MCDataUtil.updateOtherFieldsDisabled({
53982
+ MCDataUtil.updateFixedFieldsDisablement({
53976
53983
  dataManager,
53977
53984
  rowPath: `$.${subFieldKey}[${rowIndex}]`,
53978
53985
  disabled: isConfirmed
@@ -54132,19 +54139,16 @@ class MaterialConsumeTableController {
54132
54139
  }
54133
54140
  }
54134
54141
  /**
54135
- * 根据数据计算需要禁用的字段
54136
- * @param row
54137
- * @return {*}
54142
+ * 获取是否是 物料查看
54143
+ * @param product_id_
54144
+ * @returns
54138
54145
  */
54139
- calcDisabledFields(row) {
54140
- const disabledKeys = ["qty_consumed_", "qty_required_"];
54141
- if (row.product_id_) {
54142
- const util = this.bomEntriesValidator.findUtilByProductId(row.product_id_);
54143
- if (util?.bomEntry.type_ === "view") {
54144
- disabledKeys.push("material_no_", "qty_");
54145
- }
54146
+ getMaterialTypeIsView(product_id_) {
54147
+ if (product_id_) {
54148
+ const util = this.bomEntriesValidator.findUtilByProductId(product_id_);
54149
+ return util?.bomEntry.type_ === "view";
54146
54150
  }
54147
- return disabledKeys;
54151
+ return false;
54148
54152
  }
54149
54153
  /**
54150
54154
  * 获取bom内主物料,替换物料查询的算子
@@ -54422,7 +54426,8 @@ class MaterialConsumeTableController {
54422
54426
  if (["product_id_", "material_no_"].includes(fieldKey)) {
54423
54427
  const rowPath = `${parentFieldPath}[${dataIndex}]`;
54424
54428
  if (fieldKey === "product_id_") {
54425
- const versionId = changedData[`${rowPath}.product_id_`]?.split(":").pop();
54429
+ const product_id_ = changedData[`${rowPath}.product_id_`];
54430
+ const versionId = product_id_?.split(":").pop();
54426
54431
  if (versionId) {
54427
54432
  getSubFieldConfig(doc.paramsConfig).set(`${rowPath}.material_no_`, {
54428
54433
  "product_id_.versionIn": [versionId]
@@ -54433,6 +54438,8 @@ class MaterialConsumeTableController {
54433
54438
  [`${rowPath}.material_no__lb_`]: void 0,
54434
54439
  [`${rowPath}.qty_`]: void 0
54435
54440
  });
54441
+ const disabled = this.getMaterialTypeIsView(product_id_);
54442
+ MCDataUtil.updateViewFieldsDisablement({ dataManager: doc.dataManager, rowPath, disabled });
54436
54443
  } else if (fieldKey === "material_no_") {
54437
54444
  doc.dataManager.setMultiple({
54438
54445
  [`${rowPath}.product_id_`]: selectedOption.product_id_
@@ -54446,7 +54453,6 @@ class MaterialConsumeTableController {
54446
54453
  return data;
54447
54454
  }, {});
54448
54455
  doc.dataManager.setMultiple(wordValue);
54449
- MCDataUtil.disableQtyFields(doc.dataManager, rowPath);
54450
54456
  }
54451
54457
  }
54452
54458
  }
@@ -103389,6 +103395,20 @@ function useDependency(doc, widget, ctx) {
103389
103395
  initDependency
103390
103396
  };
103391
103397
  }
103398
+ const syncMaterialConsumeTableBomInfo = async (templateId, docModel) => {
103399
+ const formTmplBomList = await api.apaas.onlineFormTmpl.getGetBomByFormTmplId({ id: templateId });
103400
+ if (formTmplBomList?.length) {
103401
+ if (docModel.document.config) {
103402
+ docModel.document.config.formTmplBomList = formTmplBomList;
103403
+ }
103404
+ docModel.document.children[0]?.children.flatMap((el) => el.regions).filter((r) => r?.type === "material-consume-table").forEach((r) => {
103405
+ const { valuePath } = r;
103406
+ const matchedBom = formTmplBomList.find((bom) => bom.table_key_ === valuePath);
103407
+ if (!matchedBom) return;
103408
+ r.widgetMeta.props = matchedBom;
103409
+ });
103410
+ }
103411
+ };
103392
103412
  async function runDocumentPostLoadEnrichFlush(doc) {
103393
103413
  const instances = doc.model?.getWidgetInstances() ?? [];
103394
103414
  if (!instances.length) return;
@@ -103473,18 +103493,7 @@ async function initializeDocumentEngine(props, payload, result) {
103473
103493
  const linkFieldKey = checkTableRegions[0]?.linkFieldKey;
103474
103494
  const docModel = ModelConverter.toModel(runtimeJsonForModel);
103475
103495
  const templateId = result.tid.split(":")[1];
103476
- const formTmplBomList = await api.apaas.onlineFormTmpl.getGetBomByFormTmplId({ id: templateId });
103477
- if (formTmplBomList?.length) {
103478
- if (docModel.document.config) {
103479
- docModel.document.config.formTmplBomList = formTmplBomList;
103480
- }
103481
- docModel.document.children[0]?.children.flatMap((el) => el.regions).filter((r) => r?.type === "material-consume-table").forEach((r) => {
103482
- const { valuePath } = r;
103483
- const matchedBom = formTmplBomList.find((bom) => bom.table_key_ === valuePath);
103484
- if (!matchedBom) return;
103485
- r.widgetMeta.props = matchedBom;
103486
- });
103487
- }
103496
+ await syncMaterialConsumeTableBomInfo(templateId, docModel);
103488
103497
  const instances = docModel.getWidgetInstances();
103489
103498
  if (fillModeType !== DocModeTypeConst.Edit) {
103490
103499
  instances.forEach((instance2) => {
@@ -103575,7 +103584,7 @@ async function initializeDocumentEngine(props, payload, result) {
103575
103584
  });
103576
103585
  rows.forEach((row, rowIndex) => {
103577
103586
  if (row.is_confirmed_) {
103578
- MCDataUtil.updateOtherFieldsDisabled({
103587
+ MCDataUtil.updateFixedFieldsDisablement({
103579
103588
  dataManager: doc.dataManager,
103580
103589
  rowPath: `$.${subFieldKey}[${rowIndex}]`,
103581
103590
  disabled: true
@@ -109538,6 +109547,13 @@ const _sfc_main$2w = /* @__PURE__ */ defineComponent({
109538
109547
  index: yDataIndex ?? dataIndex ?? 0
109539
109548
  };
109540
109549
  };
109550
+ const getTableRows = (subFieldKey, visible) => {
109551
+ const rows = docInst.value.dataManager.getRawData()[subFieldKey] ?? [];
109552
+ if (visible) {
109553
+ return rows.filter((row) => !row.deleted_);
109554
+ }
109555
+ return rows;
109556
+ };
109541
109557
  const readonly2 = computed(() => {
109542
109558
  const state = resolveWidgetState({
109543
109559
  doc: props.doc,
@@ -109551,9 +109567,9 @@ const _sfc_main$2w = /* @__PURE__ */ defineComponent({
109551
109567
  });
109552
109568
  const computedInfo = computed(() => {
109553
109569
  const { index: rowIndex, subFieldKey } = getCtx();
109554
- const tableData = docInst.value.dataManager.getRawData()[subFieldKey] ?? [];
109555
- const isDeleteBtnVisible = tableData.length > 1;
109556
- const isRowConfirmed = !!tableData[rowIndex]?.is_confirmed_;
109570
+ const visibleRows = getTableRows(subFieldKey, true);
109571
+ const isDeleteBtnVisible = visibleRows.length > 1;
109572
+ const isRowConfirmed = !!visibleRows[rowIndex]?.is_confirmed_;
109557
109573
  return {
109558
109574
  isDeleteBtnVisible,
109559
109575
  isRowConfirmed
@@ -109575,23 +109591,23 @@ const _sfc_main$2w = /* @__PURE__ */ defineComponent({
109575
109591
  if (!subFieldKey) return;
109576
109592
  const subModelKey = mainFields.find((f) => f.key === subFieldKey)?.bindInfo;
109577
109593
  const { dataManager } = docInst.value;
109578
- const tableData = dataManager.getRawData()[subFieldKey] ?? [];
109594
+ const allRows = getTableRows(subFieldKey);
109579
109595
  const { tableName } = props.cell.subRenderer;
109580
- let row = tableData[rowIndex];
109581
- const insertEmptyRow = (row2, rowIndex2, cb) => {
109582
- if (!row2) {
109583
- row2 = {};
109584
- tableData[rowIndex2] = row2;
109585
- dataManager.set(subFieldKey, tableData);
109596
+ const row = allRows[rowIndex];
109597
+ const checkTargetRow = (_row, cb) => {
109598
+ if (!_row) {
109599
+ _row = {};
109600
+ allRows.splice(rowIndex, 0, _row);
109601
+ dataManager.set(subFieldKey, allRows);
109586
109602
  }
109587
109603
  setTimeout(cb);
109588
109604
  };
109589
109605
  if (val === "confirm") {
109590
- insertEmptyRow(row, rowIndex, () => {
109606
+ checkTargetRow(row, () => {
109591
109607
  tableController.confirm({ row, rowIndex, dataManager, subFieldKey }, subModelKey);
109592
109608
  });
109593
109609
  } else if (val === "scan") {
109594
- insertEmptyRow(row, rowIndex, () => {
109610
+ checkTargetRow(row, () => {
109595
109611
  tableController.openScanModal(tableName, { dataManager, subFieldKey }, subModelKey);
109596
109612
  });
109597
109613
  } else if (val === "edit") {
@@ -109605,8 +109621,8 @@ const _sfc_main$2w = /* @__PURE__ */ defineComponent({
109605
109621
  const getIsAddable = () => {
109606
109622
  if (isMaterialConsumeTable.value) {
109607
109623
  const { subFieldKey } = getCtx();
109608
- const tableData = docInst.value.dataManager.getRawData()[subFieldKey] ?? [];
109609
- const isAllConfirmed = tableData.length && tableData.every((row) => row.is_confirmed_);
109624
+ const visibleRows = getTableRows(subFieldKey, true);
109625
+ const isAllConfirmed = visibleRows.length && visibleRows.every((row) => row.is_confirmed_);
109610
109626
  if (!isAllConfirmed) {
109611
109627
  GctMessage.error("同时只能有一条数据开启编辑状态");
109612
109628
  }
@@ -109802,7 +109818,7 @@ const _sfc_main$2w = /* @__PURE__ */ defineComponent({
109802
109818
  };
109803
109819
  }
109804
109820
  });
109805
- const SubTableAction = /* @__PURE__ */ _export_sfc(_sfc_main$2w, [["__scopeId", "data-v-8fbc11fb"]]);
109821
+ const SubTableAction = /* @__PURE__ */ _export_sfc(_sfc_main$2w, [["__scopeId", "data-v-9ca63e84"]]);
109806
109822
  const _sfc_main$2v = /* @__PURE__ */ defineComponent({
109807
109823
  __name: "index",
109808
109824
  props: {
@@ -110382,6 +110398,14 @@ function validateDocDesigner(doc) {
110382
110398
  source: "doc"
110383
110399
  });
110384
110400
  }
110401
+ const materialConsumeTableRegions = children.filter((w2) => w2.name === "w:tbl" && w2.hasMaterialConsumeTable).flatMap((w2) => w2.materialConsumeTable);
110402
+ if (materialConsumeTableRegions.some((r) => !r.widgetMeta.props.barcode_parsing_rules_id_)) {
110403
+ errors.push({
110404
+ code: "barcode-parsing-rules-required",
110405
+ message: "请给物料消耗表设置条码解析规则",
110406
+ source: "doc"
110407
+ });
110408
+ }
110385
110409
  return createDesignerValidationResult(errors);
110386
110410
  }
110387
110411
  function validateDesigner(doc) {
@@ -110484,9 +110508,10 @@ function useDocOperations(docRef) {
110484
110508
  dirty: changedScopes.length > 0
110485
110509
  };
110486
110510
  }
110487
- function markAsSaved() {
110511
+ async function markAsSaved() {
110488
110512
  const doc = getDoc();
110489
110513
  if (!doc) return;
110514
+ await syncMaterialConsumeTableBomInfo(doc.docRuntimeMeta.id, doc.model);
110490
110515
  doc.docRuntimeMeta.handleInfo.initDocModelJson = JSON.stringify(exportModel());
110491
110516
  doc.docRuntimeMeta.handleInfo.initRawDataSnapshot = cloneDeep(doc.dataManager.getRawData());
110492
110517
  }
@@ -42,16 +42,26 @@ export declare class MCDataUtil {
42
42
  /** 设置的值(不给则true) */
43
43
  disabled?: boolean;
44
44
  }): void;
45
+ private static _updateDisablement;
45
46
  /**
46
- * 物料消耗表 需求数量、已消耗数量 不可修改
47
+ * 物料消耗表[需求数量、已消耗数量]一直禁用
47
48
  * @param rowPath $.f_sub[n] n 必须为数字
48
49
  */
49
50
  static disableQtyFields(dataManager: DataManager, rowPath: string): void;
50
51
  /**
51
- * 物料消耗表 更新部分字段是否禁用
52
+ * 物料消耗表 物料类型是否是[查看物料]时需要更新[物料批号、数量]字段是否禁用
52
53
  * @param rowPath $.f_sub[n] n 必须为数字
53
54
  */
54
- static updateOtherFieldsDisabled(option: {
55
+ static updateViewFieldsDisablement(option: {
56
+ dataManager: DataManager;
57
+ rowPath: string;
58
+ disabled: boolean;
59
+ }): void;
60
+ /**
61
+ * 物料消耗表 更新固定几个字段是否禁用
62
+ * @param rowPath $.f_sub[n] n 必须为数字
63
+ */
64
+ static updateFixedFieldsDisablement(option: {
55
65
  dataManager: DataManager;
56
66
  rowPath: string;
57
67
  disabled: boolean;
@@ -139,11 +149,11 @@ export declare class MaterialConsumeTableController {
139
149
  */
140
150
  calcFormState(): IMaterialConsumeData[] | undefined;
141
151
  /**
142
- * 根据数据计算需要禁用的字段
143
- * @param row
144
- * @return {*}
152
+ * 获取是否是 物料查看
153
+ * @param product_id_
154
+ * @returns
145
155
  */
146
- calcDisabledFields(row: IMaterialConsumeData): (keyof IMaterialConsumeData)[];
156
+ getMaterialTypeIsView(product_id_?: string): boolean;
147
157
  /**
148
158
  * 获取bom内主物料,替换物料查询的算子
149
159
  * @return {*}
@@ -0,0 +1,2 @@
1
+ import { DocModel } from '../../../../../core/model';
2
+ export declare const syncMaterialConsumeTableBomInfo: (templateId: string, docModel: DocModel) => Promise<void>;
package/dist/word.css CHANGED
@@ -8680,20 +8680,20 @@ textarea[data-v-57fe54a3]::placeholder {
8680
8680
  .table-action .row-headers .row-header:last-child .row-add-btn[data-v-c40eef9f] .gct-icon.bottom {
8681
8681
  transform: translateY(-100%);
8682
8682
  }
8683
- .sub-table-action-container[data-v-8fbc11fb] {
8683
+ .sub-table-action-container[data-v-9ca63e84] {
8684
8684
  position: absolute;
8685
8685
  z-index: 999;
8686
8686
  }
8687
- .sub-table-action-bar[data-v-8fbc11fb],
8688
- .sub-table-action-popper[data-v-8fbc11fb] {
8687
+ .sub-table-action-bar[data-v-9ca63e84],
8688
+ .sub-table-action-popper[data-v-9ca63e84] {
8689
8689
  pointer-events: auto;
8690
8690
  user-select: none;
8691
8691
  }
8692
- .sub-table-action-bar[data-v-8fbc11fb] {
8692
+ .sub-table-action-bar[data-v-9ca63e84] {
8693
8693
  display: flex;
8694
8694
  }
8695
- .sub-table-action-bar .more-btn[data-v-8fbc11fb],
8696
- .sub-table-action-bar .confirm-btn[data-v-8fbc11fb] {
8695
+ .sub-table-action-bar .more-btn[data-v-9ca63e84],
8696
+ .sub-table-action-bar .confirm-btn[data-v-9ca63e84] {
8697
8697
  display: flex;
8698
8698
  justify-content: center;
8699
8699
  align-items: center;
@@ -8702,44 +8702,44 @@ textarea[data-v-57fe54a3]::placeholder {
8702
8702
  cursor: pointer;
8703
8703
  box-sizing: border-box;
8704
8704
  }
8705
- .sub-table-action-bar .more-btn[data-v-8fbc11fb] {
8705
+ .sub-table-action-bar .more-btn[data-v-9ca63e84] {
8706
8706
  width: 10px;
8707
8707
  background: #026ac8;
8708
8708
  border-radius: 0 4px 4px 0;
8709
8709
  }
8710
- .sub-table-action-bar .confirm-btn[data-v-8fbc11fb] {
8710
+ .sub-table-action-bar .confirm-btn[data-v-9ca63e84] {
8711
8711
  margin-left: 4px;
8712
8712
  border-radius: 4px;
8713
8713
  border: 1px solid #4ec262;
8714
8714
  }
8715
- .sub-table-action-popper[data-v-8fbc11fb] {
8715
+ .sub-table-action-popper[data-v-9ca63e84] {
8716
8716
  padding: 2px 8px;
8717
8717
  }
8718
- .sub-table-action-popper .action-menu[data-v-8fbc11fb] {
8718
+ .sub-table-action-popper .action-menu[data-v-9ca63e84] {
8719
8719
  padding: 4px 0;
8720
8720
  width: 220px;
8721
8721
  user-select: none;
8722
8722
  }
8723
- .sub-table-action-popper .action-menu + .action-menu[data-v-8fbc11fb] {
8723
+ .sub-table-action-popper .action-menu + .action-menu[data-v-9ca63e84] {
8724
8724
  margin-top: 4px;
8725
8725
  padding-top: 4px;
8726
8726
  border-top: 1px solid #efefef;
8727
8727
  }
8728
- .sub-table-action-popper .action-menu .menu-title[data-v-8fbc11fb] {
8728
+ .sub-table-action-popper .action-menu .menu-title[data-v-9ca63e84] {
8729
8729
  color: #bcbcbc;
8730
8730
  margin: 4px 0;
8731
8731
  }
8732
- .sub-table-action-popper .action-menu .menu-item[data-v-8fbc11fb] {
8732
+ .sub-table-action-popper .action-menu .menu-item[data-v-9ca63e84] {
8733
8733
  display: flex;
8734
8734
  align-items: center;
8735
8735
  padding: 8px 10px;
8736
8736
  border-radius: 4px;
8737
8737
  }
8738
- .sub-table-action-popper .action-menu .menu-item[data-v-8fbc11fb]:hover {
8738
+ .sub-table-action-popper .action-menu .menu-item[data-v-9ca63e84]:hover {
8739
8739
  cursor: pointer;
8740
8740
  background-color: #f2f5f8;
8741
8741
  }
8742
- .sub-table-action-popper .action-menu .menu-item .item-icon[data-v-8fbc11fb] {
8742
+ .sub-table-action-popper .action-menu .menu-item .item-icon[data-v-9ca63e84] {
8743
8743
  display: flex;
8744
8744
  align-items: center;
8745
8745
  justify-content: start;
@@ -8747,14 +8747,14 @@ textarea[data-v-57fe54a3]::placeholder {
8747
8747
  width: 20px;
8748
8748
  height: 20px;
8749
8749
  }
8750
- .sub-table-action-popper .action-menu .menu-item .item-icon.scale-large[data-v-8fbc11fb] {
8750
+ .sub-table-action-popper .action-menu .menu-item .item-icon.scale-large[data-v-9ca63e84] {
8751
8751
  transform: scale(1.5);
8752
8752
  }
8753
- .sub-table-action-popper .action-menu .menu-item .item-label[data-v-8fbc11fb] {
8753
+ .sub-table-action-popper .action-menu .menu-item .item-label[data-v-9ca63e84] {
8754
8754
  flex-grow: 1;
8755
8755
  margin-left: 8px;
8756
8756
  }
8757
- .sub-table-action-popper .action-menu .menu-item .item-label.flex-between-center[data-v-8fbc11fb] {
8757
+ .sub-table-action-popper .action-menu .menu-item .item-label.flex-between-center[data-v-9ca63e84] {
8758
8758
  display: flex;
8759
8759
  justify-content: space-between;
8760
8760
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",