✨ 司机与车辆列表支持按未分配组织筛选

This commit is contained in:
2026-10-25 19:45:41 +08:00
parent c402d68aea
commit 324daf9d4d
3 changed files with 53 additions and 5 deletions
+24 -2
View File
@@ -26,6 +26,11 @@ import { h } from 'vue';
*/
const ORG_PROPS = ['organizationName', 'deptName'];
// 「未分配组织」筛选项的哨兵值:不是真实组织名,选中后提交给后端的就是这串字面量。
// 后端 DriverMapper.xml:172-184 与 TransportVehicleMapper.xml:119-131 按此字面量改判为
// organization_name 为空(改成空串会让后端整段组织条件不生效,筛选静默失效)。
export const UNASSIGNED_ORG_FILTER = '__UNASSIGNED_ORG__';
export default {
data() {
return {
@@ -34,9 +39,18 @@ export default {
organizationTreeOptions: [],
organizationTreeFlatOptions: [],
organizationLoading: false,
// 组织筛选是否追加「未分配组织」一项;页面在 data 里覆盖为 true 才生效
enableUnassignedOrgFilter: false,
};
},
computed: {
// 搜索栏级联的选项:开关打开时在真实组织最前面追加「未分配组织」。
// 不能直接改 organizationTreeOptions——司机/车辆页的编辑表单也用这棵树选组织。
organizationSearchTreeOptions() {
return this.enableUnassignedOrgFilter
? [this.unassignedOrgOption(), ...this.organizationTreeOptions]
: this.organizationTreeOptions;
},
// 所属组织级联配置:checkStrictly 允许选中任意层级,不必选到末级
organizationCascaderProps() {
return {
@@ -61,7 +75,7 @@ export default {
? this.excludeExternalOrganization(source)
: source;
this.organizationTreeOptions = this.normalizeOrgTree(tree);
this.organizationTreeFlatOptions = this.flattenOrgTree(this.organizationTreeOptions);
this.organizationTreeFlatOptions = this.flattenOrgTree(this.organizationSearchTreeOptions);
const option = this.tableOption || this.option;
if (!option) return;
ORG_PROPS.forEach(prop => {
@@ -100,12 +114,20 @@ export default {
};
});
},
// 哨兵节点的 id 与 rawLabel 都取哨兵值,resolveOrgName 取到的仍是哨兵而不是某个真实组织名
unassignedOrgOption() {
return { id: UNASSIGNED_ORG_FILTER, label: '未分配组织', rawLabel: UNASSIGNED_ORG_FILTER };
},
flattenOrgTree(tree = []) {
return (tree || []).flatMap(item => [
{ id: String(item.id), label: item.label, rawLabel: item.rawLabel },
...this.flattenOrgTree(item.children || []),
]);
},
// 组织列渲染用:空串或纯空白即「未分配组织」(存量口径是空串,NULL 只是历史脏数据)
isBlankOrganizationName(value) {
return String(value ?? '').trim() === '';
},
// 兼容两种入参:级联路径数组(取末级)或单个部门 id
findOrgById(id) {
const value = Array.isArray(id) ? id.at(-1) : id;
@@ -155,7 +177,7 @@ export default {
// 级联单选:modelValue 必须是 id 路径数组,否则控件内部状态会错乱导致无法再次选中
if (scope.row) scope.row[prop] = Array.isArray(value) ? value : [];
},
options: this.organizationTreeOptions,
options: this.organizationSearchTreeOptions,
props: {
label: 'label',
value: 'id',