✨ 列表导出补齐创建人创建时间,并修复组织类型提交
多模块列表与导出展示创建人、创建时间;组织类型强制提交数字编码,避免中文 dictKey 反序列化失败。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+69
-13
@@ -34,7 +34,7 @@
|
||||
type="primary"
|
||||
plain
|
||||
:loading="oaSyncLoading"
|
||||
v-if="userInfo.authority.includes('admin')"
|
||||
v-if="isAdministrator"
|
||||
@click="handleOaOrgSync"
|
||||
>自动同步组织
|
||||
</el-button>
|
||||
@@ -43,7 +43,7 @@
|
||||
<el-link
|
||||
type="primary"
|
||||
@click.stop="handleAdd(scope.row, scope.index)"
|
||||
v-if="userInfo.authority.includes('admin')"
|
||||
v-if="isAdministrator"
|
||||
>新增子项
|
||||
</el-link>
|
||||
</template>
|
||||
@@ -365,6 +365,7 @@ export default {
|
||||
label: '组织类型',
|
||||
type: 'select',
|
||||
dicData: [],
|
||||
dataType: 'number',
|
||||
minWidth: 120,
|
||||
order: 90,
|
||||
prop: 'deptCategory',
|
||||
@@ -509,7 +510,7 @@ export default {
|
||||
this.loadOrganizationTypeOptions();
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['userInfo', 'permission']),
|
||||
...mapGetters(['userInfo', 'permission', 'isAdministrator']),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.validData(this.permission.dept_add, false),
|
||||
@@ -753,6 +754,9 @@ export default {
|
||||
.map(item => this.normalizeOrganizationTypeOption(item))
|
||||
.filter(Boolean);
|
||||
this.resetDeptCategoryOptions();
|
||||
if (list.length && !this.organizationTypeOptions.length) {
|
||||
this.$message.warning('组织类型字典 dictKey 须为数字 1~6,当前无法解析,请检查业务字典配置');
|
||||
}
|
||||
// 字典异步返回后触发表格组织类型标签重绘
|
||||
if (Array.isArray(this.data) && this.data.length) {
|
||||
this.data = [...this.data];
|
||||
@@ -760,24 +764,68 @@ export default {
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 业务字典项转下拉选项:dictKey 为纯数字时转 number(兼容历史 deptCategory 1~6),否则保留原值。
|
||||
* 业务字典项转下拉选项。后端 deptCategory 为 Integer,value 必须始终为数字。
|
||||
* dictKey 为纯数字时直接使用;若配成中文则回退用 sort(1~6)作为层级码。
|
||||
*/
|
||||
normalizeOrganizationTypeOption(item) {
|
||||
const label = item?.dictValue ?? item?.label;
|
||||
const rawKey = item?.dictKey ?? item?.value;
|
||||
if (label === undefined || label === null || String(label).trim() === '') {
|
||||
return null;
|
||||
}
|
||||
if (rawKey === undefined || rawKey === null || String(rawKey).trim() === '') {
|
||||
const rawKey = item?.dictKey ?? item?.value;
|
||||
const keyText = rawKey === undefined || rawKey === null ? '' : String(rawKey).trim();
|
||||
const keyNumber = Number(keyText);
|
||||
const isPureNumber = keyText !== '' && !Number.isNaN(keyNumber) && String(keyNumber) === keyText;
|
||||
if (isPureNumber) {
|
||||
return {
|
||||
label: String(label),
|
||||
value: keyNumber,
|
||||
};
|
||||
}
|
||||
// 兼容 dictKey 误配成中文:用排序号作为 1~6 层级码,保证下拉有数据且可提交 Integer
|
||||
const sortNumber = Number(item?.sort);
|
||||
if (!Number.isNaN(sortNumber) && sortNumber >= 1 && sortNumber <= 6) {
|
||||
return {
|
||||
label: String(label),
|
||||
value: sortNumber,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
},
|
||||
/**
|
||||
* 提交前将组织类型规范为 Integer;空状态字段去掉,避免 "" 反序列化失败。
|
||||
*/
|
||||
prepareDeptSubmitRow(row) {
|
||||
const category = this.resolveDeptCategoryValue(row.deptCategory);
|
||||
if (category === null) {
|
||||
return false;
|
||||
}
|
||||
row.deptCategory = category;
|
||||
if (row.status === '' || row.status === null || row.status === undefined) {
|
||||
delete row.status;
|
||||
} else {
|
||||
row.status = Number(row.status);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
resolveDeptCategoryValue(value) {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
this.$message.warning('请选择组织类型');
|
||||
return null;
|
||||
}
|
||||
const keyText = String(rawKey).trim();
|
||||
const asNumber = Number(keyText);
|
||||
const isPureNumber = keyText !== '' && !Number.isNaN(asNumber) && String(asNumber) === keyText;
|
||||
return {
|
||||
label: String(label),
|
||||
value: isPureNumber ? asNumber : keyText,
|
||||
};
|
||||
const asNumber = Number(value);
|
||||
if (!Number.isNaN(asNumber) && String(asNumber) === String(value).trim()) {
|
||||
return asNumber;
|
||||
}
|
||||
// 容错:表单里残留了中文标签时,按字典项 label 反查数字编码
|
||||
const matched = this.organizationTypeOptions.find(
|
||||
item => String(item.label) === String(value) || this.isSameDeptCategory(item.value, value)
|
||||
);
|
||||
if (matched && typeof matched.value === 'number' && !Number.isNaN(matched.value)) {
|
||||
return matched.value;
|
||||
}
|
||||
this.$message.warning('组织类型无效,请重新选择(字典键须为数字 1~6)');
|
||||
return null;
|
||||
},
|
||||
resetDeptCategoryOptions() {
|
||||
const categoryColumn = this.findColumn(this.option.column, 'deptCategory');
|
||||
@@ -952,6 +1000,10 @@ export default {
|
||||
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
||||
row.leaderId = func.join(row.leaderId);
|
||||
this.normalizeTopParent(row);
|
||||
if (!this.prepareDeptSubmitRow(row)) {
|
||||
loading();
|
||||
return;
|
||||
}
|
||||
if (this.isCarrierDeptCategory(row.deptCategory) && !row.carrierCustomerId) {
|
||||
this.$message.warning('请选择承运商');
|
||||
loading();
|
||||
@@ -983,6 +1035,10 @@ export default {
|
||||
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
||||
row.leaderId = func.join(row.leaderId);
|
||||
this.normalizeTopParent(row);
|
||||
if (!this.prepareDeptSubmitRow(row)) {
|
||||
loading();
|
||||
return;
|
||||
}
|
||||
if (this.isCarrierDeptCategory(row.deptCategory) && !row.carrierCustomerId) {
|
||||
this.$message.warning('请选择承运商');
|
||||
loading();
|
||||
|
||||
Reference in New Issue
Block a user