doway-coms 2.11.61 → 2.11.66

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