合并代码

This commit is contained in:
2025-04-30 15:41:00 +08:00
parent d74696fb64
commit b9413abf93
5 changed files with 222 additions and 185 deletions
+2 -1
View File
@@ -41,13 +41,14 @@ export interface ThinkVip {
prices?: string;
// 是否赠送积分:1赠送,2不赠送
isIntegral?: number;
mode?: number;
expiredTime?: string;
//
createTime?: number;
//
updateTime?: number;
// 是否有效:1是,0否
isUse?: number;
// 是否销售:1是,0否
isSale?: number;
}
+3 -2
View File
@@ -56,6 +56,7 @@
v-model:visible="showEdit"
:merchant="data"
:merchantId="categoryId"
:sid="data.id"
:data="current"
@done="reload"
/>
@@ -180,8 +181,8 @@
},
{
title: '排序',
dataIndex: 'sortNumber',
key: 'sortNumber',
dataIndex: 'sort',
key: 'sort',
align: 'center'
},
{
@@ -15,11 +15,11 @@
<span>{{ data.totalPrice }}元</span>
</a-form-item>
<a-form-item label="支付金额">
<span>{{ data.payPrice }}元</span>
<span>{{ data.price }}元</span>
</a-form-item>
<a-form-item label="退款金额">
<a-input-number placeholder="请输入退款金额" style="width: 300px" v-model:value="form.refundAmount"
:max="data.payPrice" />
:max="data.price" />
</a-form-item>
</a-form>
</ele-modal>
@@ -63,7 +63,7 @@ const updateVisible = (value: boolean) => {
};
const save = async () => {
if (!form.refundAmount) return message.error("请输入退款金额");
if (!form.refundAmount && props.data.price > 0) return message.error("请输入退款金额");
loading.value = true;
await addThinkOrderRefundLog(form);
loading.value = false;
+15 -7
View File
@@ -44,14 +44,9 @@
</template>
<template v-if="column.key === 'action'">
<a-space v-if="record.status === 1">
<ThinkSelectUsers :id="record.id" @done="changeBindCard" />
<a-divider type="vertical" />
<template v-if="record.uid">
<a-popconfirm
title="确定要解绑吗?"
@confirm="release(record)"
>
<a class="text-green-600">解绑</a>
</a-popconfirm>
<a-divider type="vertical" />
<a-popconfirm
title="确定要退卡吗?"
@confirm="remove(record)"
@@ -106,6 +101,7 @@ import type {
ThinkUsersVipParam
} from "@/api/think/thinkUsersVip/model";
import ThinkUsersVipLog from "@/views/think/thinkUsersVip/components/thinkUsersVipLog.vue";
import { ThinkUsers } from "@/api/think/thinkUsers/model";
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -391,6 +387,18 @@ const query = () => {
loading.value = true;
};
const changeBindCard = (row: ThinkUsers, id: number) => {
updateThinkUsersVip({
id,
uid: row.id,
username: row.truename ?? row.username,
phone: row.phone
}).then(() => {
message.success("操作成功");
reload();
});
};
/* 自定义行属性 */
const customRow = (record: ThinkUsersVip) => {
return {
@@ -53,6 +53,12 @@
<a-radio :value="2">不赠送</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="过期类型" name="mode">
<a-radio-group v-model:value="form.mode">
<a-radio :value="0">按下单时间计算</a-radio>
<a-radio :value="1">按固定时间</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="可选场馆" name="sid">
<ThinkSelectSiteMultiple v-model:value="sites" />
</a-form-item>
@@ -98,26 +104,32 @@
v-model:value="form.eachMoney"
/>
</a-form-item>
<a-form-item label="年限" name="term">
<a-input
allow-clear
placeholder="请输入年限"
v-model:value="form.term"
/>
</a-form-item>
<a-form-item label="月限" name="month">
<a-input
allow-clear
placeholder="请输入月限"
v-model:value="form.month"
/>
</a-form-item>
<a-form-item label="日限" name="day">
<a-input
allow-clear
placeholder="请输入日限"
v-model:value="form.day"
/>
<template v-if="form.mode === 0">
<a-form-item label="年限" name="term">
<a-input
allow-clear
placeholder="请输入年限"
v-model:value="form.term"
/>
</a-form-item>
<a-form-item label="月限" name="month">
<a-input
allow-clear
placeholder="请输入月限"
v-model:value="form.month"
/>
</a-form-item>
<a-form-item label="日限" name="day">
<a-input
allow-clear
placeholder="请输入日限"
v-model:value="form.day"
/>
</a-form-item>
</template>
<a-form-item v-else label="过期时间" name="expiredTime">
<a-date-picker v-model:value="form.expiredTime" value-format="YYYY-MM-DD"
placeholder="请选择过期时间"></a-date-picker>
</a-form-item>
<a-form-item label="排序" name="sort">
<a-input-number
@@ -137,7 +149,13 @@
<a-form-item label="是否有效" name="isUse">
<a-radio-group v-model:value="form.isUse">
<a-radio :value="1">是</a-radio>
<a-radio :value="0">否</a-radio>
<a-radio :value="2">否</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否在售" name="isSale">
<a-radio-group v-model:value="form.isSale">
<a-radio :value="1">是</a-radio>
<a-radio :value="2">否</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
@@ -145,165 +163,174 @@
</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 { addThinkVip, updateThinkVip } from '@/api/think/thinkVip';
import { ThinkVip } from '@/api/think/thinkVip/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';
import { ThinkSite } from '@/api/think/thinkSite/model';
import { IMG_URL } from '@/config/setting';
import { ref, reactive, watch } from "vue";
import { Form, message } from "ant-design-vue";
import { assignObject, uuid } from "ele-admin-pro";
import { addThinkVip, updateThinkVip } from "@/api/think/thinkVip";
import { ThinkVip } from "@/api/think/thinkVip/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";
import { ThinkSite } from "@/api/think/thinkSite/model";
import { IMG_URL } from "@/config/setting";
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ThinkVip | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ThinkVip | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
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 sites = ref<ThinkSite[]>([]);
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
const sites = ref<ThinkSite[]>([]);
// 用户信息
const form = reactive<ThinkVip>({
id: undefined,
sid: undefined,
name: undefined,
price: undefined,
desc: undefined,
info: undefined,
discount: undefined,
count: undefined,
eachMoney: undefined,
term: 1,
month: undefined,
day: undefined,
type: 1,
cardType: 1,
vipType: 2,
pic: undefined,
prices: undefined,
isIntegral: 2,
isUse: undefined
});
// 用户信息
const form = reactive<ThinkVip>({
id: undefined,
sid: undefined,
name: undefined,
price: undefined,
desc: undefined,
info: undefined,
discount: undefined,
count: undefined,
eachMoney: undefined,
term: 1,
month: undefined,
day: undefined,
type: 1,
cardType: 1,
vipType: 2,
pic: undefined,
prices: undefined,
isIntegral: 2,
mode: 0,
sort: 0,
isSale: 1,
isUse: undefined,
expiredTime: undefined,
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
/* 更新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;
// 表单验证规则
const rules = reactive({
name: [
{
required: true,
type: "string",
message: "请填写名称",
trigger: "blur"
}
formRef.value
.validate()
.then(() => {
loading.value = true;
// 字符串数组用逗号相连
const join = sites.value.map((d) => d.id).join(',');
const formData = {
...form,
sid: join
};
const saveOrUpdate = isUpdate.value ? updateThinkVip : addThinkVip;
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 = [];
sites.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
});
}
if (props.data.sid) {
const split = props.data.sid.split(',');
split.map((id) => {
sites.value.push({
id: Number(id)
});
});
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
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 join = sites.value.map((d) => d.id).join(",");
const formData = {
...form,
sid: join
};
if (formData.mode === 1 && !formData.expiredTime) {
message.error("请选择过期时间");
return;
}
},
{ immediate: true }
);
const saveOrUpdate = isUpdate.value ? updateThinkVip : addThinkVip;
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 = [];
sites.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: "done"
});
}
if (props.data.sid) {
const split = props.data.sid.split(",");
split.map((id) => {
sites.value.push({
id: Number(id)
});
});
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>