diff --git a/src/views/order/orderDetail.vue b/src/views/order/orderDetail.vue index c81d725..5e83a3d 100644 --- a/src/views/order/orderDetail.vue +++ b/src/views/order/orderDetail.vue @@ -1,6 +1,6 @@ <template> <div> - <el-dialog title="订单信息" :visible.sync="dialogVisible" width="700px" v-if="orderDatalist"> + <el-dialog title="订单信息" :visible.sync="dialogVisible" width="1000px" v-if="orderDatalist"> <div class="description" v-loading="loading"> <div class="title">用户信息</div> <div class="acea-row"> @@ -72,14 +72,16 @@ <div class="li" style="display: flex; flex-wrap: nowrap; width: 100%; align-items: center; margin-top: 10px;" v-for="(item, index) in zdlist" :key="index"> <div style="margin-right: 20px;">状态: {{ item.repaymentStatus }}</div> - <div style="margin-right: 20px;">还款金额: {{ item.repaymentAmount }}</div> - <div class="text" style="margin-right: 8px;">还款时间:</div> - <el-date-picker v-model="item.repaymentDeadlineStr" type="date" placeholder="选择日期" - :disabled="item.repaymentStatus != '待还款'"> + <div style="margin-right: 20px;">还款金额:</div> + <el-input v-model="item.repaymentAmount" placeholder="账单金额" class="selWidth" size="small" clearable> + </el-input> + <div class="text" style="margin-right: 4px;">还款时间:</div> + <el-date-picker v-model="item.repaymentDeadlineStr" type="date" placeholder="选择日期"> </el-date-picker> - <el-button size="small" @click="changetime(item.id,item.repaymentDeadlineStr)" class="mr10" :disabled="item.repaymentStatus != '待还款'" - v-hasPermi="['admin:channel:update']">确定</el-button> + </div> + <el-button type="primary" size="small" @click="changetimes()" class="mr10" s + v-hasPermi="['admin:channel:update']" style="margin-left: 800px;">确定</el-button> <template v-if="orderDatalist.statusStr.key === 'toBeWrittenOff' && orderDatalist.systemStore"> <div class="description-term">提货码:{{ orderDatalist.verifyCode }}</div> <div class="description-term">门店名称:{{ orderDatalist.systemStore.name }}</div> @@ -149,7 +151,7 @@ import { infobyconditionApi } from '@/api/user' import { orderDetailApi, getLogisticsInfoApi, changePrice } from '@/api/order'; -import { changetime } from '@/api/marketing'; +import { changetime } from '@/api/marketing'; export default { name: 'OrderDetail', props: { @@ -173,29 +175,111 @@ export default { }, mounted() { }, methods: { - changetime(id,repaymentDeadlineStr){ - let repaymentDeadlineStrs=repaymentDeadlineStr - let date = new Date(repaymentDeadlineStrs); - let year = date.getFullYear(); - let month = (date.getMonth() + 1).toString().padStart(2, '0'); - let day = date.getDate().toString().padStart(2, '0'); - repaymentDeadlineStrs = `${year}-${month}-${day}`; - + changetimes() { + // console.log(id,'repaymentAmountrepaymentAmount'); + let totalRepaymentAmount = 0; // 初始化总额为0 + this.zdlist.forEach(item => { + // console.log(id,'repaymentAmountrepaymentAmount'); + let repaymentDeadlineStrs = item.repaymentDeadlineStr; + let date = new Date(repaymentDeadlineStrs); + let year = date.getFullYear(); + let month = (date.getMonth() + 1).toString().padStart(2, '0'); + let day = date.getDate().toString().padStart(2, '0'); + repaymentDeadlineStrs = `${year}-${month}-${day}`; + // 替换原字段值 + let repaymentAmount = parseFloat(item.repaymentAmount); + + // 计算总额 + totalRepaymentAmount += repaymentAmount; + }); + console.log(totalRepaymentAmount,'totalRepaymentAmounttotalRepaymentAmount'); setTimeout(() => { - let data = { - repaymentDeadlineStr: repaymentDeadlineStrs, - // repaymentAmount:repaymentDeadlineStrs - } - changetime(id, data).then((res) => { - // console.log("11111111111111111---------"+JSON.stringify(res)) - - if (res.code == 500) { - this.$message.error(res.msg); - } - - + if (totalRepaymentAmount != this.repaymentAmount) { + this.$confirm('此操作将会修改订单总金额, 是否继续?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + setTimeout(() => { + this.repaymentAmount=totalRepaymentAmount + this.sunchange() + this.zdlist.forEach(item => { + let data = { + repaymentDeadlineStr: item.repaymentDeadlineStr, + repaymentAmount: item.repaymentAmount + }; + console.log(data); + changetime(item.id, data).then((res) => { + if (res.code == 500) { + this.$message.error(res.msg); + } else { + this.$message.success(res.msg); + // 更新 this.zdlist + // 这里根据接口返回的数据更新 this.zdlist,例如: + // item.someField = res.someField; + } + }); + }); + }, 200); + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消修改' + }); }); - }, 200); + } else { + this.zdlist.forEach(item => { + let data = { + repaymentDeadlineStr: item.repaymentDeadlineStr, + repaymentAmount: item.repaymentAmount + }; + console.log(data); + changetime(item.id, data).then((res) => { + if (res.code == 500) { + this.$message.error(res.msg); + } else { + this.$message.success(res.msg); + // 更新 this.zdlist + // 这里根据接口返回的数据更新 this.zdlist,例如: + // item.someField = res.someField; + } + }); + }); + + } + }, 10); + + // this.$confirm('此操作将会修改订单总金额, 是否继续?', '提示', { + // confirmButtonText: '确定', + // cancelButtonText: '取消', + // type: 'warning' + // }).then(() => { + // setTimeout(() => { + // let data = { + // repaymentDeadlineStr: item.repaymentDeadlineStrs, + // repaymentAmount: item.repaymentAmount + // } + // console.log(data,); + // changetime(item.id, data).then((res) => { + // // console.log("11111111111111111---------"+JSON.stringify(res)) + + // if (res.code == 500) { + // this.$message.error(res.msg); + // } else { + // this.$message.success(res.msg); + // } + + + // }); + // }, 200); + // }).catch(() => { + // this.$message({ + // type: 'info', + // message: '已取消修改' + // }); + // }); + + }, openLogistics() { this.getOrderData(); @@ -219,34 +303,31 @@ export default { }); }, async sunchange() { - console.log(this.orderDatalist, 'this.orderDatalistthis.orderDatalist'); - if (typeof this.repaymentAmount === 'string') { - // 将字符串转换为数字 - let amount = parseFloat(this.repaymentAmount); + let newRepaymentAmount = parseFloat(this.repaymentAmount); - // 检查是否为有效数字 - if (!isNaN(amount)) { - // 将数字转换为两位小数的字符串 - this.repaymentAmount = amount.toFixed(2); - if (this.repaymentAmount != this.orderDatalist.payPrice) { - let data = { - payPrice: this.repaymentAmount, - orderNo: this.orderDatalist.orderId - } - await changePrice(data).then((res) => { - console.log(res, 'resres'); + // 检查是否为有效数字 + if (!isNaN(newRepaymentAmount)) { + // 将数字转换为两位小数的字符串 + this.repaymentAmount = newRepaymentAmount.toFixed(2); + // 检查是否需要进行接口请求 + if (this.repaymentAmount !== this.orderDatalist.payPrice) { + let data = { + payPrice: this.repaymentAmount, + orderNo: this.orderDatalist.orderId + }; - this.getDetail(this.id); - }).catch(error => { - console.error(error); // 打印捕获的错误 - }) - } - } - } - - - }, + await changePrice(data) + .then((res) => { + console.log(res, 'resres'); + this.getDetail(this.id); + }) + .catch(error => { + console.error(error); // 打印捕获的错误 + }); + } + } +}, getDetail(id) { this.id = id this.loading = true;