imatrix-ui 2.9.99 → 7.7.20-p2

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 (35) hide show
  1. package/lib/super-ui.css +1 -1
  2. package/lib/super-ui.umd.min.js +13 -6
  3. package/package.json +3 -2
  4. package/src/api/sso-service.js +12 -1
  5. package/src/directives/permission/permission.js +1 -1
  6. package/src/i18n/langs/cn.js +64 -3
  7. package/src/i18n/langs/en.js +65 -4
  8. package/src/permission.js +16 -22
  9. package/src/router/index.js +18 -1
  10. package/src/store/getters.js +2 -1
  11. package/src/store/modules/user.js +16 -1
  12. package/src/styles/index.scss +11 -2
  13. package/src/utils/calculator/calculator-factory.js +125 -0
  14. package/src/utils/calculator/calculator-util.js +6 -0
  15. package/src/utils/common-util.js +21 -1
  16. package/src/utils/eventBus.js +2 -0
  17. package/src/utils/iconUtils.js +23 -0
  18. package/src/utils/jump-page-utils.js +467 -0
  19. package/src/utils/permission.js +1 -1
  20. package/src/utils/permissionAuth.js +1 -1
  21. package/src/utils/request.js +4 -2
  22. package/src/utils/restful-interface-utils.js +47 -0
  23. package/src/utils/util.js +451 -0
  24. package/src/utils/watermark.js +95 -0
  25. package/src/views/layout/NewLayout.vue +77 -0
  26. package/src/views/layout/components/AppMain.vue +9 -0
  27. package/src/views/layout/components/Breadcrumb/index.vue +33 -1
  28. package/src/views/layout/components/Menubar/Item.vue +46 -0
  29. package/src/views/layout/components/Menubar/Link.vue +31 -0
  30. package/src/views/layout/components/Menubar/SidebarItem.vue +101 -0
  31. package/src/views/layout/components/Menubar/index.vue +143 -0
  32. package/src/views/layout/components/iframe-page.vue +31 -0
  33. package/src/views/layout/components/index.js +1 -0
  34. package/src/views/redirect/index.vue +3 -3
  35. package/src/views/wf-history/tache-subprocess-history.vue +45 -0
package/src/utils/util.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import i18n from '../i18n/i18n'
2
2
  import Vue from 'vue'
3
+ import { executeExpression } from './calculator/calculator-util'
3
4
  export function getI18n() {
4
5
  if (!window.$locale) {
5
6
  i18n.locale = 'cn'
@@ -17,7 +18,441 @@ export function getLanguageWithLocale() {
17
18
  return 'zh_CN'
18
19
  }
19
20
  }
21
+ /**
22
+ * 根据动态数据源获得下拉选的选项集合
23
+ * @param {*} dynamicSourceCode 动态数据源编码
24
+ * @param {*} searchText 查询的文本
25
+ * @param {*} entity 实体信息
26
+ * @returns
27
+ */
28
+ export function findOptionsByDynamicDataSource(dynamicSourceCode, searchText, entity, additionalParameterStr) {
29
+ return new Promise((resolve, reject) => {
30
+ findDynamicDataSourceByCode(dynamicSourceCode, searchText, entity, additionalParameterStr).then(dynamicDataSourceDto => {
31
+ let options = []
32
+ if (dynamicDataSourceDto && dynamicDataSourceDto.options) {
33
+ const setOptions = dynamicDataSourceDto.options
34
+ let valueAttribute
35
+ if (dynamicDataSourceDto.valueAttribute) {
36
+ valueAttribute = dynamicDataSourceDto.valueAttribute
37
+ }
38
+ if (!valueAttribute || valueAttribute === '[label]') {
39
+ valueAttribute = '_label_'
40
+ }
41
+ setOptions.forEach(item => {
42
+ // 值
43
+ const value = item[valueAttribute]
44
+ // 显示的标签
45
+ const label = item['_label_']
46
+ options.push({ label, value })
47
+ })
48
+ }
49
+ if (!options) {
50
+ options = []
51
+ }
52
+ resolve(options)
53
+ }).catch(error => {
54
+ reject(error)
55
+ })
56
+ })
57
+ }
58
+
59
+ /**
60
+ * 根据动态数据源获得下拉选的选项对象集合
61
+ * @param {*} dynamicSourceCode 动态数据源编码
62
+ * @param {*} searchText 查询的文本
63
+ * @param {*} entity 实体信息
64
+ * @returns
65
+ */
66
+ export function findDynamicDataSourceByCode(dynamicSourceCode, searchText, entity, additionalParameterStr) {
67
+ return new Promise((resolve, reject) => {
68
+ if (searchText === undefined || searchText === null) {
69
+ searchText = ''
70
+ }
71
+ const params = {
72
+ searchText
73
+ }
74
+ // const additionalParameterStr = sessionStorage.getItem('additionalParamMap')
75
+ if (additionalParameterStr) {
76
+ params.additionalParamMap = JSON.parse(additionalParameterStr)
77
+ }
78
+ if (entity && entity !== null) {
79
+ params.entity = entity
80
+ }
81
+ Vue.prototype.$http.post(Vue.prototype.baseURL + '/common/dynamic-data-source/' + dynamicSourceCode, params).then(dynamicDataSourceDto => {
82
+ resolve(dynamicDataSourceDto)
83
+ }).catch(error => {
84
+ reject(error)
85
+ })
86
+ })
87
+ }
88
+
89
+ /**
90
+ * 解析是否可见的条件,例如:按钮是否按钮;列表单元格内容是否可见
91
+ * @param {*} conditionListJson
92
+ * @param {*} entity
93
+ * @param {*} additionalParameter
94
+ * @param {*} contextParameter
95
+ * @param {*} isSql
96
+ * @param {*} tableName
97
+ * @returns
98
+ */
99
+ export function analysisCondition(conditionListJson, entity, additionalParameter, contextParameter, isSql, tableName, parentFormData) {
100
+ // console.log('analysisCondition判断条件conditionListJson', conditionListJson)
101
+ // console.log('analysisCondition判断条件entity', entity)
102
+ // console.log('analysisCondition判断条件additionalParameter', additionalParameter)
103
+ // console.log('analysisCondition判断条件contextParameter', contextParameter)
104
+ // console.log('analysisCondition判断条件isSql', isSql)
105
+ // console.log('analysisCondition判断条件tableName', tableName)
106
+ // console.log('analysisCondition判断条件parentFormData', parentFormData)
107
+ if (conditionListJson === undefined || conditionListJson === '' || conditionListJson === null) {
108
+ // 如果条件不存在,则默认返回true
109
+ return true
110
+ }
111
+ if (typeof (isSql) === 'undefined' || isSql === null) {
112
+ // 默认是定制开发时
113
+ isSql = false
114
+ }
115
+ // 页面附加参数
116
+ let additionalParameterMap = {}
117
+ if (additionalParameter && typeof (additionalParameter) === 'string' && additionalParameter !== '') {
118
+ additionalParameterMap = JSON.parse(additionalParameter)
119
+ } else if (additionalParameter && typeof (additionalParameter) === 'object') {
120
+ additionalParameterMap = additionalParameter
121
+ }
122
+ // 环境变量,例如:当前用户id、当前用户登录名等
123
+ let contextParameterMap = {}
124
+ if (contextParameter && typeof (contextParameter) === 'string' && contextParameter !== '') {
125
+ contextParameterMap = JSON.parse(contextParameter)
126
+ } else if (contextParameter && typeof (contextParameter) === 'object') {
127
+ contextParameterMap = contextParameter
128
+ }
129
+ let conditionList = []
130
+ if (conditionListJson && typeof (conditionListJson) === 'string' && conditionListJson !== '') {
131
+ // conditionList = eval('('+conditionListJson+')')
132
+ conditionList = JSON.parse(conditionListJson)
133
+ } else if (conditionListJson && Array.isArray(conditionListJson)) {
134
+ conditionList = conditionListJson
135
+ }
136
+ return parseCondition(entity, conditionList, isSql, tableName, additionalParameterMap, contextParameterMap, parentFormData)
137
+ }
138
+
139
+ function parseCondition(entity, conditionList, isSql, tableName, additionalParamMap, contextParameterMap, parentFormData) {
140
+ if (conditionList === undefined || conditionList === null || conditionList.length === 0) {
141
+ // 表示没有设置条件,默认是true
142
+ return true
143
+ }
144
+ // 条件封装的表达式
145
+ let conditions = ''
146
+ for (let i = 0; i < conditionList.length; i++) {
147
+ const condition = conditionList[i]
148
+ let propName = condition.propName
149
+ let propDbName = condition.propDbName
150
+ if ((!propName || propName === '') && (!propDbName || propDbName === '')) {
151
+ // 没有属性和字段名表示是无效的条件
152
+ continue
153
+ }
154
+ let leftValue
155
+ if (isSql) {
156
+ if (propDbName.indexOf('parent_+_') !== -1) {
157
+ propDbName = propDbName.replace('parent_+_', '')
158
+ // 再获取属于那张表
159
+ const propDbNameArr = propDbName.split('_+_')
160
+ propDbName = propDbNameArr[1]
161
+ leftValue = getValue(parentFormData, propDbName, isSql)
162
+ } else {
163
+ leftValue = getValue(entity, propDbName, isSql)
164
+ }
165
+ if (leftValue === undefined || leftValue === null) {
166
+ if (tableName && propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')) {
167
+ // 表示是当前表的字段
168
+ const myProp = propDbName.substring(propDbName.indexOf('.'))
169
+ leftValue = getValue(entity, myProp, isSql)
170
+ }
171
+ }
172
+ } else {
173
+ if (propName.indexOf('parent_+_') !== -1) {
174
+ propName = propName.replace('parent_+_', '')
175
+ const propNameArr = propName.split('_+_')
176
+ propName = propNameArr[1]
177
+ leftValue = getValue(parentFormData, propName, isSql)
178
+ } else {
179
+ leftValue = getValue(entity, propName, isSql)
180
+ }
181
+ if (leftValue !== undefined && leftValue !== null) {
182
+ leftValue = getValue(entity, propDbName, isSql)
183
+ }
184
+ }
185
+ const operator = condition.operator
186
+ const propValue = condition.propValue
187
+ const dataType = condition.dataType
188
+ const variableIsNullStr = condition.variableIsNull
189
+ // 解析单个条件的值
190
+ // 判断value类型
191
+ let value = getPropValue(propValue, entity, additionalParamMap, contextParameterMap)
192
+ if (variableIsNullStr && variableIsNullStr === 'null') {
193
+ if (value === undefined || value === '') {
194
+ value = null
195
+ }
196
+ }
197
+ let conditionResult = executeExpression(leftValue, operator, value, dataType)
198
+ const leftBracket = condition.leftBracket
199
+ const rightBracket = condition.rightBracket
200
+ let joinSign = condition.joinSign
201
+ if (leftBracket && leftBracket !== null && leftBracket !== '') {
202
+ conditions = conditions + leftBracket
203
+ conditions = conditions + (' ')
204
+ // conditions.append(leftBracket).append(' ')
205
+ }
206
+ if (variableIsNullStr && variableIsNullStr !== 'null') {
207
+ if (value === undefined || value === null || value + '' === '') {
208
+ if (variableIsNullStr === '1=1') {
209
+ conditionResult = true
210
+ } else {
211
+ conditionResult = false
212
+ }
213
+ }
214
+ }
215
+ conditions += conditionResult + ' '
216
+ if (leftBracket && leftBracket !== null && leftBracket !== '') {
217
+ conditions = conditions + rightBracket
218
+ conditions = conditions + (' ')
219
+ // conditions.append(rightBracket).append(' ')
220
+ }
221
+ if (i < conditionList.length - 1) {
222
+ // 最后一个不拼接“连接符”
223
+ if (joinSign && joinSign !== null && joinSign !== '') {
224
+ const joinSignIgnoreCase = joinSign.toLowerCase()
225
+ if (joinSignIgnoreCase === 'AND') {
226
+ joinSign = joinSignIgnoreCase.replace('AND', '&&')
227
+ } else if (joinSignIgnoreCase === 'OR') {
228
+ joinSign = joinSignIgnoreCase.replace('OR', '||')
229
+ }
230
+ conditions += joinSign + ' '
231
+ }
232
+ }
233
+ }
234
+ // eslint-disable-next-line no-eval
235
+ return eval('(' + conditions + ')')
236
+ }
237
+ const REPLACE_DOT = '__'
238
+ function getValue(entityData, fieldName, isSql) {
239
+ let value = null
240
+ if (entityData && entityData !== null) {
241
+ if (fieldName && fieldName !== null) {
242
+ value = getValueByField(entityData, fieldName)
243
+ if (value === undefined || value === null) {
244
+ if (isSql) {
245
+ if (value === undefined || value == null) {
246
+ if (fieldName.indexOf('.') > 0) {
247
+ // 将“.”替换为'__',列表组件中的entity中如果是'.',传过来的实体信息中的字段属性会是“__”
248
+ fieldName = fieldName.replace('.', REPLACE_DOT)
249
+ value = getValueByField(entityData, fieldName)
250
+ }
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ return value
257
+ }
258
+
259
+ function getValueByField(entityData, fieldName) {
260
+ if (entityData && entityData !== null) {
261
+ let value
262
+ if (fieldName.indexOf('.') > 0) {
263
+ // 表示是子表字段
264
+ value = getSubEntityValue(entityData, fieldName)
265
+ } else {
266
+ value = entityData[fieldName]
267
+ }
268
+ return value
269
+ }
270
+ }
271
+
272
+ function getSubEntityValue(entityData, fieldName) {
273
+ let value = null
274
+ let subEntityData = entityData
275
+ const fieldNames = fieldName.split('\\.')
276
+ for (let i = 0; i < fieldNames.length; i++) {
277
+ const field = fieldNames[i]
278
+ if (i === fieldNames.length) {
279
+ value = getSubEntityFieldValue(subEntityData, field)
280
+ } else {
281
+ subEntityData = getSubEntityFieldValue(subEntityData, field)
282
+ }
283
+ }
284
+ return value
285
+ }
286
+
287
+ /**
288
+ * 获得关联表字段的值。
289
+ * 处理sql 或 实体情况。
290
+ * @param subEntityData
291
+ * @param fieldName
292
+ * @return
293
+ */
294
+ function getSubEntityFieldValue(subEntityData, fieldName) {
295
+ if (subEntityData === undefined || subEntityData === null) {
296
+ return null
297
+ }
298
+ return subEntityData[fieldName]
299
+ }
300
+
301
+ function getContextValue(contextParameterMap, propValue) {
302
+ if (contextParameterMap) {
303
+ return contextParameterMap[propValue]
304
+ }
305
+ }
306
+
307
+ export function getPropValue(propValue, entity, additionalParamMap, contextParameterMap) {
308
+ let value = null
309
+ if (propValue && propValue !== null && propValue !== '') {
310
+ if (propValue === 'null') {
311
+ value = null
312
+ } else if (propValue.includes('${context.') || propValue.includes('${request.') || propValue.includes('${obj.')) {
313
+ // 填写的固定值
314
+ if (propValue.includes('${context.')) {
315
+ propValue = propValue.replace('${context.', '').replace('}', '')
316
+ value = getContextValue(contextParameterMap, propValue)
317
+ } else if (propValue.includes('${request.') && propValue !== ('${request.term}')) {
318
+ // ${request.term}表示页面中手动输入的值
319
+ propValue = propValue.replace('${request.', '').replace('}', '')
320
+ if (additionalParamMap && additionalParamMap != null && Object.keys(additionalParamMap).indexOf(propValue) >= 0 && additionalParamMap[propValue] && additionalParamMap[propValue] !== null) {
321
+ value = additionalParamMap[propValue]
322
+ } else {
323
+ value = null
324
+ }
325
+ } else if (propValue.includes('${obj.')) {
326
+ if (entity == null) {
327
+ value = null
328
+ } else {
329
+ const propName = propValue.replace('${obj.', '').replace('}', '')
330
+ value = getEntityFieldValue(entity, propName)
331
+ }
332
+ }
333
+ } else if (propValue.includes('${input.')) {
334
+ value = propValue.replace('${input.', '').replace('}', '')
335
+ } else {
336
+ value = propValue
337
+ }
338
+ }
339
+ return value
340
+ }
341
+ /**
342
+ * 解析条件,例如:${obj.menu_code}-#-#${input.---}-#-#${context.currentTransactor}
343
+ * @param {*} conditionValue
344
+ * @param {*} entity
345
+ * @param {*} additionalParameter
346
+ * @param {*} contextParameter
347
+ * @returns
348
+ */
349
+ export function analysisValue(conditionValue, entity, additionalParameter, contextParameter) {
350
+ if (!conditionValue) {
351
+ return
352
+ }
353
+ let label = ''
354
+ const split = conditionValue.split('-#-#')
355
+ if (split != null && split.length > 0) {
356
+ split.forEach(item => {
357
+ let value = getPropValue(item, entity, additionalParameter, contextParameter)
358
+ if (!value || value === null) {
359
+ value = ''
360
+ }
361
+ label += value
362
+ })
363
+ }
364
+ return label
365
+ }
366
+
367
+ /**
368
+ * 设置entity中某属性的值,处理子对象的情况
369
+ * @param {*} entity
370
+ * @param {*} prop
371
+ * @param {*} value
372
+ */
373
+ export function setEntityFieldValue(entity, prop, value) {
374
+ if (prop && entity) {
375
+ if (prop && prop.indexOf('.') > 0) {
376
+ const parentObj = getParentObjectUtil(prop, entity)
377
+ if (parentObj) {
378
+ Vue.set(parentObj, prop.substring(prop.lastIndexOf('.') + 1), value)
379
+ }
380
+ } else {
381
+ Vue.set(entity, prop, value)
382
+ }
383
+ }
384
+ }
20
385
 
386
+ /**
387
+ * 获得实体entity中某属性的值,处理子表对象的情况
388
+ * @param {*} entity
389
+ * @param {*} prop
390
+ * @returns
391
+ */
392
+ export function getEntityFieldValue(entity, prop) {
393
+ let value = getEntityFieldValueWithCase(entity, prop)
394
+ if (value === undefined) {
395
+ // 兼容mysql数据库
396
+ value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
397
+ }
398
+ if (value === undefined) {
399
+ // 兼容oracle数据库
400
+ value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
401
+ }
402
+ return value
403
+ }
404
+
405
+ function getEntityFieldValueWithCase(entity, prop) {
406
+ if (prop && prop.indexOf('.') > 0) {
407
+ const parentOjbect = getParentObjectUtil(prop, entity)
408
+ const modelName = prop.substring(prop.lastIndexOf('.') + 1)
409
+ return parentOjbect[modelName]
410
+ } else {
411
+ return entity[prop]
412
+ }
413
+ }
414
+
415
+ export function getParentObjectUtil(prop, entity) {
416
+ const nestedProp = prop.split('.')
417
+ // 属性只有一个时父对象就是models
418
+ if (nestedProp.length === 1) {
419
+ return entity
420
+ } else {
421
+ let parentObject
422
+ // 属性超过2个时先找到最后一层属性的父对象
423
+ for (let i = 0; i < nestedProp.length - 1; i++) {
424
+ if (i === 0) {
425
+ parentObject = getParentModelProp(nestedProp[i], entity)
426
+ } else {
427
+ parentObject = getParentModelProp(nestedProp[i], parentObject)
428
+ }
429
+ }
430
+ return parentObject
431
+ }
432
+ }
433
+
434
+ function getParentModelProp(prop, parentObj) {
435
+ let myPparentObject = getParentModelPropWithCase(prop, parentObj)
436
+ if (myPparentObject === undefined) {
437
+ // 兼容mysql数据库
438
+ myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
439
+ }
440
+ if (myPparentObject === undefined) {
441
+ // 兼容oracle数据库
442
+ myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
443
+ }
444
+ return myPparentObject
445
+ }
446
+
447
+ function getParentModelPropWithCase(prop, parentObj) {
448
+ if (!parentObj) {
449
+ parentObj = {}
450
+ }
451
+ if (!parentObj[prop]) {
452
+ parentObj[prop] = {}
453
+ }
454
+ return parentObj[prop]
455
+ }
21
456
  /**
22
457
  * 获得系统信息
23
458
  * @param {*}} systemCode
@@ -40,3 +475,19 @@ export function findSystemInfoByCode(systemCode) {
40
475
  })
41
476
  })
42
477
  }
478
+
479
+ export function getPropNameWhenJoinTable(prop, isJoinTable, tableName) {
480
+ if (prop && isJoinTable !== undefined && isJoinTable === true) {
481
+ // 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
482
+ const replaceDot = '__'
483
+ if (prop.indexOf('.') > 0) {
484
+ prop = prop.replace('.', replaceDot)
485
+ } else {
486
+ if (tableName && tableName !== null && tableName !== '' && prop.indexOf(tableName + replaceDot) < 0) {
487
+ // 如果属性名没有拼接表名才需要拼接
488
+ prop = tableName + replaceDot + prop
489
+ }
490
+ }
491
+ }
492
+ return prop
493
+ }
@@ -0,0 +1,95 @@
1
+ 'use strict'
2
+ // import ssoService from '../api/sso-service'
3
+ const watermark = {}
4
+
5
+ const setWatermark = (str, parma, paramId) => {
6
+ let id = '1.23452384164.123412415'
7
+ if (paramId) {
8
+ id = paramId
9
+ }
10
+ if (document.getElementById(id) !== null) {
11
+ if (document.getElementById('pdfDom')) {
12
+ var cell1 = document.getElementById('pdfDom')
13
+ cell1.removeChild(document.getElementById(id))
14
+ } else {
15
+ document.body.removeChild(document.getElementById(id))
16
+ }
17
+ }
18
+ const can = document.createElement('canvas')
19
+ can.width = parma && parma.width && parma.width !== '' ? parma.width : '400' // 单个水印的宽高
20
+ can.height = parma && parma.height && parma.height !== '' ? parma.height : '200'
21
+
22
+ const cans = can.getContext('2d')
23
+ cans.rotate((20 * Math.PI) / 160) // 水印偏转角度
24
+ cans.font = parma && parma.font && parma.font !== '' ? parma.font : '17px Vedana' // 设置样式
25
+ cans.fillStyle = parma && parma.color && parma.color !== '' ? parma.color : 'rgba(200, 200, 200, 0.40)'// 水印字体颜色
26
+ cans.textAlign = 'left'
27
+ cans.textBaseline = 'Middle'
28
+ cans.fillText(str, 60, 40)
29
+
30
+ const div = document.createElement('div')
31
+ div.id = id
32
+ div.style.pointerEvents = 'none'
33
+ div.style.top = '80px'
34
+ div.style.left = '200px'
35
+ div.style.position = 'fixed'
36
+ div.style.zIndex = '10000'
37
+ div.style.width = '70%'
38
+ div.style.height = '80%'
39
+ div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
40
+
41
+ if (document.getElementById('pdfDom')) {
42
+ var cell = document.getElementById('pdfDom')
43
+ cell.appendChild(div)
44
+ } else {
45
+ document.body.appendChild(div)
46
+ }
47
+ return id
48
+ }
49
+
50
+ // 该方法只允许调用一次
51
+ export function showWatermark(label, parma, user, paramId) {
52
+ var date = new Date()
53
+ date = formatDate(date, 'yyyy-MM-dd')
54
+ setTimeout(() => {
55
+ var str = label && label !== '' ? label : user ? user.name + ' ' + date : date
56
+ let id = setWatermark(str, parma, paramId)
57
+ setInterval(() => {
58
+ if (document.getElementById(id) === null) {
59
+ id = setWatermark(str, parma, paramId)
60
+ }
61
+ }, 500)
62
+ window.onresize = () => {
63
+ setWatermark(str, parma, paramId)
64
+ }
65
+ })
66
+ }
67
+ // watermark.set = (label, parma) => {
68
+
69
+ // }
70
+
71
+ const formatDate = (date, fmt) => {
72
+ if (/(y+)/.test(fmt)) {
73
+ fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
74
+ }
75
+ const o = {
76
+ 'M+': date.getMonth() + 1,
77
+ 'd+': date.getDate(),
78
+ 'h+': date.getHours(),
79
+ 'm+': date.getMinutes(),
80
+ 's+': date.getSeconds()
81
+ }
82
+ for (const k in o) {
83
+ if (new RegExp(`(${k})`).test(fmt)) {
84
+ const str = o[k] + ''
85
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str))
86
+ }
87
+ }
88
+ return fmt
89
+ }
90
+
91
+ function padLeftZero(str) {
92
+ return ('00' + str).substr(str.length)
93
+ }
94
+
95
+ export default watermark
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <div :class="classObj" class="app-wrapper">
3
+ <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
4
+ <menubar class="sidebar-container" />
5
+ <div class="main-container">
6
+ <breadcrumb v-if="showMenuRoute" />
7
+ <app-main />
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ import { Menubar, AppMain, Breadcrumb } from './components'
14
+ import ResizeMixin from './mixin/ResizeHandler'
15
+ import { isShowMenuRoute } from '../../../src/utils/common-util'
16
+
17
+ export default {
18
+ name: 'Layout',
19
+ components: {
20
+ Menubar,
21
+ AppMain,
22
+ Breadcrumb
23
+ },
24
+ mixins: [ResizeMixin],
25
+ data() {
26
+ // 是否显示菜单路径,默认是不显示
27
+ const showMenuRoute = isShowMenuRoute()
28
+ return {
29
+ showMenuRoute
30
+ }
31
+ },
32
+ computed: {
33
+ sidebar() {
34
+ return this.$store.state.app.sidebar
35
+ },
36
+ device() {
37
+ return this.$store.state.app.device
38
+ },
39
+ classObj() {
40
+ return {
41
+ hideSidebar: !this.sidebar.opened,
42
+ openSidebar: this.sidebar.opened,
43
+ withoutAnimation: this.sidebar.withoutAnimation,
44
+ mobile: this.device === 'mobile'
45
+ }
46
+ }
47
+ },
48
+ methods: {
49
+ handleClickOutside() {
50
+ this.$store.dispatch('closeSidebar', { withoutAnimation: false })
51
+ }
52
+ }
53
+ }
54
+ </script>
55
+
56
+ <style rel="stylesheet/scss" lang="scss" scoped>
57
+ @import "../../styles/mixin.scss";
58
+ .app-wrapper {
59
+ @include clearfix;
60
+ position: relative;
61
+ height: 100%;
62
+ width: 100%;
63
+ &.mobile.openSidebar{
64
+ position: fixed;
65
+ top: 0;
66
+ }
67
+ }
68
+ .drawer-bg {
69
+ background: #000;
70
+ opacity: 0.3;
71
+ width: 100%;
72
+ top: 0;
73
+ height: 100%;
74
+ position: absolute;
75
+ z-index: 999;
76
+ }
77
+ </style>
@@ -15,6 +15,15 @@ export default {
15
15
  // key() {
16
16
  // return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
17
17
  // }
18
+
19
+ // 解决的问题如下:
20
+ // 改变路由参数(page?pageCode=xx)去获取对应数据,然后渲染到页面(用的是同一套组件),
21
+ // 问题来了:当切换菜单时,数据并没有更新,后来看了Vue-router官网,
22
+ // 有这么一句话:提醒一下,当使用路由参数时,例如从 /user/foo 导航到 user/bar,原来的组件实例会被复用。
23
+ // 因为两个路由都渲染同个组件,比起销毁再创建,复用则显得更加高效。不过,这也意味着组件的生命周期钩子不会再被调用
24
+ key() {
25
+ return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
26
+ }
18
27
  }
19
28
  }
20
29
  </script>