|
|
1
|
+<template>
|
|
|
2
|
+ <section>
|
|
|
3
|
+ <!--工具条-->
|
|
|
4
|
+ <el-form :inline="true" :model="filters">
|
|
|
5
|
+ <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
|
|
|
6
|
+ <el-form-item>
|
|
|
7
|
+ <el-input v-model="filters.roleName" placeholder="客户名称" clearable>
|
|
|
8
|
+ <template slot="prepend">客户名称</template>
|
|
|
9
|
+ </el-input>
|
|
|
10
|
+ </el-form-item>
|
|
|
11
|
+ <el-form-item>
|
|
|
12
|
+ <div class="my-text-area">
|
|
|
13
|
+ <div class="el-input-group__prepend prepand">业务类型</div>
|
|
|
14
|
+ <el-select
|
|
|
15
|
+ v-model="filters.orgtype"
|
|
|
16
|
+ filterable
|
|
|
17
|
+ allow-create
|
|
|
18
|
+ clearable
|
|
|
19
|
+ default-first-option
|
|
|
20
|
+ placeholder="业务类型">
|
|
|
21
|
+ <el-option
|
|
|
22
|
+ v-for="item in orgtypeOption"
|
|
|
23
|
+ :key="item.value"
|
|
|
24
|
+ :label="item.label"
|
|
|
25
|
+ :value="item.value">
|
|
|
26
|
+ </el-option>
|
|
|
27
|
+ </el-select>
|
|
|
28
|
+ </div>
|
|
|
29
|
+ </el-form-item>
|
|
|
30
|
+ <el-form-item>
|
|
|
31
|
+ <el-input v-model="filters.departmentid" placeholder="客户简码" clearable>
|
|
|
32
|
+ <template slot="prepend">简  码</template>
|
|
|
33
|
+ </el-input>
|
|
|
34
|
+ </el-form-item>
|
|
|
35
|
+
|
|
|
36
|
+ <el-form-item>
|
|
|
37
|
+ <el-button type="primary" v-on:click="getRoles()" icon="el-icon-search">查  询</el-button>
|
|
|
38
|
+ </el-form-item>
|
|
|
39
|
+ <el-form-item>
|
|
|
40
|
+ <el-button type="success" @click="handleAdd" icon="el-icon-document">新  增</el-button>
|
|
|
41
|
+ </el-form-item>
|
|
|
42
|
+ <el-form-item>
|
|
|
43
|
+ <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0" icon="el-icon-delete">批量删除</el-button>
|
|
|
44
|
+ </el-form-item>
|
|
|
45
|
+ <el-form-item>
|
|
|
46
|
+ <el-button type="warning" @click="toggleRowExpansion" icon="el-icon-sort" size="mini">
|
|
|
47
|
+ 全部{{ isExpansion ? "折叠" : "展开" }}
|
|
|
48
|
+ </el-button>
|
|
|
49
|
+ </el-form-item>
|
|
|
50
|
+ </el-col>
|
|
|
51
|
+ </el-form>
|
|
|
52
|
+
|
|
|
53
|
+ <el-col :gutter="0" class="toolbar toobar_analysis" style="padding-top:0">
|
|
|
54
|
+ <el-col :span="7">
|
|
|
55
|
+ <div class="analysis_title">机构数量:</div>
|
|
|
56
|
+ <div class="analysis_text">{{total}}</div>
|
|
|
57
|
+ </el-col>
|
|
|
58
|
+ <el-col :span="1">
|
|
|
59
|
+ <el-divider direction="vertical"></el-divider>
|
|
|
60
|
+ </el-col>
|
|
|
61
|
+ <el-col :span="7">
|
|
|
62
|
+ <div class="analysis_title">公司数量:</div>
|
|
|
63
|
+ <div class="analysis_text">{{total}}</div>
|
|
|
64
|
+ </el-col>
|
|
|
65
|
+ <el-col :span="1">
|
|
|
66
|
+ <el-divider direction="vertical"></el-divider>
|
|
|
67
|
+ </el-col>
|
|
|
68
|
+ <el-col :span="8">
|
|
|
69
|
+ <div class="analysis_title">数据量共:</div>
|
|
|
70
|
+ <div class="analysis_text">150</div>
|
|
|
71
|
+ </el-col>
|
|
|
72
|
+ </el-col>
|
|
|
73
|
+
|
|
|
74
|
+ <!--列表-->
|
|
|
75
|
+ <el-table :data="roles" highlight-current-row v-loading="listLoading" @selection-change="selsChange"
|
|
|
76
|
+ default-expand-all
|
|
|
77
|
+ ref="dataTreeList"
|
|
|
78
|
+ row-key="roleId"
|
|
|
79
|
+ border
|
|
|
80
|
+ tooltip-effect="dark"
|
|
|
81
|
+ style="border-radius: 10px 10px 0px 0px;line-height: 25px;min-height: 500px"
|
|
|
82
|
+ :header-cell-style="{background:'#6F8294',color:'#FFFFFF'}" size="small"
|
|
|
83
|
+ :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
|
|
84
|
+ <el-table-column type="selection" width="55">
|
|
|
85
|
+ </el-table-column>
|
|
|
86
|
+ <!--<el-table-column type="index" width="60">-->
|
|
|
87
|
+ <!--</el-table-column>-->
|
|
|
88
|
+ <el-table-column prop="roleId" label="ID" width="120">
|
|
|
89
|
+ </el-table-column>
|
|
|
90
|
+ <el-table-column prop="roleName" label="岗位/角色名称" min-width="200" sortable>
|
|
|
91
|
+ </el-table-column>
|
|
|
92
|
+ <!--<el-table-column prop="departmentName" label="部门名称" min-width="200" sortable>-->
|
|
|
93
|
+ <!--</el-table-column>-->
|
|
|
94
|
+ <el-table-column prop="description" label="描述" min-width="160" >
|
|
|
95
|
+ </el-table-column>
|
|
|
96
|
+ <el-table-column prop="type" label="类型" min-width="80" sortable>
|
|
|
97
|
+ </el-table-column>
|
|
|
98
|
+ <el-table-column prop="businessLicense" label="工商代码" min-width="180" >
|
|
|
99
|
+ </el-table-column>
|
|
|
100
|
+ <el-table-column prop="orgtype" label="业务类型" min-width="150" >
|
|
|
101
|
+ <template slot-scope="scope">
|
|
|
102
|
+ <el-tag type="" v-if="scope.row.orgtype==='M'">{{busnessType[scope.row.orgtype]}}</el-tag>
|
|
|
103
|
+ <el-tag type="success" v-if="scope.row.orgtype==='C'">{{busnessType[scope.row.orgtype]}}</el-tag>
|
|
|
104
|
+ <el-tag type="warning" v-if="scope.row.orgtype==='S'">{{busnessType[scope.row.orgtype]}}</el-tag>
|
|
|
105
|
+ </template>
|
|
|
106
|
+ </el-table-column>
|
|
|
107
|
+ <el-table-column prop="departmentid" label="简码" min-width="150" >
|
|
|
108
|
+ </el-table-column>
|
|
|
109
|
+ <el-table-column label="操作" min-width="260" fixed="right">
|
|
|
110
|
+ <template slot-scope="scope">
|
|
|
111
|
+<!-- <el-row>-->
|
|
|
112
|
+<!-- <el-button type="success" @click="handleAdd(scope.$index, scope.row)">新增下级</el-button>-->
|
|
|
113
|
+<!-- <el-button @click="setPerm(scope.$index, scope.row)">设置权限</el-button>-->
|
|
|
114
|
+<!-- </el-row>-->
|
|
|
115
|
+ <el-row>
|
|
|
116
|
+ <el-button @click="handleEdit(scope.$index, scope.row)">编  辑</el-button>
|
|
|
117
|
+ <el-button type="danger" @click="handleDel(scope.$index, scope.row)">删  除</el-button>
|
|
|
118
|
+ </el-row>
|
|
|
119
|
+ </template>
|
|
|
120
|
+ </el-table-column>
|
|
|
121
|
+ </el-table>
|
|
|
122
|
+ <!--工具条-->
|
|
|
123
|
+ <el-col :span="24" class="toolbar">
|
|
|
124
|
+ <el-pagination layout="total, prev, pager, next" @current-change="handleCurrentChange" :page-size="pageSize" :total="total" style="float:right;">
|
|
|
125
|
+ </el-pagination>
|
|
|
126
|
+ </el-col>
|
|
|
127
|
+
|
|
|
128
|
+ <!--新增界面-->
|
|
|
129
|
+ <el-dialog :title="dialogMap[dialogStatus]" :visible.sync="addFormVisible" :close-on-click-modal="false">
|
|
|
130
|
+ <el-form :model="addForm" label-width="120px" :rules="addFormRules" ref="addForm">
|
|
|
131
|
+ <el-form-item label="上级组织机构">
|
|
|
132
|
+ <span>{{addForm.parentName}}</span>
|
|
|
133
|
+ </el-form-item>
|
|
|
134
|
+ <el-form-item label=" " prop="type">
|
|
|
135
|
+ <el-select
|
|
|
136
|
+ v-model="addForm.type"
|
|
|
137
|
+ filterable
|
|
|
138
|
+ allow-create
|
|
|
139
|
+ default-first-option
|
|
|
140
|
+ placeholder="组织机构类型">
|
|
|
141
|
+ <el-option
|
|
|
142
|
+ v-for="item in companyOption"
|
|
|
143
|
+ :key="item.value"
|
|
|
144
|
+ :label="item.label"
|
|
|
145
|
+ :value="item.value">
|
|
|
146
|
+ </el-option>
|
|
|
147
|
+ </el-select>
|
|
|
148
|
+ </el-form-item>
|
|
|
149
|
+ <el-form-item label=" " prop="roleName">
|
|
|
150
|
+ <el-input v-model="addForm.roleName" auto-complete="off" placeholder="请输入组织机构名称:例如:公司名称">
|
|
|
151
|
+ <template slot="prepend">组织机构名称</template>
|
|
|
152
|
+ </el-input>
|
|
|
153
|
+ </el-form-item>
|
|
|
154
|
+ <el-form-item label=" " prop="description">
|
|
|
155
|
+ <el-input v-model="addForm.description" auto-complete="off" placeholder="组织机构描述:例如:组织机构简介">
|
|
|
156
|
+ <template slot="prepend">组织机构描述</template>
|
|
|
157
|
+ </el-input>
|
|
|
158
|
+ </el-form-item>
|
|
|
159
|
+ <el-form-item label=" " prop="businessLicense">
|
|
|
160
|
+ <el-input v-model="addForm.businessLicense" auto-complete="off" placeholder="社会信用代码或者组织机构代码">
|
|
|
161
|
+ <template slot="prepend">企业信用代码</template>
|
|
|
162
|
+ </el-input>
|
|
|
163
|
+ </el-form-item>
|
|
|
164
|
+ <el-form-item label=" " prop="customsRegCode">
|
|
|
165
|
+ <el-input v-model="addForm.customsRegCode" auto-complete="off" placeholder="海关备案后返回的备案代码">
|
|
|
166
|
+ <template slot="prepend">海关备案代码</template>
|
|
|
167
|
+ </el-input>
|
|
|
168
|
+ </el-form-item>
|
|
|
169
|
+ <el-form-item label=" " prop="mqcode">
|
|
|
170
|
+ <el-input v-model="addForm.mqcode" auto-complete="off" placeholder="海关通道编号">
|
|
|
171
|
+ <template slot="prepend">海关通道编号</template>
|
|
|
172
|
+ </el-input>
|
|
|
173
|
+ </el-form-item>
|
|
|
174
|
+ <el-form-item label=" " prop="departmentid">
|
|
|
175
|
+ <el-input v-model="addForm.departmentid" auto-complete="off" placeholder="航司承运人代码,组织机构为航司时必填">
|
|
|
176
|
+ <template slot="prepend"> 承运人代码 </template>
|
|
|
177
|
+ </el-input>
|
|
|
178
|
+ </el-form-item>
|
|
|
179
|
+ </el-form>
|
|
|
180
|
+ <div slot="footer" class="dialog-footer">
|
|
|
181
|
+ <el-button @click.native="addFormVisible = false">取消</el-button>
|
|
|
182
|
+ <el-button type="primary" @click="dialogStatus==='create'?addSubmit():editSubmit()" :loading="addLoading" >提交</el-button>
|
|
|
183
|
+ </div>
|
|
|
184
|
+ </el-dialog>
|
|
|
185
|
+
|
|
|
186
|
+ <!--权限设置界面-->
|
|
|
187
|
+ <el-dialog title="岗位的权限设置"
|
|
|
188
|
+ :visible.sync="PermFormVisible"
|
|
|
189
|
+ :close-on-click-modal="false"
|
|
|
190
|
+ top="5vh"
|
|
|
191
|
+ >
|
|
|
192
|
+ <el-row>
|
|
|
193
|
+ <el-col :span="4" >
|
|
|
194
|
+ <el-button type="primary" @click.native="treeMerge(false)">合并节点</el-button>
|
|
|
195
|
+ </el-col>
|
|
|
196
|
+ <el-col :span="4">
|
|
|
197
|
+ <el-button type="success" @click.native="treeMerge(true)">展开节点</el-button>
|
|
|
198
|
+ </el-col>
|
|
|
199
|
+ </el-row>
|
|
|
200
|
+ <el-divider></el-divider>
|
|
|
201
|
+ <el-form :model="permForm" label-width="80px" ref="permForm">
|
|
|
202
|
+ <el-tree :data="permissons" :props="treeDefaultProps"
|
|
|
203
|
+ @check="clickDeal"
|
|
|
204
|
+ :default-expand-all = "treeExpand"
|
|
|
205
|
+ show-checkbox highlight-current check-on-click-node check-strictly
|
|
|
206
|
+ node-key="permissionId" ref="tree">
|
|
|
207
|
+ </el-tree>
|
|
|
208
|
+ </el-form>
|
|
|
209
|
+ <div slot="footer" class="dialog-footer">
|
|
|
210
|
+ <el-button @click.native="PermFormVisible = false">取消</el-button>
|
|
|
211
|
+ <el-button type="primary" @click.native="setPermSubmit" :loading="addLoading">提交</el-button>
|
|
|
212
|
+ </div>
|
|
|
213
|
+ </el-dialog>
|
|
|
214
|
+ </section>
|
|
|
215
|
+</template>
|
|
|
216
|
+
|
|
|
217
|
+<script>
|
|
|
218
|
+ import util from '../../common/js/util'
|
|
|
219
|
+ import NProgress from 'nprogress'
|
|
|
220
|
+ import { getList, remove, batchRemove, edit, add, updateRolePerm } from '../../api/role_api';
|
|
|
221
|
+ import { getList as getCRMList } from '@/api/crm_api';
|
|
|
222
|
+ import { getList as getDepartmentList} from '../../api/department';
|
|
|
223
|
+ import { getList as permList } from '../../api/perm_api';
|
|
|
224
|
+ import moment from 'moment'
|
|
|
225
|
+ export default {
|
|
|
226
|
+ name:'Role',
|
|
|
227
|
+ data() {
|
|
|
228
|
+ return {
|
|
|
229
|
+ filters: {
|
|
|
230
|
+ roleName: '',
|
|
|
231
|
+ orgtype:'',
|
|
|
232
|
+ departmentid:''
|
|
|
233
|
+ },
|
|
|
234
|
+ companyOption: [
|
|
|
235
|
+ {
|
|
|
236
|
+ label: "集团",
|
|
|
237
|
+ value: "集团",
|
|
|
238
|
+ },
|
|
|
239
|
+ {
|
|
|
240
|
+ label: "公司",
|
|
|
241
|
+ value: "公司"
|
|
|
242
|
+ },
|
|
|
243
|
+ {
|
|
|
244
|
+ label: "部门",
|
|
|
245
|
+ value: "部门"
|
|
|
246
|
+ },
|
|
|
247
|
+ {
|
|
|
248
|
+ label: "航司",
|
|
|
249
|
+ value: "航司"
|
|
|
250
|
+ },
|
|
|
251
|
+ {
|
|
|
252
|
+ label: "货代",
|
|
|
253
|
+ value: "货代"
|
|
|
254
|
+ },
|
|
|
255
|
+ {
|
|
|
256
|
+ label: "货主",
|
|
|
257
|
+ value: "货主"
|
|
|
258
|
+ }
|
|
|
259
|
+ ],
|
|
|
260
|
+ treeDefaultProps: {
|
|
|
261
|
+ children: 'children',
|
|
|
262
|
+ label: 'name',
|
|
|
263
|
+ },
|
|
|
264
|
+ treeExpand: false,
|
|
|
265
|
+ departmentNameList:[],
|
|
|
266
|
+ roles: [],
|
|
|
267
|
+ permissons: [],
|
|
|
268
|
+ permIds: [],
|
|
|
269
|
+ total: 0,
|
|
|
270
|
+ pageNum: 1,
|
|
|
271
|
+ pageSize: 10,
|
|
|
272
|
+ listLoading: false,
|
|
|
273
|
+ sels: [],//列表选中列
|
|
|
274
|
+ dialogMap: {
|
|
|
275
|
+ update: '编辑',
|
|
|
276
|
+ create: '新增',
|
|
|
277
|
+ },
|
|
|
278
|
+ dialogStatus: 'create',
|
|
|
279
|
+ //新增界面是否显示
|
|
|
280
|
+ addFormVisible: false,
|
|
|
281
|
+ //设置权限界面是否显示
|
|
|
282
|
+ PermFormVisible: false,
|
|
|
283
|
+ addLoading: false,
|
|
|
284
|
+ addFormRules: {
|
|
|
285
|
+ roleName: [
|
|
|
286
|
+ { required: true, message: '请输入岗位/角色名称', trigger: 'blur' }
|
|
|
287
|
+ ],
|
|
|
288
|
+ type: [
|
|
|
289
|
+ { required: true, message: '请选择组织机构类型', trigger: 'blur' }
|
|
|
290
|
+ ]
|
|
|
291
|
+ },
|
|
|
292
|
+ //新增界面数据
|
|
|
293
|
+ addForm: {
|
|
|
294
|
+ description: '',
|
|
|
295
|
+ roleName: '',
|
|
|
296
|
+ roleSign: 1,
|
|
|
297
|
+ departmentid:'',
|
|
|
298
|
+ type: '',
|
|
|
299
|
+ businessLicense: '',
|
|
|
300
|
+ customsRegCode: '',
|
|
|
301
|
+ parentName: '',
|
|
|
302
|
+ mqcode: ''
|
|
|
303
|
+
|
|
|
304
|
+ },
|
|
|
305
|
+ isExpansion:true,
|
|
|
306
|
+ permForm: {
|
|
|
307
|
+ roleId: 1,
|
|
|
308
|
+ description: '',
|
|
|
309
|
+ roleName: '',
|
|
|
310
|
+ roleSign: 1,
|
|
|
311
|
+ permissions: []
|
|
|
312
|
+ },
|
|
|
313
|
+ busnessType: {
|
|
|
314
|
+ 'M':'自身',
|
|
|
315
|
+ 'C':'客户',
|
|
|
316
|
+ 'S':'供应商'
|
|
|
317
|
+ },
|
|
|
318
|
+ orgtypeOption:[
|
|
|
319
|
+ {
|
|
|
320
|
+ label: "客户",
|
|
|
321
|
+ value: "C",
|
|
|
322
|
+ },
|
|
|
323
|
+ {
|
|
|
324
|
+ label: "供应商",
|
|
|
325
|
+ value: "S",
|
|
|
326
|
+ },
|
|
|
327
|
+ {
|
|
|
328
|
+ label: "自身",
|
|
|
329
|
+ value: "M",
|
|
|
330
|
+ }
|
|
|
331
|
+ ]
|
|
|
332
|
+
|
|
|
333
|
+ }
|
|
|
334
|
+ },
|
|
|
335
|
+ methods: {
|
|
|
336
|
+ toggleRowExpansion() {
|
|
|
337
|
+ this.isExpansion = !this.isExpansion;
|
|
|
338
|
+ this.toggleRowExpansionAll(this.roles, this.isExpansion);
|
|
|
339
|
+ },
|
|
|
340
|
+ toggleRowExpansionAll(data, isExpansion) {
|
|
|
341
|
+ data.forEach((item) => {
|
|
|
342
|
+ this.$refs.dataTreeList.toggleRowExpansion(item, isExpansion);
|
|
|
343
|
+ if (item.children !== undefined && item.children !== null) {
|
|
|
344
|
+ this.toggleRowExpansionAll(item.children, isExpansion);
|
|
|
345
|
+ }
|
|
|
346
|
+ });
|
|
|
347
|
+ },
|
|
|
348
|
+ treeMerge: function (expand) {
|
|
|
349
|
+ this.treeExpand = expand;
|
|
|
350
|
+ for(var i=0;i<this.$refs.tree.store._getAllNodes().length;i++){
|
|
|
351
|
+ this.$refs.tree.store._getAllNodes()[i].expanded=this.treeExpand;
|
|
|
352
|
+ }
|
|
|
353
|
+ },
|
|
|
354
|
+ handleCurrentChange(val) {
|
|
|
355
|
+ this.pageNum = val;
|
|
|
356
|
+ this.getRoles();
|
|
|
357
|
+ },
|
|
|
358
|
+ //获取角色列表
|
|
|
359
|
+ getRoles() {
|
|
|
360
|
+ let _this= this;
|
|
|
361
|
+ this.listLoading = true;
|
|
|
362
|
+ getCRMList(this.filters,this.pageNum,this.pageSize).then((res) => {
|
|
|
363
|
+ this.total = res.data.data.total;
|
|
|
364
|
+ this.roles = res.data.data.list;
|
|
|
365
|
+ }).catch((error) => {
|
|
|
366
|
+ if(null!= error.response && error.response!==undefined){
|
|
|
367
|
+ let status= error.response.status;
|
|
|
368
|
+ let msg = error.response.statusText;
|
|
|
369
|
+ return _this.$message.error(status+msg)
|
|
|
370
|
+ }else {
|
|
|
371
|
+ return _this.$message.error(error.toString())
|
|
|
372
|
+ }
|
|
|
373
|
+ }).finally(()=>{
|
|
|
374
|
+ this.listLoading = false;
|
|
|
375
|
+ });
|
|
|
376
|
+
|
|
|
377
|
+ },
|
|
|
378
|
+
|
|
|
379
|
+ //获取部门列表
|
|
|
380
|
+ getdepartmentNames() {
|
|
|
381
|
+
|
|
|
382
|
+ this.listLoading = true;
|
|
|
383
|
+ //NProgress.start();
|
|
|
384
|
+ getDepartmentList().then((res) => {
|
|
|
385
|
+ this.total = res.data.total;
|
|
|
386
|
+ this.departmentNameList = res.data.list;
|
|
|
387
|
+ this.listLoading = false;
|
|
|
388
|
+ //NProgress.done();
|
|
|
389
|
+ }).catch((error) => {
|
|
|
390
|
+
|
|
|
391
|
+ this.listLoading = false;
|
|
|
392
|
+ if(null!= error.response && error.response!==undefined){
|
|
|
393
|
+ let status= error.response.status;
|
|
|
394
|
+ let msg = error.response.statusText;
|
|
|
395
|
+ alert(status+msg);
|
|
|
396
|
+ }else {
|
|
|
397
|
+ alert(error);
|
|
|
398
|
+ }
|
|
|
399
|
+
|
|
|
400
|
+ });
|
|
|
401
|
+
|
|
|
402
|
+ },
|
|
|
403
|
+
|
|
|
404
|
+ //获取权限列表
|
|
|
405
|
+ getPermList() {
|
|
|
406
|
+ let para = {
|
|
|
407
|
+ pageNum: 1,
|
|
|
408
|
+ pageSize: 700
|
|
|
409
|
+ };
|
|
|
410
|
+ NProgress.start();
|
|
|
411
|
+ permList(para).then((res) => {
|
|
|
412
|
+ this.permissons = res.data.list;
|
|
|
413
|
+ NProgress.done();
|
|
|
414
|
+ }).catch((error) => {
|
|
|
415
|
+ if(null!= error.response && error.response!==undefined){
|
|
|
416
|
+ let status= error.response.status;
|
|
|
417
|
+ let msg = error.response.statusText;
|
|
|
418
|
+ message({
|
|
|
419
|
+ // 饿了么的消息弹窗组件
|
|
|
420
|
+ message: status+msg,
|
|
|
421
|
+ type: "error"
|
|
|
422
|
+ });
|
|
|
423
|
+ }else {
|
|
|
424
|
+ alert(error);
|
|
|
425
|
+ }
|
|
|
426
|
+ });
|
|
|
427
|
+
|
|
|
428
|
+ },
|
|
|
429
|
+ //删除
|
|
|
430
|
+ handleDel: function (index, row) {
|
|
|
431
|
+ this.$confirm('确认删除该记录吗?', '提示', {
|
|
|
432
|
+ type: 'warning'
|
|
|
433
|
+ }).then(() => {
|
|
|
434
|
+ this.listLoading = true;
|
|
|
435
|
+ //NProgress.start();
|
|
|
436
|
+ let para = { roleId: row.roleId };
|
|
|
437
|
+ remove(para).then((res) => {
|
|
|
438
|
+ this.listLoading = false;
|
|
|
439
|
+ //NProgress.done();
|
|
|
440
|
+ this.$message({
|
|
|
441
|
+ message: '删除成功',
|
|
|
442
|
+ type: 'success'
|
|
|
443
|
+ });
|
|
|
444
|
+ this.getRoles();
|
|
|
445
|
+ }).catch((error) => {
|
|
|
446
|
+ this.listLoading = false;
|
|
|
447
|
+ alert(error);
|
|
|
448
|
+ });
|
|
|
449
|
+ }).catch();
|
|
|
450
|
+ },
|
|
|
451
|
+ /**
|
|
|
452
|
+ * 显示编辑界面
|
|
|
453
|
+ * @param index
|
|
|
454
|
+ * @param row 为这行的数据对象
|
|
|
455
|
+ */
|
|
|
456
|
+ handleEdit: function (index, row) {
|
|
|
457
|
+ this.addFormVisible = true;
|
|
|
458
|
+ this.dialogStatus= 'update',
|
|
|
459
|
+ this.addForm = Object.assign({}, row);
|
|
|
460
|
+ // this.getdepartmentNames();
|
|
|
461
|
+ },
|
|
|
462
|
+ setPerm: function (index, row) {
|
|
|
463
|
+ this.PermFormVisible = true;
|
|
|
464
|
+ this.getPermList();
|
|
|
465
|
+ var _this = this;
|
|
|
466
|
+ this.permIds = [];
|
|
|
467
|
+ this.permForm = Object.assign({}, row);
|
|
|
468
|
+ let rolePerms = this.permForm.permissions;
|
|
|
469
|
+ if (util.checkNull(rolePerms)){
|
|
|
470
|
+ rolePerms.forEach(function (perm,v_index,v_arr) {
|
|
|
471
|
+ if(util.checkNull(perm)){
|
|
|
472
|
+ _this.permIds[v_index] = perm.permissionId;
|
|
|
473
|
+ }
|
|
|
474
|
+ });
|
|
|
475
|
+ }
|
|
|
476
|
+
|
|
|
477
|
+ this.$nextTick(() => {
|
|
|
478
|
+
|
|
|
479
|
+ //反向适配
|
|
|
480
|
+ this.$refs.tree.setCheckedKeys(this.permIds);
|
|
|
481
|
+ });
|
|
|
482
|
+ },
|
|
|
483
|
+ //显示新增界面,每次点开初始化数据
|
|
|
484
|
+ handleAdd: function (index,row) {
|
|
|
485
|
+ this.addFormVisible = true;
|
|
|
486
|
+ this.dialogStatus= 'create';
|
|
|
487
|
+ this.addForm = {
|
|
|
488
|
+ description: '',
|
|
|
489
|
+ roleName: '',
|
|
|
490
|
+ roleSign: 1,
|
|
|
491
|
+ departmentid:'',
|
|
|
492
|
+ type: '',
|
|
|
493
|
+ businessLicense: '',
|
|
|
494
|
+ customsRegCode: '',
|
|
|
495
|
+ mqcode: '',
|
|
|
496
|
+ parentid: 0,
|
|
|
497
|
+
|
|
|
498
|
+ };
|
|
|
499
|
+ //如果新增下级
|
|
|
500
|
+ if(util.checkNull(row)){
|
|
|
501
|
+ //传递上级ID
|
|
|
502
|
+ let parentRole = Object.assign({}, row);
|
|
|
503
|
+ this.addForm.parentid = parentRole.roleId;
|
|
|
504
|
+ this.addForm.parentName = parentRole.roleName;
|
|
|
505
|
+ }
|
|
|
506
|
+
|
|
|
507
|
+// this.getdepartmentNames();
|
|
|
508
|
+ },
|
|
|
509
|
+ //编辑
|
|
|
510
|
+ editSubmit: function () {
|
|
|
511
|
+ this.$refs.addForm.validate((valid) => {
|
|
|
512
|
+ if (valid) {
|
|
|
513
|
+ this.$confirm('确认提交吗?', '提示', {}).then(() => {
|
|
|
514
|
+ this.addLoading = true;
|
|
|
515
|
+ //NProgress.start();
|
|
|
516
|
+ let para = Object.assign({}, this.addForm);
|
|
|
517
|
+ //不需要提交的 去掉,后端不好接收
|
|
|
518
|
+ para.authorities = null;
|
|
|
519
|
+ para.permissions = null;
|
|
|
520
|
+ para.roles = null;
|
|
|
521
|
+ para.children = null;
|
|
|
522
|
+// para.birth = (!para.birth || para.birth == '') ? '' : util.formatDate.format(new Date(para.birth), 'yyyy-MM-dd');
|
|
|
523
|
+ /*
|
|
|
524
|
+ 查询之后格式this.filters.column.create_start_date中日期发生变化;
|
|
|
525
|
+ Wed Aug 09 2017 00:00:00 GMT+0800 (中国标准时间) 变成了 "2017-08-08T16:00:00.000Z";
|
|
|
526
|
+ 所以使用 moment 日期格式化插件将时间转换成 [ Wed Aug 09 2017 00:00:00 GMT+0800 (中国标准时间) ] 格
|
|
|
527
|
+ 式;
|
|
|
528
|
+ */
|
|
|
529
|
+ /*moment 安装 npm install moment --save*/
|
|
|
530
|
+ // para.creattime = moment(para.creattime).format('YYYY-MM-DD HH:mm:ss');
|
|
|
531
|
+ this.addLoading = false;
|
|
|
532
|
+ edit(para).then((res) => {
|
|
|
533
|
+
|
|
|
534
|
+ //NProgress.done();
|
|
|
535
|
+ this.$message({
|
|
|
536
|
+ message: '提交成功',
|
|
|
537
|
+ type: 'success'
|
|
|
538
|
+ });
|
|
|
539
|
+ this.$refs['addForm'].resetFields();
|
|
|
540
|
+ this.addFormVisible = false;
|
|
|
541
|
+ this.getRoles();
|
|
|
542
|
+ }).catch(error => alert(error));
|
|
|
543
|
+ });
|
|
|
544
|
+ }
|
|
|
545
|
+ });
|
|
|
546
|
+ },
|
|
|
547
|
+ //新增
|
|
|
548
|
+ addSubmit: function () {
|
|
|
549
|
+ this.$refs.addForm.validate((valid) => {
|
|
|
550
|
+ if (valid) {
|
|
|
551
|
+ this.$confirm('确认提交吗?', '提示', {}).then(() => {
|
|
|
552
|
+ this.addLoading = true;
|
|
|
553
|
+ //NProgress.start();
|
|
|
554
|
+ let para = Object.assign({}, this.addForm);
|
|
|
555
|
+ add(para).then((res) => {
|
|
|
556
|
+ this.addLoading = false;
|
|
|
557
|
+ //NProgress.done();
|
|
|
558
|
+ this.$message({
|
|
|
559
|
+ message: '提交成功',
|
|
|
560
|
+ type: 'success'
|
|
|
561
|
+ });
|
|
|
562
|
+ this.$refs['addForm'].resetFields();
|
|
|
563
|
+ this.addFormVisible = false;
|
|
|
564
|
+ this.getRoles();
|
|
|
565
|
+ }).catch(error => alert(error));
|
|
|
566
|
+ });
|
|
|
567
|
+ }
|
|
|
568
|
+ });
|
|
|
569
|
+ },
|
|
|
570
|
+ //设置角色提交
|
|
|
571
|
+ setPermSubmit: function () {
|
|
|
572
|
+ this.$refs.permForm.validate((valid) => {
|
|
|
573
|
+ if (valid) {
|
|
|
574
|
+ this.$confirm('确认提交吗?', '提示', {}).then(() => {
|
|
|
575
|
+ this.addLoading = true;
|
|
|
576
|
+ //NProgress.start();
|
|
|
577
|
+ let role = Object.assign({}, this.permForm);
|
|
|
578
|
+ let roleId = role.roleId;
|
|
|
579
|
+ let permissionIds = this.$refs.tree.getCheckedKeys();
|
|
|
580
|
+ let para = {roleId,permissionIds};
|
|
|
581
|
+ updateRolePerm(para).then((res) => {
|
|
|
582
|
+ this.addLoading = false;
|
|
|
583
|
+ if (res.status ===200) {
|
|
|
584
|
+ this.$message({
|
|
|
585
|
+ message: '提交成功',
|
|
|
586
|
+ type: 'success'
|
|
|
587
|
+ });
|
|
|
588
|
+ this.$refs['permForm'].resetFields();
|
|
|
589
|
+ }
|
|
|
590
|
+ //NProgress.done();
|
|
|
591
|
+ this.PermFormVisible = false;
|
|
|
592
|
+ this.getRoles();
|
|
|
593
|
+ }).catch(error => alert(error))
|
|
|
594
|
+ .finally(()=>{
|
|
|
595
|
+ this.addLoading = false
|
|
|
596
|
+ });
|
|
|
597
|
+ });
|
|
|
598
|
+ }
|
|
|
599
|
+ });
|
|
|
600
|
+ },
|
|
|
601
|
+ selsChange: function (sels) {
|
|
|
602
|
+ this.sels = sels;
|
|
|
603
|
+ },
|
|
|
604
|
+ //批量删除
|
|
|
605
|
+ batchRemove: function () {
|
|
|
606
|
+ var ids = this.sels.map(item => item.roleId).toString();
|
|
|
607
|
+ this.$confirm('确认删除选中记录吗?', '提示', {
|
|
|
608
|
+ type: 'warning'
|
|
|
609
|
+ }).then(() => {
|
|
|
610
|
+ this.listLoading = true;
|
|
|
611
|
+ //NProgress.start();
|
|
|
612
|
+ let para = { ids: ids };
|
|
|
613
|
+ batchRemove(para).then((res) => {
|
|
|
614
|
+ this.listLoading = false;
|
|
|
615
|
+ //NProgress.done();
|
|
|
616
|
+ this.$message({
|
|
|
617
|
+ message: '删除成功',
|
|
|
618
|
+ type: 'success'
|
|
|
619
|
+ });
|
|
|
620
|
+ this.getRoles();
|
|
|
621
|
+ });
|
|
|
622
|
+ }).catch(() => {
|
|
|
623
|
+
|
|
|
624
|
+ });
|
|
|
625
|
+ },
|
|
|
626
|
+ treeHandleCheckChange: function (data, checked, indeterminate) {
|
|
|
627
|
+ if(checked) {
|
|
|
628
|
+ this.permIds.push(data.permissionId);
|
|
|
629
|
+ }else {
|
|
|
630
|
+ this.permIds.splice(this.permIds.contains(data.permissionId),1);
|
|
|
631
|
+ }
|
|
|
632
|
+ console.log(data, checked, indeterminate);
|
|
|
633
|
+
|
|
|
634
|
+ },
|
|
|
635
|
+ uniteParentSame(id,treeStatus){//当子节点全为未选中时父节点也变为未选中状态
|
|
|
636
|
+ let node = this.$refs.tree.getNode(permissionId);//获取当前节点的节点树
|
|
|
637
|
+ if (node.parent !== null && node.parent !== undefined) {
|
|
|
638
|
+ let parentNode = node.parent.data;//获取当前节点的父节点树
|
|
|
639
|
+ if (parentNode != undefined){//判断父节点是否存在
|
|
|
640
|
+ for (let i = 0; i < parentNode.children.length; i++) {
|
|
|
641
|
+ let checkedKeys = this.$refs.tree.getCheckedKeys();
|
|
|
642
|
+ let hafCheckedKeys = this.$refs.tree.getHalfCheckedKeys();
|
|
|
643
|
+ let selectNodes = checkedKeys.concat(hafCheckedKeys);//获取已选择树节点
|
|
|
644
|
+ let selected = selectNodes.indexOf(parentNode.children[i].permissionId); // -1当前节点的同级节点是否全部未选中
|
|
|
645
|
+ if (selected !== -1){
|
|
|
646
|
+ return;
|
|
|
647
|
+ }
|
|
|
648
|
+ }
|
|
|
649
|
+ }else {
|
|
|
650
|
+ return;
|
|
|
651
|
+ }
|
|
|
652
|
+ this.$refs.tree.setChecked(parentNode.permissionId, false);//修改节点为未选择
|
|
|
653
|
+ if(node.level>2){//判断是否是最上级节点
|
|
|
654
|
+ this.uniteParentSame(parentNode.permissionId,treeStatus)
|
|
|
655
|
+ }
|
|
|
656
|
+ }else {
|
|
|
657
|
+ return;
|
|
|
658
|
+ }
|
|
|
659
|
+ },
|
|
|
660
|
+
|
|
|
661
|
+ // 统一处理子节点为相同的勾选状态
|
|
|
662
|
+ uniteChildSame(treeList, isSelected){
|
|
|
663
|
+ this.$refs.tree.setChecked(treeList.permissionId, isSelected);
|
|
|
664
|
+ if (treeList.children !== undefined){
|
|
|
665
|
+ for (let i = 0; i < treeList.children.length; i++) {
|
|
|
666
|
+ this.uniteChildSame(treeList.children[i], isSelected)
|
|
|
667
|
+ }
|
|
|
668
|
+ }
|
|
|
669
|
+ },
|
|
|
670
|
+ // 统一处理父节点为选中
|
|
|
671
|
+ selectedParent(currentObj){
|
|
|
672
|
+ let currentNode = this.$refs.tree.getNode(currentObj);
|
|
|
673
|
+ if (currentNode.parent.key !== undefined) {
|
|
|
674
|
+ this.$refs.tree.setChecked(currentNode.parent, true);
|
|
|
675
|
+ this.selectedParent(currentNode.parent)
|
|
|
676
|
+ }
|
|
|
677
|
+ },
|
|
|
678
|
+ clickDeal: function (currentObj, treeStatus){
|
|
|
679
|
+ // 用于:父子节点严格互不关联时,父节点勾选变化时通知子节点同步变化,实现单向关联。
|
|
|
680
|
+ let selected = treeStatus.checkedKeys.indexOf(currentObj.permissionId); // -1未选中
|
|
|
681
|
+ // 选中
|
|
|
682
|
+ if (selected !== -1) {
|
|
|
683
|
+ // 子节点只要被选中父节点就被选中
|
|
|
684
|
+ // this.selectedParent(currentObj);
|
|
|
685
|
+ // 统一处理子节点为相同的勾选状态
|
|
|
686
|
+ this.uniteChildSame(currentObj, true)
|
|
|
687
|
+ } else {
|
|
|
688
|
+ // 未选中 处理子节点全部未选中
|
|
|
689
|
+ if (currentObj.children !== undefined){
|
|
|
690
|
+ if (currentObj.children.length !== 0) {
|
|
|
691
|
+ this.uniteChildSame(currentObj, false)
|
|
|
692
|
+ }
|
|
|
693
|
+ //放开时为当子节点全为未选中时父节点也变为未选中状态 注释后就是父节点不和子节点强制绑定
|
|
|
694
|
+ // this.uniteParentSame(currentObj.id,treeStatus)//当子节点全为未选中时父节点也变为未选中状态
|
|
|
695
|
+ }
|
|
|
696
|
+ // else {
|
|
|
697
|
+ // this.uniteParentSame(currentObj.id,treeStatus)
|
|
|
698
|
+ // }
|
|
|
699
|
+ }
|
|
|
700
|
+ }
|
|
|
701
|
+ },
|
|
|
702
|
+ mounted() {
|
|
|
703
|
+ this.getRoles();
|
|
|
704
|
+ let _this = this;
|
|
|
705
|
+ document.onkeydown = function (e) {
|
|
|
706
|
+ let key = window.event.keyCode;
|
|
|
707
|
+ if (key == 13) {
|
|
|
708
|
+ _this.getRoles();
|
|
|
709
|
+ }
|
|
|
710
|
+ };
|
|
|
711
|
+ this.isExpansion=true;
|
|
|
712
|
+ }
|
|
|
713
|
+ }
|
|
|
714
|
+
|
|
|
715
|
+</script>
|
|
|
716
|
+
|
|
|
717
|
+<style>
|
|
|
718
|
+
|
|
|
719
|
+</style>
|
|
|
720
|
+
|
|
|
721
|
+<style lang="scss">
|
|
|
722
|
+ .grid-content {
|
|
|
723
|
+ height: 36px;
|
|
|
724
|
+ line-height: 36px;
|
|
|
725
|
+ }
|
|
|
726
|
+ .toobar_analysis{
|
|
|
727
|
+ padding-top: 0;
|
|
|
728
|
+ .el-col{
|
|
|
729
|
+ margin-right: 0;
|
|
|
730
|
+ }
|
|
|
731
|
+ .analysis_title{
|
|
|
732
|
+ color: #a6b6c6;
|
|
|
733
|
+ font-size: 12px;
|
|
|
734
|
+ height: 34px;
|
|
|
735
|
+ line-height: 34px;
|
|
|
736
|
+ }
|
|
|
737
|
+ .analysis_text{
|
|
|
738
|
+ color: #5473E8;
|
|
|
739
|
+ font-size: 16px;
|
|
|
740
|
+ height: 16px;
|
|
|
741
|
+ line-height: 16px;
|
|
|
742
|
+ }
|
|
|
743
|
+ .el-divider--vertical{
|
|
|
744
|
+ height:2em;
|
|
|
745
|
+ }
|
|
|
746
|
+ }
|
|
|
747
|
+
|
|
|
748
|
+</style>
|
|
|
749
|
+<style scoped>
|
|
|
750
|
+ .my-text-area .prepand{
|
|
|
751
|
+ float: left;
|
|
|
752
|
+ width:89px;
|
|
|
753
|
+ height: 28px;
|
|
|
754
|
+ font-size: 12px;
|
|
|
755
|
+ line-height: 28px;
|
|
|
756
|
+ }
|
|
|
757
|
+</style>
|
|
|
758
|
+<style>
|
|
|
759
|
+ .my-text-area .el-input__inner{
|
|
|
760
|
+ min-height: 28px;
|
|
|
761
|
+ height: 28px;
|
|
|
762
|
+ border-bottom-left-radius: 0;
|
|
|
763
|
+ border-top-left-radius: 0;
|
|
|
764
|
+ }
|
|
|
765
|
+</style> |