init
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"g-upload": "/components/uploadPic/uploadPic",
|
||||
"van-picker": "@vant/weapp/picker/index",
|
||||
"van-popup": "@vant/weapp/popup/index",
|
||||
"van-search": "@vant/weapp/search/index"
|
||||
},
|
||||
"navigationBarTitleText": "报价"
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
/* pages/vehicleMaintenance/operation/offer/offer.wxss */
|
||||
.container {
|
||||
height: 100vh;
|
||||
background: #EFF1F4;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.content-box {
|
||||
height: calc(100vh - 84px);
|
||||
overflow-y: auto;
|
||||
|
||||
.content {
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
background: #fff;
|
||||
|
||||
.top {
|
||||
margin-bottom: 8px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.line {
|
||||
width: 4px;
|
||||
height: 22px;
|
||||
margin: 0 8px 0 2px;
|
||||
background: linear-gradient(180deg, #4E87FC 0%, #38B1FE 100%);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: #333F53;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
.btn-add {
|
||||
padding: 8px 24px;
|
||||
background: #E9F2FF;
|
||||
border-radius: 4px;
|
||||
border: 1px dashed #4381FC;
|
||||
color: #4381FC;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin-right: 9px;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.offer-content {
|
||||
.offer-list {
|
||||
.offer-item {
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
background: #ECEFF5;
|
||||
border-radius: 4px;
|
||||
color: #2F3B50;
|
||||
font-size: 14px;
|
||||
|
||||
.row {
|
||||
padding: 10px 12px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #E6EAF2;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.label {}
|
||||
|
||||
.val {
|
||||
width: 60%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
>.project-select {
|
||||
width: 100%;
|
||||
// border: 1px solid #DBDBDB;
|
||||
border-radius: 4px;
|
||||
background: #ffffff;
|
||||
|
||||
picker {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
.picker {
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
padding: 0 20px 0 8px;
|
||||
box-sizing: border-box;
|
||||
// border: 1px solid #E6EAF2;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.picker::after {
|
||||
content: '';
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 6px solid #636B83;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid transparent;
|
||||
border-left: 6px solid transparent;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 6px;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
>input {
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.unit {
|
||||
width: 56rpx;
|
||||
margin-left: 6px;
|
||||
color: #636B83;
|
||||
font-size: 24rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.num-val {
|
||||
width: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
|
||||
>input {
|
||||
width: 50%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.up,
|
||||
.down {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
line-height: 18px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 50%;
|
||||
border: 1px solid #C3CBE4;
|
||||
color: #C3CBE4;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
// image {
|
||||
// width: 100%;
|
||||
// height: 100%;
|
||||
// display: block;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.total-row {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.total {
|
||||
padding: 0 6px;
|
||||
color: #2E3A4F;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.num {
|
||||
margin: 0 8px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-del {
|
||||
padding: 2px 16px;
|
||||
background: #FFEEEE;
|
||||
border: 1px solid #FDD0DD;
|
||||
border-radius: 4px;
|
||||
color: #FA5955;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-show,
|
||||
.btn-hide {
|
||||
padding: 8px;
|
||||
color: #2F3B50;
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
margin-right: 10px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
>.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.label {
|
||||
color: #2F3B50;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.val {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
>input {
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.unit {
|
||||
width: 56rpx;
|
||||
margin-left: 6px;
|
||||
color: #636B83;
|
||||
font-size: 24rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.marker {
|
||||
padding: 12px 8px;
|
||||
border: 1px solid #E6EAF2;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.upload {
|
||||
padding: 12px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.echoFile {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.photo-list {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin-left: 8px;
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.del {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
right: -10px;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bottom {
|
||||
width: 100%;
|
||||
padding: 22px 10px;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
border-radius: 8px 8px 0 0;
|
||||
box-shadow: 0px -2px 12px 0px rgba(0, 0, 0, 0.2);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
|
||||
.btn-box {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(90deg, #3B7CFC 0%, #548BFC 100%);
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.require {
|
||||
&::after {
|
||||
content: '*';
|
||||
width: 6px;
|
||||
height: 100%;
|
||||
color: red;
|
||||
margin-left: 8px;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.searchBox {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
top: 80rpx;
|
||||
z-index: 63;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 11rpx solid transparent;
|
||||
border-right: 11rpx solid transparent;
|
||||
border-top: 13rpx solid #636B83;
|
||||
margin-left: 18rpx;
|
||||
}
|
||||
|
||||
.delete {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.requireItem {
|
||||
&::before {
|
||||
content: '*';
|
||||
width: 6px;
|
||||
height: 100%;
|
||||
color: red;
|
||||
margin-right: 4px;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,519 @@
|
||||
// pages/vehicleMaintenance/operation/offer/offer.ts
|
||||
import { getAction, postAction } from '../../../../api/base';
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
showMore: true, // 展示/收起明细
|
||||
classifyOptions: [] as any, // 保养分类数据
|
||||
filterClassifyOptions: [] as any, // 过滤保养分类数据
|
||||
repairDetailList: [] as any, // 保养明细
|
||||
materialCost: '' as any, // 总计材料费
|
||||
totalWorkHours: '' as any, // 总计工时
|
||||
totalWorkHoursCost: '' as any, // 总计工时费用
|
||||
totaCost: '' as any, // 总计
|
||||
offerContent: '', // 内容说明
|
||||
beforeUpkeepImgUrl: [], // 保养前图片
|
||||
attachmentUpkeepList: [], // 单据附件
|
||||
echoFile: null as any, // 回显时的单据附件
|
||||
echoBeforeFile: null as any, // 回显保养前
|
||||
upkeepObject: {} as any, // 保养单数据
|
||||
uploadUrl: 'api/vehicles/repair/fileUpload', // 上传图片地址
|
||||
classifySearchVal: '', // 保养分类过滤查询
|
||||
currentIndex: null // 当前选中的保养明细
|
||||
},
|
||||
showDetail() {
|
||||
this.setData({
|
||||
showMore: !this.data.showMore
|
||||
});
|
||||
},
|
||||
// 明细相关值修改-------------------
|
||||
addOffer() {
|
||||
let tmpArr = this.data.repairDetailList;
|
||||
tmpArr.push({
|
||||
repairClass: '',
|
||||
repairClass_dictText: '',
|
||||
repairContent: '',
|
||||
quantity: '',
|
||||
unitPrice: '',
|
||||
workHours: '',
|
||||
workHoursCost: '',
|
||||
totalCost: 0
|
||||
});
|
||||
this.setData({
|
||||
repairDetailList: tmpArr
|
||||
});
|
||||
},
|
||||
changeOfferVal(e: any) {
|
||||
let tmpArr = this.data.repairDetailList;
|
||||
let index = e.currentTarget.dataset.index;
|
||||
let { key, fixed } = e.currentTarget.dataset;
|
||||
if (key != 'repairContent') {
|
||||
if (e.detail.value > 99999999) {
|
||||
wx.showToast({
|
||||
title: '输入值不能大于99999999',
|
||||
icon: 'none'
|
||||
});
|
||||
e.detail.value = 99999999;
|
||||
} else if (e.detail.value < 0) {
|
||||
wx.showToast({
|
||||
title: '输入值不能小于0',
|
||||
icon: 'none'
|
||||
});
|
||||
e.detail.value = 0;
|
||||
}
|
||||
tmpArr[index][key] = Number(Number(e.detail.value).toFixed(fixed));
|
||||
} else tmpArr[index][key] = e.detail.value;
|
||||
this.setData({
|
||||
repairDetailList: tmpArr
|
||||
});
|
||||
if (key == 'repairContent') {
|
||||
this.checkString(tmpArr[index][key]);
|
||||
// 保养内容不用计算
|
||||
return;
|
||||
}
|
||||
// 调用计算总金额
|
||||
this.calculateTotal();
|
||||
},
|
||||
// 校验字符串
|
||||
checkString(str: string) {
|
||||
let res = true;
|
||||
const spaceRegex = new RegExp(/\s+/g);
|
||||
if (str && spaceRegex.test(str)) {
|
||||
wx.showToast({
|
||||
title: '保养内容不支持含有空格',
|
||||
icon: 'none'
|
||||
});
|
||||
res = false;
|
||||
}
|
||||
|
||||
const regex = /['"{};<>!@#$%^&*|\\]/;
|
||||
if (str && regex.test(str)) {
|
||||
wx.showToast({
|
||||
title: '保养内容不支持特殊字符',
|
||||
icon: 'none'
|
||||
});
|
||||
res = false;
|
||||
}
|
||||
const tooLong = str.length > 100;
|
||||
if (str && tooLong) {
|
||||
wx.showToast({
|
||||
title: '保养内容输入长度不得超过100个字符',
|
||||
icon: 'none'
|
||||
});
|
||||
res = false;
|
||||
}
|
||||
return res;
|
||||
},
|
||||
changeNum(e: any) {
|
||||
let tmpArr = this.data.repairDetailList;
|
||||
let index = e.currentTarget.dataset.index;
|
||||
if (tmpArr[index].quantity == '') {
|
||||
tmpArr[index].quantity = 0;
|
||||
}
|
||||
if (e.currentTarget.dataset.type == 'up') {
|
||||
tmpArr[index].quantity += 1;
|
||||
tmpArr[index].quantity = Number(
|
||||
Number(tmpArr[index].quantity).toFixed(0)
|
||||
);
|
||||
} else {
|
||||
if (tmpArr[index].quantity == 0) {
|
||||
wx.showToast({
|
||||
title: '数量不能为负数',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
tmpArr[index].quantity -= 1;
|
||||
tmpArr[index].quantity = Number(
|
||||
Number(tmpArr[index].quantity).toFixed(0)
|
||||
);
|
||||
}
|
||||
this.setData({
|
||||
repairDetailList: tmpArr
|
||||
});
|
||||
// 调用计算总金额
|
||||
this.calculateTotal();
|
||||
},
|
||||
delOffer(e: any) {
|
||||
let tmpArr = this.data.repairDetailList.filter(
|
||||
(x: any, i: number) => i != e.currentTarget.dataset.index
|
||||
);
|
||||
this.setData({
|
||||
repairDetailList: tmpArr
|
||||
});
|
||||
// 调用计算总金额
|
||||
this.calculateTotal();
|
||||
},
|
||||
calculateTotal() {
|
||||
let tmpArr = this.data.repairDetailList;
|
||||
let materialCost = 0;
|
||||
let totalWorkHours = 0;
|
||||
let totalWorkHoursCost = 0;
|
||||
let totaCost = 0;
|
||||
tmpArr.forEach((item: any) => {
|
||||
let quantity = item.quantity ? Number(item.quantity) : 0;
|
||||
let unitPrice = item.unitPrice ? Number(item.unitPrice) : 0;
|
||||
let workHours = item.workHours ? Number(item.workHours) : 0;
|
||||
let workHoursCost = item.workHoursCost ? Number(item.workHoursCost) : 0;
|
||||
item.totalCost = Number(
|
||||
(quantity * unitPrice + workHours * workHoursCost).toFixed(2)
|
||||
);
|
||||
materialCost += Number((quantity * unitPrice).toFixed(2));
|
||||
totalWorkHours += workHours;
|
||||
totalWorkHoursCost += Number((workHours * workHoursCost).toFixed(2));
|
||||
totaCost += item.totalCost;
|
||||
});
|
||||
this.setData({
|
||||
repairDetailList: tmpArr,
|
||||
materialCost: materialCost,
|
||||
totalWorkHours: totalWorkHours,
|
||||
totalWorkHoursCost: totalWorkHoursCost,
|
||||
totaCost: totaCost
|
||||
});
|
||||
},
|
||||
// 明细相关值修改-------------------
|
||||
getMarker(e: any) {
|
||||
this.setData({
|
||||
offerContent: e.detail.value
|
||||
});
|
||||
},
|
||||
// 提交报价
|
||||
bindSend() {
|
||||
// 校验是否新增了保养明细
|
||||
if (this.data.repairDetailList.length == 0) {
|
||||
wx.showToast({
|
||||
title: '请先新建保养明细',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 校验保养明细
|
||||
let res = true;
|
||||
let result = true;
|
||||
this.data.repairDetailList.forEach((item: any) => {
|
||||
let key = Object.keys(item);
|
||||
key.forEach(el => {
|
||||
if (item[el] === '') res = false;
|
||||
if (el == 'repairContent') {
|
||||
let check = this.checkString(item[el]);
|
||||
if (!check) result = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
if (!res) {
|
||||
wx.showToast({
|
||||
title: '请完成保养明细的填写',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 保养内容不符合校验
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
if (!this.data.offerContent) {
|
||||
wx.showToast({
|
||||
title: '请输入内容说明',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 单据附件数据
|
||||
let fileList = JSON.parse(
|
||||
JSON.stringify(this.data.attachmentUpkeepList)
|
||||
) as any;
|
||||
let beforeFileList = JSON.parse(
|
||||
JSON.stringify(this.data.beforeUpkeepImgUrl)
|
||||
) as any;
|
||||
// 如何有回显的附件且未删除
|
||||
if (this.data.echoFile) {
|
||||
this.data.echoFile.forEach((item: any) => {
|
||||
fileList.push(item);
|
||||
});
|
||||
}
|
||||
if (this.data.echoBeforeFile) {
|
||||
this.data.echoBeforeFile.forEach((item: any) => {
|
||||
beforeFileList.push(item);
|
||||
});
|
||||
}
|
||||
if (beforeFileList.length > 0) {
|
||||
beforeFileList = beforeFileList.join(',');
|
||||
} else beforeFileList = '';
|
||||
if (beforeFileList == 0) {
|
||||
wx.showToast({
|
||||
title: '请上传保养前图片',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (fileList == 0) {
|
||||
wx.showToast({
|
||||
title: '请上传单据附件',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
let params = {
|
||||
id: this.data.upkeepObject.id, //id
|
||||
flowStatus: 3, //当前流程状态
|
||||
checkFlag: 1, //审核状态 1-》通过, 2-》不通过
|
||||
upkeepBill: {},
|
||||
upkeepAssign: {},
|
||||
upkeepOffer: {
|
||||
id: null,
|
||||
repairDetailList: this.data.repairDetailList,
|
||||
materialCost: this.data.materialCost, //总计材料费
|
||||
totalWorkHours: this.data.totalWorkHours, //总计工时
|
||||
totalWorkHoursCost: this.data.totalWorkHoursCost, //工时费用总计
|
||||
totaCost: this.data.totaCost, //总计
|
||||
offerContent: this.data.offerContent, //内容说明
|
||||
beforeUpkeepImgUrl: beforeFileList, // 维修前图片
|
||||
attachmentUpkeepList: fileList // 单据附件
|
||||
},
|
||||
currentUpkeepCheck: {}
|
||||
};
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
});
|
||||
postAction('api/vehicles/upkeepBill/submitUpkeepObject', params)
|
||||
.then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: '派单成功',
|
||||
icon: 'none'
|
||||
});
|
||||
wx.setStorageSync('message', {
|
||||
upkeepOffer: this.data.upkeepObject.upkeepBill.orderNo,
|
||||
plateNumber: this.data.upkeepObject.upkeepBill.plateNumber,
|
||||
price: this.data.totaCost,
|
||||
id: this.data.upkeepObject.id,
|
||||
flowStatus: 3
|
||||
});
|
||||
wx.redirectTo({
|
||||
url: '../message/message',
|
||||
fail: e => {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: err.message,
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
},
|
||||
returnPicOne(e: any) {
|
||||
this.setData({
|
||||
attachmentUpkeepList: e.detail.photoList
|
||||
});
|
||||
},
|
||||
// 获取图片上传后的数据 维修前
|
||||
returnPicTwo(e: any) {
|
||||
let list = [] as any;
|
||||
e.detail.photoList.forEach((item: any) => {
|
||||
list.push(item.fileUrl);
|
||||
});
|
||||
this.setData({
|
||||
beforeUpkeepImgUrl: list
|
||||
});
|
||||
},
|
||||
// 删除回显图片
|
||||
delImg(e: any) {
|
||||
let that = this;
|
||||
let { index, fieldname } = e.currentTarget.dataset;
|
||||
let { echoFile, echoBeforeFile } = this.data;
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除当前照片',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
// 删除单据附件回显
|
||||
if (fieldname == 'echoFile') {
|
||||
echoFile.splice(index, 1);
|
||||
that.setData({
|
||||
echoFile: echoFile
|
||||
});
|
||||
}
|
||||
// 删除维修前回显
|
||||
else if (fieldname == 'echoBeforeFile') {
|
||||
echoBeforeFile.splice(index, 1);
|
||||
that.setData({
|
||||
echoBeforeFile: echoBeforeFile
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
getInf() {
|
||||
// 获取信息
|
||||
let info = wx.getStorageSync('upkeepObject');
|
||||
wx.removeStorage({ key: 'upkeepObject' });
|
||||
this.setData({
|
||||
upkeepObject: info
|
||||
});
|
||||
},
|
||||
// 获取报修分类
|
||||
getRepairClass() {
|
||||
getAction('api/vehicles/repair/getRepairClass')
|
||||
.then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
let data = [] as any;
|
||||
res.result.forEach((el: any) => {
|
||||
el.value = el.value;
|
||||
el.text = el.text;
|
||||
});
|
||||
data = res.result;
|
||||
this.setData({
|
||||
classifyOptions: data,
|
||||
filterClassifyOptions: data
|
||||
});
|
||||
// 如果是审核不通过的数据,需要回显
|
||||
// 需要等待保养分类的数据出来
|
||||
if (this.data.upkeepObject.upkeepOffer) {
|
||||
this.setData({
|
||||
repairDetailList:
|
||||
this.data.upkeepObject.upkeepOffer.repairDetailList,
|
||||
materialCost: this.data.upkeepObject.upkeepOffer.materialCost, //总计材料费
|
||||
totalWorkHours: this.data.upkeepObject.upkeepOffer.totalWorkHours, //总计工时
|
||||
totalWorkHoursCost:
|
||||
this.data.upkeepObject.upkeepOffer.totalWorkHoursCost, //工时费用总计
|
||||
totaCost: this.data.upkeepObject.upkeepOffer.totaCost, //总计
|
||||
offerContent: this.data.upkeepObject.upkeepOffer.offerContent, //内容说明
|
||||
echoBeforeFile:
|
||||
this.data.upkeepObject.upkeepOffer.beforeUpkeepImgUrl, // 回显附件
|
||||
echoFile: this.data.upkeepObject.upkeepOffer.attachmentUpkeepList // 回显附件
|
||||
});
|
||||
}
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
wx.showToast({
|
||||
title: err.message,
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
},
|
||||
// 展示选择框
|
||||
pickerChange(event: any) {
|
||||
//下拉框切换是否展示
|
||||
let { fieldname, index } = event.currentTarget.dataset;
|
||||
let data: any = { ...this.data };
|
||||
data[fieldname] = true;
|
||||
this.setData(data);
|
||||
this.setData({
|
||||
currentIndex: index
|
||||
});
|
||||
},
|
||||
// 隐藏展示框
|
||||
hidePicker() {
|
||||
this.setData({
|
||||
classifyShow: false
|
||||
});
|
||||
},
|
||||
// 选择器点击确认
|
||||
pickerConfirm(event: any) {
|
||||
let { fieldname } = event.currentTarget.dataset;
|
||||
let detail = event.detail;
|
||||
let data = this.data.repairDetailList;
|
||||
let index = this.data.currentIndex;
|
||||
if (index != null) {
|
||||
data[index].repairClass = detail.value.value;
|
||||
data[index].repairClass_dictText = detail.value.text;
|
||||
// 选择报修分类
|
||||
if (fieldname == 'classify') {
|
||||
this.setData({
|
||||
repairDetailList: data
|
||||
});
|
||||
}
|
||||
}
|
||||
this.hidePicker();
|
||||
},
|
||||
// 清空数据
|
||||
resetData(event: any) {
|
||||
let { fieldname, index } = event.currentTarget.dataset;
|
||||
let data = this.data.repairDetailList;
|
||||
if (fieldname == 'repairContent') {
|
||||
data[index].repairContent = '';
|
||||
this.setData({
|
||||
repairDetailList: data
|
||||
});
|
||||
}
|
||||
},
|
||||
// 图片预览
|
||||
showImage(event: any) {
|
||||
let { index, image } = event.currentTarget.dataset;
|
||||
let list = [] as any;
|
||||
if (image == 'echoFile') {
|
||||
this.data.echoFile.forEach((item: any) => {
|
||||
list.push(item.fileUrl);
|
||||
});
|
||||
} else if (image == 'echoBeforeFile') {
|
||||
list = this.data.echoBeforeFile;
|
||||
}
|
||||
wx.previewImage({
|
||||
current: list[index | 0], // 当前显示图片的http链接 默认urls[0]
|
||||
urls: list // 需要预览的图片http链接列表
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
this.getRepairClass();
|
||||
this.getInf();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {}
|
||||
});
|
||||
@@ -0,0 +1,181 @@
|
||||
<!--pages/vehicleMaintenance/operation/offer/offer.wxml-->
|
||||
<view class="container">
|
||||
<view class="content-box">
|
||||
<view class="content">
|
||||
<view class="top">
|
||||
<view class="left">
|
||||
<view class="line"></view>
|
||||
<view class="title require">保养明细 ({{repairDetailList.length}})</view>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="btn-add" catch:tap="addOffer">
|
||||
<image src="../../../../images/btn_add.png" mode="" />
|
||||
新增明细
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="offer-content">
|
||||
<view class="offer-list">
|
||||
<view class="offer-item" wx:if="{{showMore}}" wx:for="{{repairDetailList}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
||||
<view class="row">
|
||||
<view class="label">保养分类</view>
|
||||
<view class="val">
|
||||
<view class="project-select" data-fieldname="classifyShow" data-index="{{index}}" catch:tap="pickerChange">
|
||||
<view class="picker">
|
||||
<view style="color: #aaa;font-size: 14px;" wx:if="{{!item.repairClass}}">请选择保养分类</view>
|
||||
<view style="font-size: 14px;" wx:else>{{item.repairClass_dictText}}</view>
|
||||
<view class="arrow"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">保养内容</view>
|
||||
<view class="val">
|
||||
<input type="text" placeholder="请输入" value="{{ item.repairContent }}" data-index="{{index}}" data-key="repairContent" value="{{ item.repairContent }}" data-index="{{index}}" data-key="repairContent" bindblur="changeOfferVal" />
|
||||
<image src="../../../../images/icon_delete.png" mode="" class="delete" data-fieldName="repairContent" data-index="{{index}}" catch:tap="resetData" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">数量</view>
|
||||
<view class="num-val">
|
||||
<view class="down" data-index="{{index}}" data-type="down" catch:tap="changeNum">-</view>
|
||||
<input type="digit" placeholder="请输入" value="{{ item.quantity }}" data-index="{{index}}" data-key="quantity" data-fixed="0" bindblur="changeOfferVal"/>
|
||||
<view class="up" data-index="{{index}}" data-type="up" catch:tap="changeNum">+</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">材料单价</view>
|
||||
<view class="val">
|
||||
<input type="digit" placeholder="请输入" value="{{ item.unitPrice }}" data-index="{{index}}" data-key="unitPrice" data-fixed="2" bindblur="changeOfferVal" />
|
||||
<view class="unit">元</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">工时</view>
|
||||
<view class="val">
|
||||
<input type="digit" placeholder="请输入" value="{{ item.workHours }}" data-index="{{index}}" data-key="workHours" data-fixed="2" bindblur="changeOfferVal" />
|
||||
<view class="unit">小时</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="label">工时单价</view>
|
||||
<view class="val">
|
||||
<input type="digit" max='100' placeholder="请输入" value="{{ item.workHoursCost}}" data-index="{{index}}" data-fixed="2" data-key="workHoursCost" bindblur="changeOfferVal" />
|
||||
<view class="unit">元</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="total-row">
|
||||
<view class="total">费用小记 <view class="num">{{ item.totalCost }}</view> 元</view>
|
||||
<view class="btn-del" data-index="{{index}}" catch:tap="delOffer">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
<van-popup show="{{classifyShow}}" position="bottom" bind:close="hidePicker">
|
||||
<van-picker data-fieldname="classify" show-toolbar columns="{{filterClassifyOptions}}" bind:confirm="pickerConfirm" bind:cancel="hidePicker">
|
||||
</van-picker>
|
||||
</van-popup>
|
||||
</view>
|
||||
<view class="btn-hide" wx:if="{{showMore}}" catch:tap="showDetail">
|
||||
<image src="../../../../images/icon_up.png" mode="" /> 收起明细
|
||||
</view>
|
||||
<view class="btn-show" wx:if="{{!showMore}}" catch:tap="showDetail">
|
||||
<image src="../../../../images/icon_down.png" mode="" /> 展开明细
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="top">
|
||||
<view class="left">
|
||||
<view class="line"></view>
|
||||
<view class="title">保养费用总计</view>
|
||||
</view>
|
||||
<view class="right"></view>
|
||||
</view>
|
||||
<view class="row" style="margin: 0 8px 8px 16px;">
|
||||
<view class="label">材料费</view>
|
||||
<view class="val">
|
||||
<input type="digit" placeholder="自动计算" value="{{ materialCost}}" disabled="true" />
|
||||
<view class="unit">元</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row" style="margin: 0 8px 8px 16px;">
|
||||
<view class="label">工时</view>
|
||||
<view class="val">
|
||||
<input type="digit" placeholder="自动计算" value="{{ totalWorkHours}}" disabled="true" />
|
||||
<view class="unit">小时</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row" style="margin: 0 8px 8px 16px;">
|
||||
<view class="label">工时费用</view>
|
||||
<view class="val">
|
||||
<input type="digit" placeholder="自动计算" value="{{ totalWorkHoursCost }}" disabled="true" />
|
||||
<view class="unit">元</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row" style="margin: 0 8px 0 16px;">
|
||||
<view class="label">保养报价</view>
|
||||
<view class="val">
|
||||
<input type="digit" placeholder="自动计算" value="{{ totaCost }}" disabled="true" />
|
||||
<view class="unit">元</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="top">
|
||||
<view class="left">
|
||||
<view class="line"></view>
|
||||
<view class="title require">内容说明</view>
|
||||
</view>
|
||||
<view class="right"></view>
|
||||
</view>
|
||||
<view class="marker">
|
||||
<textarea type="text" maxlength="100" placeholder="最大输入长度为100" style="height: 96rpx;width: 100%;" placeholder-style="color: #949CB5; font-size: 28rpx; font-weight: 400;" value="{{offerContent}}" bindblur="getMarker" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="top">
|
||||
<view class="left">
|
||||
<view class="line"></view>
|
||||
<view class="title require">保养前(最大上传10张)</view>
|
||||
</view>
|
||||
<view class="right"></view>
|
||||
</view>
|
||||
<view wx:if="{{echoBeforeFile}}" class="echoFile">
|
||||
<view class="photo-list" wx:for="{{echoBeforeFile}}" data-index="{{index}}" wx:key="index">
|
||||
<image src="{{item}}" mode="" data-index="{{index}}" data-image="echoBeforeFile" catch:tap="showImage" />
|
||||
<view class="del" catchtap="delImg" data-index="{{index}}" data-fieldName="echoBeforeFile">
|
||||
<image src="../../../../images/btn_del.png" mode="" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="upload" style="margin-left: 8px;">
|
||||
<g-upload id="g-upload" maxLength="{{10 - (echoBeforeFile ? echoBeforeFile.length : 0)}}" uploadUrl="{{uploadUrl}}" bind:returnPic="returnPicTwo"></g-upload>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="top">
|
||||
<view class="left">
|
||||
<view class="line"></view>
|
||||
<view class="title require">单据附件(最大上传10张)</view>
|
||||
</view>
|
||||
<view class="right"></view>
|
||||
</view>
|
||||
<view wx:if="{{echoFile}}" class="echoFile">
|
||||
<view class="photo-list" wx:for="{{echoFile}}" data-index="{{index}}" wx:key="index">
|
||||
<image src="{{item.fileUrl}}" mode="" data-index="{{index}}" data-image="echoFile" catch:tap="showImage" />
|
||||
<view class="del" catchtap="delImg" data-index="{{index}}" data-fieldName="echoFile">
|
||||
<image src="../../../../images/btn_del.png" mode="" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="upload" style="margin-left: 8px;">
|
||||
<g-upload id="g-upload" maxLength="{{10 - (echoFile ? echoFile.length : 0)}}" uploadUrl="{{uploadUrl}}" bind:returnPic="returnPicOne"></g-upload>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom">
|
||||
<view class="btn-box">
|
||||
<view class="btn" catch:tap="bindSend">提交报价</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
Reference in New Issue
Block a user