Commit 397aed3f authored by Damon's avatar Damon

feat: 【ID1001296】前台-异常单去处理时只展示驳回的那几项

parent 3842edcf
......@@ -246,10 +246,10 @@
+ "&orderServiceType=" + item.orderServiceType
+ "&inGuaranteePeriod=" + item.inGuaranteePeriod
+ "&partnerCompanyId=" + item.partnerCompanyId
+ "&auditResultsId=" + (item.auditResults?Object.keys(item.auditResults)[Object.keys(item.auditResults).length - 1]:'')
+ "&maintainStep=" + item.maintainStep
+ '&orderStatus=' + item.orderStatus
+ '&brandId=' + item.lianbaoBrandId
+ '&auditResults=' + (item.auditResults ? Object.keys(item.auditResults).join() : '')
})
},
handleClick(item, type, showCountTime) { // type:类型,showCountTime:是否显示倒计时。详情页面情况太多,提前传值可以避免页面晃动
......
......@@ -266,7 +266,7 @@
shape="circle"
:hover-class="submitStatus ? '' : 'none'"
>
{{ tabIndex === list.length - 1 ? "提交" : "下一步" }}
{{ tabIndex === list.length - 1 ? '提交' : '下一步' }}
</u-button>
</view>
</view>
......@@ -286,53 +286,53 @@
</view>
</template>
<script>
import XhInput from "@/components/createCom/XhInput.vue";
import XhMultiInput from "@/components/createCom/XhMultiInput.vue";
import XhRadio from "@/components/createCom/XhRadio.vue";
import XhCheckbox from "@/components/createCom/XhCheckbox.vue";
import XhSelect from "@/components/createCom/XhSelect.vue";
import XhSpecifications from "@/components/createCom/XhSpecifications.vue";
import XhFiles from "@/components/createCom/XhFiles.vue";
import XhLocation from "@/components/createCom/XhLocation.vue";
import XhScan from "@/components/createCom/XhScan.vue";
import XhTime from "@/components/createCom/XhTime.vue";
import XhServiceMeasure from "@/components/createCom/XhServiceMeasure.vue";
import XhServiceMore from "../../components/createCom/XhServiceMore";
import XhLabel from "../../components/createCom/XhLabel";
import XhParts from "@/components/createCom/XhParts";
import takePhoto from "@/components/take/index.vue";
import baseFile from "@/components/upload/index";
import Detail from "@/components/order/detail.vue";
import returnPartsVue from "../parts/returnParts.vue";
import XhInput from '@/components/createCom/XhInput.vue'
import XhMultiInput from '@/components/createCom/XhMultiInput.vue'
import XhRadio from '@/components/createCom/XhRadio.vue'
import XhCheckbox from '@/components/createCom/XhCheckbox.vue'
import XhSelect from '@/components/createCom/XhSelect.vue'
import XhSpecifications from '@/components/createCom/XhSpecifications.vue'
import XhFiles from '@/components/createCom/XhFiles.vue'
import XhLocation from '@/components/createCom/XhLocation.vue'
import XhScan from '@/components/createCom/XhScan.vue'
import XhTime from '@/components/createCom/XhTime.vue'
import XhServiceMeasure from '@/components/createCom/XhServiceMeasure.vue'
import XhServiceMore from '../../components/createCom/XhServiceMore'
import XhLabel from '../../components/createCom/XhLabel'
import XhParts from '@/components/createCom/XhParts'
import takePhoto from '@/components/take/index.vue'
import baseFile from '@/components/upload/index'
import Detail from '@/components/order/detail.vue'
import returnPartsVue from '../parts/returnParts.vue'
// 表单类型map
const formType = new Map([
["text", ["input", "textarea"]],
["password", ["password", "input"]],
["textarea", ["input", "digit"]],
["number", ["input", "digit"]],
["decimal", ["input", "digit"]],
["double", ["input", "digit"]],
["integer", ["input", "digit"]],
["string", ["input", "text"]],
["jscode", ["input", "text"]],
["multiinput", ["multiinput", "text"]],
["select", ["select", "text"]],
["specifications", ["select-new-page", "text"]],
["radio", ["radio", "text"]],
["checkbox", ["checkbox", "text"]],
["file", ["file", "text"]],
["photos", ["file", "text"]],
["location", ["location", "text"]],
["scan", ["scan", "text"]],
["machine_code", ["scan", "text"]],
["service_measures", ["servicemeasure", "text"]],
["time", ["time", "text"]],
["date", ["time", "text"]],
["form", ["form", "text"]],
["label", ["label", "text"]],
["parts", ["parts", "text"]],
]);
['text', ['input', 'textarea']],
['password', ['password', 'input']],
['textarea', ['input', 'digit']],
['number', ['input', 'digit']],
['decimal', ['input', 'digit']],
['double', ['input', 'digit']],
['integer', ['input', 'digit']],
['string', ['input', 'text']],
['jscode', ['input', 'text']],
['multiinput', ['multiinput', 'text']],
['select', ['select', 'text']],
['specifications', ['select-new-page', 'text']],
['radio', ['radio', 'text']],
['checkbox', ['checkbox', 'text']],
['file', ['file', 'text']],
['photos', ['file', 'text']],
['location', ['location', 'text']],
['scan', ['scan', 'text']],
['machine_code', ['scan', 'text']],
['service_measures', ['servicemeasure', 'text']],
['time', ['time', 'text']],
['date', ['time', 'text']],
['form', ['form', 'text']],
['label', ['label', 'text']],
['parts', ['parts', 'text']],
])
/**
* modal 弹窗校验
......@@ -345,80 +345,80 @@ const formType = new Map([
const actions = (name, pass, type, submit) => {
const handerProgrom = {
perfect: {
confirmText: "去完善",
action: "handerProgrom",
confirmText: '去完善',
action: 'handerProgrom',
},
appointment: {
confirmText: "好的,再次预约",
action: "appointment",
confirmText: '好的,再次预约',
action: 'appointment',
},
next: {
confirmText: "下一步",
action: "nextAction",
confirmText: '下一步',
action: 'nextAction',
},
noPerfectSubmit: {
confirmText: "去完善",
action: "handerProgrom",
cancelText: "部分提交",
cancelAction: "appointment",
confirmText: '去完善',
action: 'handerProgrom',
cancelText: '部分提交',
cancelAction: 'appointment',
},
submit: {
confirmText: "提交",
action: "orderFinish",
confirmText: '提交',
action: 'orderFinish',
},
confirm: {
confirmText: "确定",
action: "nextAction",
cancelText: "取消",
cancelAction: "closeCheckResult",
confirmText: '确定',
action: 'nextAction',
cancelText: '取消',
cancelAction: 'closeCheckResult',
},
};
if (name === "partnerInspectItem") {
}
if (name === 'partnerInspectItem') {
// 勘察
if (!pass) return handerProgrom.perfect;
if (!pass) return handerProgrom.perfect
return type
? type === "01"
? type === '01'
? handerProgrom.next
: handerProgrom.appointment
: handerProgrom.perfect;
} else if (name === "partnerInstallItem") {
: handerProgrom.perfect
} else if (name === 'partnerInstallItem') {
// 安装
let hander = "";
let hander = ''
switch (type) {
case "01": // 安装完成
hander = !pass ? handerProgrom.perfect : handerProgrom.next;
break;
case "02": // 二次安装
case '01': // 安装完成
hander = !pass ? handerProgrom.perfect : handerProgrom.next
break
case '02': // 二次安装
hander = !pass
? handerProgrom.noPerfectSubmit
: handerProgrom.appointment;
break;
case "03": //不安装
hander = handerProgrom.confirm;
break;
: handerProgrom.appointment
break
case '03': //不安装
hander = handerProgrom.confirm
break
default:
hander = handerProgrom.perfect;
break;
hander = handerProgrom.perfect
break
}
return hander;
return hander
} else {
// 基础信息
if (!pass) return handerProgrom.perfect;
return submit ? handerProgrom.submit : handerProgrom.next;
if (!pass) return handerProgrom.perfect
return submit ? handerProgrom.submit : handerProgrom.next
}
};
}
export default {
data() {
return {
hiddenTitle: ["location", "form", "label", "parts"],
hiddenTitle: ['location', 'form', 'label', 'parts'],
orderId: 0,
categoryId: 0,
brandId: 0,
orderServiceType: "",
inGuaranteePeriod: "",
partnerCompanyId: "",
auditResultsId: "",
orderServiceType: '',
inGuaranteePeriod: '',
partnerCompanyId: '',
auditResults: [],
list: [],
tabIndex: 0,
scrollTop: 0, //tab标题的滚动条位置
......@@ -426,8 +426,8 @@ export default {
current: 0, // 预设当前项的值
menuHeight: 0, // 左边菜单的高度
menuItemHeight: 0, // 左边菜单item的高度
itemId: "", // 栏目右边scroll-view用于滚动的id
oldItemId: "",
itemId: '', // 栏目右边scroll-view用于滚动的id
oldItemId: '',
menuItemPos: [],
arr: [],
scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
......@@ -439,10 +439,10 @@ export default {
completeCheck: {
status: false,
resulut: [],
confirmText: "去完善",
cancelText: "",
action: "",
cancelAction: "",
confirmText: '去完善',
cancelText: '',
action: '',
cancelAction: '',
},
waitHandlerPanelIndex: 0,
waitHandlerGroupIndex: 0,
......@@ -451,20 +451,20 @@ export default {
// 上传组件相关
carmeraList: [
{
text: "相册",
text: '相册',
},
{
text: "拍照",
text: '拍照',
},
],
maskShow: false,
takeStatus: false,
currentItemDate: {},
photoItem: {},
maintainStep: "partnerInspectItem",
orderStatus: "",
maintainStep: 'partnerInspectItem',
orderStatus: '',
// showTab: true,
};
}
},
components: {
XhInput,
......@@ -482,32 +482,32 @@ export default {
XhLabel,
XhParts,
Detail,
"take-photo": takePhoto,
'take-photo': takePhoto,
},
mixins: [baseFile],
created() {
// console.log(allComponents,'allComponents')
},
onLoad(option) {
getApp().trackPage("订单完工信息页");
getApp().trackPage('订单完工信息页')
if (option) {
this.maintainStep = option.maintainStep;
this.orderId = option.orderId;
this.categoryId = option.categoryId;
this.brandId = option.brandId;
this.orderServiceType = decodeURIComponent(option.orderServiceType);
this.inGuaranteePeriod = option.inGuaranteePeriod;
this.partnerCompanyId = option.partnerCompanyId;
this.auditResultsId = option.auditResultsId;
this.orderStatus = option.orderStatus;
this.maintainStep = option.maintainStep
this.orderId = option.orderId
this.categoryId = option.categoryId
this.brandId = option.brandId
this.orderServiceType = decodeURIComponent(option.orderServiceType)
this.inGuaranteePeriod = option.inGuaranteePeriod
this.partnerCompanyId = option.partnerCompanyId
this.orderStatus = option.orderStatus
this.auditResults = option?.auditResults ? option?.auditResults.split(',') : []
// this.showTab =item.partnerCompanyName == '挚达充电桩'
} else {
this.orderId = 11880091;
this.categoryId = 1100000214;
this.orderServiceType = "安装";
this.inGuaranteePeriod = "Y";
this.orderId = 11880091
this.categoryId = 1100000214
this.orderServiceType = '安装'
this.inGuaranteePeriod = 'Y'
}
this.getCompleteData();
this.getCompleteData()
},
updated() {
//console.log(this.form.name, 'form.name')
......@@ -517,152 +517,189 @@ export default {
// 没有数据的时候tab要有占位数据,不然有页面有晃动
return this.list.length > 0
? this.list[this.tabIndex].items
: [{ name: "" }];
: [{ name: '' }]
},
mixingImage() {
return process.uniEnv.qn_base_url + "mixing.png";
return process.uniEnv.qn_base_url + 'mixing.png'
},
uploadImage() {
return process.uniEnv.qn_base_url + "upload-file.png";
return process.uniEnv.qn_base_url + 'upload-file.png'
},
buttonStyle() {
return {
color: "#FFFFFF",
"background-color": "#2272FF;",
width: "300rpx",
height: "104rpx",
"font-size": "32rpx",
"font-weight": "bold",
"margin-left": "50rpx",
};
color: '#FFFFFF',
'background-color': '#2272FF;',
width: '300rpx',
height: '104rpx',
'font-size': '32rpx',
'font-weight': 'bold',
'margin-left': '50rpx',
}
},
customStyle() {
return {
"background-color": "#D1D4D4",
width: "300rpx",
height: "104rpx",
"background-color": "transparent",
border: "1px solid #2272FF",
color: "#2272FF",
"font-weight": "bold",
"font-size": "32rpx",
};
'background-color': '#D1D4D4',
width: '300rpx',
height: '104rpx',
'background-color': 'transparent',
border: '1px solid #2272FF',
color: '#2272FF',
'font-weight': 'bold',
'font-size': '32rpx',
}
},
show200() {
return (
this.form.paymentMethodsType && this.form.paymentMethodsType != "03"
);
this.form.paymentMethodsType && this.form.paymentMethodsType != '03'
)
},
},
methods: {
getCompleteData() {
//获取工单配置的完工项目
uni.showLoading({
title: "加载中",
});
title: '加载中',
})
if (this.orderId) {
this.$u.api.getCompleteConfigAndData(this.orderId).then((res) => {
if (res.code == 200) {
this.initData(res);
this.initData(res)
} else {
this.$refs.uToast.show({
title: res.message || res.data,
type: "error",
});
type: 'error',
})
}
});
})
}
},
initData(res) {
this.form = res.data.value || {};
this.initFormData();
const list = res.data.config.sort((a, b) => a.order - b.order);
this.form = res.data.value || {}
this.initFormData()
const list = res.data.config.sort((a, b) => a.order - b.order)
list.forEach((item, index) => {
if (this.maintainStep === item.panelFieldsName) this.tabIndex = index;
if (this.maintainStep === item.panelFieldsName) this.tabIndex = index
item.items.forEach((v) => {
v.items.forEach((d) => {
const type = d.fieldsType.toLocaleLowerCase();
const formMap = formType.get(type) || formType.get("text");
d.formType = formMap[0];
d.inputType = formMap[1];
if (d.fieldsName === "actualPaid" && res.data.value) {
d.required = res.data.value["paymentMethodsType"]
? res.data.value["paymentMethodsType"] != "03"
: false;
const type = d.fieldsType.toLocaleLowerCase()
const formMap = formType.get(type) || formType.get('text')
d.formType = formMap[0]
d.inputType = formMap[1]
if (d.fieldsName === 'actualPaid' && res.data.value) {
d.required = res.data.value['paymentMethodsType']
? res.data.value['paymentMethodsType'] != '03'
: false
}
if (d.fieldsName === "pipe" || d.fieldsName === "pipeUseLength") {
if (d.fieldsName === 'pipe' || d.fieldsName === 'pipeUseLength') {
// 申请费用计算
this.calcMoney();
this.calcMoney()
}
if (d.fieldsName === "materialList") {
d.subtitle = "(必填项)";
if (d.fieldsName === 'materialList') {
d.subtitle = '(必填项)'
}
if (d.fieldsName === "craftList") {
d.subtitle = "(若有增项,则为必填项)";
if (d.fieldsName === 'craftList') {
d.subtitle = '(若有增项,则为必填项)'
}
});
});
});
})
})
})
this.list = list;
// this.showTab = this.list.length > 1
// 异常单处理
if (this.auditResultsId) this.checkCompleteError();
uni.hideLoading();
if (this.auditResults.length > 0) {
this.checkCompleteError(list)
} else {
this.list = list
}
uni.hideLoading()
},
initFormData() {
this.loadOrderDetail();
this.loadOrderDetail()
},
loadOrderDetail() {
if (!this.$u.test.isEmpty(this.form) && this.form.hasOwnProperty("installComfirmTime")
&& this.$u.test.isEmpty(this.form.installComfirmTime)) {
if (
!this.$u.test.isEmpty(this.form) &&
this.form.hasOwnProperty('installComfirmTime') &&
this.$u.test.isEmpty(this.form.installComfirmTime)
) {
this.$u.api.orderDetail(null, this.orderId).then((res) => {
if (res.code == 200) {
if (!this.$u.test.isEmpty(res.data.checkInDateTime)) {
this.$set(
this.form,
"installComfirmTime",
this.moment(res.data.checkInDateTime).format("YYYY-MM-DD")
);
'installComfirmTime',
this.moment(res.data.checkInDateTime).format('YYYY-MM-DD')
)
}
}
});
})
}
},
checkCompleteError() {
checkCompleteError(list) {
// 异常单定位错误项
let self = this;
self.list.forEach((panel, panelIndex) => {
let errArr = []
list.forEach((panel, panelIndex) => {
panel.items.forEach((group, groupIndex) => {
group.items.forEach((ele, eleIndex) => {
if (ele.fieldsName === self.auditResultsId) {
self.waitHandlerPanelIndex = panelIndex;
self.waitHandlerGroupIndex = groupIndex;
self.waitHandlerEleIndex = eleIndex;
self.oldItemId = `item${ele.fieldsId}`;
if (this.auditResults.includes(ele.fieldsName)) {
const errGroup = {
componentType: group.componentType,
name: group.name,
items: ele,
}
errArr.push(errGroup)
}
});
});
});
this.locationCompleteItem(
self.waitHandlerPanelIndex,
self.waitHandlerGroupIndex,
self.waitHandlerEleIndex
);
})
})
})
const result = errArr.reduce((groups, item) => {
let groupFound = groups.find((arrItem) => item.name === arrItem.name)
if (groupFound) {
groupFound.componentType = item.componentType
if (groupFound.items.indexOf(item.items) == -1) {
//去重
groupFound.items.push(item.items)
}
} else {
//不要直接在原来的对象修改,新建对象
let newGroup = {
name: item.name,
componentType: item.componentType,
items: [item.items],
}
groups.push(newGroup)
}
return groups
}, [])
let index = list.length++
list[index] = {
order: index + 1,
panelFieldsName: "error",
panelName: "异常处理",
items: result
}
this.list = list
this.tabIndex = index
},
handleSaveData() {
let param = {};
const name = this.list[this.tabIndex].panelFieldsName;
let param = {}
const name = this.list[this.tabIndex].panelFieldsName
this.list.forEach((panel) => {
param[panel.panelFieldsName] = [];
param[panel.panelFieldsName] = []
panel.items.forEach((group) => {
group.items.forEach((ele) => {
if(name === "partnerInspectItem") {
if(!this.form?.installationMethodType) {
this.$set(this.form, "installationMethodType", this.form.installType);
if (name === 'partnerInspectItem') {
if (!this.form?.installationMethodType) {
this.$set(
this.form,
'installationMethodType',
this.form.installType
)
}
}
if (this.form[ele.fieldsName]) {
......@@ -671,96 +708,95 @@ export default {
fieldsType: ele.fieldsType,
fieldsValue: this.form[ele.fieldsName],
required: ele.required,
});
})
}
});
});
});
return param;
})
})
})
return param
},
saveComplete() {
// 保存完工信息
// this.submitParts() // 不调这个接口;没完工不能调提交配件
const param = this.handleSaveData();
const param = this.handleSaveData()
this.$u.api.saveCompleteData(param, this.orderId).then((res) => {
if (res.code == 200) {
this.$refs.uToast.show({
title: "保存成功",
type: "success",
});
title: '保存成功',
type: 'success',
})
} else {
this.$refs.uToast.show({
title: res.message || res.data,
type: "error",
});
type: 'error',
})
}
});
})
},
checkCompleteItem() {
let checkResult = [];
let pass = true;
let first = true;
const lists = this.tabList;
let checkResult = []
let pass = true
let first = true
const lists = this.tabList
lists.forEach((group, groupIndex) => {
const checkRequired = group.items.some((v) => v.required);
const checkRequired = group.items.some((v) => v.required)
if (checkRequired) {
let panelResult = {
label: group.name,
submitted: 0,
required: 0,
pass: true,
};
}
group.items.forEach((ele, eleIndex) => {
if (ele.required) {
panelResult.required++;
let value = this.form[ele.fieldsName];
panelResult.required++
let value = this.form[ele.fieldsName]
if (value && !Array.isArray(value)) {
panelResult.submitted++;
panelResult.submitted++
} else if (value && Array.isArray(value) && value.length > 0) {
if (ele.fieldsName === "materialList") {
let hasMate = false;
if (ele.fieldsName === 'materialList') {
let hasMate = false
let mateRow = value.find((mate) => {
if (mate.hasOwnProperty("useLength")) {
hasMate = true;
return !this.$u.test.isEmpty(mate.useLength);
if (mate.hasOwnProperty('useLength')) {
hasMate = true
return !this.$u.test.isEmpty(mate.useLength)
}
});
})
if (!hasMate || !this.$u.test.isEmpty(mateRow)) {
panelResult.submitted++;
panelResult.submitted++
}
panelResult.submitted++;
panelResult.submitted++
} else {
panelResult.submitted++;
panelResult.submitted++
}
} else if (first) {
// 记录第一个 为空 并且需要必填的项 用于定位
first = false;
this.waitHandlerPanelIndex = this.tabIndex;
this.waitHandlerGroupIndex = groupIndex;
this.waitHandlerEleIndex = eleIndex;
this.oldItemId = `item${ele.fieldsId}`;
first = false
this.waitHandlerPanelIndex = this.tabIndex
this.waitHandlerGroupIndex = groupIndex
this.waitHandlerEleIndex = eleIndex
this.oldItemId = `item${ele.fieldsId}`
}
}
});
panelResult.pass = panelResult.required <= panelResult.submitted;
pass = pass && panelResult.pass;
checkResult.push(panelResult);
})
panelResult.pass = panelResult.required <= panelResult.submitted
pass = pass && panelResult.pass
checkResult.push(panelResult)
}
});
})
console.log(checkResult);
this.completeCheck.result = checkResult;
return pass;
this.completeCheck.result = checkResult
return pass
},
// 检查结果窗口取消回调
closeCheckResult() {
this.completeCheck.status = false;
this[this.completeCheck.cancelAction]();
this.completeCheck.status = false
this[this.completeCheck.cancelAction]()
},
// 检查结果窗口 确认回调
confirm() {
this.completeCheck.status = false;
this[this.completeCheck.action]();
this.completeCheck.status = false
this[this.completeCheck.action]()
},
// 去完善
handerProgrom() {
......@@ -768,50 +804,50 @@ export default {
this.waitHandlerPanelIndex,
this.waitHandlerGroupIndex,
this.waitHandlerEleIndex
);
)
},
// 去预约
async appointment() {
const save = await this.nextStepSaveData();
const save = await this.nextStepSaveData()
if (save) {
uni.reLaunch({
url: "/pages/index/order?type=0",
});
url: '/pages/index/order?type=0',
})
}
},
// 下一步动作
async nextAction() {
const save = await this.nextStepSaveData();
const save = await this.nextStepSaveData()
if (this.tabIndex < this.list.length - 1 && save) {
this.tabIndex++;
this.arr = [];
this.scrollRightTop = 0;
this.current = 0;
this.tabIndex++
this.arr = []
this.scrollRightTop = 0
this.current = 0
//this.itemId = ''
//const itemId = this.list[this.tabIndex].items[0].items[0].fieldsId
//this.oldItemId = `item${itemId}`
this.$nextTick(async () => {
await this.swichMenu(0);
});
await this.swichMenu(0)
})
}
},
// 下一步弹窗处理
nextStep() {
this.pass = this.checkCompleteItem();
this.pass = this.checkCompleteItem()
const name = this.list[this.tabIndex].panelFieldsName;
const name = this.list[this.tabIndex].panelFieldsName
const type =
name === "partnerInspectItem"
name === 'partnerInspectItem'
? this.form.inspectConclusionType
: this.form.constructionConclusionType;
const submit = this.tabIndex === this.list.length - 1;
const result = actions(name, this.pass, type, submit);
: this.form.constructionConclusionType
const submit = this.tabIndex === this.list.length - 1
const result = actions(name, this.pass, type, submit)
this.completeCheck.status = true;
this.completeCheck.confirmText = result.confirmText;
this.completeCheck.action = result.action;
this.completeCheck.cancelText = result.cancelText || "";
this.completeCheck.cancelAction = result.cancelAction || "";
this.completeCheck.status = true
this.completeCheck.confirmText = result.confirmText
this.completeCheck.action = result.action
this.completeCheck.cancelText = result.cancelText || ''
this.completeCheck.cancelAction = result.cancelAction || ''
},
// 下一步数据保存
nextStepSaveData() {
......@@ -819,274 +855,274 @@ export default {
maintainFields: this.handleSaveData(),
currentStep: this.list[this.tabIndex].panelFieldsName,
nextStep: this.list[this.tabIndex + 1].panelFieldsName,
};
}
uni.showLoading({
title: "加载中",
});
title: '加载中',
})
return this.$u.api.completeNextStep(params, this.orderId).then((res) => {
uni.hideLoading();
uni.hideLoading()
if (res.code == 200) {
return Promise.resolve(true);
return Promise.resolve(true)
} else {
this.$refs.uToast.show({
title: res.message || res.data,
type: "error",
});
return Promise.resolve(false);
type: 'error',
})
return Promise.resolve(false)
}
});
})
},
locationCompleteItem(panelIndex, groupIndex, eleIndex) {
// 页面定位到某一项
this.tabIndex = panelIndex;
this.current = groupIndex;
this.itemId = "";
this.$nextTick(function () {
if (this.oldItemId) this.itemId = this.oldItemId;
});
this.tabIndex = panelIndex
this.current = groupIndex
this.itemId = ''
this.$nextTick(function() {
if (this.oldItemId) this.itemId = this.oldItemId
})
},
// 提交配件信息
submitParts() {
if (this.form.orderSpareParts) {
const orderSpareParts = JSON.parse(this.form.orderSpareParts);
const lists = orderSpareParts.filter((v) => v.quantity > 0);
const orderSpareParts = JSON.parse(this.form.orderSpareParts)
const lists = orderSpareParts.filter((v) => v.quantity > 0)
const params = {
workOrderId: this.orderId,
applyType: "10",
parts: lists ? JSON.stringify(lists) : "",
};
applyType: '10',
parts: lists ? JSON.stringify(lists) : '',
}
this.$u.api.createParts(params).then((res) => {
if (res.code !== 200) {
this.$refs.uToast.show({
title: res.data,
type: "error",
});
type: 'error',
})
}
});
})
}
},
// 提交订单
orderFinish() {
const param = this.handleSaveData();
const param = this.handleSaveData()
// 完工事件埋点
getApp().track("order_finish", {
getApp().track('order_finish', {
id: this.vuex_user.id,
mobile: this.vuex_user.mobile,
orderId: Number(this.orderId),
});
})
this.$u.api.saveCompleteData(param, this.orderId).then((res) => {
if (res.code == 200) {
//完工项信息保存成功再次完工工单
if (this.inGuaranteePeriod === "Y") {
if (this.inGuaranteePeriod === 'Y') {
this.$u.api.inOrderFinish(this.orderId).then((res) => {
if (res.code == 200) {
this.submitParts();
this.submitParts()
this.$refs.uToast.show({
title: "提交成功",
type: "success",
title: '提交成功',
type: 'success',
callback: () => {
uni.reLaunch({
url: "/pages/index/order?type=3",
});
url: '/pages/index/order?type=3',
})
},
});
})
} else {
this.$refs.uToast.show({
title: res.data,
type: "error",
});
type: 'error',
})
}
});
})
} else {
this.$u.api
.outOrderFinish({ customerPayType: "CASH" }, this.orderId)
.outOrderFinish({ customerPayType: 'CASH' }, this.orderId)
.then((res) => {
if (res.code == 200) {
this.$refs.uToast.show({
title: "提交成功",
type: "success",
title: '提交成功',
type: 'success',
callback: () => {
uni.reLaunch({
url: "/pages/index/order?type=3",
});
url: '/pages/index/order?type=3',
})
},
});
})
} else {
this.$refs.uToast.show({
title: res.data,
type: "error",
});
type: 'error',
})
}
});
})
}
} else {
this.$refs.uToast.show({
title: res.data,
type: "error",
});
type: 'error',
})
}
});
})
},
calMaterialCraftListAmount(arr) {
let amount = 0;
let amount = 0
if (arr) {
arr.forEach((item) => {
let useLength =
(item.hasOwnProperty("useLength") && Number(item.useLength)) || 0;
(item.hasOwnProperty('useLength') && Number(item.useLength)) || 0
let freeLength =
(item.hasOwnProperty("freeLength") && Number(item.freeLength)) || 0;
(item.hasOwnProperty('freeLength') && Number(item.freeLength)) || 0
let unitAmt =
(item.hasOwnProperty("unitAmt") && Number(item.unitAmt)) || 0;
amount += Math.max(useLength - freeLength, 0) * unitAmt;
if (item.hasOwnProperty("extraAmt") && Number(item.extraAmt)) {
amount += Number(item.extraAmt);
(item.hasOwnProperty('unitAmt') && Number(item.unitAmt)) || 0
amount += Math.max(useLength - freeLength, 0) * unitAmt
if (item.hasOwnProperty('extraAmt') && Number(item.extraAmt)) {
amount += Number(item.extraAmt)
}
});
})
}
return amount;
return amount
},
setData(data) {
// 通过页面设置数据
Object.keys(data).forEach((key) => {
this.$set(this.form, key, data[key]);
});
this.$set(this.form, key, data[key])
})
// 更新预计超出金额
let amount = 0;
amount += this.calMaterialCraftListAmount(this.form.materialList);
amount += this.calMaterialCraftListAmount(this.form.craftList);
this.$set(this.form, "overAmount", amount || 0);
let amount = 0
amount += this.calMaterialCraftListAmount(this.form.materialList)
amount += this.calMaterialCraftListAmount(this.form.craftList)
this.$set(this.form, 'overAmount', amount || 0)
},
// 字段的值更新
fieldValueChange(data) {
const groupItem = this.list[this.tabIndex].items[data.groupIndex];
let innerItem;
const groupItem = this.list[this.tabIndex].items[data.groupIndex]
let innerItem
if (groupItem.items) {
innerItem = groupItem.items[data.itemIndex];
innerItem = groupItem.items[data.itemIndex]
}
if (innerItem.fieldsType === "multiInput") {
if (innerItem.fieldsType === 'multiInput') {
// 多个输入框的值触发
let key = Object.keys(data.value)[0];
this.form[key] = data.value[key];
let key = Object.keys(data.value)[0]
this.form[key] = data.value[key]
} else {
this.$set(this.form, innerItem.fieldsName, data.value);
this.$set(this.form, innerItem.fieldsName, data.value)
}
if (innerItem.fieldsName === "paymentMethodsType") {
if (innerItem.fieldsName === 'paymentMethodsType') {
// 选不需要收款的时候,收款金额修改为非必选
const row = groupItem.items.find((v) => v.fieldsName === "actualPaid");
row.required = data.value != "03";
const row = groupItem.items.find((v) => v.fieldsName === 'actualPaid')
row.required = data.value != '03'
}
if (
innerItem.fieldsName === "pipe" ||
innerItem.fieldsName === "pipeUseLength"
innerItem.fieldsName === 'pipe' ||
innerItem.fieldsName === 'pipeUseLength'
) {
// 申请费用计算
this.calcMoney();
this.calcMoney()
}
},
// 申请费用计算
calcMoney() {
const price = parseInt(this.form.pipe) || 0;
const pipeUseLength = parseFloat(this.form.pipeUseLength) || 0;
const price = parseInt(this.form.pipe) || 0
const pipeUseLength = parseFloat(this.form.pipeUseLength) || 0
if (price && pipeUseLength) {
const money = (price * pipeUseLength).toFixed(2);
this.$set(this.form, "pipeAmount", money);
const money = (price * pipeUseLength).toFixed(2)
this.$set(this.form, 'pipeAmount', money)
} else {
this.$set(this.form, "pipeAmount", 0);
this.$set(this.form, 'pipeAmount', 0)
}
},
// ------------------------- 以下方法为上传组件相关 -------------------------
// 弹出上传选项
selectUpload(item, groupIndex, itemIndex) {
const imgList =
this.$refs[`fileChild${groupIndex}${itemIndex}`][0].imgList;
const imgList = this.$refs[`fileChild${groupIndex}${itemIndex}`][0]
.imgList
if (imgList.length === 10) {
return this.$refs.uToast.show({
title: "图片已超出最大数量",
type: "error",
});
title: '图片已超出最大数量',
type: 'error',
})
}
this.photoItem = {
...JSON.parse(item),
groupIndex,
itemIndex,
};
}
// 弹窗展示
this.maskShow = true;
this.maskShow = true
},
// 区分上传动作
uploadSelect(index) {
if (index === 0) {
this.uploadFile("photo");
this.uploadFile('photo')
} else {
this.uploadFile();
this.uploadFile()
}
},
// 拍照回调
async closeTake(val) {
if (val && val.length > 0) {
const files = val.map((v) => v.path);
const value = await this.saveToTask(files);
const files = val.map((v) => v.path)
const value = await this.saveToTask(files)
this.$refs[
`fileChild${this.photoItem.groupIndex}${this.photoItem.itemIndex}`
][0].setTmpValue(value);
][0].setTmpValue(value)
}
this.takeStatus = false;
this.takeStatus = false
},
// 上传图片
async uploadFile(type) {
const self = this;
if (type && type === "photo") {
const self = this
if (type && type === 'photo') {
// 直接打开相册
let options = {
sourceType: ["album"], //['album', 'camera']
sourceType: ['album'], //['album', 'camera']
count: 3,
sizeType: ["compressed"],
};
const value = await this.chooseImg(options);
sizeType: ['compressed'],
}
const value = await this.chooseImg(options)
self.$refs[
`fileChild${self.photoItem.groupIndex}${self.photoItem.itemIndex}`
][0].setTmpValue(value);
return;
][0].setTmpValue(value)
return
}
// 使用拍照工具拍摄
this.photograph();
this.getWatermark();
this.photograph()
this.getWatermark()
},
// 获取拍照规范
photograph() {
let self = this;
let self = this
let param = {
partnerCompanyId: this.partnerCompanyId || "",
partnerCompanyId: this.partnerCompanyId || '',
categoryId: this.categoryId,
brandId: this.brandId || "",
brandId: this.brandId || '',
fieldName: this.photoItem.fieldsName,
};
}
this.$u.api.orderStandardItem(param).then((res) => {
if (res.code == 200 && res.data.length > 0) {
self.currentItemDate = res.data[0];
self.currentItemDate = res.data[0]
} else {
console.log("获取完工项的拍照标准异常", res.data.message);
console.log('获取完工项的拍照标准异常', res.data.message)
}
self.takeStatus = true;
});
self.takeStatus = true
})
},
// 获取水印
getWatermark() {
if (getApp().globalData.photo.waterSetting) {
return;
return
}
var data = { partnerCompanyId: this.partnerCompanyId || "" };
var data = { partnerCompanyId: this.partnerCompanyId || '' }
this.$u.api.getWatermark(data).then((res) => {
if (res.code == 200) {
getApp().globalData.photo.waterSetting = res.data;
getApp().globalData.photo.waterSetting = res.data
} else {
console.log("获取水印备注异常", res.data.message);
console.log('获取水印备注异常', res.data.message)
}
});
})
},
// ------------------------- 以上方法为上传组件相关 -------------------------
......@@ -1094,77 +1130,77 @@ export default {
// 点击左边的栏目切换
async swichMenu(index) {
if (this.arr.length == 0) {
await this.getMenuItemTop();
await this.getMenuItemTop()
}
// if (index == this.current) return;
this.scrollRightTop = this.oldScrollTop;
this.$nextTick(function () {
this.scrollRightTop = this.oldScrollTop
this.$nextTick(function() {
setTimeout(() => {
// 没有指定滚动到某一小项,就滚动到大的项
this.scrollRightTop = this.arr[index];
this.current = index;
}, 100);
});
this.scrollRightTop = this.arr[index]
this.current = index
}, 100)
})
},
// 获取右边菜单每个item到顶部的距离
getMenuItemTop() {
new Promise((resolve) => {
let selectorQuery = uni.createSelectorQuery();
let selectorQuery = uni.createSelectorQuery()
selectorQuery
.selectAll(".class-item")
.selectAll('.class-item')
.boundingClientRect((rects) => {
// 如果节点尚未生成,rects值为[](因为用selectAll,所以返回的是数组),循环调用执行
if (!rects.length) {
setTimeout(() => {
this.getMenuItemTop();
}, 10);
return;
this.getMenuItemTop()
}, 10)
return
}
rects.forEach((rect) => {
// 这里减去rects[0].top,是因为第一项顶部可能不是贴到导航栏(比如有个搜索框的情况)
this.arr.push(rect.top - rects[0].top);
resolve();
});
this.arr.push(rect.top - rects[0].top)
resolve()
})
})
.exec();
});
.exec()
})
},
// 右边菜单滚动
async rightScroll(e) {
this.oldScrollTop = e.detail.scrollTop;
this.oldScrollTop = e.detail.scrollTop
if (this.arr.length == 0) {
await this.getMenuItemTop();
await this.getMenuItemTop()
}
if (this.timer) return;
if (this.timer) return
this.timer = setTimeout(() => {
// 节流
this.timer = null;
this.timer = null
// scrollHeight为右边菜单垂直中点位置
let scrollHeight = e.detail.scrollTop;
let scrollHeight = e.detail.scrollTop
for (let i = 0; i < this.arr.length; i++) {
let height1 = this.arr[i];
let height2 = this.arr[i + 1];
let height1 = this.arr[i]
let height2 = this.arr[i + 1]
// 如果不存在height2,意味着数据循环已经到了最后一个,设置左边菜单为最后一项即可
if (!height2 || (scrollHeight >= height1 && scrollHeight < height2)) {
this.current = i;
return;
this.current = i
return
}
}
}, 10);
}, 10)
},
handleTouchstart() {
// 防止输入光标滚动出现错乱
uni.hideKeyboard();
uni.hideKeyboard()
},
// 返回上一页更新订单状态
backGo() {
const pages = getCurrentPages();
const beforePage = pages[pages.length - 2];
if (beforePage.$vm.loadOrderDetail) beforePage.$vm.loadOrderDetail();
uni.navigateBack();
const pages = getCurrentPages()
const beforePage = pages[pages.length - 2]
if (beforePage.$vm.loadOrderDetail) beforePage.$vm.loadOrderDetail()
uni.navigateBack()
},
},
};
}
</script>
<style lang="scss" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment