bri-components 1.4.93 → 1.4.95

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