|
|
@@ -160,7 +160,7 @@
|
|
|
v-for="item in form.qualityType == 2
|
|
|
? form.jobList.find((job) => job.id == form.executeJobId)
|
|
|
?.userVOList
|
|
|
- : executorList"
|
|
|
+ : executorOptions"
|
|
|
:key="item.id"
|
|
|
:value="item.id"
|
|
|
:label="item.name"
|
|
|
@@ -457,6 +457,7 @@
|
|
|
import { getProduceTaskList } from '@/api/aps';
|
|
|
import { getByCode } from '@/api/system/dictionary-data';
|
|
|
import { parameterGetByCode } from '@/api/main/index';
|
|
|
+ import { getCurrentUserCompany } from '@/utils/org-util';
|
|
|
export default {
|
|
|
components: {
|
|
|
EquipmentDialog,
|
|
|
@@ -519,6 +520,20 @@
|
|
|
// deep: true
|
|
|
// }
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ /* 执行人候选项: 保证当前登录用户始终在列表中, 否则多选框回显不出姓名 */
|
|
|
+ executorOptions() {
|
|
|
+ const list = Array.isArray(this.executorList) ? this.executorList : [];
|
|
|
+ const userInfo = this.$store?.state?.user?.info;
|
|
|
+ if (!userInfo || !userInfo.userId) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ if (list.find((item) => item.id == userInfo.userId)) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return [...list, { id: userInfo.userId, name: userInfo.name }];
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
executorList: [],
|
|
|
@@ -767,9 +782,45 @@
|
|
|
data = Object.assign(data, params);
|
|
|
}
|
|
|
const res = await getUserPage(data);
|
|
|
- this.executorList = res.list;
|
|
|
+ this.executorList = (res && res.list) || [];
|
|
|
} catch (error) {}
|
|
|
},
|
|
|
+ /* 默认执行部门=当前登录用户所属公司, 默认执行人=当前登录用户 */
|
|
|
+ async setDefaultExecuteInfo() {
|
|
|
+ const userInfo = this.$store?.state?.user?.info;
|
|
|
+ if (!userInfo || !userInfo.userId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 班组模式下执行人由班组决定, 检验方案模式下没有执行部门, 均不处理
|
|
|
+ if (this.form.assignType == 1 || this.form.qualityType == 2) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 执行人: 未指定时默认当前登录用户
|
|
|
+ // 注意: 不能依赖执行部门是否取到公司, 否则公司查不到时执行人也不会默认值
|
|
|
+ if (
|
|
|
+ !this.form.executeUserIdList ||
|
|
|
+ !this.form.executeUserIdList.length
|
|
|
+ ) {
|
|
|
+ this.$set(this.form, 'executeUserIdList', [userInfo.userId]);
|
|
|
+ this.$set(this.form, 'executeUserName', userInfo.name);
|
|
|
+ this.$set(this.form, 'executeUserId', String(userInfo.userId));
|
|
|
+ }
|
|
|
+ // 执行部门: 未指定时默认当前登录用户所属公司
|
|
|
+ if (!this.form.executeDeptId) {
|
|
|
+ let company = null;
|
|
|
+ try {
|
|
|
+ company = await getCurrentUserCompany(userInfo);
|
|
|
+ } catch (e) {
|
|
|
+ company = null;
|
|
|
+ }
|
|
|
+ if (company) {
|
|
|
+ this.$set(this.form, 'executeDeptId', company.id);
|
|
|
+ this.$set(this.form, 'executeDeptName', company.name);
|
|
|
+ // 执行部门变了, 人员范围跟着变
|
|
|
+ await this.getUserList({ groupId: company.id });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
// 人员选择
|
|
|
changeExecutor(val) {
|
|
|
this.$set(this.form, 'qualityIdList', val);
|
|
|
@@ -778,7 +829,7 @@
|
|
|
this.form.qualityName = val
|
|
|
.map(
|
|
|
(item) =>
|
|
|
- this.executorList.find((item2) => item2.id == item)?.name
|
|
|
+ this.executorOptions.find((item2) => item2.id == item)?.name
|
|
|
)
|
|
|
.join(',');
|
|
|
} else {
|
|
|
@@ -795,9 +846,9 @@
|
|
|
? this.form.jobList.find(
|
|
|
(job) => job.id == this.form.executeJobId
|
|
|
)?.userVOList
|
|
|
- : this.executorList;
|
|
|
+ : this.executorOptions;
|
|
|
this.form.executeUserName = val
|
|
|
- .map((item) => arr.find((item2) => item2.id == item)?.name)
|
|
|
+ .map((item) => arr?.find((item2) => item2.id == item)?.name)
|
|
|
.join(',');
|
|
|
} else {
|
|
|
this.form.executeUserName = '';
|