第一次提交

This commit is contained in:
gxwebsoft
2023-08-04 13:32:43 +08:00
commit c02e8be49b
1151 changed files with 200453 additions and 0 deletions

View File

@@ -0,0 +1,377 @@
<!-- 用户编辑弹窗 -->
<template>
<a-drawer
:width="600"
:visible="visible"
:confirm-loading="loading"
:maxable="maxAble"
:title="isUpdate ? '编辑' : '新建'"
:body-style="{ paddingBottom: '8px' }"
:footer-style="{ textAlign: 'right' }"
@update:visible="updateVisible"
:maskClosable="isUpdate"
@ok="save"
>
<a-form
ref="formRef"
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
layout="vertical"
:model="form"
:rules="rules"
>
<a-form-item label="提现金额" name="money">
<a-input-number
allow-clear
style="width: 100%"
:placeholder="`可提现金额¥3000.00`"
v-model:value="form.money"
/>
</a-form-item>
<a-form-item label="收款方式" name="payType">
<DictSelect
dict-code="withdrawType"
v-model:value="form.payType"
placeholder="选择收款方式"
/>
</a-form-item>
<!-- <a-form-item-->
<!-- label="开户行名称"-->
<!-- name="bankName"-->
<!-- v-if="form.payType === '30'"-->
<!-- >-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- :placeholder="`请选择开户的银行名称`"-->
<!-- v-model:value="merchant.bankName"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item-->
<!-- label="银行开户名"-->
<!-- name="bankAccount"-->
<!-- v-if="form.payType === '30'"-->
<!-- >-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- :placeholder="`请填写银行卡姓名`"-->
<!-- v-model:value="merchant.bankAccount"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item-->
<!-- label="银行卡号"-->
<!-- name="bankCard"-->
<!-- v-if="form.payType === '30'"-->
<!-- >-->
<!-- <a-input-->
<!-- allow-clear-->
<!-- :placeholder="`请填写银行卡号`"-->
<!-- v-model:value="merchant.bankCard"-->
<!-- />-->
<!-- </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 v-role="'superAdmin'" label="处理状态" 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>
<template #footer>
<a-space>
<a-button @click="onClose">取消</a-button>
<a-button type="primary" @click="save">保存</a-button>
</a-space>
</template>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue';
import type { MerchantWithdraw } from '@/api/merchant/withdraw/model';
import {
addMerchantWithdraw,
updateMerchantWithdraw
} from '@/api/merchant/withdraw';
import { FormInstance, Rule, RuleObject } from 'ant-design-vue/es/form';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { uploadFile } from '@/api/system/file';
import { FILE_SERVER, FILE_THUMBNAIL } from '@/config/setting';
import useFormData from '@/utils/use-form-data';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import DictSelect from '@/components/DictSelect/index.vue';
import dayjs, { Dayjs } from 'dayjs';
import { createCode, createOrderNo } from "@/utils/common";
import { Merchant } from '@/api/merchant/model';
// import MultiSpec from './MultiSpec.vue';
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: MerchantWithdraw | null;
merchant?: Merchant[];
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 是否是修改
const isUpdate = ref(false);
// 是否显示最大化切换按钮
const maxAble = ref(true);
const disabled = ref(false);
// 选择日期
const batteryDeliveryTime = ref<Dayjs>();
const ctiveTime = ref<Dayjs>();
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
const formRef = ref<FormInstance | null>(null);
// 选项卡位置
// const activeKey = ref('1');
// 编辑器内容,双向绑定
const content = ref<any>('');
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单数据
const { form, resetFields, assignFields } = useFormData<MerchantWithdraw>({
id: undefined,
withdrawCode: `W${createCode()}`,
money: undefined,
payType: '30',
bankName: undefined,
bankAccount: undefined,
bankCard: undefined,
comments: '',
applyStatus: undefined,
sortNumber: 100,
status: 0,
merchantCode: undefined
});
/* 上传事件 */
const uploadHandler = (file: File) => {
const item: ItemType = {
file,
uid: (file as any).uid,
name: file.name
};
if (!file.type.startsWith('image')) {
message.error('只能选择图片');
return;
}
if (file.size / 1024 / 1024 > 2) {
message.error('大小不能超过 2MB');
return;
}
onUpload(item);
};
// 上传文件
const onUpload = (item) => {
const { file } = item;
uploadFile(file)
.then((data) => {
images.value.push({
uid: data.id,
url: FILE_THUMBNAIL + data.path,
status: 'done'
});
message.success('上传成功');
})
.catch((e) => {
message.error(e.message);
});
};
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
money: [
{
required: true,
message: '请输入提现金额',
type: 'number',
trigger: 'blur'
}
],
payType: [
{
required: true,
message: '请选择收款方式',
type: 'string',
trigger: 'blur'
}
],
status: [
{
required: true,
type: 'number',
message: '请选择设备状态',
trigger: 'blur'
}
],
sortNumber: [
{
required: true,
type: 'number',
message: '请输入排序号',
trigger: 'blur'
}
],
// images: [
// {
// required: true,
// type: 'string',
// message: '请选择设备图片',
// trigger: 'blur',
// validator: async (_rule: RuleObject, value: string) => {
// if (images.value.length == 0) {
// return Promise.reject('请上传设备图片');
// }
// return Promise.resolve();
// }
// }
// ],
content: [
{
required: true,
type: 'string',
message: '请输入文章内容',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (content.value == '') {
return Promise.reject('请输入文字内容');
}
return Promise.resolve();
}
}
]
});
/* 控制放店开关 */
const editStatus = () => {
if (form.status == 0) {
form.status = 1;
} else {
form.status = 0;
}
updateMerchantWithdraw(form)
.then(() => {
message.success('操作成功');
})
.catch((e) => {
message.error(e.message);
});
};
const onClose = () => {
updateVisible(false);
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
// 获取第一张图片作为封面图
// images.value.map((d, i) => {
// if (i === 0) {
// form.image = d.url;
// }
// });
// 判断可提现金额是否足够
if (props?.merchant?.money < form.money) {
message.error('可提现金额不足!');
return;
}
const equipmentFaultForm = {
...form,
files: JSON.stringify(images.value),
content: content.value,
batteryDeliveryTime: batteryDeliveryTime.value?.format(
'YYYY-MM-DD HH:mm:ss'
),
ctiveTime: ctiveTime.value?.format('YYYY-MM-DD HH:mm:ss')
};
const saveOrUpdate = isUpdate.value
? updateMerchantWithdraw
: addMerchantWithdraw;
saveOrUpdate(equipmentFaultForm)
.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) {
if (props.data) {
loading.value = false;
assignFields({
...props.data
});
if (props.data.batteryDeliveryTime) {
batteryDeliveryTime.value = dayjs(
props.data.batteryDeliveryTime,
'YYYY-MM-DD'
);
ctiveTime.value = dayjs(props.data.ctiveTime, 'YYYY-MM-DD');
} else {
batteryDeliveryTime.value = undefined;
ctiveTime.value = undefined;
}
// images.value = JSON.parse(String(props.data.files));
content.value = props.data.content;
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
formRef.value?.clearValidate();
}
}
);
</script>
<style lang="less">
.tab-pane {
min-height: 300px;
}
.ml-10 {
margin-left: 5px;
}
</style>

View File

@@ -0,0 +1,134 @@
<!-- 搜索表单 -->
<template>
<a-space>
<a-button
type="primary"
class="ele-btn-icon"
v-permission="'shop:merchantWithdraw:save'"
@click="add"
>
<template #icon>
<PlusOutlined />
</template>
<span>申请提现</span>
</a-button>
<a-button
danger
type="primary"
class="ele-btn-icon"
:v-role="`shop:merchantWithdraw:remove`"
@click="removeBatch"
v-if="props.selection.length > 0"
>
<template #icon>
<DeleteOutlined />
</template>
<span>批量删除</span>
</a-button>
<!-- <a-radio-group v-model:value="listType" @change="handleTabs">-->
<!-- <a-radio-button value="all">全部</a-radio-button>-->
<!-- <a-radio-button value="onSale">出售中</a-radio-button>-->
<!-- <a-radio-button value="offSale">已下架</a-radio-button>-->
<!-- <a-radio-button value="soldOut">已售罄</a-radio-button>-->
<!-- </a-radio-group>-->
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
@search="search"
@pressEnter="search"
>
<template #addonBefore>
<a-select v-model:value="type" style="width: 80px; margin: -5px -12px">
<a-select-option value="withdrawCode">编号</a-select-option>
</a-select>
</template>
</a-input-search>
<!-- <CustomerSelect-->
<!-- v-model:value="where.equipmentId"-->
<!-- :placeholder="`按设备筛选`"-->
<!-- @select="onSelect"-->
<!-- @clear="onClear"-->
<!-- />-->
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
import useSearch from '@/utils/use-search';
import type { EquipmentParam } from '@/api/apps/equipment/model';
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
import { ref, watch } from 'vue';
// import { EquipmentFaultParam } from '@/api/apps/equipment/fault/model';
import { MerchantWithdrawParam } from '@/api/merchant/withdraw/model';
const emit = defineEmits<{
(e: 'search', where?: EquipmentParam): void;
(e: 'add'): void;
(e: 'remove'): void;
}>();
const props = defineProps<{
// 勾选的项目
selection?: [];
}>();
// 表单数据
const { where, resetFields } = useSearch<MerchantWithdrawParam>({
withdrawCode: ''
});
// 下来选项
const type = ref('withdrawCode');
// tabType
const listType = ref('all');
// 搜索内容
const searchText = ref('');
/* 搜索 */
const search = () => {
if (type.value == 'withdrawCode') {
where.withdrawCode = searchText.value;
}
emit('search', where);
};
// const handleTabs = (e) => {
// listType.value = e.target.value;
// if (listType.value == 'all') {
// resetFields();
// }
// if (listType.value == 'onSale') {
// where.status = 0;
// }
// if (listType.value == 'offSale') {
// where.status = 1;
// }
// if (listType.value == 'soldOut') {
// where.stockTotal = 0;
// }
// emit('search', where);
// };
// 新增
const add = () => {
emit('add');
};
// 批量删除
const removeBatch = () => {
emit('remove');
};
/* 重置 */
const reset = () => {
resetFields();
search();
};
// 监听字典id变化
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,346 @@
<template>
<div class="page">
<a-page-header :ghost="false" title="资金提现">
<a-row type="flex">
<a-statistic
title="可提现金额"
prefix="¥"
:precision="2"
:value="money"
/>
<a-statistic
title="待提现"
prefix="¥"
:precision="2"
:value="freezeMoney"
:style="{
margin: '0 80px'
}"
/>
<a-statistic
title="累计已提现"
prefix="¥"
:precision="2"
:value="totalMoney"
/>
</a-row>
<!-- <template #extra>-->
<!-- <a-button key="1" type="primary" danger>申请提现</a-button>-->
<!-- </template>-->
</a-page-header>
<div class="ele-body">
<a-card :bordered="false">
<!-- 表格 -->
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:height="tableHeight"
:datasource="datasource"
v-model:selection="selection"
:scroll="{ x: 800 }"
>
<template #toolbar>
<search
:selection="selection"
@search="reload"
@add="openEdit"
@remove="removeBatch"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="80" />
</template>
<template v-if="column.key === 'money'">
{{ formatNumber(record.money, 2) }}
</template>
<template v-if="column.key === 'bankName'">
<p>{{ record.bankName }}</p>
<p>{{ record.bankAccount }}</p>
<p>{{ record.bankCard }}</p>
</template>
<template v-if="column.key === 'payType'">
<a-tag v-if="record.payType === 10" color="green">微信</a-tag>
<a-tag v-if="record.payType === 20" color="blue">支付宝</a-tag>
<a-tag v-if="record.payType === 30" color="purple">银行卡</a-tag>
</template>
<template v-if="column.key === 'comments'">
<a-tooltip :title="record.comments" placement="topLeft">
{{ record.comments }}
</a-tooltip>
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="red">未处理</a-tag>
<a-tag v-if="record.status === 1" color="green">已处理</a-tag>
</template>
<template v-if="column.key === 'createTime'">
<a-tooltip :title="`${toDateString(record.createTime)}`">
{{ timeAgo(record.createTime) }}
</a-tooltip>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a-popconfirm>
<template #title>
<span style="font-weight: bold">
您确定要标记为已打款状态吗?
</span>
<p>
该操作仅改变提现申请状态实际付款/支付需要您线下操作
</p>
</template>
<a>已打款</a>
</a-popconfirm>
<a-divider type="vertical" />
<a-popconfirm
title="您确定要使用微信企业支付到零钱功能自动打款吗?"
>
<a class="ele-text-success">微信打款</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<Edit
v-model:visible="showEdit"
:data="current"
:merchant="merchant"
@done="reload"
/>
</div>
</div>
</template>
<!--suppress TypeScriptValidateTypes -->
<script lang="ts" setup>
import { timeAgo } from 'ele-admin-pro';
import { formatNumber } from 'ele-admin-pro/es';
import { createVNode, computed, 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 type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import { toDateString } from 'ele-admin-pro';
import Search from './components/search.vue';
import Edit from './components/edit.vue';
import {
pageMerchantWithdraws,
// removeMerchantWithdraw,
removeMerchantWithdraws
} from '@/api/merchant/withdraw';
import type {
MerchantWithdraw,
MerchantWithdrawParam
} from '@/api/merchant/withdraw/model';
// import { Category } from '@/api/goods/category/model';
import { listMerchant } from '@/api/merchant';
import { Merchant } from '@/api/merchant/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '所属商户',
dataIndex: 'merchantName',
sorter: true,
ellipsis: true,
hideInTable: true
},
{
title: '编号',
dataIndex: 'withdrawCode',
sorter: true
},
{
title: '提现金额',
dataIndex: 'money',
key: 'money'
},
{
title: '打款方式',
dataIndex: 'payType',
key: 'payType'
},
{
title: '收款账号',
dataIndex: 'bankName',
key: 'bankName'
},
// {
// title: '备注',
// dataIndex: 'comments',
// key: 'comments',
// width: 380,
// ellipsis: true
// },
{
title: '审核状态',
dataIndex: 'status',
key: 'status',
sorter: true
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center',
hideInSetting: true
}
]);
// 表格选中数据
const selection = ref<MerchantWithdraw[]>([]);
// 当前编辑数据
const current = ref<MerchantWithdraw | null>(null);
const merchant = ref<Merchant | null>(null);
// 当前商户资金
const money = ref<any>(0.0);
const freezeMoney = ref<any>(0.0);
const totalMoney = ref<any>(0.0);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.brand = filters.brand;
}
return pageMerchantWithdraws({ ...where, ...orders, page, limit });
};
// 加载状态
const loading = ref(true);
/* 查询 */
const query = () => {
loading.value = true;
const merchantCode = localStorage.getItem('merchantCode');
listMerchant({ merchantCode: String(merchantCode) }).then((res) => {
if (res.length > 0) {
loading.value = false;
merchant.value = res[0];
money.value = merchant.value.money;
freezeMoney.value = merchant.value.freezeMoney;
totalMoney.value = merchant.value.totalMoney;
}
});
};
/* 搜索 */
const reload = (where?: MerchantWithdrawParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
// 搜索是否展开
const searchExpand = ref(false);
// 表格固定高度
const fixedHeight = ref(false);
// 表格高度
const tableHeight = computed(() => {
return fixedHeight.value
? searchExpand.value
? 'calc(100vh - 618px)'
: 'calc(100vh - 562px)'
: void 0;
});
/* 打开编辑弹窗 */
const openEdit = (row?: MerchantWithdraw) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
// const remove = (row: MerchantWithdraw) => {
// const hide = message.loading('请求中..', 0);
// removeMerchantWithdraw(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);
removeMerchantWithdraws(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
query();
</script>
<script lang="ts">
export default {
name: 'MerchantWithdrawIndex'
};
</script>
<style lang="less" scoped>
// 文字超出隐藏(两行)
// 需要设置文字容器的宽度
.twoline-hide {
width: 320px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
white-space: normal;
}
</style>