|
|
@@ -14,10 +14,10 @@
|
|
|
<ContactList ref="contactRef" :type="type" v-show="currentValue == 6" :itemList="contactInfoVOS"
|
|
|
:isReport="isReport" />
|
|
|
<SchemeList ref="schemeRef" v-show="currentValue == 7" :type='type' :itemList="costListVOS" />
|
|
|
- <ReportInfo v-show="currentValue == 1" />
|
|
|
- <view class="footerButton" v-if="isDisable">
|
|
|
+ <ReportInfo ref="reportInfoRef" :form="reportForm" v-show="currentValue == 1" />
|
|
|
+ <view :class=" type == 'report' ? 'footerButton footer_button':'footerButton'" v-if="isDisable">
|
|
|
<u-button type="default" text="返回" @click="back"></u-button>
|
|
|
- <u-button type="primary" text="报工" @click="back"></u-button>
|
|
|
+ <u-button type="primary" text="报工" v-if="type == 'report'" @click="save('report')"></u-button>
|
|
|
<u-button type="primary" @click="save" text="保存"></u-button>
|
|
|
</view>
|
|
|
<!-- <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
|
|
|
@@ -29,7 +29,8 @@
|
|
|
<script>
|
|
|
import {
|
|
|
getSalesWorkOrderById,
|
|
|
- updateScheme
|
|
|
+ updateScheme,
|
|
|
+ reportWorkingSalesWorkOrder
|
|
|
} from '@/api/salesServiceManagement/workOrder/index.js';
|
|
|
import {
|
|
|
contactDetail
|
|
|
@@ -105,6 +106,11 @@
|
|
|
costListVOS: [], // 方案
|
|
|
currentValue: 5,
|
|
|
accessList: [], // 配件回收
|
|
|
+ reportForm: {
|
|
|
+ acceptTime: '',
|
|
|
+ finishTime: '',
|
|
|
+ inFactDuration: ''
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
onLoad(params) {
|
|
|
@@ -130,6 +136,11 @@
|
|
|
// this.getDept();
|
|
|
const res = await getSalesWorkOrderById(id);
|
|
|
console.log(res, 'res ----')
|
|
|
+ this.reportForm = {
|
|
|
+ acceptTime: res.acceptTime,
|
|
|
+ finishTime: res.finishTime,
|
|
|
+ inFactDuration: res.inFactDuration
|
|
|
+ }
|
|
|
this.accessList = res.accessoryApply?.detailList || []
|
|
|
this.contactData(res.afterSalesDemandVO.contactId, 'init');
|
|
|
resData = res;
|
|
|
@@ -193,8 +204,47 @@
|
|
|
this.listData = data;
|
|
|
})
|
|
|
},
|
|
|
- save() {
|
|
|
+ clistData(arrList) {
|
|
|
+ let list = JSON.parse(JSON.stringify(arrList));
|
|
|
+ let arr = [];
|
|
|
+ if (list.length == 0) return list;
|
|
|
+ list.map((item) => {
|
|
|
+ this.addData(item, arr);
|
|
|
+ });
|
|
|
+ return arr;
|
|
|
+ },
|
|
|
+ addData(item, arr) {
|
|
|
+ let totalCount = item.totalCount ? item.totalCount - 0 : '';
|
|
|
+ if (!totalCount || totalCount == 1) {
|
|
|
+ arr.push(item);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (let i = 0; i < totalCount; i++) {
|
|
|
+ item.totalPrice = item.singlePrice || 0;
|
|
|
+ item.totalCount = 1;
|
|
|
+ arr.push(item);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ process(type) {
|
|
|
let productDetail = this.$refs.salesRef.getTabData();
|
|
|
+ // 点击报工 逻辑
|
|
|
+ if (type == 'report') {
|
|
|
+ let flag = true;
|
|
|
+ productDetail[0].faultDetails.forEach((el) => {
|
|
|
+ if (!el.faultReason || !el.maintenanceProcess) {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: "warning",
|
|
|
+ message: "故障原因跟维修过程不能为空",
|
|
|
+ })
|
|
|
+ this.currentValue = 5;
|
|
|
+ flag = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!flag) {
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+ }
|
|
|
let contactInfoVOS = this.$refs.contactRef.getTabData();
|
|
|
let costListVOS = this.$refs.schemeRef.getTabData();
|
|
|
let obj = resData.afterSalesDemandVO;
|
|
|
@@ -223,10 +273,52 @@
|
|
|
data.salesDemandUpdatePO.productDetail = productDetail;
|
|
|
data.salesDemandUpdatePO.contractInfo = contractInfo;
|
|
|
data.salesDemandUpdatePO.contactInfoVOS = contactInfoVOS;
|
|
|
+ // 处理报工信息的数据
|
|
|
+ let reportForm = this.$refs.reportInfoRef.getReportForm();
|
|
|
+ if (!reportForm.acceptTime || !reportForm.finishTime) {
|
|
|
+ this.currentValue = 1;
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: "warning",
|
|
|
+ message: "请选择开始时间跟结束时间",
|
|
|
+ })
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ data = {
|
|
|
+ ...data,
|
|
|
+ ...reportForm
|
|
|
+ }
|
|
|
+ // 报工进来 保存或者报工 数据
|
|
|
+ if (this.type == 'report' && productDetail[0].faultDetails.length > 0) {
|
|
|
+ let list = this.$refs.accessoryRef.getTabData() || [];
|
|
|
+ if (list.length > 0) {
|
|
|
+ let detailList = this.clistData(list);
|
|
|
+ // 指定绑定第一条设备信息
|
|
|
+ let item = data.salesDemandUpdatePO.productDetail[0];
|
|
|
+ let accessoryApply = {
|
|
|
+ demandDetailId: item.id,
|
|
|
+ categoryCode: item.categoryCode,
|
|
|
+ categoryName: item.categoryName,
|
|
|
+ contactName: data.salesDemandUpdatePO.contractInfo.name,
|
|
|
+ contactCode: data.salesDemandUpdatePO.contractInfo.code,
|
|
|
+ detailList
|
|
|
+ };
|
|
|
+ data.accessoryApply = accessoryApply;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ save(type) {
|
|
|
+ // 获取 报工信息以外的数据
|
|
|
+ let data = this.process(type);
|
|
|
+ if (!data) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log(data, 'data')
|
|
|
uni.showLoading({
|
|
|
title: '加载中'
|
|
|
- })
|
|
|
- updateScheme(data).then(res => {
|
|
|
+ });
|
|
|
+ let api = type != 'report' ? updateScheme : reportWorkingSalesWorkOrder;
|
|
|
+ api(data).then(res => {
|
|
|
this.$refs.uToast.show({
|
|
|
type: "success",
|
|
|
message: "操作成功",
|
|
|
@@ -236,7 +328,6 @@
|
|
|
}).catch(e => {
|
|
|
uni.hideLoading();
|
|
|
})
|
|
|
-
|
|
|
},
|
|
|
// confirm(data, name) {
|
|
|
// this.form.executeGroupName = name
|
|
|
@@ -294,7 +385,7 @@
|
|
|
|
|
|
/deep/.u-button {
|
|
|
height: 100%;
|
|
|
- width: 30%;
|
|
|
+ width: 50%;
|
|
|
}
|
|
|
|
|
|
>view {
|
|
|
@@ -303,6 +394,13 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ .footer_button {
|
|
|
+ /deep/.u-button {
|
|
|
+ height: 100%;
|
|
|
+ width: 30%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.scrollable-tabs {
|
|
|
white-space: nowrap;
|
|
|
/* 防止选项卡换行 */
|