bri-components 1.5.21 → 1.6.0

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 (153) 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 -434
  12. package/src/components/controls/base/BriUpload/BriUploadImage.vue +377 -377
  13. package/src/components/controls/base/BriUpload/uploadList.vue +727 -727
  14. package/src/components/controls/base/BriUpload/uploadMixin.js +446 -446
  15. package/src/components/controls/base/DshCascader/DshCascader.vue +215 -215
  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 +141 -141
  19. package/src/components/controls/base/DshCascader/components/cascaderTree.vue +151 -151
  20. package/src/components/controls/base/DshCoordinates.vue +585 -577
  21. package/src/components/controls/base/DshDate/DshDate.vue +191 -191
  22. package/src/components/controls/base/DshDate/DshDaterange.vue +186 -186
  23. package/src/components/controls/base/DshDivider.vue +201 -201
  24. package/src/components/controls/base/DshEditor.vue +274 -274
  25. package/src/components/controls/base/DshInput/BriInputs.vue +166 -166
  26. package/src/components/controls/base/DshInput/DshInput.vue +260 -260
  27. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +435 -435
  28. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -34
  29. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -14
  30. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -322
  31. package/src/components/controls/base/DshNumber/DshNumber.vue +143 -143
  32. package/src/components/controls/base/DshNumber/DshNumberange.vue +109 -109
  33. package/src/components/controls/base/DshSelect/DshCheckbox.vue +168 -168
  34. package/src/components/controls/base/DshSelect/DshSelect.vue +180 -180
  35. package/src/components/controls/base/DshSelect/DshSelectAll.vue +269 -269
  36. package/src/components/controls/base/DshSwitch/DshSwitch.vue +115 -115
  37. package/src/components/controls/control.less +324 -324
  38. package/src/components/controls/controlMap.js +117 -117
  39. package/src/components/controls/extra/DshColor.vue +81 -81
  40. package/src/components/controls/extra/DshThemeColor.vue +100 -100
  41. package/src/components/controls/extra/DshThemeIcon.vue +122 -122
  42. package/src/components/controls/mixins/cascaderMixin.js +325 -325
  43. package/src/components/controls/mixins/cascaderPickerMixin.js +227 -227
  44. package/src/components/controls/mixins/cascaderTableMixin.js +130 -130
  45. package/src/components/controls/mixins/controlMixin.js +393 -393
  46. package/src/components/controls/mixins/dateMixin.js +149 -149
  47. package/src/components/controls/mixins/flatTableMixin.js +111 -111
  48. package/src/components/controls/mixins/numberMixin.js +112 -112
  49. package/src/components/controls/mixins/selectMixin.js +233 -233
  50. package/src/components/controls/mixins/switchMixin.js +87 -87
  51. package/src/components/controls/mixins/userAndDepartMixin.js +260 -260
  52. package/src/components/controls/senior/DshLabels.vue +333 -333
  53. package/src/components/controls/senior/DshPackage.vue +57 -57
  54. package/src/components/controls/senior/cascaderTable.vue +213 -213
  55. package/src/components/controls/senior/correlation.vue +135 -135
  56. package/src/components/controls/senior/flatTable.vue +138 -138
  57. package/src/components/controls/senior/selectDepartments.vue +399 -399
  58. package/src/components/controls/senior/selectUsers/departMenu.vue +293 -293
  59. package/src/components/controls/senior/selectUsers/selectUsers.vue +712 -712
  60. package/src/components/controls/special/DshBack.vue +42 -42
  61. package/src/components/controls/special/DshUndeveloped.vue +41 -41
  62. package/src/components/form/DshAdvSearch.vue +510 -510
  63. package/src/components/form/DshDefaultSearch.vue +260 -260
  64. package/src/components/form/DshForm.vue +494 -494
  65. package/src/components/form/searchMixin.js +376 -376
  66. package/src/components/list/BriCard.vue +95 -95
  67. package/src/components/list/BriTable.vue +205 -205
  68. package/src/components/list/BriTree.vue +529 -529
  69. package/src/components/list/BriTreeItem.vue +163 -163
  70. package/src/components/list/DshBox/DshBox.vue +219 -219
  71. package/src/components/list/DshBox/DshCard.vue +446 -446
  72. package/src/components/list/DshBox/DshCrossTable.vue +827 -827
  73. package/src/components/list/DshBox/DshList.vue +404 -404
  74. package/src/components/list/DshBox/DshPanel.vue +669 -669
  75. package/src/components/list/DshBox/DshSingleData.vue +119 -119
  76. package/src/components/list/DshBox/DshTable.vue +239 -239
  77. package/src/components/list/DshCascaderTable.vue +115 -115
  78. package/src/components/list/DshFlatTable.vue +337 -337
  79. package/src/components/list/DshPage.vue +194 -194
  80. package/src/components/list/DshTreeTable.vue +113 -113
  81. package/src/components/list/common/importModal.vue +243 -243
  82. package/src/components/list/common/quoteListModal.vue +206 -206
  83. package/src/components/list/mixins/DshCascaderTableMixin.js +278 -278
  84. package/src/components/list/mixins/DshFlatTableMixin.js +509 -509
  85. package/src/components/list/mixins/DshTreeTableMixin.js +286 -286
  86. package/src/components/list/mixins/tableBaseMixin.js +1653 -1653
  87. package/src/components/list/mixins/treeTableBaseMixin.js +145 -145
  88. package/src/components/other/BriAvatar.vue +166 -166
  89. package/src/components/other/BriCode.vue +125 -125
  90. package/src/components/other/BriCollapseTree.vue +207 -207
  91. package/src/components/other/BriGantt.vue +1087 -1087
  92. package/src/components/other/BriIframe.vue +116 -116
  93. package/src/components/other/BriLoading.vue +171 -171
  94. package/src/components/other/BriSvg.vue +27 -27
  95. package/src/components/other/DshColorPanel.vue +128 -128
  96. package/src/components/other/DshMenuNav.vue +188 -188
  97. package/src/components/small/BriButton.vue +71 -71
  98. package/src/components/small/BriDrawer.vue +169 -169
  99. package/src/components/small/BriTooltip.vue +87 -87
  100. package/src/components/small/DshBtnModal.vue +68 -68
  101. package/src/components/small/DshButtons.vue +324 -324
  102. package/src/components/small/DshDropdown.vue +225 -225
  103. package/src/components/small/DshIcons.vue +59 -59
  104. package/src/components/small/DshListRender.js +21 -21
  105. package/src/components/small/DshModal.vue +160 -160
  106. package/src/components/small/DshSteps.vue +141 -141
  107. package/src/components/small/DshTabs.vue +598 -598
  108. package/src/components/small/DshTabsSet.vue +309 -309
  109. package/src/components/small/DshTags.vue +251 -251
  110. package/src/components/small/DshTitle.vue +50 -50
  111. package/src/components/small/render.js +20 -20
  112. package/src/components/unit/DshFormUnit.vue +398 -398
  113. package/src/components/unit/DshListUnit.vue +115 -115
  114. package/src/components/unit/unitMixin.js +86 -86
  115. package/src/data/index.js +4 -4
  116. package/src/index.js +285 -285
  117. package/src/styles/bundle.css +12 -12
  118. package/src/styles/components/BriButton.less +307 -307
  119. package/src/styles/components/BriTable.less +344 -344
  120. package/src/styles/components/DshModal.less +257 -257
  121. package/src/styles/components/index.less +3 -3
  122. package/src/styles/global/animate.less +11 -11
  123. package/src/styles/global/base.less +45 -45
  124. package/src/styles/global/box.less +186 -186
  125. package/src/styles/global/control.less +122 -122
  126. package/src/styles/global/flex.less +282 -282
  127. package/src/styles/global/global.less +8 -8
  128. package/src/styles/global/text.less +59 -59
  129. package/src/styles/global/variables.less +85 -85
  130. package/src/styles/iconfont/iconfont.css +254 -254
  131. package/src/styles/iconfont/iconfont.json +422 -422
  132. package/src/styles/iconfont/iconfont.svg +137 -137
  133. package/src/styles/index.less +26 -26
  134. package/src/styles/reset-easytable.less +21 -21
  135. package/src/styles/reset-iview-controls.less +145 -145
  136. package/src/styles/reset-iview-other.less +49 -49
  137. package/src/styles/reset-iview-variables.less +43 -43
  138. package/src/styles/reset.less +45 -45
  139. package/src/utils/index.js +3 -5
  140. package/lib/0.bri-components.min.js +0 -1
  141. package/lib/1.bri-components.min.js +0 -1
  142. package/lib/10.bri-components.min.js +0 -1
  143. package/lib/11.bri-components.min.js +0 -1
  144. package/lib/2.bri-components.min.js +0 -1
  145. package/lib/3.bri-components.min.js +0 -1
  146. package/lib/4.bri-components.min.js +0 -1
  147. package/lib/5.bri-components.min.js +0 -1
  148. package/lib/6.bri-components.min.js +0 -1
  149. package/lib/7.bri-components.min.js +0 -1
  150. package/lib/8.bri-components.min.js +0 -1
  151. package/lib/9.bri-components.min.js +0 -1
  152. package/lib/bri-components.min.js +0 -18
  153. package/src/utils/table.js +0 -175
@@ -1,376 +1,376 @@
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
-
373
- return loop(list);
374
- }
375
- }
376
- };
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
+
373
+ return loop(list);
374
+ }
375
+ }
376
+ };