|
|
@@ -0,0 +1,313 @@
|
|
|
+<template>
|
|
|
+ <div v-loading="checking" class="operation-tab">
|
|
|
+ <div v-if="!produceTaskId || !workOrderInfo || !workOrderInfo.id">
|
|
|
+ <el-empty description="暂无工序信息"></el-empty>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-else-if="!outsourceAllowed" class="outsource-tip">
|
|
|
+ <el-alert
|
|
|
+ :title="outsourceTipMsg"
|
|
|
+ type="info"
|
|
|
+ :closable="false"
|
|
|
+ show-icon
|
|
|
+ ></el-alert>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-else class="right_main_box">
|
|
|
+ <!-- 委外 / 请托记录列表 -->
|
|
|
+ <outsourcingDetails
|
|
|
+ ref="outsourcingListRef"
|
|
|
+ v-if="!isStep && !isOutsource && !isPleaseEntrust"
|
|
|
+ :chooseType="chooseType"
|
|
|
+ @outsourcingAdd="outsourcingAdd"
|
|
|
+ @pleaseEntrustReceived="handlePleaseEntrustReceived"
|
|
|
+ ></outsourcingDetails>
|
|
|
+
|
|
|
+ <!-- 新增委外(选完工序) -->
|
|
|
+ <outsourcing
|
|
|
+ :outsourceFormVal="outsourceForm"
|
|
|
+ :taskObj="mergedTaskObj"
|
|
|
+ :workListIds="workOrderInfo.id"
|
|
|
+ :workData="workInfoList"
|
|
|
+ :chooseType="chooseType"
|
|
|
+ @changePlugIn="changePlugIn"
|
|
|
+ @changeCancel="changeCancel"
|
|
|
+ v-if="isStep"
|
|
|
+ ></outsourcing>
|
|
|
+
|
|
|
+ <!-- 委外单列表 -->
|
|
|
+ <outsourceList
|
|
|
+ :workData="workInfoList"
|
|
|
+ :taskObj="mergedTaskObj"
|
|
|
+ :outsourceFormVal="outsourceForm"
|
|
|
+ :chooseType="chooseType"
|
|
|
+ @closeForm="closeForm"
|
|
|
+ @outScucc="outScucc"
|
|
|
+ v-if="isOutsource"
|
|
|
+ ></outsourceList>
|
|
|
+
|
|
|
+ <!-- 请托单列表 -->
|
|
|
+ <pleaseEntrust
|
|
|
+ :outsourceFormVal="outObj"
|
|
|
+ @closeForm="closeForm"
|
|
|
+ @outScucc="outScucc"
|
|
|
+ v-if="isPleaseEntrust"
|
|
|
+ ></pleaseEntrust>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <addPlease ref="addPleaseRef" @refresh="refreshPlease"></addPlease>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import outsourcingDetails from '@/views/produce/components/outsourcing/details.vue';
|
|
|
+ import outsourcing from '@/views/produce/components/outsourcing/index.vue';
|
|
|
+ import outsourceList from '@/views/produce/components/outsourcing/new_outsourceList.vue';
|
|
|
+ import pleaseEntrust from '@/views/produce/components/outsourcing/pleaseEntrust.vue';
|
|
|
+ import addPlease from '@/views/produce/components/outsourcing/addPlease.vue';
|
|
|
+ import {
|
|
|
+ pcCheckOutsource,
|
|
|
+ getTaskInstanceById,
|
|
|
+ checkOutsourceMaterial,
|
|
|
+ checkPleaseEntrust
|
|
|
+ } from '@/api/produce/index';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ name: 'outsourceTab',
|
|
|
+ components: {
|
|
|
+ outsourcingDetails,
|
|
|
+ outsourcing,
|
|
|
+ outsourceList,
|
|
|
+ pleaseEntrust,
|
|
|
+ addPlease
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ // 工单信息
|
|
|
+ workOrderInfo: {
|
|
|
+ type: Object,
|
|
|
+ required: true
|
|
|
+ },
|
|
|
+ // 工序配置 id(作业台取自 store.taskObj.id)
|
|
|
+ produceTaskId: {
|
|
|
+ type: [String, Number],
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ // 工序实例 id
|
|
|
+ taskInstanceId: {
|
|
|
+ type: [String, Number],
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ // 顶部步骤条当前所选工序的完整数据
|
|
|
+ taskObj: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({})
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ checking: false,
|
|
|
+ outsourceAllowed: false,
|
|
|
+ outsourceTipMsg: '',
|
|
|
+ isStep: false,
|
|
|
+ isOutsource: false,
|
|
|
+ isPleaseEntrust: false,
|
|
|
+ chooseType: '1',
|
|
|
+ outsourceForm: {},
|
|
|
+ outObj: {},
|
|
|
+ workInfoList: { list: [] }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // 委外面板需要 store taskObj 的字段结构:id 为工序配置 id
|
|
|
+ mergedTaskObj() {
|
|
|
+ return {
|
|
|
+ ...this.taskObj,
|
|
|
+ id: this.produceTaskId,
|
|
|
+ sourceTaskId: this.produceTaskId,
|
|
|
+ taskId: this.taskInstanceId
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ produceTaskId() {
|
|
|
+ this.reset();
|
|
|
+ this.checkOutsourceEnabled();
|
|
|
+ },
|
|
|
+ workOrderInfo: {
|
|
|
+ deep: true,
|
|
|
+ handler() {
|
|
|
+ this.reset();
|
|
|
+ this.checkOutsourceEnabled();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.checkOutsourceEnabled();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ reset() {
|
|
|
+ this.isStep = false;
|
|
|
+ this.isOutsource = false;
|
|
|
+ this.isPleaseEntrust = false;
|
|
|
+ this.chooseType = '1';
|
|
|
+ this.outsourceForm = {};
|
|
|
+ this.outObj = {};
|
|
|
+ this.workInfoList = { list: [] };
|
|
|
+ },
|
|
|
+
|
|
|
+ // 与作业台一致:先判断该工序是否允许委外(pcCheckOutsource)
|
|
|
+ async checkOutsourceEnabled() {
|
|
|
+ if (
|
|
|
+ !this.produceTaskId ||
|
|
|
+ !this.workOrderInfo ||
|
|
|
+ !this.workOrderInfo.id
|
|
|
+ ) {
|
|
|
+ this.outsourceAllowed = false;
|
|
|
+ this.outsourceTipMsg = '暂无工序信息';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.checking = true;
|
|
|
+ try {
|
|
|
+ const res = await pcCheckOutsource({
|
|
|
+ taskId: this.produceTaskId,
|
|
|
+ workOrderId: this.workOrderInfo.id
|
|
|
+ });
|
|
|
+ const data = (res && res.data) || {};
|
|
|
+ this.outsourceForm = { ...data };
|
|
|
+ this.outsourceAllowed = !!data.outsource;
|
|
|
+ this.outsourceTipMsg = this.outsourceAllowed ? '' : '此工序不能委外';
|
|
|
+ this.getTaskInstanceByIdFn(this.workOrderInfo.id);
|
|
|
+ } catch (error) {
|
|
|
+ this.outsourceAllowed = false;
|
|
|
+ this.outsourceTipMsg = '委外资格校验失败';
|
|
|
+ } finally {
|
|
|
+ this.checking = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ getTaskInstanceByIdFn(workOrderId) {
|
|
|
+ getTaskInstanceById(workOrderId).then((res) => {
|
|
|
+ let { data } = res;
|
|
|
+ if (data && data.length) {
|
|
|
+ data = data.filter(
|
|
|
+ (item) => item.taskId != -2 && item.taskId != -1
|
|
|
+ );
|
|
|
+ const arr = data.findIndex(
|
|
|
+ (item) => item.sourceTaskId == this.produceTaskId
|
|
|
+ );
|
|
|
+ if (arr != -1) {
|
|
|
+ data.splice(0, arr);
|
|
|
+ }
|
|
|
+ this.$set(this.outsourceForm, 'newStepsList', data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ outsourcingAdd(type, activeName) {
|
|
|
+ this.chooseType = activeName;
|
|
|
+ this.getTaskInstanceByIdFn(this.workOrderInfo.id);
|
|
|
+
|
|
|
+ this.workInfoList = { list: [] };
|
|
|
+ this.workInfoList.list.push(this.workOrderInfo);
|
|
|
+ if (this.chooseType == '2') {
|
|
|
+ this.isStep = true;
|
|
|
+ } else {
|
|
|
+ this.isOutsource = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ changeCancel(activeType) {
|
|
|
+ this.isStep = false;
|
|
|
+ this.chooseType = activeType;
|
|
|
+ this.reloadList();
|
|
|
+ },
|
|
|
+
|
|
|
+ async changePlugIn(e, index) {
|
|
|
+ if (index == '1') {
|
|
|
+ this.outObj = e;
|
|
|
+ const req = this.buildPlugInReq(e);
|
|
|
+ const res = await checkOutsourceMaterial(req);
|
|
|
+ this.outObj = {
|
|
|
+ ...res.data,
|
|
|
+ ...this.outsourceForm,
|
|
|
+ ...this.outObj
|
|
|
+ };
|
|
|
+ this.isStep = false;
|
|
|
+ this.isOutsource = true;
|
|
|
+ } else if (index == '2') {
|
|
|
+ this.outObj = e;
|
|
|
+ const req = this.buildPlugInReq(e);
|
|
|
+ const res = await checkPleaseEntrust(req);
|
|
|
+ this.outObj = {
|
|
|
+ ...res.data,
|
|
|
+ ...this.outsourceForm,
|
|
|
+ ...this.outObj
|
|
|
+ };
|
|
|
+ this.isStep = false;
|
|
|
+ this.isPleaseEntrust = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ buildPlugInReq(e) {
|
|
|
+ return {
|
|
|
+ taskId: e.taskId,
|
|
|
+ taskIds: e.taskIds,
|
|
|
+ workOrderId: e.workOrderId,
|
|
|
+ quantity: e.formedNumLast
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ closeForm() {
|
|
|
+ this.isOutsource = false;
|
|
|
+ this.isPleaseEntrust = false;
|
|
|
+ this.reloadList();
|
|
|
+ },
|
|
|
+
|
|
|
+ outScucc() {
|
|
|
+ this.isOutsource = false;
|
|
|
+ this.isPleaseEntrust = false;
|
|
|
+ this.reloadList();
|
|
|
+ },
|
|
|
+
|
|
|
+ reloadList() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const ref = this.$refs.outsourcingListRef;
|
|
|
+ if (!ref || !this.workOrderInfo) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.chooseType == '1') {
|
|
|
+ ref.getDataList(this.workOrderInfo.code);
|
|
|
+ } else if (this.chooseType == '2') {
|
|
|
+ ref.getPleaseData(this.workOrderInfo.code);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ refreshPlease() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.outsourcingListRef &&
|
|
|
+ this.$refs.outsourcingListRef.getPleaseData(
|
|
|
+ this.workOrderInfo.code
|
|
|
+ );
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 请托收货成功后刷新工单,通知外层详情抽屉重新拉取 */
|
|
|
+ handlePleaseEntrustReceived() {
|
|
|
+ this.isStep = false;
|
|
|
+ this.isOutsource = false;
|
|
|
+ this.isPleaseEntrust = false;
|
|
|
+ this.$emit('refresh');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .operation-tab {
|
|
|
+ min-height: 160px;
|
|
|
+ }
|
|
|
+ .outsource-tip {
|
|
|
+ padding: 12px 0;
|
|
|
+ }
|
|
|
+</style>
|