This commit is contained in:
孟帅
2023-05-10 23:54:50 +08:00
parent bbe655a4d8
commit 49a96750bf
314 changed files with 15138 additions and 6244 deletions

View File

@@ -0,0 +1,149 @@
<template>
<div>
<n-spin :show="loading" description="请稍候...">
<n-modal
v-model:show="isShowModal"
:show-icon="false"
preset="dialog"
title="受理退款申请"
:style="{
width: dialogWidth,
}"
>
<n-form
:model="params"
:rules="rules"
ref="formRef"
label-placement="left"
:label-width="80"
class="py-4"
>
<n-form-item label="业务单号" path="orderSn">
<n-input v-model:value="params.orderSn" :disabled="true" />
</n-form-item>
<n-form-item label="订单金额" path="money">
<n-input placeholder="请输入标题" v-model:value="params.money" :disabled="true" />
</n-form-item>
<n-form-item label="退款原因" path="refundReason">
<n-input
type="textarea"
placeholder="请填写退款原因"
v-model:value="params.refundReason"
:disabled="true"
/>
</n-form-item>
<n-form-item label="更新状态" path="status">
<n-select v-model:value="params.status" :options="options.acceptRefundStatus" />
</n-form-item>
<n-form-item label="拒绝原因" path="rejectRefundReason" v-if="params.status === 9">
<n-input
type="textarea"
placeholder="请填拒绝退款原因"
v-model:value="params.rejectRefundReason"
/>
</n-form-item>
<n-form-item label="退款备注" path="remark" v-if="params.status === 8">
<n-input type="textarea" placeholder="请填退款备注" v-model:value="params.remark" />
</n-form-item>
</n-form>
<template #action>
<n-space>
<n-button @click="closeForm">取消</n-button>
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">确定</n-button>
</n-space>
</template>
</n-modal>
</n-spin>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref, computed, watch } from 'vue';
import { rules, State, newState, options } from './model';
import { useMessage } from 'naive-ui';
import { adaModalWidth } from '@/utils/hotgo';
import { AcceptRefund, View } from '@/api/order';
const emit = defineEmits(['reloadTable', 'updateShowModal']);
interface Props {
showModal: boolean;
formParams?: State;
}
const props = withDefaults(defineProps<Props>(), {
showModal: false,
formParams: () => {
return newState(null);
},
});
const isShowModal = computed({
get: () => {
return props.showModal;
},
set: (value) => {
emit('updateShowModal', value);
},
});
const loading = ref(false);
const params = ref<State>(props.formParams);
const message = useMessage();
const formRef = ref<any>({});
const dialogWidth = ref('75%');
const formBtnLoading = ref(false);
function confirmForm(e) {
e.preventDefault();
formBtnLoading.value = true;
formRef.value.validate((errors) => {
if (!errors) {
AcceptRefund(params.value).then((_res) => {
message.success('操作成功');
setTimeout(() => {
isShowModal.value = false;
emit('reloadTable');
});
});
} else {
message.error('请填写完整信息');
}
formBtnLoading.value = false;
});
}
onMounted(async () => {
adaModalWidth(dialogWidth);
});
function closeForm() {
isShowModal.value = false;
}
function loadForm(value) {
loading.value = true;
// 编辑
View({ id: value.id })
.then((res) => {
params.value = res;
})
.finally(() => {
loading.value = false;
});
}
watch(
() => props.formParams,
(value) => {
loadForm(value);
}
);
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,132 @@
<template>
<div>
<n-spin :show="loading" description="请稍候...">
<n-modal
v-model:show="isShowModal"
:show-icon="false"
preset="dialog"
title="退款申请"
:style="{
width: dialogWidth,
}"
>
<n-form
:model="params"
:rules="rules"
ref="formRef"
label-placement="left"
:label-width="80"
class="py-4"
>
<n-form-item label="业务单号" path="orderSn">
<n-input v-model:value="params.orderSn" :disabled="true" />
</n-form-item>
<n-form-item label="订单金额" path="money">
<n-input placeholder="请输入标题" v-model:value="params.money" :disabled="true" />
</n-form-item>
<n-form-item label="退款原因" path="refundReason">
<n-input
type="textarea"
placeholder="请填写退款原因"
v-model:value="params.refundReason"
/>
</n-form-item>
</n-form>
<template #action>
<n-space>
<n-button @click="closeForm">取消</n-button>
<n-button type="info" :loading="formBtnLoading" @click="confirmForm">确定</n-button>
</n-space>
</template>
</n-modal>
</n-spin>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref, computed, watch } from 'vue';
import { rules, State, newState } from './model';
import { useMessage } from 'naive-ui';
import { adaModalWidth } from '@/utils/hotgo';
import { ApplyRefund, View } from '@/api/order';
const emit = defineEmits(['reloadTable', 'updateShowModal']);
interface Props {
showModal: boolean;
formParams?: State;
}
const props = withDefaults(defineProps<Props>(), {
showModal: false,
formParams: () => {
return newState(null);
},
});
const isShowModal = computed({
get: () => {
return props.showModal;
},
set: (value) => {
emit('updateShowModal', value);
},
});
const loading = ref(false);
const params = ref<State>(props.formParams);
const message = useMessage();
const formRef = ref<any>({});
const dialogWidth = ref('75%');
const formBtnLoading = ref(false);
function confirmForm(e) {
e.preventDefault();
formBtnLoading.value = true;
formRef.value.validate((errors) => {
if (!errors) {
ApplyRefund(params.value).then((_res) => {
message.success('操作成功');
setTimeout(() => {
isShowModal.value = false;
emit('reloadTable');
});
});
} else {
message.error('请填写完整信息');
}
formBtnLoading.value = false;
});
}
onMounted(async () => {
adaModalWidth(dialogWidth);
});
function closeForm() {
isShowModal.value = false;
}
function loadForm(value) {
loading.value = true;
// 编辑
View({ id: value.id })
.then((res) => {
params.value = res;
})
.finally(() => {
loading.value = false;
});
}
watch(
() => props.formParams,
(value) => {
loadForm(value);
}
);
</script>
<style lang="less"></style>

View File

@@ -0,0 +1,45 @@
<template>
<div>
<div class="n-layout-page-header">
<n-card :bordered="false" title="充值记录" />
</div>
<n-card :bordered="false" class="proCard">
<n-tabs
type="card"
class="card-tabs"
:value="defaultTab"
animated
@before-leave="handleBeforeLeave"
>
<n-tab-pane
:name="item.key.toString()"
:tab="item.label"
v-for="item in options.status"
:key="item.key"
>
<List :type="defaultTab" />
</n-tab-pane>
</n-tabs>
</n-card>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import List from './list.vue';
import { useRouter } from 'vue-router';
import { options } from '@/views/asset/rechargeLog/model';
const router = useRouter();
const defaultTab = ref('-1');
onMounted(() => {
if (router.currentRoute.value.query?.type) {
defaultTab.value = router.currentRoute.value.query.type as string;
}
});
function handleBeforeLeave(tabName: string) {
defaultTab.value = tabName;
}
</script>

View File

@@ -0,0 +1,228 @@
<template>
<div>
<n-card :bordered="false" class="proCard">
<BasicForm
@register="register"
@submit="reloadTable"
@reset="reloadTable"
@keyup.enter="reloadTable"
ref="searchFormRef"
>
<template #statusSlot="{ model, field }">
<n-input v-model:value="model[field]" />
</template>
</BasicForm>
<BasicTable
:openChecked="true"
:columns="columns"
:request="loadDataTable"
:row-key="(row) => row.id"
ref="actionRef"
:actionColumn="actionColumn"
@update:checked-row-keys="onCheckedRow"
:scroll-x="1800"
:resizeHeightOffset="-10000"
>
<template #tableTitle>
<n-button
type="error"
@click="handleBatchDelete"
:disabled="batchDeleteDisabled"
class="min-left-space"
v-if="hasPermission(['/order/delete'])"
>
<template #icon>
<n-icon>
<DeleteOutlined />
</n-icon>
</template>
批量删除
</n-button>
<n-button
type="primary"
@click="handleExport"
class="min-left-space"
v-if="hasPermission(['/order/export'])"
>
<template #icon>
<n-icon>
<ExportOutlined />
</n-icon>
</template>
导出
</n-button>
</template>
</BasicTable>
</n-card>
<ApplyRefund
@reloadTable="reloadTable"
@updateShowModal="updateShowModal"
:showModal="showModal"
:formParams="formParams"
/>
<AcceptRefund
@reloadTable="reloadTable"
@updateShowModal="updateAcceptShowModal"
:showModal="showAcceptModal"
:formParams="formParams"
/>
</div>
</template>
<script lang="ts" setup>
import { h, reactive, ref } from 'vue';
import { useDialog, useMessage } from 'naive-ui';
import { BasicTable, TableAction } from '@/components/Table';
import { BasicForm, useForm } from '@/components/Form/index';
import { usePermission } from '@/hooks/web/usePermission';
import { List, Export, Delete } from '@/api/order';
import { State, columns, schemas, newState } from './model';
import { ExportOutlined, DeleteOutlined } from '@vicons/antd';
import ApplyRefund from './applyRefund.vue';
import AcceptRefund from './acceptRefund.vue';
interface Props {
type?: string;
}
const props = withDefaults(defineProps<Props>(), {
type: '-1',
});
const { hasPermission } = usePermission();
const actionRef = ref();
const dialog = useDialog();
const message = useMessage();
const searchFormRef = ref<any>({});
const batchDeleteDisabled = ref(true);
const checkedIds = ref([]);
const showModal = ref(false);
const showAcceptModal = ref(false);
const formParams = ref<State>();
const actionColumn = reactive({
width: 120,
title: '操作',
key: 'action',
fixed: 'right',
render(record) {
return h(TableAction as any, {
style: 'button',
actions: [
{
type: 'warning',
label: '受理退款',
onClick: handleAcceptRefund.bind(null, record),
auth: ['/order/acceptRefund'],
ifShow: () => {
return record.status == 6;
},
},
{
type: 'default',
label: '申请退款',
onClick: handleApplyRefund.bind(null, record),
auth: ['/order/applyRefund'],
ifShow: () => {
return record.status == 4;
},
},
{
label: '删除',
onClick: handleDelete.bind(null, record),
auth: ['/order/delete'],
ifShow: () => {
return record.status == 5;
},
},
],
});
},
});
const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80,
schemas,
});
const loadDataTable = async (res) => {
return await List({ ...searchFormRef.value?.formModel, ...res, ...{ status: props.type } });
};
function reloadTable() {
actionRef.value.reload();
}
function onCheckedRow(rowKeys) {
batchDeleteDisabled.value = rowKeys.length <= 0;
checkedIds.value = rowKeys;
}
function handleExport() {
message.loading('正在导出列表...', { duration: 1200 });
Export(searchFormRef.value?.formModel);
}
function handleDelete(record: Recordable) {
dialog.warning({
title: '警告',
content: '你确定要删除?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: () => {
Delete(record).then((_res) => {
message.success('删除成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('取消');
},
});
}
function handleBatchDelete() {
dialog.warning({
title: '警告',
content: '你确定要批量删除?只有已关闭的订单才能被删除',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: () => {
Delete({ id: checkedIds.value }).then((_res) => {
message.success('删除成功');
reloadTable();
});
},
onNegativeClick: () => {
// message.error('取消');
},
});
}
function updateShowModal(value) {
showModal.value = value;
}
function handleApplyRefund(record: Recordable) {
showModal.value = true;
formParams.value = newState(record as State);
}
function updateAcceptShowModal(value) {
showAcceptModal.value = value;
}
function handleAcceptRefund(record: Recordable) {
showAcceptModal.value = true;
formParams.value = newState(record as State);
}
defineExpose({
reloadTable,
});
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,209 @@
import { h, ref } from 'vue';
import { NTag } from 'naive-ui';
import { cloneDeep } from 'lodash-es';
import { FormSchema } from '@/components/Form';
import { Option } from '@/api/order';
import { isNullObject } from '@/utils/is';
import { defRangeShortcuts } from '@/utils/dateUtil';
import { getOptionLabel, getOptionTag, Options } from '@/utils/hotgo';
export interface State {
id: number;
memberId: number;
orderType: string;
productId: number;
orderSn: string;
money: number;
remark: string;
payLogOutTradeNo: string;
status: number;
createdAt: string;
updatedAt: string;
refundReason: string;
rejectRefundReason: string;
payLogPayType: string;
}
export const defaultState = {
id: 0,
memberId: 0,
orderType: '',
productId: 0,
orderSn: '',
money: 0,
payLogOutTradeNo: '',
remark: '',
status: 1,
createdAt: '',
updatedAt: '',
refundReason: '',
rejectRefundReason: '',
payLogPayType: '',
};
export function newState(state: State | null): State {
if (state !== null) {
return cloneDeep(state);
}
return cloneDeep(defaultState);
}
export const options = ref<Options>({
status: [],
acceptRefundStatus: [],
payType: [],
});
export const rules = {};
export const schemas = ref<FormSchema[]>([
{
field: 'memberId',
component: 'NInput',
label: '管理员ID',
componentProps: {
placeholder: '请输入管理员ID',
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
{
field: 'orderSn',
component: 'NInput',
label: '业务单号',
componentProps: {
placeholder: '请输入业务订单号',
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
{
field: 'payLogOutTradeNo',
component: 'NInput',
label: '商户单号',
componentProps: {
placeholder: '请输入商户订单号',
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
{
field: 'createdAt',
component: 'NDatePicker',
label: '创建时间',
componentProps: {
type: 'datetimerange',
clearable: true,
shortcuts: defRangeShortcuts(),
onUpdateValue: (e: any) => {
console.log(e);
},
},
},
]);
export const columns = [
{
title: '订单ID',
key: 'id',
width: 100,
},
{
title: '管理员ID',
key: 'memberId',
width: 100,
},
{
title: '业务订单号',
key: 'orderSn',
width: 260,
},
{
title: '商户订单号',
key: 'payLogOutTradeNo',
width: 260,
},
{
title: '支付方式',
key: 'payLogPayType',
render(row) {
if (isNullObject(row.payLogPayType)) {
return ``;
}
return h(
NTag,
{
style: {
marginRight: '6px',
},
type: getOptionTag(options.value.payType, row.payLogPayType),
bordered: false,
},
{
default: () => getOptionLabel(options.value.payType, row.payLogPayType),
}
);
},
width: 150,
},
{
title: '充值金额',
key: 'money',
width: 100,
render(row) {
return '¥' + Number(row.money).toFixed(2);
},
},
{
title: '订单状态',
key: 'status',
render(row) {
if (isNullObject(row.status)) {
return ``;
}
return h(
NTag,
{
style: {
marginRight: '6px',
},
type: getOptionTag(options.value.status, row.status),
bordered: false,
},
{
default: () =>
getOptionLabel(options.value.status, row.status) +
(row.status === 9 ? '' + row.rejectRefundReason : ''),
}
);
},
width: 150,
},
{
title: '创建时间',
key: 'createdAt',
width: 180,
},
];
async function loadOptions() {
options.value = await Option();
for (const item of schemas.value) {
switch (item.field) {
case 'status':
item.componentProps.options = options.value.status;
break;
case 'acceptRefundStatus':
item.componentProps.options = options.value.acceptRefundStatus;
break;
case 'payType':
item.componentProps.options = options.value.payType;
break;
}
}
}
await loadOptions();