n20-project-component 1.0.5 → 1.0.6
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/dist/n20-project-component.common.js +88 -80
- package/dist/n20-project-component.css +1 -1
- package/dist/n20-project-component.umd.js +88 -80
- package/dist/n20-project-component.umd.min.js +5 -5
- package/package.json +1 -1
- package/src/components/ProFilterView/AdvancedFilter/index.vue +5 -1
- package/src/components/ProFilterView/index.vue +22 -15
package/package.json
CHANGED
|
@@ -529,7 +529,11 @@ export default {
|
|
|
529
529
|
resolve({ code: 500 }) // 返回一个成功状态的 Promise
|
|
530
530
|
return
|
|
531
531
|
}
|
|
532
|
-
|
|
532
|
+
|
|
533
|
+
let _data = JSON.parse(JSON.stringify(data))
|
|
534
|
+
_data.forEach((item) => {
|
|
535
|
+
if(this.optionsMap[item[this.onlyKey]]) item.options = []
|
|
536
|
+
})
|
|
533
537
|
axios
|
|
534
538
|
.post(
|
|
535
539
|
`/bems/prod_1.0/user/pageHabit?t=${Date.now()}`,
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
:name="filter.slotName"
|
|
144
144
|
:model="model"
|
|
145
145
|
:value="searchForm[filter.value]"
|
|
146
|
-
:input="val => (searchForm
|
|
146
|
+
:input="val => $set(searchForm, filter.value, val)"
|
|
147
147
|
></slot>
|
|
148
148
|
<!-- 无 value 的 slot(如 startDate/endDate 多值绑定),传递 searchForm 让父组件自行管理 -->
|
|
149
149
|
<slot
|
|
@@ -262,17 +262,18 @@ export default {
|
|
|
262
262
|
},
|
|
263
263
|
filterObj() {
|
|
264
264
|
// 合并 slot 类型筛选器的值(来自 initialValue)到 searchValue 中
|
|
265
|
+
// 注意:searchValue 优先级高于 slotValues,避免用户已选值被初始值覆盖
|
|
265
266
|
const slotValues = {};
|
|
266
267
|
this.filterList
|
|
267
268
|
.filter(item => item.type === 'slot' && item.value)
|
|
268
269
|
.forEach(item => {
|
|
269
270
|
if (this.initialValue && this.initialValue[item.value] !== undefined) {
|
|
270
|
-
slotValues[item.value] = this.initialValue[item.value];
|
|
271
|
+
slotValues[item.value] = JSON.parse(JSON.stringify(this.initialValue[item.value]));
|
|
271
272
|
}
|
|
272
273
|
});
|
|
273
274
|
return {
|
|
274
|
-
//
|
|
275
|
-
searchValue: { ...this.searchValue
|
|
275
|
+
// 筛选条件:slotValues 兜底,searchValue 优先级更高
|
|
276
|
+
searchValue: { ...slotValues, ...this.searchValue },
|
|
276
277
|
// 视图id
|
|
277
278
|
viewId: this.selectItem ? this.selectItem.viewId : null,
|
|
278
279
|
};
|
|
@@ -280,11 +281,13 @@ export default {
|
|
|
280
281
|
},
|
|
281
282
|
watch: {
|
|
282
283
|
initialValue: {
|
|
283
|
-
handler(newVal) {
|
|
284
|
+
handler(newVal, oldVal) {
|
|
284
285
|
if (!newVal) return;
|
|
285
|
-
|
|
286
|
+
// 深度比较,避免引用变化但值相同时误触发重置
|
|
287
|
+
if (JSON.stringify(newVal) === JSON.stringify(oldVal)) return;
|
|
288
|
+
|
|
286
289
|
// 浅拷贝,避免修改 searchValue 时污染外部 initialValue
|
|
287
|
-
this.searchValue =
|
|
290
|
+
this.searchValue = JSON.parse(JSON.stringify(newVal));
|
|
288
291
|
},
|
|
289
292
|
deep: true,
|
|
290
293
|
immediate: false,
|
|
@@ -306,17 +309,17 @@ export default {
|
|
|
306
309
|
this.getFilterList();
|
|
307
310
|
}
|
|
308
311
|
// 合并初始筛选值:slot 字段使用默认值,其他字段使用 initialValue 传入的值
|
|
309
|
-
this.searchValue = { ...this.getInitialSearchValue, ...this.initialValue };
|
|
312
|
+
this.searchValue = { ...this.getInitialSearchValue, ...JSON.parse(JSON.stringify(this.initialValue || {})) };
|
|
310
313
|
},
|
|
311
314
|
methods: {
|
|
312
|
-
// 处理 slot 类型字段的输入事件,同时更新 searchValue
|
|
315
|
+
// 处理 slot 类型字段的输入事件,同时更新 searchValue
|
|
313
316
|
handleSlotInput(fieldName, val) {
|
|
314
317
|
// 防御性检查:如果 fieldName 无效,不执行任何操作
|
|
315
318
|
if (!fieldName) return;
|
|
316
319
|
// 更新 searchValue
|
|
317
|
-
this.searchValue
|
|
318
|
-
//
|
|
319
|
-
this.$
|
|
320
|
+
this.$set(this.searchValue, fieldName, val);
|
|
321
|
+
// 值改变时实时同步到父组件(不刷新数据)
|
|
322
|
+
this.$emit('filter', this.filterObj, 'change');
|
|
320
323
|
},
|
|
321
324
|
handleCommand(command, item) {
|
|
322
325
|
const commandMap = {
|
|
@@ -349,12 +352,15 @@ export default {
|
|
|
349
352
|
};
|
|
350
353
|
}
|
|
351
354
|
this.$emit('changeFn', obj);
|
|
355
|
+
// 值改变时实时同步到父组件(不刷新数据)
|
|
356
|
+
this.$emit('filter', this.filterObj, 'change');
|
|
352
357
|
},
|
|
353
358
|
filterFn() {
|
|
354
359
|
this.$emit('filter', this.filterObj, 'filter');
|
|
355
360
|
},
|
|
356
361
|
handleClean() {
|
|
357
|
-
|
|
362
|
+
// 统一走 change 类型,父组件无需单独处理 clean
|
|
363
|
+
this.$emit('filter', this.filterObj, 'change');
|
|
358
364
|
},
|
|
359
365
|
handleClear() {
|
|
360
366
|
// 收集不需要清空的字段 key(required / isNotClose / initialValue 中的额外 key)
|
|
@@ -544,7 +550,7 @@ export default {
|
|
|
544
550
|
this.selectedItem = item.viewName;
|
|
545
551
|
if (item.viewName === '无视图') {
|
|
546
552
|
this.selectItem = '';
|
|
547
|
-
this.searchValue = { ...this.getInitialSearchValue, ...this.initialValue };
|
|
553
|
+
this.searchValue = { ...this.getInitialSearchValue, ...JSON.parse(JSON.stringify(this.initialValue || {})) };
|
|
548
554
|
// 无视图时恢复原来的筛选逻辑
|
|
549
555
|
this.$nextTick(() => {
|
|
550
556
|
const filterRef = this.$refs.filter;
|
|
@@ -559,6 +565,7 @@ export default {
|
|
|
559
565
|
} else {
|
|
560
566
|
const config = this.safeParse(item.viewConfig);
|
|
561
567
|
this.searchForm = config;
|
|
568
|
+
|
|
562
569
|
this.searchValue = config;
|
|
563
570
|
// 按视图保存的 keyIds 更新展示字段
|
|
564
571
|
this.$nextTick(() => {
|
|
@@ -610,7 +617,7 @@ export default {
|
|
|
610
617
|
this.searchKeyword = '';
|
|
611
618
|
this.selectedItem = '无视图';
|
|
612
619
|
this.selectItem = '';
|
|
613
|
-
this.searchValue = { ...this.getInitialSearchValue, ...this.initialValue };
|
|
620
|
+
this.searchValue = { ...this.getInitialSearchValue, ...JSON.parse(JSON.stringify(this.initialValue || {})) };
|
|
614
621
|
this.searchForm = { ...this.getInitialSearchValue };
|
|
615
622
|
this.filterExpanded = this.defaultExpanded;
|
|
616
623
|
this.viewId = undefined;
|