cloud-web-corejs 1.0.54-dev.387 → 1.0.54-dev.388

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.387",
4
+ "version": "1.0.54-dev.388",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -208,14 +208,20 @@ tmixins = {
208
208
  return false;
209
209
  }
210
210
 
211
- this.createImportTimer();
211
+ /* this.createImportTimer();
212
212
  this.showImportDialog = false;
213
213
  if (!option.onConfirm) {
214
214
  this.showImportDialog2 = true;
215
- }
216
- this.$nextTick(() => {
217
- try {
218
- this.readExcel(this.fileRaw, function (resultData) {
215
+ } */
216
+ // this.$nextTick(() => {
217
+ try {
218
+ this.readExcel(this.fileRaw, function (resultData) {
219
+ that.createImportTimer();
220
+ that.showImportDialog = false;
221
+ if (!option.onConfirm) {
222
+ that.showImportDialog2 = true;
223
+ }
224
+ that.$nextTick(() => {
219
225
  if (option.onConfirm) {
220
226
  option.onConfirm(resultData.data, that.fileRaw);
221
227
  } else {
@@ -228,11 +234,12 @@ tmixins = {
228
234
  });
229
235
  }
230
236
  });
231
- } catch (et) {
232
- that.clearImportTimer();
233
- console.error(et);
234
- }
235
- });
237
+ });
238
+ } catch (et) {
239
+ that.clearImportTimer();
240
+ console.error(et);
241
+ }
242
+ // });
236
243
  },
237
244
  handleBeforeImport(file, resultData, callback) {
238
245
  let importOption = this.option.importOption;
@@ -365,6 +372,11 @@ tmixins = {
365
372
  let that = this;
366
373
  let option = this.option;
367
374
 
375
+ if (option.importOption.multipleSheet) {
376
+ this.readExcel2(file, callback);
377
+ return;
378
+ }
379
+
368
380
  const fileReader = new FileReader();
369
381
  fileReader.onload = async (ev) => {
370
382
  var resultData;
@@ -1447,7 +1459,7 @@ tmixins = {
1447
1459
  type: "binary",
1448
1460
  });
1449
1461
 
1450
- let sheetDatas = []
1462
+ let sheetDatas = [];
1451
1463
  for (let pi = 0; pi < workbook.SheetNames.length; pi++) {
1452
1464
  let sheetName = workbook.SheetNames[pi];
1453
1465
  let sheet = workbook.Sheets[sheetName];
@@ -1522,7 +1534,7 @@ tmixins = {
1522
1534
  "components.excelImport.warmMsg2"
1523
1535
  )
1524
1536
  );
1525
- that.handleClose2();
1537
+ // that.handleClose2();
1526
1538
  return false;
1527
1539
  }
1528
1540
 
@@ -1541,7 +1553,7 @@ tmixins = {
1541
1553
  "components.excelImport.warmMsg2"
1542
1554
  )
1543
1555
  );
1544
- that.handleClose2();
1556
+ // that.handleClose2();
1545
1557
  return false;
1546
1558
  }
1547
1559
  let t = title.substr(-1);
@@ -1561,19 +1573,15 @@ tmixins = {
1561
1573
  uniqueKeys.push(field);
1562
1574
  isSheetUnique = true;
1563
1575
  }
1564
- if(!uniqueKeys.length){
1565
- that.clearImportTimer();
1566
- that.$baseAlert(
1567
- `[${sheetName}]`+
1568
- that.$t2(
1569
- "缺失单据唯一标识"
1570
- )
1571
- );
1572
- that.handleClose2();
1573
- return false;
1576
+ if (!uniqueKeys.length) {
1577
+ // that.clearImportTimer();
1578
+ that.$baseAlert(
1579
+ `[${sheetName}]` + that.$t1("缺失单据唯一标识***")
1580
+ );
1581
+ // that.handleClose2();
1582
+ return false;
1574
1583
  }
1575
1584
 
1576
-
1577
1585
  let otherConfig = {};
1578
1586
  let isFile = false;
1579
1587
  if (field.startsWith("attachments_")) {
@@ -1594,14 +1602,14 @@ tmixins = {
1594
1602
  isUnique: isUnique,
1595
1603
  isFile,
1596
1604
  otherConfig,
1597
- isSheetUnique
1605
+ isSheetUnique,
1598
1606
  };
1599
1607
  cols.push(col);
1600
1608
  }
1601
1609
  }
1602
1610
 
1603
1611
  var oriCols = JSON.parse(JSON.stringify(cols)); //列信息
1604
- if (uniqueKeys.length) {
1612
+ /* if (uniqueKeys.length) {
1605
1613
  //分组唯一字段为空时,全部不发包。
1606
1614
  for (let i = 0; i < oriCols.length; i++) {
1607
1615
  let oriCol = oriCols[i];
@@ -1610,26 +1618,21 @@ tmixins = {
1610
1618
  let data = excelRows[j];
1611
1619
  let value = data[oriCol.field];
1612
1620
  if (value == null || value == "") {
1613
- that.clearImportTimer();
1614
- that.$baseAlert(
1615
- `[${sheetName}]`+
1616
- that.$t2(
1617
- "第" + (j + 4) + "行[" + oriCol.title + "]不能为空;",
1618
- "components.excelImport.warmMsg3",
1619
- {
1620
- lineNo: j + 4,
1621
- title: oriCol.title,
1622
- }
1623
- )
1624
- );
1625
- that.handleClose2();
1621
+ that.errorHandle(`[${sheetName}]`+
1622
+ that.$t2(
1623
+ "第" + (j + 4) + "行[" + oriCol.title + "]不能为空;",
1624
+ "components.excelImport.warmMsg3",
1625
+ {
1626
+ lineNo: j + 4,
1627
+ title: oriCol.title,
1628
+ }
1629
+ ));
1626
1630
  return false;
1627
1631
  }
1628
1632
  }
1629
1633
  }
1630
1634
  }
1631
- }
1632
-
1635
+ } */
1633
1636
  // this.oriCols = oriCols;
1634
1637
 
1635
1638
  let resultData1 = {
@@ -1639,37 +1642,54 @@ tmixins = {
1639
1642
  fields: fields,
1640
1643
  uniqueFields: uniqueFields,
1641
1644
  oriCols: oriCols,
1642
- uniqueKeys
1645
+ uniqueKeys,
1643
1646
  };
1644
1647
  sheetDatas.push(resultData1);
1645
1648
  }
1646
- // var sheet = workbook.Sheets[workbook.SheetNames[0]];
1647
- let newDatas = [];
1648
- resultData = that.$baseLodash.cloneDeep(sheetDatas[0])
1649
- resultData.sheetDatas = sheetDatas;
1650
1649
 
1650
+ //校验必填
1651
+ if (!that.checkAllSheetData(sheetDatas)) {
1652
+ return false;
1653
+ }
1654
+
1655
+ //合并多sheet数据
1656
+ let newDatas = [];
1657
+ resultData = that.$baseLodash.cloneDeep(sheetDatas[0]);
1651
1658
  let uniqueKey = resultData.uniqueKeys[0];
1652
- for(let i = 0; i < resultData.data.length; i++){
1659
+ let data2 = [];
1660
+ for (let i = 0; i < resultData.data.length; i++) {
1653
1661
  let item = resultData.data[i];
1662
+ let sheetName = resultData[sheetName];
1654
1663
  let uniqueValue = item[uniqueKey];
1655
1664
 
1656
- if(uniqueValue){
1657
- let index = newDatas.findIndex((item) => item[uniqueKey] == uniqueValue);
1658
- if(index == -1){
1659
- newDatas.push(item);
1660
- }
1661
- for(let j = 1; j < sheetDatass.length; j++){
1662
- let sheetData = sheetDatass[j];
1663
- let sheetDataIndex = sheetData.data.findIndex((item) => item[uniqueKey] == uniqueValue);
1664
- if(sheetDataIndex != -1){
1665
- sheetData.data.splice(sheetDataIndex, 1);
1665
+ if (!that.isNull(uniqueValue)) {
1666
+ let newItem = { ...item };
1667
+ let allItems = [];
1668
+ for (let j = 1; j < sheetDatas.length; j++) {
1669
+ let sheetData = sheetDatas[j];
1670
+ let fDatas = [];
1671
+ for (let k = 0; k < sheetData.data.length; k++) {
1672
+ let sheetItem = sheetData.data[k];
1673
+ if (that.isNull(sheetItem[uniqueKey])) {
1674
+ that.handleCellNotNull(k, sheetData);
1675
+ return;
1676
+ }
1677
+ if (sheetItem[uniqueKey] == uniqueValue) {
1678
+ fDatas.push(sheetItem);
1679
+ }
1666
1680
  }
1681
+ allItems.push(fDatas);
1667
1682
  }
1668
-
1669
-
1683
+ newItem.sheetItems = allItems;
1684
+ data2.push(newItem);
1685
+ } else {
1686
+ that.handleCellNotNull(i, resultData);
1687
+ return false;
1670
1688
  }
1671
1689
  }
1672
1690
 
1691
+ resultData.sheetDatas = sheetDatas;
1692
+ resultData.data = data2;
1673
1693
  this.oriCols = resultData.oriCols;
1674
1694
  this.resultData = resultData;
1675
1695
  callback(resultData);
@@ -1681,6 +1701,67 @@ tmixins = {
1681
1701
  };
1682
1702
  fileReader.readAsBinaryString(file);
1683
1703
  },
1704
+ isNull(val) {
1705
+ if (val == null || val == "" || val == undefined) {
1706
+ return true;
1707
+ }
1708
+ },
1709
+ checkAllSheetData(sheetItems){
1710
+ let that = this;
1711
+ for(let sheetItem of sheetItems){
1712
+ let oriCols = sheetItem.oriCols;
1713
+ let uniqueKeys = sheetItem.uniqueKeys;
1714
+ let excelRows = sheetItem.data;
1715
+ let sheetName = sheetItem.sheetName;
1716
+
1717
+ for (let i = 0; i < oriCols.length; i++) {
1718
+ let oriCol = oriCols[i];
1719
+ if (oriCol.isNeed || uniqueKeys.includes(oriCol.field)) {
1720
+ for (let j = 0; j < excelRows.length; j++) {
1721
+ let data = excelRows[j];
1722
+ let value = data[oriCol.field];
1723
+ if (that.isNull(value)) {
1724
+ that.errorHandle(`[${sheetName}]`+
1725
+ that.$t2(
1726
+ "第" + (j + 4) + "行[" + oriCol.title + "]不能为空;",
1727
+ "components.excelImport.warmMsg3",
1728
+ {
1729
+ lineNo: j + 4,
1730
+ title: oriCol.title,
1731
+ }
1732
+ ));
1733
+ return false;
1734
+ }
1735
+ }
1736
+ }
1737
+ }
1738
+
1739
+ }
1740
+ return true;
1741
+ },
1742
+
1743
+
1744
+ handleCellNotNull(i, sheetData) {
1745
+ let that = this;
1746
+ let uniqueKey = sheetData.uniqueKeys[0];
1747
+ let oriCol = sheetData.oriCols.find((item) => item.field == uniqueKey);
1748
+ that.errorHandle(
1749
+ `[${sheetData.sheetName}]` +
1750
+ that.$t2(
1751
+ "第" + (i + 4) + "行[" + oriCol.title + "]不能为空;",
1752
+ "components.excelImport.warmMsg3",
1753
+ {
1754
+ lineNo: i + 4,
1755
+ title: oriCol.title,
1756
+ }
1757
+ )
1758
+ );
1759
+ },
1760
+ errorHandle(errorText) {
1761
+ this.clearImportTimer();
1762
+ this.$baseAlert(errorText);
1763
+ // this.handleClose2();
1764
+ },
1684
1765
  /***sheet2 */
1685
1766
  },
1686
1767
  };
@@ -7,7 +7,10 @@
7
7
  <el-input v-model="optionModel.importEntity"></el-input>
8
8
  </el-form-item>
9
9
  <el-form-item label="文件大小限制(M)">
10
- <base-input-number v-model="optionModel.importFileLimitSize" :max="200"></base-input-number>
10
+ <base-input-number
11
+ v-model="optionModel.importFileLimitSize"
12
+ :max="200"
13
+ ></base-input-number>
11
14
  </el-form-item>
12
15
  <el-form-item label="导入模板文件编码">
13
16
  <el-input
@@ -15,41 +18,60 @@
15
18
  max="200"
16
19
  :value="optionModel.importAttachCode"
17
20
  clearable
18
- @clear="optionModel.importAttachCode=null;optionModel.importAttachName=null;"
21
+ @clear="
22
+ optionModel.importAttachCode = null;
23
+ optionModel.importAttachName = null;
24
+ "
19
25
  >
20
- <i slot="suffix" class="el-input__icon el-icon-search" @click="showBdAttachSettingDialog = true"></i>
26
+ <i
27
+ slot="suffix"
28
+ class="el-input__icon el-icon-search"
29
+ @click="showBdAttachSettingDialog = true"
30
+ ></i>
21
31
  </el-input>
22
32
  </el-form-item>
23
- <el-form-item label="导入模板文件名称">
24
- <span>{{optionModel.importAttachName}}</span>
25
- </el-form-item>
33
+ <el-form-item label="导入模板文件名称">
34
+ <span>{{ optionModel.importAttachName }}</span>
35
+ </el-form-item>
26
36
  <el-form-item label="关联表格唯一名称">
27
37
  <el-input v-model="optionModel.tableRef"></el-input>
28
38
  </el-form-item>
29
39
  <el-form-item label="执行后台脚本编码">
30
40
  <el-input v-model="optionModel.importScriptCode"></el-input>
31
41
  </el-form-item>
42
+ <el-form-item label="多sheet导入">
43
+ <el-switch v-model="optionModel.multipleSheet"></el-switch>
44
+ </el-form-item>
32
45
  <el-form-item label="批量导入">
33
46
  <el-switch v-model="optionModel.importMultiple"></el-switch>
34
47
  </el-form-item>
35
48
  <el-form-item label="批量导入大小">
36
- <base-input-number v-model="optionModel.importMultiSize" :max="200"></base-input-number>
49
+ <base-input-number
50
+ v-model="optionModel.importMultiSize"
51
+ :max="200"
52
+ ></base-input-number>
37
53
  </el-form-item>
38
54
 
39
55
  <el-form-item label="启用图片处理">
40
56
  <el-switch v-model="optionModel.enabledImportPreHandle"></el-switch>
41
57
  </el-form-item>
42
58
  <el-form-item label="导入前数据处理" label-width="150px">
43
- <a href="javascript:void(0);" class="a-link link-oneLind"
44
- @click="editEventHandler('onBeforeImport', onBeforeImportParams)">
59
+ <a
60
+ href="javascript:void(0);"
61
+ class="a-link link-oneLind"
62
+ @click="editEventHandler('onBeforeImport', onBeforeImportParams)"
63
+ >
45
64
  <span>{{ optionModel.onBeforeImport }}</span>
46
65
  <i class="el-icon-edit"></i>
47
66
  </a>
48
67
  </el-form-item>
49
68
 
50
69
  <el-form-item label="导入完成回调" label-width="150px">
51
- <a href="javascript:void(0);" class="a-link link-oneLind"
52
- @click="editEventHandler('onSuccessImport', onSuccessImportParams)">
70
+ <a
71
+ href="javascript:void(0);"
72
+ class="a-link link-oneLind"
73
+ @click="editEventHandler('onSuccessImport', onSuccessImportParams)"
74
+ >
53
75
  <span>{{ optionModel.onSuccessImport }}</span>
54
76
  <i class="el-icon-edit"></i>
55
77
  </a>
@@ -58,20 +80,23 @@
58
80
  <el-switch v-model="optionModel.hideCancelButton"></el-switch>
59
81
  </el-form-item>
60
82
 
61
- <bdAttachSettingDialog v-if="showBdAttachSettingDialog" :visiable.sync="showBdAttachSettingDialog" :multi="false"
62
- @confirm="confirmBdAttachSettingDialog"></bdAttachSettingDialog>
83
+ <bdAttachSettingDialog
84
+ v-if="showBdAttachSettingDialog"
85
+ :visiable.sync="showBdAttachSettingDialog"
86
+ :multi="false"
87
+ @confirm="confirmBdAttachSettingDialog"
88
+ ></bdAttachSettingDialog>
63
89
  </div>
64
90
  </template>
65
91
 
66
92
  <script>
67
93
  import i18n from "../../../../../../components/xform/utils/i18n";
68
- import eventMixin
69
- from "../../../../../../components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin";
94
+ import eventMixin from "../../../../../../components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin";
70
95
  import bdAttachSettingDialog from "../../../../../../views/bd/setting/bd_attach_setting/dialog.vue";
71
96
 
72
97
  export default {
73
98
  name: "import-button-editor",
74
- components: {bdAttachSettingDialog},
99
+ components: { bdAttachSettingDialog },
75
100
  mixins: [i18n, eventMixin],
76
101
  props: {
77
102
  designer: Object,
@@ -82,9 +107,9 @@ export default {
82
107
  return {
83
108
  eventParams: [],
84
109
  showBdAttachSettingDialog: false,
85
- onBeforeImportParams: ["dataId", "formCode", 'file', 'resultData', 'done'],
86
- onConfirmImportParams: ["dataId", "formCode", 'resultData', 'file', 'done'],
87
- onSuccessImportParams: ["dataId", "formCode", 'resultData', 'file']
110
+ onBeforeImportParams: ["dataId", "formCode", "file", "resultData", "done"],
111
+ onConfirmImportParams: ["dataId", "formCode", "resultData", "file", "done"],
112
+ onSuccessImportParams: ["dataId", "formCode", "resultData", "file"],
88
113
  };
89
114
  },
90
115
  methods: {
@@ -94,8 +119,8 @@ export default {
94
119
  this.optionModel.importAttachName = row.name;
95
120
  this.optionModel.importAttachCode = row.code;
96
121
  }
97
- }
98
- }
122
+ },
123
+ },
99
124
  };
100
125
  </script>
101
126