|
@@ -8,7 +8,7 @@
|
|
|
style="margin-bottom: 20px"
|
|
style="margin-bottom: 20px"
|
|
|
>
|
|
>
|
|
|
<deptSelect
|
|
<deptSelect
|
|
|
-
|
|
|
|
|
|
|
+ ref="deptSelectRef"
|
|
|
v-model="form.useDeptId"
|
|
v-model="form.useDeptId"
|
|
|
@changeGroup="searchDeptNodeClick"
|
|
@changeGroup="searchDeptNodeClick"
|
|
|
/>
|
|
/>
|
|
@@ -127,7 +127,8 @@
|
|
|
import {
|
|
import {
|
|
|
assign,
|
|
assign,
|
|
|
cancel,
|
|
cancel,
|
|
|
- UpdateInformation
|
|
|
|
|
|
|
+ UpdateInformation,
|
|
|
|
|
+ getApprovalPurchaseDept
|
|
|
} from '@/api/bpm/components/purchasingManage/purchasePlanManage';
|
|
} from '@/api/bpm/components/purchasingManage/purchasePlanManage';
|
|
|
import deptSelect from '@/components/CommomSelect/dept-select.vue';
|
|
import deptSelect from '@/components/CommomSelect/dept-select.vue';
|
|
|
import { getUserPage } from '@/api/system/organization';
|
|
import { getUserPage } from '@/api/system/organization';
|
|
@@ -170,7 +171,42 @@
|
|
|
created() {
|
|
created() {
|
|
|
this.getAllUsers()
|
|
this.getAllUsers()
|
|
|
},
|
|
},
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ // 需要部门下拉已挂载(ref 可用)后才能校验默认值是否合法
|
|
|
|
|
+ this.loadApprovalPurchaseDept()
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 主管指派节点:接口返回审批采购部门时,自动预选该部门并带出其下的采购员。
|
|
|
|
|
+ * 接口返回空对象、或返回的部门不在组织架构中 → 不预选,保持手选,
|
|
|
|
|
+ * 避免把不存在的部门 id 传给采购员查询接口、导致通过时取不到采购员。
|
|
|
|
|
+ */
|
|
|
|
|
+ async loadApprovalPurchaseDept() {
|
|
|
|
|
+ if (this.taskDefinitionKey !== 'deptLeaderAssign') return;
|
|
|
|
|
+ try {
|
|
|
|
|
+ const dept = await getApprovalPurchaseDept();
|
|
|
|
|
+ if (!dept || !Object.keys(dept).length) return;
|
|
|
|
|
+ // 部门主键,与 /main/group/getGroupList 节点 id(dept-select 的 value-key)对应
|
|
|
|
|
+ const deptId = dept.id;
|
|
|
|
|
+ if (deptId === undefined || deptId === null || deptId === '') return;
|
|
|
|
|
+ const deptSelect = this.$refs.deptSelectRef;
|
|
|
|
|
+ const exists = deptSelect ? await deptSelect.hasNode(deptId) : false;
|
|
|
|
|
+ if (!exists) {
|
|
|
|
|
+ this.$message.warning(
|
|
|
|
|
+ `审批采购部门「${dept.name || deptId}」不在组织架构中,请手动选择采购部门`
|
|
|
|
|
+ );
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.form.useDeptId = deptId;
|
|
|
|
|
+ // 部门确定后按该部门筛选采购员,与手动选择部门的行为保持一致
|
|
|
|
|
+ this.searchDeptNodeClick(deptId);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.warn(
|
|
|
|
|
+ '[采购计划审批] 获取审批采购部门失败:',
|
|
|
|
|
+ error.message || error
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
getAllUsers() {
|
|
getAllUsers() {
|
|
|
this.userOptions = [];
|
|
this.userOptions = [];
|
|
|
listAllUserBind().then((data) => {
|
|
listAllUserBind().then((data) => {
|
|
@@ -255,6 +291,10 @@
|
|
|
console.log(this.form)
|
|
console.log(this.form)
|
|
|
//主管指派采购员
|
|
//主管指派采购员
|
|
|
if (this.taskDefinitionKey === 'deptLeaderAssign') {
|
|
if (this.taskDefinitionKey === 'deptLeaderAssign') {
|
|
|
|
|
+ if (!this.form.useDeptId) {
|
|
|
|
|
+ this.$message.warning(`请选择采购部门!`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (!this.form.userId) {
|
|
if (!this.form.userId) {
|
|
|
this.$message.warning(`请选择采购员!`);
|
|
this.$message.warning(`请选择采购员!`);
|
|
|
return;
|
|
return;
|
|
@@ -265,7 +305,9 @@
|
|
|
assignList: this.form.assignList,
|
|
assignList: this.form.assignList,
|
|
|
id: this.taskId,
|
|
id: this.taskId,
|
|
|
reason: this.form.reason,
|
|
reason: this.form.reason,
|
|
|
- businessId: this.businessId
|
|
|
|
|
|
|
+ businessId: this.businessId,
|
|
|
|
|
+ // 采购部门:取界面上当前选中的部门(可能是接口默认带出的,也可能是手选的)
|
|
|
|
|
+ useDeptId: this.form.useDeptId
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
// //采购员核对
|
|
// //采购员核对
|
|
@@ -284,6 +326,10 @@
|
|
|
|
|
|
|
|
if(this.taskDefinitionKey === 'deptLeaderAssign') {
|
|
if(this.taskDefinitionKey === 'deptLeaderAssign') {
|
|
|
variables.userId = this.selectId.join(',');
|
|
variables.userId = this.selectId.join(',');
|
|
|
|
|
+ // 采购部门:与界面显示保持一致(默认带出的或手选的),通过/驳回都要带对
|
|
|
|
|
+ if (this.form.useDeptId) {
|
|
|
|
|
+ variables.useDeptId = this.form.useDeptId;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
await API({
|
|
await API({
|
|
|
id: this.taskId,
|
|
id: this.taskId,
|
|
@@ -296,12 +342,20 @@
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
async rejectTask(status) {
|
|
async rejectTask(status) {
|
|
|
|
|
+ const variables = {
|
|
|
|
|
+ pass: !!status
|
|
|
|
|
+ };
|
|
|
|
|
+ // 主管指派节点驳回:部门同样按界面当前值带出,保证与通过时口径一致
|
|
|
|
|
+ if (
|
|
|
|
|
+ this.taskDefinitionKey === 'deptLeaderAssign' &&
|
|
|
|
|
+ this.form.useDeptId
|
|
|
|
|
+ ) {
|
|
|
|
|
+ variables.useDeptId = this.form.useDeptId;
|
|
|
|
|
+ }
|
|
|
await rejectTask({
|
|
await rejectTask({
|
|
|
id: this.taskId,
|
|
id: this.taskId,
|
|
|
reason: this.form.reason,
|
|
reason: this.form.reason,
|
|
|
- variables: {
|
|
|
|
|
- pass: !!status
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ variables
|
|
|
});
|
|
});
|
|
|
this.$emit('handleAudit', {
|
|
this.$emit('handleAudit', {
|
|
|
status,
|
|
status,
|