xs-common-plugins 1.1.3 → 1.1.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/README.md +20 -0
- package/package.json +1 -1
- package/src/common/common.js +88 -6
- package/src/router/index.js +4 -0
- package/src/store/modules/dic.js +1 -1
- package/src/utils/getMenu.js +2 -1
- package/src/views/layout/components/Navbar.vue +42 -2
package/README.md
CHANGED
|
@@ -258,4 +258,24 @@
|
|
|
258
258
|
```
|
|
259
259
|
1.1.3
|
|
260
260
|
1. common.js 文件增加报表操作相关公用方法(查询配置信息, 查询列表数据)
|
|
261
|
+
```
|
|
262
|
+
```
|
|
263
|
+
1.1.4
|
|
264
|
+
1. common.js 增加 common.updateData() 修改数据后, 刷新列表页函数
|
|
265
|
+
2. dic 字段, 移除 '0' 字符串 0 的 参数
|
|
266
|
+
3. 移除 common.getReportList() 获取列表页数据 函数 空数据入参
|
|
267
|
+
```
|
|
268
|
+
```
|
|
269
|
+
1.1.5
|
|
270
|
+
1. common.js common.exportExcel (报表导出) 方法, 移除空条件
|
|
271
|
+
```
|
|
272
|
+
```
|
|
273
|
+
1.1.6
|
|
274
|
+
1. 增加多租户却换
|
|
275
|
+
2. 兼容相同路由跳转警告问题
|
|
276
|
+
3. common.js 增加公用方法 this.$common.dic() 用于查询字典单条/多条数据
|
|
277
|
+
```
|
|
278
|
+
```
|
|
279
|
+
1.1.7
|
|
280
|
+
1. 多余显示移除
|
|
261
281
|
```
|
package/package.json
CHANGED
package/src/common/common.js
CHANGED
|
@@ -4,6 +4,7 @@ import router from '@/router/index'
|
|
|
4
4
|
import store from '@/store/index'
|
|
5
5
|
import {OrgEnum} from '@/utils/enum'
|
|
6
6
|
import filterRules from '@/utils/filterRules'
|
|
7
|
+
import request from "xs-request";
|
|
7
8
|
|
|
8
9
|
const common = {}
|
|
9
10
|
|
|
@@ -139,15 +140,23 @@ common.updateById = (that, url, query, callBack) => {
|
|
|
139
140
|
})
|
|
140
141
|
}
|
|
141
142
|
/**
|
|
142
|
-
* 判断多条数据
|
|
143
|
-
* @param {
|
|
144
|
-
* @param {
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {
|
|
143
|
+
* 判断多条数据 返回 true/false 或者 重新拼接好的 ids []
|
|
144
|
+
* @param {Object} that 传 this
|
|
145
|
+
* @param {Array} row 要判断的数据
|
|
146
|
+
* @param {String} title 无数据/ 提示操作的 关键字
|
|
147
|
+
* @param {String} prop 默认 id 要取出数组中哪个字段汇成新数组
|
|
148
|
+
* @param {Boolean} check 默认 true 二次弹窗确认即将要做的提醒
|
|
149
|
+
*
|
|
150
|
+
* 使用场景 (列表页上批量操作数据后刷新列表页)
|
|
151
|
+
* async updateRows () {
|
|
152
|
+
* let ids = await this.$common.checkRows(this, this.selectRows, 'xxx')
|
|
153
|
+
* if(!ids) retuen
|
|
154
|
+
* this.$common.updateData(that, 'ask.xxx.xxx', {保存对象})
|
|
155
|
+
* }
|
|
147
156
|
*/
|
|
148
157
|
common.checkRows = async (that, row, title, prop = "id", check = true) => {
|
|
149
158
|
if(row.length == 0) {
|
|
150
|
-
common.message(that,
|
|
159
|
+
common.message(that, `请选择数据`, 'error');
|
|
151
160
|
return false;
|
|
152
161
|
}
|
|
153
162
|
if(check) {
|
|
@@ -157,9 +166,28 @@ common.updateById = (that, url, query, callBack) => {
|
|
|
157
166
|
} catch (error) {
|
|
158
167
|
return false
|
|
159
168
|
}
|
|
169
|
+
} else {
|
|
170
|
+
return true
|
|
160
171
|
}
|
|
161
172
|
}
|
|
162
173
|
|
|
174
|
+
/**
|
|
175
|
+
* 修改数据后, 刷新列表页
|
|
176
|
+
* @param {Object} that 传值 this
|
|
177
|
+
* @param {String} url api 地址
|
|
178
|
+
* @param {Object} query 接口参数
|
|
179
|
+
* @param {Function} callBack 接口响应成功后, 界面上自行处理返回事件, 不传, 默认执行页面 getList 方法 (刷新列表页)
|
|
180
|
+
*/
|
|
181
|
+
common.updateData = (that, url, query, callBack) => {
|
|
182
|
+
let request = common.getObject(url)
|
|
183
|
+
request(Object.assign({}, query)).then(res => {
|
|
184
|
+
if(res.code !== 0) return
|
|
185
|
+
common.message(that, res.message)
|
|
186
|
+
if(callBack) callBack(res)
|
|
187
|
+
else that.getList && that.getList()
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
|
|
163
191
|
|
|
164
192
|
/**
|
|
165
193
|
* 消息弹窗---自动消失
|
|
@@ -323,6 +351,10 @@ common.clone = (obj) => {
|
|
|
323
351
|
common.exportExcel = async (url, query, fileName = 'demo', headers = { responseType: 'arraybuffer' }) => {
|
|
324
352
|
let newQuery = JSON.parse(JSON.stringify(query))
|
|
325
353
|
delete newQuery.data
|
|
354
|
+
for (const key in newQuery) {
|
|
355
|
+
if(newQuery[key] == null || newQuery[key] === '')
|
|
356
|
+
delete newQuery[key]
|
|
357
|
+
}
|
|
326
358
|
const httpRequest = common.getObject(url)
|
|
327
359
|
const response = await httpRequest(newQuery, headers)
|
|
328
360
|
const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' })
|
|
@@ -428,6 +460,11 @@ common.getReportList = (that, url, query, callBack) => {
|
|
|
428
460
|
else {
|
|
429
461
|
let obj = Object.assign({}, that.data)
|
|
430
462
|
delete obj.data
|
|
463
|
+
// 移除空项查询条件
|
|
464
|
+
for (const key in obj) {
|
|
465
|
+
if(obj[key] == null || obj[key] === '')
|
|
466
|
+
delete obj[key]
|
|
467
|
+
}
|
|
431
468
|
newQuery = Object.assign(obj, {report: that.reportCfgVal})
|
|
432
469
|
}
|
|
433
470
|
let request = common.getObject(url)
|
|
@@ -437,4 +474,49 @@ common.getReportList = (that, url, query, callBack) => {
|
|
|
437
474
|
})
|
|
438
475
|
}
|
|
439
476
|
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* 字典表 里通过Id 查 name, 或者查询多条数据
|
|
480
|
+
* @param {Array} props ['服务名', '表名', '字段名']
|
|
481
|
+
* @param {String, Number, Array} val 值, 传入id, 或者 [id1, id2, ...]
|
|
482
|
+
*
|
|
483
|
+
* 使用案例 (异步方法)
|
|
484
|
+
* async getValue () {
|
|
485
|
+
* await this.$common.dic(['qccuser', 'Brand'], '10010')
|
|
486
|
+
* }
|
|
487
|
+
*
|
|
488
|
+
*/
|
|
489
|
+
|
|
490
|
+
common.dic = async (props, val) => {
|
|
491
|
+
let isArray = Array.isArray(val)
|
|
492
|
+
let server = props[0] || ''
|
|
493
|
+
let tableName = props[1] || ''
|
|
494
|
+
let prop = props[2] || 'name'
|
|
495
|
+
let key = server + tableName
|
|
496
|
+
if(store.getters.dic[key]) {
|
|
497
|
+
if(isArray) return await getDicVal()
|
|
498
|
+
let row = store.getters.dic[key].find(item => item.id == val)
|
|
499
|
+
if(row && (row.isNull || row[prop] === null)) { return '' }
|
|
500
|
+
if(row) return row[prop]
|
|
501
|
+
if(!row) return await getDicVal()
|
|
502
|
+
|
|
503
|
+
} else {
|
|
504
|
+
return await getDicVal()
|
|
505
|
+
}
|
|
506
|
+
async function getDicVal () {
|
|
507
|
+
let servers = props[0] || "";
|
|
508
|
+
let tableName = props[1] || "";
|
|
509
|
+
let key = servers + tableName;
|
|
510
|
+
let url = servers + "/UserAll/Search/Dic/" + tableName;
|
|
511
|
+
let res = await request.post(url, isArray ? val : [val])
|
|
512
|
+
if (res.code !== 0) return;
|
|
513
|
+
store.commit("dic/SET_ASK", { key, val: res.data });
|
|
514
|
+
if(isArray) return res.data
|
|
515
|
+
else {
|
|
516
|
+
let row = res.data.find(item => item.id == val)
|
|
517
|
+
return row ? row[prop] : ''
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
440
522
|
export default common
|
package/src/router/index.js
CHANGED
|
@@ -3,6 +3,10 @@ import VueRouter from 'vue-router'
|
|
|
3
3
|
import autoRouter from '../automatically/router'
|
|
4
4
|
Vue.use(VueRouter)
|
|
5
5
|
|
|
6
|
+
const originalPush = VueRouter.prototype.push;
|
|
7
|
+
VueRouter.prototype.push = function push(location) {
|
|
8
|
+
return originalPush.call(this, location).catch(err => err)
|
|
9
|
+
}
|
|
6
10
|
const routes = [
|
|
7
11
|
{
|
|
8
12
|
path: '/',
|
package/src/store/modules/dic.js
CHANGED
package/src/utils/getMenu.js
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
<AllSearch />
|
|
32
32
|
<div class="is-dot">
|
|
33
33
|
<el-badge
|
|
34
|
+
style="margin: 0 3px;"
|
|
34
35
|
v-if="isShowKF === 'isv' || isShowKF === 'erp'"
|
|
35
36
|
is-dot
|
|
36
37
|
class="item"
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
</el-badge>
|
|
46
47
|
</div>
|
|
47
48
|
<div>
|
|
48
|
-
<el-tag>{{
|
|
49
|
+
<el-tag style="margin: 0 3px;">{{
|
|
49
50
|
userProfile &&
|
|
50
51
|
userProfile.hasOwnProperty("real_name") &&
|
|
51
52
|
userProfile.real_name
|
|
@@ -61,6 +62,17 @@
|
|
|
61
62
|
: "--未绑定--"
|
|
62
63
|
}}
|
|
63
64
|
</el-tag>
|
|
65
|
+
</div>
|
|
66
|
+
<!-- 租户 -->
|
|
67
|
+
<div class="tenant" v-if="userProfile.TId">
|
|
68
|
+
<el-dropdown @command="changeTenant">
|
|
69
|
+
<span class="el-dropdown-link">
|
|
70
|
+
{{tenantList && tenantList[userProfile.TId]}}
|
|
71
|
+
</span>
|
|
72
|
+
<el-dropdown-menu slot="dropdown">
|
|
73
|
+
<el-dropdown-item v-for="(value, key) in tenantList" :key="key" :command="key">{{value}}</el-dropdown-item>
|
|
74
|
+
</el-dropdown-menu>
|
|
75
|
+
</el-dropdown>
|
|
64
76
|
</div>
|
|
65
77
|
<el-dropdown class="avatar-container" trigger="click">
|
|
66
78
|
<div class="avatar-wrapper">
|
|
@@ -107,7 +119,9 @@ import AllSearch from "./AllSearch";
|
|
|
107
119
|
import { getConfig } from "@/utils/global-config";
|
|
108
120
|
import { getToken, removeToken, removeLocalToken } from "@/utils/auth"; // get token from cookie
|
|
109
121
|
import ImCom from "@/components/im";
|
|
110
|
-
import { getLocalStorage } from "@/utils/localStorage";
|
|
122
|
+
import { getLocalStorage, setLocalStorage } from "@/utils/localStorage";
|
|
123
|
+
import { setToken } from "@/utils/auth"; // get token from cookie
|
|
124
|
+
import { initMenu } from '@/utils/getMenu'
|
|
111
125
|
|
|
112
126
|
export default {
|
|
113
127
|
components: {
|
|
@@ -136,6 +150,7 @@ export default {
|
|
|
136
150
|
LoginName: false,
|
|
137
151
|
isShowKF: getConfig("GROUP"),
|
|
138
152
|
defaultParentId: "887904812217cca9bc2b9adb875daf42",
|
|
153
|
+
tenantList: [], // 租户列表
|
|
139
154
|
};
|
|
140
155
|
},
|
|
141
156
|
computed: {
|
|
@@ -146,8 +161,29 @@ export default {
|
|
|
146
161
|
if (userName === "admin") {
|
|
147
162
|
this.LoginName = true;
|
|
148
163
|
}
|
|
164
|
+
if(this.userProfile.TId) this.getTenantList()
|
|
149
165
|
},
|
|
150
166
|
methods: {
|
|
167
|
+
changeTenant (id) {
|
|
168
|
+
if(id === this.userProfile.TId) return
|
|
169
|
+
this.$router.push("/home")
|
|
170
|
+
this.$ask.ucmng.api.sysmng.Tenant.SwitchTenant({clientId: getConfig('CLIENT_ID'), newTId: id}).then(res => {
|
|
171
|
+
let newuser = this.userProfile
|
|
172
|
+
newuser.TId = id
|
|
173
|
+
setLocalStorage('userProfile', newuser)
|
|
174
|
+
this.userProfile = getLocalStorage('userProfile')
|
|
175
|
+
let user = res.data
|
|
176
|
+
setToken(user.accessToken);
|
|
177
|
+
localStorage.setItem("token", user.accessToken);
|
|
178
|
+
initMenu()
|
|
179
|
+
|
|
180
|
+
})
|
|
181
|
+
},
|
|
182
|
+
getTenantList () {
|
|
183
|
+
this.$ask.ucmng.api.sysmng.Tenant.GetTenants().then(res => {
|
|
184
|
+
this.tenantList = res.data
|
|
185
|
+
})
|
|
186
|
+
},
|
|
151
187
|
toggleSideBar() {
|
|
152
188
|
this.$store.dispatch("app/toggleSideBar");
|
|
153
189
|
},
|
|
@@ -279,6 +315,10 @@ export default {
|
|
|
279
315
|
}
|
|
280
316
|
}
|
|
281
317
|
|
|
318
|
+
.tenant {
|
|
319
|
+
padding: 0 10px;
|
|
320
|
+
}
|
|
321
|
+
|
|
282
322
|
.breadcrumb-container {
|
|
283
323
|
float: left;
|
|
284
324
|
}
|