✨ 运力管理司机、车辆、船舶的所属组织只允许选择平台公司
This commit is contained in:
@@ -147,7 +147,7 @@
|
||||
<el-form-item label="船舶所属组织" prop="organizationName">
|
||||
<el-cascader
|
||||
v-model="organizationCascaderValue"
|
||||
:options="organizationTreeOptions"
|
||||
:options="formOrganizationTreeOptions"
|
||||
:props="organizationCascaderProps"
|
||||
filterable
|
||||
clearable
|
||||
@@ -664,6 +664,8 @@ export default {
|
||||
shipForm: emptyForm(),
|
||||
uploadHeaders: getUploadHeaders(),
|
||||
organizationOptions: [],
|
||||
// 表单「船舶所属组织」只允许选平台公司;搜索栏不受影响
|
||||
restrictFormOrgToPlatformCompany: true,
|
||||
formRules: {
|
||||
organizationName: [{ required: true, message: '请选择船舶所属组织', trigger: 'change' }],
|
||||
shipName: [
|
||||
@@ -710,13 +712,19 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permission', 'userInfo']),
|
||||
// 表单所属组织级联的选项:限定平台公司时多一个原组织兜底节点
|
||||
formOrganizationTreeOptions() {
|
||||
return this.buildFormOrganizationTree();
|
||||
},
|
||||
// 船舶所属组织级联:表单存组织名称,级联控件用 id 路径,两者在此双向转换
|
||||
organizationCascaderValue: {
|
||||
get() {
|
||||
return this.resolveOrgPath(this.shipForm.organizationName);
|
||||
return this.resolveFormOrgPath(this.shipForm.organizationName);
|
||||
},
|
||||
set(path) {
|
||||
this.shipForm.organizationName = this.resolveOrgName(path);
|
||||
const name = this.resolveOrgName(path);
|
||||
this.shipForm.organizationName = name;
|
||||
this.syncFormOrganizationLegacy(name);
|
||||
},
|
||||
},
|
||||
isAdmin() {
|
||||
@@ -744,8 +752,8 @@ export default {
|
||||
},
|
||||
},
|
||||
created() {
|
||||
// initDeptTree 末尾会拉组织树(含平台公司 id),这里不再重复请求
|
||||
this.initDeptTree();
|
||||
this.loadOrganizationOptions();
|
||||
},
|
||||
methods: {
|
||||
hasPermission(code) {
|
||||
@@ -756,9 +764,7 @@ export default {
|
||||
this.organizationOptions = this.flattenDeptOptions(res.data.data || []);
|
||||
const column = this.findColumn(this.option.column, 'organizationName');
|
||||
column.dicData = this.organizationOptions;
|
||||
if (this.shipBox && !this.shipForm.id && !this.shipForm.organizationName) {
|
||||
this.shipForm.organizationName = this.getCurrentOrganizationName();
|
||||
}
|
||||
return this.loadOrganizationOptions();
|
||||
});
|
||||
},
|
||||
flattenDeptOptions(tree = [], level = 0) {
|
||||
@@ -784,6 +790,10 @@ export default {
|
||||
);
|
||||
return currentDept?.rawLabel || this.userInfo.deptName || this.userInfo.dept_name || '';
|
||||
},
|
||||
// 新增时的默认组织:当前登录人组织是平台公司才预填,否则留空
|
||||
getDefaultOrganizationName() {
|
||||
return this.defaultFormOrganizationName(this.getCurrentOrganizationName());
|
||||
},
|
||||
validateField(prop) {
|
||||
this.$refs.shipForm?.validateField(prop);
|
||||
},
|
||||
@@ -875,12 +885,19 @@ export default {
|
||||
this.readonly = readonly;
|
||||
if (!row?.id) {
|
||||
this.shipForm = emptyForm();
|
||||
this.shipForm.organizationName = this.getCurrentOrganizationName();
|
||||
// 默认组织要先有组织树和平台公司列表才能判定,先留空、数据到位再补
|
||||
this.shipForm.organizationName = '';
|
||||
this.formOrganizationLegacyName = '';
|
||||
this.shipBox = true;
|
||||
this.whenOrganizationOptionsReady(() => {
|
||||
if (!this.shipBox || this.shipForm.id || this.shipForm.organizationName) return;
|
||||
this.shipForm.organizationName = this.getDefaultOrganizationName();
|
||||
});
|
||||
return;
|
||||
}
|
||||
getDetail(row.id).then(res => {
|
||||
this.shipForm = { ...emptyForm(), ...(res.data.data || {}) };
|
||||
this.syncFormOrganizationLegacy(this.shipForm.organizationName);
|
||||
this.shipBox = true;
|
||||
});
|
||||
},
|
||||
@@ -890,6 +907,7 @@ export default {
|
||||
},
|
||||
resetShip() {
|
||||
this.shipForm = emptyForm();
|
||||
this.formOrganizationLegacyName = '';
|
||||
this.readonly = false;
|
||||
this.submitLoading = false;
|
||||
this.$refs.shipForm?.clearValidate();
|
||||
|
||||
Reference in New Issue
Block a user