bri-components 1.4.91 → 1.4.93

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 (156) hide show
  1. package/README.md +83 -83
  2. package/lib/styles/bundle.css +12 -12
  3. package/lib/styles/font/fontello.svg +31 -31
  4. package/package.json +125 -125
  5. package/src/components/Error/Error403.vue +42 -42
  6. package/src/components/Error/Error404.vue +40 -40
  7. package/src/components/Error/Error500.vue +51 -51
  8. package/src/components/Error/error.less +162 -162
  9. package/src/components/Error/errorBack.vue +40 -40
  10. package/src/components/controls/DshControlInput.vue +195 -195
  11. package/src/components/controls/base/BriUpload/BriUpload.vue +434 -435
  12. package/src/components/controls/base/BriUpload/BriUploadImage.vue +373 -373
  13. package/src/components/controls/base/BriUpload/uploadList.vue +724 -724
  14. package/src/components/controls/base/BriUpload/uploadMixin.js +446 -417
  15. package/src/components/controls/base/DshCascader/DshCascader.vue +210 -210
  16. package/src/components/controls/base/DshCascader/components/cascaderModal.vue +366 -366
  17. package/src/components/controls/base/DshCascader/components/cascaderPicker.vue +416 -416
  18. package/src/components/controls/base/DshCascader/components/cascaderSimple.vue +143 -143
  19. package/src/components/controls/base/DshCoordinates.vue +577 -577
  20. package/src/components/controls/base/DshDate/DshDate.vue +191 -191
  21. package/src/components/controls/base/DshDate/DshDaterange.vue +186 -186
  22. package/src/components/controls/base/DshDivider.vue +201 -201
  23. package/src/components/controls/base/DshEditor.vue +274 -274
  24. package/src/components/controls/base/DshInput/BriInputs.vue +166 -166
  25. package/src/components/controls/base/DshInput/DshInput.vue +255 -255
  26. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +435 -435
  27. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -34
  28. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -14
  29. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -322
  30. package/src/components/controls/base/DshNumber/DshNumber.vue +143 -143
  31. package/src/components/controls/base/DshNumber/DshNumberange.vue +109 -109
  32. package/src/components/controls/base/DshSelect/DshCheckbox.vue +168 -168
  33. package/src/components/controls/base/DshSelect/DshSelect.vue +180 -180
  34. package/src/components/controls/base/DshSwitch/DshSwitch.vue +115 -115
  35. package/src/components/controls/control.less +324 -324
  36. package/src/components/controls/controlMap.js +114 -114
  37. package/src/components/controls/extra/DshColor.vue +81 -81
  38. package/src/components/controls/extra/themeColor.vue +104 -104
  39. package/src/components/controls/extra/themeIcon.vue +114 -114
  40. package/src/components/controls/mixins/cascaderMixin.js +295 -295
  41. package/src/components/controls/mixins/cascaderPickerMixin.js +216 -216
  42. package/src/components/controls/mixins/cascaderTableMixin.js +130 -130
  43. package/src/components/controls/mixins/controlMixin.js +368 -368
  44. package/src/components/controls/mixins/dateMixin.js +149 -147
  45. package/src/components/controls/mixins/flatTableMixin.js +111 -111
  46. package/src/components/controls/mixins/numberMixin.js +112 -112
  47. package/src/components/controls/mixins/selectMixin.js +233 -233
  48. package/src/components/controls/mixins/switchMixin.js +87 -87
  49. package/src/components/controls/mixins/userAndDepartMixin.js +218 -218
  50. package/src/components/controls/senior/DshLabels.vue +331 -331
  51. package/src/components/controls/senior/DshPackage.vue +57 -57
  52. package/src/components/controls/senior/cascaderTable.vue +210 -210
  53. package/src/components/controls/senior/flatTable.vue +135 -135
  54. package/src/components/controls/senior/selectDepartments.vue +438 -438
  55. package/src/components/controls/senior/selectUsers/departMenu.vue +293 -293
  56. package/src/components/controls/senior/selectUsers/selectUsers.vue +752 -752
  57. package/src/components/controls/special/DshBack.vue +42 -42
  58. package/src/components/controls/special/DshUndeveloped.vue +41 -41
  59. package/src/components/form/DshAdvSearch.vue +510 -510
  60. package/src/components/form/DshDefaultSearch.vue +258 -258
  61. package/src/components/form/DshForm.vue +494 -494
  62. package/src/components/form/searchMixin.js +375 -375
  63. package/src/components/list/BriCard.vue +95 -95
  64. package/src/components/list/BriTable.vue +205 -205
  65. package/src/components/list/BriTree.vue +529 -529
  66. package/src/components/list/BriTreeItem.vue +163 -163
  67. package/src/components/list/DshBox/DshBox.vue +219 -219
  68. package/src/components/list/DshBox/DshCard.vue +446 -446
  69. package/src/components/list/DshBox/DshCrossTable.vue +827 -827
  70. package/src/components/list/DshBox/DshList.vue +404 -404
  71. package/src/components/list/DshBox/DshPanel.vue +669 -669
  72. package/src/components/list/DshBox/DshSingleData.vue +119 -119
  73. package/src/components/list/DshBox/DshTable.vue +239 -239
  74. package/src/components/list/DshCascaderTable.vue +115 -115
  75. package/src/components/list/DshFlatTable.vue +339 -339
  76. package/src/components/list/DshPage.vue +194 -194
  77. package/src/components/list/DshTreeTable.vue +113 -113
  78. package/src/components/list/common/importModal.vue +243 -243
  79. package/src/components/list/common/quoteListModal.vue +206 -206
  80. package/src/components/list/mixins/DshCascaderTableMixin.js +278 -278
  81. package/src/components/list/mixins/DshFlatTableMixin.js +493 -493
  82. package/src/components/list/mixins/DshTreeTableMixin.js +286 -286
  83. package/src/components/list/mixins/tableBaseMixin.js +1661 -1662
  84. package/src/components/list/mixins/treeTableBaseMixin.js +149 -149
  85. package/src/components/other/BriAvatar.vue +166 -166
  86. package/src/components/other/BriCode.vue +125 -125
  87. package/src/components/other/BriCollapseTree.vue +207 -207
  88. package/src/components/other/BriGantt.vue +1084 -1084
  89. package/src/components/other/BriIframe.vue +116 -116
  90. package/src/components/other/BriLoading.vue +171 -171
  91. package/src/components/other/BriSvg.vue +28 -28
  92. package/src/components/other/DshColorPanel.vue +128 -128
  93. package/src/components/other/DshMenuNav.vue +188 -188
  94. package/src/components/small/BriButton.vue +71 -71
  95. package/src/components/small/BriDrawer.vue +169 -169
  96. package/src/components/small/BriTooltip.vue +87 -87
  97. package/src/components/small/DshBtnModal.vue +68 -68
  98. package/src/components/small/DshButtons.vue +324 -324
  99. package/src/components/small/DshDropdown.vue +225 -225
  100. package/src/components/small/DshIcons.vue +59 -59
  101. package/src/components/small/DshListRender.js +21 -21
  102. package/src/components/small/DshModal.vue +160 -160
  103. package/src/components/small/DshSteps.vue +141 -141
  104. package/src/components/small/DshTabs.vue +598 -598
  105. package/src/components/small/DshTabsSet.vue +309 -309
  106. package/src/components/small/DshTags.vue +251 -251
  107. package/src/components/small/DshTitle.vue +50 -50
  108. package/src/components/small/render.js +20 -20
  109. package/src/components/unit/DshFormUnit.vue +398 -398
  110. package/src/components/unit/DshListUnit.vue +115 -107
  111. package/src/components/unit/unitMixin.js +86 -86
  112. package/src/data/index.js +9 -9
  113. package/src/index.js +271 -271
  114. package/src/styles/bundle.css +12 -12
  115. package/src/styles/components/BriButton.less +292 -292
  116. package/src/styles/components/BriTable.less +344 -344
  117. package/src/styles/components/DshModal.less +250 -250
  118. package/src/styles/components/index.less +3 -3
  119. package/src/styles/global/animate.less +11 -11
  120. package/src/styles/global/base.less +45 -45
  121. package/src/styles/global/box.less +186 -186
  122. package/src/styles/global/control.less +122 -122
  123. package/src/styles/global/flex.less +282 -282
  124. package/src/styles/global/global.less +8 -8
  125. package/src/styles/global/text.less +59 -59
  126. package/src/styles/global/variables.less +85 -85
  127. package/src/styles/iconfont/iconfont.css +254 -254
  128. package/src/styles/iconfont/iconfont.json +422 -422
  129. package/src/styles/iconfont/iconfont.svg +137 -137
  130. package/src/styles/index.less +11 -11
  131. package/src/styles/reset-easytable.less +21 -21
  132. package/src/styles/reset-iview-controls.less +145 -145
  133. package/src/styles/reset-iview-other.less +49 -49
  134. package/src/styles/reset-iview-variables.less +34 -34
  135. package/src/styles/reset.less +45 -45
  136. package/src/utils/index.js +5 -5
  137. package/src/utils/table.js +175 -175
  138. package/lib/0.bri-components.min.js +0 -1
  139. package/lib/1.bri-components.min.js +0 -1
  140. package/lib/10.bri-components.min.js +0 -1
  141. package/lib/11.bri-components.min.js +0 -1
  142. package/lib/2.bri-components.min.js +0 -1
  143. package/lib/3.bri-components.min.js +0 -1
  144. package/lib/4.bri-components.min.js +0 -1
  145. package/lib/5.bri-components.min.js +0 -1
  146. package/lib/6.bri-components.min.js +0 -1
  147. package/lib/7.bri-components.min.js +0 -1
  148. package/lib/8.bri-components.min.js +0 -1
  149. package/lib/9.bri-components.min.js +0 -1
  150. package/lib/bri-components.min.js +0 -18
  151. package/src/.DS_Store +0 -0
  152. package/src/components/.DS_Store +0 -0
  153. package/src/components/controls/.DS_Store +0 -0
  154. package/src/components/controls/senior/.DS_Store +0 -0
  155. package/src/styles/.DS_Store +0 -0
  156. package/src/styles/components/.DS_Store +0 -0
@@ -1,375 +1,375 @@
1
- import DshFormUnit from "../unit/DshFormUnit.vue";
2
-
3
- export default {
4
- components: {
5
- DshFormUnit
6
- },
7
- props: {
8
- initFields: {
9
- type: Array,
10
- default () {
11
- return [];
12
- }
13
- },
14
- value: {
15
- type: Object,
16
- default () {
17
- return {
18
- logic: "and",
19
- conditions: []
20
- };
21
- }
22
- },
23
- formList: {
24
- type: Array,
25
- default () {
26
- return [];
27
- }
28
- },
29
- useChainField: {
30
- type: Boolean,
31
- default: false
32
- },
33
- dynamicFormList: {
34
- type: Array,
35
- default () {
36
- return [];
37
- }
38
- }
39
- },
40
- data () {
41
- return {
42
- fieldMap: this.$modFieldMap,
43
-
44
- advSearchObj: {
45
- logic: "and",
46
- conditions: []
47
- },
48
- parameterPropsObj: {
49
- _name: "参数类型",
50
- _key: "parameterType",
51
- _clearable: false,
52
- _size: "small",
53
- _default: "fixedText",
54
- _data: [
55
- { _key: "fixedText", name: "固定文本" },
56
- { _key: "dynamicText", name: "动态文本" }
57
- ]
58
- }
59
- };
60
- },
61
- computed: {
62
- canSearchFormList () {
63
- return this.formList.filter(formItem =>
64
- this.$formHasAbility(formItem, "canSearch") &&
65
- (this.mode === "set" ? true : formItem._displayType !== "hide")
66
- );
67
- },
68
- dynamicFieldsMap () {
69
- return this.$arrToCategoryArr(this.dynamicFormList);
70
- }
71
- },
72
- created () {
73
- this.init();
74
- },
75
- methods: {
76
- // 初始化
77
- init () {
78
- this.advSearchObj = this.$deepCopy(this.value);
79
- this.advSearchObj.conditions = [...this.initFields, ...this.advSearchObj.conditions].map(conditionItem => {
80
- const newConditionItem = typeof conditionItem === "string"
81
- ? this.createContionFunc(undefined, undefined, conditionItem)
82
- : this.createContionFunc(conditionItem, undefined, conditionItem.fieldKey);
83
- this.dealSubSearch(newConditionItem);
84
-
85
- return newConditionItem;
86
- });
87
- },
88
-
89
- // 新增条件项
90
- createCondition (operationItem, isLoop, formItem, list) {
91
- const newConditionItem = this.createContionFunc({ logic: isLoop ? "and" : "field" }, formItem);
92
- this.dealSubSearch(newConditionItem);
93
- list.push(newConditionItem);
94
-
95
- this.change(operationItem.type, newConditionItem);
96
- },
97
- // 删除条件项
98
- deleteCondition (operationItem, conditionItem, conditionIndex, list) {
99
- list.splice(conditionIndex, 1);
100
-
101
- this.change(operationItem.type, conditionItem);
102
- },
103
- // 获取动态文本或固定文本类型 选项列表
104
- getParameterData (conditionItem) {
105
- // 配置端 且 含有子集的
106
- return !!conditionItem.dynamicList.length && conditionItem.operators.some(operator => ["subSearch", "subTableSearch", "cascaderTableSearch", "treeTableSearch"].includes(operator._key))
107
- ? []
108
- : this.parameterPropsObj._data;
109
- },
110
- // 选择某控件的动态文本或固定文本类型
111
- changeParameterType (operationItem, conditionItem, conditionIndex, list, optionItem) {
112
- conditionItem.parameterType = optionItem._key;
113
- conditionItem.parameterTypeName = optionItem.name;
114
- conditionItem.fieldParams = [];
115
- conditionItem.chainFieldKey = "";
116
- conditionItem.fieldValue = [];
117
-
118
- this.change(operationItem.type, conditionItem);
119
- },
120
- // 选择某控件的操作类型
121
- changeOperator (operationItem, conditionItem, conditionIndex, list, optionItem) {
122
- if (optionItem._key !== conditionItem.fieldOperator) {
123
- conditionItem.fieldOperator = optionItem._key;
124
- conditionItem.fieldOperatorName = optionItem.name;
125
-
126
- if (["isnull", "notnull", "nosize", "size", "nolist", "list"].includes(conditionItem.fieldOperator)) {
127
- conditionItem.fieldParams = [];
128
- conditionItem.chainFieldKey = "";
129
- conditionItem.fieldValue = [];
130
- conditionItem.fieldSearch = {
131
- logic: "and",
132
- conditions: []
133
- };
134
- } else if (["subSearch", "subTableSearch", "cascaderTableSearch", "treeTableSearch"].includes(conditionItem.fieldOperator)) {
135
- conditionItem.fieldParams = [];
136
- conditionItem.chainFieldKey = "";
137
- conditionItem.fieldValue = [];
138
- this.dealSubSearch(conditionItem);
139
- } else {
140
- conditionItem.fieldSearch = {
141
- logic: "and",
142
- conditions: []
143
- };
144
- }
145
-
146
- this.change(operationItem.type, conditionItem);
147
- }
148
- },
149
- // 发生改动
150
- change (operationType, conditionItem, ...params) {
151
- if (operationType === "loopSearch") {
152
- const subAdvSearchObj = params[0];
153
- Object.assign(conditionItem, subAdvSearchObj);
154
- } else if (operationType === "subSearch") {
155
- const subAdvSearchObj = params[0];
156
- Object.assign(conditionItem.fieldSearch, subAdvSearchObj);
157
- }
158
-
159
- const advSearchObj = {
160
- ...this.advSearchObj,
161
- conditions: this.transformConditions(this.advSearchObj.conditions)
162
- };
163
- this.$emit("change", advSearchObj, operationType, conditionItem);
164
- },
165
-
166
- /* -------- 方法 ----------- */
167
- // 生成条件项的值
168
- createContionFunc (initContion = { logic: "field" }, curFormItem, fieldKey) {
169
- if (["field", undefined].includes(initContion.logic)) {
170
- curFormItem = curFormItem || this.canSearchFormList.find(formItem => formItem._key === fieldKey);
171
-
172
- if (curFormItem) {
173
- const fieldType = curFormItem._type;
174
- fieldKey = curFormItem._key;
175
- const fieldData = this.fieldMap[fieldType];
176
-
177
- const dynamicTypes = this.useChainField
178
- ? [...new Set([...(fieldData.categoryTypes || []), fieldType])]
179
- : [fieldType];
180
- let dynamicList = dynamicTypes.reduce((list, type) => list.concat(this.dynamicFieldsMap[type] || []), []);
181
- dynamicList = this.useChainField
182
- ? ["select", "checkbox", "cascader", "cascaders"].includes(fieldType)
183
- ? dynamicList.filter(dynamicItem => dynamicItem._resourceKey === curFormItem._resourceKey)
184
- : ["reference"].includes(fieldType) && !!curFormItem._ref
185
- ? dynamicList.filter(dynamicItem => dynamicItem._ref === curFormItem._ref)
186
- : dynamicList
187
- : dynamicList;
188
-
189
- const operators = (
190
- ["_id"].includes(fieldKey)
191
- ? []
192
- : ["cascaderTable"].includes(fieldType)
193
- ? curFormItem._subType === "old"
194
- ? fieldData.operators.filter(operator => !["treeTableSearch"].includes(operator._key))
195
- : fieldData.operators.filter(operator => !["cascaderTableSearch"].includes(operator._key))
196
- // 单条关联类型 -配置端:无动态字段的地方过滤掉“是”和“不是”筛选条件,有动态字段的地方用的全部条件;用户端:用的全部条件,
197
- : ["reference"].includes(fieldType)
198
- ? this.mode === "set" && !dynamicList.length
199
- ? fieldData.operators.filter(operator => !["eq", "ne"].includes(operator._key))
200
- : fieldData.operators
201
- : fieldData.operators
202
- ) || [];
203
-
204
- const fieldOperator = initContion.fieldOperator || (
205
- ["_id"].includes(fieldKey)
206
- ? "eq"
207
- : ["reference"].includes(fieldType) && this.isSimpleSearch
208
- ? "eq"
209
- : (operators[0] || {})._key
210
- );
211
- const fieldOperatorName = (operators.find(operatorItem => operatorItem._key === fieldOperator) || { name: `${fieldOperator}不存在` }).name;
212
-
213
- const parameterType = initContion.parameterType || (
214
- (
215
- (initContion.fieldParams || []).length ||
216
- initContion.chainFieldKey ||
217
- (!!dynamicList.length && operators.some(operator => ["subSearch", "subTableSearch", "cascaderTableSearch", "treeTableSearch"].includes(operator._key)))
218
- ) ? "dynamicText" : "fixedText"
219
- );
220
- const parameterTypeName = (this.parameterPropsObj._data.find(parameterTypeItem => parameterTypeItem._key === parameterType) || { name: `${parameterType}不存在` }).name;
221
-
222
- return {
223
- _id: this.$ObjectID().str,
224
- logic: "field",
225
- fieldKey,
226
- fieldType,
227
- fieldOperator,
228
- fieldValue: [],
229
- fieldSearch: {
230
- logic: "and",
231
- conditions: []
232
- },
233
- parameterType,
234
- fieldParams: [],
235
- chainFieldKey: "",
236
- ...initContion,
237
-
238
- // 下面的是前端所用
239
- dynamicList: dynamicList,
240
- parameterTypeName: parameterTypeName,
241
- operators,
242
- fieldOperatorName: fieldOperatorName,
243
- formItem: this.getFormItem(curFormItem),
244
- subFormList: curFormItem._subForm || [],
245
- finished: !operators.some(operator => ["subSearch"].includes(operator._key)) // 子集条件的 请求form数据 是否完成状态
246
- };
247
- } else {
248
- return {
249
- _id: this.$ObjectID().str,
250
- ...initContion,
251
- __isDelete__: true, // 前端用它标识对应字段已被删除的条件项
252
- formItem: {
253
- __realKey__: initContion.fieldKey
254
- }
255
- };
256
- }
257
- } else if (["and", "or"].includes(initContion.logic)) {
258
- return {
259
- _id: this.$ObjectID().str,
260
- logic: "and",
261
- conditions: [],
262
- ...initContion
263
- };
264
- } else if (["text"].includes(initContion.logic)) {
265
- return {
266
- _id: this.$ObjectID().str,
267
- logic: "text",
268
- textSearch: "",
269
- ...initContion
270
- };
271
- } else if (["native"].includes(initContion.logic)) {
272
- return {
273
- _id: this.$ObjectID().str,
274
- logic: "native",
275
- nativeSearch: {},
276
- ...initContion
277
- };
278
- } else {
279
- return {
280
- _id: this.$ObjectID().str,
281
- ...initContion
282
- };
283
- }
284
- },
285
- // 获取表单配置
286
- getFormItem (formItem) {
287
- return {
288
- ...this.formatFormItem(formItem),
289
-
290
- _line: false,
291
- _span: 24,
292
- _useColor: true
293
- };
294
- },
295
- // 格式化表单配置,适合需要
296
- formatFormItem (formItem) {
297
- return {
298
- ...formItem,
299
- inSearch: true,
300
-
301
- _key: "fieldValue",
302
- __realKey__: formItem._key,
303
- _description: undefined,
304
- _disabled: false,
305
- _readonly: false,
306
- _required: false,
307
- _br: false,
308
- _wrap: false,
309
- _noLabel: false,
310
-
311
- _multiple: true,
312
- _enterType: undefined,
313
- canEdit: true
314
- };
315
- },
316
- // 处理operator为子集subSearch\subTableSearch,1.subTableSearch为flatTable类型,使用_subForm;2.subSearch为reference类型,请求form
317
- dealSubSearch (conditionItem) {
318
- if (conditionItem.fieldOperator === "subSearch") {
319
- if (conditionItem.finished !== true) {
320
- this.getModData(conditionItem.formItem, data => {
321
- conditionItem.finished = true;
322
- conditionItem.subFormList = (data.screens.find(screenItem =>
323
- this.mode === "set"
324
- ? screenItem.screenType === "all"
325
- : screenItem._key === conditionItem.formItem._screen
326
- ) || { form: [] }).form;
327
- });
328
- }
329
- }
330
- },
331
- // 加载 reference数据
332
- getModData (obj, cb) {
333
- this.$https({
334
- url: {
335
- module: "sheet",
336
- name: "schema" // 管理员下,不管传不传screenKey,且screenKey是不是全部视图,全部视图的form数据一定返回
337
- },
338
- params: {
339
- _key: obj._ref,
340
- screenKey: obj._screen
341
- },
342
- callback: data => {
343
- cb(data);
344
- }
345
- });
346
- },
347
- // 剔除conditions项里不要的属性
348
- transformConditions (list = []) {
349
- const loop = (list = []) => {
350
- const conditionFields = [
351
- "_id", "logic", "conditions", "textSearch", "nativeSearch",
352
- "fieldKey", "fieldType", "fieldValue", "fieldOperator", "fieldSearch",
353
- "parameterType", "fieldParams", "chainFieldKey"
354
- ];
355
-
356
- return list.map(item =>
357
- conditionFields.reduce((obj, key) => ({
358
- ...obj,
359
- [key]: item[key]
360
- ? key === "fieldSearch"
361
- ? {
362
- ...item[key],
363
- conditions: loop(item[key].conditions)
364
- }
365
- : key === "conditions"
366
- ? loop(item[key])
367
- : item[key]
368
- : item[key]
369
- })), {});
370
- };
371
-
372
- return loop(list);
373
- }
374
- }
375
- };
1
+ import DshFormUnit from "../unit/DshFormUnit.vue";
2
+
3
+ export default {
4
+ components: {
5
+ DshFormUnit
6
+ },
7
+ props: {
8
+ initFields: {
9
+ type: Array,
10
+ default () {
11
+ return [];
12
+ }
13
+ },
14
+ value: {
15
+ type: Object,
16
+ default () {
17
+ return {
18
+ logic: "and",
19
+ conditions: []
20
+ };
21
+ }
22
+ },
23
+ formList: {
24
+ type: Array,
25
+ default () {
26
+ return [];
27
+ }
28
+ },
29
+ useChainField: {
30
+ type: Boolean,
31
+ default: false
32
+ },
33
+ dynamicFormList: {
34
+ type: Array,
35
+ default () {
36
+ return [];
37
+ }
38
+ }
39
+ },
40
+ data () {
41
+ return {
42
+ fieldMap: this.$modFieldMap,
43
+
44
+ advSearchObj: {
45
+ logic: "and",
46
+ conditions: []
47
+ },
48
+ parameterPropsObj: {
49
+ _name: "参数类型",
50
+ _key: "parameterType",
51
+ _clearable: false,
52
+ _size: "small",
53
+ _default: "fixedText",
54
+ _data: [
55
+ { _key: "fixedText", name: "固定文本" },
56
+ { _key: "dynamicText", name: "动态文本" }
57
+ ]
58
+ }
59
+ };
60
+ },
61
+ computed: {
62
+ canSearchFormList () {
63
+ return this.formList.filter(formItem =>
64
+ this.$formHasAbility(formItem, "canSearch") &&
65
+ (this.mode === "set" ? true : formItem._displayType !== "hide")
66
+ );
67
+ },
68
+ dynamicFieldsMap () {
69
+ return this.$arrToCategoryArr(this.dynamicFormList);
70
+ }
71
+ },
72
+ created () {
73
+ this.init();
74
+ },
75
+ methods: {
76
+ // 初始化
77
+ init () {
78
+ this.advSearchObj = this.$deepCopy(this.value);
79
+ this.advSearchObj.conditions = [...this.initFields, ...this.advSearchObj.conditions].map(conditionItem => {
80
+ const newConditionItem = typeof conditionItem === "string"
81
+ ? this.createContionFunc(undefined, undefined, conditionItem)
82
+ : this.createContionFunc(conditionItem, undefined, conditionItem.fieldKey);
83
+ this.dealSubSearch(newConditionItem);
84
+
85
+ return newConditionItem;
86
+ });
87
+ },
88
+
89
+ // 新增条件项
90
+ createCondition (operationItem, isLoop, formItem, list) {
91
+ const newConditionItem = this.createContionFunc({ logic: isLoop ? "and" : "field" }, formItem);
92
+ this.dealSubSearch(newConditionItem);
93
+ list.push(newConditionItem);
94
+
95
+ this.change(operationItem.type, newConditionItem);
96
+ },
97
+ // 删除条件项
98
+ deleteCondition (operationItem, conditionItem, conditionIndex, list) {
99
+ list.splice(conditionIndex, 1);
100
+
101
+ this.change(operationItem.type, conditionItem);
102
+ },
103
+ // 获取动态文本或固定文本类型 选项列表
104
+ getParameterData (conditionItem) {
105
+ // 配置端 且 含有子集的
106
+ return !!conditionItem.dynamicList.length && conditionItem.operators.some(operator => ["subSearch", "subTableSearch", "cascaderTableSearch", "treeTableSearch"].includes(operator._key))
107
+ ? []
108
+ : this.parameterPropsObj._data;
109
+ },
110
+ // 选择某控件的动态文本或固定文本类型
111
+ changeParameterType (operationItem, conditionItem, conditionIndex, list, optionItem) {
112
+ conditionItem.parameterType = optionItem._key;
113
+ conditionItem.parameterTypeName = optionItem.name;
114
+ conditionItem.fieldParams = [];
115
+ conditionItem.chainFieldKey = "";
116
+ conditionItem.fieldValue = [];
117
+
118
+ this.change(operationItem.type, conditionItem);
119
+ },
120
+ // 选择某控件的操作类型
121
+ changeOperator (operationItem, conditionItem, conditionIndex, list, optionItem) {
122
+ if (optionItem._key !== conditionItem.fieldOperator) {
123
+ conditionItem.fieldOperator = optionItem._key;
124
+ conditionItem.fieldOperatorName = optionItem.name;
125
+
126
+ if (["isnull", "notnull", "nosize", "size", "nolist", "list"].includes(conditionItem.fieldOperator)) {
127
+ conditionItem.fieldParams = [];
128
+ conditionItem.chainFieldKey = "";
129
+ conditionItem.fieldValue = [];
130
+ conditionItem.fieldSearch = {
131
+ logic: "and",
132
+ conditions: []
133
+ };
134
+ } else if (["subSearch", "subTableSearch", "cascaderTableSearch", "treeTableSearch"].includes(conditionItem.fieldOperator)) {
135
+ conditionItem.fieldParams = [];
136
+ conditionItem.chainFieldKey = "";
137
+ conditionItem.fieldValue = [];
138
+ this.dealSubSearch(conditionItem);
139
+ } else {
140
+ conditionItem.fieldSearch = {
141
+ logic: "and",
142
+ conditions: []
143
+ };
144
+ }
145
+
146
+ this.change(operationItem.type, conditionItem);
147
+ }
148
+ },
149
+ // 发生改动
150
+ change (operationType, conditionItem, ...params) {
151
+ if (operationType === "loopSearch") {
152
+ const subAdvSearchObj = params[0];
153
+ Object.assign(conditionItem, subAdvSearchObj);
154
+ } else if (operationType === "subSearch") {
155
+ const subAdvSearchObj = params[0];
156
+ Object.assign(conditionItem.fieldSearch, subAdvSearchObj);
157
+ }
158
+
159
+ const advSearchObj = {
160
+ ...this.advSearchObj,
161
+ conditions: this.transformConditions(this.advSearchObj.conditions)
162
+ };
163
+ this.$emit("change", advSearchObj, operationType, conditionItem);
164
+ },
165
+
166
+ /* -------- 方法 ----------- */
167
+ // 生成条件项的值
168
+ createContionFunc (initContion = { logic: "field" }, curFormItem, fieldKey) {
169
+ if (["field", undefined].includes(initContion.logic)) {
170
+ curFormItem = curFormItem || this.canSearchFormList.find(formItem => formItem._key === fieldKey);
171
+
172
+ if (curFormItem) {
173
+ const fieldType = curFormItem._type;
174
+ fieldKey = curFormItem._key;
175
+ const fieldData = this.fieldMap[fieldType];
176
+
177
+ const dynamicTypes = this.useChainField
178
+ ? [...new Set([...(fieldData.categoryTypes || []), fieldType])]
179
+ : [fieldType];
180
+ let dynamicList = dynamicTypes.reduce((list, type) => list.concat(this.dynamicFieldsMap[type] || []), []);
181
+ dynamicList = this.useChainField
182
+ ? ["select", "checkbox", "cascader", "cascaders"].includes(fieldType)
183
+ ? dynamicList.filter(dynamicItem => dynamicItem._resourceKey === curFormItem._resourceKey)
184
+ : ["reference"].includes(fieldType) && !!curFormItem._ref
185
+ ? dynamicList.filter(dynamicItem => dynamicItem._ref === curFormItem._ref)
186
+ : dynamicList
187
+ : dynamicList;
188
+
189
+ const operators = (
190
+ ["_id"].includes(fieldKey)
191
+ ? []
192
+ : ["cascaderTable"].includes(fieldType)
193
+ ? curFormItem._subType === "old"
194
+ ? fieldData.operators.filter(operator => !["treeTableSearch"].includes(operator._key))
195
+ : fieldData.operators.filter(operator => !["cascaderTableSearch"].includes(operator._key))
196
+ // 单条关联类型 -配置端:无动态字段的地方过滤掉“是”和“不是”筛选条件,有动态字段的地方用的全部条件;用户端:用的全部条件,
197
+ : ["reference"].includes(fieldType)
198
+ ? this.mode === "set" && !dynamicList.length
199
+ ? fieldData.operators.filter(operator => !["eq", "ne"].includes(operator._key))
200
+ : fieldData.operators
201
+ : fieldData.operators
202
+ ) || [];
203
+
204
+ const fieldOperator = initContion.fieldOperator || (
205
+ ["_id"].includes(fieldKey)
206
+ ? "eq"
207
+ : ["reference"].includes(fieldType) && this.isSimpleSearch
208
+ ? "eq"
209
+ : (operators[0] || {})._key
210
+ );
211
+ const fieldOperatorName = (operators.find(operatorItem => operatorItem._key === fieldOperator) || { name: `${fieldOperator}不存在` }).name;
212
+
213
+ const parameterType = initContion.parameterType || (
214
+ (
215
+ (initContion.fieldParams || []).length ||
216
+ initContion.chainFieldKey ||
217
+ (!!dynamicList.length && operators.some(operator => ["subSearch", "subTableSearch", "cascaderTableSearch", "treeTableSearch"].includes(operator._key)))
218
+ ) ? "dynamicText" : "fixedText"
219
+ );
220
+ const parameterTypeName = (this.parameterPropsObj._data.find(parameterTypeItem => parameterTypeItem._key === parameterType) || { name: `${parameterType}不存在` }).name;
221
+
222
+ return {
223
+ _id: this.$ObjectID().str,
224
+ logic: "field",
225
+ fieldKey,
226
+ fieldType,
227
+ fieldOperator,
228
+ fieldValue: [],
229
+ fieldSearch: {
230
+ logic: "and",
231
+ conditions: []
232
+ },
233
+ parameterType,
234
+ fieldParams: [],
235
+ chainFieldKey: "",
236
+ ...initContion,
237
+
238
+ // 下面的是前端所用
239
+ dynamicList: dynamicList,
240
+ parameterTypeName: parameterTypeName,
241
+ operators,
242
+ fieldOperatorName: fieldOperatorName,
243
+ formItem: this.getFormItem(curFormItem),
244
+ subFormList: curFormItem._subForm || [],
245
+ finished: !operators.some(operator => ["subSearch"].includes(operator._key)) // 子集条件的 请求form数据 是否完成状态
246
+ };
247
+ } else {
248
+ return {
249
+ _id: this.$ObjectID().str,
250
+ ...initContion,
251
+ __isDelete__: true, // 前端用它标识对应字段已被删除的条件项
252
+ formItem: {
253
+ __realKey__: initContion.fieldKey
254
+ }
255
+ };
256
+ }
257
+ } else if (["and", "or"].includes(initContion.logic)) {
258
+ return {
259
+ _id: this.$ObjectID().str,
260
+ logic: "and",
261
+ conditions: [],
262
+ ...initContion
263
+ };
264
+ } else if (["text"].includes(initContion.logic)) {
265
+ return {
266
+ _id: this.$ObjectID().str,
267
+ logic: "text",
268
+ textSearch: "",
269
+ ...initContion
270
+ };
271
+ } else if (["native"].includes(initContion.logic)) {
272
+ return {
273
+ _id: this.$ObjectID().str,
274
+ logic: "native",
275
+ nativeSearch: {},
276
+ ...initContion
277
+ };
278
+ } else {
279
+ return {
280
+ _id: this.$ObjectID().str,
281
+ ...initContion
282
+ };
283
+ }
284
+ },
285
+ // 获取表单配置
286
+ getFormItem (formItem) {
287
+ return {
288
+ ...this.formatFormItem(formItem),
289
+
290
+ _line: false,
291
+ _span: 24,
292
+ _useColor: true
293
+ };
294
+ },
295
+ // 格式化表单配置,适合需要
296
+ formatFormItem (formItem) {
297
+ return {
298
+ ...formItem,
299
+ inSearch: true,
300
+
301
+ _key: "fieldValue",
302
+ __realKey__: formItem._key,
303
+ _description: undefined,
304
+ _disabled: false,
305
+ _readonly: false,
306
+ _required: false,
307
+ _br: false,
308
+ _wrap: false,
309
+ _noLabel: false,
310
+
311
+ _multiple: true,
312
+ _enterType: undefined,
313
+ canEdit: true
314
+ };
315
+ },
316
+ // 处理operator为子集subSearch\subTableSearch,1.subTableSearch为flatTable类型,使用_subForm;2.subSearch为reference类型,请求form
317
+ dealSubSearch (conditionItem) {
318
+ if (conditionItem.fieldOperator === "subSearch") {
319
+ if (conditionItem.finished !== true) {
320
+ this.getModData(conditionItem.formItem, data => {
321
+ conditionItem.finished = true;
322
+ conditionItem.subFormList = (data.screens.find(screenItem =>
323
+ this.mode === "set"
324
+ ? screenItem.screenType === "all"
325
+ : screenItem._key === conditionItem.formItem._screen
326
+ ) || { form: [] }).form;
327
+ });
328
+ }
329
+ }
330
+ },
331
+ // 加载 reference数据
332
+ getModData (obj, cb) {
333
+ this.$https({
334
+ url: {
335
+ module: "sheet",
336
+ name: "schema" // 管理员下,不管传不传screenKey,且screenKey是不是全部视图,全部视图的form数据一定返回
337
+ },
338
+ params: {
339
+ _key: obj._ref,
340
+ screenKey: obj._screen
341
+ },
342
+ callback: data => {
343
+ cb(data);
344
+ }
345
+ });
346
+ },
347
+ // 剔除conditions项里不要的属性
348
+ transformConditions (list = []) {
349
+ const loop = (list = []) => {
350
+ const conditionFields = [
351
+ "_id", "logic", "conditions", "textSearch", "nativeSearch",
352
+ "fieldKey", "fieldType", "fieldValue", "fieldOperator", "fieldSearch",
353
+ "parameterType", "fieldParams", "chainFieldKey"
354
+ ];
355
+
356
+ return list.map(item =>
357
+ conditionFields.reduce((obj, key) => ({
358
+ ...obj,
359
+ [key]: item[key]
360
+ ? key === "fieldSearch"
361
+ ? {
362
+ ...item[key],
363
+ conditions: loop(item[key].conditions)
364
+ }
365
+ : key === "conditions"
366
+ ? loop(item[key])
367
+ : item[key]
368
+ : item[key]
369
+ })), {});
370
+ };
371
+
372
+ return loop(list);
373
+ }
374
+ }
375
+ };