|
|
@@ -226,7 +226,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { save, addSubmit, pleaseEntrustDetail } from '@/api/entrust/index';
|
|
|
+ import {
|
|
|
+ save,
|
|
|
+ addSubmit,
|
|
|
+ pleaseEntrustDetail,
|
|
|
+ update
|
|
|
+ } from '@/api/entrust/index';
|
|
|
import produceOrder from './produceOrder';
|
|
|
import detail from '@/views/bpm/processInstance/detail.vue';
|
|
|
import deptSelect from '@/components/CommomSelect/dept-select.vue';
|
|
|
@@ -258,7 +263,8 @@
|
|
|
factoriesId: '',
|
|
|
priority: '',
|
|
|
beEntrustedFactoriesId: '', //受托工厂id
|
|
|
- beEntrustedFactoriesName: '' //受托工厂名称
|
|
|
+ beEntrustedFactoriesName: '', //受托工厂名称
|
|
|
+ id: ''
|
|
|
};
|
|
|
};
|
|
|
export default {
|
|
|
@@ -562,29 +568,82 @@
|
|
|
},
|
|
|
|
|
|
async getDetail(id) {
|
|
|
- await pleaseEntrustDetail(id).then((res) => {
|
|
|
- this.form.pleaseEntrustDeptName = res.data.applyDeptName;
|
|
|
- this.form.pleaseEntrustDeptId = res.data.applyDeptId;
|
|
|
- this.form.pleaseEntrustUserName = res.data.createUserName;
|
|
|
- this.form.pleaseEntrustUserId = res.data.createUserId;
|
|
|
- this.form.factoriesId = res.data.applyFactoriesId;
|
|
|
- this.form.factoriesName = res.data.applyFactoriesName;
|
|
|
- this.form.beEntrustedDeptId = res.data.beEntrustedDeptId;
|
|
|
- this.form.beEntrustedDeptName = res.data.beEntrustedDeptName;
|
|
|
- this.form.beEntrustedFactoriesName =
|
|
|
- res.data.beEntrustedFactoriesName;
|
|
|
- this.form.beEntrustedFactoriesId = res.data.beEntrustedFactoriesId;
|
|
|
- this.form.name = res.data.name;
|
|
|
- this.form.type = res.data.type;
|
|
|
- this.form.priority = res.data.priority;
|
|
|
-
|
|
|
- res.data.taskList = [];
|
|
|
-
|
|
|
- this.orderList.push(this.deepCopy(res.data));
|
|
|
-
|
|
|
- // console.log(this.orderList, 'this.orderListthis.orderList');
|
|
|
- this.getOrderTaskList();
|
|
|
- });
|
|
|
+ try {
|
|
|
+ const res = await pleaseEntrustDetail(id);
|
|
|
+ const data = res?.data || {};
|
|
|
+
|
|
|
+ // 从 data 中结构需要的字段
|
|
|
+ const {
|
|
|
+ applyDeptName,
|
|
|
+ applyDeptId,
|
|
|
+ createUserName,
|
|
|
+ createUserId,
|
|
|
+ applyFactoriesId,
|
|
|
+ applyFactoriesName,
|
|
|
+ beEntrustedDeptId,
|
|
|
+ beEntrustedDeptName,
|
|
|
+ beEntrustedFactoriesName,
|
|
|
+ beEntrustedFactoriesId,
|
|
|
+ name,
|
|
|
+ type,
|
|
|
+ priority,
|
|
|
+ id: dataId
|
|
|
+ } = data;
|
|
|
+
|
|
|
+ // 一次性合并到 form
|
|
|
+ Object.assign(this.form, {
|
|
|
+ pleaseEntrustDeptName: applyDeptName,
|
|
|
+ pleaseEntrustDeptId: applyDeptId,
|
|
|
+ pleaseEntrustUserName: createUserName,
|
|
|
+ pleaseEntrustUserId: createUserId,
|
|
|
+ factoriesId: applyFactoriesId,
|
|
|
+ factoriesName: applyFactoriesName,
|
|
|
+ beEntrustedDeptId,
|
|
|
+ beEntrustedDeptName,
|
|
|
+ beEntrustedFactoriesName,
|
|
|
+ beEntrustedFactoriesId,
|
|
|
+ name,
|
|
|
+ type,
|
|
|
+ priority,
|
|
|
+ id: dataId
|
|
|
+ });
|
|
|
+
|
|
|
+ // 深拷贝时添加 taskList
|
|
|
+ const newData = {
|
|
|
+ ...this.deepCopy(data),
|
|
|
+ taskList: []
|
|
|
+ };
|
|
|
+
|
|
|
+ this.orderList.push(newData);
|
|
|
+
|
|
|
+ await this.getOrderTaskList();
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载委托详情失败:', error);
|
|
|
+ }
|
|
|
+
|
|
|
+ // await pleaseEntrustDetail(id).then((res) => {
|
|
|
+ // this.form.pleaseEntrustDeptName = res.data.applyDeptName;
|
|
|
+ // this.form.pleaseEntrustDeptId = res.data.applyDeptId;
|
|
|
+ // this.form.pleaseEntrustUserName = res.data.createUserName;
|
|
|
+ // this.form.pleaseEntrustUserId = res.data.createUserId;
|
|
|
+ // this.form.factoriesId = res.data.applyFactoriesId;
|
|
|
+ // this.form.factoriesName = res.data.applyFactoriesName;
|
|
|
+ // this.form.beEntrustedDeptId = res.data.beEntrustedDeptId;
|
|
|
+ // this.form.beEntrustedDeptName = res.data.beEntrustedDeptName;
|
|
|
+ // this.form.beEntrustedFactoriesName =
|
|
|
+ // res.data.beEntrustedFactoriesName;
|
|
|
+ // this.form.beEntrustedFactoriesId = res.data.beEntrustedFactoriesId;
|
|
|
+ // this.form.name = res.data.name;
|
|
|
+ // this.form.type = res.data.type;
|
|
|
+ // this.form.priority = res.data.priority;
|
|
|
+ // this.form.id = res.data.id;
|
|
|
+
|
|
|
+ // res.data.taskList = [];
|
|
|
+
|
|
|
+ // this.orderList.push(this.deepCopy(res.data));
|
|
|
+
|
|
|
+ // this.getOrderTaskList();
|
|
|
+ // });
|
|
|
},
|
|
|
|
|
|
removeOder() {
|
|
|
@@ -623,43 +682,103 @@
|
|
|
this.visible = false;
|
|
|
},
|
|
|
choose(list) {
|
|
|
- if (list.length == 0) {
|
|
|
+ // if (list.length == 0) {
|
|
|
+ // this.orderList = [];
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // const existingKeys = new Set(
|
|
|
+ // this.orderList.map((i) => i.id || i.apsWorkOrderCode)
|
|
|
+ // );
|
|
|
+
|
|
|
+ // const newData = list.filter((item) =>
|
|
|
+ // existingKeys.has(item.id || item.apsWorkOrderCode)
|
|
|
+ // );
|
|
|
+ // this.orderList = [];
|
|
|
+
|
|
|
+ // newData.forEach((it) => {
|
|
|
+ // this.orderList.push(this.deepCopy(it));
|
|
|
+ // });
|
|
|
+
|
|
|
+ // const data = list.filter(
|
|
|
+ // (item) => !existingKeys.has(item.id || item.apsWorkOrderCode)
|
|
|
+ // );
|
|
|
+
|
|
|
+ // data.forEach((item) => {
|
|
|
+ // item.describes = '';
|
|
|
+ // item.totalCount = '';
|
|
|
+ // item.taskList = [];
|
|
|
+ // item.taskId = '';
|
|
|
+ // item.taskName = '';
|
|
|
+ // item.beEntrustedFactoriesId = '';
|
|
|
+ // item.beEntrustedFactoriesName = '';
|
|
|
+ // item.status = '';
|
|
|
+ // item.beEntrustedDeptName = '';
|
|
|
+ // item.beEntrustedDeptId = '';
|
|
|
+ // item.categoryName = item.productName;
|
|
|
+ // item.categoryCode = item.productCode;
|
|
|
+ // item.brandNum = item.brandNo;
|
|
|
+ // item.modelType = item.model;
|
|
|
+ // item.name = this.form.name;
|
|
|
+ // item.type = this.form.type;
|
|
|
+ // item.planDeliveryTime = item.startTime;
|
|
|
+ // item.applyDeptId = this.form.pleaseEntrustDeptId;
|
|
|
+ // item.applyDeptName = this.form.pleaseEntrustDeptName;
|
|
|
+ // item.applyFactoriesId = this.form.factoriesId;
|
|
|
+ // item.applyFactoriesName = this.form.factoriesName;
|
|
|
+ // this.orderList.push(this.deepCopy(item));
|
|
|
+ // });
|
|
|
+
|
|
|
+ if (!list || list.length === 0) {
|
|
|
this.orderList = [];
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const existingKeys = new Set(
|
|
|
- this.orderList.map((i) => i.id || i.apsWorkOrderCode)
|
|
|
- );
|
|
|
- const data = list.filter(
|
|
|
- (item) => !existingKeys.has(item.id || item.apsWorkOrderCode)
|
|
|
+ const getKey = (item) => item.id ?? item.apsWorkOrderCode ?? '';
|
|
|
+ const existingKeys = new Set(this.orderList.map(getKey));
|
|
|
+
|
|
|
+ const commonList = list.filter((item) =>
|
|
|
+ existingKeys.has(getKey(item))
|
|
|
);
|
|
|
|
|
|
- data.forEach((item) => {
|
|
|
- item.describes = '';
|
|
|
- item.totalCount = '';
|
|
|
- item.taskList = [];
|
|
|
- item.taskId = '';
|
|
|
- item.taskName = '';
|
|
|
- item.beEntrustedFactoriesId = '';
|
|
|
- item.beEntrustedFactoriesName = '';
|
|
|
- item.status = '';
|
|
|
- item.beEntrustedDeptName = '';
|
|
|
- item.beEntrustedDeptId = '';
|
|
|
- item.categoryName = item.productName;
|
|
|
- item.categoryCode = item.productCode;
|
|
|
- item.brandNum = item.brandNo;
|
|
|
- item.modelType = item.model;
|
|
|
- item.name = this.form.name;
|
|
|
- item.type = this.form.type;
|
|
|
- item.planDeliveryTime = item.startTime;
|
|
|
- item.applyDeptId = this.form.pleaseEntrustDeptId;
|
|
|
- item.applyDeptName = this.form.pleaseEntrustDeptName;
|
|
|
- item.applyFactoriesId = this.form.factoriesId;
|
|
|
- item.applyFactoriesName = this.form.factoriesName;
|
|
|
- this.orderList.push(this.deepCopy(item));
|
|
|
+ const newList = list.filter((item) => !existingKeys.has(getKey(item)));
|
|
|
+
|
|
|
+ const mergedList = [];
|
|
|
+
|
|
|
+ commonList.forEach((it) => {
|
|
|
+ mergedList.push(this.deepCopy(it));
|
|
|
+ });
|
|
|
+
|
|
|
+ // 处理新增
|
|
|
+ newList.forEach((item) => {
|
|
|
+ Object.assign(item, {
|
|
|
+ describes: '',
|
|
|
+ totalCount: '',
|
|
|
+ taskList: [],
|
|
|
+ taskId: '',
|
|
|
+ taskName: '',
|
|
|
+ beEntrustedFactoriesId: '',
|
|
|
+ beEntrustedFactoriesName: '',
|
|
|
+ status: '',
|
|
|
+ beEntrustedDeptName: '',
|
|
|
+ beEntrustedDeptId: '',
|
|
|
+ categoryName: item.productName,
|
|
|
+ categoryCode: item.productCode,
|
|
|
+ brandNum: item.brandNo,
|
|
|
+ modelType: item.model,
|
|
|
+ name: this.form.name,
|
|
|
+ type: this.form.type,
|
|
|
+ planDeliveryTime: item.startTime,
|
|
|
+ applyDeptId: this.form.pleaseEntrustDeptId,
|
|
|
+ applyDeptName: this.form.pleaseEntrustDeptName,
|
|
|
+ applyFactoriesId: this.form.factoriesId,
|
|
|
+ applyFactoriesName: this.form.factoriesName
|
|
|
+ });
|
|
|
+ mergedList.push(this.deepCopy(item));
|
|
|
});
|
|
|
|
|
|
+ this.orderList = mergedList;
|
|
|
+
|
|
|
this.getOrderTaskList();
|
|
|
},
|
|
|
|
|
|
@@ -714,7 +833,18 @@
|
|
|
item.approvalStatus = type == 1 ? 0 : 1;
|
|
|
});
|
|
|
|
|
|
- const URL = type == 1 ? save : addSubmit;
|
|
|
+ // const URL = type == 1 ? save : addSubmit;
|
|
|
+ let URL = '';
|
|
|
+ if (type == 1) {
|
|
|
+ console.log(this.form, '数据777');
|
|
|
+ if (this.form.id) {
|
|
|
+ URL = update;
|
|
|
+ } else {
|
|
|
+ URL = save;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ URL = addSubmit;
|
|
|
+ }
|
|
|
|
|
|
this.loading = this.$loading({
|
|
|
lock: true,
|