doway-coms 2.4.6 → 2.4.7

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.4.6",
3
+ "version": "2.4.7",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
@@ -2,7 +2,40 @@
2
2
  <div style="height:300px">
3
3
  <splitpanes class="default-theme">
4
4
  <pane>
5
- <a-tree :tree-data="fileGroupData" :selectedKeys="currentSelectKey" :replaceFields="{title:'name',key:'id'}" show-icon default-expand-all @select="handleFileGroupSelect">
5
+ <vxe-table
6
+ :size="'mini'"
7
+ :height="'100%'"
8
+ show-overflow
9
+ highlight-current-row
10
+ highlight-hover-row
11
+ ref="eisTreeView"
12
+ row-id="id"
13
+ row-key
14
+ @current-change="eisCurrentChange"
15
+ border="inner"
16
+ :show-header="false"
17
+ :data="fileGroupData"
18
+ :tree-config="{
19
+ transform: true,
20
+ line: true,
21
+ rowField: 'id',
22
+ parentField: 'parentId',
23
+ expandRowKeys:['sys_top_folder']
24
+ }"
25
+ >
26
+ <vxe-column title="菜单权限" tree-node>
27
+ <template #default="{ row }">
28
+ <span>
29
+ <a-icon type="folder-open" v-if="$refs.eisTreeView.isTreeExpandByRow(row)" />
30
+ <a-icon v-else type="folder" />
31
+ <span>{{ row.name }}</span>
32
+ <span @click="handleAddSubFolder(row)" v-if="edit===true">添加</span>
33
+ <span @click="handleEditSubFolder(row)" v-if="edit===true && row.id!=='sys_top_folder'">编辑</span>
34
+ </span>
35
+ </template>
36
+ </vxe-column>
37
+ </vxe-table>
38
+ <!-- <a-tree :tree-data="fileGroupData" :selectedKeys="currentSelectKey" :replaceFields="{title:'name',key:'id'}" show-icon default-expand-all @select="handleFileGroupSelect">
6
39
  <a-icon slot="fileGroup" type="folder" />
7
40
  <template #title="{ name,id }">
8
41
  <div>
@@ -11,7 +44,7 @@
11
44
  <span @click="handleEditSubFolder(id,name)" v-if="edit===true && id!=='sys_top_folder'">编辑</span>
12
45
  </div>
13
46
  </template>
14
- </a-tree>
47
+ </a-tree> -->
15
48
  </pane>
16
49
  <pane>
17
50
  <div class="card-view-items">
@@ -20,7 +53,8 @@
20
53
  <div @click="removeAttach(loopFileData)" v-if="edit===true">删除</div>
21
54
  <div @click="downloadAttach(loopFileData)" v-if="loopFileData.attachType==='file' && allowDownload===true">下载</div>
22
55
  </div>
23
- <div class="card-view-item" :style="{ width: itemWidth + 'px' }" v-if="edit===true">
56
+
57
+ <div class="card-view-item" :style="{ width: itemWidth + 'px' }" v-if="edit===true && currentSelectKey.length>0">
24
58
  <a-upload
25
59
  class="avatar-uploader"
26
60
  :headers="uploadHeaders"
@@ -96,7 +130,6 @@
96
130
 
97
131
  <script>
98
132
  import { notification, Upload,Tree,Icon,Popconfirm,Input } from "ant-design-vue";
99
- import { sysRowState } from "../../utils/enum";
100
133
  import { Checkbox, Modal } from "vxe-table";
101
134
  import { attachGetAttachUrlApi, attachSearchApi } from "../../utils/api";
102
135
  import XEUtils from 'xe-utils'
@@ -120,7 +153,7 @@ export default {
120
153
  showEditFolder:false,
121
154
  currentEditInfo:{},
122
155
  currentEditFolderValue:'',
123
- currentSelectKey:['1'],
156
+ currentSelectKey:[],
124
157
  fileGroupData:[],
125
158
  internalRows: [],
126
159
  itemWidth:200,
@@ -139,8 +172,7 @@ export default {
139
172
  if(this.currentSelectKey.length===0){
140
173
  return []
141
174
  }
142
- console.debug(this.internalRows)
143
- return this.internalRows.filter(p=>p.parentId==this.currentSelectKey[0] && p.sysRowState!==sysRowState.delete)
175
+ return this.internalRows.filter(p=>p.parentId==this.currentSelectKey[0] && p.sysRowState!=='delete')
144
176
  }
145
177
  },
146
178
  props: {
@@ -250,9 +282,9 @@ export default {
250
282
  buildTreeData(tempRows){
251
283
  this.internalRows =JSON.parse(JSON.stringify(tempRows))
252
284
  let tempTopFolder = {
253
- sysRowState: sysRowState.view,
285
+ sysRowState: 'view',
254
286
  parentId: null,
255
- sort:1,
287
+ sort:0,
256
288
  attachType:'folder',
257
289
  name:'文件',
258
290
  id:'sys_top_folder',
@@ -264,11 +296,15 @@ export default {
264
296
  }
265
297
  p.parentId = 'sys_top_folder'
266
298
  })
267
- // console.debug(this.internalRows)
268
299
 
269
300
  //
270
- let tempFoldRows = XEUtils.filter(this.internalRows,p=>p.attachType==='folder')
271
- this.fileGroupData = XEUtils.toArrayTree(tempFoldRows,{strict:true,sortKey:'sort'})
301
+ this.fileGroupData = XEUtils.orderBy(XEUtils.filter(this.internalRows,p=>p.attachType==='folder'),p=>p.sort)
302
+ console.debug('davistest',this.fileGroupData)
303
+ if(this.currentSelectKey.length===0){
304
+ this.$refs.eisTreeView.setCurrentRow(tempTopFolder)
305
+ this.currentSelectKey = [tempTopFolder.id]
306
+ }
307
+ // this.fileGroupData = XEUtils.toArrayTree(tempFoldRows,{strict:true,sortKey:'sort'})
272
308
 
273
309
  // // this.internalRows.push(tempTopFolder)
274
310
  // this.fileGroupData = [tempTopFolder]
@@ -277,48 +313,47 @@ export default {
277
313
 
278
314
  // this.fileData = XEUtils.filter(tempRows,p=>p.attachType==='file')
279
315
  },
280
- handleAddSubFolder(loopId){
316
+ handleAddSubFolder(rowInfo){
281
317
  //添加子项文件夹
282
- this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===loopId)
318
+ this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===rowInfo.id)
283
319
  this.currentEditInfo['operation'] = 'add'
284
320
  this.showEditFolder = true
285
321
  },
286
- handleEditSubFolder(loopId,loopName){
287
- this.currentEditFolderValue = loopName
322
+ handleEditSubFolder(rowInfo){
323
+ this.currentEditFolderValue = rowInfo.name
288
324
  //添加子项文件夹
289
- this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===loopId)
325
+ this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===rowInfo.id)
290
326
  this.currentEditInfo['operation'] = 'edit'
291
327
  this.showEditFolder = true
292
328
  },
329
+ eisCurrentChange(scope) {
330
+ this.currentSelectKey = [scope.row.id]
331
+
332
+ },
293
333
  confirmEditFolder(){
334
+
335
+ let tempRowInfo = this.$refs.eisTreeView.getRowById(this.currentEditInfo.id)
294
336
  if(this.currentEditInfo.operation==='add'){
295
- let tempNodeInfo = XEUtils.findTree(this.fileGroupData,p=>p.id===this.currentEditInfo.id)
296
337
  //新增文件夹
297
338
  let tempAddRowInfo = {
298
- sysRowState: sysRowState.add,
339
+ sysRowState: 'add',
299
340
  parentId: this.currentEditInfo.id,
300
- sort:tempNodeInfo.item.children?tempNodeInfo.item.children.length+1:1,
341
+ sort: tempRowInfo.children.length+1,
301
342
  attachType:'folder',
302
343
  children:[],
303
344
  name:this.currentEditFolderValue,
304
345
  id:this.$store.getters.newId() + "",
305
346
  }
306
347
  this.internalRows.push(tempAddRowInfo)
307
- if(tempNodeInfo.item.children){
308
- tempNodeInfo.item.children.push(tempAddRowInfo)
309
- }else{
310
- tempNodeInfo.item['children'] = [tempAddRowInfo]
311
- }
312
-
348
+ this.$refs.eisTreeView.insertAt(tempAddRowInfo,-1)
313
349
  }else{
314
- let tempRowInfo = XEUtils.find(this.internalRows,p=>p.id===this.currentEditInfo.id)
315
- if(tempRowInfo.sysRowState!==sysRowState.add){
316
- tempRowInfo.sysRowState = sysRowState.update
350
+ let tempInternalRowInfo = XEUtils.find(this.internalRows,p=>p.id===this.currentEditInfo.id)
351
+ if(tempInternalRowInfo.sysRowState!=='add'){
352
+ tempInternalRowInfo.sysRowState = 'update'
317
353
  }
318
- tempRowInfo.name = this.currentEditFolderValue
354
+ tempInternalRowInfo.name = this.currentEditFolderValue
319
355
  //修改树节点名称
320
- let tempNodeInfo = XEUtils.findTree(this.fileGroupData,p=>p.id===this.currentEditInfo.id)
321
- tempNodeInfo.item.name = tempRowInfo.name
356
+ tempRowInfo.name = tempInternalRowInfo.name
322
357
  }
323
358
  this.showEditFolder = false
324
359
  this.currentEditFolderValue =null
@@ -327,6 +362,17 @@ export default {
327
362
  if(loopFileData.attachType==='file'){
328
363
  return
329
364
  }
365
+
366
+ let tempParentRowInfo = this.$refs.eisTreeView.getRowById(loopFileData.parentId)
367
+ let tempExpandRows = []
368
+ if(tempParentRowInfo){
369
+ tempExpandRows.push(tempParentRowInfo)
370
+ }
371
+ let tempRowInfo = this.$refs.eisTreeView.getRowById(loopFileData.id)
372
+ this.$refs.eisTreeView.setCurrentRow(tempRowInfo)
373
+
374
+ tempExpandRows.push(tempRowInfo)
375
+ this.$refs.eisTreeView.setTreeExpand(tempExpandRows,true)
330
376
  this.currentSelectKey = [loopFileData.id]
331
377
  },
332
378
  handleFileGroupSelect(selectedKeys){
@@ -400,8 +446,7 @@ export default {
400
446
  //添加文件数据
401
447
  let addRow = {
402
448
  attachId: info.file.response.content.id,
403
- sysRowState: sysRowState.add,
404
- attach: info.file.response.content,
449
+ sysRowState: 'add',
405
450
  parentId: this.currentSelectKey[0],
406
451
  fileType: info.file.response.content.fileType,
407
452
  sort:this.internalRows.length+1,
@@ -472,7 +517,7 @@ export default {
472
517
  },
473
518
  removeAttach(attachFile) {
474
519
  //检查是否存在子项文件夹或者文件需要删除
475
- let tempChild = XEUtils.find(this.internalRows,p=>p.parentId==attachFile.id && p.sysRowState!==sysRowState.delete)
520
+ let tempChild = XEUtils.find(this.internalRows,p=>p.parentId==attachFile.id && p.sysRowState!=='delete')
476
521
  if(tempChild){
477
522
  notification.error({
478
523
  message: "错误",
@@ -483,10 +528,10 @@ export default {
483
528
  // console.debug(attachFile)
484
529
  for (let i = 0; i < this.internalRows.length; i++) {
485
530
  if (this.internalRows[i].id === attachFile.id) {
486
- if (this.internalRows[i].sysRowState === sysRowState.add) {
531
+ if (this.internalRows[i].sysRowState === 'add') {
487
532
  this.internalRows.splice(i, 1);
488
533
  } else {
489
- this.$set(this.internalRows[i], "sysRowState", sysRowState.delete);
534
+ this.$set(this.internalRows[i], "sysRowState", 'delete');
490
535
  }
491
536
  break;
492
537
  }
@@ -501,6 +546,21 @@ export default {
501
546
  `?accessToken=${this.$store.getters.token}`
502
547
  );
503
548
  },
549
+ getUpdateRows(){
550
+ //先获取删除数据,因为前台删除一个明细后又添加相同的明细后台会
551
+ //报唯一索引错误,因为后台也是先添加然后再是删除的会照成问题
552
+ //所有就要把删除的放在数组的第一个传递过去,这样后台就先删除然后再新增了
553
+ let tempRemoveRows =XEUtils.filter(this.internalRows,p=>p.sysRowState==='delete' && p.id!=='sys_top_folder')
554
+ let tempAddRows =XEUtils.filter(this.internalRows,p=>p.sysRowState==='add' && p.id!=='sys_top_folder')
555
+ let tempUpdateRows =XEUtils.filter(this.internalRows,p=>p.sysRowState==='update' && p.id!=='sys_top_folder')
556
+ let tempRows = XEUtils.union(tempRemoveRows,tempAddRows,tempUpdateRows)
557
+ XEUtils.arrayEach(tempRows,p=>{
558
+ if(p.parentId==='sys_top_folder'){
559
+ p.parentId = null
560
+ }
561
+ })
562
+ return tempRows
563
+ },
504
564
  /**
505
565
  * 查看附件
506
566
  */
@@ -611,6 +671,10 @@ export default {
611
671
  }
612
672
  }
613
673
  }
674
+ .tree-node-icon {
675
+ width: 16px;
676
+ text-align: center;
677
+ }
614
678
 
615
679
  .avatar-uploader .el-upload {
616
680
  border: 1px solid #d9d9d9;
@@ -1603,7 +1603,7 @@ export default {
1603
1603
  let tmpRow = JSON.parse(JSON.stringify(this.copySaveRow))
1604
1604
  delete tmpRow['_X_ROW_KEY']
1605
1605
  delete tmpRow[childrenField]
1606
- tmpRow[parentField]=row.id
1606
+ tmpRow[parentField]=row==null?null:row.id
1607
1607
  $table.insertAt(tmpRow, -1)
1608
1608
  .then(({ row }) => {
1609
1609
  pasteChildren(this.copySaveRow, childrenField,parentField)
@@ -2417,7 +2417,7 @@ export default {
2417
2417
  let colElId = scope.column.id
2418
2418
  let rowElId = scope.row._X_ROW_KEY
2419
2419
  //如果用了rowConfig里的keyField
2420
- if(this.rowConfig.keyField){
2420
+ if(this.rowConfig!=null&&this.rowConfig.keyField){
2421
2421
  rowElId=scope.row[this.rowConfig.keyField]
2422
2422
  }
2423
2423
  //延迟设置输入框自动获取焦点以及选中