This commit is contained in:
2026-10-24 13:32:34 +08:00
parent 72a93e7701
commit cd0aa98dc0
74 changed files with 7928 additions and 1037 deletions
@@ -25,15 +25,21 @@ import { ref, watch } from "vue";
import { ThinkOrderInfoParam } from "@/api/think/thinkOrderInfo/model";
import { messageLoading } from "ele-admin-pro";
import dayjs from "dayjs";
import { thinkOrderExportData } from "@/api/think/thinkOrder";
import {
exportThinkOrderTrainingBusiness,
thinkOrderExportData
} from "@/api/think/thinkOrder";
import { ThinkOrder, ThinkOrderParam } from "@/api/think/thinkOrder/model";
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
type?: number;
}>(),
{}
{
type: 0
}
);
const emit = defineEmits<{
@@ -85,7 +91,16 @@ const reload = () => {
// 导出
const handleExport = async () => {
const hide = messageLoading("导出中...", 0);
const res = await thinkOrderExportData(where);
const [d1, d2] = dateRange.value ?? [];
const params = {
...where,
createTimeStart: d1 ? dayjs(d1).unix() : undefined,
createTimeEnd: d2 ? dayjs(d2).unix() : undefined
};
const res =
props.type === 2
? await exportThinkOrderTrainingBusiness(params)
: await thinkOrderExportData(params);
hide();
window.open(res.url);
};
@@ -0,0 +1,131 @@
<template>
<div class="training-report">
<div
v-for="section in sections"
:key="section.key || section.title"
class="report-section"
>
<table class="report-table">
<thead>
<tr>
<th colspan="9" class="section-title">
{{ section.title }}
</th>
</tr>
<tr>
<th rowspan="2" class="institution-col">培训机构名称</th>
<th colspan="2">开卡统计</th>
<th colspan="2">核销次数</th>
<th colspan="2">过期次数</th>
<th colspan="2">未核销次数</th>
</tr>
<tr>
<th>次数</th>
<th>收款金额</th>
<th>次数</th>
<th>核销金额</th>
<th>次数</th>
<th>过期金额</th>
<th>次数</th>
<th>剩余金额</th>
</tr>
</thead>
<tbody>
<tr v-for="row in section.rows || []" :key="row.trainingInstitutionName">
<td>{{ row.trainingInstitutionName || "-" }}</td>
<td>{{ formatCount(row.openCount) }}</td>
<td>{{ formatAmount(row.openAmount) }}</td>
<td>{{ formatCount(row.verifyCount) }}</td>
<td>{{ formatAmount(row.verifyAmount) }}</td>
<td>{{ formatCount(row.expiredCount) }}</td>
<td>{{ formatAmount(row.expiredAmount) }}</td>
<td>{{ formatCount(row.unverifiedCount) }}</td>
<td>{{ formatAmount(row.remainingAmount) }}</td>
</tr>
<tr class="total-row">
<td>合计</td>
<td>{{ formatCount(section.total?.openCount) }}</td>
<td>{{ formatAmount(section.total?.openAmount) }}</td>
<td>{{ formatCount(section.total?.verifyCount) }}</td>
<td>{{ formatAmount(section.total?.verifyAmount) }}</td>
<td>{{ formatCount(section.total?.expiredCount) }}</td>
<td>{{ formatAmount(section.total?.expiredAmount) }}</td>
<td>{{ formatCount(section.total?.unverifiedCount) }}</td>
<td>{{ formatAmount(section.total?.remainingAmount) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script lang="ts" setup>
import type { ThinkTrainingBusinessSection } from "@/api/think/thinkOrder/model";
defineProps<{
sections: ThinkTrainingBusinessSection[];
}>();
const formatCount = (value?: number | string) => {
if (value === undefined || value === null || value === "") {
return "0";
}
return String(value);
};
const formatAmount = (value?: number | string) => {
if (value === undefined || value === null || value === "") {
return "0";
}
return String(value);
};
</script>
<style lang="less" scoped>
.training-report {
display: flex;
flex-direction: column;
gap: 28px;
}
.report-section {
overflow-x: auto;
}
.report-table {
width: 100%;
min-width: 1200px;
border-collapse: collapse;
table-layout: fixed;
background: #fff;
}
.report-table th,
.report-table td {
padding: 12px 10px;
border: 1px solid #1f1f1f;
font-size: 14px;
line-height: 1.45;
text-align: center;
vertical-align: middle;
word-break: break-all;
}
.report-table th {
font-weight: 600;
}
.section-title {
font-size: 22px;
line-height: 1.4;
padding: 16px 12px !important;
}
.institution-col {
width: 240px;
}
.total-row td {
font-weight: 600;
}
</style>
+73 -54
View File
@@ -3,91 +3,118 @@
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<a-space style="margin-bottom: 1rem">
<a-button @click="changeType(0)" :type="type === 0 ? 'primary' : ''">收款汇总表</a-button>
<a-button @click="changeType(1)" :type="type === 1 ? 'primary' : ''">收入日报表及汇总表</a-button>
<a-button @click="changeType(0)" :type="type === 0 ? 'primary' : ''">
收款汇总表
</a-button>
<a-button @click="changeType(1)" :type="type === 1 ? 'primary' : ''">
收入日报表及汇总表
</a-button>
<a-button @click="changeType(2)" :type="type === 2 ? 'primary' : ''">
培训业务报表
</a-button>
</a-space>
<a-spin :spinning="loading">
<search
@search="searchData"
@reload="reload"
<search @search="searchData" @reload="reload" :type="type" />
<a-table
v-if="type === 0"
:scroll="{ y: tableHeight }"
:data-source="incomeList"
:columns="columns"
:pagination="false"
/>
<a-table v-if="type === 0"
:scroll="{ y: tableHeight }"
:data-source="list"
:columns="columns"
:pagination="false"
/>
<a-table v-else
:scroll="{ y: tableHeight }"
:data-source="list"
:columns="columns1"
:pagination="false"
<a-table
v-else-if="type === 1"
:scroll="{ y: tableHeight }"
:data-source="cardList"
:columns="columns1"
:pagination="false"
/>
<training-business-report v-else :sections="trainingSections" />
</a-spin>
</a-card>
</div>
<OrderList v-model:visible="showList" v-if="showList" :pay-type="payTypeList" :sid="sid"
:showType="showType" :showCardType="showCardType" :type="type" :isPayTime="type === 0"
:create-time-start="createTimeStart" :wechat-order="wechatOrder"
:create-time-end="createTimeEnd" />
<OrderList
v-model:visible="showList"
v-if="showList"
:pay-type="payTypeList"
:sid="sid"
:showType="showType"
:showCardType="showCardType"
:type="type"
:isPayTime="type === 0"
:create-time-start="createTimeStart"
:wechat-order="wechatOrder"
:create-time-end="createTimeEnd"
/>
</div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import type {
ColumnItem
} from "ele-admin-pro/es/ele-pro-table/types";
import type { ColumnItem } from "ele-admin-pro/es/ele-pro-table/types";
import Search from "./components/search.vue";
import TrainingBusinessReport from "./components/trainingBusinessReport.vue";
import {
getThinkOrderExcelData, getThinkOrderExcelDataForCard
getThinkOrderExcelData,
getThinkOrderExcelDataForCard,
getThinkOrderTrainingBusinessData
} from "@/api/think/thinkOrder";
import type {
ThinkOrderParam
ThinkOrderParam,
ThinkTrainingBusinessSection
} from "@/api/think/thinkOrder/model";
import OrderList from "./components/OrderList.vue";
import dayjs from "dayjs";
// 加载状态
const loading = ref(true);
const showType = ref(false);
const showCardType = ref(false);
const type = ref<number>(0);
const changeType = (val) => {
type.value = val;
getList();
};
const tableHeight = document.body.clientHeight - 330;
console.log(tableHeight);
const createTimeStart = ref();
const createTimeEnd = ref();
const list = ref<any[]>([]);
const incomeList = ref<any[]>([]);
const cardList = ref<any[]>([]);
const trainingSections = ref<ThinkTrainingBusinessSection[]>([]);
const sid = ref<number>(0);
const wechatOrder = ref<string>("");
const payTypeList = ref<number[]>([]);
const showList = ref(false);
const getList = async () => {
loading.value = true;
list.value = [];
incomeList.value = [];
cardList.value = [];
trainingSections.value = [];
const params = {
createTimeStart: createTimeStart.value
? dayjs(createTimeStart.value).unix()
: undefined,
createTimeEnd: createTimeEnd.value
? dayjs(createTimeEnd.value).unix()
: undefined
};
if (type.value === 0) {
list.value = await getThinkOrderExcelData({
createTimeStart: createTimeStart.value ? dayjs(createTimeStart.value).unix() : undefined,
createTimeEnd: createTimeEnd.value ? dayjs(createTimeEnd.value).unix() : undefined
});
incomeList.value = await getThinkOrderExcelData(params);
} else if (type.value === 1) {
cardList.value = await getThinkOrderExcelDataForCard(params);
} else {
list.value = await getThinkOrderExcelDataForCard({
createTimeStart: createTimeStart.value ? dayjs(createTimeStart.value).unix() : undefined,
createTimeEnd: createTimeEnd.value ? dayjs(createTimeEnd.value).unix() : undefined
});
trainingSections.value = await getThinkOrderTrainingBusinessData(params);
}
loading.value = false;
};
const changeType = (val: number) => {
type.value = val;
getList();
};
createTimeStart.value = dayjs().format("YYYY-MM-DD");
createTimeEnd.value = dayjs().format("YYYY-MM-DD 23:59:59");
getList();
const sid = ref<number>(0);
const wechatOrder = ref<string>("");
const columns1 = ref<ColumnItem[]>([
{
title: "场馆名称",
@@ -166,7 +193,6 @@ const columns1 = ref<ColumnItem[]>([
customCell: (row) => {
return {
onClick: () => {
console.log(row);
sid.value = row.sid;
wechatOrder.value = "";
payTypeList.value = [2, 3, 12, 15];
@@ -185,7 +211,6 @@ const columns1 = ref<ColumnItem[]>([
}
]);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: "场馆名称",
@@ -307,11 +332,9 @@ const columns = ref<ColumnItem[]>([
}
]);
/* 搜索 */
const searchData = (param: ThinkOrderParam) => {
createTimeStart.value = param.createTimeStart;
createTimeEnd.value = param.createTimeEnd;
console.log(createTimeEnd.value);
getList();
};
@@ -320,11 +343,6 @@ const reload = () => {
createTimeEnd.value = dayjs().format("YYYY-MM-DD");
getList();
};
const payTypeList = ref<number[]>([]);
const showList = ref(false);
</script>
<script lang="ts">
@@ -335,6 +353,7 @@ export default {
components: MenuIcons
};
</script>
<style lang="less" scoped>
.tag-icon {
padding-right: 6px;
@@ -0,0 +1,218 @@
<!-- 编辑弹窗 -->
<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="amount">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.amount"
/>
</a-form-item>
<a-form-item label="" name="orderNo">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.orderNo"
/>
</a-form-item>
<a-form-item label="" name="isPaid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.isPaid"
/>
</a-form-item>
<a-form-item label="" name="paidNumber">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.paidNumber"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</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="remark">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.remark"
/>
</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 { addBalanceChargeLog, updateBalanceChargeLog } from '@/api/shop/balanceChargeLog';
import { BalanceChargeLog } from '@/api/shop/balanceChargeLog/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?: BalanceChargeLog | 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<BalanceChargeLog>({
id: undefined,
amount: undefined,
orderNo: undefined,
isPaid: undefined,
paidNumber: undefined,
userId: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
remark: undefined,
balanceChargeLogId: undefined,
balanceChargeLogName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
balanceChargeLogName: [
{
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 ? updateBalanceChargeLog : addBalanceChargeLog;
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>
@@ -0,0 +1,55 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-input-search
allow-clear
placeholder="请输入手机号"
v-model:value="where.phone"
@pressEnter="reload"
@search="reload"
/>
<a-input-search
allow-clear
placeholder="请输入订单号"
v-model:value="where.orderNo"
@pressEnter="reload"
@search="reload"
/>
<a-select
allow-clear
placeholder="请选择状态"
v-model:value="where.isPaid"
style="width: 140px"
@change="reload"
>
<a-select-option :value="0">未支付</a-select-option>
<a-select-option :value="1">已支付</a-select-option>
<a-select-option :value="2">已退款</a-select-option>
</a-select>
<a-button @click="reset">重置</a-button>
</a-space>
</template>
<script lang="ts" setup>
import useSearch from '@/utils/use-search';
import type { BalanceChargeLogParam } from '@/api/shop/balanceChargeLog/model';
const emit = defineEmits<{
(e: 'search', where?: BalanceChargeLogParam): void;
}>();
const { where, resetFields } = useSearch<BalanceChargeLogParam>({
phone: undefined,
orderNo: undefined,
isPaid: undefined
});
const reload = () => {
emit('search', where);
};
const reset = () => {
resetFields();
reload();
};
</script>
+189
View File
@@ -0,0 +1,189 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search @search="reload" />
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'isPaid'">
<a-tag v-if="record.isPaid === 0">未支付</a-tag>
<a-tag v-if="record.isPaid === 1" color="green">已支付</a-tag>
<a-tag v-if="record.isPaid === 2" color="red">已退款</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a-popconfirm
v-if="record.isPaid === 1"
title="确定要退款吗?"
@confirm="refund(record)"
>
<a class="ele-text-danger">退款</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { message } from 'ant-design-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import {
pageBalanceChargeLog,
refundBalanceChargeLog
} from '@/api/shop/balanceChargeLog';
import type {
BalanceChargeLog,
BalanceChargeLogParam
} from '@/api/shop/balanceChargeLog/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<BalanceChargeLog[]>([]);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageBalanceChargeLog({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '操作',
key: 'action',
width: 90,
align: 'center',
hideInSetting: true
},
{
title: 'ID',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90
},
{
title: '金额',
dataIndex: 'amount',
key: 'amount',
align: 'center'
},
{
title: '手机号',
dataIndex: 'phone',
key: 'phone',
align: 'center'
},
{
title: '订单号',
dataIndex: 'orderNo',
key: 'orderNo',
align: 'center'
},
{
title: '是否已支付',
dataIndex: 'isPaid',
key: 'isPaid',
align: 'center'
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
}
]);
/* 搜索 */
const reload = (where?: BalanceChargeLogParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 退款 */
const refund = (row: BalanceChargeLog) => {
const hide = message.loading('请求中..', 0);
refundBalanceChargeLog(row)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: BalanceChargeLog) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'BalanceChargeLog'
};
</script>
<style lang="less" scoped></style>
@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<!-- <a-button type="primary" class="ele-btn-icon" @click="add">-->
<!-- <template #icon>-->
<!-- <PlusOutlined />-->
<!-- </template>-->
<!-- <span>添加</span>-->
<!-- </a-button>-->
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>
@@ -0,0 +1,260 @@
<!-- 编辑弹窗 -->
<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="用户ID" name="userId">
<a-input
allow-clear
placeholder="请输入用户ID"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="余额变动场景(0 用户充值 1用户消费 2管理员操作 3订单退款)" name="scene">
<a-input
allow-clear
placeholder="请输入余额变动场景(0 用户充值 1用户消费 2管理员操作 3订单退款)"
v-model:value="form.scene"
/>
</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="balance">
<a-input
allow-clear
placeholder="请输入变动后余额"
v-model:value="form.balance"
/>
</a-form-item>
<a-form-item label="管理员备注" name="remark">
<a-input
allow-clear
placeholder="请输入管理员备注"
v-model:value="form.remark"
/>
</a-form-item>
<a-form-item label="" name="orderId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.orderId"
/>
</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="排序(数字越小越靠前)" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</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-item label="状态, 0正常, 1冻结" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</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 { addUserBalanceLog, updateUserBalanceLog } from '@/api/shop/userBalanceLog';
import { UserBalanceLog } from '@/api/shop/userBalanceLog/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?: UserBalanceLog | 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<UserBalanceLog>({
logId: undefined,
userId: undefined,
scene: undefined,
money: undefined,
balance: undefined,
remark: undefined,
orderId: undefined,
adminId: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
userBalanceLogId: undefined,
userBalanceLogName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
userBalanceLogName: [
{
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 ? updateUserBalanceLog : addUserBalanceLog;
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>
+238
View File
@@ -0,0 +1,238 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="userBalanceLogId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<UserBalanceLogEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import UserBalanceLogEdit from './components/userBalanceLogEdit.vue';
import { pageUserBalanceLog, removeUserBalanceLog, removeBatchUserBalanceLog } from '@/api/shop/userBalanceLog';
import type { UserBalanceLog, UserBalanceLogParam } from '@/api/shop/userBalanceLog/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<UserBalanceLog[]>([]);
// 当前编辑数据
const current = ref<UserBalanceLog | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageUserBalanceLog({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'logId',
key: 'logId',
align: 'center',
width: 90,
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '余额变动场景',
dataIndex: 'scene',
key: 'scene',
align: 'center',
customRender: ({ text }) => ['用户充值', '用户消费', '管理员操作', '订单退款'][text]
},
{
title: '变动金额',
dataIndex: 'money',
key: 'money',
align: 'center',
},
{
title: '变动后余额',
dataIndex: 'balance',
key: 'balance',
align: 'center',
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark',
align: 'center',
},
{
title: '操作时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
},
]);
/* 搜索 */
const reload = (where?: UserBalanceLogParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: UserBalanceLog) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: UserBalanceLog) => {
const hide = message.loading('请求中..', 0);
removeUserBalanceLog(row.logId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchUserBalanceLog(selection.value.map((d) => d.logId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: UserBalanceLog) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'UserBalanceLog'
};
</script>
<style lang="less" scoped></style>
@@ -82,12 +82,12 @@
v-model:value="form.email"
/>
</a-form-item>
<a-form-item label="备注信息" name="info">
<a-form-item label="备注信息" name="remark">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入备注信息"
v-model:value="form.info"
v-model:value="form.remark"
/>
</a-form-item>
<a-form-item label="发票类型" name="type">
@@ -97,14 +97,14 @@
</a-radio-group>
</a-form-item>
<a-form-item label="发票类型" name="itype">
<a-radio-group v-model:value="form.itype" :disabled="true">
<a-radio-group v-model:value="form.itype">
<a-radio :value="1">场地发票</a-radio>
<a-radio :value="2">vip卡发票</a-radio>
<a-radio :value="3">IC卡发票</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="发票类型" name="invoicetype">
<a-radio-group v-model:value="form.invoicetype" :disabled="true">
<a-radio-group v-model:value="form.invoicetype">
<a-radio :value="1">普票</a-radio>
<a-radio :value="2">专票</a-radio>
</a-radio-group>
@@ -118,10 +118,8 @@
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import {
addThinkInvoice,
doInvoice,
pageThinkInvoice,
updateThinkInvoice
} from '@/api/think/thinkInvoice';
import { ThinkInvoice } from '@/api/think/thinkInvoice/model';
import { useThemeStore } from '@/store/modules/theme';
@@ -191,7 +189,6 @@
price: [
{
required: true,
type: 'number',
message: '请填写发票金额',
trigger: 'blur'
}
@@ -214,10 +211,6 @@
]
});
const onChangeInvoice = (data: ThinkInvoice) => {
console.log(data);
console.log(form);
};
const { resetFields } = useForm(form, rules);
@@ -255,14 +248,17 @@
() => props.visible,
(visible) => {
if (visible) {
const random = uuid();
const random1 = uuid();
// 第一次开票
isUpdate.value = false;
form.oid = props.data?.id;
form.price = props.data?.price;
form.incoiveNum = props.data?.code;
form.orderNum = props.data?.code;
form.incoiveNum = random1;
form.orderNum = random;
form.vid = props.data?.vid;
form.phone = props.data?.phone;
form.uid = props.data?.uid;
form.itype = 3;
// 开过票
@@ -272,7 +268,7 @@
isUpdate.value = true;
form.oid = props.data?.id;
form.price = props.data?.price;
form.incoiveNum = props.data?.code;
form.incoiveNum = random1;
form.vid = props.data?.vid;
form.phone = props.data?.phone;
}
+490 -369
View File
@@ -7,7 +7,6 @@
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
:selection="selection"
:scroll="{ x: 3800 }"
tool-class="ele-toolbar-form"
@@ -46,11 +45,13 @@
<a class="ele-text-danger">注销</a>
</a-popconfirm>
<a-divider type="vertical" />
<a @click="onInvoice(record)" v-if="record.isInvoice === 2">开票</a>
<a @click="onInvoice(record)" v-if="record.isInvoice === 2"
>开票</a
>
</a-space>
</template>
<template v-if="column.key === 'sid'">
<span>{{ record.siteList.map(item => item.name).join() }}</span>
<span>{{ record.siteList.map((item) => item.name).join() }}</span>
</template>
<template v-if="column.key === 'type'">
<a-tag>{{ types[record.type] }}</a-tag>
@@ -66,7 +67,61 @@
<a-tag v-if="record.status === 2" color="red">未付款</a-tag>
</template>
<template v-if="column.key === 'expireTime'">
{{ toDateString(record.expireTime) }}
<a-date-picker
show-time
value-format="YYYY-MM-DD HH:mm:ss"
:value="formatExpireTime(record.expireTime)"
:disabled="expireTimeLoading[record.id || 0]"
style="width: 180px"
placeholder="请选择到期时间"
:allow-clear="false"
@change="(value) => changeExpireTime(value, record)"
/>
</template>
<template v-if="column.key === 'num'">
<a-space>
<template v-if="isRemainingEditing(record, 'num')">
<a-input
type="number"
:value="getRemainingDraft(record, 'num')"
:disabled="isRemainingLoading(record.id, 'num')"
style="width: 90px"
@update:value="(value) => setRemainingDraft(record, 'num', value)"
/>
<a-button type="link" size="small" :loading="isRemainingLoading(record.id, 'num')" @click="saveRemaining(record, 'num')">确认</a-button>
</template>
<template v-else>
<span>{{ record.num ?? '-' }}</span>
<a-button
v-if="hasPermission('think:thinkCard:changeRemain')"
type="link"
size="small"
@click="editRemaining(record, 'num')"
>修改</a-button>
</template>
</a-space>
</template>
<template v-if="column.key === 'remainingMoney'">
<a-space>
<template v-if="isRemainingEditing(record, 'remainingMoney')">
<a-input
:value="getRemainingDraft(record, 'remainingMoney')"
:disabled="isRemainingLoading(record.id, 'remainingMoney')"
style="width: 100px"
@update:value="(value) => setRemainingDraft(record, 'remainingMoney', value)"
/>
<a-button type="link" size="small" :loading="isRemainingLoading(record.id, 'remainingMoney')" @click="saveRemaining(record, 'remainingMoney')">确认</a-button>
</template>
<template v-else>
<span>{{ record.remainingMoney ?? '-' }}</span>
<a-button
v-if="hasPermission('think:thinkCard:changeRemain')"
type="link"
size="small"
@click="editRemaining(record, 'remainingMoney')"
>修改</a-button>
</template>
</a-space>
</template>
<template v-if="column.key === 'isInvoice'">
<a-tag v-if="record.isInvoice === 1" color="green">已开票</a-tag>
@@ -102,383 +157,449 @@
</template>
<script lang="ts" setup>
import { createVNode, ref } from "vue";
import { message, Modal } from "ant-design-vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import type { EleProTable } from "ele-admin-pro";
import { toDateString } from "ele-admin-pro";
import type {
DatasourceFunction,
ColumnItem
} from "ele-admin-pro/es/ele-pro-table/types";
import Search from "./components/search.vue";
import ThinkCardEdit from "./components/thinkCardEdit.vue";
import {
pageThinkCard,
removeThinkCard,
removeBatchThinkCard,
updateThinkCard
} from "@/api/think/thinkCard";
import type { ThinkCard, ThinkCardParam } from "@/api/think/thinkCard/model";
import MakeICCard from "@/views/think/thinkCard/components/makeICCard.vue";
import ThinkCardLog from "./components/thinkCardLog.vue";
import Invoice from "./components/invoice.vue";
import { createVNode, reactive, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import dayjs from 'dayjs';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkCardEdit from './components/thinkCardEdit.vue';
import {
pageThinkCard,
removeThinkCard,
removeBatchThinkCard,
updateThinkCard,
updateThinkCardRemaining
} from '@/api/think/thinkCard';
import type { ThinkCard, ThinkCardParam } from '@/api/think/thinkCard/model';
import MakeICCard from '@/views/think/thinkCard/components/makeICCard.vue';
import ThinkCardLog from './components/thinkCardLog.vue';
import Invoice from './components/invoice.vue';
import { hasPermission } from '@/utils/permission';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ThinkCard[]>([]);
// 当前编辑数据
const current = ref<ThinkCard | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
const types = ref<string[]>([
"",
"年卡",
"次卡",
"月卡",
"会员IC卡",
"充值卡"
]);
const payTypes = ref<string[]>([
"",
"微信支付",
"支付宝支付",
"现金",
"POS机刷卡",
"平安健康卡",
"免费",
"抖音支付",
]);
const isIntegral = ref<string[]>(["", "赠送", "不赠送"]);
// 表格选中数据
const selection = ref<ThinkCard[]>([]);
// 当前编辑数据
const current = ref<ThinkCard | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
const types = ref<string[]>([
'',
'年卡',
'次卡',
'月卡',
'会员IC卡',
'充值卡'
]);
const payTypes = ref<string[]>([
'',
'微信支付',
'支付宝支付',
'现金',
'POS机刷卡',
'平安健康卡',
'免费',
'抖音支付'
]);
const isIntegral = ref<string[]>(['', '赠送', '不赠送']);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageThinkCard({
...where,
...orders,
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: "操作",
dataIndex: "username",
key: "username",
align: "center",
fixed: "left",
width: 400
},
{
title: "卡号",
dataIndex: "code",
key: "code",
align: "center",
fixed: "left",
width: 140
},
{
title: "手机号",
dataIndex: "phone",
key: "phone",
align: "center",
fixed: "left",
width: 140
},
{
title: "会员卡名称",
dataIndex: "name",
key: "name",
align: "center",
width: 140,
fixed: "left"
},
{
title: "IC卡数字",
dataIndex: "cardNum",
key: "cardNum",
width: 140,
align: "center"
},
{
title: "紧急联系人",
dataIndex: "urgentName",
key: "urgentName",
width: 140,
align: "center"
},
{
title: "紧急联系人号码",
dataIndex: "urgentPhone",
key: "urgentPhone",
width: 140,
align: "center"
},
{
title: "可用场馆",
dataIndex: "sid",
key: "sid",
width: 140,
align: "center"
},
{
title: "vip购卡价格",
dataIndex: "price",
key: "price",
width: 140,
sorter: true,
align: "center"
},
{
title: "vip卡折扣率",
dataIndex: "discount",
key: "discount",
width: 140,
sorter: true,
align: "center"
},
{
title: "使用次数",
dataIndex: "count",
key: "count",
width: 140,
sorter: true,
align: "center"
},
{
title: "剩余次数",
dataIndex: "num",
key: "num",
width: 140,
sorter: true,
align: "center"
},
{
title: "每使用一次减少的金额",
dataIndex: "eachMoney",
key: "eachMoney",
width: 140,
sorter: true,
align: "center"
},
{
title: "剩余金额",
dataIndex: "remainingMoney",
key: "remainingMoney",
width: 140,
sorter: true,
align: "center"
},
{
title: "月限",
dataIndex: "month",
key: "month",
width: 140,
align: "center"
},
{
title: "年限",
dataIndex: "term",
key: "term",
width: 140,
align: "center"
},
{
title: "IC卡类型",
dataIndex: "type",
key: "type",
width: 140,
align: "center"
},
{
title: "到期时间",
dataIndex: "expireTime",
key: "expireTime",
width: 140,
sorter: true,
align: "center"
},
{
title: "支付状态",
dataIndex: "status",
key: "status",
width: 140,
sorter: true,
align: "center"
},
{
title: "付款方式",
dataIndex: "payType",
key: "payType",
width: 140,
align: "center"
},
{
title: "是否赠送积分",
dataIndex: "isIntegral",
key: "isIntegral",
width: 140,
sorter: true,
align: "center"
},
{
title: "是否已开具发票",
dataIndex: "isInvoice",
key: "isInvoice",
width: 140,
sorter: true,
align: "center"
},
{
title: "购卡时间",
dataIndex: "createTime",
key: "createTime",
align: "center",
sorter: true,
ellipsis: true,
width: 180,
customRender: ({ text }) => toDateString(text, "yyyy-MM-dd HH:mm:ss")
}
]);
/* 搜索 */
const reload = (where?: ThinkCardParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkCard) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
const showMakeCard = ref(false);
const openMakeCard = () => {
showMakeCard.value = true;
};
const unBindCard = (row: ThinkCard) => {
updateThinkCard({ id: row.id, uid: 0, username: "", phone: "" }).then(() => {
message.success("操作成功");
reload();
});
};
const changeBindCard = (row: any, id: number) => {
// console.log(row, id);
updateThinkCard({
id, uid: row.id,
username: row.truename ?? row.phone,
phone: row.phone
}).then(() => {
message.success("操作成功");
reload();
});
};
/* 删除单个 */
const remove = (row: ThinkCard) => {
const hide = message.loading("请求中..", 0);
removeThinkCard(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error("请至少选择一条数据");
return;
}
Modal.confirm({
title: "提示",
content: "确定要删除选中的记录吗?",
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading("请求中..", 0);
removeBatchThinkCard(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
});
};
return pageThinkCard({
...where,
...orders,
page,
limit
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
const showLog = ref(false)
const openLog = (row: ThinkCard) => {
showLog.value = true
current.value = row
}
const showInvoice = ref(false)
const onInvoice = (row?: ThinkCard) => {
current.value = row ?? null;
showInvoice.value = true;
};
/* 自定义行属性 */
const customRow = (record: ThinkCard) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '操作',
dataIndex: 'username',
key: 'username',
align: 'center',
fixed: 'left',
width: 400
},
// 行双击事件
onDblclick: () => {
openEdit(record);
{
title: '卡号',
dataIndex: 'code',
key: 'code',
align: 'center',
fixed: 'left',
width: 140
},
{
title: '手机号',
dataIndex: 'phone',
key: 'phone',
align: 'center',
fixed: 'left',
width: 140
},
{
title: '会员卡名称',
dataIndex: 'name',
key: 'name',
align: 'center',
width: 140,
fixed: 'left'
},
{
title: 'IC卡数字',
dataIndex: 'cardNum',
key: 'cardNum',
width: 140,
align: 'center'
},
{
title: '可用场馆',
dataIndex: 'sid',
key: 'sid',
width: 140,
align: 'center'
},
{
title: 'vip购卡价格',
dataIndex: 'price',
key: 'price',
width: 140,
sorter: true,
align: 'center'
},
{
title: 'vip卡折扣率',
dataIndex: 'discount',
key: 'discount',
width: 140,
sorter: true,
align: 'center'
},
{
title: '使用次数',
dataIndex: 'count',
key: 'count',
width: 140,
sorter: true,
align: 'center'
},
{
title: '剩余次数',
dataIndex: 'num',
key: 'num',
width: 140,
align: 'center'
},
{
title: '剩余金额',
dataIndex: 'remainingMoney',
key: 'remainingMoney',
width: 140,
align: 'center'
},
{
title: 'IC卡类型',
dataIndex: 'type',
key: 'type',
width: 140,
align: 'center'
},
{
title: '支付状态',
dataIndex: 'status',
key: 'status',
width: 140,
align: 'center'
},
{
title: '付款方式',
dataIndex: 'payType',
key: 'payType',
width: 140,
align: 'center'
},
{
title: '购卡时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
width: 220,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
},
{
title: '到期时间',
dataIndex: 'expireTime',
key: 'expireTime',
width: 280,
sorter: true,
align: 'center'
},
{
title: '每使用一次减少的金额',
dataIndex: 'eachMoney',
key: 'eachMoney',
width: 140,
sorter: true,
align: 'center'
},
{
title: '年限',
dataIndex: 'term',
key: 'term',
width: 140,
align: 'center'
},
{
title: '月限',
dataIndex: 'month',
key: 'month',
width: 140,
align: 'center'
},
{
title: '紧急联系人',
dataIndex: 'urgentName',
key: 'urgentName',
width: 140,
align: 'center'
},
{
title: '紧急联系人号码',
dataIndex: 'urgentPhone',
key: 'urgentPhone',
width: 140,
align: 'center'
},
{
title: '是否赠送积分',
dataIndex: 'isIntegral',
key: 'isIntegral',
width: 140,
align: 'center'
},
{
title: '是否已开具发票',
dataIndex: 'isInvoice',
key: 'isInvoice',
width: 140,
align: 'center'
}
]);
const expireTimeLoading = reactive<Record<number, boolean>>({});
const remainingDrafts = reactive<Record<string, string | number | null>>({});
const remainingLoadingKey = ref<string | null>(null);
const remainingEditing = reactive<Record<string, boolean>>({});
const remainingKey = (row: ThinkCard, field: 'num' | 'remainingMoney') => `${row.id ?? ''}-${field}`;
const getRemainingDraft = (row: ThinkCard, field: 'num' | 'remainingMoney') => {
const key = remainingKey(row, field);
if (!(key in remainingDrafts)) remainingDrafts[key] = field === 'num' ? (row.num ?? 0) : (row.remainingMoney ?? '');
return remainingDrafts[key];
};
const setRemainingDraft = (row: ThinkCard, field: 'num' | 'remainingMoney', value: string | number | null) => {
remainingDrafts[remainingKey(row, field)] = value;
};
const isRemainingEditing = (row: ThinkCard, field: 'num' | 'remainingMoney') =>
!!remainingEditing[remainingKey(row, field)];
const editRemaining = (row: ThinkCard, field: 'num' | 'remainingMoney') => {
if (!hasPermission('think:thinkCard:changeRemain')) return;
getRemainingDraft(row, field);
remainingEditing[remainingKey(row, field)] = true;
};
const isRemainingLoading = (id: number | undefined, field: string) =>
remainingLoadingKey.value === `${id ?? ''}-${field}`;
const saveRemaining = async (row: ThinkCard, field: 'num' | 'remainingMoney') => {
if (!row.id) return;
const value = getRemainingDraft(row, field);
if (value === null || value === '' || value === undefined || (field === 'num' && (!Number.isInteger(Number(value)) || Number(value) < 0))) {
message.error(field === 'num' ? '剩余次数必须是非负整数' : '请输入剩余金额');
return;
}
const key = remainingKey(row, field);
remainingLoadingKey.value = key;
try {
await updateThinkCardRemaining({ id: row.id, ...(field === 'num' ? { num: Number(value) } : { remainingMoney: String(value) }) });
if (field === 'num') row.num = Number(value); else row.remainingMoney = String(value);
remainingEditing[key] = false;
message.success('保存成功');
} catch (e: any) {
message.error(e.message || '保存失败');
} finally {
remainingLoadingKey.value = null;
}
};
};
query();
const formatExpireTime = (value?: number) => {
return value
? dayjs(value * 1000).format('YYYY-MM-DD HH:mm:ss')
: undefined;
};
const changeExpireTime = async (value: string, row: ThinkCard) => {
if (!row.id) {
return;
}
if (!value) {
message.error('请选择到期时间');
return;
}
const expireTime = dayjs(value).unix();
if (row.expireTime === expireTime) {
return;
}
expireTimeLoading[row.id] = true;
try {
await updateThinkCard({
id: row.id,
expireTime
});
row.expireTime = expireTime;
message.success('到期时间修改成功');
} catch (e: any) {
message.error(e.message || '到期时间修改失败');
} finally {
expireTimeLoading[row.id] = false;
}
};
/* 搜索 */
const reload = (where?: ThinkCardParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkCard) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
const showMakeCard = ref(false);
const openMakeCard = () => {
showMakeCard.value = true;
};
const unBindCard = (row: ThinkCard) => {
updateThinkCard({ id: row.id, uid: 0, username: '', phone: '' }).then(
() => {
message.success('操作成功');
reload();
}
);
};
const changeBindCard = (row: any, id: number) => {
// console.log(row, id);
updateThinkCard({
id,
uid: row.id,
username: row.truename ?? row.phone,
phone: row.phone
}).then(() => {
message.success('操作成功');
reload();
});
};
/* 删除单个 */
const remove = (row: ThinkCard) => {
const hide = message.loading('请求中..', 0);
removeThinkCard(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkCard(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
const showLog = ref(false);
const openLog = (row: ThinkCard) => {
showLog.value = true;
current.value = row;
};
const showInvoice = ref(false);
const onInvoice = (row?: ThinkCard) => {
current.value = row ?? null;
showInvoice.value = true;
};
query();
</script>
<script lang="ts">
export default {
name: "ThinkCard"
};
export default {
name: 'ThinkCard'
};
</script>
<style lang="less" scoped></style>
@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>
@@ -0,0 +1,209 @@
<!-- 编辑弹窗 -->
<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="cid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.cid"
/>
</a-form-item>
<a-form-item label="" name="vid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.vid"
/>
</a-form-item>
<a-form-item label="" name="uid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.uid"
/>
</a-form-item>
<a-form-item label="" name="balance">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.balance"
/>
</a-form-item>
<a-form-item label="每次减少金额" name="reduceEach">
<a-input
allow-clear
placeholder="请输入每次减少金额"
v-model:value="form.reduceEach"
/>
</a-form-item>
<a-form-item label="" name="updateTime">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.updateTime"
/>
</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 { addThinkCardBalance, updateThinkCardBalance } from '@/api/think/thinkCardBalance';
import { ThinkCardBalance } from '@/api/think/thinkCardBalance/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?: ThinkCardBalance | 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<ThinkCardBalance>({
id: undefined,
cid: undefined,
vid: undefined,
uid: undefined,
balance: undefined,
reduceEach: undefined,
createTime: undefined,
updateTime: undefined,
thinkCardBalanceId: undefined,
thinkCardBalanceName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
thinkCardBalanceName: [
{
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 ? updateThinkCardBalance : addThinkCardBalance;
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>
+251
View File
@@ -0,0 +1,251 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="thinkCardBalanceId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ThinkCardBalanceEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkCardBalanceEdit from './components/thinkCardBalanceEdit.vue';
import { pageThinkCardBalance, removeThinkCardBalance, removeBatchThinkCardBalance } from '@/api/think/thinkCardBalance';
import type { ThinkCardBalance, ThinkCardBalanceParam } from '@/api/think/thinkCardBalance/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ThinkCardBalance[]>([]);
// 当前编辑数据
const current = ref<ThinkCardBalance | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageThinkCardBalance({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'cid',
key: 'cid',
align: 'center',
},
{
title: '',
dataIndex: 'vid',
key: 'vid',
align: 'center',
},
{
title: '',
dataIndex: 'uid',
key: 'uid',
align: 'center',
},
{
title: '',
dataIndex: 'balance',
key: 'balance',
align: 'center',
},
{
title: '每次减少金额',
dataIndex: 'reduceEach',
key: 'reduceEach',
align: 'center',
},
{
title: '下单时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ThinkCardBalanceParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkCardBalance) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ThinkCardBalance) => {
const hide = message.loading('请求中..', 0);
removeThinkCardBalance(row.thinkCardBalanceId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkCardBalance(selection.value.map((d) => d.thinkCardBalanceId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ThinkCardBalance) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ThinkCardBalance'
};
</script>
<style lang="less" scoped></style>
@@ -129,23 +129,28 @@
<template #footer>
<a-button @click="showCal = false">关闭</a-button>
</template>
<a-date-picker v-model:value="month" value-format="YYYY-MM" picker="month"/>
<div v-for="(item, index) in prices" :key="index">
<a-date-picker
v-model:value="month"
value-format="YYYY-MM"
picker="month"
@change="onMonthChange"
/>
<div v-for="(item, index) in prices" :key="`${month}-${index}`">
<div style="padding: 1rem 0">
<div class="flex justify-start items-center">
<span style="width: 120px">{{ index + 1 }}号价格</span>
<a-input-number v-model:value="prices[index]" style="width: 300px;" />
</div>
<p style="color: #999; font-size: 0.8rem"> {{ dayjs(`${month}-${(index + 1)}`).format("YYYY-MM-DD") }}
{{ weekStr[dayjs(`${month}-${(index + 1)}`).format("d")] }}的价格,温馨提示:如价格填写0则代表当日免费。</p>
<p style="color: #999; font-size: 0.8rem"> {{ dayjs(`${month}-${String(index + 1).padStart(2, '0')}`).format("YYYY-MM-DD") }}
{{ weekStr[dayjs(`${month}-${String(index + 1).padStart(2, '0')}`).format("d")] }}的价格,温馨提示:如价格填写0则代表当日免费。</p>
</div>
<div style="margin-bottom: 1rem">
<div class="flex justify-start items-center">
<span style="width: 120px">{{ index + 1 }}号半场价格</span>
<a-input-number v-model:value="halfPrices[index]" style="width: 300px;" />
</div>
<p style="color: #999; font-size: 0.8rem"> {{ dayjs(`${month}-${(index + 1)}`).format("YYYY-MM-DD") }}
{{ weekStr[dayjs(`${month}-${(index + 1)}`).format("d")]
<p style="color: #999; font-size: 0.8rem"> {{ dayjs(`${month}-${String(index + 1).padStart(2, '0')}`).format("YYYY-MM-DD") }}
{{ weekStr[dayjs(`${month}-${String(index + 1).padStart(2, '0')}`).format("d")]
}}的半场价格,温馨提示:如价格填写0则代表当日免费。</p>
</div>
<a-divider />
@@ -275,12 +280,23 @@ const save = () => {
return;
}
formData.week = JSON.stringify(formData.week);
formData.prices = JSON.stringify({
[month.value]: prices.value.map(item => item ? item.toString() : '')
});
formData.halfPrices = JSON.stringify({
[month.value]: halfPrices.value.map(item => item ? item.toString() : '')
});
// 只保留当前选中月份的价格数据
const dayPrices = normalizeDayPrices(prices.value, month.value).map(
(item) =>
item !== "" && item !== null && item !== undefined
? String(item)
: ""
);
const dayHalfPrices = normalizeDayPrices(
halfPrices.value,
month.value
).map((item) =>
item !== "" && item !== null && item !== undefined ? String(item) : ""
);
formData.prices = JSON.stringify({ [month.value]: dayPrices });
formData.halfPrices = JSON.stringify({ [month.value]: dayHalfPrices });
form.prices = formData.prices;
form.halfPrices = formData.halfPrices;
formData.timePeriod = `${formData.timePeriod1} - ${formData.timePeriod2}`;
formData.startTime = `${formData.timePeriod1?.replace(":", "")}`;
console.log(formData)
@@ -308,6 +324,19 @@ const prices = ref<any[]>([]);
const halfPrices = ref<any[]>([]);
const showCal = ref(false);
const openCal = () => {
// 打开日历前先按当前月份校正数据结构,避免脏数据导致表格无法渲染
const priceMap = parsePriceMap(form.prices);
const halfPriceMap = parsePriceMap(form.halfPrices);
// 仅使用当前月份的数据;若 form 中是其他月份则重建空结构
if (priceMap[month.value]) {
prices.value = normalizeDayPrices(priceMap[month.value], month.value);
halfPrices.value = normalizeDayPrices(
halfPriceMap[month.value],
month.value
);
} else {
resetMonthPrices(month.value);
}
showCal.value = true;
};
@@ -321,21 +350,52 @@ const weekStr = ref([
"星期六"
]);
const makePrices = () => {
const dayNum = dayjs().daysInMonth();
prices.value = [];
for (let i = 0; i < dayNum; i++) {
prices.value.push("");
/** 安全解析价格 JSON */
const parsePriceMap = (value?: string | null): Record<string, any[]> => {
if (!value || value === "0") return {};
try {
const parsed = JSON.parse(value);
return parsed && typeof parsed === "object" ? parsed : {};
} catch {
return {};
}
// console.log(prices.value);
};
/** 按指定月份天数生成/校正价格数组 */
const normalizeDayPrices = (source?: any[] | null, targetMonth?: string) => {
const dayNum = dayjs(`${targetMonth || month.value}-01`).daysInMonth();
const result: any[] = [];
for (let i = 0; i < dayNum; i++) {
const val = source?.[i];
result.push(val !== undefined && val !== null ? val : "");
}
return result;
};
const makePrices = () => {
prices.value = normalizeDayPrices(null);
};
const makeHalfPrices = () => {
const dayNum = dayjs().daysInMonth();
halfPrices.value = [];
for (let i = 0; i < dayNum; i++) {
halfPrices.value.push("");
}
halfPrices.value = normalizeDayPrices(null);
};
/** 按目标月天数重置为空的 prices / halfPrices */
const resetMonthPrices = (targetMonth: string) => {
if (!targetMonth) return;
prices.value = normalizeDayPrices(null, targetMonth);
halfPrices.value = normalizeDayPrices(null, targetMonth);
// 同步 form:只保留当前这一个月份
form.prices = JSON.stringify({ [targetMonth]: prices.value });
form.halfPrices = JSON.stringify({ [targetMonth]: halfPrices.value });
};
/** 切换月份:丢弃旧月份,按新月份天数重建价格结构 */
const onMonthChange = (value: string | null) => {
const nextMonth = value || month.value;
if (!nextMonth) return;
month.value = nextMonth;
resetMonthPrices(nextMonth);
};
watch(
@@ -354,26 +414,24 @@ watch(
form.week = JSON.parse(props.data.week);
}
isUpdate.value = true;
if (props.data?.prices === "0") {
makePrices();
} else {
const keys = Object.keys(JSON.parse(props.data?.prices))
month.value = keys[0]
const pricesItem = JSON.parse(props.data?.prices)[month.value];
if (pricesItem) prices.value = pricesItem;
else makePrices();
}
if (props.data?.halfPrices === "0") {
makeHalfPrices();
} else {
const keys = Object.keys(JSON.parse(props.data?.prices))
month.value = keys[0]
const halfPricesItem = JSON.parse(props.data?.halfPrices)[month.value];
if (halfPricesItem) halfPrices.value = halfPricesItem;
else makeHalfPrices();
}
const priceMap = parsePriceMap(props.data?.prices);
const halfPriceMap = parsePriceMap(props.data?.halfPrices);
const keys = Object.keys(priceMap);
if (keys.length) month.value = keys[0];
else month.value = dayjs().format("YYYY-MM");
// 回显时校正结构,且 form 只保留这一个月份
prices.value = normalizeDayPrices(priceMap[month.value], month.value);
halfPrices.value = normalizeDayPrices(
halfPriceMap[month.value],
month.value
);
form.prices = JSON.stringify({ [month.value]: prices.value });
form.halfPrices = JSON.stringify({ [month.value]: halfPrices.value });
} else {
isUpdate.value = false;
month.value = dayjs().format("YYYY-MM");
makePrices();
makeHalfPrices();
}
} else {
resetFields();
@@ -0,0 +1,52 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-input allow-clear v-model:value="keyword" placeholder="流水号搜索" @change="search" />
<a-range-picker
allow-clear
v-model:value="dateRange"
@change="search"
value-format="YYYY-MM-DD"
class="ele-fluid"
/>
</a-space>
</template>
<script lang="ts" setup>
import { ref, watch } from "vue";
import { ThinkFtpCheckBillParam } from "@/api/think/thinkFtpCheckBill/model";
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const dateRange = ref<[string, string] | null>();
const emit = defineEmits<{
(e: "search", where?: ThinkFtpCheckBillParam): void;
(e: "add"): void;
(e: "remove"): void;
(e: "batchMove"): void;
}>();
// 新增
const keyword = ref<string>("");
const search = () => {
let payTimeStart: string = undefined, payTimeEnd: string = undefined;
if (dateRange.value && dateRange.value?.length > 0 && dateRange.value[0]) {
[payTimeStart, payTimeEnd] = dateRange.value;
payTimeEnd = `${payTimeEnd} 23:59:59`
}
emit("search", { keywords: keyword.value, payTimeStart, payTimeEnd });
};
watch(
() => props.selection,
() => {
}
);
</script>
@@ -0,0 +1,289 @@
<!-- 编辑弹窗 -->
<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="deviceNo">
<a-input
allow-clear
placeholder="请输入终端号"
v-model:value="form.deviceNo"
/>
</a-form-item>
<a-form-item label="卡号" name="cardNo">
<a-input
allow-clear
placeholder="请输入卡号"
v-model:value="form.cardNo"
/>
</a-form-item>
<a-form-item label="" name="amount">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.amount"
/>
</a-form-item>
<a-form-item label="结算金额" name="settleAmount">
<a-input
allow-clear
placeholder="请输入结算金额"
v-model:value="form.settleAmount"
/>
</a-form-item>
<a-form-item label="手续费" name="feeAmount">
<a-input
allow-clear
placeholder="请输入手续费"
v-model:value="form.feeAmount"
/>
</a-form-item>
<a-form-item label="实际支付金额" name="paidAmount">
<a-input
allow-clear
placeholder="请输入实际支付金额"
v-model:value="form.paidAmount"
/>
</a-form-item>
<a-form-item label="参考号" name="refNo">
<a-input
allow-clear
placeholder="请输入参考号"
v-model:value="form.refNo"
/>
</a-form-item>
<a-form-item label="流水号" name="flowNo">
<a-input
allow-clear
placeholder="请输入流水号"
v-model:value="form.flowNo"
/>
</a-form-item>
<a-form-item label="卡类型" name="cardType">
<a-input
allow-clear
placeholder="请输入卡类型"
v-model:value="form.cardType"
/>
</a-form-item>
<a-form-item label="发卡行" name="postCardType">
<a-input
allow-clear
placeholder="请输入发卡行"
v-model:value="form.postCardType"
/>
</a-form-item>
<a-form-item label="支付方式" name="payType">
<a-input
allow-clear
placeholder="请输入支付方式"
v-model:value="form.payType"
/>
</a-form-item>
<a-form-item label="银商订单号" name="orderNo">
<a-input
allow-clear
placeholder="请输入银商订单号"
v-model:value="form.orderNo"
/>
</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="状态, 0已发布, 1待审核 2已驳回 3违规内容" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</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 { addThinkFtpCheckBill, updateThinkFtpCheckBill } from '@/api/think/thinkFtpCheckBill';
import { ThinkFtpCheckBill } from '@/api/think/thinkFtpCheckBill/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?: ThinkFtpCheckBill | 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<ThinkFtpCheckBill>({
id: undefined,
deviceNo: undefined,
cardNo: undefined,
amount: undefined,
settleAmount: undefined,
feeAmount: undefined,
paidAmount: undefined,
refNo: undefined,
flowNo: undefined,
cardType: undefined,
postCardType: undefined,
payType: undefined,
orderNo: undefined,
payTime: undefined,
tenantId: undefined,
status: undefined,
deleted: undefined,
createTime: undefined,
updateTime: undefined,
thinkFtpCheckBillId: undefined,
thinkFtpCheckBillName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
thinkFtpCheckBillName: [
{
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 ? updateThinkFtpCheckBill : addThinkFtpCheckBill;
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>
+270
View File
@@ -0,0 +1,270 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="thinkFtpCheckBillId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'payTime'">
<span>{{ dayjs(record.payTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ThinkFtpCheckBillEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkFtpCheckBillEdit from './components/thinkFtpCheckBillEdit.vue';
import { pageThinkFtpCheckBill, removeThinkFtpCheckBill, removeBatchThinkFtpCheckBill } from '@/api/think/thinkFtpCheckBill';
import type { ThinkFtpCheckBill, ThinkFtpCheckBillParam } from '@/api/think/thinkFtpCheckBill/model';
import dayjs from "dayjs";
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ThinkFtpCheckBill[]>([]);
// 当前编辑数据
const current = ref<ThinkFtpCheckBill | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageThinkFtpCheckBill({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '终端号',
dataIndex: 'deviceNo',
key: 'deviceNo',
align: 'center',
},
{
title: '卡号',
dataIndex: 'cardNo',
key: 'cardNo',
align: 'center',
},
{
title: '金额',
dataIndex: 'amount',
key: 'amount',
align: 'center',
},
{
title: '结算金额',
dataIndex: 'settleAmount',
key: 'settleAmount',
align: 'center',
},
{
title: '手续费',
dataIndex: 'feeAmount',
key: 'feeAmount',
align: 'center',
},
{
title: '实际支付金额',
dataIndex: 'paidAmount',
key: 'paidAmount',
align: 'center',
},
{
title: '参考号',
dataIndex: 'refNo',
key: 'refNo',
align: 'center',
},
{
title: '流水号',
dataIndex: 'flowNo',
key: 'flowNo',
align: 'center',
},
{
title: '卡类型',
dataIndex: 'cardType',
key: 'cardType',
align: 'center',
},
{
title: '发卡行',
dataIndex: 'postCardType',
key: 'postCardType',
align: 'center',
},
{
title: '支付方式',
dataIndex: 'payType',
key: 'payType',
align: 'center',
},
{
title: '银商订单号',
dataIndex: 'orderNo',
key: 'orderNo',
align: 'center',
},
{
title: '支付时间',
dataIndex: 'payTime',
key: 'payTime',
align: 'center',
},
]);
/* 搜索 */
const reload = (where?: ThinkFtpCheckBillParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkFtpCheckBill) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ThinkFtpCheckBill) => {
const hide = message.loading('请求中..', 0);
removeThinkFtpCheckBill(row.thinkFtpCheckBillId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkFtpCheckBill(selection.value.map((d) => d.thinkFtpCheckBillId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ThinkFtpCheckBill) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ThinkFtpCheckBill'
};
</script>
<style lang="less" scoped></style>
@@ -117,11 +117,11 @@
v-model:value="form.email"
/>
</a-form-item>
<a-form-item label="备注信息" name="info">
<a-form-item label="备注信息" name="remark">
<a-input
allow-clear
placeholder="请输入备注信息"
v-model:value="form.info"
v-model:value="form.remark"
/>
</a-form-item>
<a-form-item label="是否已开:1已开,2未开" name="isOpen">
+23 -6
View File
@@ -58,10 +58,14 @@
发票额度已不够使用
</template>
</p>
<a-space v-if="record.isOpen === 2 && record.status === 0">
<a @click="openInvoice(record)">开票</a>
<a-divider type="vertical" />
<a class="ele-text-danger" @click="refuse(record)">拒绝</a>
<a-space v-if="record.isOpen === 2">
<a @click="updateInvoiceStatus(record)">更新状态</a>
<template v-if="record.status === 0">
<a-divider type="vertical" />
<a @click="openInvoice(record)">开票</a>
<a-divider type="vertical" />
<a class="ele-text-danger" @click="refuse(record)">拒绝</a>
</template>
</a-space>
<span v-if="record.status === 2" class="ele-text-danger">已拒绝</span>
</template>
@@ -94,7 +98,7 @@ import ThinkInvoiceEdit from "./components/thinkInvoiceEdit.vue";
import {
pageThinkInvoice,
removeThinkInvoice,
removeBatchThinkInvoice, updateThinkInvoice, doInvoice, thinkInvoiceData
removeBatchThinkInvoice, updateThinkInvoice, doInvoice, thinkInvoiceData, getInvoiceRes
} from "@/api/think/thinkInvoice";
import type {
ThinkInvoice,
@@ -147,7 +151,7 @@ const columns = ref<ColumnItem[]>([
{
title: "操作",
key: "action",
width: 180,
width: 220,
fixed: "left",
align: "center",
hideInSetting: true
@@ -312,6 +316,19 @@ const openInvoice = async (row: ThinkInvoice) => {
reload();
};
const updateInvoiceStatus = async (row: ThinkInvoice) => {
const hide = message.loading("请求中..", 0);
try {
await getInvoiceRes({ id: row.id });
hide();
message.success("状态已更新");
reload();
} catch (e) {
hide();
message.error((e as Error).message);
}
};
const refuse = async (row: ThinkInvoice) => {
await updateThinkInvoice({
id: row.id,
@@ -5,7 +5,7 @@
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '开具发票2' : '开具发票'"
:title="isUpdate ? '开具发票' : '开具发票'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
@@ -103,12 +103,12 @@
v-model:value="form.email"
/>
</a-form-item>
<a-form-item label="备注信息" name="info">
<a-form-item label="备注信息" name="remark">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入备注信息"
v-model:value="form.info"
v-model:value="form.remark"
/>
</a-form-item>
<a-form-item label="发票类型" name="type">
@@ -212,7 +212,6 @@
price: [
{
required: true,
type: 'number',
message: '请填写发票金额',
trigger: 'blur'
}
@@ -82,12 +82,12 @@
v-model:value="form.email"
/>
</a-form-item>
<a-form-item label="备注信息" name="info">
<a-form-item label="备注信息" name="remark">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入备注信息"
v-model:value="form.info"
v-model:value="form.remark"
/>
</a-form-item>
<a-form-item label="发票类型" name="type">
@@ -86,17 +86,19 @@
<a-tag v-if="form.payType == 4">现金</a-tag>
<a-tag v-if="form.payType == 5">POS机</a-tag>
<a-tag v-if="form.payType == 6">VIP月卡</a-tag>
<a-tag v-if="form.payType == 7">formVIP年卡</a-tag>
<a-tag v-if="form.payType == 8">formVIP次卡</a-tag>
<a-tag v-if="form.payType == 9">formIC月卡</a-tag>
<a-tag v-if="form.payType == 10">formIC年卡</a-tag>
<a-tag v-if="form.payType == 11">formIC次卡</a-tag>
<a-tag v-if="form.payType == 12">form免费</a-tag>
<a-tag v-if="form.payType == 13">formVIP充值卡</a-tag>
<a-tag v-if="form.payType == 14">formIC充值卡</a-tag>
<a-tag v-if="form.payType == 15">form积分支付</a-tag>
<a-tag v-if="form.payType == 16">formVIP季卡</a-tag>
<a-tag v-if="form.payType == 17">formIC季卡</a-tag>
<a-tag v-if="form.payType == 7">VIP年卡</a-tag>
<a-tag v-if="form.payType == 8">VIP次卡</a-tag>
<a-tag v-if="form.payType == 9">IC月卡</a-tag>
<a-tag v-if="form.payType == 10">IC年卡</a-tag>
<a-tag v-if="form.payType == 11">IC次卡</a-tag>
<a-tag v-if="form.payType == 12">免费</a-tag>
<a-tag v-if="form.payType == 13">VIP充值卡</a-tag>
<a-tag v-if="form.payType == 14">IC充值卡</a-tag>
<a-tag v-if="form.payType == 15">积分支付</a-tag>
<a-tag v-if="form.payType == 16">VIP季卡</a-tag>
<a-tag v-if="form.payType == 17">IC季卡</a-tag>
<a-tag v-if="form.payType == 18">对公</a-tag>
<a-tag v-if="form.payType == 19">余额</a-tag>
</template>
<template v-else>
<span></span>
@@ -40,6 +40,8 @@
<a-select-option :value="15">积分支付</a-select-option>
<a-select-option :value="16">VIP季卡</a-select-option>
<a-select-option :value="17">IC季卡</a-select-option>
<a-select-option :value="18">对公</a-select-option>
<a-select-option :value="19">余额</a-select-option>
</a-select>
<span class="text-gray-400">开票状态</span>
<a-select v-model:value="where.isInvoice" style="width: 150px" placeholder="开票状态筛选" @change="search">
@@ -102,7 +104,7 @@ import { utils, writeFile } from "xlsx";
import { message } from "ant-design-vue";
import { toDateString } from "ele-admin-pro";
import dayjs from "dayjs";
import { listThinkOrder, updateThinkOrder } from "@/api/think/thinkOrder";
import { listThinkOrder, setThinkOrderInvoice } from "@/api/think/thinkOrder";
import { ThinkOrder, ThinkOrderParam } from "@/api/think/thinkOrder/model";
import { ThinkSite } from "@/api/think/thinkSite/model";
@@ -256,16 +258,28 @@ const handleExport2 = async () => {
};
const setHasInvoice = async () => {
const hide = message.loading("请求中..", 0);
if (props.selection) {
props.selection.filter(item => item.isInvoice === 2).map(async item => {
item.isInvoice = 1;
await updateThinkOrder(item);
});
if (!props.selection?.length) {
message.warning("请选择订单");
return;
}
const ids = props.selection
.filter((item) => item.isInvoice === 2)
.map((item) => item.id)
.filter((id): id is number => id != null);
if (!ids.length) {
message.warning("请选择未开票的订单");
return;
}
const hide = message.loading("请求中..", 0);
try {
await setThinkOrderInvoice(ids);
message.success("设置成功");
search();
} catch (e: any) {
message.error(e?.message || "设置失败");
} finally {
hide();
}
hide();
message.success("设置成功");
};
const openInvoiceByList = async () => {
+6
View File
@@ -104,6 +104,12 @@
<IdcardOutlined class="tag-icon" />
IC季卡
</a-tag>
<a-tag v-if="record.payType == 18">
对公
</a-tag>
<a-tag v-if="record.payType == 19">
余额
</a-tag>
</template>
<template v-else>
<span></span>
@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>
@@ -0,0 +1,249 @@
<!-- 编辑弹窗 -->
<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="oid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.oid"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="原价" name="originAmount">
<a-input
allow-clear
placeholder="请输入原价"
v-model:value="form.originAmount"
/>
</a-form-item>
<a-form-item label="折扣" name="rate">
<a-input
allow-clear
placeholder="请输入折扣"
v-model:value="form.rate"
/>
</a-form-item>
<a-form-item label="折后价" name="offAmount">
<a-input
allow-clear
placeholder="请输入折后价"
v-model:value="form.offAmount"
/>
</a-form-item>
<a-form-item label="申请原因" name="reqReason">
<a-input
allow-clear
placeholder="请输入申请原因"
v-model:value="form.reqReason"
/>
</a-form-item>
<a-form-item label="拒绝原因" name="refuseReason">
<a-input
allow-clear
placeholder="请输入拒绝原因"
v-model:value="form.refuseReason"
/>
</a-form-item>
<a-form-item label="审核人" name="checkUid">
<a-input
allow-clear
placeholder="请输入审核人"
v-model:value="form.checkUid"
/>
</a-form-item>
<a-form-item label="状态, 0已发布, 1待审核 2已驳回 3违规内容" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</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 { addThinkOrderOffCheck, updateThinkOrderOffCheck } from '@/api/think/thinkOrderOffCheck';
import { ThinkOrderOffCheck } from '@/api/think/thinkOrderOffCheck/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?: ThinkOrderOffCheck | 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<ThinkOrderOffCheck>({
id: undefined,
oid: undefined,
userId: undefined,
originAmount: undefined,
rate: undefined,
offAmount: undefined,
reqReason: undefined,
refuseReason: undefined,
checkUid: undefined,
tenantId: undefined,
status: undefined,
deleted: undefined,
createTime: undefined,
updateTime: undefined,
thinkOrderOffCheckId: undefined,
thinkOrderOffCheckName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
thinkOrderOffCheckName: [
{
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 ? updateThinkOrderOffCheck : addThinkOrderOffCheck;
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>
@@ -0,0 +1,281 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="thinkOrderOffCheckId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ThinkOrderOffCheckEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkOrderOffCheckEdit from './components/thinkOrderOffCheckEdit.vue';
import { pageThinkOrderOffCheck, removeThinkOrderOffCheck, removeBatchThinkOrderOffCheck } from '@/api/think/thinkOrderOffCheck';
import type { ThinkOrderOffCheck, ThinkOrderOffCheckParam } from '@/api/think/thinkOrderOffCheck/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ThinkOrderOffCheck[]>([]);
// 当前编辑数据
const current = ref<ThinkOrderOffCheck | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageThinkOrderOffCheck({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'oid',
key: 'oid',
align: 'center',
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '原价',
dataIndex: 'originAmount',
key: 'originAmount',
align: 'center',
},
{
title: '折扣',
dataIndex: 'rate',
key: 'rate',
align: 'center',
},
{
title: '折后价',
dataIndex: 'offAmount',
key: 'offAmount',
align: 'center',
},
{
title: '申请原因',
dataIndex: 'reqReason',
key: 'reqReason',
align: 'center',
},
{
title: '拒绝原因',
dataIndex: 'refuseReason',
key: 'refuseReason',
align: 'center',
},
{
title: '审核人',
dataIndex: 'checkUid',
key: 'checkUid',
align: 'center',
},
{
title: '状态, 0已发布, 1待审核 2已驳回 3违规内容',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ThinkOrderOffCheckParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkOrderOffCheck) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ThinkOrderOffCheck) => {
const hide = message.loading('请求中..', 0);
removeThinkOrderOffCheck(row.thinkOrderOffCheckId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkOrderOffCheck(selection.value.map((d) => d.thinkOrderOffCheckId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ThinkOrderOffCheck) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ThinkOrderOffCheck'
};
</script>
<style lang="less" scoped></style>
@@ -173,14 +173,17 @@
<a-switch v-model:checked="form.childFree" :checked-value="1" :un-checked-value="0"/>
</a-form-item>
</template>
<a-form-item label="是否开启">
<a-switch v-model:checked="form.isOn" :checked-value="1" :un-checked-value="0"/>
</a-form-item>
<a-form-item label="每天人数上限" extra="-1为不限制">
<a-input-number v-model:value="form.dailyMaxNum" />
</a-form-item>
<a-form-item label="排序" name="sortNumber">
<a-form-item label="排序" name="sort">
<a-input
allow-clear
placeholder="请输入排序"
v-model:value="form.sortNumber"
v-model:value="form.sort"
/>
</a-form-item>
</a-form>
@@ -253,6 +256,7 @@ const form = reactive<ThinkSite>({
info: undefined,
tel: undefined,
sortNumber: undefined,
sort: undefined,
type: undefined,
num: undefined,
proportion: undefined,
@@ -261,6 +265,7 @@ const form = reactive<ThinkSite>({
updateTime: undefined,
weekendOpen: undefined,
dailyMaxNum: -1,
isOn: 1,
album: '',
});
+3 -1
View File
@@ -102,7 +102,9 @@
// 表格数据源
const datasource: DatasourceFunction = () => {
return listThinkSite();
return listThinkSite({
isAdmin: true
});
};
// 表格列配置
@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>
@@ -0,0 +1,201 @@
<!-- 编辑弹窗 -->
<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="cid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.cid"
/>
</a-form-item>
<a-form-item label="" name="vid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.vid"
/>
</a-form-item>
<a-form-item label="" name="uid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.uid"
/>
</a-form-item>
<a-form-item label="" name="amount">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.amount"
/>
</a-form-item>
<a-form-item label="" name="updateTime">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.updateTime"
/>
</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 { addThinkSmallRecharge, updateThinkSmallRecharge } from '@/api/think/thinkSmallRecharge';
import { ThinkSmallRecharge } from '@/api/think/thinkSmallRecharge/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?: ThinkSmallRecharge | 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<ThinkSmallRecharge>({
id: undefined,
cid: undefined,
vid: undefined,
uid: undefined,
amount: undefined,
createTime: undefined,
updateTime: undefined,
thinkSmallRechargeId: undefined,
thinkSmallRechargeName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
thinkSmallRechargeName: [
{
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 ? updateThinkSmallRecharge : addThinkSmallRecharge;
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>
@@ -0,0 +1,245 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="thinkSmallRechargeId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ThinkSmallRechargeEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkSmallRechargeEdit from './components/thinkSmallRechargeEdit.vue';
import { pageThinkSmallRecharge, removeThinkSmallRecharge, removeBatchThinkSmallRecharge } from '@/api/think/thinkSmallRecharge';
import type { ThinkSmallRecharge, ThinkSmallRechargeParam } from '@/api/think/thinkSmallRecharge/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ThinkSmallRecharge[]>([]);
// 当前编辑数据
const current = ref<ThinkSmallRecharge | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageThinkSmallRecharge({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'cid',
key: 'cid',
align: 'center',
},
{
title: '',
dataIndex: 'vid',
key: 'vid',
align: 'center',
},
{
title: '',
dataIndex: 'uid',
key: 'uid',
align: 'center',
},
{
title: '',
dataIndex: 'amount',
key: 'amount',
align: 'center',
},
{
title: '下单时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ThinkSmallRechargeParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkSmallRecharge) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ThinkSmallRecharge) => {
const hide = message.loading('请求中..', 0);
removeThinkSmallRecharge(row.thinkSmallRechargeId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkSmallRecharge(selection.value.map((d) => d.thinkSmallRechargeId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ThinkSmallRecharge) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ThinkSmallRecharge'
};
</script>
<style lang="less" scoped></style>
@@ -0,0 +1,72 @@
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-input-search
v-model:value="where.keywords"
allow-clear
placeholder="请输入机构名称/联系人/联系方式"
style="width: 320px"
@pressEnter="search"
@search="search"
/>
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
<a-button @click="reset">重置</a-button>
<a-button danger :disabled="!selection?.length" @click="remove">
批量删除
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue';
import useSearch from '@/utils/use-search';
import type { ThinkTrainingInstitutionParam } from '@/api/think/thinkTrainingInstitution/model';
const props = withDefaults(
defineProps<{
selection?: unknown[];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: ThinkTrainingInstitutionParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
const { where, resetFields } = useSearch<ThinkTrainingInstitutionParam>({
id: undefined,
keywords: undefined
});
const search = () => {
emit('search', {
...where
});
};
const add = () => {
emit('add');
};
const remove = () => {
emit('remove');
};
const reset = () => {
resetFields();
search();
};
watch(
() => props.selection,
() => {}
);
</script>
@@ -0,0 +1,171 @@
<template>
<ele-modal
:width="640"
: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: 5, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 18, sm: 18, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="机构名称" name="name">
<a-input
v-model:value="form.name"
allow-clear
maxlength="50"
placeholder="请输入机构名称"
/>
</a-form-item>
<a-form-item label="联系人" name="contactName">
<a-input
v-model:value="form.contactName"
allow-clear
maxlength="20"
placeholder="请输入联系人"
/>
</a-form-item>
<a-form-item label="联系方式" name="contactPhone">
<a-input
v-model:value="form.contactPhone"
allow-clear
maxlength="20"
placeholder="请输入联系方式"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { phoneReg } from 'ele-admin-pro/es';
import { storeToRefs } from 'pinia';
import type { FormInstance } from 'ant-design-vue/es/form';
import { useThemeStore } from '@/store/modules/theme';
import {
addThinkTrainingInstitution,
updateThinkTrainingInstitution
} from '@/api/think/thinkTrainingInstitution';
import type { ThinkTrainingInstitution } from '@/api/think/thinkTrainingInstitution/model';
const isUpdate = ref(false);
const useForm = Form.useForm;
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
visible: boolean;
data?: ThinkTrainingInstitution | 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 form = reactive<ThinkTrainingInstitution>({
id: undefined,
name: undefined,
contactName: undefined,
contactPhone: undefined,
createTime: undefined
});
const rules = reactive({
name: [
{
required: true,
type: 'string',
message: '请输入机构名称',
trigger: 'blur'
}
],
contactName: [
{
required: true,
type: 'string',
message: '请输入联系人',
trigger: 'blur'
}
],
contactPhone: [
{
required: true,
type: 'string',
message: '请输入联系方式',
trigger: 'blur'
},
{
pattern: phoneReg,
message: '请输入正确的手机号',
trigger: 'blur'
}
]
});
const { resetFields } = useForm(form, rules);
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const save = () => {
if (!formRef.value || loading.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const request = isUpdate.value
? updateThinkTrainingInstitution
: addThinkTrainingInstitution;
request({ ...form })
.then((msg) => {
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
message.error(e.message);
})
.finally(() => {
loading.value = false;
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>
@@ -0,0 +1,201 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
:selection="selection"
@search="reload"
@add="openEdit"
@remove="removeBatch"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm title="确定要删除此记录吗?" @confirm="remove(record)">
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<ThinkTrainingInstitutionEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkTrainingInstitutionEdit from './components/thinkTrainingInstitutionEdit.vue';
import {
pageThinkTrainingInstitution,
removeBatchThinkTrainingInstitution,
removeThinkTrainingInstitution
} from '@/api/think/thinkTrainingInstitution';
import type {
ThinkTrainingInstitution,
ThinkTrainingInstitutionParam
} from '@/api/think/thinkTrainingInstitution/model';
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const selection = ref<ThinkTrainingInstitution[]>([]);
const current = ref<ThinkTrainingInstitution | null>(null);
const showEdit = ref(false);
const loading = ref(true);
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
return pageThinkTrainingInstitution({
...where,
...orders,
page,
limit
});
};
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
width: 90,
align: 'center'
},
{
title: '机构名称',
dataIndex: 'name',
key: 'name',
align: 'center'
},
{
title: '联系人',
dataIndex: 'contactName',
key: 'contactName',
align: 'center'
},
{
title: '联系方式',
dataIndex: 'contactPhone',
key: 'contactPhone',
align: 'center'
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
const reload = (where?: ThinkTrainingInstitutionParam) => {
selection.value = [];
tableRef?.value?.reload({ where });
};
const openEdit = (row?: ThinkTrainingInstitution) => {
current.value = row ?? null;
showEdit.value = true;
};
const remove = (row: ThinkTrainingInstitution) => {
const hide = message.loading('请求中..', 0);
removeThinkTrainingInstitution(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkTrainingInstitution(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
const query = () => {
loading.value = true;
};
const customRow = (record: ThinkTrainingInstitution) => {
return {
onClick: () => {
selection.value = selection.value;
},
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ThinkTrainingInstitution'
};
</script>
<style lang="less" scoped></style>
@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>
@@ -0,0 +1,168 @@
<!-- 编辑弹窗 -->
<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="uid">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.uid"
/>
</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 { addThinkUserInAccess, updateThinkUserInAccess } from '@/api/think/thinkUserInAccess';
import { ThinkUserInAccess } from '@/api/think/thinkUserInAccess/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?: ThinkUserInAccess | 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<ThinkUserInAccess>({
id: undefined,
uid: undefined,
thinkUserInAccessId: undefined,
thinkUserInAccessName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
thinkUserInAccessName: [
{
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 ? updateThinkUserInAccess : addThinkUserInAccess;
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>
+212
View File
@@ -0,0 +1,212 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="thinkUserInAccessId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ThinkUserInAccessEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkUserInAccessEdit from './components/thinkUserInAccessEdit.vue';
import { pageThinkUserInAccess, removeThinkUserInAccess, removeBatchThinkUserInAccess } from '@/api/think/thinkUserInAccess';
import type { ThinkUserInAccess, ThinkUserInAccessParam } from '@/api/think/thinkUserInAccess/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ThinkUserInAccess[]>([]);
// 当前编辑数据
const current = ref<ThinkUserInAccess | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageThinkUserInAccess({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'uid',
key: 'uid',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ThinkUserInAccessParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkUserInAccess) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ThinkUserInAccess) => {
const hide = message.loading('请求中..', 0);
removeThinkUserInAccess(row.thinkUserInAccessId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkUserInAccess(selection.value.map((d) => d.thinkUserInAccessId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ThinkUserInAccess) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ThinkUserInAccess'
};
</script>
<style lang="less" scoped></style>
@@ -0,0 +1,152 @@
<template>
<ele-modal
:width="500"
:visible="visible"
:confirm-loading="loading"
title="余额充值"
:body-style="{ paddingBottom: '8px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 7, sm: 4, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 17, sm: 20, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="充值金额" name="money">
<a-input-number
v-model:value="form.money"
:min="0.01"
:precision="2"
placeholder="请输入金额"
style="width: 280px"
/>
</a-form-item>
<a-form-item label="备注" name="remark">
<a-textarea
v-model:value="form.remark"
:rows="4"
:maxlength="200"
style="width: 280px"
placeholder="请输入备注"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue';
import { message } from 'ant-design-vue/es';
import type { FormInstance, Rule } from 'ant-design-vue/es/form';
import { storeToRefs } from 'pinia';
import { useThemeStore } from '@/store/modules/theme';
import useFormData from '@/utils/use-form-data';
import { addUserBalanceLog } from '@/api/shop/userBalanceLog';
import type { ThinkUsers } from '@/api/think/thinkUsers/model';
interface RechargeForm {
money?: number;
remark?: string;
}
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const props = defineProps<{
visible: boolean;
data?: ThinkUsers | null;
}>();
const formRef = ref<FormInstance | null>(null);
const loading = ref(false);
const { form, resetFields } = useFormData<RechargeForm>({
money: undefined,
remark: ''
});
const rules = reactive<Record<string, Rule[]>>({
money: [
{
required: true,
type: 'number',
message: '请输入充值金额',
trigger: 'blur'
}
],
remark: [
{
required: true,
type: 'string',
message: '请输入备注',
trigger: 'blur'
}
]
});
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const getCurrentBalance = () => {
const balance = Number((props.data as ThinkUsers & { balance?: string })?.balance);
if (!Number.isNaN(balance)) {
return balance;
}
return Number(props.data?.money ?? 0);
};
const save = () => {
if (!formRef.value || !props.data?.id) {
return;
}
formRef.value
.validate()
.then(() => {
const amount = Number(form.money ?? 0);
const currentBalance = getCurrentBalance();
loading.value = true;
addUserBalanceLog({
userId: props.data?.userId,
scene: 2,
money: String(amount),
balance: String(Number((currentBalance + amount).toFixed(2))),
remark: form.remark,
comments: form.remark,
status: 0,
deleted: 0
})
.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) {
resetFields();
formRef.value?.clearValidate();
}
}
);
</script>
+19 -3
View File
@@ -49,7 +49,7 @@
</template>
<template v-if="column.key === 'action'">
<a-space>
<a>积分充值</a>
<a @click="openRecharge(record)" v-if="!!record.userId">余额充值</a>
<!-- <a @click="openEdit(record)">修改</a>-->
<!-- <a-divider type="vertical" />-->
<!-- <a-popconfirm-->
@@ -66,6 +66,11 @@
<!-- 编辑弹窗 -->
<Edit v-model:visible="showEdit" :data="current" @done="reload" />
<BalanceRecharge
v-model:visible="showRecharge"
:data="rechargeCurrent"
@done="reload"
/>
</div>
</div>
</template>
@@ -83,6 +88,7 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import Edit from './components/thinkUsersEdit.vue';
import BalanceRecharge from './components/balanceRecharge.vue';
import {
pageThinkUsers,
removeThinkUsers,
@@ -101,8 +107,12 @@
const selection = ref<ThinkUsers[]>([]);
// 当前编辑数据
const current = ref<ThinkUsers | null>(null);
// 当前充值数据
const rechargeCurrent = ref<ThinkUsers | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示充值弹窗
const showRecharge = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
@@ -183,8 +193,8 @@
},
{
title: '余额',
dataIndex: 'money',
key: 'money',
dataIndex: 'balance',
key: 'balance',
align: 'center',
sorter: true
},
@@ -254,6 +264,12 @@
showEdit.value = true;
};
/* 打开充值弹窗 */
const openRecharge = (row: ThinkUsers) => {
rechargeCurrent.value = row;
showRecharge.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
@@ -0,0 +1,85 @@
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-input
v-model:value="where.uid"
allow-clear
placeholder="请输入用户ID"
style="width: 180px"
@pressEnter="search"
/>
<a-select
v-model:value="where.status"
allow-clear
placeholder="请选择状态"
style="width: 160px"
@change="search"
>
<a-select-option :value="1">生效中</a-select-option>
<a-select-option :value="2">已失效</a-select-option>
</a-select>
<a-button type="primary" class="ele-btn-icon" @click="search">
查询
</a-button>
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
<a-button @click="reset">重置</a-button>
<a-button danger :disabled="!selection?.length" @click="remove">
批量删除
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import { watch } from 'vue';
import useSearch from '@/utils/use-search';
import type { ThinkUsersBlackParam } from '@/api/think/thinkUsersBlack/model';
const props = withDefaults(
defineProps<{
selection?: unknown[];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: ThinkUsersBlackParam): void;
(e: 'add'): void;
(e: 'remove'): void;
}>();
const { where, resetFields } = useSearch<ThinkUsersBlackParam>({
id: undefined,
uid: undefined,
status: undefined,
expireTime: undefined
});
const search = () => {
emit('search', {
...where
});
};
const add = () => {
emit('add');
};
const remove = () => {
emit('remove');
};
const reset = () => {
resetFields();
search();
};
watch(
() => props.selection,
() => {}
);
</script>
@@ -0,0 +1,211 @@
<template>
<ele-modal
:width="640"
: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: 5, sm: 5, xs: 24 } : { flex: '100px' }
"
:wrapper-col="
styleResponsive ? { md: 18, sm: 18, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="选择用户" name="uid">
<a-space direction="vertical" class="ele-fluid" :size="8">
<a-space v-if="selectedUser">
<a-tag color="blue">UID:{{ form.uid }}</a-tag>
<span>
{{
selectedUser.truename || selectedUser.username || '未命名用户'
}}
/ {{ selectedUser.phone || '未绑定手机号' }}
</span>
<a-button type="link" @click="clearSelectedUser">清空</a-button>
</a-space>
<a-button class="ele-fluid" @click="showUserSelect = true">
{{ selectedUser ? '重新选择用户' : '按手机号/姓名搜索并选择用户' }}
</a-button>
</a-space>
</a-form-item>
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="1">生效中</a-radio>
<a-radio :value="2">已失效</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="失效时间" name="expireTime">
<a-date-picker
v-model:value="form.expireTime"
show-time
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="请选择失效时间"
class="ele-fluid"
/>
</a-form-item>
</a-form>
<SelectUserData
v-model:visible="showUserSelect"
title="按手机号/姓名搜索用户"
@done="selectUser"
/>
</ele-modal>
</template>
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { storeToRefs } from 'pinia';
import type { FormInstance } from 'ant-design-vue/es/form';
import { useThemeStore } from '@/store/modules/theme';
import {
addThinkUsersBlack,
updateThinkUsersBlack
} from '@/api/think/thinkUsersBlack';
import { listThinkUsers } from '@/api/think/thinkUsers';
import type { ThinkUsersBlack } from '@/api/think/thinkUsersBlack/model';
import type { ThinkUsers } from '@/api/think/thinkUsers/model';
import SelectUserData from '@/components/ThinkSelectUsers/components/select-data.vue';
const isUpdate = ref(false);
const useForm = Form.useForm;
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
visible: boolean;
data?: ThinkUsersBlack | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const loading = ref(false);
const userLoading = ref(false);
const maxable = ref(true);
const formRef = ref<FormInstance | null>(null);
const showUserSelect = ref(false);
const selectedUser = ref<ThinkUsers | null>(null);
const form = reactive<ThinkUsersBlack>({
id: undefined,
uid: undefined,
status: 1,
expireTime: undefined,
createTime: undefined
});
const rules = reactive({
uid: [
{
required: true,
type: 'number',
message: '请选择用户',
trigger: 'change'
}
],
status: [
{
required: true,
type: 'number',
message: '请选择状态',
trigger: 'change'
}
]
});
const { resetFields } = useForm(form, rules);
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const selectUser = (user: ThinkUsers) => {
form.uid = user.id;
selectedUser.value = user;
};
const clearSelectedUser = () => {
form.uid = undefined;
selectedUser.value = null;
};
const loadSelectedUser = async (uid?: number) => {
if (!uid) {
selectedUser.value = null;
return;
}
userLoading.value = true;
try {
const users = await listThinkUsers({
id: uid
});
selectedUser.value = users?.[0] ?? null;
} catch (e) {
selectedUser.value = null;
} finally {
userLoading.value = false;
}
};
const save = () => {
if (!formRef.value || loading.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const request = isUpdate.value
? updateThinkUsersBlack
: addThinkUsersBlack;
request({ ...form })
.then((msg) => {
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
message.error(e.message);
})
.finally(() => {
loading.value = false;
});
})
.catch(() => {});
};
watch(
() => props.visible,
async (visible) => {
if (visible) {
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
await loadSelectedUser(props.data.uid);
} else {
isUpdate.value = false;
form.status = 1;
clearSelectedUser();
}
} else {
resetFields();
clearSelectedUser();
}
},
{ immediate: true }
);
</script>
+222
View File
@@ -0,0 +1,222 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
:selection="selection"
@search="reload"
@add="openEdit"
@remove="removeBatch"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 1" color="red">生效中</a-tag>
<a-tag v-else-if="record.status === 2" color="green"
>已失效</a-tag
>
<a-tag v-else>未知</a-tag>
</template>
<template v-if="column.key === 'expireTime'">
{{
record.expireTime
? toDateString(record.expireTime, 'yyyy-MM-dd HH:mm')
: '-'
}}
</template>
<template v-if="column.key === 'createTime'">
{{
record.createTime
? toDateString(record.createTime, 'yyyy-MM-dd HH:mm')
: '-'
}}
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<ThinkUsersBlackEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkUsersBlackEdit from './components/thinkUsersBlackEdit.vue';
import {
pageThinkUsersBlack,
removeBatchThinkUsersBlack,
removeThinkUsersBlack
} from '@/api/think/thinkUsersBlack';
import type {
ThinkUsersBlack,
ThinkUsersBlackParam
} from '@/api/think/thinkUsersBlack/model';
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const selection = ref<ThinkUsersBlack[]>([]);
const current = ref<ThinkUsersBlack | null>(null);
const showEdit = ref(false);
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
return pageThinkUsersBlack({
...where,
...orders,
page,
limit
});
};
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
width: 90,
align: 'center'
},
{
title: '姓名',
dataIndex: 'truename',
key: 'truename',
align: 'center'
},
{
title: '手机号',
dataIndex: 'phone',
key: 'phone',
align: 'center'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center'
},
{
title: '失效时间',
dataIndex: 'expireTime',
key: 'expireTime',
align: 'center',
width: 180
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
width: 180
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
const reload = (where?: ThinkUsersBlackParam) => {
selection.value = [];
tableRef?.value?.reload({ where });
};
const openEdit = (row?: ThinkUsersBlack) => {
current.value = row ?? null;
showEdit.value = true;
};
const remove = (row: ThinkUsersBlack) => {
const hide = message.loading('请求中..', 0);
removeThinkUsersBlack(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkUsersBlack(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
const customRow = (record: ThinkUsersBlack) => {
return {
onDblclick: () => {
openEdit(record);
}
};
};
</script>
<script lang="ts">
export default {
name: 'ThinkUsersBlack'
};
</script>
<style lang="less" scoped></style>
+519 -333
View File
@@ -4,10 +4,9 @@
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="thinkUsersVipId"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
:scroll="{ x: 3000 }"
tool-class="ele-toolbar-form"
class="sys-org-table"
@@ -38,10 +37,86 @@
class="cursor-pointer"
v-if="record.remainingMoney === record.price"
color="red"
>全额退款
>全额退款
</a-tag>
</a-space>
</template>
<template v-if="column.key === 'expireTime'">
<a-date-picker
show-time
value-format="YYYY-MM-DD HH:mm:ss"
:value="formatExpireTime(record.expireTime)"
:disabled="expireTimeLoading[record.id || 0]"
style="width: 200px"
placeholder="请选择到期时间"
:allow-clear="false"
@change="(value) => changeExpireTime(value, record)"
/>
</template>
<template v-if="column.key === 'num'">
<a-space>
<template v-if="isRemainingEditing(record, 'num')">
<a-input
type="number"
:value="getRemainingDraft(record, 'num')"
:disabled="isRemainingLoading(record.id, 'num')"
style="width: 90px"
@update:value="
(value) => setRemainingDraft(record, 'num', value)
"
/>
<a-button
type="link"
size="small"
:loading="isRemainingLoading(record.id, 'num')"
@click="saveRemaining(record, 'num')"
>确认</a-button
>
</template>
<template v-else>
<span>{{ record.num ?? '-' }}</span>
<a-button
v-if="hasPermission('think:thinkUsersVip:changeRemain')"
type="link"
size="small"
@click="editRemaining(record, 'num')"
>修改</a-button
>
</template>
</a-space>
</template>
<template v-if="column.key === 'remainingMoney'">
<a-space>
<template v-if="isRemainingEditing(record, 'remainingMoney')">
<a-input
:value="getRemainingDraft(record, 'remainingMoney')"
:disabled="isRemainingLoading(record.id, 'remainingMoney')"
style="width: 100px"
@update:value="
(value) =>
setRemainingDraft(record, 'remainingMoney', value)
"
/>
<a-button
type="link"
size="small"
:loading="isRemainingLoading(record.id, 'remainingMoney')"
@click="saveRemaining(record, 'remainingMoney')"
>确认</a-button
>
</template>
<template v-else>
<span>{{ record.remainingMoney ?? '-' }}</span>
<a-button
v-if="hasPermission('think:thinkUsersVip:changeRemain')"
type="link"
size="small"
@click="editRemaining(record, 'remainingMoney')"
>修改</a-button
>
</template>
</a-space>
</template>
<template v-if="column.key === 'action'">
<a-space v-if="record.status === 1">
<ThinkSelectUsers :id="record.id" @done="changeBindCard" />
@@ -70,354 +145,465 @@
:data="current"
@done="reload"
/>
<ThinkUsersVipLog v-if="showLog"
v-model:visible="showLog"
:data="current"
@done="reload"
<ThinkUsersVipLog
v-if="showLog"
v-model:visible="showLog"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from "vue";
import { message, Modal } from "ant-design-vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import type { EleProTable } from "ele-admin-pro";
import { toDateString } from "ele-admin-pro";
import type {
DatasourceFunction,
ColumnItem
} from "ele-admin-pro/es/ele-pro-table/types";
import Search from "./components/search.vue";
import ThinkUsersVipEdit from "./components/thinkUsersVipEdit.vue";
import {
pageThinkUsersVip,
removeThinkUsersVip,
removeBatchThinkUsersVip, updateThinkUsersVip
} from "@/api/think/thinkUsersVip";
import type {
ThinkUsersVip,
ThinkUsersVipParam
} from "@/api/think/thinkUsersVip/model";
import ThinkUsersVipLog from "@/views/think/thinkUsersVip/components/thinkUsersVipLog.vue";
import { ThinkUsers } from "@/api/think/thinkUsers/model";
import { createVNode, reactive, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import dayjs from 'dayjs';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ThinkUsersVipEdit from './components/thinkUsersVipEdit.vue';
import {
pageThinkUsersVip,
removeThinkUsersVip,
removeBatchThinkUsersVip,
updateThinkUsersVip,
updateThinkUsersVipRemaining
} from '@/api/think/thinkUsersVip';
import type {
ThinkUsersVip,
ThinkUsersVipParam
} from '@/api/think/thinkUsersVip/model';
import ThinkUsersVipLog from '@/views/think/thinkUsersVip/components/thinkUsersVipLog.vue';
import { ThinkUsers } from '@/api/think/thinkUsers/model';
import { hasPermission } from '@/utils/permission';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ThinkUsersVip[]>([]);
// 当前编辑数据
const current = ref<ThinkUsersVip | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格选中数据
const selection = ref<ThinkUsersVip[]>([]);
// 当前编辑数据
const current = ref<ThinkUsersVip | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
where.forAdmin = true;
return pageThinkUsersVip({
...where,
...orders,
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: "操作",
key: "action",
width: 250,
fixed: "left",
align: "center",
hideInSetting: true
},
{
title: "手机号码",
dataIndex: "phone",
key: "phone",
fixed: "left",
align: "center"
},
{
title: "真实姓名",
dataIndex: "realName",
key: "realName",
align: "center"
},
{
title: "订单号",
dataIndex: "wechatOrder",
align: "center"
},
{
title: "卡号",
dataIndex: "code",
key: "code",
align: "center"
},
{
title: "VIP卡名称",
dataIndex: "name",
key: "name",
align: "center"
},
{
title: "可用场馆",
dataIndex: "siteNames",
key: "siteNames",
ellipsis: true,
align: "center"
},
{
title: "购卡价格",
dataIndex: "price",
key: "price",
sorter: true,
align: "center"
},
{
title: "支付状态",
dataIndex: "status",
key: "status",
sorter: true,
width: 180,
align: "center"
},
{
title: "折扣率",
dataIndex: "discount",
key: "discount",
sorter: true,
align: "center"
},
{
title: "可使用次数",
dataIndex: "count",
key: "count",
sorter: true,
align: "center"
},
{
title: "剩余次数",
dataIndex: "num",
key: "num",
sorter: true,
align: "center"
},
{
title: "每使用一次减少的金额",
dataIndex: "eachMoney",
key: "eachMoney",
sorter: true,
align: "center"
},
{
title: "剩余金额",
dataIndex: "remainingMoney",
key: "remainingMoney",
sorter: true,
align: "center"
},
{
title: "月限",
dataIndex: "month",
key: "month",
sorter: true,
align: "center"
},
{
title: "年限",
dataIndex: "term",
key: "term",
sorter: true,
align: "center"
},
{
title: "会员卡类型",
dataIndex: "vipType",
key: "vipType",
align: "center",
sorter: true,
customRender: ({ text }) => ["", "特殊VIP卡", "普通VIP卡"][text]
},
{
title: "卡类型",
dataIndex: "cardType",
key: "cardType",
align: "center",
sorter: true,
customRender: ({ text }) => ["", "成人卡", "儿童卡", "不限"][text]
},
{
title: "会员卡类型",
dataIndex: "type",
key: "type",
align: "center",
sorter: true,
customRender: ({ text }) =>
["", "年卡", "次卡", "月卡", "会员VIP", "VIP充值卡"][text]
},
{
title: "是否赠送积分",
dataIndex: "isIntegral",
key: "isIntegral",
sorter: true,
align: "center",
customRender: ({ text }) => ["", "赠送", "不赠送"][text]
},
{
title: "是否已开具发票",
dataIndex: "isInvoice",
key: "isInvoice",
sorter: true,
align: "center",
customRender: ({ text }) => ["", "已开票", "未开票"][text]
},
{
title: "到期时间",
dataIndex: "expireTime",
key: "expireTime",
sorter: true,
align: "center",
customRender: ({ text }) => toDateString(text, "yyyy-MM-dd HH:mm:ss")
},
{
title: "购卡时间",
dataIndex: "createTime",
key: "createTime",
sorter: true,
align: "center",
customRender: ({ text }) => toDateString(text, "yyyy-MM-dd HH:mm:ss")
}
]);
/* 搜索 */
const reload = (where?: ThinkUsersVipParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkUsersVip) => {
current.value = row ?? null;
showEdit.value = true;
};
const release = async (row?: ThinkUsersVip) => {
await updateThinkUsersVip({
id: row?.id,
uid: 0
});
message.success("解绑成功");
reload();
};
const showLog = ref(false);
const openLog = (row?: ThinkUsersVip) => {
current.value = row ?? null;
showLog.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ThinkUsersVip) => {
const hide = message.loading("请求中..", 0);
removeThinkUsersVip(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error("请至少选择一条数据");
return;
}
Modal.confirm({
title: "提示",
content: "确定要删除选中的记录吗?",
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading("请求中..", 0);
removeBatchThinkUsersVip(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
});
};
where.forAdmin = true;
return pageThinkUsersVip({
...where,
...orders,
page,
limit
});
};
/* 查询 */
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 {
// 行点击事件
onClick: () => {
// console.log(record);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '操作',
key: 'action',
width: 250,
fixed: 'left',
align: 'center',
hideInSetting: true
},
// 行双击事件
onDblclick: () => {
openEdit(record);
{
title: '手机号码',
dataIndex: 'phone',
key: 'phone',
fixed: 'left',
align: 'center'
},
{
title: '真实姓名',
dataIndex: 'realName',
key: 'realName',
align: 'center'
},
{
title: '订单号',
dataIndex: 'wechatOrder',
align: 'center'
},
{
title: '卡号',
dataIndex: 'code',
key: 'code',
align: 'center'
},
{
title: 'VIP卡名称',
dataIndex: 'name',
key: 'name',
align: 'center'
},
{
title: '可用场馆',
dataIndex: 'siteNames',
key: 'siteNames',
ellipsis: true,
align: 'center'
},
{
title: '购卡价格',
dataIndex: 'price',
key: 'price',
sorter: true,
align: 'center'
},
{
title: '支付状态',
dataIndex: 'status',
key: 'status',
sorter: true,
width: 180,
align: 'center'
},
{
title: '购卡时间',
dataIndex: 'createTime',
key: 'createTime',
sorter: true,
align: 'center',
width: 240,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
},
{
title: '到期时间',
dataIndex: 'expireTime',
key: 'expireTime',
sorter: true,
width: 240,
align: 'center'
},
{
title: '折扣率',
dataIndex: 'discount',
key: 'discount',
sorter: true,
align: 'center'
},
{
title: '可使用次数',
dataIndex: 'count',
key: 'count',
sorter: true,
align: 'center'
},
{
title: '剩余次数',
dataIndex: 'num',
key: 'num',
width: 190,
sorter: true,
align: 'center'
},
{
title: '每使用一次减少的金额',
dataIndex: 'eachMoney',
key: 'eachMoney',
sorter: true,
align: 'center'
},
{
title: '剩余金额',
dataIndex: 'remainingMoney',
key: 'remainingMoney',
width: 200,
sorter: true,
align: 'center'
},
{
title: '月限',
dataIndex: 'month',
key: 'month',
sorter: true,
align: 'center'
},
{
title: '年限',
dataIndex: 'term',
key: 'term',
sorter: true,
align: 'center'
},
{
title: '会员卡类型',
dataIndex: 'vipType',
key: 'vipType',
align: 'center',
sorter: true,
customRender: ({ text }) => ['', '特殊VIP卡', '普通VIP卡'][text]
},
{
title: '卡类型',
dataIndex: 'cardType',
key: 'cardType',
align: 'center',
sorter: true,
customRender: ({ text }) => ['', '成人卡', '儿童卡', '不限'][text]
},
{
title: '会员卡类型',
dataIndex: 'type',
key: 'type',
align: 'center',
sorter: true,
customRender: ({ text }) =>
['', '年卡', '次卡', '月卡', '会员VIP', 'VIP充值卡'][text]
},
{
title: '是否赠送积分',
dataIndex: 'isIntegral',
key: 'isIntegral',
sorter: true,
align: 'center',
customRender: ({ text }) => ['', '赠送', '不赠送'][text]
},
{
title: '是否已开具发票',
dataIndex: 'isInvoice',
key: 'isInvoice',
sorter: true,
align: 'center',
customRender: ({ text }) => ['', '已开票', '未开票'][text]
}
]);
const expireTimeLoading = reactive<Record<number, boolean>>({});
const remainingDrafts = reactive<Record<string, string | number | null>>({});
const remainingLoadingKey = ref<string | null>(null);
const remainingEditing = reactive<Record<string, boolean>>({});
const remainingKey = (row: ThinkUsersVip, field: 'num' | 'remainingMoney') =>
`${row.id ?? ''}-${field}`;
const getRemainingDraft = (
row: ThinkUsersVip,
field: 'num' | 'remainingMoney'
) => {
const key = remainingKey(row, field);
if (!(key in remainingDrafts)) {
remainingDrafts[key] =
field === 'num' ? row.num ?? 0 : row.remainingMoney ?? '';
}
return remainingDrafts[key];
};
const setRemainingDraft = (
row: ThinkUsersVip,
field: 'num' | 'remainingMoney',
value: string | number | null
) => {
remainingDrafts[remainingKey(row, field)] = value;
};
const isRemainingEditing = (
row: ThinkUsersVip,
field: 'num' | 'remainingMoney'
) => !!remainingEditing[remainingKey(row, field)];
const editRemaining = (
row: ThinkUsersVip,
field: 'num' | 'remainingMoney'
) => {
if (!hasPermission('think:thinkUsersVip:changeRemain')) {
return;
}
getRemainingDraft(row, field);
remainingEditing[remainingKey(row, field)] = true;
};
const isRemainingLoading = (
id: number | undefined,
field: 'num' | 'remainingMoney'
) => remainingLoadingKey.value === `${id ?? ''}-${field}`;
const saveRemaining = async (
row: ThinkUsersVip,
field: 'num' | 'remainingMoney'
) => {
if (!row.id) {
return;
}
const value = getRemainingDraft(row, field);
if (
value === null ||
value === '' ||
value === undefined ||
(field === 'num' &&
(!Number.isInteger(Number(value)) || Number(value) < 0))
) {
message.error(
field === 'num' ? '剩余次数必须是非负整数' : '请输入剩余金额'
);
return;
}
const key = remainingKey(row, field);
remainingLoadingKey.value = key;
try {
await updateThinkUsersVipRemaining({
id: row.id,
...(field === 'num'
? { num: Number(value) }
: { remainingMoney: String(value) })
});
if (field === 'num') {
row.num = Number(value);
} else {
row.remainingMoney = String(value);
}
remainingEditing[key] = false;
message.success('保存成功');
} catch (e: any) {
message.error(e.message || '保存失败');
} finally {
remainingLoadingKey.value = null;
}
};
};
query();
const formatExpireTime = (value?: number) => {
return value
? dayjs(value * 1000).format('YYYY-MM-DD HH:mm:ss')
: undefined;
};
const changeExpireTime = async (value: string, row: ThinkUsersVip) => {
if (!row.id) {
return;
}
if (!value) {
message.error('请选择到期时间');
return;
}
const expireTime = dayjs(value).unix();
if (row.expireTime === expireTime) {
return;
}
expireTimeLoading[row.id] = true;
try {
await updateThinkUsersVip({
id: row.id,
expireTime
});
row.expireTime = expireTime;
message.success('到期时间修改成功');
} catch (e: any) {
message.error(e.message || '到期时间修改失败');
} finally {
expireTimeLoading[row.id] = false;
}
};
/* 搜索 */
const reload = (where?: ThinkUsersVipParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ThinkUsersVip) => {
current.value = row ?? null;
showEdit.value = true;
};
const showLog = ref(false);
const openLog = (row?: ThinkUsersVip) => {
current.value = row ?? null;
showLog.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ThinkUsersVip) => {
const hide = message.loading('请求中..', 0);
removeThinkUsersVip(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchThinkUsersVip(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
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();
});
};
query();
</script>
<script lang="ts">
export default {
name: "ThinkUsersVip"
};
export default {
name: 'ThinkUsersVip'
};
</script>
<style lang="less" scoped></style>
@@ -30,8 +30,32 @@
<a-radio-group v-model:value="form.vipType">
<a-radio :value="1">特殊vip卡</a-radio>
<a-radio :value="2">普通vip卡</a-radio>
<a-radio :value="3">培训卡</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item
v-if="form.vipType === 3"
label="培训机构"
name="trainingInstitutionId"
>
<a-select
v-model:value="form.trainingInstitutionId"
allow-clear
show-search
filter-option
option-filter-prop="label"
placeholder="请选择培训机构"
>
<a-select-option
v-for="item in trainingInstitutionList"
:key="item.id"
:value="item.id"
:label="item.name"
>
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="卡类型" name="cardType">
<a-radio-group v-model:value="form.cardType">
<a-radio :value="1">成人卡</a-radio>
@@ -63,8 +87,17 @@
<ThinkSelectSiteMultiple v-model:value="sites" />
</a-form-item>
<a-form-item label="报表归属场馆" name="reportSid">
<a-select v-model:value="form.reportSid" filter-option="label" show-search>
<a-select-option v-for="item in siteList" :key="item.id" :value="item.id" :label="item.name">
<a-select
v-model:value="form.reportSid"
filter-option="label"
show-search
>
<a-select-option
v-for="item in siteList"
:key="item.id"
:value="item.id"
:label="item.name"
>
{{ item.name }}
</a-select-option>
</a-select>
@@ -142,8 +175,11 @@
</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-date-picker
v-model:value="form.expiredTime"
value-format="YYYY-MM-DD"
placeholder="请选择过期时间"
/>
</a-form-item>
<a-form-item label="排序" name="sort">
<a-input-number
@@ -157,9 +193,9 @@
<a-form-item label="特殊卡开发凭证图" name="pic">
<a-avatar :src="`${IMG_URL}${form.pic}`" :size="120" />
</a-form-item>
<!-- <a-form-item label="VIP充值卡价格组" name="prices">-->
<!-- {{ form.prices }}-->
<!-- </a-form-item>-->
<!-- <a-form-item label="VIP充值卡价格组" name="prices">-->
<!-- {{ form.prices }}-->
<!-- </a-form-item>-->
<a-form-item label="是否有效" name="isUse">
<a-radio-group v-model:value="form.isUse">
<a-radio :value="1">是</a-radio>
@@ -177,191 +213,324 @@
</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 { listThinkSite } from "@/api/think/thinkSite";
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 { ThinkSite } from '@/api/think/thinkSite/model';
import { IMG_URL } from '@/config/setting';
import { listThinkSite } from '@/api/think/thinkSite';
import { listThinkTrainingInstitution } from '@/api/think/thinkTrainingInstitution';
import type { ThinkTrainingInstitution } from '@/api/think/thinkTrainingInstitution/model';
// 是否是修改
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,
renewPrice: undefined,
desc: undefined,
info: undefined,
discount: undefined,
reportSid: 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,
});
// 用户信息
const form = reactive<ThinkVip>({
id: undefined,
sid: undefined,
name: undefined,
price: undefined,
renewPrice: undefined,
desc: undefined,
info: undefined,
discount: undefined,
reportSid: undefined,
count: undefined,
eachMoney: undefined,
term: 1,
month: undefined,
day: undefined,
type: 1,
cardType: 1,
vipType: 2,
trainingInstitutionId: undefined,
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"
}
],
price: [
{
required: true,
message: "请填写价格",
trigger: "blur"
}
],
renewPrice: [
{
required: true,
message: "请填写续卡价格",
trigger: "blur"
}
],
reportSid: [
{
required: true,
message: "请选择报表归属场馆",
trigger: "blur"
}
],
const isEmptyOrZero = (value: number | string | null | undefined) => {
return (
value === undefined ||
value === null ||
value === '' ||
Number(value) === 0
);
};
});
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;
// 表单验证规则
const rules = reactive({
name: [
{
required: true,
type: 'string',
message: '请填写名称',
trigger: 'blur'
}
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(() => {
});
};
],
price: [
{
required: true,
message: '请填写价格',
trigger: 'blur'
}
],
renewPrice: [
{
required: true,
message: '请填写续卡价格',
trigger: 'blur'
}
],
reportSid: [
{
required: true,
message: '请选择报表归属场馆',
trigger: 'blur'
}
],
term: [
{
validator: async (
_rule: unknown,
value: number | string | undefined
) => {
if (form.mode !== 0) {
return Promise.resolve();
}
if (form.type === 1 && isEmptyOrZero(value)) {
return Promise.reject('年卡年限不能为0');
}
return Promise.resolve();
},
trigger: ['blur', 'change']
}
],
month: [
{
validator: async (
_rule: unknown,
value: number | string | undefined
) => {
if (form.mode !== 0) {
return Promise.resolve();
}
if ((form.type === 3 || form.type === 4) && isEmptyOrZero(value)) {
return Promise.reject('月卡/季卡月限不能为0');
}
return Promise.resolve();
},
trigger: ['blur', 'change']
}
],
trainingInstitutionId: [
{
validator: async (_rule: unknown, value: number | undefined) => {
if (form.vipType === 3 && !value) {
return Promise.reject('请选择培训机构');
}
return Promise.resolve();
},
trigger: 'change'
}
],
count: [
{
validator: async (
_rule: unknown,
value: number | string | undefined
) => {
if (
form.vipType === 3 &&
(value === undefined || value === null || value === '')
) {
return Promise.reject('培训卡请填写使用次数');
}
return Promise.resolve();
},
trigger: ['blur', 'change']
}
]
});
const siteList = ref<ThinkSite[]>([])
const getSiteList = async () => {
siteList.value = await listThinkSite()
};
getSiteList()
const { resetFields } = useForm(form, rules);
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"
});
/* 保存编辑 */
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.vipType !== 3) {
formData.trainingInstitutionId = undefined;
}
if (props.data.sid) {
const split = props.data.sid.split(",");
split.map((id) => {
sites.value.push({
id: Number(id)
if (formData.mode === 1 && !formData.expiredTime) {
loading.value = false;
message.error('请选择过期时间');
return;
}
if (
formData.mode === 0 &&
formData.type === 1 &&
isEmptyOrZero(formData.term)
) {
loading.value = false;
message.error('年卡年限不能为0');
return;
}
if (
formData.mode === 0 &&
(formData.type === 3 || formData.type === 4) &&
isEmptyOrZero(formData.month)
) {
loading.value = false;
message.error('月卡/季卡月限不能为0');
return;
}
if (formData.vipType === 3 && !formData.trainingInstitutionId) {
loading.value = false;
message.error('请选择培训机构');
return;
}
if (
formData.vipType === 3 &&
(formData.count === undefined ||
formData.count === null ||
formData.count === '')
) {
loading.value = false;
message.error('培训卡请填写使用次数');
return;
}
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(() => {});
};
const siteList = ref<ThinkSite[]>([]);
const trainingInstitutionList = ref<ThinkTrainingInstitution[]>([]);
const getSiteList = async () => {
siteList.value = await listThinkSite();
};
getSiteList();
const getTrainingInstitutionList = async () => {
trainingInstitutionList.value = await listThinkTrainingInstitution();
};
getTrainingInstitutionList();
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;
}
isUpdate.value = true;
} else {
isUpdate.value = false;
resetFields();
}
} else {
resetFields();
},
{ immediate: true }
);
watch(
() => form.vipType,
(vipType) => {
if (vipType !== 3) {
form.trainingInstitutionId = undefined;
}
formRef.value
?.validateFields(['trainingInstitutionId', 'count'])
.catch(() => {});
}
},
{ immediate: true }
);
);
watch(
() => form.type,
() => {
formRef.value?.validateFields(['term', 'month']).catch(() => {});
}
);
</script>
+8 -1
View File
@@ -230,7 +230,14 @@
key: 'vipType',
sorter: true,
align: 'center',
customRender: ({ text }) => ['', '特殊VIP卡', '普通VIP卡'][text]
customRender: ({ text }) => ['', '特殊VIP卡', '普通VIP卡', '培训卡'][text]
},
{
title: '培训机构',
dataIndex: 'trainingInstitutionName',
key: 'trainingInstitutionName',
align: 'center',
ellipsis: true
},
{
title: '卡类型',