xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<template>
    <div class="mod-sys__dict">
      <el-row :gutter="5">
        <el-col :span="11">
          <div class="fa-card-a">
          <zt-table-wraper ref="typeTable" v-slot="{ table }" :paging='false'
                           delete-url="/sys/dict/type"
                           query-url="/sys/dict/type/tree">
                <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
                  <el-form-item>
                    <zt-button perm="sys:dict" type="add" @click="table.editHandle()"/>
                    <zt-button type='self' icon2="el-icon-upload2"  @click="DictImport">导入</zt-button>
                  </el-form-item>
                </el-form>
              <el-table ref="table" v-adaptive="{bottomOffset:30}" v-loading="table.dataLoading"
                          :data="table.dataList"
                          height="100px" highlight-current-row
                          row-key="id" @current-change="handleCurrentChange"
                          @selection-change="table.selectionChangeHandle"
                          :cell-style="dictNameleft"
                          @sort-change="table.sortChangeHandle">
                  <el-table-column :label="$t('dict.dictName')" align="left" prop="dictName"/>
                  <el-table-column :label="$t('dict.dictType')" header-align="center" prop="dictType"/>
                  <zt-table-column-dict v-if="$store.state.user.isPlatform" :label="$t('dict.canView')" dict="bool"
                                        prop="canView"
                                        width="80"/>
                  <zt-table-column-dict v-if="$store.state.user.isPlatform" :label="$t('dict.canOverload')" dict="bool"
                                        prop="canOverload"
                                        width="80"/>
                  <zt-table-column-handle v-if="$store.state.user.isPlatform" :table="table" delete-perm="sys:dict:delete"
                                          edit-perm="sys:dict:update"/>
                  <!-- 租户按钮 -->
                  <zt-table-column-handle v-if="!$store.state.user.isPlatform" :has-delete="isCanDelete"
                                          :has-edit="isCanUpdate"
                                          :table="table" delete-perm="sys:dict:delete"
                                          edit-perm="sys:dict:update">
                    <template v-slot="{ row }">
                      <zt-table-button v-if="isCanOverload(row)" @click="copy(row)">{{
                          $t('dict.copy')
                        }}
                      </zt-table-button>
                    </template>
                  </zt-table-column-handle>
                </el-table>
            <dictListImport ref="dictListImport" @refreshDataList="refresh()"></dictListImport>
            <!-- 弹窗, 新增 / 修改 -->
            <add-or-update @refreshDataList="table.query()"/>
          </zt-table-wraper>
          </div>
        </el-col>
        <el-col :span="13">
          <dict-data ref="dictList"/>
        </el-col>
      </el-row>
    </div>
</template>
<script>
import AddOrUpdate from './dict-type-add-or-update'
import DictData from './dict-data'
import {stringify} from "qs";
import dictListImport from './dict-list-import'
 
export default {
  data() {
    return {
      dataForm: {
        id: '0',
        dictName: '',
        dictType: ''
      },
      progress: {
        id: null,
        speed: 0,
        text: '',
        start: false,
        timer: null
      },
      fileType: ['xlsx', 'xls'],
      apiURL: '',
      start: 0,
      dialogVisible: false,
      dialogMsg: '',
      fileList: [],
      resultData: []
    }
  },
  components: {
    AddOrUpdate,
    DictData,
    dictListImport,
  },
  methods: {
    init() {
      this.fileList = []
      this.resultData = []
      this.progress.id = guid()
      let params = stringify({
        token: Cookies.get('token'),
        progressId:this.progress.id
      })
      this.apiURL = `http://localhost:8050/maintain/lifeManagement/importDataDictExcel?${params}`
    },
    DictImport() {
      this.$refs.dictListImport.$refs.dialog.init()
    },
    dictNameleft({row, column, rowIndex, columnIndex}){
      console.log({row, column, rowIndex, columnIndex},'row rowIndex')
      if(column.property === 'dictName'){
        return {'textAlign':'left'}
      }
    },
    refresh() {
      let page = this.$refs.tableObj.page
      let limit = this.$refs.tableObj.limit
      this.$refs.tableObj.pageLimitChange(page, limit)
      this.$refs.ztBoatTree.getProductList()
      this.$refs.tableObj.query()
    },
    handleCurrentChange(row) {
      this.dataForm.id = row.id
      if (row.children.length === 0) {
        this.$refs['dictList'].init(row.id, row.dictName)
      } else {
        this.$refs['dictList'].$refs.dataTable.dataList = []
      }
    },
    isCanUpdate(row) {
      return row.tenantId !== this.$config.PLATFORM_TENANT_ID
    },
    isCanDelete(row) {
      if (this.$store.state.user.isPlatform) { // 平台用户
        return row.children.length === 0
      } else { // 租户
        return row.tenantId !== this.$config.PLATFORM_TENANT_ID && row.children.length === 0 // 租户的参数才可以删除
      }
    },
    isCanOverload(row) { // 是否能拷贝
      return row.tenantId === this.$config.PLATFORM_TENANT_ID && row.pid === this.$config.DICT_ROOT && row.canOverload === true
    },
    async copy(row) {
      if (await this.$tip.confirm(this.$t('prompt.info', {'handle': this.$t('dict.copy')}))) {
        let res = await this.$http.post(`/sys/dict/type/copy?id=${row.id}`)
        if (res.success) {
          await this.$tip.success()
          this.$refs.typeTable.query()
        }
      }
    }
  }
}
</script>
 
<style>
.custom-tree-node {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  padding-right: 8px;
}
</style>