leisure-core 0.6.87 → 0.6.89

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/index.js CHANGED
@@ -47,6 +47,10 @@ import LeButtonAttach from "./le-button-attach/index.js";
47
47
  import LeSelectMulti from "./le-select-multi/index.js";
48
48
  import LeUploadTable from "./le-upload-table/index.js";
49
49
  import LeReport from "./le-report/index.js";
50
+ import LeArea from "./le-area/index.js";
51
+ import LeMenu from "./le-menu/index.js";
52
+ import LeRole from "./le-role/index.js";
53
+ import LeRoleUser from "./le-role-user/index.js";
50
54
 
51
55
  const components = [
52
56
  LeButton,
@@ -92,6 +96,10 @@ const components = [
92
96
  LeSelectMulti,
93
97
  LeUploadTable,
94
98
  LeReport,
99
+ LeArea,
100
+ LeMenu,
101
+ LeRole,
102
+ LeRoleUser,
95
103
  ];
96
104
 
97
105
  const install = function (Vue) {
@@ -202,4 +210,8 @@ export default {
202
210
  LeSelectMulti,
203
211
  LeUploadTable,
204
212
  LeReport,
213
+ LeArea,
214
+ LeMenu,
215
+ LeRole,
216
+ LeRoleUser,
205
217
  };
@@ -0,0 +1,7 @@
1
+ import LeArea from "./src/main.vue";
2
+
3
+ LeArea.install = function (Vue) {
4
+ Vue.component(LeArea.name, LeArea);
5
+ };
6
+
7
+ export default LeArea;
@@ -0,0 +1,112 @@
1
+ <template>
2
+ <el-cascader
3
+ v-model="value"
4
+ v-bind="$attrs"
5
+ v-on="$listeners"
6
+ clearable
7
+ :ref="elcascader"
8
+ :props="props"
9
+ @change="handleChange"
10
+ ></el-cascader>
11
+ </template>
12
+ <script>
13
+ import { getAreas } from "@/api/system-area.js";
14
+ export default {
15
+ name: "le-area",
16
+ props: {
17
+ level: {
18
+ type: [String, Number],
19
+ default: "2",
20
+ },
21
+ initCode: {
22
+ type: [String, Number],
23
+ default: "0",
24
+ },
25
+ isAny: {
26
+ type: Boolean,
27
+ default: false,
28
+ },
29
+ initArea: {
30
+ type: Array,
31
+ default: () => [],
32
+ },
33
+ elcascader: {
34
+ type: String,
35
+ default: "",
36
+ },
37
+ },
38
+ data() {
39
+ return {
40
+ value: [],
41
+ props: {
42
+ label: "name",
43
+ value: "code",
44
+ checkStrictly: false,
45
+ lazy: true,
46
+ lazyLoad: this.LoadData,
47
+ },
48
+ };
49
+ },
50
+ watch: {
51
+ isAny: {
52
+ handler(val) {
53
+ this.props.checkStrictly = val;
54
+ },
55
+ immediate: true,
56
+ },
57
+ initArea: {
58
+ handler(val) {
59
+ this.value = val;
60
+ },
61
+ immediate: true,
62
+ deep: true,
63
+ },
64
+ },
65
+
66
+ mounted() {
67
+ if (this.initArea && this.initArea.length > 0) {
68
+ this.value = this.initArea;
69
+ }
70
+ },
71
+ methods: {
72
+ setInitArea(initArea) {
73
+ this.value = initArea;
74
+ },
75
+ clearInitArea() {
76
+ this.value = [];
77
+ },
78
+ LoadData(node, resolve) {
79
+ let nodes = [];
80
+ let { level } = node;
81
+ let param = {};
82
+ param.pcode = level == 0 ? this.initCode : node.value;
83
+ getAreas(param).then((res) => {
84
+ nodes = res.data.data;
85
+ nodes.forEach((item) => {
86
+ item.leaf = item.type == this.level ? true : false;
87
+ });
88
+ resolve(nodes);
89
+ });
90
+ },
91
+ handleChange(currentValue) {
92
+ let selectValue = {};
93
+ selectValue.code = currentValue;
94
+ if (!selectValue.code || selectValue.code.length <= 0) return;
95
+ let cascader = this.$refs[this.elcascader];
96
+ if (cascader) {
97
+ const nodes = cascader.getCheckedNodes();
98
+ if (nodes && nodes.length > 0) {
99
+ console.log(nodes[0].pathLabels);
100
+ const labels = nodes[0].pathLabels;
101
+ selectValue.name = labels.join("");
102
+ this.$emit("areaChange", selectValue);
103
+ } else {
104
+ console.log("area control node 不存:");
105
+ }
106
+ } else {
107
+ console.log("area control err:", "elcascader ref 不存在");
108
+ }
109
+ },
110
+ },
111
+ };
112
+ </script>
@@ -67,13 +67,13 @@
67
67
  <slot name="rowBtnStand" :scope="scope">
68
68
  <le-button
69
69
  @click="editItem(scope.row)"
70
- v-if="disBtn === 'edit'"
70
+ v-if="getBtnType(scope.row) === 'edit'"
71
71
  >
72
72
  {{ editBtnText }}</le-button
73
73
  >
74
74
  <le-button
75
75
  @click="detail(scope.row)"
76
- v-if="disBtn === 'detail'"
76
+ v-if="getBtnType(scope.row) === 'detail'"
77
77
  >
78
78
  {{ detailBtnText }}</le-button
79
79
  >
@@ -193,7 +193,7 @@ export default {
193
193
  default: "标题",
194
194
  },
195
195
  disBtn: {
196
- type: String,
196
+ type: [String, Function],
197
197
  default: "edit",
198
198
  },
199
199
  showChecked: {
@@ -373,6 +373,12 @@ export default {
373
373
  this.getList();
374
374
  });
375
375
  },
376
+ getBtnType(row) {
377
+ if (typeof this.disBtn === "function") {
378
+ return this.disBtn(row); // 调用父组件传入的函数,传入当前行数据
379
+ }
380
+ return this.disBtn; // 兼容旧的字符串写法
381
+ },
376
382
  customItem(rowData) {
377
383
  this.handleStatus = 2;
378
384
  if (rowData) {
@@ -0,0 +1,7 @@
1
+ import LeMenu from "./src/main.vue";
2
+
3
+ LeMenu.install = function (Vue) {
4
+ Vue.component(LeMenu.name, LeMenu);
5
+ };
6
+
7
+ export default LeMenu;
@@ -0,0 +1,248 @@
1
+ <template>
2
+ <div class="le-menu-mainClass">
3
+ <div class="titleClass">角色:{{ roleInfo.roleName }}的功能菜单</div>
4
+ <el-tree
5
+ :data="menus"
6
+ ref="elTree"
7
+ show-checkbox
8
+ node-key="id"
9
+ :props="props"
10
+ >
11
+ <span class="custom-tree-node" slot-scope="{ node, data }">
12
+ <span>{{ node.label }}</span>
13
+ <span v-if="!data.children && data.btns && data.btns.length > 0">
14
+ <el-button
15
+ type="text"
16
+ size="mini"
17
+ @click="() => buttonPermission(data)"
18
+ >
19
+ 页面按钮
20
+ </el-button>
21
+ </span>
22
+ </span>
23
+ </el-tree>
24
+ <div class="footerClass">
25
+ <el-button @click="cancel()">取 消</el-button>
26
+ <el-button type="primary" @click="saveAll">保 存</el-button>
27
+ </div>
28
+ <div>
29
+ <el-dialog
30
+ width="50%"
31
+ title="页面按钮"
32
+ append-to-body
33
+ :visible.sync="showDialog"
34
+ :close-on-click-modal="true"
35
+ >
36
+ <el-form>
37
+ <el-checkbox-group v-model="checkBtnList">
38
+ <el-checkbox
39
+ v-for="item in btnsList"
40
+ :label="item.id"
41
+ :key="item.id"
42
+ >{{ item.name }}</el-checkbox
43
+ >
44
+ </el-checkbox-group>
45
+ </el-form>
46
+ <span slot="footer" class="dialog-footer">
47
+ <el-button @click="closePageButton()">关 闭</el-button>
48
+ <el-button type="primary" @click="savePageBtn()">保 存</el-button>
49
+ </span>
50
+ </el-dialog>
51
+ </div>
52
+ </div>
53
+ </template>
54
+ <script>
55
+ import { menuRoleList } from "@/api/menu";
56
+ import { batchAddRoleMenu, listRoleMenu } from "@/api/role";
57
+ export default {
58
+ name: "le-menu",
59
+ props: {
60
+ roleInfo: {
61
+ type: Object,
62
+ default: () => {},
63
+ },
64
+ },
65
+ data() {
66
+ return {
67
+ props: {
68
+ label: "title",
69
+ btns: "btns",
70
+ children: "children",
71
+ },
72
+ menus: [],
73
+ showDialog: false,
74
+ checkBtnList: [], //当前选择的按钮
75
+ btnsList: [], //按钮列表
76
+ };
77
+ },
78
+ mounted() {
79
+ this.getMenus();
80
+ },
81
+ methods: {
82
+ fillCheckboxStatus() {
83
+ this.userRoleList = [];
84
+ let param = {};
85
+ param.rid = this.roleInfo.roleId;
86
+ listRoleMenu(param).then((res) => {
87
+ let roleMenus = res.data.data;
88
+ if (roleMenus != undefined && roleMenus.length > 0) {
89
+ let selectKeys = roleMenus.map(function (item) {
90
+ return item.mid;
91
+ });
92
+ this.$refs.elTree.setCheckedKeys(selectKeys, false);
93
+ }
94
+ });
95
+ },
96
+ cancel() {
97
+ this.$emit("close");
98
+ },
99
+ buttonPermission(data) {
100
+ this.btnsList = [];
101
+ this.checkBtnList = [];
102
+ let btns = data.btns;
103
+ if (btns && btns.length > 0) {
104
+ let json = JSON.parse(btns);
105
+ json.forEach((btn) => {
106
+ if (btn && btn.permission && btn.permission == "ok") {
107
+ if (btn.id && btn.id.length > 0) {
108
+ if (!this.checkBtnList.includes(btn.id)) {
109
+ this.checkBtnList.push(btn.id);
110
+ }
111
+ }
112
+ }
113
+ });
114
+ this.btnsList = json;
115
+ this.showDialog = true;
116
+ }
117
+ },
118
+ handleMenuCheckChange(data, checked, indeterminate) {
119
+ // if (checked) {
120
+ // const childes = data.children ?? [];
121
+ // if (childes.length == 0) {
122
+ // let btns = data.btns;
123
+ // if (btns && btns.length > 0) {
124
+ // let json = JSON.parse(btns);
125
+ // json.forEach((btn) => {
126
+ // if (btn && btn.effect && btn.effect == "ok") {
127
+ // this.checkBtnList.push(btn.name);
128
+ // }
129
+ // });
130
+ // this.btnsList = json;
131
+ // this.showDialog = true;
132
+ // }
133
+ // }
134
+ // }
135
+ },
136
+ closePageButton() {
137
+ this.showDialog = false;
138
+ },
139
+ savePageBtn() {
140
+ let btns = this.btnsList;
141
+ if (btns && btns.length > 0) {
142
+ btns.forEach((btn) => {
143
+ if (this.checkBtnList.includes(btn.id)) {
144
+ btn.permission = "ok"; //标识有权限
145
+ } else {
146
+ btn.permission = "no";
147
+ }
148
+ });
149
+ }
150
+ this.$refs.elTree.getCurrentNode().btns = JSON.stringify(btns);
151
+ this.save();
152
+ this.closePageButton();
153
+ },
154
+ save() {
155
+ return new Promise((reslove, reject) => {
156
+ let nodes = this.$refs.elTree.getCheckedNodes(false);
157
+ let tops = this.$refs.elTree.getHalfCheckedNodes();
158
+ let params = new Array();
159
+ if (nodes != undefined && nodes.length > 0) {
160
+ nodes.forEach((node) => {
161
+ let param = {};
162
+ param.mid = node.id;
163
+ param.rid = this.roleInfo.roleId;
164
+ param.istop = 0;
165
+ param.btns = node.btns;
166
+ param.control = node.control;
167
+ params.push(param);
168
+ });
169
+ if (tops != undefined && tops.length > 0) {
170
+ tops.forEach((top) => {
171
+ let param = {};
172
+ param.mid = top.id;
173
+ param.rid = this.roleInfo.roleId;
174
+ param.istop = 1;
175
+ param.btns = top.btns;
176
+ param.control = top.control;
177
+ params.push(param);
178
+ });
179
+ }
180
+ batchAddRoleMenu(params).then(() => {
181
+ this.$message.success("功能菜单定义成功");
182
+ reslove();
183
+ });
184
+ } else {
185
+ let param = {};
186
+ param.rid = this.roleInfo.roleId;
187
+ params.push(param);
188
+ batchAddRoleMenu(params).then(() => {
189
+ this.$message.success("功能菜单定义成功");
190
+ reslove();
191
+ });
192
+ }
193
+ });
194
+ },
195
+ saveAll() {
196
+ this.save().then(() => {});
197
+ },
198
+ getMenus() {
199
+ let param = {};
200
+ param.rid = this.roleInfo.roleId;
201
+ menuRoleList(param).then((res) => {
202
+ let menus = res.data.data;
203
+ menus = menus.filter((item) => {
204
+ // if (item.children) {
205
+ // item.children = item.children.filter((child) => {
206
+ // return child.isHide == 0;
207
+ // });
208
+ // }
209
+ return item;
210
+ });
211
+ this.menus = menus;
212
+ this.fillCheckboxStatus();
213
+ });
214
+ },
215
+ },
216
+ };
217
+ </script>
218
+ <style lang="scss" scoped>
219
+ .le-menu-mainClass {
220
+ display: flex;
221
+ display: -webkit-flex;
222
+ flex-direction: column;
223
+ height: calc(100vh - 100px);
224
+ overflow: auto;
225
+
226
+ .titleClass {
227
+ text-align: center;
228
+ font-size: 16px;
229
+ font-weight: bold;
230
+ margin-bottom: 5px;
231
+ }
232
+
233
+ .custom-tree-node {
234
+ flex: 1;
235
+ display: flex;
236
+ align-items: center;
237
+ justify-content: space-between;
238
+ font-size: 14px;
239
+ padding-right: 8px;
240
+ text-align: center;
241
+ }
242
+
243
+ .footerClass {
244
+ text-align: center;
245
+ margin-top: 5px;
246
+ }
247
+ }
248
+ </style>
@@ -0,0 +1,7 @@
1
+ import LeRole from "./src/main.vue";
2
+
3
+ LeRole.install = function (Vue) {
4
+ Vue.component(LeRole.name, LeRole);
5
+ };
6
+
7
+ export default LeRole;
@@ -0,0 +1,183 @@
1
+ <template>
2
+ <div class="le-role-container">
3
+ <el-form :inline="true" class="demo-form-inline">
4
+ <el-form-item>
5
+ <le-button type="primary" @click="addRole()">新建角色</le-button>
6
+ </el-form-item>
7
+ </el-form>
8
+ <el-table
9
+ :data="tableData"
10
+ ref="eltablemain"
11
+ border
12
+ row-key="id"
13
+ stripe
14
+ :max-height="elTableMaxHeight"
15
+ style="width: 100%"
16
+ >
17
+ <el-table-column prop="name" label="名称" width="260"> </el-table-column>
18
+ <el-table-column prop="note" label="备注"> </el-table-column>
19
+ <el-table-column label="操作" align="center" width="360" row>
20
+ <template slot-scope="scope">
21
+ <le-button text="编辑" @click="openEditWindow(scope.row)"></le-button>
22
+ <le-button-msg
23
+ @click="del(scope.row.id)"
24
+ v-if="scope.row.is_can_delete !== 0"
25
+ >删除</le-button-msg
26
+ >
27
+ <le-button
28
+ text="菜单"
29
+ @click="openMenuWindow(scope.row)"
30
+ style="margin-left: 10px"
31
+ ></le-button>
32
+ <le-button
33
+ text="用户列表"
34
+ @click="openUserWindow(scope.row)"
35
+ style="margin-left: 10px"
36
+ ></le-button>
37
+ </template>
38
+ </el-table-column>
39
+ </el-table>
40
+ <le-dialog-container
41
+ :showDialog="showMenu"
42
+ width="60%"
43
+ title="功能菜单"
44
+ :showCloseBtnTop="true"
45
+ @close="closeMenuDialog"
46
+ >
47
+ <le-menu @close="closeMenuDialog" :roleInfo="roleInfo"></le-menu>
48
+ </le-dialog-container>
49
+ <le-dialog-container
50
+ title="角色"
51
+ width="60%"
52
+ :showCloseBtnTop="true"
53
+ :showDialog="showEdit"
54
+ @close="closeEditDialog"
55
+ >
56
+ <le-role-sub
57
+ @close="closeEditDialog"
58
+ @rowRefresh="list"
59
+ :rowitem="currentRow"
60
+ v-if="showEdit"
61
+ ></le-role-sub>
62
+ </le-dialog-container>
63
+ <le-dialog-container
64
+ :title="curRoleName"
65
+ :showCloseBtnTop="true"
66
+ :showDialog="showUsers"
67
+ @close="closeUserDialog"
68
+ >
69
+ <el-table
70
+ :data="userlist"
71
+ border
72
+ row-key="id"
73
+ tooltip-effect="dark"
74
+ style="width: 100%"
75
+ v-if="showUsers"
76
+ >
77
+ <el-table-column prop="account" label="账号" align="center">
78
+ </el-table-column>
79
+ <el-table-column prop="nick" label="昵称" align="center">
80
+ </el-table-column>
81
+ </el-table>
82
+ </le-dialog-container>
83
+ </div>
84
+ </template>
85
+ <script>
86
+ import { roleDel, roleList, listUserOfRole } from "@/api/role";
87
+ import leMixins from "leisure-core/le-libs/mixins/main";
88
+ import LeRoleSub from "./sub.vue";
89
+ export default {
90
+ name: "le-role",
91
+ mixins: [leMixins],
92
+ components: {
93
+ LeRoleSub,
94
+ },
95
+ data() {
96
+ return {
97
+ tableData: [],
98
+ showUsers: false,
99
+ userlist: [],
100
+ curRoleName: "",
101
+ currentRow: {},
102
+ showEdit: false,
103
+ showMenu: false,
104
+ roleInfo: {},
105
+ };
106
+ },
107
+ mounted() {
108
+ this.list();
109
+ },
110
+ computed: {},
111
+ methods: {
112
+ list() {
113
+ let param = {};
114
+ roleList(param).then((res) => {
115
+ this.tableData = res.data.data;
116
+ });
117
+ },
118
+ del(id) {
119
+ let param = { id: id };
120
+ roleDel(param).then((response) => {
121
+ this.list();
122
+ this.$message.success(response.data.info, this);
123
+ });
124
+ },
125
+ addRole() {
126
+ this.currentRow = {};
127
+ this.showEdit = true;
128
+ },
129
+ openEditWindow(item) {
130
+ // let routeData = {
131
+ this.currentRow = item;
132
+ this.showEdit = true;
133
+ },
134
+ closeEditDialog() {
135
+ this.showEdit = false;
136
+ this.list();
137
+ },
138
+ openMenuWindow(item) {
139
+ // this.roleInfo = JSON.parse(JSON.stringify(item));
140
+ this.roleInfo.roleId = item.id;
141
+ this.roleInfo.roleName = item.name;
142
+ this.showMenu = true;
143
+ // let routeData = {
144
+ // name: "rolemenu",
145
+ // params: JSON.parse(JSON.stringify(item)),
146
+ // };
147
+ // this.$router.push(routeData);
148
+ },
149
+ closeMenuDialog() {
150
+ this.showMenu = false;
151
+ },
152
+ openUserWindow(item) {
153
+ let param = {};
154
+ if (item && item.id) {
155
+ param.rid = item.id;
156
+ param.pageNo = 1;
157
+ listUserOfRole(param)
158
+ .then((res) => {
159
+ if (res && res.data && res.data.data) {
160
+ this.userlist = res.data.data;
161
+ this.curRoleName = item.name;
162
+ this.showUsers = true;
163
+ } else {
164
+ this.$message.info("暂无数据");
165
+ }
166
+ })
167
+ .catch((err) => {
168
+ console.log("用户弹窗出错", err);
169
+ });
170
+ } else {
171
+ this.$message.error("参数不正确");
172
+ }
173
+ },
174
+ closeUserDialog() {
175
+ this.showUsers = false;
176
+ },
177
+ },
178
+ };
179
+ </script>
180
+ <style lang="scss" scoped>
181
+ .le-role-container {
182
+ }
183
+ </style>
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <el-form id="form" ref="form" :model="form" :rules="rules" label-width="80px">
3
+ <el-form-item label="名称" prop="name">
4
+ <el-input v-model="form.name"></el-input>
5
+ </el-form-item>
6
+ <el-form-item label="备注" prop="note">
7
+ <el-input v-model="form.note"></el-input>
8
+ </el-form-item>
9
+ <el-form-item>
10
+ <el-button type="primary" @click="onSubmit()">保存</el-button>
11
+ <el-button @click="close()">取消</el-button>
12
+ </el-form-item>
13
+ </el-form>
14
+ </template>
15
+ <script>
16
+ import { roleCreate, roleEdit } from "@/api/role";
17
+ export default {
18
+ name: "le-roles-sub",
19
+ props: {
20
+ rowitem: {},
21
+ },
22
+ data() {
23
+ return {
24
+ form: {
25
+ id: "",
26
+ name: "",
27
+ note: "",
28
+ },
29
+ rules: {
30
+ name: [
31
+ { required: true, message: "请输入角色名称", trigger: "blur" },
32
+ {
33
+ min: 1,
34
+ max: 30,
35
+ message: "长度在 1 到 30 个字符",
36
+ trigger: "blur",
37
+ },
38
+ ],
39
+ },
40
+ };
41
+ },
42
+ watch: {
43
+ rowitem: {
44
+ handler(newValue) {
45
+ this.form = newValue;
46
+ },
47
+ immediate: true,
48
+ },
49
+ },
50
+ mounted() {},
51
+ methods: {
52
+ onSubmit() {
53
+ this.$refs["form"].validate((valid) => {
54
+ if (valid) {
55
+ let param = JSON.parse(JSON.stringify(this.form));
56
+ if (param.id && param.id.length > 0) {
57
+ roleEdit(param).then((res) => {
58
+ this.close();
59
+ this.$message.success(res.data.info);
60
+ this.$refs["form"].resetFields();
61
+ });
62
+ } else {
63
+ roleCreate(param).then((response) => {
64
+ this.close();
65
+ this.$message.success(response.data.info);
66
+ this.$refs["form"].resetFields();
67
+ });
68
+ }
69
+ } else {
70
+ return false;
71
+ }
72
+ });
73
+ },
74
+ close() {
75
+ this.$emit("close");
76
+ },
77
+ },
78
+ };
79
+ </script>
@@ -0,0 +1,7 @@
1
+ import LeRoleUser from "./src/main.vue";
2
+
3
+ LeRoleUser.install = function (Vue) {
4
+ Vue.component(LeRoleUser.name, LeRoleUser);
5
+ };
6
+
7
+ export default LeRoleUser;
@@ -0,0 +1,160 @@
1
+ <template>
2
+ <div class="le-role-user-container">
3
+ <el-form :inline="true" :model="searchData" @submit.native.prevent>
4
+ <el-form-item label="账号">
5
+ <le-input v-model="searchData.account" placeholder="账号"></le-input>
6
+ </el-form-item>
7
+ <el-form-item>
8
+ <le-button type="primary" @click="userList">查询</le-button>
9
+ </el-form-item>
10
+ </el-form>
11
+ <el-table :data="userData" border row-key="id" stripe style="width: 100%">
12
+ <el-table-column prop="account" label="账号" width="150">
13
+ </el-table-column>
14
+ <el-table-column prop="nick" label="昵称"> </el-table-column>
15
+ <el-table-column
16
+ prop="cdate"
17
+ label="时间"
18
+ width="150"
19
+ :formatter="dateFormat"
20
+ >
21
+ </el-table-column>
22
+
23
+ <el-table-column prop="note" width="230" label="备注"> </el-table-column>
24
+ <el-table-column
25
+ fixed="right"
26
+ label="操作"
27
+ align="center"
28
+ width="150"
29
+ row
30
+ >
31
+ <template slot-scope="scope">
32
+ <el-button
33
+ type="primary"
34
+ size="small"
35
+ @click="openEditWindow(scope.row, 2)"
36
+ >角色管理</el-button
37
+ >
38
+ </template>
39
+ </el-table-column>
40
+ </el-table>
41
+ <div style="text-align: center; margin-top: 30px">
42
+ <el-pagination
43
+ background
44
+ layout="prev, pager, next"
45
+ :total="searchData.total"
46
+ :page-size="10"
47
+ @current-change="current_change"
48
+ >
49
+ </el-pagination>
50
+ </div>
51
+ <div>
52
+ <el-dialog
53
+ v-el-drag-dialog
54
+ title="角色列表"
55
+ ref="elDialog"
56
+ :visible.sync="isShowRoleList"
57
+ width="70%"
58
+ :close-on-click-modal="isCloseByModal"
59
+ :show-close="isShowClose"
60
+ :open="openDialog()"
61
+ >
62
+ <le-role-user-sub
63
+ ref="roleComponent"
64
+ @loadFinished="roleLoadFinished"
65
+ @saveAfter="roleSaveAfter"
66
+ ></le-role-user-sub>
67
+ <div slot="footer">
68
+ <el-button @click="cancel()">取 消</el-button>
69
+ <el-button type="primary" @click="save">保 存</el-button>
70
+ </div>
71
+ </el-dialog>
72
+ </div>
73
+ </div>
74
+ </template>
75
+ <script>
76
+ import { listUserBg, roleList } from "@/api/role";
77
+ import LeRoleUserSub from "./sub.vue";
78
+ import moment from "moment";
79
+ export default {
80
+ name: "le-role-user",
81
+ components: {
82
+ LeRoleUserSub,
83
+ },
84
+ data() {
85
+ return {
86
+ userData: [],
87
+ isCloseByModal: false,
88
+ isShowClose: false,
89
+ isShowRoleList: false,
90
+ currentItem: {},
91
+ searchData: {
92
+ account: "",
93
+ pageNo: 1,
94
+ total: 1,
95
+ },
96
+ };
97
+ },
98
+ mounted() {
99
+ this.userList();
100
+ },
101
+ methods: {
102
+ roleList() {
103
+ roleList().then((res) => {
104
+ this.roleData = res.data.data;
105
+ });
106
+ },
107
+ userList() {
108
+ let params = {};
109
+ if (this.searchData.account.length > 0) {
110
+ params.account = this.searchData.account;
111
+ }
112
+ params.pageNo = this.searchData.pageNo;
113
+ listUserBg(params).then((res) => {
114
+ this.userData = res.data.data.list;
115
+ this.searchData.total = res.data.data.count;
116
+ });
117
+ },
118
+ current_change(currentPage) {
119
+ this.searchData.pageNo = currentPage;
120
+ this.userList();
121
+ },
122
+ roleLoadFinished() {
123
+ if (this.isShowRoleList) {
124
+ if (Object.keys(this.currentItem).length !== 0) {
125
+ let uid = this.currentItem.id;
126
+ this.$refs.roleComponent.fillCheckboxStatus(uid);
127
+ }
128
+ }
129
+ },
130
+ openEditWindow(item) {
131
+ this.currentItem = item;
132
+ this.isShowRoleList = true;
133
+ },
134
+ dateFormat(row, column, data) {
135
+ return moment.unix(data).format("YYYY-MM-DD HH:mm");
136
+ },
137
+ openDialog() {
138
+ if (this.isShowRoleList && this.$refs.roleComponent != undefined) {
139
+ this.$refs.roleComponent.roleList();
140
+ }
141
+ },
142
+ cancel() {
143
+ this.$refs.elDialog.close();
144
+ this.isShowRoleList = false;
145
+ },
146
+ save() {
147
+ let uid = this.currentItem.id;
148
+ this.$refs.roleComponent.saveUserRole(uid);
149
+ },
150
+ roleSaveAfter() {
151
+ this.$refs.elDialog.close();
152
+ this.isShowRoleList = false;
153
+ },
154
+ },
155
+ };
156
+ </script>
157
+ <style lang="scss" scoped>
158
+ .le-role-user-container {
159
+ }
160
+ </style>
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <div class="le-role-user-sub-container">
3
+ <el-table
4
+ :data="roleData"
5
+ border
6
+ row-key="id"
7
+ ref="tblRole"
8
+ tooltip-effect="dark"
9
+ style="width: 100%"
10
+ @selection-change="handleSelectionChange"
11
+ >
12
+ <el-table-column type="selection" width="55"> </el-table-column>
13
+ <el-table-column prop="name" label="角色名称"> </el-table-column>
14
+ </el-table>
15
+ </div>
16
+ </template>
17
+ <script>
18
+ import { roleList, listRoleUser, batchAddRoleUser } from "@/api/role";
19
+ export default {
20
+ name: "le-role-user-sub",
21
+ data() {
22
+ return {
23
+ roleData: [],
24
+ selectionRoles: [],
25
+ userRoleList: [],
26
+ };
27
+ },
28
+ mounted() {
29
+ this.roleList();
30
+ },
31
+ methods: {
32
+ roleList() {
33
+ let param = { cid: this.$store.getters.cid };
34
+ roleList(param).then((res) => {
35
+ this.roleData = res.data.data;
36
+ this.$emit("loadFinished");
37
+ });
38
+ },
39
+ handleSelectionChange(val) {
40
+ this.selectionRoles = val.map(function (item) {
41
+ return item.id;
42
+ });
43
+ },
44
+ saveUserRole(uid) {
45
+ let params = new Array();
46
+ if (this.selectionRoles != undefined && this.selectionRoles.length > 0) {
47
+ this.selectionRoles.forEach((rid) => {
48
+ let param = {};
49
+ param.cid = this.$store.getters.cid;
50
+ param.uid = uid;
51
+ param.rid = rid;
52
+ params.push(param);
53
+ });
54
+ batchAddRoleUser(params).then(() => {
55
+ this.$message.success("角色定义成功!");
56
+ this.$emit("saveAfter");
57
+ });
58
+ } else {
59
+ let param = {};
60
+ param.cid = this.$store.getters.cid;
61
+ param.uid = uid;
62
+ params.push(param);
63
+ batchAddRoleUser(params).then(() => {
64
+ this.$message.success("角色定义成功!");
65
+ this.$emit("saveAfter");
66
+ });
67
+ }
68
+ },
69
+ fillCheckboxStatus(uid) {
70
+ this.userRoleList = [];
71
+ let param = { cid: this.$store.getters.cid };
72
+ param.uid = uid;
73
+ listRoleUser(param).then((res) => {
74
+ this.userRoleList = res.data.data;
75
+ this.userRoleList.forEach((userRoleItem) => {
76
+ this.roleData.forEach((roleItem) => {
77
+ if (userRoleItem.rid == roleItem.id) {
78
+ this.$refs.tblRole.toggleRowSelection(roleItem, true);
79
+ }
80
+ });
81
+ });
82
+ });
83
+ },
84
+ },
85
+ };
86
+ </script>
87
+ <style lang="scss" scoped>
88
+ .le-role-user-sub-container {
89
+ }
90
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leisure-core",
3
- "version": "0.6.87",
3
+ "version": "0.6.89",
4
4
  "description": "leisure-core是京心数据基于vue2.x开发的一套后台管理系统桌面端组件库,封装了大量实用的UI控件模板,非常方便开发者快速搭建前端应用",
5
5
  "private": false,
6
6
  "author": "北方乐逍遥(zcx7878)",