第一次提交

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,549 @@
<!-- 用户编辑弹窗 -->
<template>
<ele-modal
:width="750"
:visible="visible"
:confirm-loading="loading"
:maxable="maxAble"
:title="isUpdate ? '编辑商户' : '添加商户'"
:body-style="{ paddingBottom: '8px' }"
@update:visible="updateVisible"
:maskClosable="false"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
layout="vertical"
>
<a-form-item label="商户编号" name="merchantCode">
<a-input
allow-clear
placeholder="请输入商户编号"
:disabled="isUpdate"
v-model:value="form.merchantCode"
/>
</a-form-item>
<a-form-item label="商户名称" name="merchantName">
<a-input
allow-clear
placeholder="请输入商户名称"
v-model:value="form.merchantName"
/>
</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="LOGO" name="images" extra="建议尺寸: 120*120">
<ele-image-upload
v-model:value="images"
:limit="1"
:drag="true"
:item-style="{ width: '80px', height: '80px' }"
:upload-handler="uploadHandler"
@upload="onUpload"
/>
</a-form-item>
<a-form-item label="背景图" name="background" extra="建议尺寸: 750*200">
<ele-image-upload
v-model:value="background"
:limit="1"
:drag="true"
:item-style="{ width: '360px', height: '100px' }"
:upload-handler="uploadHandler"
@upload="onUploadBackground"
/>
</a-form-item>
<a-form-item
label="负责人"
name="merchantOwner"
extra="请绑定负责人,注意:超管和游客账号不要绑定"
>
<OwnerChoose :value="form.merchantOwner" @select="onSelect" />
</a-form-item>
<a-form-item label="营业时间" name="merchantHours">
<a-input
allow-clear
placeholder="请输入营业时间"
v-model:value="form.merchantHours"
/>
</a-form-item>
<a-form-item label="门店电话" name="merchantPhone">
<a-input
allow-clear
placeholder="请输入门店电话"
v-model:value="form.merchantPhone"
/>
</a-form-item>
<a-form-item label="商户坐标" name="lngAndLat">
<div class="flex-sb">
<a-input
allow-clear
placeholder="请输入商户坐标"
v-model:value="form.lngAndLat"
/>
<a-button
class="ele-btn-icon"
style="margin-left: 10px"
@click="openMapPicker"
>
打开地图位置选择器
</a-button>
</div>
</a-form-item>
<a-form-item label="所在地区" name="region">
<div class="flex-sb">
<regions-select
v-model:value="city"
valueField="label"
placeholder="请选择省市区"
class="ele-fluid"
@change="onChangeRegion"
/>
</div>
</a-form-item>
<a-form-item label="街道地址" name="address">
<a-input
allow-clear
placeholder="请输入详细街道地址"
v-model:value="form.address"
/>
</a-form-item>
<a-form-item label="商户详情" name="content">
<!-- 编辑器 -->
<byte-md-editor
v-model:value="content"
:locale="zh_Hans"
:plugins="plugins"
height="350px"
/>
</a-form-item>
<a-form-item 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-item label="排序号" name="sortNumber">
<a-input-number
:min="0"
:max="99999"
class="ele-fluid"
placeholder="请输入排序号(数字越小越靠前)"
v-model:value="form.sortNumber"
/>
</a-form-item>
<!-- 地图位置选择弹窗 -->
<ele-map-picker
:need-city="true"
:dark-mode="darkMode"
v-model:visible="showMap"
:center="[108.374959, 22.767024]"
:search-type="1"
:zoom="12"
@done="onDone"
/>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue';
import type { Merchant } from '@/api/merchant/model';
import { addMerchant, updateMerchant } from '@/api/merchant';
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 OwnerChoose from '@/components/UserChoose/index.vue';
import { FILE_SERVER, FILE_THUMBNAIL } from "@/config/setting";
import useFormData from '@/utils/use-form-data';
import RegionsSelect from '@/components/RegionsSelect/index.vue';
import { createMerchantCode } from '@/utils/common';
import { storeToRefs } from 'pinia';
import { useThemeStore } from '@/store/modules/theme';
import type { CenterPoint } from 'ele-admin-pro/es/ele-map-picker/types';
import ByteMdEditor from '@/components/ByteMdEditor/index.vue';
import highlight from '@bytemd/plugin-highlight';
// 中文语言文件
import zh_Hans from 'bytemd/locales/zh_Hans.json';
// // 链接、删除线、复选框、表格等的插件
import gfm from '@bytemd/plugin-gfm';
// // 插件的中文语言文件
import zh_HansGfm from '@bytemd/plugin-gfm/locales/zh_Hans.json';
// // 预览界面的样式,这里用的 github 的 markdown 主题
import 'github-markdown-css/github-markdown-light.css';
// 是否是修改
const isUpdate = ref(false);
// 是否显示最大化切换按钮
const maxAble = ref(true);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Merchant | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const themeStore = useThemeStore();
const { darkMode } = storeToRefs(themeStore);
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
const background = ref<ItemType[]>([]);
const formRef = ref<FormInstance | null>(null);
// 编辑器内容,双向绑定
const content = ref<any>('');
// 省市区
const city = ref<string[]>([]);
// 是否显示地图选择弹窗
const showMap = ref(false);
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 选择地区
const onChangeRegion = (value) => {
form.province = value[0];
form.city = value[1];
form.region = value[2];
};
// 表单数据
const { form, resetFields, assignFields } = useFormData<Merchant>({
merchantName: '',
merchantCode: `${createMerchantCode()}`,
image: '',
createTime: '',
comments: '',
sortNumber: 100,
status: 0,
linkman: '',
address: '',
lngAndLat: '',
phone: '',
merchantId: 0,
userId: undefined,
merchantOwner: 0,
merchantPhone: undefined,
content: '',
merchantHours: '8:30 - 22:30',
province: '',
city: '',
region: '',
customerId: 0
});
/* 上传事件 */
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'
});
form.logo = data.path;
message.success('上传成功');
})
.catch((e) => {
message.error(e.message);
});
};
// 上传文件
const onUploadBackground = (item) => {
const { file } = item;
uploadFile(file)
.then((data) => {
background.value.push({
uid: data.id,
url: FILE_THUMBNAIL + data.path,
status: 'done'
});
form.logo = data.path;
message.success('上传成功');
})
.catch((e) => {
message.error(e.message);
});
};
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
merchantName: [
{
required: true,
message: '请输入商户名称',
type: 'string',
trigger: 'blur'
}
],
merchantCode: [
{
required: true,
type: 'string',
message: '请填写商户编号',
trigger: 'blur'
}
],
// comments: [
// {
// required: true,
// type: 'string',
// message: '请填写商户简介',
// trigger: 'blur'
// }
// ],
status: [
{
required: true,
type: 'number',
message: '请选择商户状态',
trigger: 'blur'
}
],
sortNumber: [
{
required: true,
type: 'number',
message: '请输入排序号',
trigger: 'blur'
}
],
merchantOwner: [
{
required: true,
type: 'number',
message: '请绑定商户负责人',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
console.log(value);
if (form.merchantOwner == 0) {
return Promise.reject('请绑定商户负责人');
}
return Promise.resolve();
}
}
],
merchantPhone: [
{
required: true,
type: 'string',
message: '请填写门店联系电话',
trigger: 'blur'
}
],
merchantHours: [
{
required: true,
type: 'string',
message: '请填写商户营业时间',
trigger: 'blur'
}
],
address: [
{
required: true,
type: 'string',
message: '请填写商户所在街道地址',
trigger: 'blur'
}
],
lngAndLat: [
{
required: true,
type: 'string',
message: '请设置商户的定位信息',
trigger: 'blur'
}
],
content: [
{
required: true,
type: 'string',
message: '请填写商户详情',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (content.value.length == 0) {
return Promise.reject('请填写商户详情');
}
return Promise.resolve();
}
}
],
region: [
{
required: true,
type: 'string',
message: '请选择商户所在区域',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (city.value.length == 0) {
return Promise.reject('请选择商户所在区域');
}
return Promise.resolve();
}
}
]
// ,
// 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();
// }
// }
// ]
});
// 插件
const plugins = ref([
gfm({
locale: zh_HansGfm
}),
highlight()
]);
/* 打开位置选择 */
const openMapPicker = () => {
showMap.value = true;
};
/* 地图选择后回调 */
const onDone = (location: CenterPoint) => {
city.value = [
`${location.city?.province}`,
`${location.city?.city}`,
`${location.city?.district}`
];
form.province = `${location.city?.province}`;
form.city = `${location.city?.city}`;
form.region = `${location.city?.district}`;
form.address = `${location.address}`;
form.lngAndLat = `${location.lng},${location.lat}`;
showMap.value = false;
};
const onSelect = (item) => {
form.merchantOwner = item.userId;
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const merchantForm = {
...form,
content: content.value
};
const saveOrUpdate = isUpdate.value ? updateMerchant : addMerchant;
saveOrUpdate(merchantForm)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
form.city = '[]';
resetFields();
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
});
images.value = [];
images.value.push({
uid: 1,
url: props.data.logo,
status: 'done'
});
content.value = props.data.content;
city.value = [
`${props.data.province}`,
`${props.data.city}`,
`${props.data.region}`
];
isUpdate.value = true;
} else {
isUpdate.value = false;
content.value = '';
}
} else {
resetFields();
formRef.value?.clearValidate();
}
}
);
</script>
<style lang="less">
.tab-pane {
min-height: 300px;
}
.ml-10 {
margin-left: 5px;
}
.flex-sb {
display: flex;
justify-content: space-between;
}
</style>

View File

@@ -0,0 +1,128 @@
<!-- 搜索表单 -->
<template>
<a-space>
<a-button
type="primary"
class="ele-btn-icon"
v-permission="'shop:merchant:save'"
@click="add"
>
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
<a-button
danger
type="primary"
class="ele-btn-icon"
:v-role="`dev`"
@click="removeBatch"
v-if="props.selection.length > 0"
>
<template #icon>
<DeleteOutlined />
</template>
<span>批量删除</span>
</a-button>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
@search="search"
@pressEnter="search"
>
<template #addonBefore>
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
<a-select-option value="merchantName">商户名称</a-select-option>
<a-select-option value="merchantCode">商户编号</a-select-option>
</a-select>
</template>
</a-input-search>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
import useSearch from '@/utils/use-search';
import type { MerchantParam } from '@/api/merchant/model';
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
import { ref, watch } from 'vue';
const emit = defineEmits<{
(e: 'search', where?: MerchantParam): void;
(e: 'add'): void;
(e: 'remove'): void;
}>();
const props = defineProps<{
// 勾选的项目
selection?: [];
}>();
// 表单数据
const { where, resetFields } = useSearch<MerchantParam>({
merchantId: undefined,
merchantName: '',
merchantCode: ''
});
// 下来选项
const type = ref('merchantName');
// tabType
const listType = ref('all');
// 搜索内容
const searchText = ref('');
/* 搜索 */
const search = () => {
if (type.value == 'merchantName') {
where.merchantName = searchText.value;
where.merchantCode = undefined;
}
if (type.value == 'merchantCode') {
where.merchantCode = searchText.value;
where.merchantName = undefined;
}
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,285 @@
<template>
<div class="page">
<a-page-header :ghost="false" title="门店店员">
<!-- <div class="ele-text-secondary"> 商户管理 </div>-->
</a-page-header>
<div class="ele-body">
<a-card :bordered="false">
<!-- 表格 -->
<ele-pro-table
ref="tableRef"
row-key="merchantClerkId"
: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 === 'logo'">
<a-image :src="record.logo" :preview="false" :width="80" />
</template>
<template v-if="column.key === 'merchantClerkName'">
<a-tooltip
:title="`商户编号:${record.merchantClerkCode}`"
placement="topLeft"
>
<p class="twoline-hide">
{{ record.merchantClerkName }}
</p>
</a-tooltip>
</template>
<template v-if="column.key === 'user'">
<a-tooltip :title="`用户ID${record.userId}`">
<a-avatar
:size="30"
:src="`${record.user.avatar}`"
style="margin-right: 4px"
>
<template #icon>
<UserOutlined />
</template>
</a-avatar>
<a @click="openInfo(record)">{{ record.user.nickname }}</a>
</a-tooltip>
</template>
<template v-if="column.key === 'phone'">
{{ record.user.phone }}
</template>
<template v-if="column.key === 'comments'">
<a-tooltip :title="record.comments" placement="topLeft">
{{ record.comments }}
</a-tooltip>
</template>
<template v-if="column.key === 'createTime'">
<a-tooltip :title="`${toDateString(record.createTime)}`">
{{ record.createTime }}
</a-tooltip>
</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>
<!-- 编辑弹窗 -->
<MerchantClerkEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
<!--suppress TypeScriptValidateTypes -->
<script lang="ts" setup>
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 MerchantClerkEdit from './components/merchant-clerk-edit.vue';
import { Category } from '@/api/goods/category/model';
import {
pageMerchantClerks,
removeMerchantClerk,
removeMerchantClerks
} from '@/api/merchant/clerk';
import type {
MerchantClerk,
MerchantClerkParam
} from '@/api/merchant/clerk/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 当前用户信息
// const brand = getDictionaryOptions('serverBrand');
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '所属商户',
dataIndex: 'merchantName',
key: 'merchantName',
ellipsis: true
},
{
title: '用户信息',
dataIndex: 'user',
key: 'user'
},
{
title: '真实姓名',
dataIndex: 'realName',
key: 'realName'
},
{
title: '手机号码',
dataIndex: 'phone',
key: 'phone'
},
{
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<MerchantClerk[]>([]);
// 当前编辑数据
const current = ref<MerchantClerk | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const showUser = ref(false);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.brand = filters.brand;
}
return pageMerchantClerks({ ...where, ...orders, page, limit });
};
/* 搜索 */
const reload = (where?: MerchantClerkParam) => {
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?: MerchantClerk) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开用户详情弹窗 */
const openInfo = (row?: MerchantClerk) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: MerchantClerk) => {
const hide = message.loading('请求中..', 0);
removeMerchantClerk(row.merchantClerkId)
.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);
removeMerchantClerks(selection.value.map((d) => d.merchantClerkId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
</script>
<script lang="ts">
export default {
name: 'MerchantClerkIndex'
};
</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>

View File

@@ -0,0 +1,243 @@
<!-- 用户编辑弹窗 -->
<template>
<a-drawer
:width="700"
:visible="visible"
:confirm-loading="loading"
:maxable="maxAble"
:title="'成员管理'"
:body-style="{ paddingBottom: '8px' }"
@update:visible="updateVisible"
:footer="null"
>
<!-- 表格 -->
<ele-pro-table
ref="tableRef"
row-key="userId"
:columns="columns"
:datasource="datasource"
v-model:selection="selection"
:where="defaultWhere"
cache-key="proSystemUserTable"
>
<template #toolbar>
<a-space>
<!-- <UserMerchantClerk @select="onSelect" />-->
<a-input
allow-clear
v-model="userId"
@change="getUserId"
placeholder="请输入用户ID"
/>
<a-button type="primary" class="ele-btn-icon" @click="save">
<template #icon>
<plus-outlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'nickname'">
<a-tooltip :title="`ID${record.userId}`">
<a-avatar
:size="30"
:src="`${record.user?.avatar}`"
style="margin-right: 4px"
>
<template #icon>
<UserOutlined />
</template>
</a-avatar>
{{ record.user?.nickname }}
</a-tooltip>
</template>
<template v-if="column.key === 'username'">
{{ record.user?.username }}
</template>
<template v-if="column.key === 'phone'">
{{ record.user?.phone }}
</template>
<template v-else-if="column.key === 'action'">
<a-space>
<a class="ele-text-danger" @click="remove(record)">移除</a>
</a-space>
</template>
</template>
</ele-pro-table>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, EleProTable } from 'ele-admin-pro';
import type {
MerchantClerk,
MerchantClerkParam
} from '@/api/merchant/clerk/model';
import {
ColumnItem,
DatasourceFunction
} from 'ele-admin-pro/es/ele-pro-table/types';
import { UserOutlined } from '@ant-design/icons-vue';
import {
addMerchantClerk,
pageMerchantClerks,
removeMerchantClerk
} from '@/api/merchant/clerk';
// import UserMerchantClerk from '@/components/UserChoose/index.vue';
const useForm = Form.useForm;
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: MerchantClerk | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '姓名',
key: 'nickname',
dataIndex: 'nickname'
},
{
title: '登录账号',
key: 'username',
dataIndex: 'username'
},
{
title: '手机号',
key: 'phone',
dataIndex: 'phone'
},
{
title: '操作',
key: 'action',
align: 'center'
}
]);
// 默认搜索条件
const defaultWhere = reactive({
username: '',
nickname: ''
});
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
where = {};
where.merchantCode = props.data?.merchantCode;
return pageMerchantClerks({ ...where, ...orders, page, limit });
};
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
/* 搜索 */
const reload = (where?: MerchantClerkParam) => {
tableRef?.value?.reload({ where: where });
};
// 用户信息
const clerk = reactive<MerchantClerk>({
clerkId: undefined,
// 商户名称
merchantName: '',
// 商户编号
merchantCode: '',
// 店员真实姓名
realName: '',
// 用户id
userId: undefined,
// 昵称
nickname: '',
// 登录账号
username: '',
// 创建时间
createTime: ''
});
// 请求状态
const loading = ref(true);
// 是否显示最大化切换按钮
const maxAble = ref(true);
// 选项卡位置
const { resetFields } = useForm(clerk);
// 选中用户
const userId = ref(undefined);
// const onSelect = (user) => {
// userId.value = user.userId;
// };
const getUserId = (e) => {
userId.value = e.target.value;
};
// 添加门店成员
const save = () => {
const data = {
merchantCode: props.data?.merchantCode,
userId: userId.value
};
addMerchantClerk(data)
.then((msg) => {
message.success(msg);
reload();
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
};
/* 删除单个 */
const remove = (row: MerchantClerk) => {
console.log(row);
const hide = message.loading('请求中..', 0);
removeMerchantClerk(row.clerkId)
.then(() => {
hide();
message.success('移除成功');
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
watch(
() => props.visible,
(visible) => {
if (visible) {
if (props.data) {
loading.value = false;
assignObject(clerk, props.data);
reload();
}
} else {
resetFields();
}
}
);
</script>
<style lang="less">
.tab-pane {
min-height: 100px;
}
.important {
font-weight: bold;
}
</style>

View File

@@ -0,0 +1,576 @@
<!-- 用户编辑弹窗 -->
<template>
<ele-modal
:width="750"
:visible="visible"
:confirm-loading="loading"
:maxable="maxAble"
:title="isUpdate ? '编辑商户' : '添加商户'"
:body-style="{ paddingBottom: '8px' }"
@update:visible="updateVisible"
:maskClosable="false"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
layout="vertical"
>
<a-form-item label="商户编号" name="merchantCode">
<a-input
allow-clear
placeholder="请输入商户编号"
:disabled="isUpdate"
v-model:value="form.merchantCode"
/>
</a-form-item>
<a-form-item label="商户名称" name="merchantName">
<a-input
allow-clear
placeholder="请输入商户名称"
v-model:value="form.merchantName"
/>
</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="LOGO" name="images" extra="建议尺寸: 120*120">
<ele-image-upload
v-model:value="images"
:limit="1"
:drag="true"
:item-style="{ width: '80px', height: '80px' }"
:upload-handler="uploadHandler"
@upload="onUpload"
/>
</a-form-item>
<a-form-item label="背景图" name="background" extra="建议尺寸: 750*200">
<ele-image-upload
v-model:value="background"
:limit="1"
:drag="true"
:item-style="{ width: '360px', height: '100px' }"
:upload-handler="backgroundHandler"
@upload="onUploadBackground"
/>
</a-form-item>
<!-- <a-form-item-->
<!-- label="负责人"-->
<!-- name="merchantOwner"-->
<!-- extra="请绑定负责人,注意:超管和游客账号不要绑定"-->
<!-- >-->
<!-- <OwnerChoose :value="form.merchantOwner" @select="onSelect" />-->
<!-- </a-form-item>-->
<a-form-item label="营业时间" name="merchantHours">
<a-input
allow-clear
placeholder="请输入营业时间"
v-model:value="form.merchantHours"
/>
</a-form-item>
<a-form-item label="门店电话" name="merchantPhone">
<a-input
allow-clear
placeholder="请输入门店电话"
v-model:value="form.merchantPhone"
/>
</a-form-item>
<a-form-item label="商户坐标" name="lngAndLat">
<div class="flex-sb">
<a-input
allow-clear
placeholder="请选择所在位置"
v-model:value="form.lngAndLat"
disabled
/>
<a-button
class="ele-btn-icon"
style="margin-left: 10px"
@click="openMapPicker"
>
打开地图位置选择器
</a-button>
</div>
</a-form-item>
<a-form-item label="所在地区" name="region">
<div class="flex-sb">
<regions-select
v-model:value="city"
valueField="label"
placeholder="请选择省市区"
class="ele-fluid"
@change="onChangeRegion"
/>
</div>
</a-form-item>
<a-form-item label="街道地址" name="address">
<a-input
allow-clear
placeholder="请输入详细街道地址"
v-model:value="form.address"
/>
</a-form-item>
<a-form-item label="商户详情" name="content">
<!-- 编辑器 -->
<byte-md-editor
v-model:value="content"
:locale="zh_Hans"
:plugins="plugins"
height="350px"
/>
</a-form-item>
<a-form-item 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-item label="排序号" name="sortNumber">
<a-input-number
:min="0"
:max="99999"
class="ele-fluid"
placeholder="请输入排序号(数字越小越靠前)"
v-model:value="form.sortNumber"
/>
</a-form-item>
<!-- 地图位置选择弹窗 -->
<ele-map-picker
:need-city="true"
:dark-mode="darkMode"
v-model:visible="showMap"
:center="[108.374959, 22.767024]"
:search-type="1"
:zoom="12"
@done="onDone"
/>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { message } from 'ant-design-vue';
import type { Merchant } from '@/api/merchant/model';
import { addMerchant, updateMerchant } from '@/api/merchant';
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 OwnerChoose from '@/components/UserChoose/index.vue';
import { FILE_SERVER, FILE_THUMBNAIL } from '@/config/setting';
import useFormData from '@/utils/use-form-data';
import RegionsSelect from '@/components/RegionsSelect/index.vue';
import { createMerchantCode } from '@/utils/common';
import { storeToRefs } from 'pinia';
import { useThemeStore } from '@/store/modules/theme';
import type { CenterPoint } from 'ele-admin-pro/es/ele-map-picker/types';
import ByteMdEditor from '@/components/ByteMdEditor/index.vue';
import highlight from '@bytemd/plugin-highlight';
// 中文语言文件
import zh_Hans from 'bytemd/locales/zh_Hans.json';
// // 链接、删除线、复选框、表格等的插件
import gfm from '@bytemd/plugin-gfm';
// // 插件的中文语言文件
import zh_HansGfm from '@bytemd/plugin-gfm/locales/zh_Hans.json';
// // 预览界面的样式,这里用的 github 的 markdown 主题
import 'github-markdown-css/github-markdown-light.css';
// 是否是修改
const isUpdate = ref(false);
// 是否显示最大化切换按钮
const maxAble = ref(true);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Merchant | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const themeStore = useThemeStore();
const { darkMode } = storeToRefs(themeStore);
// 提交状态
const loading = ref(false);
// 已上传数据
const images = ref<ItemType[]>([]);
const background = ref<ItemType[]>([]);
const formRef = ref<FormInstance | null>(null);
// 编辑器内容,双向绑定
const content = ref<any>('');
// 省市区
const city = ref<string[]>([]);
// 是否显示地图选择弹窗
const showMap = ref(false);
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 选择地区
const onChangeRegion = (value) => {
form.province = value[0];
form.city = value[1];
form.region = value[2];
};
// 表单数据
const { form, resetFields, assignFields } = useFormData<Merchant>({
merchantName: '',
merchantCode: `M${createMerchantCode()}`,
image: '',
logo: '',
background: '',
createTime: '',
comments: '',
sortNumber: 100,
status: 0,
linkman: '',
address: '',
lngAndLat: '',
phone: '',
merchantId: 0,
userId: undefined,
merchantOwner: 0,
merchantPhone: undefined,
content: '',
merchantHours: '8:30 - 22:30',
province: '',
city: '',
region: '',
customerId: 0
});
/* 上传事件 */
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: data.url,
status: 'done'
});
form.logo = data.thumbnail;
message.success('上传成功');
})
.catch((e) => {
message.error(e.message);
});
};
const backgroundHandler = (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;
}
onUploadBackground(item);
};
// 上传文件
const onUploadBackground = (item) => {
const { file } = item;
uploadFile(file)
.then((data) => {
background.value.push({
uid: data.id,
url: data.url,
status: 'done'
});
form.background = data.url;
message.success('上传成功');
})
.catch((e) => {
message.error(e.message);
});
};
// 表单验证规则
const rules = reactive<Record<string, Rule[]>>({
merchantName: [
{
required: true,
message: '请输入商户名称',
type: 'string',
trigger: 'blur'
}
],
merchantCode: [
{
required: true,
type: 'string',
message: '请填写商户编号',
trigger: 'blur'
}
],
// comments: [
// {
// required: true,
// type: 'string',
// message: '请填写商户简介',
// trigger: 'blur'
// }
// ],
status: [
{
required: true,
type: 'number',
message: '请选择商户状态',
trigger: 'blur'
}
],
sortNumber: [
{
required: true,
type: 'number',
message: '请输入排序号',
trigger: 'blur'
}
],
merchantOwner: [
{
required: true,
type: 'number',
message: '请绑定商户负责人',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
console.log(value);
if (form.merchantOwner == 0) {
return Promise.reject('请绑定商户负责人');
}
return Promise.resolve();
}
}
],
merchantPhone: [
{
required: true,
type: 'string',
message: '请填写门店联系电话',
trigger: 'blur'
}
],
merchantHours: [
{
required: true,
type: 'string',
message: '请填写商户营业时间',
trigger: 'blur'
}
],
address: [
{
required: true,
type: 'string',
message: '请填写商户所在街道地址',
trigger: 'blur'
}
],
lngAndLat: [
{
required: true,
type: 'string',
message: '请设置商户的定位信息',
trigger: 'blur'
}
],
content: [
{
required: true,
type: 'string',
message: '请填写商户详情',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (content.value.length == 0) {
return Promise.reject('请填写商户详情');
}
return Promise.resolve();
}
}
],
region: [
{
required: true,
type: 'string',
message: '请选择商户所在区域',
trigger: 'blur',
validator: async (_rule: RuleObject, value: string) => {
if (city.value.length == 0) {
return Promise.reject('请选择商户所在区域');
}
return Promise.resolve();
}
}
]
// ,
// 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();
// }
// }
// ]
});
// 插件
const plugins = ref([
gfm({
locale: zh_HansGfm
}),
highlight()
]);
/* 打开位置选择 */
const openMapPicker = () => {
showMap.value = true;
};
/* 地图选择后回调 */
const onDone = (location: CenterPoint) => {
city.value = [
`${location.city?.province}`,
`${location.city?.city}`,
`${location.city?.district}`
];
form.province = `${location.city?.province}`;
form.city = `${location.city?.city}`;
form.region = `${location.city?.district}`;
form.address = `${location.address}`;
form.lngAndLat = `${location.lng},${location.lat}`;
showMap.value = false;
};
// const onSelect = (item) => {
// form.merchantOwner = item.userId;
// };
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const merchantForm = {
...form,
content: content.value
};
const saveOrUpdate = isUpdate.value ? updateMerchant : addMerchant;
saveOrUpdate(merchantForm)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
form.city = '[]';
resetFields();
form.merchantCode = '';
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
});
images.value = [];
background.value = [];
images.value.push({
uid: 1,
url: props.data.logo,
status: 'done'
});
background.value.push({
uid: 1,
url: props.data.background,
status: 'done'
});
content.value = props.data.content;
city.value = [
`${props.data.province}`,
`${props.data.city}`,
`${props.data.region}`
];
isUpdate.value = true;
} else {
isUpdate.value = false;
content.value = '';
}
} else {
resetFields();
formRef.value?.clearValidate();
}
}
);
</script>
<style lang="less">
.tab-pane {
min-height: 300px;
}
.ml-10 {
margin-left: 5px;
}
.flex-sb {
display: flex;
justify-content: space-between;
}
</style>

View File

@@ -0,0 +1,128 @@
<!-- 搜索表单 -->
<template>
<a-space>
<a-button
type="primary"
class="ele-btn-icon"
v-permission="'shop:merchant:save'"
@click="add"
>
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
<a-button
danger
type="primary"
class="ele-btn-icon"
:v-role="`dev`"
@click="removeBatch"
v-if="props.selection.length > 0"
>
<template #icon>
<DeleteOutlined />
</template>
<span>批量删除</span>
</a-button>
<a-input-search
allow-clear
v-model:value="searchText"
placeholder="请输入搜索关键词"
@search="search"
@pressEnter="search"
>
<template #addonBefore>
<a-select v-model:value="type" style="width: 120px; margin: -5px -12px">
<a-select-option value="merchantName">商户名称</a-select-option>
<a-select-option value="merchantCode">商户编号</a-select-option>
</a-select>
</template>
</a-input-search>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
import useSearch from '@/utils/use-search';
import type { MerchantParam } from '@/api/merchant/model';
// import CustomerSelect from '@/components/CustomerSelect/index.vue';
import { ref, watch } from 'vue';
const emit = defineEmits<{
(e: 'search', where?: MerchantParam): void;
(e: 'add'): void;
(e: 'remove'): void;
}>();
const props = defineProps<{
// 勾选的项目
selection?: [];
}>();
// 表单数据
const { where, resetFields } = useSearch<MerchantParam>({
merchantId: undefined,
merchantName: '',
merchantCode: ''
});
// 下来选项
const type = ref('merchantName');
// tabType
const listType = ref('all');
// 搜索内容
const searchText = ref('');
/* 搜索 */
const search = () => {
if (type.value == 'merchantName') {
where.merchantName = searchText.value;
where.merchantCode = undefined;
}
if (type.value == 'merchantCode') {
where.merchantCode = searchText.value;
where.merchantName = undefined;
}
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,312 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false">
<!-- 表格 -->
<ele-pro-table
ref="tableRef"
row-key="merchantId"
:columns="columns"
:height="tableHeight"
:customRow="customRow"
: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 === 'logo'">
<a-image :src="record.logo" :preview="false" :width="80" />
</template>
<template v-if="column.key === 'merchantName'">
<a-tooltip
:title="`门店编号:${record.merchantCode}`"
placement="topLeft"
>
<p class="twoline-hide">
{{ record.merchantName }}
</p>
</a-tooltip>
</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="orange">停业中</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 === 'createTime'">
<a-tooltip :title="`${toDateString(record.createTime)}`">
{{ timeAgo(record.createTime) }}
</a-tooltip>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openUser(record)">成员管理</a>
<a-divider type="vertical" />
<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>
<!-- 编辑弹窗 -->
<merchant-edit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
<!-- 账号管理 -->
<merchant-user
v-model:visible="showUser"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
<!--suppress TypeScriptValidateTypes -->
<script lang="ts" setup>
import { timeAgo } from 'ele-admin-pro';
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 MerchantEdit from './components/merchant-edit.vue';
import MerchantUser from './components/clerk.vue';
import { Category } from '@/api/goods/category/model';
import {
pageMerchant,
removeMerchant,
removeBatchMerchant
} from '@/api/merchant';
import type { Merchant, MerchantParam } from '@/api/merchant/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 当前用户信息
// const brand = getDictionaryOptions('serverBrand');
// 表格列配置
const columns = ref<ColumnItem[]>([
{
key: 'index',
width: 48,
align: 'center',
fixed: 'left',
hideInSetting: true,
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
},
{
title: '门店名称',
dataIndex: 'merchantName',
key: 'merchantName',
ellipsis: true
},
{
title: 'LOGO',
dataIndex: 'logo',
key: 'logo'
},
{
title: '地址',
dataIndex: 'address',
key: 'address'
},
{
title: '联系电话',
dataIndex: 'merchantPhone',
key: 'merchantPhone'
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
hideInTable: true,
ellipsis: true
},
{
title: '状态',
dataIndex: 'status',
sorter: true,
key: 'status',
showSorterTooltip: false,
customRender: ({ text }) => ['上架', '下架'][text]
},
{
title: '排序',
dataIndex: 'sortNumber',
hideInTable: true,
sorter: true
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
sorter: true,
ellipsis: true,
hideInTable: true,
customRender: ({ text }) => toDateString(text)
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center',
hideInSetting: true
}
]);
// 表格选中数据
const selection = ref<Merchant[]>([]);
// 当前编辑数据
const current = ref<Merchant | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
const showUser = ref(false);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.brand = filters.brand;
}
return pageMerchant({ ...where, ...orders, page, limit });
};
/* 搜索 */
const reload = (where?: MerchantParam) => {
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?: Merchant) => {
current.value = row ?? null;
showEdit.value = true;
};
const openUser = (row?: Merchant) => {
current.value = row ?? null;
showUser.value = true;
};
/* 删除单个 */
const remove = (row: Merchant) => {
const hide = message.loading('请求中..', 0);
removeMerchant(row.merchantId)
.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);
removeBatchMerchant(selection.value.map((d) => d.merchantId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: Merchant) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
</script>
<script lang="ts">
export default {
name: 'MerchantIndex'
};
</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>

View File

@@ -0,0 +1,292 @@
<template>
<div class="ele-body ele-body-card">
<a-card :bordered="false" class="user-info-tabs" style="min-height: 600px">
<a-tabs v-model:active-key="active" size="large">
<a-tab-pane tab="基本信息" key="info">
<a-form
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
>
<a-form-item label="商城名称" v-bind="validateInfos.storeName">
<a-input
v-model:value="form.storeName"
placeholder="请输入商城名称"
allow-clear
/>
</a-form-item>
<a-form-item label="商城全称" v-bind="validateInfos.fullName">
<a-input
v-model:value="form.fullName"
placeholder="请输入商城名称"
allow-clear
/>
</a-form-item>
<a-form-item label="商城介绍">
<a-textarea
v-model:value="form.comments"
placeholder="请输入商城介绍"
:rows="4"
/>
</a-form-item>
<a-form-item :wrapper-col="{ md: { offset: 6 } }">
<a-button type="primary" :loading="loading" @click="save">
{{ loading ? '保存中..' : '保存更改' }}
</a-button>
</a-form-item>
</a-form>
</a-tab-pane>
</a-tabs>
</a-card>
<!-- 头像裁剪弹窗 -->
<ele-cropper-modal
:src="form.avatar"
v-model:visible="visible"
@done="onCrop"
/>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, computed, watch, unref } from 'vue';
import {
UploadOutlined,
UserOutlined,
HomeOutlined,
EnvironmentOutlined,
TagOutlined,
QqOutlined,
WechatOutlined,
AlipayOutlined
} from '@ant-design/icons-vue';
import { Form, message } from 'ant-design-vue';
import { assignObject } from 'ele-admin-pro';
import { useUserStore } from '@/store/modules/user';
import { useRouter } from 'vue-router';
import { addStore, listStore, updateStore } from '@/api/merchant/setting';
import type { Store } from '@/api/merchant/setting/model';
const { currentRoute } = useRouter();
const useForm = Form.useForm;
const userStore = useUserStore();
// 是否是修改
const isUpdate = ref(false);
// tab页选中
const active = ref('info');
// 保存按钮loading
const loading = ref(false);
// 是否显示裁剪弹窗
const visible = ref(false);
// 登录用户信息
const loginUser = computed(() => userStore.info ?? {});
// 表单数据
const form = reactive<Store>({
storeName: '',
fullName: '',
comments: '',
storeId: undefined
});
// 表单验证规则
const rules = reactive({
storeName: [
{
required: true,
message: '请输入系统名称',
type: 'string',
trigger: 'blur'
}
]
});
const { validate, validateInfos } = useForm(form, rules);
/* 修改登录用户 */
const updateLoginUser = (obj: Record<string, any>) => {
userStore.setInfo(assignObject({ ...loginUser.value }, obj));
};
/* 保存更改 */
const save = () => {
validate()
.then(() => {
loading.value = true;
const data = {
...form
// 处理其他数据
};
const saveOrUpdate = isUpdate.value ? updateStore : addStore;
saveOrUpdate(data)
.then((msg) => {
loading.value = false;
message.success(msg);
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
/* 头像裁剪完成回调 */
const onCrop = (result: string) => {
form.avatar = result;
visible.value = false;
updateLoginUser(form);
};
/* 打开图片裁剪 */
const openCropper = () => {
visible.value = true;
};
const query = () => {
console.log('>>>>');
listStore().then((res) => {
if (res[0]) {
isUpdate.value = true;
assignObject(form, res[0]);
}
});
};
watch(
currentRoute,
(route) => {
const { path } = unref(route);
if (path !== '/shop/store') {
return;
}
query();
},
{
immediate: true
}
);
</script>
<script lang="ts">
export default {
name: 'UserProfile'
};
</script>
<style lang="less" scoped>
/* 用户资料卡片 */
.user-info-avatar-group {
margin: 16px 0;
display: inline-block;
position: relative;
cursor: pointer;
.user-info-avatar-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #fff;
font-size: 30px;
display: none;
z-index: 2;
}
&:hover .user-info-avatar-icon {
display: block;
}
&:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
background-color: transparent;
transition: background-color 0.3s;
}
&:hover:after {
background-color: rgba(0, 0, 0, 0.4);
}
& + h1 {
margin-bottom: 8px;
}
}
/* 用户信息列表 */
.user-info-list {
margin: 47px 0 32px 0;
.ele-cell + .ele-cell {
margin-top: 16px;
}
& + .ant-divider {
margin-bottom: 16px;
}
}
/* 用户标签 */
.user-info-tags {
margin: 16px 0 4px 0;
.ant-tag {
margin: 0 12px 8px 0;
}
}
/* 右侧卡片 */
.user-info-tabs {
:deep(.ant-card-body) {
padding: 0;
}
:deep(.ant-tabs-tab) {
padding-left: 4px;
padding-right: 4px;
margin: 0 12px 0 28px !important;
}
.ant-form {
max-width: 580px;
margin-top: 20px;
padding: 0 24px;
}
}
/* 用户账号绑定列表 */
.user-account-list {
margin-bottom: 16px;
& > .ele-cell {
padding: 18px 34px;
}
.user-account-icon {
color: #fff;
padding: 8px;
font-size: 26px;
border-radius: 50%;
&.anticon-qq {
background: #3492ed;
}
&.anticon-wechat {
background: #4daf29;
}
&.anticon-alipay {
background: #1476fe;
}
}
}
</style>

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>