This commit is contained in:
2024-12-24 20:31:47 +08:00
parent 9e831de60b
commit 07b1f341b3
100 changed files with 11616 additions and 1653 deletions

View File

@@ -0,0 +1,125 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="'80%'"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="'评论列表'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
:footer="null"
@cancel="updateVisible(false)"
>
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</template>
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, watch} from 'vue';
import type {EleProTable} from "ele-admin-pro";
import {Article} from "@/api/cms/article/model";
import {pageCmsArticleComment, removeCmsArticleComment} from "@/api/cms/cmsArticleComment";
import {message} from "ant-design-vue";
import {CmsArticleComment} from "@/api/cms/cmsArticleComment/model";
const columns = ref<any[]>([{
title: '昵称',
dataIndex: ['nickname'],
align: 'center',
},
{
title: '评论内容',
dataIndex: 'content',
align: 'center',
},
{
title: '评论时间',
dataIndex: 'createTime',
align: 'center',
},
{
title: '操作',
key: 'action',
align: 'center',
},
]);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Article | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 是否显示最大化切换按钮
const maxable = ref(true);
const datasource = ({page, limit}) => {
return pageCmsArticleComment({
articleId: props.data?.articleId,
page,
limit
})
}
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
emit('done');
};
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const reload = () => {
tableRef.value?.reload();
}
const remove = (row: CmsArticleComment) => {
const hide = message.loading('请求中..', 0);
removeCmsArticleComment(row.commentId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
} else {
reload()
}
},
{immediate: true}
);
</script>

View File

@@ -41,7 +41,7 @@
allow-clear
placeholder="请输入关键词"
style="width: 280px"
v-model:value="where.userId"
v-model:value="where.keywords"
@pressEnter="reload"
@search="reload"
/>

View File

@@ -30,7 +30,7 @@
<span
class="cursor-pointer"
@click="openSpmUrl(`/detail`, record, record.articleId)"
>{{ record.title }}</span
>{{ record.title }}</span
>
</template>
<template v-if="column.key === 'categoryName'">
@@ -43,7 +43,7 @@
record.categoryId
)
"
>{{ record.categoryName }}</span
>{{ record.categoryName }}</span
>
</template>
<template v-if="column.key === 'type'">
@@ -66,13 +66,15 @@
:color="record.status == 0 ? 'green' : 'red'"
class="cursor-pointer"
@click="onUpdate(record)"
>{{ record.statusText }}
>{{ record.statusText }}
</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openComment(record)">评论</a>
<a-divider type="vertical"/>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-divider type="vertical"/>
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -93,279 +95,296 @@
:data="current"
@done="reload"
/>
<CommentList
v-model:visible="showComment"
:data="current"
@done="reload"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref, watch } 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 Search from './components/search.vue';
import ArticleEdit from './components/articleEdit.vue';
import {
pageArticle,
removeArticle,
removeBatchArticle
} from '@/api/cms/article';
import type { Article, ArticleParam } from '@/api/cms/article/model';
import { formatNumber } from 'ele-admin-pro/es';
import router from '@/router';
import { toTreeData } from 'ele-admin-pro';
import { isImage, openSpmUrl } from '@/utils/common';
import { listNavigation } from '@/api/cms/navigation';
import { Navigation } from '@/api/cms/navigation/model';
import { getMerchantId } from '@/utils/merchant';
import {createVNode, ref, watch} 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 Search from './components/search.vue';
import ArticleEdit from './components/articleEdit.vue';
import {
pageArticle,
removeArticle,
removeBatchArticle
} from '@/api/cms/article';
import type {Article, ArticleParam} from '@/api/cms/article/model';
import {formatNumber} from 'ele-admin-pro/es';
import router from '@/router';
import {toTreeData} from 'ele-admin-pro';
import {isImage, openSpmUrl} from '@/utils/common';
import {listNavigation} from '@/api/cms/navigation';
import {Navigation} from '@/api/cms/navigation/model';
import {getMerchantId} from '@/utils/merchant';
import CommentList from "@/views/cms/article/components/commentList.vue";
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<Article[]>([]);
// 当前编辑数据
const current = ref<Article | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<any>(getMerchantId());
// 栏目ID
const categoryId = ref<number>();
// 当前模型
const model = ref<number>();
// 栏目数据
const navigationList = ref<Navigation[]>();
// 表格选中数据
const selection = ref<Article[]>([]);
// 当前编辑数据
const current = ref<Article | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 店铺ID
const merchantId = ref<any>(getMerchantId());
// 栏目ID
const categoryId = ref<number>();
// 当前模型
const model = ref<number>();
// 栏目数据
const navigationList = ref<Navigation[]>();
// 表格数据源
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
where.merchantId = getMerchantId();
return pageArticle({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
width: 90
},
{
title: '封面图',
dataIndex: 'image',
key: 'image',
width: 120,
align: 'center'
},
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
{
title: '栏目名称',
dataIndex: 'categoryName',
key: 'categoryName',
width: 120,
align: 'center'
},
{
title: '所属栏目',
dataIndex: 'categoryId',
key: 'categoryId',
align: 'center',
hideInTable: true
},
{
title: '实际阅读量',
dataIndex: 'actualViews',
key: 'actualViews',
sorter: true,
width: 120,
align: 'center'
},
{
title: '虚拟阅读量',
dataIndex: 'virtualViews',
key: 'virtualViews',
width: 120,
align: 'center'
},
{
title: '推荐',
dataIndex: 'recommend',
key: 'recommend',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
sorter: true,
width: 120,
align: 'center'
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ArticleParam) => {
if (where?.categoryId) {
categoryId.value = where.categoryId;
}
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Article) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
const onUpdate = (row?: Article) => {
// const isShow = row?.isShow == 0 ? 1 : 0;
// updateArticle({ ...row, isShow }).then((msg) => {
// message.success(msg);
// reload();
// });
};
/* 删除单个 */
const remove = (row: Article) => {
const hide = message.loading('请求中..', 0);
removeArticle(row.articleId)
.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);
removeBatchArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: Article) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (d.model != 'article') {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
// 表格数据源
const datasource: DatasourceFunction = ({page, limit, where, orders}) => {
if (categoryId.value) {
where.categoryId = categoryId.value;
}
where.merchantId = getMerchantId();
return pageArticle({
...where,
...orders,
page,
limit
});
};
watch(
() => router.currentRoute.value.query,
(query) => {
console.log(query);
if (query) {
categoryId.value = Number(query.id);
model.value = Number(query.type);
reload();
}
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
width: 90
},
{
title: '封面图',
dataIndex: 'image',
key: 'image',
width: 120,
align: 'center'
},
{
title: '文章标题',
dataIndex: 'title',
key: 'title'
},
{
title: '栏目名称',
dataIndex: 'categoryName',
key: 'categoryName',
width: 120,
align: 'center'
},
{
title: '所属栏目',
dataIndex: 'categoryId',
key: 'categoryId',
align: 'center',
hideInTable: true
},
{
title: '实际阅读量',
dataIndex: 'actualViews',
key: 'actualViews',
sorter: true,
width: 120,
align: 'center'
},
{
title: '虚拟阅读量',
dataIndex: 'virtualViews',
key: 'virtualViews',
width: 120,
align: 'center'
},
{
title: '评论数',
dataIndex: 'commentNumbers',
align: 'center'
},
{
title: '推荐',
dataIndex: 'recommend',
key: 'recommend',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
sorter: true,
width: 120,
align: 'center'
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
sorter: true,
align: 'center',
hideInTable: true
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ArticleParam) => {
if (where?.categoryId) {
categoryId.value = where.categoryId;
}
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: Article) => {
current.value = row ?? null;
showEdit.value = true;
};
const showComment = ref(false)
const openComment = (row?: Article) => {
current.value = row ?? null;
showComment.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
const onUpdate = (row?: Article) => {
// const isShow = row?.isShow == 0 ? 1 : 0;
// updateArticle({ ...row, isShow }).then((msg) => {
// message.success(msg);
// reload();
// });
};
/* 删除单个 */
const remove = (row: Article) => {
const hide = message.loading('请求中..', 0);
removeArticle(row.articleId)
.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);
removeBatchArticle(selection.value.map((d) => d.articleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 自定义行属性 */
const customRow = (record: Article) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
{ immediate: true }
);
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
// 加载栏目数据
if (!navigationList.value) {
listNavigation({}).then((res) => {
navigationList.value = toTreeData({
data: res?.map((d) => {
d.value = d.navigationId;
d.label = d.title;
if (d.model != 'article') {
d.disabled = true;
}
return d;
}),
idField: 'navigationId',
parentIdField: 'parentId'
});
});
}
watch(
() => router.currentRoute.value.query,
(query) => {
console.log(query);
if (query) {
categoryId.value = Number(query.id);
model.value = Number(query.type);
reload();
}
},
{immediate: true}
);
</script>
<script lang="ts">
export default {
name: 'ArticleV2'
};
export default {
name: 'ArticleV2'
};
</script>

View File

@@ -0,0 +1,220 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑' : '添加'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="文章ID" name="articleId">
<a-input
allow-clear
placeholder="请输入文章ID"
v-model:value="form.articleId"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="0待审核1通过2拒绝" 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="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addArticleCheck, updateArticleCheck } from '@/api/cms/articleCheck';
import { ArticleCheck } from '@/api/cms/articleCheck/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ArticleCheck | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<ArticleCheck>({
id: undefined,
articleId: undefined,
userId: undefined,
status: undefined,
sortNumber: undefined,
comments: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
articleCheckId: undefined,
articleCheckName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
articleCheckName: [
{
required: true,
type: 'string',
message: '请填写名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateArticleCheck : addArticleCheck;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,257 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="articleCheckId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ArticleCheckEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ArticleCheckEdit from './components/articleCheckEdit.vue';
import { pageArticleCheck, removeArticleCheck, removeBatchArticleCheck } from '@/api/cms/articleCheck';
import type { ArticleCheck, ArticleCheckParam } from '@/api/cms/articleCheck/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ArticleCheck[]>([]);
// 当前编辑数据
const current = ref<ArticleCheck | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageArticleCheck({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '文章ID',
dataIndex: 'articleId',
key: 'articleId',
align: 'center',
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '0待审核1通过2拒绝',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ArticleCheckParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ArticleCheck) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ArticleCheck) => {
const hide = message.loading('请求中..', 0);
removeArticleCheck(row.articleCheckId)
.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);
removeBatchArticleCheck(selection.value.map((d) => d.articleCheckId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ArticleCheck) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ArticleCheck'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,220 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑关注' : '添加关注'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="" name="followUserId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.followUserId"
/>
</a-form-item>
<a-form-item label="排序(数字越小越靠前)" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="状态, 0已发布, 1待审核 2已驳回 3违规内容" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addFollow, updateFollow } from '@/api/cms/follow';
import { Follow } from '@/api/cms/follow/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Follow | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<Follow>({
id: undefined,
userId: undefined,
followUserId: undefined,
sortNumber: undefined,
comments: undefined,
status: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
followId: undefined,
followName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
followName: [
{
required: true,
type: 'string',
message: '请填写关注名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateFollow : addFollow;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,257 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="followId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<FollowEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import FollowEdit from './components/followEdit.vue';
import { pageFollow, removeFollow, removeBatchFollow } from '@/api/cms/follow';
import type { Follow, FollowParam } from '@/api/cms/follow/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<Follow[]>([]);
// 当前编辑数据
const current = ref<Follow | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageFollow({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '',
dataIndex: 'followUserId',
key: 'followUserId',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '状态, 0已发布, 1待审核 2已驳回 3违规内容',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: FollowParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Follow) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: Follow) => {
const hide = message.loading('请求中..', 0);
removeFollow(row.followId)
.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);
removeBatchFollow(selection.value.map((d) => d.followId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: Follow) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'Follow'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,171 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑分红角色' : '添加分红角色'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="角色名称" name="title">
<a-input
allow-clear
placeholder="请输入角色名称"
v-model:value="form.title"
/>
</a-form-item>
<a-form-item label="地区选择" required v-if="areaList.length">
<a-cascader v-model:value="city" :options="areaList" placeholder="点击选择省市"
:field-names="areaFieldNames"
change-on-select
@change="changeArea"/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject,} from 'ele-admin-pro';
import {addCommissionRole, updateCommissionRole} from '@/api/shop/commissionRole';
import {CommissionRole} from '@/api/shop/commissionRole/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {FormInstance} from 'ant-design-vue/es/form';
import {Area} from "@/api/system/area/model";
import {listArea} from "@/api/system/area";
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: CommissionRole | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
// 用户信息
const form = reactive<CommissionRole>({
id: undefined,
title: undefined,
provinceId: undefined,
cityId: undefined,
regionId: undefined,
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
title: [
{
required: true,
type: 'string',
message: '请填写分红角色名称',
trigger: 'blur'
}
]
});
const areaFieldNames = {
label: 'name',
value: 'id'
}
const city = ref([])
const areaList = ref<Area[]>([])
const getAreaList = async () => {
areaList.value = await listArea({})
}
const changeArea = (value) => {
if (value.length > 0) {
form.provinceId = value[0]
if (value.length > 1) {
form.cityId = value[1]
if (value.length > 2) form.regionId = value[2]
}
}
}
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
if (!city.value.length) return message.error('请选择地区')
const saveOrUpdate = isUpdate.value ? updateCommissionRole : addCommissionRole;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
});
};
watch(
() => props.visible,
async (visible) => {
if (visible) {
await getAreaList()
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{immediate: true}
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,239 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="commissionRoleId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<CommissionRoleEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import CommissionRoleEdit from './components/commissionRoleEdit.vue';
import { pageCommissionRole, removeCommissionRole, removeBatchCommissionRole } from '@/api/shop/commissionRole';
import type { CommissionRole, CommissionRoleParam } from '@/api/shop/commissionRole/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<CommissionRole[]>([]);
// 当前编辑数据
const current = ref<CommissionRole | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageCommissionRole({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '名称',
dataIndex: 'title',
key: 'title',
align: 'center',
},
{
title: '省',
dataIndex: ['province', 'name'],
key: 'region',
align: 'center',
},
{
title: '市',
dataIndex: ['city', 'name'],
key: 'region',
align: 'center',
},
{
title: '区/县',
dataIndex: ['region', 'name'],
key: 'region',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: CommissionRoleParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: CommissionRole) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: CommissionRole) => {
const hide = message.loading('请求中..', 0);
removeCommissionRole(row.commissionRoleId)
.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);
removeBatchCommissionRole(selection.value.map((d) => d.commissionRoleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: CommissionRole) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'CommissionRole'
};
</script>
<style lang="less" scoped></style>

View File

@@ -19,13 +19,6 @@
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="分销商用户ID" name="userId">
<a-input
allow-clear
placeholder="请输入分销商用户ID"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="提现金额" name="money">
<a-input
allow-clear
@@ -33,234 +26,196 @@
v-model:value="form.money"
/>
</a-form-item>
<a-form-item label="打款方式 (10微信 20支付宝 30银行卡)" name="payType">
<a-input
allow-clear
placeholder="请输入打款方式 (10微信 20支付宝 30银行卡)"
v-model:value="form.payType"
/>
<a-form-item label="打款方式" name="payType">
<a-select v-model:value="form.payType" disabled>
<a-select-option :value="10">微信</a-select-option>
<a-select-option :value="20">支付宝</a-select-option>
<a-select-option :value="30">银行卡</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="支付宝姓名" name="alipayName">
<a-input
allow-clear
placeholder="请输入支付宝姓名"
v-model:value="form.alipayName"
/>
<template v-if="form.payType === 20">
<a-form-item label="支付宝姓名" name="alipayName">
<a-input disabled
allow-clear
placeholder="请输入支付宝姓名"
v-model:value="form.alipayName"
/>
</a-form-item>
<a-form-item label="支付宝账号" name="alipayAccount">
<a-input disabled
allow-clear
placeholder="请输入支付宝账号"
v-model:value="form.alipayAccount"
/>
</a-form-item>
</template>
<template v-if="form.payType === 30">
<a-form-item label="开户行名称" name="bankName">
<a-input
allow-clear
placeholder="请输入开户行名称"
v-model:value="form.bankName"
/>
</a-form-item>
<a-form-item label="银行开户名" name="bankAccount">
<a-input
allow-clear
placeholder="请输入银行开户名"
v-model:value="form.bankAccount"
/>
</a-form-item>
<a-form-item label="银行卡号" name="bankCard">
<a-input
allow-clear
placeholder="请输入银行卡号"
v-model:value="form.bankCard"
/>
</a-form-item>
</template>
<a-form-item label="申请状态" name="applyStatus">
<a-select v-model:value="form.applyStatus">
<a-select-option :value="10">待审核</a-select-option>
<a-select-option :value="20">审核通过</a-select-option>
<a-select-option :value="30">驳回</a-select-option>
<a-select-option :value="40">已打款</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="支付宝账号" name="alipayAccount">
<a-input
allow-clear
placeholder="请输入支付宝账号"
v-model:value="form.alipayAccount"
/>
</a-form-item>
<a-form-item label="开户行名称" name="bankName">
<a-input
allow-clear
placeholder="请输入开户行名称"
v-model:value="form.bankName"
/>
</a-form-item>
<a-form-item label="银行开户名" name="bankAccount">
<a-input
allow-clear
placeholder="请输入银行开户名"
v-model:value="form.bankAccount"
/>
</a-form-item>
<a-form-item label="银行卡号" name="bankCard">
<a-input
allow-clear
placeholder="请输入银行卡号"
v-model:value="form.bankCard"
/>
</a-form-item>
<a-form-item label="申请状态 (10待审核 20审核通过 30驳回 40已打款)" name="applyStatus">
<a-input
allow-clear
placeholder="请输入申请状态 (10待审核 20审核通过 30驳回 40已打款)"
v-model:value="form.applyStatus"
/>
</a-form-item>
<a-form-item label="审核时间" name="auditTime">
<a-input
allow-clear
placeholder="请输入审核时间"
v-model:value="form.auditTime"
/>
</a-form-item>
<a-form-item label="驳回原因" name="rejectReason">
<a-form-item label="驳回原因" name="rejectReason" v-if="form.applyStatus === 30">
<a-input
allow-clear
placeholder="请输入驳回原因"
v-model:value="form.rejectReason"
/>
</a-form-item>
<a-form-item label="来源客户端(APP、H5、小程序等)" name="platform">
<a-input
allow-clear
placeholder="请输入来源客户端(APP、H5、小程序等)"
v-model:value="form.platform"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addDealerWithdraw, updateDealerWithdraw } from '@/api/shop/dealerWithdraw';
import { DealerWithdraw } from '@/api/shop/dealerWithdraw/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject, uuid} from 'ele-admin-pro';
import {addDealerWithdraw, updateDealerWithdraw} from '@/api/shop/dealerWithdraw';
import {DealerWithdraw} from '@/api/shop/dealerWithdraw/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FormInstance} from 'ant-design-vue/es/form';
import {FileRecord} from '@/api/system/file/model';
import dayjs from "dayjs";
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: DealerWithdraw | null;
}>();
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: DealerWithdraw | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<DealerWithdraw>({
id: undefined,
userId: undefined,
money: undefined,
payType: undefined,
alipayName: undefined,
alipayAccount: undefined,
bankName: undefined,
bankAccount: undefined,
bankCard: undefined,
applyStatus: undefined,
auditTime: undefined,
rejectReason: undefined,
platform: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
dealerWithdrawId: undefined,
dealerWithdrawName: '',
status: 0,
comments: '',
sortNumber: 100
});
// 用户信息
const form = reactive<DealerWithdraw>({
id: undefined,
userId: undefined,
money: undefined,
payType: undefined,
alipayName: undefined,
alipayAccount: undefined,
bankName: undefined,
bankAccount: undefined,
bankCard: undefined,
applyStatus: undefined,
auditTime: undefined,
rejectReason: undefined,
platform: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
dealerWithdrawName: [
{
required: true,
type: 'string',
message: '请填写分销商提现明细表名称',
trigger: 'blur'
}
]
});
// 表单验证规则
const rules = reactive({
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
formData.auditTime = dayjs().unix()
const saveOrUpdate = isUpdate.value ? updateDealerWithdraw : addDealerWithdraw;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
});
form.image = data.path;
};
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateDealerWithdraw : addDealerWithdraw;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
isUpdate.value = true;
} else {
resetFields();
isUpdate.value = false;
}
},
{ immediate: true }
);
} else {
resetFields();
}
},
{immediate: true}
);
</script>

View File

@@ -1,12 +1,7 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>

View File

@@ -7,7 +7,6 @@
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
@@ -22,7 +21,7 @@
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
<a-image :src="record.image" :width="50"/>
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
@@ -31,7 +30,7 @@
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-divider type="vertical"/>
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
@@ -55,232 +54,247 @@
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import DealerWithdrawEdit from './components/dealerWithdrawEdit.vue';
import {
pageDealerWithdraw,
removeDealerWithdraw,
removeBatchDealerWithdraw
} from '@/api/shop/dealerWithdraw';
import type {
DealerWithdraw,
DealerWithdrawParam
} from '@/api/shop/dealerWithdraw/model';
import {createVNode, ref} from 'vue';
import {message, Modal} from 'ant-design-vue';
import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
import type {EleProTable} from 'ele-admin-pro';
import {toDateString} from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import DealerWithdrawEdit from './components/dealerWithdrawEdit.vue';
import {
pageDealerWithdraw,
removeDealerWithdraw,
removeBatchDealerWithdraw
} from '@/api/shop/dealerWithdraw';
import type {
DealerWithdraw,
DealerWithdrawParam
} from '@/api/shop/dealerWithdraw/model';
import dayjs from "dayjs";
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<DealerWithdraw[]>([]);
// 当前编辑数据
const current = ref<DealerWithdraw | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格选中数据
const selection = ref<DealerWithdraw[]>([]);
// 当前编辑数据
const current = ref<DealerWithdraw | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageDealerWithdraw({
...where,
...orders,
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
width: 90
},
{
title: '提现金额',
dataIndex: 'money',
key: 'money',
align: 'center'
},
{
title: '打款方式',
dataIndex: 'payType',
key: 'payType',
align: 'center',
customRender: ({text}) => {
if (text === 20) return '支付宝'
else if (text === 30) return '银行卡'
}
return pageDealerWithdraw({
...where,
...orders,
page,
limit
},
{
title: '支付宝姓名',
dataIndex: 'alipayName',
key: 'alipayName',
align: 'center'
},
{
title: '支付宝账号',
dataIndex: 'alipayAccount',
key: 'alipayAccount',
align: 'center'
},
{
title: '开户行名称',
dataIndex: 'bankName',
key: 'bankName',
align: 'center'
},
{
title: '银行开户名',
dataIndex: 'bankAccount',
key: 'bankAccount',
align: 'center'
},
{
title: '银行卡号',
dataIndex: 'bankCard',
key: 'bankCard',
align: 'center'
},
{
title: '申请状态',
dataIndex: 'applyStatus',
key: 'applyStatus',
align: 'center',
customRender: ({text}) => {
if (text === 10) return '审核中'
else if (text === 20) return '审核通过'
else if (text === 30) return '审核拒绝'
else if (text === 40) return '已打款'
}
},
{
title: '审核时间',
dataIndex: 'auditTime',
key: 'auditTime',
align: 'center',
customRender: ({text}) => {
if (text === 0) return ''
else return dayjs(text).format('YYYY-MM-DD HH:mm:ss')
}
},
{
title: '驳回原因',
dataIndex: 'rejectReason',
key: 'rejectReason',
align: 'center'
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({text}) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: DealerWithdrawParam) => {
selection.value = [];
tableRef?.value?.reload({where: where});
};
/* 打开编辑弹窗 */
const openEdit = (row?: DealerWithdraw) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: DealerWithdraw) => {
const hide = message.loading('请求中..', 0);
removeDealerWithdraw(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
width: 90
},
{
title: '提现金额',
dataIndex: 'money',
key: 'money',
align: 'center'
},
{
title: '打款方式',
dataIndex: 'payType',
key: 'payType',
align: 'center'
},
{
title: '支付宝姓名',
dataIndex: 'alipayName',
key: 'alipayName',
align: 'center'
},
{
title: '支付宝账号',
dataIndex: 'alipayAccount',
key: 'alipayAccount',
align: 'center'
},
{
title: '开户行名称',
dataIndex: 'bankName',
key: 'bankName',
align: 'center'
},
{
title: '银行开户名',
dataIndex: 'bankAccount',
key: 'bankAccount',
align: 'center'
},
{
title: '银行卡号',
dataIndex: 'bankCard',
key: 'bankCard',
align: 'center'
},
{
title: '申请状态',
dataIndex: 'applyStatus',
key: 'applyStatus',
align: 'center'
},
{
title: '审核时间',
dataIndex: 'auditTime',
key: 'auditTime',
align: 'center'
},
{
title: '驳回原因',
dataIndex: 'rejectReason',
key: 'rejectReason',
align: 'center'
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchDealerWithdraw(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
]);
});
};
/* 搜索 */
const reload = (where?: DealerWithdrawParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 打开编辑弹窗 */
const openEdit = (row?: DealerWithdraw) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: DealerWithdraw) => {
const hide = message.loading('请求中..', 0);
removeDealerWithdraw(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;
/* 自定义行属性 */
const customRow = (record: DealerWithdraw) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的记录吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
removeBatchDealerWithdraw(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: DealerWithdraw) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
};
query();
</script>
<script lang="ts">
export default {
name: 'DealerWithdraw'
};
export default {
name: 'DealerWithdraw'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,276 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑运费模板' : '添加运费模板'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="名称" name="title">
<a-input
allow-clear
placeholder="请输入名称"
v-model:value="form.title"
/>
</a-form-item>
<a-form-item label="地区选择" required>
<a-cascader v-model:value="city" :options="areaList" placeholder="点击选择省市"
:field-names="areaFieldNames"
multiple
@change="changeArea"/>
</a-form-item>
<a-form-item label="类型">
<a-select
v-model:value="form.type"
style="width: 120px"
>
<a-select-option :value="0">按件数</a-select-option>
<a-select-option :value="1">按重量</a-select-option>
</a-select>
</a-form-item>
<a-form-item :label="form.type === 0 ? '首件价格' : '首重价格'" name="firstAmount">
<a-input-number
style="width: 100%;"
placeholder="请输入"
v-model:value="form.firstAmount"
/>
</a-form-item>
<a-form-item :label="form.type === 0 ? '首件' : '首重(kg)'" name="firstNum">
<a-input-number
style="width: 100%;"
placeholder="请输入"
v-model:value="form.firstNum"
/>
</a-form-item>
<a-form-item :label="form.type === 0 ? '续件价格' : '续重价格'" name="extraAmount">
<a-input-number
style="width: 100%;"
placeholder="请输入"
v-model:value="form.extraAmount"
/>
</a-form-item>
<a-form-item :label="form.type === 0 ? '续件' : '续重(kg)'" name="extraNum">
<a-input-number
style="width: 100%;"
placeholder="请输入"
v-model:value="form.extraNum"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject, uuid} from 'ele-admin-pro';
import {addExpressTemplate, updateExpressTemplate} from '@/api/shop/expressTemplate';
import {ExpressTemplate} from '@/api/shop/expressTemplate/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FormInstance} from 'ant-design-vue/es/form';
import {listArea} from "@/api/system/area";
import {Area} from "@/api/system/area/model";
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ExpressTemplate | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<ExpressTemplate>({
id: undefined,
title: undefined,
type: 0,
status: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
firstAmount: undefined,
extraAmount: undefined,
firstNum: 1,
extraNum: 0,
detailList: []
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
title: [
{
required: true,
type: 'string',
message: '请填写运费模板名称',
trigger: 'blur'
}
],
firstAmount: [
{
required: true,
message: '请填写首件价格',
trigger: 'blur'
}
],
extraAmount: [
{
required: true,
message: '请填写续件价格',
trigger: 'blur'
}
],
firstNum: [
{
required: true,
message: '请填写续件数量',
trigger: 'blur'
}
],
extraNum: [
{
required: true,
message: '请填写续件数量',
trigger: 'blur'
}
],
});
const areaFieldNames = {
label: 'name',
value: 'id'
}
const city = ref([[]])
const areaList = ref<Area[]>([])
const getAreaList = async () => {
areaList.value = await listArea({levelId: 2})
}
const changeArea = (value) => {
// console.log(value)
// const province = areaList.value.find(item => item.id === value[0])
// const city = province?.children.find(item => item.id === value[1])
// const area = city?.children.find(item => item.id === value[2])
// form.province = province?.name
// form.city = city?.name
// form.region = area?.name
city.value = value
}
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
if (!city.value.length || !city.value[0].length) return message.error('请选择地区')
formData.detailList = []
city.value.forEach(item => {
if (item.length === 1) {
const province = areaList.value.find(p => p.id === item[0])
province?.children.forEach(city => {
formData.detailList.push({
provinceId: item[0],
cityId: city.id,
firstAmount: form.firstAmount,
extraAmount: form.extraAmount
})
})
} else {
formData.detailList.push({
provinceId: item[0],
cityId: item[1],
firstAmount: form.firstAmount,
extraAmount: form.extraAmount
})
}
})
const saveOrUpdate = isUpdate.value ? updateExpressTemplate : addExpressTemplate;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
});
};
watch(
() => props.visible,
async (visible) => {
if (visible) {
await getAreaList()
city.value = [];
if (props.data) {
assignObject(form, props.data);
props.data.detailList?.forEach(item => {
city.value.push([item.provinceId, item.cityId])
})
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{immediate: true}
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,224 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="expressTemplateId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ExpressTemplateEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ExpressTemplateEdit from './components/expressTemplateEdit.vue';
import { pageExpressTemplate, removeExpressTemplate, removeBatchExpressTemplate } from '@/api/shop/expressTemplate';
import type { ExpressTemplate, ExpressTemplateParam } from '@/api/shop/expressTemplate/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ExpressTemplate[]>([]);
// 当前编辑数据
const current = ref<ExpressTemplate | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageExpressTemplate({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '名称',
dataIndex: 'title',
key: 'title',
align: 'center',
},
{
title: '首件重量',
dataIndex: 'firstAmount',
key: 'title',
align: 'center',
},
{
title: '续件重量',
dataIndex: 'extraAmount',
key: 'title',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ExpressTemplateParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ExpressTemplate) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ExpressTemplate) => {
const hide = message.loading('请求中..', 0);
removeExpressTemplate(row.expressTemplateId)
.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);
removeBatchExpressTemplate(selection.value.map((d) => d.expressTemplateId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ExpressTemplate) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ExpressTemplate'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,233 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑运费模板' : '添加运费模板'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="templateId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.templateId"
/>
</a-form-item>
<a-form-item label="0按件" name="type">
<a-input
allow-clear
placeholder="请输入0按件"
v-model:value="form.type"
/>
</a-form-item>
<a-form-item label="" name="provinceId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.provinceId"
/>
</a-form-item>
<a-form-item label="" name="cityId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.cityId"
/>
</a-form-item>
<a-form-item label="收件价格" name="firstAmount">
<a-input
allow-clear
placeholder="请输入收件价格"
v-model:value="form.firstAmount"
/>
</a-form-item>
<a-form-item label="续件价格" name="extraAmount">
<a-input
allow-clear
placeholder="请输入续件价格"
v-model:value="form.extraAmount"
/>
</a-form-item>
<a-form-item label="状态, 0已发布, 1待审核 2已驳回 3违规内容" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addExpressTemplateDetail, updateExpressTemplateDetail } from '@/api/shop/expressTemplateDetail';
import { ExpressTemplateDetail } from '@/api/shop/expressTemplateDetail/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ExpressTemplateDetail | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<ExpressTemplateDetail>({
id: undefined,
templateId: undefined,
type: undefined,
provinceId: undefined,
cityId: undefined,
firstAmount: undefined,
extraAmount: undefined,
status: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
expressTemplateDetailId: undefined,
expressTemplateDetailName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
expressTemplateDetailName: [
{
required: true,
type: 'string',
message: '请填写运费模板名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateExpressTemplateDetail : addExpressTemplateDetail;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,269 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="expressTemplateDetailId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ExpressTemplateDetailEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ExpressTemplateDetailEdit from './components/expressTemplateDetailEdit.vue';
import { pageExpressTemplateDetail, removeExpressTemplateDetail, removeBatchExpressTemplateDetail } from '@/api/shop/expressTemplateDetail';
import type { ExpressTemplateDetail, ExpressTemplateDetailParam } from '@/api/shop/expressTemplateDetail/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ExpressTemplateDetail[]>([]);
// 当前编辑数据
const current = ref<ExpressTemplateDetail | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageExpressTemplateDetail({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'templateId',
key: 'templateId',
align: 'center',
},
{
title: '0按件',
dataIndex: 'type',
key: 'type',
align: 'center',
},
{
title: '',
dataIndex: 'provinceId',
key: 'provinceId',
align: 'center',
},
{
title: '',
dataIndex: 'cityId',
key: 'cityId',
align: 'center',
},
{
title: '收件价格',
dataIndex: 'firstAmount',
key: 'firstAmount',
align: 'center',
},
{
title: '续件价格',
dataIndex: 'extraAmount',
key: 'extraAmount',
align: 'center',
},
{
title: '状态, 0已发布, 1待审核 2已驳回 3违规内容',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ExpressTemplateDetailParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ExpressTemplateDetail) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ExpressTemplateDetail) => {
const hide = message.loading('请求中..', 0);
removeExpressTemplateDetail(row.expressTemplateDetailId)
.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);
removeBatchExpressTemplateDetail(selection.value.map((d) => d.expressTemplateDetailId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ExpressTemplateDetail) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ExpressTemplateDetail'
};
</script>
<style lang="less" scoped></style>

View File

@@ -51,13 +51,17 @@
label="选择店铺"
name="merchantId"
>
<SelectMerchant
:placeholder="`选择商户`"
class="input-item"
style="width: 558px"
v-model:value="form.merchantName"
@done="chooseMerchantId"
/>
<a-space>
<SelectMerchant
:placeholder="`选择商户`"
class="input-item"
style="width: 558px"
v-model:value="form.merchantName"
@done="chooseMerchantId"
/>
<a-button @click="clearMerchant">清除店铺</a-button>
</a-space>
</a-form-item>
<a-form-item label="供应商" name="supplierMerchantId" v-if="!merchantId">
<SelectMerchant
@@ -117,14 +121,22 @@
v-model:value="form.unitName"
/>
</a-form-item>
<a-form-item label="市场价" name="salePrice">
<a-form-item label="价" name="originPrice">
<a-input-number
:placeholder="`市场价`"
:placeholder="`价`"
style="width: 240px"
:min="0.01"
v-model:value="form.originPrice"
/>
</a-form-item>
<a-form-item label="普通会员价" name="salePrice">
<a-input-number
:placeholder="`普通会员价`"
style="width: 240px"
:min="0.01"
v-model:value="form.salePrice"
/>
<div class="ele-text-placeholder">市场价或划线价仅用于商品页展示</div>
<div class="ele-text-placeholder">普通用户购物价格</div>
</a-form-item>
<a-form-item label="会员价" name="price">
<a-space>
@@ -134,17 +146,23 @@
:min="0.01"
v-model:value="form.price"
/>
<a-checkbox v-model:checked="form.priceGift">有赠品</a-checkbox>
<a-input v-if="form.priceGift" v-model:value="form.priceGiftName" style="width: 200px"
</a-space>
<div class="ele-text-placeholder">会员购物价格</div>
</a-form-item>
<a-form-item label="是否有赠品">
<a-checkbox v-model:checked="form.priceGift">有赠品</a-checkbox>
</a-form-item>
<a-form-item label="赠品">
<template v-if="form.priceGift">
<a-input v-model:value="form.priceGiftName" style="width: 200px"
placeholder="请输入赠品名称">
<template #prefix>名称</template>
</a-input>
<a-input-number v-if="form.priceGift" v-model:value="form.priceGiftNum" style="width: 200px"
<a-input-number v-model:value="form.priceGiftNum" style="width: 200px"
placeholder="请输入赠品数量">
<template #prefix>数量</template>
</a-input-number>
</a-space>
<div class="ele-text-placeholder">商品的实际购买金额最低0.01</div>
</template>
</a-form-item>
<!-- <a-form-item label="经销商价" name="dealerPrice" v-if="!merchantId">-->
<!-- <a-space>-->
@@ -160,90 +178,94 @@
<!-- </a-space>-->
<!-- <div class="ele-text-placeholder">经销商价格</div>-->
<!-- </a-form-item>-->
<a-form-item label="供应商价" name="buyingPrice" v-if="!merchantId">
<a-form-item label="会员店/总仓批发价" name="buyingPrice" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`供应商价`"
:placeholder="`会员店/总仓批发价`"
:min="0.01"
style="width: 240px"
v-model:value="form.buyingPrice"
/>
</a-space>
<div class="ele-text-placeholder">供应商</div>
<div class="ele-text-placeholder">会员店/总仓批发</div>
</a-form-item>
<a-form-item label="连锁店价格" name="chainStorePrice" v-if="!merchantId">
<a-form-item label="供应价" name="chainStorePrice" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`请输入连锁店价格`"
:placeholder="`请输入供应价`"
:min="0.01"
style="width: 240px"
v-model:value="form.chainStorePrice"
/>
</a-space>
<div class="ele-text-placeholder">连锁店价格</div>
<div class="ele-text-placeholder">供应价</div>
</a-form-item>
<a-form-item label="连锁店差价比例(%)" name="chainStoreRate" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`请输入连锁店差价比例(%)`"
:min="0.01"
:max="100"
style="width: 240px"
v-model:value="form.chainStoreRate"
/>
</a-space>
<div class="ele-text-placeholder">连锁店差价比例(%)</div>
<!-- <a-form-item label="连锁店差价比例(%)" name="chainStoreRate" v-if="!merchantId">-->
<!-- <a-space>-->
<!-- <a-input-number-->
<!-- :placeholder="`请输入连锁店差价比例(%)`"-->
<!-- :min="0.01"-->
<!-- :max="100"-->
<!-- style="width: 240px"-->
<!-- v-model:value="form.chainStoreRate"-->
<!-- />-->
<!-- </a-space>-->
<!-- <div class="ele-text-placeholder">连锁店差价比例(%)</div>-->
<!-- </a-form-item>-->
<!-- <a-form-item label="会员店价格" name="memberStorePrice" v-if="!merchantId">-->
<!-- <a-space>-->
<!-- <a-input-number-->
<!-- :placeholder="`请输入会员店价格`"-->
<!-- :min="0.01"-->
<!-- style="width: 240px"-->
<!-- v-model:value="form.memberStorePrice"-->
<!-- />-->
<!-- </a-space>-->
<!-- <div class="ele-text-placeholder">会员店价格</div>-->
<!-- </a-form-item>-->
<!-- <a-form-item label="会员店差价比例(%)" name="memberStoreRate" v-if="!merchantId">-->
<!-- <a-space>-->
<!-- <a-input-number-->
<!-- :placeholder="`请输入会员店差价比例(%)`"-->
<!-- :min="0.01"-->
<!-- :max="100"-->
<!-- style="width: 240px"-->
<!-- v-model:value="form.memberStoreRate"-->
<!-- />-->
<!-- </a-space>-->
<!-- <div class="ele-text-placeholder">会员店差价比例(%)</div>-->
<!-- </a-form-item>-->
<a-form-item label="直推收益分配(元)" v-if="!merchantId" name="memberStoreCommission">
<a-input-number
:placeholder="`会员店/供应商/总仓直推收益分配`"
style="width: 240px"
v-model:value="form.memberStoreCommission"
/>
</a-form-item>
<a-form-item label="会员店价格" name="memberStorePrice" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`请输入会员店价格`"
:min="0.01"
style="width: 240px"
v-model:value="form.memberStorePrice"
/>
</a-space>
<div class="ele-text-placeholder">会员店价格</div>
<a-form-item label="仓储费(元)" v-if="!merchantId" name="supplierCommission">
<a-input-number
:placeholder="`请输入仓储费(元)`"
style="width: 240px"
v-model:value="form.supplierCommission"
/>
</a-form-item>
<a-form-item label="会员店差价比例(%)" name="memberStoreRate" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`请输入会员店差价比例(%)`"
:min="0.01"
:max="100"
style="width: 240px"
v-model:value="form.memberStoreRate"
/>
</a-space>
<div class="ele-text-placeholder">会员店差价比例(%)</div>
</a-form-item>
<a-form-item label="会员店直推分佣(元)" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`请输入会员店直推分佣(元)`"
style="width: 240px"
v-model:value="form.memberStoreCommission"
/>
</a-space>
</a-form-item>
<a-form-item label="供应商直推分佣(元)" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`请输入供应商直推分佣(元)`"
style="width: 240px"
v-model:value="form.supplierCommission"
/>
</a-space>
</a-form-item>
<a-form-item label="合作伙伴直推分佣(元)" v-if="!merchantId">
<a-space>
<a-input-number
:placeholder="`请输入合作伙伴直推分佣(元)`"
style="width: 240px"
v-model:value="form.coopCommission"
/>
</a-space>
<a-form-item label="运费模板" v-if="!merchantId">
<a-select v-model:value="form.expressTemplateId">
<a-select-option v-for="(item, index) in expressTemplateList" :key="index" :value="item.id">{{
item.title
}}
</a-select-option>
</a-select>
</a-form-item>
<!-- <a-form-item label="合作伙伴直推分佣(元)" v-if="!merchantId">-->
<!-- <a-space>-->
<!-- <a-input-number-->
<!-- :placeholder="`请输入合作伙伴直推分佣(元)`"-->
<!-- style="width: 240px"-->
<!-- v-model:value="form.coopCommission"-->
<!-- />-->
<!-- </a-space>-->
<!-- </a-form-item>-->
<!-- <a-form-item label="会员超市价格" name="memberMarketPrice" v-if="!merchantId">-->
<!-- <a-space>-->
@@ -279,26 +301,66 @@
<a-form-item label="是否新品">
<a-switch size="small" v-model:checked="form.isNew" :checked-value="1" :un-checked-value="0"/>
</a-form-item>
<a-form-item label="商品图片" name="image">
<SelectFile
:placeholder="`请选择视频文件`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
<a-form-item label="是否开启分红角色功能" v-if="!merchantId">
<a-switch size="small" v-model:checked="form.commissionRole" :checked-value="1" :un-checked-value="0"/>
</a-form-item>
<a-form-item label="角色分红配置" v-if="form.commissionRole === 1">
<a-space>
<a-input v-model:value="form.goodsRoleCommission[index].amount"
v-for="(item, index) in form.goodsRoleCommission" :key="index">
<template #addonBefore>{{ item.roleName }}</template>
<template #addonAfter></template>
</a-input>
</a-space>
</a-form-item>
<a-form-item label="商品图片(400x400)" name="image">
<!-- <SelectFile-->
<!-- :placeholder="`请选择视频文件`"-->
<!-- :limit="1"-->
<!-- :data="images"-->
<!-- @done="chooseImage"-->
<!-- @del="onDeleteItem"-->
<!-- />-->
<a-image width="100px" height="100px" v-if="form.image" :src="form.image" style="margin-right: 10px"/>
<a-upload :show-upload-list="false" :customRequest="onUploadImage" ref="imageRef">
<a-button class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传图标</span>
</a-button>
</a-upload>
<div class="ele-text-placeholder">
支持上传视频mp4格式视频时长不超过60秒视频大小不超过200M
</div>
</a-form-item>
<a-form-item label="轮播图" name="files">
<SelectFile
:placeholder="`请选择视频文件`"
:limit="9"
:data="files"
@done="chooseFile"
@del="onDeleteFile"
/>
<!-- <SelectFile-->
<!-- :placeholder="`请选择视频文件`"-->
<!-- :limit="9"-->
<!-- :data="files"-->
<!-- @done="chooseFile"-->
<!-- @del="onDeleteFile"-->
<!-- />-->
<div class="flex flex-wrap justify-start items-start">
<div v-for="(item, index) in files" :key="index" style="margin-right: 10px; margin-bottom: 10px"
class="relative">
<img style="width: 100px; height: 100px" :src="item.url"/>
<div class="absolute right-0 top-0 w-6 h-6 bg-red-400 flex justify-center items-center rounded-bl-lg"
@click="onDeleteFile(index)">
<delete-outlined style="color: white"/>
</div>
</div>
</div>
<a-upload :show-upload-list="false" :customRequest="onUploadSwiper" multiple :max-count="9" ref="swiperRef">
<a-button class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传轮播图</span>
</a-button>
</a-upload>
</a-form-item>
<a-form-item label="状态" name="isShow">
<a-radio-group v-model:value="form.isShow">
@@ -364,12 +426,10 @@
<a-space v-if="spec.length > 0">
<a-button type="primary" class="mt-5" @click="openSpecForm"
>添加新规格
</a-button
>
</a-button>
<a-button type="primary" class="mt-5" @click="generateSku"
>生成SKU
</a-button
>
</a-button>
</a-space>
</a-space>
</a-form-item>
@@ -400,7 +460,19 @@
<a-input :placeholder="`成本价`" v-model:value="skuList[index].price"/>
</template>
<template v-if="column.key === 'salePrice'">
<a-input :placeholder="`价`" v-model:value="record.salePrice"/>
<a-input :placeholder="`市场价`" v-model:value="record.salePrice"/>
</template>
<template v-if="column.key === 'buyingPrice'">
<a-input :placeholder="`会员店/总仓批发价`" v-model:value="record.buyingPrice"/>
</template>
<template v-if="column.key === 'chainStorePrice'">
<a-input :placeholder="`供应价`" v-model:value="record.chainStorePrice"/>
</template>
<template v-if="column.key === 'memberStoreCommission'">
<a-input :placeholder="`直推收益分配(元)`" v-model:value="record.memberStoreCommission"/>
</template>
<template v-if="column.key === 'supplierCommission'">
<a-input :placeholder="`仓储费(元)`" v-model:value="record.supplierCommission"/>
</template>
<template v-if="column.key === 'stock'">
<a-input :placeholder="`库存`" v-model:value="record.stock"/>
@@ -455,6 +527,14 @@
v-model:value="form.sales"
/>
</a-form-item>
<a-form-item label="库存" name="stock">
<a-input-number
allow-clear
style="width: 250px"
placeholder="请输入库存"
v-model:value="form.stock"
/>
</a-form-item>
<a-form-item label="获取积分" name="gainIntegral">
<a-input-number
:placeholder="`消费获取的积分`"
@@ -476,6 +556,44 @@
v-model:value="form.position"
/>
</a-form-item>
<template v-if="form.type === 1 || merchantId">
<a-form-item label="可用日期">
<a-select v-model:value="canUseDate" mode="multiple">
<a-select-option v-for="(item, index) in dayList" :key="index" :value="index">{{
item
}}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="服务保障">
<div>
<a-space>
<a-tag v-for="item in ensureTag" :key="item" closable @close="onDeleteEnsureTag(item)">{{
item
}}
</a-tag>
<a-input v-model:value="ensureTagItem"></a-input>
<a-button @click="addEnsureTag()" :disabled="!ensureTagItem">添加</a-button>
</a-space>
</div>
<div class="mt-2">
<a-space>
<span @click="addEnsureTag('免预约')">免预约</span>
<span @click="addEnsureTag('随时退')">随时退</span>
<span @click="addEnsureTag('过期自动退')">过期自动退</span>
</a-space>
</div>
</a-form-item>
<a-form-item label="有效期限">
<a-input-number
:min="0"
:max="9999"
style="width: 250px"
placeholder="请输入有效期限"
v-model:value="form.expiredDay"
/>
</a-form-item>
</template>
<a-form-item label="排序号" name="sortNumber">
<a-input-number
:min="0"
@@ -492,10 +610,10 @@
</template>
<script lang="ts" setup>
import {CloseCircleOutlined} from '@ant-design/icons-vue';
import {CloseCircleOutlined, DeleteOutlined, UploadOutlined} from '@ant-design/icons-vue';
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject, uuid} from 'ele-admin-pro';
import {assignObject, messageLoading, uuid} from 'ele-admin-pro';
import {addGoods, updateGoods} from "@/api/shop/goods";
import {Goods} from '@/api/shop/goods/model';
import {useThemeStore} from '@/store/modules/theme';
@@ -515,6 +633,10 @@ import {listGoodsSpec} from "@/api/shop/goodsSpec";
import {GoodsCategory} from "@/api/shop/goodsCategory/model";
import {listGoodsCategory} from "@/api/shop/goodsCategory";
import {getMerchantId} from "@/utils/merchant";
import {ExpressTemplate} from "@/api/shop/expressTemplate/model";
import {listExpressTemplate} from "@/api/shop/expressTemplate";
import {listCommissionRole} from "@/api/shop/commissionRole";
import {listGoodsRoleCommission} from "@/api/shop/goodsRoleCommission";
// 是否是修改
const isUpdate = ref(false);
@@ -571,21 +693,39 @@ const columns = [
align: 'center'
},
{
title: '价',
title: '市场价',
dataIndex: 'salePrice',
key: 'salePrice',
align: 'center',
},
{
title: '成本价',
title: '会员价',
dataIndex: 'price',
key: 'price',
align: 'center',
},
{
title: '库存',
dataIndex: 'stock',
key: 'stock',
title: '会员店/总仓批发价',
dataIndex: 'buyingPrice',
key: 'buyingPrice',
align: 'center',
},
{
title: '供应价',
dataIndex: 'chainStorePrice',
key: 'chainStorePrice',
align: 'center',
},
{
title: '直推收益分配(元)',
dataIndex: 'memberStoreCommission',
key: 'memberStoreCommission',
align: 'center',
},
{
title: '仓储费(元)',
dataIndex: 'supplierCommission',
key: 'supplierCommission',
align: 'center',
},
{
@@ -596,6 +736,22 @@ const columns = [
},
];
const dayList = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
const canUseDate = ref([])
const ensureTag = ref<string[]>([])
const ensureTagItem = ref('')
const addEnsureTag = (item = '') => {
const tag = item || ensureTagItem.value
if (ensureTag.value.findIndex(item => item === tag) !== -1) return message.error('请勿重复添加')
ensureTag.value.push(tag)
ensureTagItem.value = ''
}
const onDeleteEnsureTag = (tag: string) => {
const index = ensureTag.value.findIndex(item => item === tag)
ensureTag.value.splice(index, 1)
};
// 用户信息
const form = reactive<Goods>({
goodsId: undefined,
@@ -611,8 +767,10 @@ const form = reactive<Goods>({
parentName: undefined,
categoryName: undefined,
specs: 0,
commissionRole: 0,
position: undefined,
price: undefined,
originPrice: undefined,
salePrice: undefined,
buyingPrice: undefined,
dealerPrice: undefined,
@@ -640,13 +798,18 @@ const form = reactive<Goods>({
memberStoreCommission: undefined,
supplierCommission: undefined,
coopCommission: undefined,
expressTemplateId: undefined,
canUseDate: undefined,
ensureTag: undefined,
expiredDay: undefined,
stock: 1000,
deductStockType: 20,
isShow: 1,
status: 0,
comments: '',
sortNumber: 100,
specName: ''
specName: '',
goodsRoleCommission: []
});
/* 更新visible */
@@ -713,7 +876,7 @@ const rules = reactive({
buyingPrice: [
{
required: true,
message: '请填写供应商价',
message: '请填写会员店/总仓批发价',
type: 'number',
trigger: 'blur'
}
@@ -726,14 +889,6 @@ const rules = reactive({
trigger: 'blur'
}
],
merchantId: [
{
required: true,
message: '请选择店铺',
type: 'number',
trigger: 'blur'
}
],
supplierMerchantId: [
{
required: true,
@@ -775,7 +930,7 @@ const rules = reactive({
chainStorePrice: [
{
required: true,
message: '请输入连锁店价格',
message: '请输入供应价',
type: 'number',
trigger: 'blur'
}
@@ -796,6 +951,22 @@ const rules = reactive({
trigger: 'blur'
}
],
memberStoreCommission: [
{
required: true,
message: '请输入直推收益分配',
type: 'number',
trigger: 'blur'
}
],
supplierCommission: [
{
required: true,
message: '请输入仓储费',
type: 'number',
trigger: 'blur'
}
],
});
@@ -809,6 +980,11 @@ const chooseMerchantId = (item: Merchant) => {
form.merchantId = item.merchantId;
};
const clearMerchant = () => {
form.merchantName = '';
form.merchantId = 0;
};
const chooseSupplier = (item: Merchant) => {
form.supplierName = item.merchantName;
form.supplierMerchantId = item.merchantId;
@@ -1050,7 +1226,17 @@ const save = () => {
.then(() => {
loading.value = true;
if (form.priceGift && !form.priceGiftNum) return message.error('请输入会员赠品数量');
if (ensureTag.value.length) form.ensureTag = ensureTag.value.join()
if (canUseDate.value.length) form.canUseDate = canUseDate.value.join()
// if (form.dealerGift && !form.dealerGiftNum) return message.error('请输入经销商赠品数量');
if (form.commissionRole === 1) {
for (let i = 0; i < form.goodsRoleCommission.length; i++) {
if (form.goodsRoleCommission[i].amount === undefined || form.goodsRoleCommission[i].amount === '' || form.goodsRoleCommission[i].amount === null) {
return message.error('请输入' + form.goodsRoleCommission[i].roleName + '的分红金额');
}
}
}
const formData = {
...form,
content: content.value,
@@ -1058,9 +1244,11 @@ const save = () => {
files: JSON.stringify(files.value),
goodsSpec: goodsSpec.value,
goodsSkus: skuList.value,
merchantId: getMerchantId(),
type: getMerchantId() ? 1 : 0
};
if (isUpdate.value) {
formData.type = props.data.type;
}
const saveOrUpdate = isUpdate.value ? updateGoods : addGoods;
saveOrUpdate(formData)
.then((msg) => {
@@ -1078,14 +1266,110 @@ const save = () => {
});
};
const expressTemplateList = ref<ExpressTemplate[]>([]);
const getExpressTemplateList = async () => {
expressTemplateList.value = await listExpressTemplate();
}
const getRoleList = async () => {
const roleList = await listCommissionRole()
form.goodsRoleCommission = []
roleList.forEach(d => {
form.goodsRoleCommission.push({
roleId: d.id,
roleName: d.title,
amount: 0
})
})
if (props?.data?.goodsId) {
const commissionList = await listGoodsRoleCommission({goodsId: props?.data?.goodsId})
form.goodsRoleCommission = form.goodsRoleCommission.map(d => {
const find = commissionList.find(c => c.roleId == d.roleId)
return {
...d,
amount: find?.amount || 0
}
})
}
}
const onUploadImage = (item) => {
const {file} = item;
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then(res => {
hide()
form.image = res.path;
})
.catch((e) => {
message.error(e.message);
hide();
})
};
const onUploadSwiper = (item) => {
const {file} = item;
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then(data => {
hide()
files.value.push({
uid: data.id,
url: data.path,
status: 'done'
})
setPicker()
})
.catch((e) => {
message.error(e.message);
hide();
})
};
const swiperRef = ref()
const imageRef = ref()
const setPicker = () => {
const swiperEl = swiperRef.value?.$el?.querySelector('input[type="file"]');
if (swiperEl) {
swiperEl.removeAttribute('accept'); // 移除 accept 属性
swiperEl.removeAttribute('capture'); // 移除 capture 属性
swiperEl.setAttribute('name', 'file'); // 添加 name 属性
}
const imageEl = imageRef.value?.$el?.querySelector('input[type="file"]');
if (imageEl) {
imageEl.removeAttribute('accept'); // 移除 accept 属性
imageEl.removeAttribute('capture'); // 移除 capture 属性
imageEl.setAttribute('name', 'file'); // 添加 name 属性
}
}
watch(
() => props.visible,
(visible) => {
async (visible) => {
if (visible) {
await getExpressTemplateList()
images.value = [];
category.value = [];
files.value = [];
videos.value = [];
canUseDate.value = [];
ensureTag.value = [];
ensureTagItem.value = '';
if (props.data) {
assignObject(form, props.data);
if (props.data.image) {
@@ -1138,12 +1422,21 @@ watch(
})
isUpdate.value = true;
if (form.ensureTag) {
ensureTag.value = form.ensureTag.split(',');
}
if (form.canUseDate) {
canUseDate.value = form.canUseDate.split(',').map(d => Number(d));
}
await getRoleList()
} else {
await getRoleList()
spec.value = [];
goodsSpec.value = undefined;
skuList.value = [];
isUpdate.value = false;
}
setPicker()
} else {
resetFields();
}

View File

@@ -19,7 +19,7 @@
>
</a-radio-group>
<SelectMerchant
:placeholder="`${merchantId}选择商户`"
:placeholder="`商户刷新`"
class="input-item"
v-if="!merchantId"
v-model:value="where.merchantName"

View File

@@ -0,0 +1,210 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑商品绑定角色的分润金额' : '添加商品绑定角色的分润金额'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="roleId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.roleId"
/>
</a-form-item>
<a-form-item label="" name="goodsId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.goodsId"
/>
</a-form-item>
<a-form-item label="" name="sku">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.sku"
/>
</a-form-item>
<a-form-item label="" name="amount">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.amount"
/>
</a-form-item>
<a-form-item label="状态, 0正常, 1异常" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addGoodsRoleCommission, updateGoodsRoleCommission } from '@/api/shop/goodsRoleCommission';
import { GoodsRoleCommission } from '@/api/shop/goodsRoleCommission/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: GoodsRoleCommission | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<GoodsRoleCommission>({
id: undefined,
roleId: undefined,
goodsId: undefined,
sku: undefined,
amount: undefined,
status: undefined,
comments: undefined,
tenantId: undefined,
createTime: undefined,
goodsRoleCommissionId: undefined,
goodsRoleCommissionName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
goodsRoleCommissionName: [
{
required: true,
type: 'string',
message: '请填写商品绑定角色的分润金额名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateGoodsRoleCommission : addGoodsRoleCommission;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,251 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="goodsRoleCommissionId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<GoodsRoleCommissionEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import GoodsRoleCommissionEdit from './components/goodsRoleCommissionEdit.vue';
import { pageGoodsRoleCommission, removeGoodsRoleCommission, removeBatchGoodsRoleCommission } from '@/api/shop/goodsRoleCommission';
import type { GoodsRoleCommission, GoodsRoleCommissionParam } from '@/api/shop/goodsRoleCommission/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<GoodsRoleCommission[]>([]);
// 当前编辑数据
const current = ref<GoodsRoleCommission | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageGoodsRoleCommission({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'roleId',
key: 'roleId',
align: 'center',
},
{
title: '',
dataIndex: 'goodsId',
key: 'goodsId',
align: 'center',
},
{
title: '',
dataIndex: 'sku',
key: 'sku',
align: 'center',
},
{
title: '',
dataIndex: 'amount',
key: 'amount',
align: 'center',
},
{
title: '状态, 0正常, 1异常',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: GoodsRoleCommissionParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: GoodsRoleCommission) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: GoodsRoleCommission) => {
const hide = message.loading('请求中..', 0);
removeGoodsRoleCommission(row.goodsRoleCommissionId)
.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);
removeBatchGoodsRoleCommission(selection.value.map((d) => d.goodsRoleCommissionId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: GoodsRoleCommission) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'GoodsRoleCommission'
};
</script>
<style lang="less" scoped></style>

View File

@@ -20,13 +20,22 @@
"
>
<a-form-item label="商户图标" name="image">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
:data="images"
@done="chooseImage"
@del="onDeleteItem"
/>
<!-- <SelectFile-->
<!-- :placeholder="`请选择图片`"-->
<!-- :limit="1"-->
<!-- :data="images"-->
<!-- @done="chooseImage"-->
<!-- @del="onDeleteItem"-->
<!-- />-->
<a-image width="100px" height="100px" v-if="form.image" :src="form.image" style="margin-right: 10px"/>
<a-upload :show-upload-list="false" :customRequest="onUploadImage" ref="imageRef">
<a-button class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传图标</span>
</a-button>
</a-upload>
</a-form-item>
<a-form-item label="商户名称" name="merchantName">
<a-input
@@ -103,7 +112,7 @@
v-model:value="form.address"
/>
</a-form-item>
<a-form-item label="手续费(%)" name="commission">
<a-form-item label="手续费(%)" name="commission" v-if="!merchantId">
<a-input-number
:step="1"
:max="100"
@@ -124,7 +133,7 @@
placeholder="输入关键词后回车"
/>
</a-form-item>
<a-form-item label="资质图片" name="files">
<a-form-item label="资质图片" name="files" v-if="!merchantId">
<SelectFile
:placeholder="`请选择图片`"
:limit="9"
@@ -134,30 +143,48 @@
/>
</a-form-item>
<a-form-item label="轮播图" name="swiper">
<SelectFile
:placeholder="`请选择图片`"
:limit="9"
:data="swiper"
@done="chooseSwiper"
@del="onDeleteSwiper"
/>
<!-- <SelectFile-->
<!-- :placeholder="`请选择图片`"-->
<!-- :limit="9"-->
<!-- :data="swiper"-->
<!-- @done="chooseSwiper"-->
<!-- @del="onDeleteSwiper"-->
<!-- />-->
<div class="flex flex-wrap justify-start items-start">
<div v-for="(item, index) in swiper" :key="index" style="margin-right: 10px; margin-bottom: 10px"
class="relative">
<img style="width: 100px; height: 100px" :src="item.url"/>
<div class="absolute right-0 top-0 w-6 h-6 bg-red-400 flex justify-center items-center rounded-bl-lg"
@click="onDeleteSwiper(index)">
<delete-outlined style="color: white"/>
</div>
</div>
</div>
<a-upload :show-upload-list="false" :customRequest="onUploadSwiper" multiple :max-count="9" ref="swiperRef">
<a-button class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
<span>上传轮播图</span>
</a-button>
</a-upload>
</a-form-item>
<!-- <a-form-item label="是否自营" name="ownStore">-->
<!-- <a-switch-->
<!-- checked-children="是"-->
<!-- un-checked-children="否"-->
<!-- :checked="form.ownStore === 1"-->
<!-- @update:checked="updateOwnStore"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="是否推荐" name="recommend">-->
<!-- <a-switch-->
<!-- checked-children="是"-->
<!-- un-checked-children="否"-->
<!-- :checked="form.recommend === 1"-->
<!-- @update:checked="updateRecommend"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="是否自营" name="ownStore">-->
<!-- <a-switch-->
<!-- checked-children="是"-->
<!-- un-checked-children="否"-->
<!-- :checked="form.ownStore === 1"-->
<!-- @update:checked="updateOwnStore"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="是否推荐" name="recommend">-->
<!-- <a-switch-->
<!-- checked-children="是"-->
<!-- un-checked-children="否"-->
<!-- :checked="form.recommend === 1"-->
<!-- @update:checked="updateRecommend"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="是否在营业" name="recommend">
<a-switch
checked-children=""
@@ -166,14 +193,14 @@
@update:checked="updateIsOn"
/>
</a-form-item>
<!-- <a-form-item label="是否需要审核" name="goodsReview">-->
<!-- <a-switch-->
<!-- checked-children="是"-->
<!-- un-checked-children="否"-->
<!-- :checked="form.goodsReview === 1"-->
<!-- @update:checked="updateGoodsReview"-->
<!-- />-->
<!-- </a-form-item>-->
<!-- <a-form-item label="是否需要审核" name="goodsReview">-->
<!-- <a-switch-->
<!-- checked-children="是"-->
<!-- un-checked-children="否"-->
<!-- :checked="form.goodsReview === 1"-->
<!-- @update:checked="updateGoodsReview"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
@@ -214,7 +241,7 @@
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject, uuid, phoneReg} from 'ele-admin-pro';
import {assignObject, uuid, phoneReg, messageLoading} from 'ele-admin-pro';
import {addMerchant, updateMerchant} from '@/api/shop/merchant';
import {Merchant} from '@/api/shop/merchant/model';
import {useThemeStore} from '@/store/modules/theme';
@@ -227,6 +254,9 @@ import {CenterPoint} from 'ele-admin-pro/es/ele-map-picker/types';
import {listRoles} from '@/api/system/role';
import {MerchantCategory} from "@/api/shop/merchantCategory/model";
import {listMerchantCategory} from "@/api/shop/merchantCategory";
import {getMerchantId} from "@/utils/merchant";
import {UploadOutlined, DeleteOutlined} from "@ant-design/icons-vue";
import {uploadOss} from "@/api/system/file";
// 是否是修改
const isUpdate = ref(false);
@@ -257,6 +287,7 @@ const images = ref<ItemType[]>([]);
const files = ref<ItemType[]>([]);
// 是否显示地图选择弹窗
const showMap = ref(false);
const merchantId = getMerchantId();
// 用户信息
const form = reactive<Merchant>({
@@ -453,6 +484,56 @@ const timeRange = ref<string[]>([])
const {resetFields} = useForm(form, rules);
const onUploadImage = (item) => {
const {file} = item;
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then(res => {
hide()
form.image = res.path;
})
.catch((e) => {
message.error(e.message);
hide();
})
};
const onUploadSwiper = (item) => {
const {file} = item;
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return;
}
const hide = messageLoading({
content: '上传中..',
duration: 0,
mask: true
});
uploadOss(file)
.then(data => {
hide()
swiper.value.push({
uid: data.id,
url: data.path,
status: 'done'
})
setPicker()
})
.catch((e) => {
message.error(e.message);
hide();
})
};
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
@@ -509,12 +590,16 @@ const chooseSwiper = (data: FileRecord) => {
url: data.path,
status: 'done'
});
};
const onDeleteSwiper = (index: number) => {
swiper.value.splice(index, 1);
setPicker()
};
const swiperRef = ref()
const imageRef = ref()
watch(
() => props.visible,
async (visible) => {
@@ -567,12 +652,28 @@ watch(
form.roleId = res[0].roleId;
form.roleName = res[0].roleName;
});
setPicker()
} else {
resetFields();
}
},
{immediate: true}
);
const setPicker = () => {
const swiperEl = swiperRef.value?.$el?.querySelector('input[type="file"]');
if (swiperEl) {
swiperEl.removeAttribute('accept'); // 移除 accept 属性
swiperEl.removeAttribute('capture'); // 移除 capture 属性
swiperEl.setAttribute('name', 'file'); // 添加 name 属性
}
const imageEl = imageRef.value?.$el?.querySelector('input[type="file"]');
if (imageEl) {
imageEl.removeAttribute('accept'); // 移除 accept 属性
imageEl.removeAttribute('capture'); // 移除 capture 属性
imageEl.setAttribute('name', 'file'); // 添加 name 属性
}
}
</script>
<style lang="less" scoped>

View File

@@ -3,7 +3,7 @@
<a-space :size="10" style="flex-wrap: wrap" v-if="!merchantId">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
<PlusOutlined/>
</template>
<span>添加</span>
</a-button>
@@ -19,50 +19,62 @@
<a-button class="ele-btn-icon" @click="openUrl(`/shop/apply`)">
<span>入驻申请</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/shop/desk`)">
<span>桌号管理</span>
</a-button>
<a-button class="ele-btn-icon" @click="openUrl(`/shop/type`)">
<span>店铺类型</span>
</a-button>
<a-button class="ele-btn-icon" @click="exportSupplierData">
<span>供应商报表</span>
</a-button>
<a-button class="ele-btn-icon" @click="exportSupplierCash">
<span>提现报表</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
import { openUrl } from '@/utils/common';
import router from '@/router';
import { getMerchant } from '@/api/shop/merchant';
import merchant from "@/views/shop/merchant/index.vue";
import { getMerchantId } from "@/utils/merchant";
import {PlusOutlined} from '@ant-design/icons-vue';
import type {GradeParam} from '@/api/user/grade/model';
import {watch} from 'vue';
import {openUrl} from '@/utils/common';
import router from '@/router';
import {getMerchantId} from "@/utils/merchant";
import {exportSupplierCashSheet, exportSupplierSheet} from "@/api/shop/order";
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
const merchantId = getMerchantId();
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
const merchantId = getMerchantId();
// 新增
const add = () => {
emit('add');
};
// 新增
const add = () => {
emit('add');
};
watch(
() => router.currentRoute,
(route) => {
console.log(route, 'route');
}
);
watch(
() => router.currentRoute,
(route) => {
console.log(route, 'route');
}
);
const exportSupplierData = async () => {
const {url} = await exportSupplierSheet()
window.open(url)
}
const exportSupplierCash = async () => {
const {url} = await exportSupplierCashSheet()
window.open(url)
}
</script>

View File

@@ -19,7 +19,7 @@
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="商户名称" name="merchantName">
<a-form-item label="商户名称" name="merchantName" v-if="form.shopType !== '合作伙伴'">
<a-input
allow-clear
placeholder="请输入商户名称"
@@ -41,21 +41,14 @@
v-model:value="form.phone"
/>
</a-form-item>
<a-form-item label="商户姓名" name="realName">
<a-form-item label="商户姓名" name="realName" v-if="form.shopType !== '合作伙伴'">
<a-input
allow-clear
placeholder="请输入商户姓名"
v-model:value="form.realName"
/>
</a-form-item>
<a-form-item label="店铺类型" name="shopType">
<SelectMerchantType
:placeholder="`请选择店铺类型`"
v-model:value="form.shopType"
@done="chooseShopType"
/>
</a-form-item>
<a-form-item label="商户分类" name="category">
<a-form-item label="商户分类" name="category" v-if="form.shopType !== '合作伙伴'">
<industry-select
v-model:value="form.category"
valueField="label"
@@ -64,7 +57,7 @@
@change="onIndustry"
/>
</a-form-item>
<a-form-item label="商家介绍" name="comments">
<a-form-item label="商家介绍" name="comments" v-if="form.shopType !== '合作伙伴'">
<a-textarea
:rows="4"
:maxlength="200"
@@ -72,7 +65,7 @@
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="营业执照" name="yyzz">
<a-form-item label="营业执照" name="yyzz" v-if="form.shopType !== '合作伙伴'">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"
@@ -99,7 +92,7 @@
/>
</a-space>
</a-form-item>
<a-form-item label="其他资质" name="files">
<a-form-item label="其他资质" name="files" v-if="form.shopType !== '合作伙伴'">
<SelectFile
:placeholder="`请选择图片`"
:limit="9"
@@ -108,7 +101,7 @@
@del="onDeleteFiles"
/>
</a-form-item>
<a-form-item label="门店照片" name="image">
<a-form-item label="门店照片" name="image" v-if="form.shopType !== '合作伙伴'">
<SelectFile
:placeholder="`请选择图片`"
:limit="1"

View File

@@ -0,0 +1,236 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑商家充值套餐' : '添加商家充值套餐'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="金额" name="amount">
<a-input
allow-clear
placeholder="请输入金额"
v-model:value="form.amount"
/>
</a-form-item>
<a-form-item label="赠送金额" name="sendAmount">
<a-input
allow-clear
placeholder="请输入赠送金额"
v-model:value="form.sendAmount"
/>
</a-form-item>
<a-form-item label="" name="merchantId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.merchantId"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="0待审核1通过2拒绝" 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="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addMerchantChargePackage, updateMerchantChargePackage } from '@/api/shop/merchantChargePackage';
import { MerchantChargePackage } from '@/api/shop/merchantChargePackage/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: MerchantChargePackage | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<MerchantChargePackage>({
id: undefined,
amount: undefined,
sendAmount: undefined,
merchantId: undefined,
userId: undefined,
status: undefined,
sortNumber: undefined,
comments: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
merchantChargePackageId: undefined,
merchantChargePackageName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
merchantChargePackageName: [
{
required: true,
type: 'string',
message: '请填写商家充值套餐名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateMerchantChargePackage : addMerchantChargePackage;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,269 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="merchantChargePackageId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<MerchantChargePackageEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import MerchantChargePackageEdit from './components/merchantChargePackageEdit.vue';
import { pageMerchantChargePackage, removeMerchantChargePackage, removeBatchMerchantChargePackage } from '@/api/shop/merchantChargePackage';
import type { MerchantChargePackage, MerchantChargePackageParam } from '@/api/shop/merchantChargePackage/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<MerchantChargePackage[]>([]);
// 当前编辑数据
const current = ref<MerchantChargePackage | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageMerchantChargePackage({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '金额',
dataIndex: 'amount',
key: 'amount',
align: 'center',
},
{
title: '赠送金额',
dataIndex: 'sendAmount',
key: 'sendAmount',
align: 'center',
},
{
title: '',
dataIndex: 'merchantId',
key: 'merchantId',
align: 'center',
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '0待审核1通过2拒绝',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: MerchantChargePackageParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: MerchantChargePackage) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: MerchantChargePackage) => {
const hide = message.loading('请求中..', 0);
removeMerchantChargePackage(row.merchantChargePackageId)
.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);
removeBatchMerchantChargePackage(selection.value.map((d) => d.merchantChargePackageId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: MerchantChargePackage) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'MerchantChargePackage'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,236 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑商家充值套餐' : '添加商家充值套餐'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="金额" name="amount">
<a-input
allow-clear
placeholder="请输入金额"
v-model:value="form.amount"
/>
</a-form-item>
<a-form-item label="可使用次数" name="getNum">
<a-input
allow-clear
placeholder="请输入可使用次数"
v-model:value="form.getNum"
/>
</a-form-item>
<a-form-item label="" name="merchantId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.merchantId"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="0待审核1通过2拒绝" 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="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addMerchantGoodsPackage, updateMerchantGoodsPackage } from '@/api/shop/merchantGoodsPackage';
import { MerchantGoodsPackage } from '@/api/shop/merchantGoodsPackage/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: MerchantGoodsPackage | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<MerchantGoodsPackage>({
id: undefined,
amount: undefined,
getNum: undefined,
merchantId: undefined,
userId: undefined,
status: undefined,
sortNumber: undefined,
comments: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
merchantGoodsPackageId: undefined,
merchantGoodsPackageName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
merchantGoodsPackageName: [
{
required: true,
type: 'string',
message: '请填写商家充值套餐名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateMerchantGoodsPackage : addMerchantGoodsPackage;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,269 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="merchantGoodsPackageId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<MerchantGoodsPackageEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import MerchantGoodsPackageEdit from './components/merchantGoodsPackageEdit.vue';
import { pageMerchantGoodsPackage, removeMerchantGoodsPackage, removeBatchMerchantGoodsPackage } from '@/api/shop/merchantGoodsPackage';
import type { MerchantGoodsPackage, MerchantGoodsPackageParam } from '@/api/shop/merchantGoodsPackage/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<MerchantGoodsPackage[]>([]);
// 当前编辑数据
const current = ref<MerchantGoodsPackage | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageMerchantGoodsPackage({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '金额',
dataIndex: 'amount',
key: 'amount',
align: 'center',
},
{
title: '可使用次数',
dataIndex: 'getNum',
key: 'getNum',
align: 'center',
},
{
title: '',
dataIndex: 'merchantId',
key: 'merchantId',
align: 'center',
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '0待审核1通过2拒绝',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: MerchantGoodsPackageParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: MerchantGoodsPackage) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: MerchantGoodsPackage) => {
const hide = message.loading('请求中..', 0);
removeMerchantGoodsPackage(row.merchantGoodsPackageId)
.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);
removeBatchMerchantGoodsPackage(selection.value.map((d) => d.merchantGoodsPackageId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: MerchantGoodsPackage) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'MerchantGoodsPackage'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,228 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑商家套餐可使用的商品' : '添加商家套餐可使用的商品'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="packageId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.packageId"
/>
</a-form-item>
<a-form-item label="" name="goodsId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.goodsId"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="0待审核1通过2拒绝" 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="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addMerchantPackageGoods, updateMerchantPackageGoods } from '@/api/shop/merchantPackageGoods';
import { MerchantPackageGoods } from '@/api/shop/merchantPackageGoods/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: MerchantPackageGoods | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<MerchantPackageGoods>({
id: undefined,
packageId: undefined,
goodsId: undefined,
userId: undefined,
status: undefined,
sortNumber: undefined,
comments: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
merchantPackageGoodsId: undefined,
merchantPackageGoodsName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
merchantPackageGoodsName: [
{
required: true,
type: 'string',
message: '请填写商家套餐可使用的商品名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateMerchantPackageGoods : addMerchantPackageGoods;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,263 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="merchantPackageGoodsId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<MerchantPackageGoodsEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import MerchantPackageGoodsEdit from './components/merchantPackageGoodsEdit.vue';
import { pageMerchantPackageGoods, removeMerchantPackageGoods, removeBatchMerchantPackageGoods } from '@/api/shop/merchantPackageGoods';
import type { MerchantPackageGoods, MerchantPackageGoodsParam } from '@/api/shop/merchantPackageGoods/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<MerchantPackageGoods[]>([]);
// 当前编辑数据
const current = ref<MerchantPackageGoods | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageMerchantPackageGoods({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'packageId',
key: 'packageId',
align: 'center',
},
{
title: '',
dataIndex: 'goodsId',
key: 'goodsId',
align: 'center',
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '0待审核1通过2拒绝',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: MerchantPackageGoodsParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: MerchantPackageGoods) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: MerchantPackageGoods) => {
const hide = message.loading('请求中..', 0);
removeMerchantPackageGoods(row.merchantPackageGoodsId)
.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);
removeBatchMerchantPackageGoods(selection.value.map((d) => d.merchantPackageGoodsId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: MerchantPackageGoods) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'MerchantPackageGoods'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,173 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑' : '添加'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="标题" name="title">
<a-input
allow-clear
placeholder="请输入标题"
v-model:value="form.title"
/>
</a-form-item>
<a-form-item label="选择用户" name="userId">
<SelectUser
:placeholder="`选择用户`"
:organizationId="0"
v-model:value="form.phone"
@done="doSelectUser"
/>
</a-form-item>
<a-form-item label="内容" name="content">
<tinymce-editor
v-model:value="form.content"
placeholder="请输入内容"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, reactive, watch} from 'vue';
import {Form, message} from 'ant-design-vue';
import {assignObject, uuid} from 'ele-admin-pro';
import {addMessage, updateMessage} from '@/api/shop/message';
import {Message} from '@/api/shop/message/model';
import {useThemeStore} from '@/store/modules/theme';
import {storeToRefs} from 'pinia';
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
import {FormInstance} from 'ant-design-vue/es/form';
import {User} from "@/api/system/user/model";
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const {styleResponsive} = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: Message | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<Message>({
id: undefined,
type: undefined,
pk: undefined,
title: undefined,
content: undefined,
phone: undefined,
nickname: undefined,
userId: undefined,
hasRead: undefined,
tenantId: undefined,
createTime: undefined,
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
title: [
{required: true, message: '请输入标题', trigger: 'blur'}
],
userId: [
{required: true, message: '请选择用户', trigger: 'blur'}
],
content: [
{required: true, message: '请输入内容', trigger: 'blur'}
]
});
const doSelectUser = (data: User) => {
form.userId = data.userId
form.phone = data.phone
form.nickname = data.nickname
}
const {resetFields} = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateMessage : addMessage;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {
});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{immediate: true}
);
</script>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,225 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 1" color="green">显示</a-tag>
<a-tag v-if="record.status === 0" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<MessageEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import MessageEdit from './components/messageEdit.vue';
import { pageMessage, removeMessage, removeBatchMessage } from '@/api/shop/message';
import type { Message, MessageParam } from '@/api/shop/message/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<Message[]>([]);
// 当前编辑数据
const current = ref<Message | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageMessage({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'title',
align: 'center',
},
{
title: '标题',
dataIndex: 'title',
key: 'title',
align: 'center',
},
{
title: '用户',
dataIndex: 'phone',
align: 'center',
},
{
title: '发送时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: MessageParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Message) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: Message) => {
const hide = message.loading('请求中..', 0);
removeMessage(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);
removeBatchMessage(selection.value.map((d) => d.id))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: Message) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'Message'
};
</script>
<style lang="less" scoped></style>

View File

@@ -83,6 +83,8 @@
><IdcardOutlined class="tag-icon" />IC季卡</a-tag
>
<a-tag v-if="record.payType == 18">代付</a-tag>
<a-tag v-if="record.payType == 19">门店余额</a-tag>
<a-tag v-if="record.payType == 20">门店套餐</a-tag>
</template>
<template v-else>
<span></span>

View File

@@ -28,7 +28,7 @@
</a-select>
</a-form-item>
<a-form-item
label="图片"
label="图片(724x360)"
name="image">
<SelectFile
:placeholder="`请选择图片`"

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,220 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑用户在商家中的余额' : '添加用户在商家中的余额'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="" name="balance">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.balance"
/>
</a-form-item>
<a-form-item label="0待审核1通过2拒绝" 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="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addUserBalanceInMerchant, updateUserBalanceInMerchant } from '@/api/shop/userBalanceInMerchant';
import { UserBalanceInMerchant } from '@/api/shop/userBalanceInMerchant/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: UserBalanceInMerchant | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<UserBalanceInMerchant>({
id: undefined,
userId: undefined,
balance: undefined,
status: undefined,
sortNumber: undefined,
comments: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
userBalanceInMerchantId: undefined,
userBalanceInMerchantName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
userBalanceInMerchantName: [
{
required: true,
type: 'string',
message: '请填写用户在商家中的余额名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateUserBalanceInMerchant : addUserBalanceInMerchant;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,257 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="userBalanceInMerchantId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<UserBalanceInMerchantEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import UserBalanceInMerchantEdit from './components/userBalanceInMerchantEdit.vue';
import { pageUserBalanceInMerchant, removeUserBalanceInMerchant, removeBatchUserBalanceInMerchant } from '@/api/shop/userBalanceInMerchant';
import type { UserBalanceInMerchant, UserBalanceInMerchantParam } from '@/api/shop/userBalanceInMerchant/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<UserBalanceInMerchant[]>([]);
// 当前编辑数据
const current = ref<UserBalanceInMerchant | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageUserBalanceInMerchant({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '',
dataIndex: 'balance',
key: 'balance',
align: 'center',
},
{
title: '0待审核1通过2拒绝',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: UserBalanceInMerchantParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: UserBalanceInMerchant) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: UserBalanceInMerchant) => {
const hide = message.loading('请求中..', 0);
removeUserBalanceInMerchant(row.userBalanceInMerchantId)
.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);
removeBatchUserBalanceInMerchant(selection.value.map((d) => d.userBalanceInMerchantId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: UserBalanceInMerchant) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'UserBalanceInMerchant'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,194 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑用户绑定分红角色' : '添加用户绑定分红角色'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="roleId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.roleId"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="状态, 0正常, 1异常" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addUserCommissionRole, updateUserCommissionRole } from '@/api/shop/userCommissionRole';
import { UserCommissionRole } from '@/api/shop/userCommissionRole/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: UserCommissionRole | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<UserCommissionRole>({
id: undefined,
roleId: undefined,
userId: undefined,
status: undefined,
comments: undefined,
tenantId: undefined,
createTime: undefined,
userCommissionRoleId: undefined,
userCommissionRoleName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
userCommissionRoleName: [
{
required: true,
type: 'string',
message: '请填写用户绑定分红角色名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateUserCommissionRole : addUserCommissionRole;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,239 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="userCommissionRoleId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<UserCommissionRoleEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import UserCommissionRoleEdit from './components/userCommissionRoleEdit.vue';
import { pageUserCommissionRole, removeUserCommissionRole, removeBatchUserCommissionRole } from '@/api/shop/userCommissionRole';
import type { UserCommissionRole, UserCommissionRoleParam } from '@/api/shop/userCommissionRole/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<UserCommissionRole[]>([]);
// 当前编辑数据
const current = ref<UserCommissionRole | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageUserCommissionRole({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'roleId',
key: 'roleId',
align: 'center',
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '状态, 0正常, 1异常',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: UserCommissionRoleParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: UserCommissionRole) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: UserCommissionRole) => {
const hide = message.loading('请求中..', 0);
removeUserCommissionRole(row.userCommissionRoleId)
.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);
removeBatchUserCommissionRole(selection.value.map((d) => d.userCommissionRoleId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: UserCommissionRole) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'UserCommissionRole'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,220 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑用户在商家中的代金券' : '添加用户在商家中的代金券'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="" name="balance">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.balance"
/>
</a-form-item>
<a-form-item label="0待审核1通过2拒绝" 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="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="备注" name="comments">
<a-textarea
:rows="4"
:maxlength="200"
placeholder="请输入描述"
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addUserGoodsInMerchant, updateUserGoodsInMerchant } from '@/api/shop/userGoodsInMerchant';
import { UserGoodsInMerchant } from '@/api/shop/userGoodsInMerchant/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: UserGoodsInMerchant | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<UserGoodsInMerchant>({
id: undefined,
userId: undefined,
balance: undefined,
status: undefined,
sortNumber: undefined,
comments: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
userGoodsInMerchantId: undefined,
userGoodsInMerchantName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
userGoodsInMerchantName: [
{
required: true,
type: 'string',
message: '请填写用户在商家中的代金券名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateUserGoodsInMerchant : addUserGoodsInMerchant;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,257 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="userGoodsInMerchantId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<UserGoodsInMerchantEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import UserGoodsInMerchantEdit from './components/userGoodsInMerchantEdit.vue';
import { pageUserGoodsInMerchant, removeUserGoodsInMerchant, removeBatchUserGoodsInMerchant } from '@/api/shop/userGoodsInMerchant';
import type { UserGoodsInMerchant, UserGoodsInMerchantParam } from '@/api/shop/userGoodsInMerchant/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<UserGoodsInMerchant[]>([]);
// 当前编辑数据
const current = ref<UserGoodsInMerchant | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageUserGoodsInMerchant({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '',
dataIndex: 'balance',
key: 'balance',
align: 'center',
},
{
title: '0待审核1通过2拒绝',
dataIndex: 'status',
key: 'status',
align: 'center',
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: UserGoodsInMerchantParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: UserGoodsInMerchant) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: UserGoodsInMerchant) => {
const hide = message.loading('请求中..', 0);
removeUserGoodsInMerchant(row.userGoodsInMerchantId)
.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);
removeBatchUserGoodsInMerchant(selection.value.map((d) => d.userGoodsInMerchantId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: UserGoodsInMerchant) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'UserGoodsInMerchant'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,42 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-button type="primary" class="ele-btn-icon" @click="add">
<template #icon>
<PlusOutlined />
</template>
<span>添加</span>
</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { PlusOutlined } from '@ant-design/icons-vue';
import type { GradeParam } from '@/api/user/grade/model';
import { watch } from 'vue';
const props = withDefaults(
defineProps<{
// 选中的角色
selection?: [];
}>(),
{}
);
const emit = defineEmits<{
(e: 'search', where?: GradeParam): void;
(e: 'add'): void;
(e: 'remove'): void;
(e: 'batchMove'): void;
}>();
// 新增
const add = () => {
emit('add');
};
watch(
() => props.selection,
() => {}
);
</script>

View File

@@ -0,0 +1,212 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑浏览历史' : '添加浏览历史'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@ok="save"
>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
:wrapper-col="
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
"
>
<a-form-item label="" name="type">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.type"
/>
</a-form-item>
<a-form-item label="" name="pk">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.pk"
/>
</a-form-item>
<a-form-item label="" name="userId">
<a-input
allow-clear
placeholder="请输入"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="排序号" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
</a-form>
</ele-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addViewHistory, updateViewHistory } from '@/api/shop/viewHistory';
import { ViewHistory } from '@/api/shop/viewHistory/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
import { FormInstance } from 'ant-design-vue/es/form';
import { FileRecord } from '@/api/system/file/model';
// 是否是修改
const isUpdate = ref(false);
const useForm = Form.useForm;
// 是否开启响应式布局
const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: ViewHistory | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 提交状态
const loading = ref(false);
// 是否显示最大化切换按钮
const maxable = ref(true);
// 表格选中数据
const formRef = ref<FormInstance | null>(null);
const images = ref<ItemType[]>([]);
// 用户信息
const form = reactive<ViewHistory>({
id: undefined,
type: undefined,
pk: undefined,
userId: undefined,
sortNumber: undefined,
deleted: undefined,
tenantId: undefined,
createTime: undefined,
updateTime: undefined,
viewHistoryId: undefined,
viewHistoryName: '',
status: 0,
comments: '',
sortNumber: 100
});
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
// 表单验证规则
const rules = reactive({
viewHistoryName: [
{
required: true,
type: 'string',
message: '请填写浏览历史名称',
trigger: 'blur'
}
]
});
const chooseImage = (data: FileRecord) => {
images.value.push({
uid: data.id,
url: data.path,
status: 'done'
});
form.image = data.path;
};
const onDeleteItem = (index: number) => {
images.value.splice(index, 1);
form.image = '';
};
const { resetFields } = useForm(form, rules);
/* 保存编辑 */
const save = () => {
if (!formRef.value) {
return;
}
formRef.value
.validate()
.then(() => {
loading.value = true;
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateViewHistory : addViewHistory;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
})
.catch(() => {});
};
watch(
() => props.visible,
(visible) => {
if (visible) {
images.value = [];
if (props.data) {
assignObject(form, props.data);
if(props.data.image){
images.value.push({
uid: uuid(),
url: props.data.image,
status: 'done'
})
}
isUpdate.value = true;
} else {
isUpdate.value = false;
}
} else {
resetFields();
}
},
{ immediate: true }
);
</script>

View File

@@ -0,0 +1,251 @@
<template>
<div class="page">
<div class="ele-body">
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="viewHistoryId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm
title="确定要删除此记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</a-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<ViewHistoryEdit v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import ViewHistoryEdit from './components/viewHistoryEdit.vue';
import { pageViewHistory, removeViewHistory, removeBatchViewHistory } from '@/api/shop/viewHistory';
import type { ViewHistory, ViewHistoryParam } from '@/api/shop/viewHistory/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<ViewHistory[]>([]);
// 当前编辑数据
const current = ref<ViewHistory | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
return pageViewHistory({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 90,
},
{
title: '',
dataIndex: 'type',
key: 'type',
align: 'center',
},
{
title: '',
dataIndex: 'pk',
key: 'pk',
align: 'center',
},
{
title: '',
dataIndex: 'userId',
key: 'userId',
align: 'center',
},
{
title: '排序号',
dataIndex: 'sortNumber',
key: 'sortNumber',
align: 'center',
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
align: 'center',
},
{
title: '操作',
key: 'action',
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ViewHistoryParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: ViewHistory) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: ViewHistory) => {
const hide = message.loading('请求中..', 0);
removeViewHistory(row.viewHistoryId)
.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);
removeBatchViewHistory(selection.value.map((d) => d.viewHistoryId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: ViewHistory) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
export default {
name: 'ViewHistory'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,44 @@
<template>
<div>
<a-row :gutter="16">
<a-col :span="8">
<a-card title="用户数" :bordered="false">
<p>{{ userNum }}</p>
</a-card>
</a-col>
<a-col :span="8">
<a-card title="总收入" :bordered="false">
<p>{{ data.totalIncome }}</p>
</a-card>
</a-col>
<a-col :span="8">
<a-card title="当日收入" :bordered="false">
<p>{{ data.todayIncome }}</p>
</a-card>
</a-col>
</a-row>
</div>
</template>
<script setup>
import {ref} from 'vue'
import {listUsers} from "@/api/system/user";
import {getData} from "@/api/shop/order";
const userNum = ref(0)
const getUserNum = async () => {
const res = await listUsers()
userNum.value = res.length
}
getUserNum()
const data = ref({
totalIncome: 0,
todayIncome: 0,
})
const getOrderData = async () => {
data.value = await getData()
}
getOrderData()
</script>

View File

@@ -0,0 +1,102 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="'80%'"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="'下级列表'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
:footer="null"
@cancel="updateVisible(false)"
>
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<a-space>
<a-input v-model:value="keywords" allow-clear placeholder="姓名/手机号搜索" @change="reload"></a-input>
</a-space>
</template>
<template #bodyCell="{ column, record }">
</template>
</ele-pro-table>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, watch} from 'vue';
import type {EleProTable} from "ele-admin-pro";
import {User} from "@/api/system/user/model";
import {pageUserReferee} from "@/api/user/referee";
const columns = ref<any[]>([{
title: '昵称',
dataIndex: ['user', 'nickname'],
align: 'center',
},
{
title: '手机号',
dataIndex: ['user', 'phone'],
align: 'center',
},
{
title: '余额',
dataIndex: ['user', 'balance'],
align: 'center',
},]);
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: User | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 是否显示最大化切换按钮
const maxable = ref(true);
const keywords = ref('');
const datasource = ({page, limit}) => {
return pageUserReferee({
dealerId: props.data?.userId,
keywords: keywords.value,
page,
limit
})
}
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const reload = () => {
tableRef.value?.reload();
}
watch(
() => props.visible,
(visible) => {
if (visible) {
} else {
reload()
}
},
{immediate: true}
);
</script>

View File

@@ -0,0 +1,101 @@
<!-- 编辑弹窗 -->
<template>
<ele-modal
:width="800"
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="'分红角色配置'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
@cancel="updateVisible(false)"
@ok="save"
>
<a-select v-model:value="list" mode="multiple" placeholder="角色选择" style="width: 100%">
<a-select-option v-for="(item, index) in roleList" :key="index" :value="item.id">{{
item.title
}}
</a-select-option>
</a-select>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref, watch} from 'vue';
import type {EleProTable} from "ele-admin-pro";
import {User} from "@/api/system/user/model";
import {UserCommissionRole} from "@/api/shop/userCommissionRole/model";
import {CommissionRole} from "@/api/shop/commissionRole/model";
import {listCommissionRole} from "@/api/shop/commissionRole";
import {batchAddUserCommissionRole, listUserCommissionRole} from "@/api/shop/userCommissionRole";
import {message} from "ant-design-vue";
const props = defineProps<{
// 弹窗是否打开
visible: boolean;
// 修改回显的数据
data?: User | null;
}>();
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
// 是否显示最大化切换按钮
const maxable = ref(true);
const list = ref<number[]>([])
const roleList = ref<CommissionRole[]>([])
const getRoleList = async () => {
roleList.value = await listCommissionRole()
}
const save = async () => {
const data: UserCommissionRole[] = []
list.value.forEach(item => {
data.push({
userId: props.data?.userId,
roleId: item
})
})
await batchAddUserCommissionRole(data)
message.success('保存成功')
updateVisible(false)
}
/* 更新visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
const reload = () => {
tableRef.value?.reload();
}
const getUerRole = async () => {
const res = await listUserCommissionRole({
userId: props.data?.userId
})
if (res && res.length > 0) {
list.value = res.map(item => item.roleId)
}
}
watch(
() => props.visible,
(visible) => {
if (visible) {
getRoleList()
getUerRole()
} else {
reload()
}
},
{immediate: true}
);
</script>

View File

@@ -17,7 +17,7 @@
<a-space>
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
<template #icon>
<plus-outlined />
<plus-outlined/>
</template>
<span>新建</span>
</a-button>
@@ -28,7 +28,7 @@
:disabled="selection.length === 0"
>
<template #icon>
<EditOutlined />
<EditOutlined/>
</template>
<span>修改</span>
</a-button>
@@ -37,7 +37,8 @@
danger
@click="resetPsw(selection[0])"
:disabled="selection.length === 0"
>重置密码</a-button
>重置密码
</a-button
>
<a-button
danger
@@ -46,13 +47,13 @@
@click="removeBatch"
>
<template #icon>
<delete-outlined />
<delete-outlined/>
</template>
<span>批量删除</span>
</a-button>
<a-button type="dashed" class="ele-btn-icon" @click="openImport">
<template #icon>
<upload-outlined />
<upload-outlined/>
</template>
<span>导入</span>
</a-button>
@@ -73,13 +74,19 @@
style="margin-right: 4px"
>
<template #icon>
<UserOutlined />
<UserOutlined/>
</template>
</a-avatar>
</template>
<template v-if="column.key === 'nickname'">
<span>{{ record.nickname }}</span>
</template>
<template v-if="column.key === 'referee'">
<template v-if="record.referee">
<p>{{ record.referee.username }}</p>
<p>{{ record.referee.phone }}</p>
</template>
</template>
<template v-if="column.key === 'mobile'">
<span v-if="hasRole('superAdmin')">{{ record.phone }}</span>
<span v-else>{{ record.mobile }}</span>
@@ -90,9 +97,9 @@
</a-tag>
</template>
<template v-if="column.key === 'platform'">
<WechatOutlined v-if="record.platform === 'MP-WEIXIN'" />
<Html5Outlined v-if="record.platform === 'H5'" />
<ChromeOutlined v-if="record.platform === 'WEB'" />
<WechatOutlined v-if="record.platform === 'MP-WEIXIN'"/>
<Html5Outlined v-if="record.platform === 'H5'"/>
<ChromeOutlined v-if="record.platform === 'WEB'"/>
</template>
<template v-if="column.key === 'balance'">
<span class="ele-text-success">
@@ -112,8 +119,12 @@
</template>
<template v-if="column.key === 'action'">
<a-space>
<a @click="openCommission(record)">分红角色</a>
<a-divider type="vertical"/>
<a @click="openChild(record)">下级</a>
<a-divider type="vertical"/>
<a @click="openEdit(record)">修改</a>
<a-divider type="vertical" />
<a-divider type="vertical"/>
<!-- <a @click="resetPsw(record)">重置</a>-->
<!-- <a-divider type="vertical" />-->
<a-popconfirm
@@ -136,427 +147,435 @@
@done="reload"
/>
<!-- 导入弹窗 -->
<user-import v-model:visible="showImport" @done="reload" />
<user-import v-model:visible="showImport" @done="reload"/>
<!-- 用户详情 -->
<user-info v-model:visible="showInfo" :data="current" @done="reload" />
<user-info v-model:visible="showInfo" :data="current" @done="reload"/>
<child-list v-model:visible="showChild" v-if="showChild" :data="current" @done="reload"/>
<commission-role v-model:visible="showCommission" v-if="showCommission" :data="current" @done="reload"/>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref, reactive } from 'vue';
import { message, Modal } from 'ant-design-vue/es';
import {
PlusOutlined,
DeleteOutlined,
UploadOutlined,
EditOutlined,
UserOutlined,
Html5Outlined,
ChromeOutlined,
WechatOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro/es';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import { messageLoading, formatNumber } from 'ele-admin-pro/es';
import { timeAgo } from 'ele-admin-pro';
import UserEdit from './components/user-edit.vue';
import UserImport from './components/user-import.vue';
import UserInfo from './components/user-info.vue';
import { toDateString } from 'ele-admin-pro';
import {
pageUsers,
removeUser,
removeUsers,
updateUserStatus,
updateUserPassword,
updateUser
} from '@/api/system/user';
import type { User, UserParam } from '@/api/system/user/model';
import { toTreeData, uuid } from 'ele-admin-pro';
import { listRoles } from '@/api/system/role';
import { listOrganizations } from '@/api/system/organization';
import { Organization } from '@/api/system/organization/model';
import { hasRole } from '@/utils/permission';
import {createVNode, ref, reactive} from 'vue';
import {message, Modal} from 'ant-design-vue/es';
import {
PlusOutlined,
DeleteOutlined,
UploadOutlined,
EditOutlined,
UserOutlined,
Html5Outlined,
ChromeOutlined,
WechatOutlined,
ExclamationCircleOutlined
} from '@ant-design/icons-vue';
import type {EleProTable} from 'ele-admin-pro/es';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import {messageLoading, formatNumber} from 'ele-admin-pro/es';
import UserEdit from './components/user-edit.vue';
import UserImport from './components/user-import.vue';
import UserInfo from './components/user-info.vue';
import {toDateString} from 'ele-admin-pro';
import {
pageUsers,
removeUser,
removeUsers,
updateUserPassword,
updateUser
} from '@/api/system/user';
import type {User, UserParam} from '@/api/system/user/model';
import {toTreeData, uuid} from 'ele-admin-pro';
import {listRoles} from '@/api/system/role';
import {listOrganizations} from '@/api/system/organization';
import {Organization} from '@/api/system/organization/model';
import {hasRole} from '@/utils/permission';
import ChildList from "@/views/system/user/components/childList.vue";
import CommissionRole from "./components/commissionRole.vue";
// 加载状态
const loading = ref(true);
// 树形数据
const data = ref<Organization[]>([]);
// 树展开的key
const expandedRowKeys = ref<number[]>([]);
// 树选中的key
const selectedRowKeys = ref<number[]>([]);
// 表格选中数据
const selection = ref<User[]>([]);
// 当前编辑数据
const current = ref<User | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示用户详情
const showInfo = ref(false);
// 是否显示用户导入弹窗
const showImport = ref(false);
const userType = ref<number>();
const searchText = ref('');
// 加载状态
const loading = ref(true);
// 树形数据
const data = ref<Organization[]>([]);
// 树展开的key
const expandedRowKeys = ref<number[]>([]);
// 树选中的key
const selectedRowKeys = ref<number[]>([]);
// 表格选中数据
const selection = ref<User[]>([]);
// 当前编辑数据
const current = ref<User | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示用户详情
const showInfo = ref(false);
// 是否显示用户导入弹窗
const showImport = ref(false);
const userType = ref<number>();
const searchText = ref('');
// 加载角色
const roles = ref<any[]>([]);
const filters = () => {
listRoles().then((result) => {
result.map((d) => {
roles.value.push({
text: d.roleName,
value: d.roleId
});
// 加载角色
const roles = ref<any[]>([]);
const filters = () => {
listRoles().then((result) => {
result.map((d) => {
roles.value.push({
text: d.roleName,
value: d.roleId
});
});
};
filters();
// 加载机构
listOrganizations()
.then((list) => {
loading.value = false;
const eks: number[] = [];
list.forEach((d) => {
d.key = d.organizationId;
d.value = d.organizationId;
d.title = d.organizationName;
if (typeof d.key === 'number') {
eks.push(d.key);
}
});
expandedRowKeys.value = eks;
data.value = toTreeData({
data: list,
idField: 'organizationId',
parentIdField: 'parentId'
});
if (list.length) {
if (typeof list[0].key === 'number') {
selectedRowKeys.value = [list[0].key];
}
// current.value = list[0];
} else {
selectedRowKeys.value = [];
// current.value = null;
});
};
filters();
// 加载机构
listOrganizations()
.then((list) => {
loading.value = false;
const eks: number[] = [];
list.forEach((d) => {
d.key = d.organizationId;
d.value = d.organizationId;
d.title = d.organizationName;
if (typeof d.key === 'number') {
eks.push(d.key);
}
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'userId',
width: 90,
showSorterTooltip: false
},
{
title: '头像',
key: 'avatar',
dataIndex: 'avatar',
align: 'center',
width: 90
},
{
title: '手机号码',
dataIndex: 'mobile',
align: 'center',
key: 'mobile',
showSorterTooltip: false
},
{
title: '真实姓名',
dataIndex: 'realName',
align: 'center',
showSorterTooltip: false
},
{
title: '昵称',
key: 'nickname',
align: 'center',
dataIndex: 'nickname'
},
{
title: '性别',
dataIndex: 'sex',
align: 'center',
showSorterTooltip: false
},
{
title: '邮箱',
dataIndex: 'email',
align: 'center',
hideInTable: true,
showSorterTooltip: false
},
{
title: '可用余额',
dataIndex: 'balance',
align: 'center'
},
{
title: '可用积分',
dataIndex: 'points',
align: 'center',
sorter: true
},
{
title: '实际消费金额',
dataIndex: 'expendMoney',
key: 'expendMoney',
sorter: true,
align: 'center',
hideInTable: true,
showSorterTooltip: false
},
{
title: '注册来源',
key: 'platform',
align: 'center',
dataIndex: 'platform',
width: 120
},
{
title: '证件号码',
dataIndex: 'idCard',
align: 'center',
hideInTable: true
},
{
title: '出生日期',
dataIndex: 'birthday',
key: 'birthday',
hideInTable: true
},
{
title: '省份',
dataIndex: 'province',
key: 'province',
hideInTable: true
},
{
title: '城市',
dataIndex: 'city',
key: 'city',
hideInTable: true,
showSorterTooltip: false
},
{
title: '地区',
dataIndex: 'region',
key: 'region',
hideInTable: true,
showSorterTooltip: false
},
{
title: '邮箱认证',
dataIndex: 'emailVerified',
hideInTable: true,
showSorterTooltip: false,
customRender: ({ text }) => ['未认证', '已认证'][text]
},
{
title: '实名认证',
dataIndex: 'certification',
sorter: true,
hideInTable: true,
customRender: ({ text }) => ['未认证', '已认证'][text]
},
{
title: '角色',
dataIndex: 'roles',
key: 'roles',
align: 'center'
},
{
title: '管理员',
key: 'isAdmin',
dataIndex: 'isAdmin',
sorter: true,
showSorterTooltip: false,
align: 'center'
},
{
title: '注册时间',
dataIndex: 'createTime',
sorter: true,
showSorterTooltip: false,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
width: 120,
fixed: 'right',
align: 'center'
expandedRowKeys.value = eks;
data.value = toTreeData({
data: list,
idField: 'organizationId',
parentIdField: 'parentId'
});
if (list.length) {
if (typeof list[0].key === 'number') {
selectedRowKeys.value = [list[0].key];
}
// current.value = list[0];
} else {
selectedRowKeys.value = [];
// current.value = null;
}
]);
// 默认搜索条件
const defaultWhere = reactive({
username: '',
nickname: ''
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
where = {};
where.roleId = filters.roles;
where.keywords = searchText.value;
return pageUsers({ page, limit, ...where, ...orders });
};
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'userId',
width: 90,
showSorterTooltip: false
},
{
title: '头像',
key: 'avatar',
dataIndex: 'avatar',
align: 'center',
width: 90
},
{
title: '手机号码',
dataIndex: 'mobile',
align: 'center',
key: 'mobile',
showSorterTooltip: false
},
{
title: '真实姓名',
dataIndex: 'realName',
align: 'center',
showSorterTooltip: false
},
{
title: '昵称',
key: 'nickname',
align: 'center',
dataIndex: 'nickname'
},
{
title: '邮箱',
dataIndex: 'email',
align: 'center',
hideInTable: true,
showSorterTooltip: false
},
{
title: '可用余额',
dataIndex: 'balance',
align: 'center'
},
{
title: '实际消费金额',
dataIndex: 'expendMoney',
key: 'expendMoney',
sorter: true,
align: 'center',
hideInTable: true,
showSorterTooltip: false
},
{
title: '注册来源',
key: 'platform',
align: 'center',
dataIndex: 'platform',
width: 120
},
{
title: '证件号码',
dataIndex: 'idCard',
align: 'center',
hideInTable: true
},
{
title: '出生日期',
dataIndex: 'birthday',
key: 'birthday',
hideInTable: true
},
{
title: '省份',
dataIndex: 'province',
key: 'province',
hideInTable: true
},
{
title: '城市',
dataIndex: 'city',
key: 'city',
hideInTable: true,
showSorterTooltip: false
},
{
title: '地区',
dataIndex: 'region',
key: 'region',
hideInTable: true,
showSorterTooltip: false
},
{
title: '邮箱认证',
dataIndex: 'emailVerified',
hideInTable: true,
showSorterTooltip: false,
customRender: ({text}) => ['未认证', '已认证'][text]
},
{
title: '实名认证',
dataIndex: 'certification',
sorter: true,
hideInTable: true,
customRender: ({text}) => ['未认证', '已认证'][text]
},
{
title: '角色',
dataIndex: 'roles',
key: 'roles',
align: 'center'
},
{
title: '上级',
key: 'referee',
align: 'center'
},
/* 搜索 */
const reload = (where?: UserParam) => {
selection.value = [];
tableRef?.value?.reload({ where });
};
{
title: '管理员',
key: 'isAdmin',
dataIndex: 'isAdmin',
sorter: true,
showSorterTooltip: false,
align: 'center'
},
{
title: '注册时间',
dataIndex: 'createTime',
sorter: true,
showSorterTooltip: false,
ellipsis: true,
customRender: ({text}) => toDateString(text, 'yyyy-MM-dd')
},
{
title: '操作',
key: 'action',
fixed: 'right',
align: 'center'
}
]);
/* 打开编辑弹窗 */
const openEdit = (row?: User) => {
current.value = row ?? null;
showEdit.value = true;
};
// 默认搜索条件
const defaultWhere = reactive({
username: '',
nickname: ''
});
/* 打开用户详情弹窗 */
const openInfo = (row?: User) => {
current.value = row ?? null;
showInfo.value = true;
};
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
where = {};
where.roleId = filters.roles;
where.keywords = searchText.value;
return pageUsers({page, limit, ...where, ...orders});
};
/* 打开编辑弹窗 */
const openImport = () => {
showImport.value = true;
};
/* 搜索 */
const reload = (where?: UserParam) => {
selection.value = [];
tableRef?.value?.reload({where});
};
const handleTabs = (e) => {
userType.value = Number(e.target.value);
reload();
};
/* 打开编辑弹窗 */
const openEdit = (row?: User) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 删除单个 */
const remove = (row: User) => {
const hide = messageLoading('请求中..', 0);
removeUser(row.userId)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
const showChild = ref(false)
const openChild = (row?: User) => {
current.value = row ?? null;
showChild.value = true;
};
/* 批量删除 */
const removeBatch = () => {
if (!selection.value.length) {
message.error('请至少选择一条数据');
return;
const showCommission = ref(false)
const openCommission = (row?: User) => {
current.value = row ?? null;
showCommission.value = true;
};
/* 打开用户详情弹窗 */
const openInfo = (row?: User) => {
current.value = row ?? null;
showInfo.value = true;
};
/* 打开编辑弹窗 */
const openImport = () => {
showImport.value = true;
};
const handleTabs = (e) => {
userType.value = Number(e.target.value);
reload();
};
/* 删除单个 */
const remove = (row: User) => {
const hide = messageLoading('请求中..', 0);
removeUser(row.userId)
.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 = messageLoading('请求中..', 0);
removeUsers(selection.value.map((d) => d.userId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
Modal.confirm({
title: '提示',
content: '确定要删除选中的用户吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = messageLoading('请求中..', 0);
removeUsers(selection.value.map((d) => d.userId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 重置用户密码 */
const resetPsw = (row: User) => {
Modal.confirm({
title: '提示',
content: '确定要重置此用户的密码吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
const password = uuid(8);
updateUserPassword(row.userId, password)
.then((msg) => {
hide();
message.success(msg + ',新密码:' + password);
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 修改用户状态 */
const updateIsAdmin = (row: User) => {
row.isAdmin = row.isAdmin ? 0 : 1;
updateUser(row)
.then((msg) => {
message.success(msg);
})
.catch((e) => {
message.error(e.message);
});
};
};
/* 重置用户密码 */
const resetPsw = (row: User) => {
Modal.confirm({
title: '提示',
content: '确定要重置此用户的密码吗?',
icon: createVNode(ExclamationCircleOutlined),
maskClosable: true,
onOk: () => {
const hide = message.loading('请求中..', 0);
const password = uuid(8);
updateUserPassword(row.userId, password)
.then((msg) => {
hide();
message.success(msg + ',新密码:' + password);
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 修改用户状态 */
const updateIsAdmin = (row: User) => {
row.isAdmin = row.isAdmin ? 0 : 1;
updateUser(row)
.then((msg) => {
message.success(msg);
})
.catch((e) => {
message.error(e.message);
});
};
/* 自定义行属性 */
const customRow = (record: User) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
/* 自定义行属性 */
const customRow = (record: User) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
</script>
<script lang="ts">
export default {
name: 'SystemUser'
};
export default {
name: 'SystemUser'
};
</script>
<style lang="less" scoped>
.user-box {
.user-box {
display: flex;
align-items: center;
.user-info {
display: flex;
align-items: center;
.user-info {
display: flex;
flex-direction: column;
align-items: start;
}
flex-direction: column;
align-items: start;
}
}
</style>