xs-common-plugins 1.2.2 → 1.2.3

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.
Files changed (56) hide show
  1. package/README.md +298 -298
  2. package/common.js +110 -110
  3. package/index.js +1 -1
  4. package/package.json +16 -16
  5. package/src/common/common.js +548 -548
  6. package/src/components/CheckBox_Cmp/index.vue +62 -62
  7. package/src/components/FormItem/index.vue +92 -92
  8. package/src/components/ReportCmp/index.vue +76 -76
  9. package/src/components/Search/index.scss +219 -219
  10. package/src/components/Search/index.vue +410 -410
  11. package/src/components/Search/product_option/index.scss +1 -1
  12. package/src/components/Search_filter/index.scss +104 -104
  13. package/src/components/TableItem/TableItem.vue +55 -55
  14. package/src/components/TextOVer/index.vue +55 -55
  15. package/src/components/UploadImg/index.vue +177 -177
  16. package/src/components/im/index.vue +155 -155
  17. package/src/components/im/pages/chatList/index.vue +45 -45
  18. package/src/components/im/pages/chatRoom/index.vue +159 -159
  19. package/src/components/xsSelect/index.vue +125 -125
  20. package/src/mixin/keepAlive.js +52 -0
  21. package/src/plugins/im/components/chat/index.scss +163 -163
  22. package/src/plugins/im/components/chat/index.vue +144 -144
  23. package/src/plugins/im/components/chat/methods.js +149 -149
  24. package/src/plugins/im/components/msg-image/index.vue +40 -40
  25. package/src/plugins/im/components/send-msg/index.scss +164 -164
  26. package/src/plugins/im/components/send-msg/index.vue +107 -107
  27. package/src/plugins/im/components/send-msg/methods.js +125 -125
  28. package/src/plugins/im/components/template-message/index.vue +76 -76
  29. package/src/plugins/im/components/without.vue +19 -19
  30. package/src/plugins/im/index.js +31 -31
  31. package/src/plugins/im/utils/services.js +625 -625
  32. package/src/plugins/index.js +60 -60
  33. package/src/plugins/row-col-cmp/index.js +20 -20
  34. package/src/router/permission.js +126 -126
  35. package/src/store/modules/dic.js +74 -74
  36. package/src/store/modules/oss.js +40 -40
  37. package/src/styles/index.scss +91 -91
  38. package/src/styles/table.scss +90 -90
  39. package/src/utils/api.js +54 -54
  40. package/src/utils/auth.js +38 -38
  41. package/src/utils/concat_batch_btns.js +88 -88
  42. package/src/utils/enum.js +150 -150
  43. package/src/utils/filter.js +5 -5
  44. package/src/utils/filterRules.js +55 -55
  45. package/src/utils/getMenu.js +82 -82
  46. package/src/utils/global_directive.js +10 -0
  47. package/src/utils/ossService.js +55 -55
  48. package/src/utils/prototype.js +46 -46
  49. package/src/utils/search.js +33 -33
  50. package/src/utils/signalR.js +24 -24
  51. package/src/views/callback/index.vue +35 -35
  52. package/src/views/home/index.vue +25 -25
  53. package/src/views/layout/components/AppMain.vue +21 -5
  54. package/src/views/layout/components/Navbar.vue +20 -13
  55. package/src/views/layout/components/TagsView/index.vue +130 -91
  56. package/src/views/slienceAuth/index.vue +42 -42
@@ -1,60 +1,60 @@
1
- import Install_config from '@modules/module.config'
2
- import { Enum, OrgEnum, EnumList } from '@/utils/enum'
3
- import utils from 'xs-component/lib/utils'
4
- import base from 'xs-component/lib/base'
5
- import api from '@/automatically/api'
6
- import Vue from 'vue'
7
- import store from '../store/index'
8
- import {request, requestApi} from 'xs-request'
9
- import ossService from '@/utils/ossService'
10
- // 以上部分为 xs-component 引入
11
- base.install(api ? api : {}) // 请求及api映射
12
-
13
- // 字典, 调用方法, 取值缓存
14
- function getDicVal (name, value) {
15
- store.dispatch('dic/GET_ASK', {props: name, value})
16
- }
17
-
18
- // 向ui组件库传值
19
- utils.install({
20
- formatUtils: {Enum, OrgEnum, EnumList, format: Install_config.format ? Install_config.format: {}}, // Install_config.format 前端自定义枚举文件导出内容
21
- dicUtils: getDicVal, // 字典工具
22
- requestUtils: request, // 发送请求工具
23
- ossUtils: ossService, // oss 图片上传
24
- })
25
-
26
-
27
- import cellCmp from '@/plugins/row-col-cmp'
28
- import ImCmp from '@/plugins/im'
29
-
30
- import apiMap from '@/utils/api'
31
-
32
- import { getConfig } from '@/utils/global-config'
33
- import { getToken } from "@/utils/auth";
34
-
35
- let clientId = getConfig('CLIENT_ID')
36
- let apis = getConfig('apis')
37
-
38
-
39
- // 获取 标识: 服务地址的映射关系
40
- function getApi (type) {
41
- let serviceObj = {} // 服务名: 服务地址 映射关系 (新版)
42
- let moduleObj = {} // 模块id: 服务地址 映射关系 (旧版)
43
- for (const key in apis) {
44
- // 服务名
45
- let apiList = apis[key].EndPoint.split("/")
46
- let serverkey = apiList[apiList.length - 2]
47
- serviceObj[serverkey] = apis[key].EndPoint
48
- //moduleId (模块id)
49
- moduleObj[apis[key]['ModuleId']] = apis[key].EndPoint
50
- }
51
- if(type == 'service') return serviceObj
52
- else if(type == 'moduleId') return moduleObj
53
- }
54
-
55
- // 向插件内部传值
56
- Vue.use(requestApi, {apis: getApi('moduleId'), api:apiMap, clientId, token: getToken }) // 旧版api, 标识 为 moduleId
57
- Vue.use(request, {apis: getApi('service'), clientId, token: getToken}) // 新版api, 标识为 service , 接口服务名
58
- Vue.use(cellCmp)
59
- Vue.use(ImCmp)
60
-
1
+ import Install_config from '@modules/module.config'
2
+ import { Enum, OrgEnum, EnumList } from '@/utils/enum'
3
+ import utils from 'xs-component/lib/utils'
4
+ import base from 'xs-component/lib/base'
5
+ import api from '@/automatically/api'
6
+ import Vue from 'vue'
7
+ import store from '../store/index'
8
+ import {request, requestApi} from 'xs-request'
9
+ import ossService from '@/utils/ossService'
10
+ // 以上部分为 xs-component 引入
11
+ base.install(api ? api : {}) // 请求及api映射
12
+
13
+ // 字典, 调用方法, 取值缓存
14
+ function getDicVal (name, value) {
15
+ store.dispatch('dic/GET_ASK', {props: name, value})
16
+ }
17
+
18
+ // 向ui组件库传值
19
+ utils.install({
20
+ formatUtils: {Enum, OrgEnum, EnumList, format: Install_config.format ? Install_config.format: {}}, // Install_config.format 前端自定义枚举文件导出内容
21
+ dicUtils: getDicVal, // 字典工具
22
+ requestUtils: request, // 发送请求工具
23
+ ossUtils: ossService, // oss 图片上传
24
+ })
25
+
26
+
27
+ import cellCmp from '@/plugins/row-col-cmp'
28
+ import ImCmp from '@/plugins/im'
29
+
30
+ import apiMap from '@/utils/api'
31
+
32
+ import { getConfig } from '@/utils/global-config'
33
+ import { getToken } from "@/utils/auth";
34
+
35
+ let clientId = getConfig('CLIENT_ID')
36
+ let apis = getConfig('apis')
37
+
38
+
39
+ // 获取 标识: 服务地址的映射关系
40
+ function getApi (type) {
41
+ let serviceObj = {} // 服务名: 服务地址 映射关系 (新版)
42
+ let moduleObj = {} // 模块id: 服务地址 映射关系 (旧版)
43
+ for (const key in apis) {
44
+ // 服务名
45
+ let apiList = apis[key].EndPoint.split("/")
46
+ let serverkey = apiList[apiList.length - 2]
47
+ serviceObj[serverkey] = apis[key].EndPoint
48
+ //moduleId (模块id)
49
+ moduleObj[apis[key]['ModuleId']] = apis[key].EndPoint
50
+ }
51
+ if(type == 'service') return serviceObj
52
+ else if(type == 'moduleId') return moduleObj
53
+ }
54
+
55
+ // 向插件内部传值
56
+ Vue.use(requestApi, {apis: getApi('moduleId'), api:apiMap, clientId, token: getToken }) // 旧版api, 标识 为 moduleId
57
+ Vue.use(request, {apis: getApi('service'), clientId, token: getToken}) // 新版api, 标识为 service , 接口服务名
58
+ Vue.use(cellCmp)
59
+ Vue.use(ImCmp)
60
+
@@ -1,21 +1,21 @@
1
- import rowCmp from "./rowCmp";
2
- import colCmp from "./colCmp";
3
-
4
- export default {
5
- install: function (Vue) {
6
- Vue.component("rowCmp", rowCmp);
7
- Vue.component("colCmp", colCmp);
8
- }
9
- }
10
-
11
- // 调用如下:
12
- // <!-- <row-cmp :column='2'>
13
- // <col-cmp name="仓库编码1" :column='2'>{{ scope.row.code }}565656</col-cmp>
14
- // <col-cmp name="更新时间3" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
15
- // <col-cmp name="联电话电话" :column='2'>{{ scope.row.tel }}</col-cmp>
16
- // <col-cmp name="更新时间4" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
17
- // <col-cmp name="更新时间5" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}联系电话联系电话联系</col-cmp>
18
- // <col-cmp name="更新时间6" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
19
- // <col-cmp name="更新时间7" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
20
- // <col-cmp name="更新时间8" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
1
+ import rowCmp from "./rowCmp";
2
+ import colCmp from "./colCmp";
3
+
4
+ export default {
5
+ install: function (Vue) {
6
+ Vue.component("rowCmp", rowCmp);
7
+ Vue.component("colCmp", colCmp);
8
+ }
9
+ }
10
+
11
+ // 调用如下:
12
+ // <!-- <row-cmp :column='2'>
13
+ // <col-cmp name="仓库编码1" :column='2'>{{ scope.row.code }}565656</col-cmp>
14
+ // <col-cmp name="更新时间3" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
15
+ // <col-cmp name="联电话电话" :column='2'>{{ scope.row.tel }}</col-cmp>
16
+ // <col-cmp name="更新时间4" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
17
+ // <col-cmp name="更新时间5" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}联系电话联系电话联系</col-cmp>
18
+ // <col-cmp name="更新时间6" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
19
+ // <col-cmp name="更新时间7" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
20
+ // <col-cmp name="更新时间8" :column='2'>{{ scope.row.createTime | dateFormat("MM-DD HH:mm:ss") }}</col-cmp>
21
21
  // </row-cmp> -->
@@ -1,126 +1,126 @@
1
- /**
2
- * 登录判断
3
- */
4
- import { getQuery } from "@/common/utils";
5
- import { getToken } from "@/utils/auth"; // get token from cookie
6
- import { getConfig } from "@/utils/global-config";
7
- import { getLocalStorage, setLocalStorage } from "@/utils/localStorage";
8
- import NProgress from "nprogress"; // progress bar
9
- import "nprogress/nprogress.css"; // progress bar style
10
- import Oidc from "oidc-client";
11
- import { requestApi as HTTP } from "xs-request";
12
- import router from "./index";
13
-
14
- NProgress.configure({
15
- showSpinner: false,
16
- });
17
-
18
- const curOrigin = window.location.origin;
19
- const path = window.location.pathname;
20
- const _redirect_uri = `${curOrigin}${path}#/callback`;
21
-
22
- const id4config = {
23
- authority: getConfig("ID4_AUTH"),
24
- client_id: getConfig("CLIENT_ID"),
25
- redirect_uri: _redirect_uri,
26
- client_secret: getConfig("CLIENT_SECRET"),
27
- response_type: "code",
28
- scope: getConfig("ID4_SCOPE"),
29
- response_mode: "query",
30
- };
31
-
32
- window.$mgr = new Oidc.UserManager(id4config);
33
- // NProgress Configuration
34
- const whiteList = ["/login", "/404", "/slienceAuth"]; // no redirect whitelist
35
- router.beforeEach((to, from, next) => {
36
- const clientId = getConfig("CLIENT_ID");
37
- const title = getLocalStorage(`title_${clientId}`);
38
- if (title) { // 此处只作用于 ucuser项目
39
- beforeInPage(title);
40
- } else {
41
- HTTP.get("api.GetProject", {
42
- clientId,
43
- }).then((res) => {
44
- setLocalStorage(
45
- `title_${clientId}`,
46
- { title: res.data.title },
47
- 60 * 60 * 1000
48
- );
49
- beforeInPage(res.data);
50
- });
51
- }
52
-
53
-
54
- const isLogin = getToken(); // title_js_ucmngvue 获取个项目token
55
- const isLoginPage = whiteList.indexOf(to.path) !== -1; // 存在
56
- if (to.path === '/home') {
57
- if (window.parent !== window.self && window.name === 'qualityTestParty') {
58
- next()
59
- }
60
- }
61
- if (to.path === "/callback" || to.path === "/scan" || to.path === '/slienceAuth') next();
62
- else if (isLogin && !isLoginPage) next();
63
- // 登录 & 进入的不是登录页 => 不做处理
64
- else if (!isLogin && isLoginPage) next();
65
- // 没登录 & 在登录页 => 不做处理
66
- else if (isLogin && isLoginPage) {
67
- toTargetPage(to, next);
68
- } // 登录 & 在登录页 => 跳转到目标页
69
- else if (!isLogin && !isLoginPage) {
70
- toLoginPage(to, next);
71
-
72
- } // 没登录 & 没在登录页 => 跳转到登录页
73
- });
74
-
75
- router.afterEach(() => {
76
- NProgress.done();
77
- });
78
-
79
- function beforeInPage(to, next) {
80
- var url =
81
- "https://id4lp194.365xs.cn/ucmng/ucvue/#/login?ReturnUrl=https%3A%2F%2Fid4lp194.365xs.cn%2Fucid4%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Djs_localvue%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A9528%252F%2523%252Fcallback%253Fredic_url%253D%252Fhome%26response_type%3Dcode%26scope%3Daimng%2520commng%2520cpmng%2520cvmng%2520erpmng%2520hkmng%2520mtmng%2520otmng%2520rcmng%2520ucmng%2520ucuser%2520openid%2520profile%26state%3D561cf219797d4e33b5db795975180886%26code_challenge%3DYO8UTivoEb6jRFH9SS213zH_exJ6z4FfhTnUqZlL6EU%26code_challenge_method%3DS256%26response_mode%3Dquery";
82
-
83
- // start progress bar
84
- NProgress.start();
85
- // set page title
86
- const title = getConfig("PROJECT_NAME_TEXT") || "Vue Admin Template";
87
- const pageTitle = to.title;
88
- document.title = pageTitle ? `${pageTitle}` : `${title}`;
89
- }
90
-
91
- function toTargetPage(to, next) {
92
- if (getConfig("ID4_LOGINTYPE")) {
93
- next();
94
- } else {
95
- if (getConfig("NEW_LOGIN")) {
96
- const redirectUrl = getQuery(to.fullPath, "redirect");
97
- const isExtenalPage = redirectUrl.startsWith("http");
98
- if (isExtenalPage) {
99
- window.location = decodeURIComponent(redirectUrl);
100
- } else {
101
- next({ path: "/" });
102
- }
103
- }
104
- }
105
- }
106
-
107
- function toLoginPage(to, next) {
108
- // 使用 ID4 接管
109
- if (getConfig("ID4_LOGINTYPE")) {
110
- id4config.redirect_uri = `${id4config.redirect_uri}?redic_url=${to.path}`;
111
- window.$mgr = new Oidc.UserManager(id4config);
112
-
113
- window.$mgr.signinRedirect();
114
- } else {
115
- if (getConfig("NEW_LOGIN")) {
116
- const redirectUrl = `${window.location.origin}${window.location.pathname}#/${to.path}`;
117
- window.location = `${getConfig(
118
- "USER_CENTER_URL"
119
- )}/#/login?redirect=${redirectUrl}`
120
- .replace(/\/{2}/gi, "/")
121
- .replace(/(http:\/|https:\/)/gi, "$1/");
122
- } else {
123
- next(`/login?redirect=${to.path}`);
124
- }
125
- }
126
- }
1
+ /**
2
+ * 登录判断
3
+ */
4
+ import { getQuery } from "@/common/utils";
5
+ import { getToken } from "@/utils/auth"; // get token from cookie
6
+ import { getConfig } from "@/utils/global-config";
7
+ import { getLocalStorage, setLocalStorage } from "@/utils/localStorage";
8
+ import NProgress from "nprogress"; // progress bar
9
+ import "nprogress/nprogress.css"; // progress bar style
10
+ import Oidc from "oidc-client";
11
+ import { requestApi as HTTP } from "xs-request";
12
+ import router from "./index";
13
+
14
+ NProgress.configure({
15
+ showSpinner: false,
16
+ });
17
+
18
+ const curOrigin = window.location.origin;
19
+ const path = window.location.pathname;
20
+ const _redirect_uri = `${curOrigin}${path}#/callback`;
21
+
22
+ const id4config = {
23
+ authority: getConfig("ID4_AUTH"),
24
+ client_id: getConfig("CLIENT_ID"),
25
+ redirect_uri: _redirect_uri,
26
+ client_secret: getConfig("CLIENT_SECRET"),
27
+ response_type: "code",
28
+ scope: getConfig("ID4_SCOPE"),
29
+ response_mode: "query",
30
+ };
31
+
32
+ window.$mgr = new Oidc.UserManager(id4config);
33
+ // NProgress Configuration
34
+ const whiteList = ["/login", "/404", "/slienceAuth"]; // no redirect whitelist
35
+ router.beforeEach((to, from, next) => {
36
+ const clientId = getConfig("CLIENT_ID");
37
+ const title = getLocalStorage(`title_${clientId}`);
38
+ if (title) { // 此处只作用于 ucuser项目
39
+ beforeInPage(title);
40
+ } else {
41
+ HTTP.get("api.GetProject", {
42
+ clientId,
43
+ }).then((res) => {
44
+ setLocalStorage(
45
+ `title_${clientId}`,
46
+ { title: res.data.title },
47
+ 60 * 60 * 1000
48
+ );
49
+ beforeInPage(res.data);
50
+ });
51
+ }
52
+
53
+
54
+ const isLogin = getToken(); // title_js_ucmngvue 获取个项目token
55
+ const isLoginPage = whiteList.indexOf(to.path) !== -1; // 存在
56
+ if (to.path === '/home') {
57
+ if (window.parent !== window.self && window.name === 'qualityTestParty') {
58
+ next()
59
+ }
60
+ }
61
+ if (to.path === "/callback" || to.path === "/scan" || to.path === '/slienceAuth') next();
62
+ else if (isLogin && !isLoginPage) next();
63
+ // 登录 & 进入的不是登录页 => 不做处理
64
+ else if (!isLogin && isLoginPage) next();
65
+ // 没登录 & 在登录页 => 不做处理
66
+ else if (isLogin && isLoginPage) {
67
+ toTargetPage(to, next);
68
+ } // 登录 & 在登录页 => 跳转到目标页
69
+ else if (!isLogin && !isLoginPage) {
70
+ toLoginPage(to, next);
71
+
72
+ } // 没登录 & 没在登录页 => 跳转到登录页
73
+ });
74
+
75
+ router.afterEach(() => {
76
+ NProgress.done();
77
+ });
78
+
79
+ function beforeInPage(to, next) {
80
+ var url =
81
+ "https://id4lp194.365xs.cn/ucmng/ucvue/#/login?ReturnUrl=https%3A%2F%2Fid4lp194.365xs.cn%2Fucid4%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Djs_localvue%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A9528%252F%2523%252Fcallback%253Fredic_url%253D%252Fhome%26response_type%3Dcode%26scope%3Daimng%2520commng%2520cpmng%2520cvmng%2520erpmng%2520hkmng%2520mtmng%2520otmng%2520rcmng%2520ucmng%2520ucuser%2520openid%2520profile%26state%3D561cf219797d4e33b5db795975180886%26code_challenge%3DYO8UTivoEb6jRFH9SS213zH_exJ6z4FfhTnUqZlL6EU%26code_challenge_method%3DS256%26response_mode%3Dquery";
82
+
83
+ // start progress bar
84
+ NProgress.start();
85
+ // set page title
86
+ const title = getConfig("PROJECT_NAME_TEXT") || "Vue Admin Template";
87
+ const pageTitle = to.title;
88
+ document.title = pageTitle ? `${pageTitle}` : `${title}`;
89
+ }
90
+
91
+ function toTargetPage(to, next) {
92
+ if (getConfig("ID4_LOGINTYPE")) {
93
+ next();
94
+ } else {
95
+ if (getConfig("NEW_LOGIN")) {
96
+ const redirectUrl = getQuery(to.fullPath, "redirect");
97
+ const isExtenalPage = redirectUrl.startsWith("http");
98
+ if (isExtenalPage) {
99
+ window.location = decodeURIComponent(redirectUrl);
100
+ } else {
101
+ next({ path: "/" });
102
+ }
103
+ }
104
+ }
105
+ }
106
+
107
+ function toLoginPage(to, next) {
108
+ // 使用 ID4 接管
109
+ if (getConfig("ID4_LOGINTYPE")) {
110
+ id4config.redirect_uri = `${id4config.redirect_uri}?redic_url=${to.path}`;
111
+ window.$mgr = new Oidc.UserManager(id4config);
112
+
113
+ window.$mgr.signinRedirect();
114
+ } else {
115
+ if (getConfig("NEW_LOGIN")) {
116
+ const redirectUrl = `${window.location.origin}${window.location.pathname}#/${to.path}`;
117
+ window.location = `${getConfig(
118
+ "USER_CENTER_URL"
119
+ )}/#/login?redirect=${redirectUrl}`
120
+ .replace(/\/{2}/gi, "/")
121
+ .replace(/(http:\/|https:\/)/gi, "$1/");
122
+ } else {
123
+ next(`/login?redirect=${to.path}`);
124
+ }
125
+ }
126
+ }
@@ -1,75 +1,75 @@
1
- /**
2
- * 功能: 字典功能
3
- * 服务对象: 列表页面上需要通过 id 去调用接口得到具体名称的 字段
4
- */
5
- import Vue from "vue";
6
- import request from "xs-request";
7
- const state = {
8
- ask: {},
9
- };
10
-
11
- const mutations = {
12
- SET_ASK(state, { key, val }) {
13
- if (state.ask[key]) {
14
- state.ask[key] = state.ask[key].concat(val);
15
- } else {
16
- Vue.set(state.ask, key, val);
17
- }
18
- },
19
- };
20
-
21
- // 正在运行的 dic 字典
22
- let dicing = [];
23
- const actions = {
24
- GET_ASK({ state, commit }, { props, value }) {
25
- if (!value || value == '0') return;
26
- let servers = props[0] || "";
27
- let tableName = props[1] || "";
28
- let key = servers + tableName;
29
- let row = dicing.find((item) => item.key == key); // 查看 项目字典运作中的是否存在
30
- if (row) {
31
- // 存在追加id
32
- row.list.push(value);
33
- } else {
34
- row = { key, timer: null, list: [value] }; // 不存在, 创建
35
- dicing.push(row);
36
- }
37
- if (row && row.timer != null) {
38
- clearTimeout(row.timer);
39
- }
40
- row.timer = setTimeout(() => {
41
- let url = servers + "/UserAll/Search/Dic/" + tableName;
42
- let ids = [...new Set(row.list)];
43
- request.post(url, ids).then((res) => {
44
- if (res.code !== 0) return;
45
- row.timer = clearTimeout(row.timer);
46
- row.list = [];
47
- let minusList = [];
48
- if (res.data.length !== ids.length) {
49
- // 库里查询回来为空
50
- minusList = checkMinus(ids, res.data);
51
- }
52
- commit("SET_ASK", { key, val: [...res.data, ...minusList] });
53
- });
54
- }, 500);
55
- },
56
- };
57
- /**
58
- * 判断两数据间的差值
59
- */
60
- function checkMinus(ids, resData) {
61
- let resIds = resData.map((item) => item.id);
62
- let minus = ids.filter((val) => resIds.indexOf(val) === -1);
63
- let list = [];
64
- minus.forEach((item) => {
65
- list.push({ id: item, isNull: true });
66
- });
67
- return list;
68
- }
69
-
70
- export default {
71
- namespaced: true,
72
- state,
73
- mutations,
74
- actions,
1
+ /**
2
+ * 功能: 字典功能
3
+ * 服务对象: 列表页面上需要通过 id 去调用接口得到具体名称的 字段
4
+ */
5
+ import Vue from "vue";
6
+ import request from "xs-request";
7
+ const state = {
8
+ ask: {},
9
+ };
10
+
11
+ const mutations = {
12
+ SET_ASK(state, { key, val }) {
13
+ if (state.ask[key]) {
14
+ state.ask[key] = state.ask[key].concat(val);
15
+ } else {
16
+ Vue.set(state.ask, key, val);
17
+ }
18
+ },
19
+ };
20
+
21
+ // 正在运行的 dic 字典
22
+ let dicing = [];
23
+ const actions = {
24
+ GET_ASK({ state, commit }, { props, value }) {
25
+ if (!value || value == '0') return;
26
+ let servers = props[0] || "";
27
+ let tableName = props[1] || "";
28
+ let key = servers + tableName;
29
+ let row = dicing.find((item) => item.key == key); // 查看 项目字典运作中的是否存在
30
+ if (row) {
31
+ // 存在追加id
32
+ row.list.push(value);
33
+ } else {
34
+ row = { key, timer: null, list: [value] }; // 不存在, 创建
35
+ dicing.push(row);
36
+ }
37
+ if (row && row.timer != null) {
38
+ clearTimeout(row.timer);
39
+ }
40
+ row.timer = setTimeout(() => {
41
+ let url = servers + "/UserAll/Search/Dic/" + tableName;
42
+ let ids = [...new Set(row.list)];
43
+ request.post(url, ids).then((res) => {
44
+ if (res.code !== 0) return;
45
+ row.timer = clearTimeout(row.timer);
46
+ row.list = [];
47
+ let minusList = [];
48
+ if (res.data.length !== ids.length) {
49
+ // 库里查询回来为空
50
+ minusList = checkMinus(ids, res.data);
51
+ }
52
+ commit("SET_ASK", { key, val: [...res.data, ...minusList] });
53
+ });
54
+ }, 500);
55
+ },
56
+ };
57
+ /**
58
+ * 判断两数据间的差值
59
+ */
60
+ function checkMinus(ids, resData) {
61
+ let resIds = resData.map((item) => item.id);
62
+ let minus = ids.filter((val) => resIds.indexOf(val) === -1);
63
+ let list = [];
64
+ minus.forEach((item) => {
65
+ list.push({ id: item, isNull: true });
66
+ });
67
+ return list;
68
+ }
69
+
70
+ export default {
71
+ namespaced: true,
72
+ state,
73
+ mutations,
74
+ actions,
75
75
  }
@@ -1,41 +1,41 @@
1
- /**
2
- * 功能: oss 图片上次
3
- * 使用对象: 需要将图片上传到 oss 存放的项目
4
- * 数据存放再 store 原因: 在token 的有效期间内(通过比较时间戳), 不再发起获取 oss-token 的请求
5
- */
6
-
7
- const state = {
8
- ossCfg: {
9
- region: null,
10
- accessKeyId: null,
11
- accessKeySecret: null,
12
- bucket: null,
13
- stsToken: null,
14
- timeout: 0,
15
- baseDir: ''
16
- }
17
- };
18
-
19
- const getters = {
20
- ossCfg: state => state.ossCfg
21
- }
22
-
23
- const mutations = {
24
- SET_OSS (state, value) { // 存放 oss 的校验信息
25
- state.ossCfg = value
26
- }
27
- };
28
-
29
- const actions = {
30
-
31
- };
32
-
33
-
34
- export default {
35
- namespaced: true,
36
- state,
37
- mutations,
38
- actions,
39
- getters
40
- };
1
+ /**
2
+ * 功能: oss 图片上次
3
+ * 使用对象: 需要将图片上传到 oss 存放的项目
4
+ * 数据存放再 store 原因: 在token 的有效期间内(通过比较时间戳), 不再发起获取 oss-token 的请求
5
+ */
6
+
7
+ const state = {
8
+ ossCfg: {
9
+ region: null,
10
+ accessKeyId: null,
11
+ accessKeySecret: null,
12
+ bucket: null,
13
+ stsToken: null,
14
+ timeout: 0,
15
+ baseDir: ''
16
+ }
17
+ };
18
+
19
+ const getters = {
20
+ ossCfg: state => state.ossCfg
21
+ }
22
+
23
+ const mutations = {
24
+ SET_OSS (state, value) { // 存放 oss 的校验信息
25
+ state.ossCfg = value
26
+ }
27
+ };
28
+
29
+ const actions = {
30
+
31
+ };
32
+
33
+
34
+ export default {
35
+ namespaced: true,
36
+ state,
37
+ mutations,
38
+ actions,
39
+ getters
40
+ };
41
41