doway-coms 2.4.6 → 2.4.8

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.8",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
@@ -1,8 +1,47 @@
1
1
  <template>
2
2
  <div style="height:300px">
3
3
  <splitpanes class="default-theme">
4
- <pane>
5
- <a-tree :tree-data="fileGroupData" :selectedKeys="currentSelectKey" :replaceFields="{title:'name',key:'id'}" show-icon default-expand-all @select="handleFileGroupSelect">
4
+ <pane size="20">
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>
33
+ </template>
34
+ </vxe-column>
35
+ <vxe-column width="80px">
36
+ <template #default="{ row }">
37
+ <span>
38
+ <span @click="handleAddSubFolder(row)" v-if="edit===true">添加</span>
39
+ <span @click="handleEditSubFolder(row)" v-if="edit===true && row.id!=='sys_top_folder'">编辑</span>
40
+ </span>
41
+ </template>
42
+ </vxe-column>
43
+ </vxe-table>
44
+ <!-- <a-tree :tree-data="fileGroupData" :selectedKeys="currentSelectKey" :replaceFields="{title:'name',key:'id'}" show-icon default-expand-all @select="handleFileGroupSelect">
6
45
  <a-icon slot="fileGroup" type="folder" />
7
46
  <template #title="{ name,id }">
8
47
  <div>
@@ -11,7 +50,7 @@
11
50
  <span @click="handleEditSubFolder(id,name)" v-if="edit===true && id!=='sys_top_folder'">编辑</span>
12
51
  </div>
13
52
  </template>
14
- </a-tree>
53
+ </a-tree> -->
15
54
  </pane>
16
55
  <pane>
17
56
  <div class="card-view-items">
@@ -20,7 +59,8 @@
20
59
  <div @click="removeAttach(loopFileData)" v-if="edit===true">删除</div>
21
60
  <div @click="downloadAttach(loopFileData)" v-if="loopFileData.attachType==='file' && allowDownload===true">下载</div>
22
61
  </div>
23
- <div class="card-view-item" :style="{ width: itemWidth + 'px' }" v-if="edit===true">
62
+
63
+ <div class="card-view-item" :style="{ width: itemWidth + 'px' }" v-if="edit===true && currentSelectKey.length>0">
24
64
  <a-upload
25
65
  class="avatar-uploader"
26
66
  :headers="uploadHeaders"
@@ -96,7 +136,6 @@
96
136
 
97
137
  <script>
98
138
  import { notification, Upload,Tree,Icon,Popconfirm,Input } from "ant-design-vue";
99
- import { sysRowState } from "../../utils/enum";
100
139
  import { Checkbox, Modal } from "vxe-table";
101
140
  import { attachGetAttachUrlApi, attachSearchApi } from "../../utils/api";
102
141
  import XEUtils from 'xe-utils'
@@ -120,7 +159,7 @@ export default {
120
159
  showEditFolder:false,
121
160
  currentEditInfo:{},
122
161
  currentEditFolderValue:'',
123
- currentSelectKey:['1'],
162
+ currentSelectKey:[],
124
163
  fileGroupData:[],
125
164
  internalRows: [],
126
165
  itemWidth:200,
@@ -139,8 +178,7 @@ export default {
139
178
  if(this.currentSelectKey.length===0){
140
179
  return []
141
180
  }
142
- console.debug(this.internalRows)
143
- return this.internalRows.filter(p=>p.parentId==this.currentSelectKey[0] && p.sysRowState!==sysRowState.delete)
181
+ return this.internalRows.filter(p=>p.parentId==this.currentSelectKey[0] && p.sysRowState!=='delete')
144
182
  }
145
183
  },
146
184
  props: {
@@ -250,9 +288,9 @@ export default {
250
288
  buildTreeData(tempRows){
251
289
  this.internalRows =JSON.parse(JSON.stringify(tempRows))
252
290
  let tempTopFolder = {
253
- sysRowState: sysRowState.view,
291
+ sysRowState: 'view',
254
292
  parentId: null,
255
- sort:1,
293
+ sort:0,
256
294
  attachType:'folder',
257
295
  name:'文件',
258
296
  id:'sys_top_folder',
@@ -264,11 +302,15 @@ export default {
264
302
  }
265
303
  p.parentId = 'sys_top_folder'
266
304
  })
267
- // console.debug(this.internalRows)
268
305
 
269
306
  //
270
- let tempFoldRows = XEUtils.filter(this.internalRows,p=>p.attachType==='folder')
271
- this.fileGroupData = XEUtils.toArrayTree(tempFoldRows,{strict:true,sortKey:'sort'})
307
+ this.fileGroupData = XEUtils.orderBy(XEUtils.filter(this.internalRows,p=>p.attachType==='folder'),p=>p.sort)
308
+ console.debug('davistest',this.fileGroupData)
309
+ if(this.currentSelectKey.length===0){
310
+ this.$refs.eisTreeView.setCurrentRow(tempTopFolder)
311
+ this.currentSelectKey = [tempTopFolder.id]
312
+ }
313
+ // this.fileGroupData = XEUtils.toArrayTree(tempFoldRows,{strict:true,sortKey:'sort'})
272
314
 
273
315
  // // this.internalRows.push(tempTopFolder)
274
316
  // this.fileGroupData = [tempTopFolder]
@@ -277,48 +319,47 @@ export default {
277
319
 
278
320
  // this.fileData = XEUtils.filter(tempRows,p=>p.attachType==='file')
279
321
  },
280
- handleAddSubFolder(loopId){
322
+ handleAddSubFolder(rowInfo){
281
323
  //添加子项文件夹
282
- this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===loopId)
324
+ this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===rowInfo.id)
283
325
  this.currentEditInfo['operation'] = 'add'
284
326
  this.showEditFolder = true
285
327
  },
286
- handleEditSubFolder(loopId,loopName){
287
- this.currentEditFolderValue = loopName
328
+ handleEditSubFolder(rowInfo){
329
+ this.currentEditFolderValue = rowInfo.name
288
330
  //添加子项文件夹
289
- this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===loopId)
331
+ this.currentEditInfo =XEUtils.find(this.internalRows,p=>p.id===rowInfo.id)
290
332
  this.currentEditInfo['operation'] = 'edit'
291
333
  this.showEditFolder = true
292
334
  },
335
+ eisCurrentChange(scope) {
336
+ this.currentSelectKey = [scope.row.id]
337
+
338
+ },
293
339
  confirmEditFolder(){
340
+
341
+ let tempRowInfo = this.$refs.eisTreeView.getRowById(this.currentEditInfo.id)
294
342
  if(this.currentEditInfo.operation==='add'){
295
- let tempNodeInfo = XEUtils.findTree(this.fileGroupData,p=>p.id===this.currentEditInfo.id)
296
343
  //新增文件夹
297
344
  let tempAddRowInfo = {
298
- sysRowState: sysRowState.add,
345
+ sysRowState: 'add',
299
346
  parentId: this.currentEditInfo.id,
300
- sort:tempNodeInfo.item.children?tempNodeInfo.item.children.length+1:1,
347
+ sort: tempRowInfo.children.length+1,
301
348
  attachType:'folder',
302
349
  children:[],
303
350
  name:this.currentEditFolderValue,
304
351
  id:this.$store.getters.newId() + "",
305
352
  }
306
353
  this.internalRows.push(tempAddRowInfo)
307
- if(tempNodeInfo.item.children){
308
- tempNodeInfo.item.children.push(tempAddRowInfo)
309
- }else{
310
- tempNodeInfo.item['children'] = [tempAddRowInfo]
311
- }
312
-
354
+ this.$refs.eisTreeView.insertAt(tempAddRowInfo,-1)
313
355
  }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
356
+ let tempInternalRowInfo = XEUtils.find(this.internalRows,p=>p.id===this.currentEditInfo.id)
357
+ if(tempInternalRowInfo.sysRowState!=='add'){
358
+ tempInternalRowInfo.sysRowState = 'update'
317
359
  }
318
- tempRowInfo.name = this.currentEditFolderValue
360
+ tempInternalRowInfo.name = this.currentEditFolderValue
319
361
  //修改树节点名称
320
- let tempNodeInfo = XEUtils.findTree(this.fileGroupData,p=>p.id===this.currentEditInfo.id)
321
- tempNodeInfo.item.name = tempRowInfo.name
362
+ tempRowInfo.name = tempInternalRowInfo.name
322
363
  }
323
364
  this.showEditFolder = false
324
365
  this.currentEditFolderValue =null
@@ -327,6 +368,17 @@ export default {
327
368
  if(loopFileData.attachType==='file'){
328
369
  return
329
370
  }
371
+
372
+ let tempParentRowInfo = this.$refs.eisTreeView.getRowById(loopFileData.parentId)
373
+ let tempExpandRows = []
374
+ if(tempParentRowInfo){
375
+ tempExpandRows.push(tempParentRowInfo)
376
+ }
377
+ let tempRowInfo = this.$refs.eisTreeView.getRowById(loopFileData.id)
378
+ this.$refs.eisTreeView.setCurrentRow(tempRowInfo)
379
+
380
+ tempExpandRows.push(tempRowInfo)
381
+ this.$refs.eisTreeView.setTreeExpand(tempExpandRows,true)
330
382
  this.currentSelectKey = [loopFileData.id]
331
383
  },
332
384
  handleFileGroupSelect(selectedKeys){
@@ -400,12 +452,11 @@ export default {
400
452
  //添加文件数据
401
453
  let addRow = {
402
454
  attachId: info.file.response.content.id,
403
- sysRowState: sysRowState.add,
404
- attach: info.file.response.content,
455
+ sysRowState: 'add',
405
456
  parentId: this.currentSelectKey[0],
406
457
  fileType: info.file.response.content.fileType,
407
458
  sort:this.internalRows.length+1,
408
- attachFile:'file',
459
+ attachType:'file',
409
460
  name:info.file.response.content.name,
410
461
  id:this.$store.getters.newId() + "",
411
462
  }
@@ -472,7 +523,7 @@ export default {
472
523
  },
473
524
  removeAttach(attachFile) {
474
525
  //检查是否存在子项文件夹或者文件需要删除
475
- let tempChild = XEUtils.find(this.internalRows,p=>p.parentId==attachFile.id && p.sysRowState!==sysRowState.delete)
526
+ let tempChild = XEUtils.find(this.internalRows,p=>p.parentId==attachFile.id && p.sysRowState!=='delete')
476
527
  if(tempChild){
477
528
  notification.error({
478
529
  message: "错误",
@@ -483,10 +534,10 @@ export default {
483
534
  // console.debug(attachFile)
484
535
  for (let i = 0; i < this.internalRows.length; i++) {
485
536
  if (this.internalRows[i].id === attachFile.id) {
486
- if (this.internalRows[i].sysRowState === sysRowState.add) {
537
+ if (this.internalRows[i].sysRowState === 'add') {
487
538
  this.internalRows.splice(i, 1);
488
539
  } else {
489
- this.$set(this.internalRows[i], "sysRowState", sysRowState.delete);
540
+ this.$set(this.internalRows[i], "sysRowState", 'delete');
490
541
  }
491
542
  break;
492
543
  }
@@ -501,6 +552,21 @@ export default {
501
552
  `?accessToken=${this.$store.getters.token}`
502
553
  );
503
554
  },
555
+ getUpdateRows(){
556
+ //先获取删除数据,因为前台删除一个明细后又添加相同的明细后台会
557
+ //报唯一索引错误,因为后台也是先添加然后再是删除的会照成问题
558
+ //所有就要把删除的放在数组的第一个传递过去,这样后台就先删除然后再新增了
559
+ let tempRemoveRows =XEUtils.filter(this.internalRows,p=>p.sysRowState==='delete' && p.id!=='sys_top_folder')
560
+ let tempAddRows =XEUtils.filter(this.internalRows,p=>p.sysRowState==='add' && p.id!=='sys_top_folder')
561
+ let tempUpdateRows =XEUtils.filter(this.internalRows,p=>p.sysRowState==='update' && p.id!=='sys_top_folder')
562
+ let tempRows = XEUtils.union(tempRemoveRows,tempAddRows,tempUpdateRows)
563
+ XEUtils.arrayEach(tempRows,p=>{
564
+ if(p.parentId==='sys_top_folder'){
565
+ p.parentId = null
566
+ }
567
+ })
568
+ return tempRows
569
+ },
504
570
  /**
505
571
  * 查看附件
506
572
  */
@@ -611,6 +677,10 @@ export default {
611
677
  }
612
678
  }
613
679
  }
680
+ .tree-node-icon {
681
+ width: 16px;
682
+ text-align: center;
683
+ }
614
684
 
615
685
  .avatar-uploader .el-upload {
616
686
  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
  //延迟设置输入框自动获取焦点以及选中