Files
gxtyzx-admin/src/views/think/thinkOrder/components/thinkOrderEdit.vue
T
2024-08-23 22:28:24 +08:00

466 lines
14 KiB
Vue

<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑' : '添加'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="订单号" name="orderNum">
<a-input
allow-clear
placeholder="请输入订单号"
v-model:value="form.orderNum"
/>
</a-form-item>
<a-form-item label="微信支付订单号" name="wechatOrder">
<a-input
allow-clear
placeholder="请输入微信支付订单号"
v-model:value="form.wechatOrder"
/>
</a-form-item>
<a-form-item label="微信退款订单号" name="refundOrder">
<a-input
allow-clear
placeholder="请输入微信退款订单号"
v-model:value="form.refundOrder"
/>
</a-form-item>
<a-form-item label="场馆id用于权限判断" name="sid">
<a-input
allow-clear
placeholder="请输入场馆id用于权限判断"
v-model:value="form.sid"
/>
</a-form-item>
<a-form-item label="用户id" name="uid">
<a-input
allow-clear
placeholder="请输入用户id"
v-model:value="form.uid"
/>
</a-form-item>
<a-form-item label="使用的优惠券id" name="cid">
<a-input
allow-clear
placeholder="请输入使用的优惠券id"
v-model:value="form.cid"
/>
</a-form-item>
<a-form-item label="使用的会员卡id" name="vid">
<a-input
allow-clear
placeholder="请输入使用的会员卡id"
v-model:value="form.vid"
/>
</a-form-item>
<a-form-item label="关联管理员id" name="aid">
<a-input
allow-clear
placeholder="请输入关联管理员id"
v-model:value="form.aid"
/>
</a-form-item>
<a-form-item label="核销管理员id" name="adminId">
<a-input
allow-clear
placeholder="请输入核销管理员id"
v-model:value="form.adminId"
/>
</a-form-item>
<a-form-item label="IC卡号" name="code">
<a-input
allow-clear
placeholder="请输入IC卡号"
v-model:value="form.code"
/>
</a-form-item>
<a-form-item label="真实姓名" name="name">
<a-input
allow-clear
placeholder="请输入真实姓名"
v-model:value="form.name"
/>
</a-form-item>
<a-form-item label="手机号码" name="phone">
<a-input
allow-clear
placeholder="请输入手机号码"
v-model:value="form.phone"
/>
</a-form-item>
<a-form-item label="订单总额" name="totalPrice">
<a-input
allow-clear
placeholder="请输入订单总额"
v-model:value="form.totalPrice"
/>
</a-form-item>
<a-form-item
label="减少的金额,使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格"
name="reducePrice"
>
<a-input
allow-clear
placeholder="请输入减少的金额,使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格"
v-model:value="form.reducePrice"
/>
</a-form-item>
<a-form-item label="实际付款" name="payPrice">
<a-input
allow-clear
placeholder="请输入实际付款"
v-model:value="form.payPrice"
/>
</a-form-item>
<a-form-item label="用于统计" name="price">
<a-input
allow-clear
placeholder="请输入用于统计"
v-model:value="form.price"
/>
</a-form-item>
<a-form-item label="价钱,用于积分赠送" name="money">
<a-input
allow-clear
placeholder="请输入价钱,用于积分赠送"
v-model:value="form.money"
/>
</a-form-item>
<a-form-item label="退款金额" name="refundMoney">
<a-input
allow-clear
placeholder="请输入退款金额"
v-model:value="form.refundMoney"
/>
</a-form-item>
<a-form-item label="教练价格" name="coachPrice">
<a-input
allow-clear
placeholder="请输入教练价格"
v-model:value="form.coachPrice"
/>
</a-form-item>
<a-form-item label="教练id" name="coachId">
<a-input
allow-clear
placeholder="请输入教练id"
v-model:value="form.coachId"
/>
</a-form-item>
<a-form-item
label="1微信支付,2积分,3支付宝,4现金,5POS机,6VIP月卡,7VIP年卡,8VIP次卡,9IC月卡,10IC年卡,11IC次卡,12免费,13VIP充值卡,14IC充值卡,15积分支付,16VIP季卡,17IC季卡"
name="payType"
>
<a-input
allow-clear
placeholder="请输入1微信支付,2积分,3支付宝,4现金,5POS机,6VIP月卡,7VIP年卡,8VIP次卡,9IC月卡,10IC年卡,11IC次卡,12免费,13VIP充值卡,14IC充值卡,15积分支付,16VIP季卡,17IC季卡"
v-model:value="form.payType"
/>
</a-form-item>
<a-form-item label="1已付款,2未付款" name="payStatus">
<a-input
allow-clear
placeholder="请输入1已付款,2未付款"
v-model:value="form.payStatus"
/>
</a-form-item>
<a-form-item
label="1已完成,2未使用,3已取消,4退款申请中,5退款被拒绝,6退款成功,7客户端申请退款"
name="orderStatus"
>
<a-input
allow-clear
placeholder="请输入1已完成,2未使用,3已取消,4退款申请中,5退款被拒绝,6退款成功,7客户端申请退款"
v-model:value="form.orderStatus"
/>
</a-form-item>
<a-form-item
label="优惠类型:0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡,5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡"
name="type"
>
<a-input
allow-clear
placeholder="请输入优惠类型:0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡,5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡"
v-model:value="form.type"
/>
</a-form-item>
<a-form-item
label="二维码地址,保存订单号,支付成功后才生成"
name="qrcode"
>
<a-input
allow-clear
placeholder="请输入二维码地址,保存订单号,支付成功后才生成"
v-model:value="form.qrcode"
/>
</a-form-item>
<a-form-item label="优惠说明" name="desc2">
<a-input
allow-clear
placeholder="请输入优惠说明"
v-model:value="form.desc2"
/>
</a-form-item>
<a-form-item label="vip月卡年卡、ic月卡年卡回退次数" name="returnNum">
<a-input
allow-clear
placeholder="请输入vip月卡年卡、ic月卡年卡回退次数"
v-model:value="form.returnNum"
/>
</a-form-item>
<a-form-item label="vip充值回退金额" name="returnMoney">
<a-input
allow-clear
placeholder="请输入vip充值回退金额"
v-model:value="form.returnMoney"
/>
</a-form-item>
<a-form-item label="预约详情开始时间数组" name="startTime">
<a-input
allow-clear
placeholder="请输入预约详情开始时间数组"
v-model:value="form.startTime"
/>
</a-form-item>
<a-form-item
label="是否已开具发票:1已开发票,2未开发票,3不能开具发票"
name="isInvoice"
>
<a-input
allow-clear
placeholder="请输入是否已开具发票:1已开发票,2未开发票,3不能开具发票"
v-model:value="form.isInvoice"
/>
</a-form-item>
<a-form-item label="" name="updateTime">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.updateTime"
/>
</a-form-item>
<a-form-item label="付款时间" name="payTime">
<a-input
allow-clear
placeholder="请输入付款时间"
v-model:value="form.payTime"
/>
</a-form-item>
<a-form-item label="退款时间" name="refundTime">
<a-input
allow-clear
placeholder="请输入退款时间"
v-model:value="form.refundTime"
/>
</a-form-item>
<a-form-item label="申请退款时间" name="refundApplyTime">
<a-input
allow-clear
placeholder="请输入申请退款时间"
v-model:value="form.refundApplyTime"
/>
</a-form-item>
<a-form-item
label="对账情况:1=已对账;2=未对账;3=已对账,金额对不上;4=未查询到该订单"
name="checkBill"
>
<a-input
allow-clear
placeholder="请输入对账情况:1=已对账;2=未对账;3=已对账,金额对不上;4=未查询到该订单"
v-model:value="form.checkBill"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addThinkOrder, updateThinkOrder } from '@/api/think/thinkOrder';
import { ThinkOrder } from '@/api/think/thinkOrder/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ThinkOrder | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<ThinkOrder>({
id: undefined,
orderNum: undefined,
wechatOrder: undefined,
refundOrder: undefined,
sid: undefined,
uid: undefined,
cid: undefined,
vid: undefined,
aid: undefined,
adminId: undefined,
code: undefined,
name: undefined,
phone: undefined,
totalPrice: undefined,
reducePrice: undefined,
payPrice: undefined,
price: undefined,
money: undefined,
refundMoney: undefined,
coachPrice: undefined,
coachId: undefined,
payType: undefined,
payStatus: undefined,
orderStatus: undefined,
type: undefined,
qrcode: undefined,
desc2: undefined,
returnNum: undefined,
returnMoney: undefined,
startTime: undefined,
isInvoice: undefined,
createTime: undefined,
updateTime: undefined,
payTime: undefined,
refundTime: undefined,
refundApplyTime: undefined,
checkBill: undefined
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
name: [
{
required: true,
type: 'string',
message: '请填写名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateThinkOrder : addThinkOrder;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
});
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>