yxk-20260731

改善提案
新增提案时,提案部门默认选中当前登录部门,用户可改选本人所属的有效业务部门。候选范围严格限定为用户关联部门中 org_type='2' 且 org_category='2' 的记录,排除岗位、科室及其他组织节点。
This commit is contained in:
ye1023
2026-07-31 14:08:01 +08:00
parent 8e4cdf4f7c
commit ba8fbd5b44
2 changed files with 51 additions and 58 deletions
@@ -12,6 +12,7 @@ enum Api {
importExcel = '/improvementproposal/improvementProposal/importExcel', importExcel = '/improvementproposal/improvementProposal/importExcel',
exportXls = '/improvementproposal/improvementProposal/exportXls', exportXls = '/improvementproposal/improvementProposal/exportXls',
queryDataById = '/improvementproposal/improvementProposal/queryById', queryDataById = '/improvementproposal/improvementProposal/queryById',
myProposalDepartments = '/improvementproposal/improvementProposal/myProposalDepartments',
improvementDeptScoreList = '/improvementproposal/improvementProposal/queryImprovementDeptScoreByMainId', improvementDeptScoreList = '/improvementproposal/improvementProposal/queryImprovementDeptScoreByMainId',
improvementInstituteVoteList = '/improvementproposal/improvementProposal/queryImprovementInstituteVoteByMainId', improvementInstituteVoteList = '/improvementproposal/improvementProposal/queryImprovementInstituteVoteByMainId',
getLatestProposalSequence = '/improvementproposal/improvementProposal/getLatestProposalSequence', getLatestProposalSequence = '/improvementproposal/improvementProposal/getLatestProposalSequence',
@@ -97,6 +98,9 @@ export const saveOrUpdate = (params, isUpdate) => {
*/ */
export const queryDataById = (id) => defHttp.get({url: Api.queryDataById, params:{ id }}); export const queryDataById = (id) => defHttp.get({url: Api.queryDataById, params:{ id }});
/** 查询当前登录用户可作为改善提案归属的业务部门。 */
export const queryMyProposalDepartments = () => defHttp.get({ url: Api.myProposalDepartments }, { successMessageMode: 'none' });
/** /**
* 查询当前年份最新提案序号 * 查询当前年份最新提案序号
* @param year 年份 * @param year 年份
@@ -25,8 +25,19 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="提案部门" :required="false" id="ImprovementProposalForm-proposalDeptId" name="proposalDeptId"> <a-form-item label="提案部门" v-bind="validateInfos.proposalDeptId" id="ImprovementProposalForm-proposalDeptId" name="proposalDeptId">
<a-input v-model:value="formData.proposalDeptName" :disabled="true" allow-clear></a-input> <a-select
v-if="isCreateMode"
v-model:value="formData.proposalDeptId"
:disabled="disabled || proposalDeptOptions.length === 0"
placeholder="请选择提案部门"
@change="handleProposalDeptChange"
>
<a-select-option v-for="department in proposalDeptOptions" :key="department.id" :value="department.id">
{{ department.departName }}
</a-select-option>
</a-select>
<a-input v-else v-model:value="formData.proposalDeptName" :disabled="true" allow-clear></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
@@ -126,7 +137,7 @@
import { defineComponent, ref, reactive, computed, toRaw, onMounted, nextTick } from 'vue'; import { defineComponent, ref, reactive, computed, toRaw, onMounted, nextTick } from 'vue';
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods'; import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
import { queryImprovementDeptScoreListByMainId, queryImprovementInstituteVoteListByMainId, queryDataById, saveOrUpdate } from '../ImprovementProposal.api'; import { queryImprovementDeptScoreListByMainId, queryImprovementInstituteVoteListByMainId, queryDataById, queryMyProposalDepartments, saveOrUpdate } from '../ImprovementProposal.api';
import { JVxeTable } from '/@/components/jeecg/JVxeTable'; import { JVxeTable } from '/@/components/jeecg/JVxeTable';
import {improvementDeptScoreColumns, improvementInstituteVoteColumns} from '../ImprovementProposal.data'; import {improvementDeptScoreColumns, improvementInstituteVoteColumns} from '../ImprovementProposal.data';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue'; import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
@@ -174,6 +185,7 @@
}); });
const activeKey = ref('improvementDeptScore'); const activeKey = ref('improvementDeptScore');
const userStore = useUserStore(); const userStore = useUserStore();
const proposalDeptOptions = ref<Record<string, any>[]>([]);
const formData = reactive<Record<string, any>>({ const formData = reactive<Record<string, any>>({
id: '', id: '',
@@ -198,6 +210,7 @@
//表单验证 //表单验证
const validatorRules = reactive({ const validatorRules = reactive({
proposalName: [{ required: true, message: '请输入提案名称!'},], proposalName: [{ required: true, message: '请输入提案名称!'},],
proposalDeptId: [{ required: true, message: '请选择提案部门!'},],
applicantName: [{ required: true, message: '请输入申请人姓名!'},], applicantName: [{ required: true, message: '请输入申请人姓名!'},],
proposalCategory: [{ required: true, message: '请选择提案类别!'},], proposalCategory: [{ required: true, message: '请选择提案类别!'},],
problemDesc: [{ required: true, message: '请输入问题描述!'},], problemDesc: [{ required: true, message: '请输入问题描述!'},],
@@ -239,6 +252,7 @@
// 子表由流程节点维护,普通新增、编辑和详情弹窗均不展示,避免误改评分或投票数据。 // 子表由流程节点维护,普通新增、编辑和详情弹窗均不展示,避免误改评分或投票数据。
const showSubTables = computed(() => props.formBpm === true && Boolean(formData.id || props.formData?.dataId)); const showSubTables = computed(() => props.formBpm === true && Boolean(formData.id || props.formData?.dataId));
const isCreateMode = computed(() => !formData.id && !props.formBpm);
function getCurrentDate() { function getCurrentDate() {
const now = new Date(); const now = new Date();
@@ -248,64 +262,36 @@
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
} }
function getCurrentLoginDepart() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>; function handleProposalDeptChange(departmentId: string) {
const loginInfo = (userStore.getLoginInfo || {}) as Record<string, any>; const department = proposalDeptOptions.value.find((item) => item.id === departmentId);
let departs: any[] = []; formData.proposalDeptName = department?.departName || '';
if (Array.isArray(loginInfo.departs)) { formData.proposalDeptCode = department?.orgCode || '';
departs = loginInfo.departs;
} else if (Array.isArray(userInfo.departs)) {
departs = userInfo.departs;
} else if (loginInfo.userInfo && Array.isArray(loginInfo.userInfo.departs)) {
departs = loginInfo.userInfo.departs;
}
if (userInfo.orgCode) {
const found = departs.find((item) => item && item.orgCode === userInfo.orgCode);
if (found) return found;
}
if (departs.length === 1) {
return departs[0];
}
if (departs.length > 0) {
return departs[0];
}
return undefined;
} }
async function getCurrentDepartInfo() { async function loadProposalDepartments() {
const userInfo = (userStore.getUserInfo || {}) as Record<string, any>; proposalDeptOptions.value = [];
const loginDepart = getCurrentLoginDepart(); try {
if (loginDepart) { const departments = await queryMyProposalDepartments();
return { proposalDeptOptions.value = Array.isArray(departments) ? departments : [];
id: loginDepart.id || '', } catch (error) {
departName: loginDepart.departName || loginDepart.name || '', formData.proposalDeptId = '';
orgCode: loginDepart.orgCode || '', formData.proposalDeptName = '';
}; formData.proposalDeptCode = '';
createMessage.error('可选提案部门加载失败,请刷新后重试');
return;
} }
if (userInfo.orgCode) { const currentOrgCode = String(userStore.getUserInfo?.orgCode || '');
try { const defaultDepartment = proposalDeptOptions.value.find((item) => item.orgCode === currentOrgCode) || proposalDeptOptions.value[0];
const depart = await defHttp.get({ url: '/sys/sysDepart/getDepartName', params: { orgCode: userInfo.orgCode } }, { successMessageMode: 'none' }); if (!defaultDepartment) {
if (depart && (depart.id || depart.departName)) { formData.proposalDeptId = '';
return { formData.proposalDeptName = '';
id: depart.id || '', formData.proposalDeptCode = '';
departName: depart.departName || depart.depart_name || '', createMessage.warning('当前用户未配置可用提案部门');
orgCode: userInfo.orgCode, return;
};
}
} catch (e) {
// ignore
}
} }
const deptId = userInfo.departIds || userInfo.deptId || userInfo.deptid || ''; formData.proposalDeptId = defaultDepartment.id;
const deptName = userInfo.departIds_dictText || userInfo.orgCodeTxt || userInfo.deptName || ''; handleProposalDeptChange(defaultDepartment.id);
return { id: deptId, departName: deptName, orgCode: userInfo.orgCode || '' };
}
async function applyCurrentUserDeptInfo() {
const departInfo = await getCurrentDepartInfo();
formData.proposalDeptId = departInfo.id;
formData.proposalDeptName = departInfo.departName;
formData.proposalDeptCode = departInfo.orgCode;
} }
onMounted(()=>{ onMounted(()=>{
@@ -340,7 +326,7 @@
improvementDeptScoreTable.dataSource = []; improvementDeptScoreTable.dataSource = [];
improvementInstituteVoteTable.dataSource = []; improvementInstituteVoteTable.dataSource = [];
formData.proposalDate = getCurrentDate(); formData.proposalDate = getCurrentDate();
await applyCurrentUserDeptInfo(); await loadProposalDepartments();
} }
async function edit(row) { async function edit(row) {
@@ -450,6 +436,9 @@
halfWrapperCol, halfWrapperCol,
disabled, disabled,
showSubTables, showSubTables,
isCreateMode,
proposalDeptOptions,
handleProposalDeptChange,
showFlowSubmitButton, showFlowSubmitButton,
getFormData, getFormData,
submitForm, submitForm,