doway-coms 2.3.9 → 2.4.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "doway-coms",
3
- "version": "2.3.9",
3
+ "version": "2.4.0",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
@@ -1562,6 +1562,19 @@ export default {
1562
1562
  $table.sort(column.field, menu.code)
1563
1563
  }
1564
1564
  }
1565
+ function pasteChildren (row, childrenField, parentField) {
1566
+ if (row[childrenField] && row[childrenField].length > 0) {
1567
+ row[childrenField].forEach(item => {
1568
+ let tmpRow = JSON.parse(JSON.stringify(item))
1569
+ delete tmpRow[childrenField]
1570
+ tmpRow[parentField] = row.id
1571
+ tmpRow.id=vm.$store.getters.newId() + ''
1572
+ $table.insertAt(tmpRow, -1).then(({row})=>{
1573
+ pasteChildren(row, childrenField, parentField)
1574
+ })
1575
+ })
1576
+ }
1577
+ }
1565
1578
  switch (menu.code) {
1566
1579
  case 'copy':
1567
1580
  // 示例
@@ -1582,8 +1595,25 @@ export default {
1582
1595
  }
1583
1596
  break
1584
1597
  case 'paste':
1585
- if(this.copySaveRow&&this.gridEdit){
1586
- $table.insertAt(this.copySaveRow,-1)
1598
+ if (this.copySaveRow && this.gridEdit) {
1599
+
1600
+ if (this.treeConfig) {
1601
+ let parentField = this.treeConfig.parentField ? this.treeConfig.parentField : 'parentId'
1602
+ let childrenField = this.treeConfig.childrenField ? this.treeConfig.childrenField : 'children'
1603
+ //树情况下 分批插入
1604
+ let tmpRow = JSON.parse(JSON.stringify(this.copySaveRow))
1605
+ delete tmpRow[childrenField]
1606
+ $table.insertAt(tmpRow, -1)
1607
+ .then(({ row }) => {
1608
+ pasteChildren(this.copySaveRow, childrenField,parentField)
1609
+ this.$emit('paste', row)
1610
+ })
1611
+ } else {
1612
+ $table.insertAt(this.copySaveRow, -1)
1613
+ .then(({ row }) => {
1614
+ this.$emit('paste', row)
1615
+ })
1616
+ }
1587
1617
  }
1588
1618
  break
1589
1619
  case 'clearFilter':