✨ 司机与车辆列表支持按未分配组织筛选
This commit is contained in:
@@ -26,6 +26,11 @@ import { h } from 'vue';
|
|||||||
*/
|
*/
|
||||||
const ORG_PROPS = ['organizationName', 'deptName'];
|
const ORG_PROPS = ['organizationName', 'deptName'];
|
||||||
|
|
||||||
|
// 「未分配组织」筛选项的哨兵值:不是真实组织名,选中后提交给后端的就是这串字面量。
|
||||||
|
// 后端 DriverMapper.xml:172-184 与 TransportVehicleMapper.xml:119-131 按此字面量改判为
|
||||||
|
// organization_name 为空(改成空串会让后端整段组织条件不生效,筛选静默失效)。
|
||||||
|
export const UNASSIGNED_ORG_FILTER = '__UNASSIGNED_ORG__';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -34,9 +39,18 @@ export default {
|
|||||||
organizationTreeOptions: [],
|
organizationTreeOptions: [],
|
||||||
organizationTreeFlatOptions: [],
|
organizationTreeFlatOptions: [],
|
||||||
organizationLoading: false,
|
organizationLoading: false,
|
||||||
|
// 组织筛选是否追加「未分配组织」一项;页面在 data 里覆盖为 true 才生效
|
||||||
|
enableUnassignedOrgFilter: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
// 搜索栏级联的选项:开关打开时在真实组织最前面追加「未分配组织」。
|
||||||
|
// 不能直接改 organizationTreeOptions——司机/车辆页的编辑表单也用这棵树选组织。
|
||||||
|
organizationSearchTreeOptions() {
|
||||||
|
return this.enableUnassignedOrgFilter
|
||||||
|
? [this.unassignedOrgOption(), ...this.organizationTreeOptions]
|
||||||
|
: this.organizationTreeOptions;
|
||||||
|
},
|
||||||
// 所属组织级联配置:checkStrictly 允许选中任意层级,不必选到末级
|
// 所属组织级联配置:checkStrictly 允许选中任意层级,不必选到末级
|
||||||
organizationCascaderProps() {
|
organizationCascaderProps() {
|
||||||
return {
|
return {
|
||||||
@@ -61,7 +75,7 @@ export default {
|
|||||||
? this.excludeExternalOrganization(source)
|
? this.excludeExternalOrganization(source)
|
||||||
: source;
|
: source;
|
||||||
this.organizationTreeOptions = this.normalizeOrgTree(tree);
|
this.organizationTreeOptions = this.normalizeOrgTree(tree);
|
||||||
this.organizationTreeFlatOptions = this.flattenOrgTree(this.organizationTreeOptions);
|
this.organizationTreeFlatOptions = this.flattenOrgTree(this.organizationSearchTreeOptions);
|
||||||
const option = this.tableOption || this.option;
|
const option = this.tableOption || this.option;
|
||||||
if (!option) return;
|
if (!option) return;
|
||||||
ORG_PROPS.forEach(prop => {
|
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 = []) {
|
flattenOrgTree(tree = []) {
|
||||||
return (tree || []).flatMap(item => [
|
return (tree || []).flatMap(item => [
|
||||||
{ id: String(item.id), label: item.label, rawLabel: item.rawLabel },
|
{ id: String(item.id), label: item.label, rawLabel: item.rawLabel },
|
||||||
...this.flattenOrgTree(item.children || []),
|
...this.flattenOrgTree(item.children || []),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
// 组织列渲染用:空串或纯空白即「未分配组织」(存量口径是空串,NULL 只是历史脏数据)
|
||||||
|
isBlankOrganizationName(value) {
|
||||||
|
return String(value ?? '').trim() === '';
|
||||||
|
},
|
||||||
// 兼容两种入参:级联路径数组(取末级)或单个部门 id
|
// 兼容两种入参:级联路径数组(取末级)或单个部门 id
|
||||||
findOrgById(id) {
|
findOrgById(id) {
|
||||||
const value = Array.isArray(id) ? id.at(-1) : id;
|
const value = Array.isArray(id) ? id.at(-1) : id;
|
||||||
@@ -155,7 +177,7 @@ export default {
|
|||||||
// 级联单选:modelValue 必须是 id 路径数组,否则控件内部状态会错乱导致无法再次选中
|
// 级联单选:modelValue 必须是 id 路径数组,否则控件内部状态会错乱导致无法再次选中
|
||||||
if (scope.row) scope.row[prop] = Array.isArray(value) ? value : [];
|
if (scope.row) scope.row[prop] = Array.isArray(value) ? value : [];
|
||||||
},
|
},
|
||||||
options: this.organizationTreeOptions,
|
options: this.organizationSearchTreeOptions,
|
||||||
props: {
|
props: {
|
||||||
label: 'label',
|
label: 'label',
|
||||||
value: 'id',
|
value: 'id',
|
||||||
|
|||||||
@@ -60,7 +60,11 @@
|
|||||||
<span>{{ row.idCardNo || '-' }}</span>
|
<span>{{ row.idCardNo || '-' }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #organizationName="{ row }">
|
<template #organizationName="{ row }">
|
||||||
{{ String(row.organizationName || '').replace(/^[\s\u3000]+/, '') }}
|
<span
|
||||||
|
v-if="isBlankOrganizationName(row.organizationName)"
|
||||||
|
class="organization-name--empty"
|
||||||
|
>未分配组织</span>
|
||||||
|
<span v-else>{{ String(row.organizationName || '').replace(/^[\s\u3000]+/, '') }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #status="{ row }">
|
<template #status="{ row }">
|
||||||
<el-tag :type="row.status === 1 ? 'primary' : 'info'" class="status-text">
|
<el-tag :type="row.status === 1 ? 'primary' : 'info'" class="status-text">
|
||||||
@@ -596,7 +600,11 @@
|
|||||||
<span>{{ row.plateNo || '-' }}</span>
|
<span>{{ row.plateNo || '-' }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #organizationName="{ row }">
|
<template #organizationName="{ row }">
|
||||||
{{ String(row.organizationName || '').replace(/^[\s\u3000]+/, '') }}
|
<span
|
||||||
|
v-if="isBlankOrganizationName(row.organizationName)"
|
||||||
|
class="organization-name--empty"
|
||||||
|
>未分配组织</span>
|
||||||
|
<span v-else>{{ String(row.organizationName || '').replace(/^[\s\u3000]+/, '') }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #boundDriver="{ row }">
|
<template #boundDriver="{ row }">
|
||||||
<span>{{ row.boundDriver || '-' }}</span>
|
<span>{{ row.boundDriver || '-' }}</span>
|
||||||
@@ -747,6 +755,8 @@ export default {
|
|||||||
expired: 0,
|
expired: 0,
|
||||||
},
|
},
|
||||||
driverBox: false,
|
driverBox: false,
|
||||||
|
// 搜索栏组织级联追加「未分配组织」一项(哨兵值见 organization-search mixin)
|
||||||
|
enableUnassignedOrgFilter: true,
|
||||||
vehicleSelectorVisible: false,
|
vehicleSelectorVisible: false,
|
||||||
vehicleSelectorLoading: false,
|
vehicleSelectorLoading: false,
|
||||||
vehicleSelectorOption,
|
vehicleSelectorOption,
|
||||||
@@ -1958,6 +1968,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 空组织记录在列表里的占位文案
|
||||||
|
.organization-name--empty {
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
.driver-page__date-expiring {
|
.driver-page__date-expiring {
|
||||||
color: #d40000;
|
color: #d40000;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -59,7 +59,11 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template #organizationName="{ row }">
|
<template #organizationName="{ row }">
|
||||||
{{ String(row.organizationName || '').replace(/^[\s\u3000]+/, '') }}
|
<span
|
||||||
|
v-if="isBlankOrganizationName(row.organizationName)"
|
||||||
|
class="organization-name--empty"
|
||||||
|
>未分配组织</span>
|
||||||
|
<span v-else>{{ String(row.organizationName || '').replace(/^[\s\u3000]+/, '') }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #status="{ row }">
|
<template #status="{ row }">
|
||||||
<el-tag :type="row.status === 1 ? 'primary' : 'info'" class="status-text">
|
<el-tag :type="row.status === 1 ? 'primary' : 'info'" class="status-text">
|
||||||
@@ -652,6 +656,8 @@ export default {
|
|||||||
vehicleCertificateUploads: {},
|
vehicleCertificateUploads: {},
|
||||||
uploadHeaders: getUploadHeaders(),
|
uploadHeaders: getUploadHeaders(),
|
||||||
organizationOptions: [],
|
organizationOptions: [],
|
||||||
|
// 搜索栏组织级联追加「未分配组织」一项(哨兵值见 organization-search mixin)
|
||||||
|
enableUnassignedOrgFilter: true,
|
||||||
vehicleTypeOptions: [
|
vehicleTypeOptions: [
|
||||||
{ label: '高栏车', value: '高栏' },
|
{ label: '高栏车', value: '高栏' },
|
||||||
{ label: '低栏车', value: '低栏' },
|
{ label: '低栏车', value: '低栏' },
|
||||||
@@ -1497,6 +1503,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 空组织记录在列表里的占位文案
|
||||||
|
.organization-name--empty {
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
// 编辑弹窗:灰底 + section-card 白卡分组
|
// 编辑弹窗:灰底 + section-card 白卡分组
|
||||||
.vehicle-form {
|
.vehicle-form {
|
||||||
:deep(.el-form-item__label) {
|
:deep(.el-form-item__label) {
|
||||||
|
|||||||
Reference in New Issue
Block a user