bri-components 1.2.85 → 1.2.87

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.2.85",
3
+ "version": "1.2.87",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -24,11 +24,12 @@
24
24
  class="DshAdvSearch-conditions-loop"
25
25
  >
26
26
  <dsh-adv-search
27
- :isInner="true"
28
27
  :mode="mode"
28
+ :isInner="true"
29
29
  :value="conditionItem"
30
30
  :formList="canSearchFormList"
31
- :dynamicFieldsMap="dynamicFieldsMap"
31
+ :useChainField="useChainField"
32
+ :dynamicFormList="dynamicFormList"
32
33
  @change="change('loopControl', conditionItem, ...arguments)"
33
34
  >
34
35
  <slot
@@ -52,7 +53,7 @@
52
53
  :key="`${conditionItem._id}field`"
53
54
  :class="{
54
55
  'DshAdvSearch-conditions-item': true,
55
- 'DshAdvSearch-conditions-item-dynamic': conditionItem.dynamicList.length
56
+ 'DshAdvSearch-conditions-item-dynamic': conditionItem.dynamicList && conditionItem.dynamicList.length
56
57
  }"
57
58
  :formData="conditionItem"
58
59
  :formItem="conditionItem.formItem"
@@ -61,15 +62,22 @@
61
62
  >
62
63
  <template v-if="!conditionItem.__isDelete__">
63
64
  <slot :conditionItem="conditionItem">
65
+ <!-- 为空和不为空时 啥不显示 -->
66
+ <div
67
+ v-if="['isnull', 'notnull', 'nosize', 'size', 'nolist', 'list'].includes(conditionItem.fieldOperator)"
68
+ class="DshAdvSearch-conditions-item-blank"
69
+ >请选择右上角条件</div>
70
+
64
71
  <!-- 子表的筛选,出现是有条件的,递归 -->
65
- <template v-if="['subSearch', 'subTableSearch'].includes(conditionItem.fieldOperator)">
72
+ <template v-else-if="['subSearch', 'subTableSearch'].includes(conditionItem.fieldOperator)">
66
73
  <dsh-adv-search
67
74
  v-if="conditionItem.finished === true"
68
- :isInner="true"
69
75
  :mode="mode"
76
+ :isInner="true"
70
77
  :value="conditionItem.fieldSearch"
71
78
  :formList="conditionItem.subFormList"
72
- :dynamicFieldsMap="dynamicFieldsMap"
79
+ :useChainField="useChainField"
80
+ :dynamicFormList="dynamicFormList"
73
81
  @change="change('subSearch', conditionItem, ...arguments)"
74
82
  ></dsh-adv-search>
75
83
 
@@ -79,38 +87,37 @@
79
87
  >加载中……</div>
80
88
  </template>
81
89
 
82
- <!-- 动态筛选字段,出现是有条件的 -->
83
- <template v-else-if="conditionItem.parameterType === 'dynamicText'">
84
- <dsh-select
85
- v-if="useChainField"
86
- class="DshAdvSearch-conditions-item-control"
87
- :value="conditionItem"
88
- :propsObj="{
89
- _name: `${conditionItem.formItem._name}的联动字段`,
90
- _key: 'chainFieldKey',
91
- _data: conditionItem.dynamicList
92
- }"
93
- @change="change('parameterTypeControl', conditionItem, ...arguments)"
94
- ></dsh-select>
95
-
96
- <dsh-checkbox
97
- v-else
98
- class="DshAdvSearch-conditions-item-control"
99
- :value="conditionItem"
100
- :propsObj="{
101
- _name: `${conditionItem.formItem._name}的动态参数`,
102
- _key: 'fieldParams',
103
- _data: conditionItem.dynamicList
104
- }"
105
- @change="change('parameterTypeControl', conditionItem, ...arguments)"
106
- ></dsh-checkbox>
90
+ <!-- 其它条件 -->
91
+ <template v-else>
92
+ <!-- 动态文本 -匹配的动态筛选字段 -->
93
+ <template v-if="conditionItem.parameterType === 'dynamicText'">
94
+ <dsh-select
95
+ v-if="useChainField"
96
+ class="DshAdvSearch-conditions-item-control"
97
+ :value="conditionItem"
98
+ :propsObj="{
99
+ _name: `${conditionItem.formItem._name}的联动字段`,
100
+ _key: 'chainFieldKey',
101
+ _data: conditionItem.dynamicList
102
+ }"
103
+ @change="change('parameterTypeControl', conditionItem, ...arguments)"
104
+ ></dsh-select>
105
+
106
+ <dsh-checkbox
107
+ v-else
108
+ class="DshAdvSearch-conditions-item-control"
109
+ :value="conditionItem"
110
+ :propsObj="{
111
+ _name: `${conditionItem.formItem._name}的动态参数`,
112
+ _key: 'fieldParams',
113
+ _data: conditionItem.dynamicList
114
+ }"
115
+ @change="change('parameterTypeControl', conditionItem, ...arguments)"
116
+ ></dsh-checkbox>
117
+ </template>
118
+
119
+ <!-- 固定文本 -筛选条件对应的显示 -->
107
120
  </template>
108
-
109
- <!-- 为空和不为空时 啥不显示 -->
110
- <div
111
- v-else-if="['isnull', 'notnull', 'nosize', 'size', 'nolist', 'list'].includes(conditionItem.fieldOperator)"
112
- class="DshAdvSearch-conditions-item-blank"
113
- >请选择右上角条件</div>
114
121
  </slot>
115
122
  </template>
116
123
 
@@ -238,7 +245,7 @@
238
245
  default: "default",
239
246
  validator: function (val) {
240
247
  // 用户态、 配置端、高级依赖、以及仪表盘乱用的地方
241
- return ["default", "set", "rely"].includes(val);
248
+ return ["default", "set"].includes(val);
242
249
  }
243
250
  },
244
251
  useLoop: {
@@ -176,11 +176,6 @@
176
176
  ? {
177
177
  _useShortcuts: false
178
178
  }
179
- // labels类型的
180
- : ["labels"].includes(formItem._type)
181
- ? {
182
- mode: "defaultSearch"
183
- }
184
179
  : {}
185
180
  )
186
181
  };
@@ -21,15 +21,15 @@ export default {
21
21
  }
22
22
  },
23
23
 
24
+ useChainField: {
25
+ type: Boolean,
26
+ default: false
27
+ },
24
28
  dynamicFormList: {
25
29
  type: Array,
26
30
  default () {
27
31
  return [];
28
32
  }
29
- },
30
- useChainField: {
31
- type: Boolean,
32
- default: false
33
33
  }
34
34
  },
35
35
  data () {
@@ -51,6 +51,7 @@ export default {
51
51
  _key: "parameterType",
52
52
  _clearable: false,
53
53
  _size: "small",
54
+ _default: "fixedText",
54
55
  _data: [
55
56
  { _key: "fixedText", name: "固定文本" },
56
57
  { _key: "dynamicText", name: "动态文本" }
@@ -71,6 +72,7 @@ export default {
71
72
  // 新增筛选条件
72
73
  createCondition (operationItem, isLoop, formItem, list) {
73
74
  const newConditionItem = this.createContionFunc({ logic: isLoop ? "and" : "field" }, formItem);
75
+ this.dealSubSearch(newConditionItem);
74
76
  list.push(newConditionItem);
75
77
 
76
78
  this.change(operationItem.type, newConditionItem);
@@ -93,15 +95,32 @@ export default {
93
95
  },
94
96
  // 选择某控件的筛选类型
95
97
  changeOperator (operationItem, conditionItem, conditionIndex, list, optionItem) {
96
- conditionItem.fieldOperator = optionItem._key;
97
- conditionItem.fieldOperatorName = optionItem.name;
98
- conditionItem.fieldSearch = {
99
- logic: "and",
100
- conditions: []
101
- };
102
- this.dealSubSearch(conditionItem);
98
+ if (optionItem._key !== conditionItem.fieldOperator) {
99
+ conditionItem.fieldOperator = optionItem._key;
100
+ conditionItem.fieldOperatorName = optionItem.name;
103
101
 
104
- this.change(operationItem.type, conditionItem);
102
+ if (["isnull", "notnull", "nosize", "size", "nolist", "list"].includes(conditionItem.fieldOperator)) {
103
+ conditionItem.fieldParams = [];
104
+ conditionItem.chainFieldKey = "";
105
+ conditionItem.fieldValue = [];
106
+ conditionItem.fieldSearch = {
107
+ logic: "and",
108
+ conditions: []
109
+ };
110
+ } else if (["subSearch", "subTableSearch"].includes(conditionItem.fieldOperator)) {
111
+ conditionItem.fieldParams = [];
112
+ conditionItem.chainFieldKey = "";
113
+ conditionItem.fieldValue = [];
114
+ this.dealSubSearch(conditionItem);
115
+ } else {
116
+ conditionItem.fieldSearch = {
117
+ logic: "and",
118
+ conditions: []
119
+ };
120
+ }
121
+
122
+ this.change(operationItem.type, conditionItem);
123
+ }
105
124
  },
106
125
  // 发生改动
107
126
  change (operationType, conditionItem) {
@@ -116,25 +135,32 @@ export default {
116
135
  // 生成筛选条件的值
117
136
  createContionFunc (initContion = { logic: "field" }, curFormItem, fieldKey) {
118
137
  if (["field", undefined].includes(initContion.logic)) {
119
- const formItem = curFormItem || this.canSearchFormList.find(formItem => formItem._key === fieldKey);
138
+ curFormItem = curFormItem || this.canSearchFormList.find(formItem => formItem._key === fieldKey);
120
139
 
121
- if (formItem) {
122
- const fieldData = this.fieldMap[formItem._type];
140
+ if (curFormItem) {
141
+ const fieldData = this.fieldMap[curFormItem._type];
123
142
 
124
- const dynamicTypes = this.useChainField ? (fieldData.categoryKinds || []) : [formItem._type];
125
- const dynamicList = dynamicTypes.reduce((list, type) => [...list, ...(this.dynamicFieldsMap[type] || [])], []) || [];
143
+ const dynamicTypes = this.useChainField ? [...new Set([...(fieldData.categoryTypes || []), curFormItem._type])] : [curFormItem._type];
144
+ let dynamicList = dynamicTypes.reduce((list, type) => [...list, ...(this.dynamicFieldsMap[type] || [])], []);
145
+ dynamicList = this.useChainField
146
+ ? ["select", "checkbox", "cascader", "cascaders"].includes(curFormItem._type)
147
+ ? dynamicList.filter(dynamicItem => dynamicItem._resourceKey === curFormItem._resourceKey)
148
+ : ["reference"].includes(curFormItem._type) && !!curFormItem._ref
149
+ ? dynamicList.filter(dynamicItem => dynamicItem._ref === curFormItem._ref)
150
+ : dynamicList
151
+ : dynamicList;
126
152
  const parameterType = initContion.parameterType || ((initContion.fieldParams || []).length || initContion.chainFieldKey ? "dynamicText" : "fixedText");
127
- const parameterTypeName = (this.parameterPropsObj._data.find(parameterTypeItem => parameterTypeItem._key === parameterType) || {}).name;
153
+ const parameterTypeName = (this.parameterPropsObj._data.find(parameterTypeItem => parameterTypeItem._key === parameterType) || { name: `${parameterType}不存在` }).name;
128
154
 
129
- const operators = fieldData[this.mode === "set" ? "operatorsSet" : this.mode === "rely" ? "operatorsRely" : "operators"] || fieldData.operators || [];
155
+ const operators = fieldData[this.mode === "default" || dynamicList.length ? "operators" : "operatorsSet"] || fieldData.operators || [];
130
156
  const fieldOperator = initContion.fieldOperator || (operators[0] || {})._key;
131
- const fieldOperatorName = (operators.find(operatorItem => operatorItem._key === fieldOperator) || {}).name;
157
+ const fieldOperatorName = (operators.find(operatorItem => operatorItem._key === fieldOperator) || { name: `${fieldOperator}不存在` }).name;
132
158
 
133
159
  return {
134
160
  _id: this.$ObjectID().str,
135
161
  logic: "field",
136
- fieldKey: formItem._key,
137
- fieldType: formItem._type,
162
+ fieldKey: curFormItem._key,
163
+ fieldType: curFormItem._type,
138
164
  fieldValue: [],
139
165
  fieldOperator: fieldOperator,
140
166
  fieldSearch: {
@@ -151,8 +177,8 @@ export default {
151
177
  parameterTypeName: parameterTypeName,
152
178
  operators: operators,
153
179
  fieldOperatorName: fieldOperatorName,
154
- formItem: this.getFormItem(formItem),
155
- subFormList: formItem._subForm || [],
180
+ formItem: this.getFormItem(curFormItem),
181
+ subFormList: curFormItem._subForm || [],
156
182
  finished: false // 标记 reference类型请求form数据 是否完成状态
157
183
  };
158
184
  } else {
@@ -193,19 +219,7 @@ export default {
193
219
 
194
220
  _line: false,
195
221
  _span: 24,
196
- _useColor: true,
197
-
198
- ...(
199
- ["default", "rely"].includes(this.mode)
200
- ? (
201
- ["date", "daterange"].includes(formItem._type)
202
- ? {
203
- _useShortcuts: false
204
- }
205
- : {}
206
- )
207
- : {}
208
- )
222
+ _useColor: true
209
223
  };
210
224
  },
211
225
  // 格式化表单配置,适合需要
@@ -280,7 +294,7 @@ export default {
280
294
  : item[key]
281
295
  )
282
296
  : item[key]
283
- }), {})
297
+ }), {})
284
298
  );
285
299
  };
286
300