doway-coms 2.11.11 → 2.11.13

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 (91) hide show
  1. package/.browserslistrc +2 -2
  2. package/README.md +28 -28
  3. package/dist/css/chunk-vendors.7f83d8f9.css +8 -0
  4. package/dist/css/index.7946d50b.css +1 -0
  5. package/dist/favicon.ico +0 -0
  6. package/dist/js/chunk-vendors.28fda91d.js +340 -0
  7. package/dist/js/index.49bc6add.js +2 -0
  8. package/lib/doway-coms.common.js +120397 -0
  9. package/lib/doway-coms.css +1 -0
  10. package/lib/doway-coms.umd.js +120407 -0
  11. package/lib/doway-coms.umd.min.js +328 -0
  12. package/package.json +62 -62
  13. package/packages/AuditsList/index.js +7 -7
  14. package/packages/AuditsList/src/index.vue +314 -314
  15. package/packages/BaseButton/index.js +7 -7
  16. package/packages/BaseButton/src/index.vue +242 -242
  17. package/packages/BaseCheckbox/index.js +7 -7
  18. package/packages/BaseCheckbox/src/index.vue +134 -134
  19. package/packages/BaseDate/index.js +7 -7
  20. package/packages/BaseDate/src/index.vue +197 -197
  21. package/packages/BaseDateWeek/index.js +7 -7
  22. package/packages/BaseDateWeek/src/index.vue +163 -163
  23. package/packages/BaseDatetime/index.js +7 -7
  24. package/packages/BaseDatetime/src/index.vue +196 -196
  25. package/packages/BaseFileGroup/index.js +7 -7
  26. package/packages/BaseFileGroup/src/index.vue +724 -724
  27. package/packages/BaseForm/index.js +7 -7
  28. package/packages/BaseForm/src/index.vue +895 -895
  29. package/packages/BaseGantt/index.js +9 -9
  30. package/packages/BaseGantt/src/index.vue +617 -617
  31. package/packages/BaseGrid/index.js +9 -9
  32. package/packages/BaseGrid/src/exportCmp.vue +105 -105
  33. package/packages/BaseGrid/src/gridApi.js +32 -32
  34. package/packages/BaseGrid/src/index.vue +4242 -4230
  35. package/packages/BaseGridAdjust/index.js +9 -9
  36. package/packages/BaseGridAdjust/src/index.vue +482 -482
  37. package/packages/BaseInput/index.js +7 -7
  38. package/packages/BaseInput/src/index.vue +195 -195
  39. package/packages/BaseIntervalInput/index.js +7 -7
  40. package/packages/BaseIntervalInput/src/index.vue +310 -310
  41. package/packages/BaseKanbanEmpty/index.js +7 -7
  42. package/packages/BaseKanbanEmpty/src/index.vue +176 -176
  43. package/packages/BaseNumberInput/index.js +7 -7
  44. package/packages/BaseNumberInput/src/index.vue +291 -291
  45. package/packages/BasePagination/index.js +7 -7
  46. package/packages/BasePagination/src/index.vue +91 -91
  47. package/packages/BasePictureCard/index.js +7 -7
  48. package/packages/BasePictureCard/src/index.vue +671 -671
  49. package/packages/BasePrintPreview/index.js +7 -7
  50. package/packages/BasePrintPreview/src/index.vue +150 -150
  51. package/packages/BasePulldown/index.js +7 -7
  52. package/packages/BasePulldown/src/index.vue +1395 -1395
  53. package/packages/BaseSearch/index.js +7 -7
  54. package/packages/BaseSearch/src/index.vue +935 -935
  55. package/packages/BaseSelect/index.js +7 -7
  56. package/packages/BaseSelect/src/index.vue +155 -155
  57. package/packages/BaseSelectMulti/index.js +7 -7
  58. package/packages/BaseSelectMulti/src/index.vue +148 -148
  59. package/packages/BaseTextArea/index.js +7 -7
  60. package/packages/BaseTextArea/src/index.vue +187 -187
  61. package/packages/BaseTime/index.js +7 -7
  62. package/packages/BaseTime/src/index.vue +166 -166
  63. package/packages/BaseTool/index.js +7 -7
  64. package/packages/BaseTool/src/index.vue +353 -353
  65. package/packages/BaseToolStatus/index.js +7 -7
  66. package/packages/BaseToolStatus/src/ApprovalPersonsGroup.vue +41 -41
  67. package/packages/BaseToolStatus/src/index.vue +439 -439
  68. package/packages/BaseTreeSelect/index.js +8 -8
  69. package/packages/BaseTreeSelect/src/index.vue +437 -437
  70. package/packages/HistoryModal/index.js +8 -8
  71. package/packages/HistoryModal/src/index.vue +144 -144
  72. package/packages/LeaveAMessage/index.js +7 -7
  73. package/packages/LeaveAMessage/src/index.vue +601 -601
  74. package/packages/directive/clickoutside.js +44 -44
  75. package/packages/index.js +197 -197
  76. package/packages/styles/default.css +78 -78
  77. package/packages/styles/default.less +91 -91
  78. package/packages/utils/api.js +122 -122
  79. package/packages/utils/auth.js +38 -38
  80. package/packages/utils/common.js +703 -703
  81. package/packages/utils/dom.js +181 -181
  82. package/packages/utils/enum.js +86 -86
  83. package/packages/utils/filters.js +495 -485
  84. package/packages/utils/gridFormat.js +66 -66
  85. package/packages/utils/msg.js +103 -103
  86. package/packages/utils/patchFiles.js +44 -44
  87. package/packages/utils/request.js +181 -181
  88. package/packages/utils/store.js +372 -372
  89. package/packages/utils/tscPrinter.js +101 -101
  90. package/sync.bash +6 -6
  91. package/vue.config.js +59 -59
@@ -1,703 +1,703 @@
1
- import {notification } from 'ant-design-vue'
2
- import store from './store'
3
- import XEUtils from 'xe-utils'
4
- import axios from 'axios'
5
- /**
6
- * 替换掩码参数字符串
7
- * @param {参数字符串} paramString
8
- * @param {当前页面数据集} formData
9
- */
10
- export function replaceParamString(
11
- paramString,
12
- formData,
13
- currentModuleSelectInfo
14
- ) {
15
- // hh添加
16
- let tempStr = paramString
17
- while (true) {
18
- if (tempStr.indexOf('@Fn(') < 0) {
19
- break
20
- }
21
- let tempReplaceParam = tempStr.substr(tempStr.indexOf('@Fn('))
22
- tempReplaceParam = tempReplaceParam.substr(
23
- 0,
24
- tempReplaceParam.indexOf(')') + 1
25
- ) // 查找掩码参数
26
- let tempDataFields = tempReplaceParam
27
- .substr(0, tempReplaceParam.length - 1)
28
- .substr(4)
29
- .split('.')
30
- let tempReplaceValue = null
31
- if (tempDataFields[0] === '') {
32
- // 取主表数据
33
- tempReplaceValue = formData[tempDataFields[1]]
34
- } else {
35
- if (formData[tempDataFields[0]] instanceof Array) {
36
- let tempSelectItemInfo = currentModuleSelectInfo.filter(filterItem => {
37
- return filterItem.attrDataName === tempDataFields[0]
38
- })
39
- if (tempSelectItemInfo.length > 0) {
40
- let tempKeyFieldValue =
41
- tempSelectItemInfo[0].selectItem[tempSelectItemInfo[0].keyField]
42
- let tempActualRow = formData[tempDataFields[0]].filter(filterItem => {
43
- return (
44
- filterItem[tempSelectItemInfo[0].keyField] === tempKeyFieldValue
45
- )
46
- })
47
- if (tempActualRow.length > 0) {
48
- tempReplaceValue = tempActualRow[0][tempDataFields[1]]
49
- }
50
- }
51
- } else {
52
- tempReplaceValue = formData[tempDataFields[0]][tempDataFields[1]]
53
- }
54
- }
55
- //刘松嗣临时处理
56
- if (tempReplaceValue == undefined) {
57
- tempReplaceValue = '0'
58
- }
59
- tempStr = tempStr.substr(
60
- tempStr.indexOf(tempReplaceParam) + tempReplaceParam.length
61
- )
62
-
63
- if (typeof tempReplaceValue === 'string') {
64
- paramString = paramString.replace(
65
- tempReplaceParam,
66
- '"' + tempReplaceValue + '"'
67
- )
68
- tempStr = tempStr.replace(tempReplaceParam, '"' + tempReplaceValue + '"')
69
- } else {
70
- paramString = paramString.replace(tempReplaceParam, tempReplaceValue)
71
- tempStr = tempStr.replace(tempReplaceParam, tempReplaceValue)
72
- }
73
- }
74
- return paramString
75
- }
76
-
77
- /**
78
- * 替换掩码参数字符串
79
- * @param {参数字符串} paramString
80
- * @param {当前页面数据集} formData
81
- */
82
- export function replaceParam(paramString, formData) {
83
- let tempStr = paramString
84
- while (true) {
85
- if (tempStr.indexOf('@Fn(') < 0) {
86
- break
87
- }
88
- let tempReplaceParam = tempStr.substr(tempStr.indexOf('@Fn('))
89
- tempReplaceParam = tempReplaceParam.substr(
90
- 0,
91
- tempReplaceParam.indexOf(')') + 1
92
- ) // 查找掩码参数
93
- let tempDataFields = tempReplaceParam
94
- .substr(0, tempReplaceParam.length - 1)
95
- .substr(4)
96
- .split('.')
97
- let tempReplaceValue = null
98
- if (tempDataFields[0] === '') {
99
- // 取主表数据
100
- tempReplaceValue = formData[tempDataFields[1]]
101
- } else {
102
- tempReplaceValue = formData[tempDataFields[0]][tempDataFields[1]]
103
- }
104
- tempStr = tempStr.substr(
105
- tempStr.indexOf(tempReplaceParam) + tempReplaceParam.length
106
- )
107
-
108
- // if (typeof tempReplaceValue === 'string') {
109
- // paramString = paramString.replace(
110
- // tempReplaceParam,
111
- // '"' + tempReplaceValue + '"'
112
- // )
113
- // tempStr = tempStr.replace(tempReplaceParam, '"' + tempReplaceValue + '"')
114
- // } else {
115
- paramString = paramString.replace(tempReplaceParam, tempReplaceValue)
116
- tempStr = tempStr.replace(tempReplaceParam, tempReplaceValue)
117
- // }
118
- }
119
- return paramString
120
- }
121
-
122
- export function setFrameColState(formCols, formState, formStatus) {
123
- for (let prop in formCols) {
124
- if (formCols[prop].editStates instanceof Array) {
125
- let exists = formCols[prop].editStates.filter(item => {
126
- //editState:['add','edit']
127
- return item === formState // view === add|edit formState :view|add|edit
128
- }) //[]
129
- if (exists.length > 0) {
130
- formCols[prop].edit = true
131
- } else {
132
- formCols[prop].edit = false
133
- }
134
- }
135
- // 单据状态控制
136
- if (
137
- formStatus &&
138
- formCols[prop].editStatuss instanceof Array &&
139
- formCols[prop].editStatuss.length > 0 &&
140
- formCols[prop].edit === true
141
- ) {
142
- let formStatusExists = formCols[prop].editStatuss.filter(item => {
143
- //editStatuss:[,'publish',]
144
- return item === formStatus // formStatus:'draft'
145
- })
146
- if (formStatusExists.length > 0) {
147
- formCols[prop].edit = true
148
- } else {
149
- formCols[prop].edit = false
150
- }
151
- }
152
- // Vue.set(formCols, i, formCols[i])
153
- }
154
- }
155
- /**
156
- * 按钮条件权限
157
- * @param {} formData
158
- * @param {*} toolBars
159
- */
160
- export function setFrameToolPerExp(formData, toolBars) {
161
- for (let i = 0; i < toolBars.length; i++) {
162
- if(!toolBars[i].perExp){
163
- continue
164
- }
165
- //存在条件表达式
166
- toolBars[i].visible = evaluateExpression(formData, toolBars[i].perExp)
167
- }
168
- }
169
- /**
170
- * 评估表达式
171
- * @param {Object} formData
172
- * @param {Object} expression
173
- * @returns {boolean}
174
- */
175
- function evaluateExpression(formData, expression) {
176
- if (!expression.expressions) {
177
- return evaluateSimpleExpression(formData, expression)
178
- }
179
-
180
- const results = expression.expressions.map(exp => {
181
- if (exp.expressions) {
182
- // 处理嵌套表达式
183
- const subResults = exp.expressions.map(subExp =>
184
- evaluateSimpleExpression(formData, subExp)
185
- )
186
- return exp.operator === 'or'
187
- ? subResults.some(r => r)
188
- : subResults.every(r => r)
189
- }
190
- return evaluateSimpleExpression(formData, exp)
191
- })
192
-
193
- return expression.operator === 'and'
194
- ? results.every(r => r)
195
- : results.some(r => r)
196
- }
197
-
198
- /**
199
- * 评估简单表达式
200
- * @param {Object} formData
201
- * @param {Object} expression
202
- * @returns {boolean}
203
- */
204
- function evaluateSimpleExpression(formData, expression) {
205
- const { field, operator, value } = expression
206
- const fieldValue = formData[field]
207
-
208
- switch (operator) {
209
- case 'IN':
210
- return Array.isArray(value) && value.includes(fieldValue)
211
- case 'CO':
212
- return String(fieldValue).includes(String(value))
213
- case 'EQ':
214
- return fieldValue === value
215
- case 'NE':
216
- return fieldValue !== value
217
- // 可以根据需要添加更多操作符
218
- default:
219
- return false
220
- }
221
- }
222
- export function setFrameToolBtnState(toolBars, formState, formStatus) {
223
- for (let i = 0; i < toolBars.length; i++) {
224
- toolBars[i].visible = false
225
- toolBars[i].isPrimary = false
226
- if (
227
- toolBars[i].visibleStates &&
228
- toolBars[i].visibleStates.indexOf(formState) >= 0
229
- ) {
230
- toolBars[i].visible = true
231
- }
232
- if (formStatus && toolBars[i].visibleStatuss && toolBars[i].visible) {
233
- toolBars[i].visible = toolBars[i].visibleStatuss.indexOf(formStatus) >= 0
234
- }
235
- }
236
- // 查找优先级最大的并且显示的设置按钮强调色
237
- let visibleBtns = toolBars.filter(filterItem => {
238
- return filterItem.visible === true
239
- })
240
- //循环数组查找出小于自身的priority优先级 优先级高设置按钮强调色
241
- for (let i = 0; i < visibleBtns.length; i++) {
242
- let tempPriority = visibleBtns[i].priority
243
- let tempBtns = visibleBtns.filter(filterItem => {
244
- return filterItem.priority < tempPriority
245
- })
246
- //如果找到小于自身优先级的数量>0就说明还有更小的跳出本次不设置true继续查找
247
- if (tempBtns.length > 0) {
248
- continue
249
- }
250
- visibleBtns[i].isPrimary = true
251
- }
252
- }
253
- export function showErrors(errs) {
254
- let errors = ''
255
- for (let i = 0; i < errs.length; i++) {
256
- errors = errors + errs[i] + '\n'
257
- }
258
- notification.error({
259
- style: {
260
- whiteSpace: 'pre-wrap'
261
- },
262
- message: '错误',
263
- description: errors,
264
- placement: 'topRight',
265
- top: '100px'
266
- })
267
- }
268
- export function getUuid() {
269
- let d = new Date().getTime()
270
- let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(
271
- c
272
- ) {
273
- let r = (d + Math.random() * 16) % 16 | 0
274
- d = Math.floor(d / 16)
275
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)
276
- })
277
- return uuid
278
- }
279
- export async function getFormValidErrors(formView) {
280
- let formErrors = []
281
- const validFormError = await formView.validate().catch(errMap => errMap)
282
- if (validFormError === false) {
283
- for (let errorProp in formView.errors) {
284
- for (let x = 0; x < formView.errors[errorProp].length; x++) {
285
- formErrors.push(errorProp + ':' + formView.errors[errorProp][x])
286
- }
287
- }
288
- }
289
- return formErrors
290
- }
291
- export function stringUrlQuery(obj) {
292
- let strUrlQuery = ''
293
- for (let prop in obj) {
294
- strUrlQuery = strUrlQuery + prop + '=' + obj[prop] + '&'
295
- }
296
- if (strUrlQuery.length > 0) {
297
- strUrlQuery = strUrlQuery.substring(0, strUrlQuery.length - 1)
298
- }
299
- return strUrlQuery
300
- }
301
- export function getRouteFullPath(route) {
302
- let fullPath = route.path + '?' + stringUrlQuery(route.query)
303
- return fullPath
304
- }
305
- export async function getGridValidErrors(gridView) {
306
- const gridErrors = await gridView.fullValidate()
307
- return gridErrors
308
- }
309
-
310
- export function routeBeforeEach(to, from, next){
311
- if(to.params.aliveCacheKey){
312
- to.meta['aliveCacheKey'] = to.params.aliveCacheKey
313
- }
314
- if(!to.meta.aliveCacheKey){
315
- // alert('防呆,子应用没有路由缓存键:' + JSON.stringify(to))
316
- notification.error({
317
- style: {
318
- whiteSpace: 'pre-wrap'
319
- },
320
- message: '路由错误',
321
- description: '防呆,子应用没有路由缓存键:' + JSON.stringify(to),
322
- placement: 'topRight',
323
- top: '100px'
324
- })
325
- }
326
- if (to.meta.moduleCode && !store.getters.moduleViewInfo[to.meta.moduleCode]) {
327
- // axios.all([store.dispatch('moduleLoadViewInfo', { moduleCode: to.meta.moduleCode }),
328
- // store.dispatch('moduleLoadLangInfo', { moduleCode: to.meta.moduleCode,moduleLangCacheHash:to.meta.moduleLangCacheHash })])
329
- // .then(axios.spread(function() {
330
- // next()
331
- // }))
332
- store
333
- .dispatch('moduleLoadViewInfo', { moduleCode: to.meta.moduleCode,companyId: store.getters.company ? store.getters.company.id : '' })
334
- .then(() => {
335
- next()
336
- })
337
- .catch((err) => {
338
- console.debug(err)
339
- })
340
- } else {
341
- next()
342
- }
343
- }
344
-
345
- /**
346
- * 供应商未税单价计算金额
347
- * @param {行数据信息} rowInfo
348
- * @param {税率} taxRate
349
- * @param {数量字段} qtyField
350
- * @param {未税单价字段} unitPriceNotTaxField
351
- * @param {含税单价字段} unitPriceField
352
- * @param {未税金额字段} amountNotTaxField
353
- * @param {含税金额字段} amountField
354
- * @param {税额字段} taxField
355
- */
356
- export function supplyUnitPriceNotTaxAmount(rowInfo, taxRate, colInfo) {
357
- //未税计算方式
358
- //未税金额
359
- rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
360
- XEUtils.multiply(
361
- rowInfo[colInfo.qtyField],
362
- rowInfo[colInfo.unitPriceNotTaxField]
363
- ),
364
- 2
365
- )
366
- //税额
367
- rowInfo[colInfo.taxField] = XEUtils.round(
368
- XEUtils.multiply(rowInfo[colInfo.amountNotTaxField], taxRate),
369
- 2
370
- )
371
- //含税金额 = 未税金额+税额
372
- rowInfo[colInfo.amountField] = XEUtils.add(
373
- rowInfo[colInfo.amountNotTaxField],
374
- rowInfo[colInfo.taxField]
375
- )
376
- //返回来计算含税单价
377
-
378
- rowInfo[colInfo.unitPriceField] = XEUtils.round(
379
- XEUtils.divide(rowInfo[colInfo.amountField], rowInfo[colInfo.qtyField]),
380
- store.getters.supplyPricePrecision,
381
- )
382
-
383
- if (colInfo.direction) {
384
- rowInfo[colInfo.taxField] = XEUtils.multiply(
385
- rowInfo[colInfo.taxField],
386
- colInfo.direction
387
- )
388
- rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
389
- rowInfo[colInfo.amountNotTaxField],
390
- colInfo.direction
391
- )
392
- rowInfo[colInfo.amountField] = XEUtils.multiply(
393
- rowInfo[colInfo.amountField],
394
- colInfo.direction
395
- )
396
- }
397
- }
398
-
399
- /**
400
- * 供应商含税单价计算金额
401
- * @param {行数据信息} rowInfo
402
- * @param {税率} taxRate
403
- * @param {数量字段} qtyField
404
- * @param {未税单价字段} unitPriceNotTaxField
405
- * @param {含税单价字段} unitPriceField
406
- * @param {未税金额字段} amountNotTaxField
407
- * @param {含税金额字段} amountField
408
- * @param {税额字段} taxField
409
- */
410
- export function supplyUnitPriceAmount(rowInfo, taxRate, colInfo) {
411
- //含税计算方式
412
- rowInfo[colInfo.amountField] = XEUtils.round(
413
- XEUtils.multiply(
414
- rowInfo[colInfo.qtyField],
415
- rowInfo[colInfo.unitPriceField]
416
- ),
417
- 2
418
- )
419
- //未税金额 = 含税金额除以1.13
420
- let tempValue = XEUtils.add(1, taxRate)
421
- rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
422
- XEUtils.divide(rowInfo[colInfo.amountField], tempValue),
423
- 2
424
- )
425
- //税额 = 含税金额-未税金额
426
- rowInfo[colInfo.taxField] = XEUtils.subtract(
427
- rowInfo[colInfo.amountField],
428
- rowInfo[colInfo.amountNotTaxField]
429
- )
430
- //未税单价
431
- rowInfo[colInfo.unitPriceNotTaxField] = XEUtils.round(
432
- XEUtils.divide(
433
- rowInfo[colInfo.amountNotTaxField],
434
- rowInfo[colInfo.qtyField]
435
- ),
436
- store.getters.supplyPriceNotTaxPrecision,
437
- )
438
-
439
- if (colInfo.direction) {
440
- rowInfo[colInfo.taxField] = XEUtils.multiply(
441
- rowInfo[colInfo.taxField],
442
- colInfo.direction
443
- )
444
- rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
445
- rowInfo[colInfo.amountNotTaxField],
446
- colInfo.direction
447
- )
448
- rowInfo[colInfo.amountField] = XEUtils.multiply(
449
- rowInfo[colInfo.amountField],
450
- colInfo.direction
451
- )
452
- }
453
- }
454
-
455
- /**
456
- * 客户含税单价计算金额
457
- * @param {行数据信息} rowInfo
458
- * @param {税率} taxRate
459
- * @param {数量字段} qtyField
460
- * @param {未税单价字段} unitPriceNotTaxField
461
- * @param {含税单价字段} unitPriceField
462
- * @param {未税金额字段} amountNotTaxField
463
- * @param {含税金额字段} amountField
464
- * @param {税额字段} taxField
465
- */
466
- export function custUnitPriceAmount(rowInfo, taxRate, colInfo) {
467
- //含税计算方式
468
- rowInfo[colInfo.amountField] = XEUtils.round(
469
- XEUtils.multiply(
470
- rowInfo[colInfo.qtyField],
471
- rowInfo[colInfo.unitPriceField]
472
- ),
473
- 2
474
- )
475
- //未税金额 = 含税金额除以1.13
476
- let tempValue = XEUtils.add(1, taxRate)
477
- rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
478
- XEUtils.divide(rowInfo[colInfo.amountField], tempValue),
479
- 2
480
- )
481
- //税额 = 含税金额-未税金额
482
- rowInfo[colInfo.taxField] = XEUtils.subtract(
483
- rowInfo[colInfo.amountField],
484
- rowInfo[colInfo.amountNotTaxField]
485
- )
486
- //未税单价
487
- rowInfo[colInfo.unitPriceNotTaxField] = XEUtils.round(
488
- XEUtils.divide(
489
- rowInfo[colInfo.amountNotTaxField],
490
- rowInfo[colInfo.qtyField]
491
- ),
492
- store.getters.custPriceNotTaxPrecision,
493
- )
494
- if (colInfo.direction) {
495
- rowInfo[colInfo.taxField] = XEUtils.multiply(
496
- rowInfo[colInfo.taxField],
497
- colInfo.direction
498
- )
499
- rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
500
- rowInfo[colInfo.amountNotTaxField],
501
- colInfo.direction
502
- )
503
- rowInfo[colInfo.amountField] = XEUtils.multiply(
504
- rowInfo[colInfo.amountField],
505
- colInfo.direction
506
- )
507
- }
508
- }
509
- /**
510
- * 客户未税单价计算金额
511
- * @param {行数据信息} rowInfo
512
- * @param {税率} taxRate
513
- * @param {数量字段} qtyField
514
- * @param {未税单价字段} unitPriceNotTaxField
515
- * @param {含税单价字段} unitPriceField
516
- * @param {未税金额字段} amountNotTaxField
517
- * @param {含税金额字段} amountField
518
- * @param {税额字段} taxField
519
- */
520
- export function custUnitPriceNotTaxAmount(rowInfo, taxRate, colInfo) {
521
- //未税计算方式
522
- //未税金额
523
- rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
524
- XEUtils.multiply(
525
- rowInfo[colInfo.qtyField],
526
- rowInfo[colInfo.unitPriceNotTaxField]
527
- ),
528
- 2
529
- )
530
- //税额
531
- rowInfo[colInfo.taxField] = XEUtils.round(
532
- XEUtils.multiply(rowInfo[colInfo.amountNotTaxField], taxRate),
533
- 2
534
- )
535
- //含税金额 = 未税金额+税额
536
- rowInfo[colInfo.amountField] = XEUtils.add(
537
- rowInfo[colInfo.amountNotTaxField],
538
- rowInfo[colInfo.taxField]
539
- )
540
- //返回来计算含税单价
541
- rowInfo[colInfo.unitPriceField] = XEUtils.round(
542
- XEUtils.divide(rowInfo[colInfo.amountField], rowInfo[colInfo.qtyField]),
543
- store.getters.custPricePrecision,
544
- )
545
-
546
- if (colInfo.direction) {
547
- rowInfo[colInfo.taxField] = XEUtils.multiply(
548
- rowInfo[colInfo.taxField],
549
- colInfo.direction
550
- )
551
- rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
552
- rowInfo[colInfo.amountNotTaxField],
553
- colInfo.direction
554
- )
555
- rowInfo[colInfo.amountField] = XEUtils.multiply(
556
- rowInfo[colInfo.amountField],
557
- colInfo.direction
558
- )
559
- }
560
- }
561
- /**
562
- * 设置行业属性字段信息
563
- * @param {字段} fields
564
- */
565
- export function setIndustryVersionFields(fields){
566
- let length = fields.length
567
- for(let i=length-1;i>=0;i--){
568
- if(XEUtils.isArray(fields[i].versions)){
569
- let tempValue = XEUtils.find(fields[i].versions,p=>store.getters.industryVersion.includes(p))
570
- if(tempValue){
571
- continue
572
- }
573
- XEUtils.remove(fields,i)
574
- }
575
- }
576
- }
577
-
578
- /**
579
- * 计算数量保留位数及判断取整方向
580
- * @param {行数据信息} rowInfo
581
- * @param {数值} number
582
- * @param {位数} digits
583
- * @param {取整方向} round
584
- */
585
- export function numberDigitsRound(rowInfo, colInfo) {
586
- // 向上、向下、四舍五入
587
- switch (rowInfo[colInfo.round]) {
588
- case 'ceiling':
589
- rowInfo[colInfo.number] = XEUtils.ceil(rowInfo[colInfo.number], rowInfo[colInfo.digits])
590
- break;
591
- case 'floor':
592
- rowInfo[colInfo.number] = XEUtils.floor(rowInfo[colInfo.number], rowInfo[colInfo.digits])
593
- break;
594
- case 'round':
595
- rowInfo[colInfo.number] = rowInfo[colInfo.number].toFixed(rowInfo[colInfo.digits])
596
- break;
597
- }
598
- }
599
- // 导出用
600
- export function getExportParams(columns) {
601
- let tempParams = {
602
- fields: [],
603
- dicts: {}
604
- }
605
- for (let i = 0; i < columns.length; i++) {
606
- if (columns[i].visible === false) {
607
- continue
608
- }
609
- let tempFieldInfo = {
610
- field: columns[i].field,
611
- title: columns[i].title
612
- }
613
- tempParams.fields.push(tempFieldInfo)
614
- if (columns[i].dataSource && columns[i].dataSource.length > 0) {
615
- if (!tempParams.dicts[columns[i].field]) {
616
- tempParams.dicts[columns[i].field] = {}
617
- for (let j = 0; j < columns[i].dataSource.length; j++) {
618
- tempParams.dicts[columns[i].field][columns[i].dataSource[j].value] =
619
- columns[i].dataSource[j].caption
620
- }
621
- }
622
- }
623
- }
624
- return tempParams
625
- }
626
- export function setFormButtons(toolBtns,statusBtns,permissionBtns,tabs){
627
- // 将获取的数据进行排序
628
- let tempSortArr = permissionBtns.sort(function(a,b){
629
- a.sort = a.sort?a.sort:1
630
- b.sort = b.sort?b.sort:1
631
- return a.sort-b.sort
632
- })
633
- XEUtils.arrayEach(tempSortArr,loopBtn=>{
634
- let pushBtn = {
635
- code: loopBtn.code,
636
- caption: loopBtn.name,
637
- visible: true
638
- }
639
- if(loopBtn.visibleState){
640
- pushBtn['visibleStates'] = loopBtn.visibleState.split(',')
641
- }
642
- if(loopBtn.visibleStatus){
643
- pushBtn['visibleStatuss'] = loopBtn.visibleStatus.split(',')
644
- }
645
- let extraInfo = loopBtn.extraInfo
646
- ? JSON.parse(loopBtn.extraInfo)
647
- : {}
648
- if (Object.keys(extraInfo).length) {
649
- pushBtn = XEUtils.assign(extraInfo, pushBtn)
650
- }
651
- switch(loopBtn.buttonType){
652
- case 'tool':
653
- toolBtns.push(pushBtn)
654
- break
655
- case 'status':
656
- statusBtns.push(pushBtn)
657
- break
658
- case 'tab':
659
- tabs.push(pushBtn)
660
- break
661
- }
662
- })
663
- }
664
- export function getGridPagerButton(datas,dataCode){
665
- let returnButtons = []
666
- let tempData = XEUtils.find(datas,p=>p.code===dataCode)
667
- if(!tempData){
668
- return returnButtons
669
- }
670
-
671
- XEUtils.arrayEach(tempData.fields,loopField=>{
672
- if(loopField.controlType==='pager_button'){
673
- returnButtons.push({
674
- field:loopField.boundField,
675
- title:loopField.name,
676
- visible:true
677
- })
678
- }
679
- })
680
- return returnButtons
681
- }
682
- /**
683
- * 获取最大排序步长
684
- * @param {} datas
685
- * @param {*} fieldCode
686
- * @param {*} step
687
- */
688
- export function getStepMaxValue(datas,fieldCode,step){
689
- let tempSortStep = step
690
- let tempMaxObj = XEUtils.max(
691
- datas,
692
- fieldCode
693
- )
694
- let tempDtlMaxSort = 0
695
- if(tempMaxObj){
696
- tempDtlMaxSort = tempMaxObj.sort
697
- }
698
- tempDtlMaxSort = XEUtils.divide(tempDtlMaxSort, tempSortStep)
699
- tempDtlMaxSort = XEUtils.floor(tempDtlMaxSort, 0)
700
- tempDtlMaxSort = XEUtils.add(tempDtlMaxSort, 1)
701
- tempDtlMaxSort = XEUtils.multiply(tempDtlMaxSort, tempSortStep)
702
- return tempDtlMaxSort
703
- }
1
+ import {notification } from 'ant-design-vue'
2
+ import store from './store'
3
+ import XEUtils from 'xe-utils'
4
+ import axios from 'axios'
5
+ /**
6
+ * 替换掩码参数字符串
7
+ * @param {参数字符串} paramString
8
+ * @param {当前页面数据集} formData
9
+ */
10
+ export function replaceParamString(
11
+ paramString,
12
+ formData,
13
+ currentModuleSelectInfo
14
+ ) {
15
+ // hh添加
16
+ let tempStr = paramString
17
+ while (true) {
18
+ if (tempStr.indexOf('@Fn(') < 0) {
19
+ break
20
+ }
21
+ let tempReplaceParam = tempStr.substr(tempStr.indexOf('@Fn('))
22
+ tempReplaceParam = tempReplaceParam.substr(
23
+ 0,
24
+ tempReplaceParam.indexOf(')') + 1
25
+ ) // 查找掩码参数
26
+ let tempDataFields = tempReplaceParam
27
+ .substr(0, tempReplaceParam.length - 1)
28
+ .substr(4)
29
+ .split('.')
30
+ let tempReplaceValue = null
31
+ if (tempDataFields[0] === '') {
32
+ // 取主表数据
33
+ tempReplaceValue = formData[tempDataFields[1]]
34
+ } else {
35
+ if (formData[tempDataFields[0]] instanceof Array) {
36
+ let tempSelectItemInfo = currentModuleSelectInfo.filter(filterItem => {
37
+ return filterItem.attrDataName === tempDataFields[0]
38
+ })
39
+ if (tempSelectItemInfo.length > 0) {
40
+ let tempKeyFieldValue =
41
+ tempSelectItemInfo[0].selectItem[tempSelectItemInfo[0].keyField]
42
+ let tempActualRow = formData[tempDataFields[0]].filter(filterItem => {
43
+ return (
44
+ filterItem[tempSelectItemInfo[0].keyField] === tempKeyFieldValue
45
+ )
46
+ })
47
+ if (tempActualRow.length > 0) {
48
+ tempReplaceValue = tempActualRow[0][tempDataFields[1]]
49
+ }
50
+ }
51
+ } else {
52
+ tempReplaceValue = formData[tempDataFields[0]][tempDataFields[1]]
53
+ }
54
+ }
55
+ //刘松嗣临时处理
56
+ if (tempReplaceValue == undefined) {
57
+ tempReplaceValue = '0'
58
+ }
59
+ tempStr = tempStr.substr(
60
+ tempStr.indexOf(tempReplaceParam) + tempReplaceParam.length
61
+ )
62
+
63
+ if (typeof tempReplaceValue === 'string') {
64
+ paramString = paramString.replace(
65
+ tempReplaceParam,
66
+ '"' + tempReplaceValue + '"'
67
+ )
68
+ tempStr = tempStr.replace(tempReplaceParam, '"' + tempReplaceValue + '"')
69
+ } else {
70
+ paramString = paramString.replace(tempReplaceParam, tempReplaceValue)
71
+ tempStr = tempStr.replace(tempReplaceParam, tempReplaceValue)
72
+ }
73
+ }
74
+ return paramString
75
+ }
76
+
77
+ /**
78
+ * 替换掩码参数字符串
79
+ * @param {参数字符串} paramString
80
+ * @param {当前页面数据集} formData
81
+ */
82
+ export function replaceParam(paramString, formData) {
83
+ let tempStr = paramString
84
+ while (true) {
85
+ if (tempStr.indexOf('@Fn(') < 0) {
86
+ break
87
+ }
88
+ let tempReplaceParam = tempStr.substr(tempStr.indexOf('@Fn('))
89
+ tempReplaceParam = tempReplaceParam.substr(
90
+ 0,
91
+ tempReplaceParam.indexOf(')') + 1
92
+ ) // 查找掩码参数
93
+ let tempDataFields = tempReplaceParam
94
+ .substr(0, tempReplaceParam.length - 1)
95
+ .substr(4)
96
+ .split('.')
97
+ let tempReplaceValue = null
98
+ if (tempDataFields[0] === '') {
99
+ // 取主表数据
100
+ tempReplaceValue = formData[tempDataFields[1]]
101
+ } else {
102
+ tempReplaceValue = formData[tempDataFields[0]][tempDataFields[1]]
103
+ }
104
+ tempStr = tempStr.substr(
105
+ tempStr.indexOf(tempReplaceParam) + tempReplaceParam.length
106
+ )
107
+
108
+ // if (typeof tempReplaceValue === 'string') {
109
+ // paramString = paramString.replace(
110
+ // tempReplaceParam,
111
+ // '"' + tempReplaceValue + '"'
112
+ // )
113
+ // tempStr = tempStr.replace(tempReplaceParam, '"' + tempReplaceValue + '"')
114
+ // } else {
115
+ paramString = paramString.replace(tempReplaceParam, tempReplaceValue)
116
+ tempStr = tempStr.replace(tempReplaceParam, tempReplaceValue)
117
+ // }
118
+ }
119
+ return paramString
120
+ }
121
+
122
+ export function setFrameColState(formCols, formState, formStatus) {
123
+ for (let prop in formCols) {
124
+ if (formCols[prop].editStates instanceof Array) {
125
+ let exists = formCols[prop].editStates.filter(item => {
126
+ //editState:['add','edit']
127
+ return item === formState // view === add|edit formState :view|add|edit
128
+ }) //[]
129
+ if (exists.length > 0) {
130
+ formCols[prop].edit = true
131
+ } else {
132
+ formCols[prop].edit = false
133
+ }
134
+ }
135
+ // 单据状态控制
136
+ if (
137
+ formStatus &&
138
+ formCols[prop].editStatuss instanceof Array &&
139
+ formCols[prop].editStatuss.length > 0 &&
140
+ formCols[prop].edit === true
141
+ ) {
142
+ let formStatusExists = formCols[prop].editStatuss.filter(item => {
143
+ //editStatuss:[,'publish',]
144
+ return item === formStatus // formStatus:'draft'
145
+ })
146
+ if (formStatusExists.length > 0) {
147
+ formCols[prop].edit = true
148
+ } else {
149
+ formCols[prop].edit = false
150
+ }
151
+ }
152
+ // Vue.set(formCols, i, formCols[i])
153
+ }
154
+ }
155
+ /**
156
+ * 按钮条件权限
157
+ * @param {} formData
158
+ * @param {*} toolBars
159
+ */
160
+ export function setFrameToolPerExp(formData, toolBars) {
161
+ for (let i = 0; i < toolBars.length; i++) {
162
+ if(!toolBars[i].perExp){
163
+ continue
164
+ }
165
+ //存在条件表达式
166
+ toolBars[i].visible = evaluateExpression(formData, toolBars[i].perExp)
167
+ }
168
+ }
169
+ /**
170
+ * 评估表达式
171
+ * @param {Object} formData
172
+ * @param {Object} expression
173
+ * @returns {boolean}
174
+ */
175
+ function evaluateExpression(formData, expression) {
176
+ if (!expression.expressions) {
177
+ return evaluateSimpleExpression(formData, expression)
178
+ }
179
+
180
+ const results = expression.expressions.map(exp => {
181
+ if (exp.expressions) {
182
+ // 处理嵌套表达式
183
+ const subResults = exp.expressions.map(subExp =>
184
+ evaluateSimpleExpression(formData, subExp)
185
+ )
186
+ return exp.operator === 'or'
187
+ ? subResults.some(r => r)
188
+ : subResults.every(r => r)
189
+ }
190
+ return evaluateSimpleExpression(formData, exp)
191
+ })
192
+
193
+ return expression.operator === 'and'
194
+ ? results.every(r => r)
195
+ : results.some(r => r)
196
+ }
197
+
198
+ /**
199
+ * 评估简单表达式
200
+ * @param {Object} formData
201
+ * @param {Object} expression
202
+ * @returns {boolean}
203
+ */
204
+ function evaluateSimpleExpression(formData, expression) {
205
+ const { field, operator, value } = expression
206
+ const fieldValue = formData[field]
207
+
208
+ switch (operator) {
209
+ case 'IN':
210
+ return Array.isArray(value) && value.includes(fieldValue)
211
+ case 'CO':
212
+ return String(fieldValue).includes(String(value))
213
+ case 'EQ':
214
+ return fieldValue === value
215
+ case 'NE':
216
+ return fieldValue !== value
217
+ // 可以根据需要添加更多操作符
218
+ default:
219
+ return false
220
+ }
221
+ }
222
+ export function setFrameToolBtnState(toolBars, formState, formStatus) {
223
+ for (let i = 0; i < toolBars.length; i++) {
224
+ toolBars[i].visible = false
225
+ toolBars[i].isPrimary = false
226
+ if (
227
+ toolBars[i].visibleStates &&
228
+ toolBars[i].visibleStates.indexOf(formState) >= 0
229
+ ) {
230
+ toolBars[i].visible = true
231
+ }
232
+ if (formStatus && toolBars[i].visibleStatuss && toolBars[i].visible) {
233
+ toolBars[i].visible = toolBars[i].visibleStatuss.indexOf(formStatus) >= 0
234
+ }
235
+ }
236
+ // 查找优先级最大的并且显示的设置按钮强调色
237
+ let visibleBtns = toolBars.filter(filterItem => {
238
+ return filterItem.visible === true
239
+ })
240
+ //循环数组查找出小于自身的priority优先级 优先级高设置按钮强调色
241
+ for (let i = 0; i < visibleBtns.length; i++) {
242
+ let tempPriority = visibleBtns[i].priority
243
+ let tempBtns = visibleBtns.filter(filterItem => {
244
+ return filterItem.priority < tempPriority
245
+ })
246
+ //如果找到小于自身优先级的数量>0就说明还有更小的跳出本次不设置true继续查找
247
+ if (tempBtns.length > 0) {
248
+ continue
249
+ }
250
+ visibleBtns[i].isPrimary = true
251
+ }
252
+ }
253
+ export function showErrors(errs) {
254
+ let errors = ''
255
+ for (let i = 0; i < errs.length; i++) {
256
+ errors = errors + errs[i] + '\n'
257
+ }
258
+ notification.error({
259
+ style: {
260
+ whiteSpace: 'pre-wrap'
261
+ },
262
+ message: '错误',
263
+ description: errors,
264
+ placement: 'topRight',
265
+ top: '100px'
266
+ })
267
+ }
268
+ export function getUuid() {
269
+ let d = new Date().getTime()
270
+ let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(
271
+ c
272
+ ) {
273
+ let r = (d + Math.random() * 16) % 16 | 0
274
+ d = Math.floor(d / 16)
275
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)
276
+ })
277
+ return uuid
278
+ }
279
+ export async function getFormValidErrors(formView) {
280
+ let formErrors = []
281
+ const validFormError = await formView.validate().catch(errMap => errMap)
282
+ if (validFormError === false) {
283
+ for (let errorProp in formView.errors) {
284
+ for (let x = 0; x < formView.errors[errorProp].length; x++) {
285
+ formErrors.push(errorProp + ':' + formView.errors[errorProp][x])
286
+ }
287
+ }
288
+ }
289
+ return formErrors
290
+ }
291
+ export function stringUrlQuery(obj) {
292
+ let strUrlQuery = ''
293
+ for (let prop in obj) {
294
+ strUrlQuery = strUrlQuery + prop + '=' + obj[prop] + '&'
295
+ }
296
+ if (strUrlQuery.length > 0) {
297
+ strUrlQuery = strUrlQuery.substring(0, strUrlQuery.length - 1)
298
+ }
299
+ return strUrlQuery
300
+ }
301
+ export function getRouteFullPath(route) {
302
+ let fullPath = route.path + '?' + stringUrlQuery(route.query)
303
+ return fullPath
304
+ }
305
+ export async function getGridValidErrors(gridView) {
306
+ const gridErrors = await gridView.fullValidate()
307
+ return gridErrors
308
+ }
309
+
310
+ export function routeBeforeEach(to, from, next){
311
+ if(to.params.aliveCacheKey){
312
+ to.meta['aliveCacheKey'] = to.params.aliveCacheKey
313
+ }
314
+ if(!to.meta.aliveCacheKey){
315
+ // alert('防呆,子应用没有路由缓存键:' + JSON.stringify(to))
316
+ notification.error({
317
+ style: {
318
+ whiteSpace: 'pre-wrap'
319
+ },
320
+ message: '路由错误',
321
+ description: '防呆,子应用没有路由缓存键:' + JSON.stringify(to),
322
+ placement: 'topRight',
323
+ top: '100px'
324
+ })
325
+ }
326
+ if (to.meta.moduleCode && !store.getters.moduleViewInfo[to.meta.moduleCode]) {
327
+ // axios.all([store.dispatch('moduleLoadViewInfo', { moduleCode: to.meta.moduleCode }),
328
+ // store.dispatch('moduleLoadLangInfo', { moduleCode: to.meta.moduleCode,moduleLangCacheHash:to.meta.moduleLangCacheHash })])
329
+ // .then(axios.spread(function() {
330
+ // next()
331
+ // }))
332
+ store
333
+ .dispatch('moduleLoadViewInfo', { moduleCode: to.meta.moduleCode,companyId: store.getters.company ? store.getters.company.id : '' })
334
+ .then(() => {
335
+ next()
336
+ })
337
+ .catch((err) => {
338
+ console.debug(err)
339
+ })
340
+ } else {
341
+ next()
342
+ }
343
+ }
344
+
345
+ /**
346
+ * 供应商未税单价计算金额
347
+ * @param {行数据信息} rowInfo
348
+ * @param {税率} taxRate
349
+ * @param {数量字段} qtyField
350
+ * @param {未税单价字段} unitPriceNotTaxField
351
+ * @param {含税单价字段} unitPriceField
352
+ * @param {未税金额字段} amountNotTaxField
353
+ * @param {含税金额字段} amountField
354
+ * @param {税额字段} taxField
355
+ */
356
+ export function supplyUnitPriceNotTaxAmount(rowInfo, taxRate, colInfo) {
357
+ //未税计算方式
358
+ //未税金额
359
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
360
+ XEUtils.multiply(
361
+ rowInfo[colInfo.qtyField],
362
+ rowInfo[colInfo.unitPriceNotTaxField]
363
+ ),
364
+ 2
365
+ )
366
+ //税额
367
+ rowInfo[colInfo.taxField] = XEUtils.round(
368
+ XEUtils.multiply(rowInfo[colInfo.amountNotTaxField], taxRate),
369
+ 2
370
+ )
371
+ //含税金额 = 未税金额+税额
372
+ rowInfo[colInfo.amountField] = XEUtils.add(
373
+ rowInfo[colInfo.amountNotTaxField],
374
+ rowInfo[colInfo.taxField]
375
+ )
376
+ //返回来计算含税单价
377
+
378
+ rowInfo[colInfo.unitPriceField] = XEUtils.round(
379
+ XEUtils.divide(rowInfo[colInfo.amountField], rowInfo[colInfo.qtyField]),
380
+ store.getters.supplyPricePrecision,
381
+ )
382
+
383
+ if (colInfo.direction) {
384
+ rowInfo[colInfo.taxField] = XEUtils.multiply(
385
+ rowInfo[colInfo.taxField],
386
+ colInfo.direction
387
+ )
388
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
389
+ rowInfo[colInfo.amountNotTaxField],
390
+ colInfo.direction
391
+ )
392
+ rowInfo[colInfo.amountField] = XEUtils.multiply(
393
+ rowInfo[colInfo.amountField],
394
+ colInfo.direction
395
+ )
396
+ }
397
+ }
398
+
399
+ /**
400
+ * 供应商含税单价计算金额
401
+ * @param {行数据信息} rowInfo
402
+ * @param {税率} taxRate
403
+ * @param {数量字段} qtyField
404
+ * @param {未税单价字段} unitPriceNotTaxField
405
+ * @param {含税单价字段} unitPriceField
406
+ * @param {未税金额字段} amountNotTaxField
407
+ * @param {含税金额字段} amountField
408
+ * @param {税额字段} taxField
409
+ */
410
+ export function supplyUnitPriceAmount(rowInfo, taxRate, colInfo) {
411
+ //含税计算方式
412
+ rowInfo[colInfo.amountField] = XEUtils.round(
413
+ XEUtils.multiply(
414
+ rowInfo[colInfo.qtyField],
415
+ rowInfo[colInfo.unitPriceField]
416
+ ),
417
+ 2
418
+ )
419
+ //未税金额 = 含税金额除以1.13
420
+ let tempValue = XEUtils.add(1, taxRate)
421
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
422
+ XEUtils.divide(rowInfo[colInfo.amountField], tempValue),
423
+ 2
424
+ )
425
+ //税额 = 含税金额-未税金额
426
+ rowInfo[colInfo.taxField] = XEUtils.subtract(
427
+ rowInfo[colInfo.amountField],
428
+ rowInfo[colInfo.amountNotTaxField]
429
+ )
430
+ //未税单价
431
+ rowInfo[colInfo.unitPriceNotTaxField] = XEUtils.round(
432
+ XEUtils.divide(
433
+ rowInfo[colInfo.amountNotTaxField],
434
+ rowInfo[colInfo.qtyField]
435
+ ),
436
+ store.getters.supplyPriceNotTaxPrecision,
437
+ )
438
+
439
+ if (colInfo.direction) {
440
+ rowInfo[colInfo.taxField] = XEUtils.multiply(
441
+ rowInfo[colInfo.taxField],
442
+ colInfo.direction
443
+ )
444
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
445
+ rowInfo[colInfo.amountNotTaxField],
446
+ colInfo.direction
447
+ )
448
+ rowInfo[colInfo.amountField] = XEUtils.multiply(
449
+ rowInfo[colInfo.amountField],
450
+ colInfo.direction
451
+ )
452
+ }
453
+ }
454
+
455
+ /**
456
+ * 客户含税单价计算金额
457
+ * @param {行数据信息} rowInfo
458
+ * @param {税率} taxRate
459
+ * @param {数量字段} qtyField
460
+ * @param {未税单价字段} unitPriceNotTaxField
461
+ * @param {含税单价字段} unitPriceField
462
+ * @param {未税金额字段} amountNotTaxField
463
+ * @param {含税金额字段} amountField
464
+ * @param {税额字段} taxField
465
+ */
466
+ export function custUnitPriceAmount(rowInfo, taxRate, colInfo) {
467
+ //含税计算方式
468
+ rowInfo[colInfo.amountField] = XEUtils.round(
469
+ XEUtils.multiply(
470
+ rowInfo[colInfo.qtyField],
471
+ rowInfo[colInfo.unitPriceField]
472
+ ),
473
+ 2
474
+ )
475
+ //未税金额 = 含税金额除以1.13
476
+ let tempValue = XEUtils.add(1, taxRate)
477
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
478
+ XEUtils.divide(rowInfo[colInfo.amountField], tempValue),
479
+ 2
480
+ )
481
+ //税额 = 含税金额-未税金额
482
+ rowInfo[colInfo.taxField] = XEUtils.subtract(
483
+ rowInfo[colInfo.amountField],
484
+ rowInfo[colInfo.amountNotTaxField]
485
+ )
486
+ //未税单价
487
+ rowInfo[colInfo.unitPriceNotTaxField] = XEUtils.round(
488
+ XEUtils.divide(
489
+ rowInfo[colInfo.amountNotTaxField],
490
+ rowInfo[colInfo.qtyField]
491
+ ),
492
+ store.getters.custPriceNotTaxPrecision,
493
+ )
494
+ if (colInfo.direction) {
495
+ rowInfo[colInfo.taxField] = XEUtils.multiply(
496
+ rowInfo[colInfo.taxField],
497
+ colInfo.direction
498
+ )
499
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
500
+ rowInfo[colInfo.amountNotTaxField],
501
+ colInfo.direction
502
+ )
503
+ rowInfo[colInfo.amountField] = XEUtils.multiply(
504
+ rowInfo[colInfo.amountField],
505
+ colInfo.direction
506
+ )
507
+ }
508
+ }
509
+ /**
510
+ * 客户未税单价计算金额
511
+ * @param {行数据信息} rowInfo
512
+ * @param {税率} taxRate
513
+ * @param {数量字段} qtyField
514
+ * @param {未税单价字段} unitPriceNotTaxField
515
+ * @param {含税单价字段} unitPriceField
516
+ * @param {未税金额字段} amountNotTaxField
517
+ * @param {含税金额字段} amountField
518
+ * @param {税额字段} taxField
519
+ */
520
+ export function custUnitPriceNotTaxAmount(rowInfo, taxRate, colInfo) {
521
+ //未税计算方式
522
+ //未税金额
523
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.round(
524
+ XEUtils.multiply(
525
+ rowInfo[colInfo.qtyField],
526
+ rowInfo[colInfo.unitPriceNotTaxField]
527
+ ),
528
+ 2
529
+ )
530
+ //税额
531
+ rowInfo[colInfo.taxField] = XEUtils.round(
532
+ XEUtils.multiply(rowInfo[colInfo.amountNotTaxField], taxRate),
533
+ 2
534
+ )
535
+ //含税金额 = 未税金额+税额
536
+ rowInfo[colInfo.amountField] = XEUtils.add(
537
+ rowInfo[colInfo.amountNotTaxField],
538
+ rowInfo[colInfo.taxField]
539
+ )
540
+ //返回来计算含税单价
541
+ rowInfo[colInfo.unitPriceField] = XEUtils.round(
542
+ XEUtils.divide(rowInfo[colInfo.amountField], rowInfo[colInfo.qtyField]),
543
+ store.getters.custPricePrecision,
544
+ )
545
+
546
+ if (colInfo.direction) {
547
+ rowInfo[colInfo.taxField] = XEUtils.multiply(
548
+ rowInfo[colInfo.taxField],
549
+ colInfo.direction
550
+ )
551
+ rowInfo[colInfo.amountNotTaxField] = XEUtils.multiply(
552
+ rowInfo[colInfo.amountNotTaxField],
553
+ colInfo.direction
554
+ )
555
+ rowInfo[colInfo.amountField] = XEUtils.multiply(
556
+ rowInfo[colInfo.amountField],
557
+ colInfo.direction
558
+ )
559
+ }
560
+ }
561
+ /**
562
+ * 设置行业属性字段信息
563
+ * @param {字段} fields
564
+ */
565
+ export function setIndustryVersionFields(fields){
566
+ let length = fields.length
567
+ for(let i=length-1;i>=0;i--){
568
+ if(XEUtils.isArray(fields[i].versions)){
569
+ let tempValue = XEUtils.find(fields[i].versions,p=>store.getters.industryVersion.includes(p))
570
+ if(tempValue){
571
+ continue
572
+ }
573
+ XEUtils.remove(fields,i)
574
+ }
575
+ }
576
+ }
577
+
578
+ /**
579
+ * 计算数量保留位数及判断取整方向
580
+ * @param {行数据信息} rowInfo
581
+ * @param {数值} number
582
+ * @param {位数} digits
583
+ * @param {取整方向} round
584
+ */
585
+ export function numberDigitsRound(rowInfo, colInfo) {
586
+ // 向上、向下、四舍五入
587
+ switch (rowInfo[colInfo.round]) {
588
+ case 'ceiling':
589
+ rowInfo[colInfo.number] = XEUtils.ceil(rowInfo[colInfo.number], rowInfo[colInfo.digits])
590
+ break;
591
+ case 'floor':
592
+ rowInfo[colInfo.number] = XEUtils.floor(rowInfo[colInfo.number], rowInfo[colInfo.digits])
593
+ break;
594
+ case 'round':
595
+ rowInfo[colInfo.number] = rowInfo[colInfo.number].toFixed(rowInfo[colInfo.digits])
596
+ break;
597
+ }
598
+ }
599
+ // 导出用
600
+ export function getExportParams(columns) {
601
+ let tempParams = {
602
+ fields: [],
603
+ dicts: {}
604
+ }
605
+ for (let i = 0; i < columns.length; i++) {
606
+ if (columns[i].visible === false) {
607
+ continue
608
+ }
609
+ let tempFieldInfo = {
610
+ field: columns[i].field,
611
+ title: columns[i].title
612
+ }
613
+ tempParams.fields.push(tempFieldInfo)
614
+ if (columns[i].dataSource && columns[i].dataSource.length > 0) {
615
+ if (!tempParams.dicts[columns[i].field]) {
616
+ tempParams.dicts[columns[i].field] = {}
617
+ for (let j = 0; j < columns[i].dataSource.length; j++) {
618
+ tempParams.dicts[columns[i].field][columns[i].dataSource[j].value] =
619
+ columns[i].dataSource[j].caption
620
+ }
621
+ }
622
+ }
623
+ }
624
+ return tempParams
625
+ }
626
+ export function setFormButtons(toolBtns,statusBtns,permissionBtns,tabs){
627
+ // 将获取的数据进行排序
628
+ let tempSortArr = permissionBtns.sort(function(a,b){
629
+ a.sort = a.sort?a.sort:1
630
+ b.sort = b.sort?b.sort:1
631
+ return a.sort-b.sort
632
+ })
633
+ XEUtils.arrayEach(tempSortArr,loopBtn=>{
634
+ let pushBtn = {
635
+ code: loopBtn.code,
636
+ caption: loopBtn.name,
637
+ visible: true
638
+ }
639
+ if(loopBtn.visibleState){
640
+ pushBtn['visibleStates'] = loopBtn.visibleState.split(',')
641
+ }
642
+ if(loopBtn.visibleStatus){
643
+ pushBtn['visibleStatuss'] = loopBtn.visibleStatus.split(',')
644
+ }
645
+ let extraInfo = loopBtn.extraInfo
646
+ ? JSON.parse(loopBtn.extraInfo)
647
+ : {}
648
+ if (Object.keys(extraInfo).length) {
649
+ pushBtn = XEUtils.assign(extraInfo, pushBtn)
650
+ }
651
+ switch(loopBtn.buttonType){
652
+ case 'tool':
653
+ toolBtns.push(pushBtn)
654
+ break
655
+ case 'status':
656
+ statusBtns.push(pushBtn)
657
+ break
658
+ case 'tab':
659
+ tabs.push(pushBtn)
660
+ break
661
+ }
662
+ })
663
+ }
664
+ export function getGridPagerButton(datas,dataCode){
665
+ let returnButtons = []
666
+ let tempData = XEUtils.find(datas,p=>p.code===dataCode)
667
+ if(!tempData){
668
+ return returnButtons
669
+ }
670
+
671
+ XEUtils.arrayEach(tempData.fields,loopField=>{
672
+ if(loopField.controlType==='pager_button'){
673
+ returnButtons.push({
674
+ field:loopField.boundField,
675
+ title:loopField.name,
676
+ visible:true
677
+ })
678
+ }
679
+ })
680
+ return returnButtons
681
+ }
682
+ /**
683
+ * 获取最大排序步长
684
+ * @param {} datas
685
+ * @param {*} fieldCode
686
+ * @param {*} step
687
+ */
688
+ export function getStepMaxValue(datas,fieldCode,step){
689
+ let tempSortStep = step
690
+ let tempMaxObj = XEUtils.max(
691
+ datas,
692
+ fieldCode
693
+ )
694
+ let tempDtlMaxSort = 0
695
+ if(tempMaxObj){
696
+ tempDtlMaxSort = tempMaxObj.sort
697
+ }
698
+ tempDtlMaxSort = XEUtils.divide(tempDtlMaxSort, tempSortStep)
699
+ tempDtlMaxSort = XEUtils.floor(tempDtlMaxSort, 0)
700
+ tempDtlMaxSort = XEUtils.add(tempDtlMaxSort, 1)
701
+ tempDtlMaxSort = XEUtils.multiply(tempDtlMaxSort, tempSortStep)
702
+ return tempDtlMaxSort
703
+ }