Files
ipms-sjy-ui/src/views/mall/promotion/seckill/activity/index.vue

131 lines
3.9 KiB
Vue
Raw Normal View History

2023-06-22 17:31:36 +08:00
<template>
<!-- 搜索工作栏 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
<!-- 新增等操作按钮 -->
<template #actionMore>
<el-button
v-hasPermi="['promotion:seckill-activity:create']"
plain
type="primary"
@click="openForm('create')"
>
<Icon class="mr-5px" icon="ep:plus" /> 新增
2023-06-22 17:31:36 +08:00
</el-button>
</template>
</Search>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<Table
v-model:currentPage="tableObject.currentPage"
v-model:pageSize="tableObject.pageSize"
:columns="allSchemas.tableColumns"
:data="tableObject.tableList"
2023-06-25 17:16:26 +08:00
:expand="true"
2023-06-22 17:31:36 +08:00
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
2023-06-25 17:16:26 +08:00
@expand-change="expandChange"
2023-06-22 17:31:36 +08:00
>
2023-06-25 17:16:26 +08:00
<template #expand> 展示活动商品和商品相关属性活动配置</template>
2023-07-05 22:26:18 +08:00
<template #spuId="{ row }">
<el-image
:src="row.picUrl"
class="w-30px h-30px align-middle mr-5px"
@click="imagePreview(row.picUrl)"
/>
<span class="align-middle">{{ row.spuName }}</span>
</template>
<template #configIds="{ row }">
<el-tag v-for="(name, index) in convertSeckillConfigNames(row)" :key="index" class="mr-5px">
{{ name }}
</el-tag>
</template>
2023-06-22 17:31:36 +08:00
<template #action="{ row }">
<el-button
v-hasPermi="['promotion:seckill-activity:update']"
link
type="primary"
@click="openForm('update', row.id)"
>
编辑
</el-button>
<el-button
v-hasPermi="['promotion:seckill-activity:delete']"
link
type="danger"
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<SeckillActivityForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
2023-06-22 17:31:36 +08:00
import { allSchemas } from './seckillActivity.data'
import { getSimpleSeckillConfigList } from '@/api/mall/promotion/seckill/seckillConfig'
2023-06-22 17:31:36 +08:00
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
import SeckillActivityForm from './SeckillActivityForm.vue'
2023-07-05 22:26:18 +08:00
import { createImageViewer } from '@/components/ImageViewer'
import { sortTableColumns } from '@/hooks/web/useCrudSchemas'
2023-06-22 17:31:36 +08:00
defineOptions({ name: 'PromotionSeckillActivity' })
2023-06-22 17:31:36 +08:00
// tableObject表格的属性对象可获得分页大小、条数等属性
// tableMethods表格的操作对象可进行获得分页、删除记录等操作
// 详细可见https://doc.iocoder.cn/vue3/crud-schema/
const { tableObject, tableMethods } = useTable({
getListApi: SeckillActivityApi.getSeckillActivityPage, // 分页接口
delListApi: SeckillActivityApi.deleteSeckillActivity // 删除接口
})
// 获得表格的各种操作
const { getList, setSearchParams } = tableMethods
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = (id: number) => {
tableMethods.delList(id, false)
}
2023-07-05 22:26:18 +08:00
/** 商品图预览 */
const imagePreview = (imgUrl: string) => {
createImageViewer({
urlList: [imgUrl]
})
}
const configList = ref([]) // 时段配置精简列表
const convertSeckillConfigNames = computed(
() => (row) =>
configList.value
?.filter((item) => row.configIds.includes(item.id))
?.map((config) => config.name)
)
2023-07-02 21:46:04 +08:00
2023-06-25 17:16:26 +08:00
const expandChange = (row, expandedRows) => {
// TODO puhui等 CRUD 完事后弄
console.log(row, expandedRows)
}
2023-06-22 17:31:36 +08:00
/** 初始化 **/
onMounted(async () => {
// 获得活动列表
sortTableColumns(allSchemas.tableColumns, 'spuId')
await getList()
// 获得秒杀时间段
configList.value = await getSimpleSeckillConfigList()
2023-06-22 17:31:36 +08:00
})
</script>