64 lines
2.0 KiB
JavaScript
64 lines
2.0 KiB
JavaScript
/**
|
||||
|
|
* PreferenceEditor 择偶条件编辑器(规范 §30)
|
|||
|
|
*
|
|||
|
|
* 每条条件有两个 importance 等级:
|
|||
|
|
* - required:必须符合(AGENTS 第 2 条硬约束)
|
|||
|
|
* - preferred:最好符合(软约束,后端可适度放宽匹配)
|
|||
|
|
*
|
|||
|
|
* 不变量(AGENTS.md 第 2 条):用户已勾选"必须符合"的字段不可被前端自动放宽为
|
|||
|
|
* "最好符合",UI 必须显式提示用户此操作将影响匹配精度。
|
|||
|
|
*/
|
|||
|
|
Component({
|
|||
|
|
options: { addGlobalClass: true },
|
|||
|
|
properties: {
|
|||
|
|
preference: { type: Object, value: null },
|
|||
|
|
readonly: { type: Boolean, value: false },
|
|||
|
|
},
|
|||
|
|
data: {
|
|||
|
|
importanceLabelMap: {
|
|||
|
|
required: '必须符合',
|
|||
|
|
preferred: '最好符合',
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
// 切换某字段的 importance:required ↔ preferred
|
|||
|
|
onToggleImportance(e) {
|
|||
|
|
if (this.data.readonly) return;
|
|||
|
|
const { field } = e.currentTarget.dataset;
|
|||
|
|
const pref = this.data.preference || {};
|
|||
|
|
const current = pref[field];
|
|||
|
|
if (!current) return;
|
|||
|
|
const next = current === 'required' ? 'preferred' : 'required';
|
|||
|
|
this.triggerEvent('change', {
|
|||
|
|
field,
|
|||
|
|
importance: next,
|
|||
|
|
// 必须符合 → 最好符合,需用户二次确认(AGENTS 第 2 条)
|
|||
|
|
needConfirmRelax: current === 'required',
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
onAgeChange(e) {
|
|||
|
|
if (this.data.readonly) return;
|
|||
|
|
const { bound } = e.currentTarget.dataset;
|
|||
|
|
this.triggerEvent('change', {
|
|||
|
|
field: bound === 'min' ? 'ageMin' : 'ageMax',
|
|||
|
|
value: Number(e.detail.value),
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
onHeightChange(e) {
|
|||
|
|
if (this.data.readonly) return;
|
|||
|
|
const { bound } = e.currentTarget.dataset;
|
|||
|
|
this.triggerEvent('change', {
|
|||
|
|
field: bound === 'min' ? 'heightMin' : 'heightMax',
|
|||
|
|
value: Number(e.detail.value) || null,
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
onAcceptChildrenChange(e) {
|
|||
|
|
if (this.data.readonly) return;
|
|||
|
|
this.triggerEvent('change', {
|
|||
|
|
field: 'acceptChildren',
|
|||
|
|
value: e.detail.value,
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
});
|