|
|
@@ -22,6 +22,7 @@
|
|
|
<el-form-item label="用户姓名:" prop="customer_id">
|
|
|
<el-select clearable
|
|
|
v-model="ruleForm.customer_id"
|
|
|
+ :disabled="pageType==='init'"
|
|
|
filterable
|
|
|
placeholder="请输入用户姓名"
|
|
|
style="width: 240px"
|
|
|
@@ -39,7 +40,7 @@
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="20">
|
|
|
<el-form-item label="房间:" prop="room_no">
|
|
|
- <el-input v-model="ruleForm.room_no" style="width: 240px" placeholder="房间"/>
|
|
|
+ <el-input v-model="ruleForm.room_no" style="width: 240px" placeholder="房间" :disabled="pageType==='init'" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -97,8 +98,8 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="数量" min-width="125">
|
|
|
<template #default="scope">
|
|
|
- <el-input-number
|
|
|
- v-model="scope.row.num"
|
|
|
+ <el-input-number :disabled="pageType==='init'"
|
|
|
+ v-model="scope.row.num"
|
|
|
:min="0"
|
|
|
:max="100"
|
|
|
@change="handleChange(scope.row)"
|
|
|
@@ -131,7 +132,7 @@
|
|
|
元
|
|
|
</el-form-item>
|
|
|
<el-form-item label="折扣:" prop="discount">
|
|
|
- <el-input-number v-model="discount" :min="0" :precision="2" :step="0.05" :max="1" size="large">
|
|
|
+ <el-input-number :disabled="pageType==='init'" v-model="discount" :min="0" :precision="2" :step="0.05" :max="1" size="large">
|
|
|
</el-input-number>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="折扣后:" prop="discountedAmount">
|
|
|
@@ -144,11 +145,11 @@
|
|
|
元
|
|
|
</el-form-item>
|
|
|
<el-form-item label="实际支付:" prop="finalPayment">
|
|
|
- <el-input-number v-model="finalPayment" :precision="2" :min="0" size="large">
|
|
|
+ <el-input-number v-model="finalPayment" :precision="2" :min="0" size="large" :disabled="pageType==='init'">
|
|
|
</el-input-number>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="付款方式:" prop="paymentMethod">
|
|
|
- <el-select clearable
|
|
|
+ <el-select clearable :disabled="pageType==='init'"
|
|
|
v-model="paymentMethod"
|
|
|
filterable
|
|
|
placeholder="请选择"
|
|
|
@@ -166,34 +167,36 @@
|
|
|
|
|
|
</div>
|
|
|
<div style=" margin-top: 20px;">
|
|
|
- <div v-if="orderObj.status==0">
|
|
|
+ <div v-if="orderItem.status==null||orderItem.status==0">
|
|
|
<el-row>
|
|
|
|
|
|
<el-col :span="6" :offset="3">
|
|
|
- <el-button @click="save" style="width: 100%;" type="primary">保存</el-button>
|
|
|
+
|
|
|
+ <el-button @click="save" style="width: 100%;" :disabled="pageType==='init'" type="primary" v-if="!orderItem.id">保存</el-button>
|
|
|
+ <el-button @click="save" style="width: 100%;" :disabled="pageType==='init'" type="primary" v-else>修改</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="6" :offset="6">
|
|
|
- <el-button @click="markAsPaid" style="width: 100%;" type="primary">确认收款</el-button>
|
|
|
+ <el-button @click="markAsPaid" :disabled="pageType==='init'" style="width: 100%;" type="primary" v-if="orderItem.payment_type&&orderItem.payment_type!=='balance'">确认收款</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
<div v-else>
|
|
|
<el-row>
|
|
|
<el-col :span="4" :offset="2">
|
|
|
- <el-button @click="save" style="width: 100%;" type="primary">保存</el-button>
|
|
|
+ <el-button @click="save" style="width: 100%;" :disabled="pageType==='init'" type="primary">保存</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="4" :offset="4">
|
|
|
- <el-button @click="markAsPaid" style="width: 100%;" disabled type="primary">已收款</el-button>
|
|
|
+ <el-button @click="markAsPaid" style="width: 100%;" :disabled="pageType==='init'" type="primary">已收款</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="4" :offset="4">
|
|
|
- <el-button @click="refund" style="width: 100%;" type="danger">退款</el-button>
|
|
|
+ <el-button @click="refund" style="width: 100%;" :disabled="pageType==='init'" type="danger">退款</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div style=" margin-top: 20px;">
|
|
|
- <div style="margin: 0 auto ;width: 200px;height: 200px;" v-if="orderObj.id!=0">
|
|
|
- <el-image style="width: 200px;height: 200px;" :src="404"/>
|
|
|
+ <div style="margin: 0 auto ;width: 200px;height: 200px;" v-if="pageType!=='init' &&orderItem.payment_type==='balance' && paymentMethod==='1'">
|
|
|
+ <el-image style="width: 200px;height: 200px;" :src="erCodeImg"/>
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-col>
|
|
|
@@ -212,7 +215,13 @@ import {listApi as dictApi} from "@/plugins/api/system/dict";
|
|
|
import {listApi} from "@/plugins/api/customer/manage/pool";
|
|
|
import ProductList from "@/views/orders/components/ProductList.vue";
|
|
|
import {useCounterStore} from "@/stores/counter";
|
|
|
-import {orderExpenseAddApi} from "@/plugins/api/shopping/order";
|
|
|
+import {
|
|
|
+ getQRCode,
|
|
|
+ orderExpenseAddApi,
|
|
|
+ orderExpenseDelApi,
|
|
|
+ orderExpenseEditApi,
|
|
|
+ orderExpensePayApi
|
|
|
+} from "@/plugins/api/shopping/order";
|
|
|
|
|
|
const store = useCounterStore();
|
|
|
|
|
|
@@ -256,7 +265,7 @@ const handleClick = async (tab) => {
|
|
|
addDialogRef = addDialogRefThird.value;
|
|
|
}
|
|
|
if (addDialogRef) {
|
|
|
- addDialogRef.initFun(tab);
|
|
|
+ addDialogRef.initFun(tab,pageType.value);
|
|
|
}
|
|
|
}
|
|
|
let itemList = ref([]);
|
|
|
@@ -349,6 +358,27 @@ const paymentOptions = [
|
|
|
const paymentMethod = ref('');
|
|
|
const emit = defineEmits([ 'refreshTable']);
|
|
|
const orderItem = ref({});
|
|
|
+const erCodeImg = ref("");
|
|
|
+function getWcQrCode() {
|
|
|
+ erCodeImg.value=""
|
|
|
+ const pData = {
|
|
|
+ path: '/subPages/storeConsumption/storeConsumption?orderNo=' + orderItem.value.order_no,
|
|
|
+ type: 'file'
|
|
|
+ // ['api-name']: 'wxapp',
|
|
|
+ // ['api-token']: uni.getStorageSync(`token`)
|
|
|
+ }
|
|
|
+ console.log(pData)
|
|
|
+ getQRCode(pData).then(res => {
|
|
|
+ erCodeImg.value = res.url
|
|
|
+ })
|
|
|
+}
|
|
|
+function orderExpenseDel() {
|
|
|
+ orderExpenseDelApi({order_no:orderItem.value.order_no})
|
|
|
+ .then((res) => {
|
|
|
+ ElMessage.success("退款成功");
|
|
|
+ emit('refreshTable');
|
|
|
+ });
|
|
|
+}
|
|
|
function save() {
|
|
|
if (tableData.value.length<1){
|
|
|
ElMessage.error('清先添加商品');
|
|
|
@@ -381,11 +411,22 @@ function save() {
|
|
|
"code":item.code,
|
|
|
"spec":item.selectSuitDisplay})
|
|
|
})
|
|
|
- orderExpenseAddApi(obj).then((data) => {
|
|
|
- orderItem.value=data
|
|
|
- ElMessage.success("订单创建成功");
|
|
|
- emit('refreshTable');
|
|
|
- });
|
|
|
+ if (orderItem.value.id){
|
|
|
+ obj.id=orderItem.value.id
|
|
|
+ orderExpenseEditApi(obj).then((data) => {
|
|
|
+ orderItem.value=data
|
|
|
+ ElMessage.success("订单修改成功");
|
|
|
+ getWcQrCode();
|
|
|
+ emit('refreshTable');
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ orderExpenseAddApi(obj).then((data) => {
|
|
|
+ orderItem.value=data
|
|
|
+ ElMessage.success("订单创建成功");
|
|
|
+ getWcQrCode();
|
|
|
+ emit('refreshTable');
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
// 验证失败
|
|
|
@@ -396,11 +437,19 @@ function save() {
|
|
|
}
|
|
|
|
|
|
function markAsPaid() {
|
|
|
+ if (!(orderItem.value.payment_type==='balance' && ruleForm.value.paymentMethod==='1')){
|
|
|
+ ElMessage.error('请先点击修改订单');
|
|
|
+ return
|
|
|
+ }
|
|
|
// 标记为已收款逻辑
|
|
|
+ orderExpensePayApi({order_no:orderItem.value.order_no,payment_type:orderItem.value.payment_type}).then((data) => {
|
|
|
+ ElMessage.success("确认成功");
|
|
|
+ emit('refreshTable');
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function refund() {
|
|
|
- // 退款逻辑
|
|
|
+ orderExpenseDel()
|
|
|
}
|
|
|
|
|
|
function handleClose(done) {
|
|
|
@@ -421,11 +470,12 @@ function handleClose(done) {
|
|
|
|
|
|
let title = ref("");
|
|
|
let ruleFormRef = ref(null);
|
|
|
+let pageType = ref(null);
|
|
|
|
|
|
-function initFun(type, row) {
|
|
|
|
|
|
+function initFun(type, row) {
|
|
|
+ erCodeImg.value=""
|
|
|
console.log(row)
|
|
|
-
|
|
|
if (ruleFormRef.value) {
|
|
|
ruleFormRef.value.resetFields();
|
|
|
}
|
|
|
@@ -441,12 +491,14 @@ function initFun(type, row) {
|
|
|
handleClick(activeName.value)
|
|
|
dialogVisible.value = true;
|
|
|
|
|
|
- if (type==="set"){
|
|
|
+ if (type==="set"|| type==="init"){
|
|
|
+ pageType.value=type
|
|
|
ruleForm.value.customer_id =row.customer_id
|
|
|
ruleForm.value.room_no =row.room_no
|
|
|
ruleForm.value.paymentMethod = row.payment_type ==="balance" ? '1': '2'
|
|
|
paymentMethod.value=ruleForm.value.paymentMethod
|
|
|
orderItem.value=row
|
|
|
+ getWcQrCode();
|
|
|
}
|
|
|
}
|
|
|
watch(orderItem, (newVal, oldVal) => {
|
|
|
@@ -478,6 +530,7 @@ watch(orderItem, (newVal, oldVal) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
function submit() {
|
|
|
if (!ruleFormRef.value) return;
|
|
|
ruleFormRef.value.validate((valid, fields) => {
|