|
@@ -0,0 +1,241 @@
|
|
|
+<script lang="ts" setup>
|
|
|
+/**
|
|
|
+ * @Name: Table.vue
|
|
|
+ * @Description:
|
|
|
+ * @Author: Cheney
|
|
|
+ */
|
|
|
+
|
|
|
+import { ArrowDown, Download, Message, Money, Open, Operation, Refresh } from '@element-plus/icons-vue';
|
|
|
+import { usePagination } from '/@/utils/usePagination';
|
|
|
+import { useTableData } from '/@/utils/useTableData';
|
|
|
+import * as api from '/@/views/product-list/api';
|
|
|
+import PermissionButton from '/@/components/PermissionButton/index.vue';
|
|
|
+import { productColumns } from '/@/views/product-list/colDefine';
|
|
|
+import { useResponse } from '/@/utils/useResponse';
|
|
|
+import EditDrawer from '/@/views/product-list/component/EditDrawer.vue';
|
|
|
+import NoticeDialog from '/@/views/product-list/component/NoticeDialog.vue';
|
|
|
+import ImportButton from '/@/components/ImportButton/index.vue';
|
|
|
+import VerticalDivider from '/@/components/VerticalDivider/index.vue';
|
|
|
+import { Icon } from '@iconify/vue';
|
|
|
+
|
|
|
+
|
|
|
+const { tableOptions, handlePageChange } = usePagination(fetchList);
|
|
|
+
|
|
|
+const gridRef = ref();
|
|
|
+const gridOptions: any = reactive({
|
|
|
+ border: false,
|
|
|
+ round: true,
|
|
|
+ stripe: true,
|
|
|
+ currentRowHighLight: true,
|
|
|
+ height: 'auto',
|
|
|
+ toolbarConfig: {
|
|
|
+ custom: true,
|
|
|
+ slots: {
|
|
|
+ buttons: 'toolbar_buttons',
|
|
|
+ tools: 'toolbar_tools'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rowConfig: {
|
|
|
+ isHover: true
|
|
|
+ },
|
|
|
+ columnConfig: {
|
|
|
+ resizable: true
|
|
|
+ },
|
|
|
+ pagerConfig: {
|
|
|
+ total: tableOptions.value.total,
|
|
|
+ page: tableOptions.value.page,
|
|
|
+ limit: tableOptions.value.limit
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ loadingConfig: {
|
|
|
+ icon: 'vxe-icon-indicator roll',
|
|
|
+ text: '正在拼命加载中...'
|
|
|
+ },
|
|
|
+ columns: productColumns,
|
|
|
+ data: ''
|
|
|
+});
|
|
|
+
|
|
|
+const checkedList = ref<Set<number>>(new Set());
|
|
|
+
|
|
|
+const editOpen = ref(false);
|
|
|
+const rowData = ref({});
|
|
|
+
|
|
|
+const dialogVisible = ref(false);
|
|
|
+
|
|
|
+onBeforeMount(() => {
|
|
|
+ fetchList();
|
|
|
+});
|
|
|
+
|
|
|
+async function fetchList() {
|
|
|
+ const query = {
|
|
|
+ page: gridOptions.pagerConfig.page,
|
|
|
+ limit: gridOptions.pagerConfig.limit
|
|
|
+ };
|
|
|
+ await useTableData(api.getTableData, query, gridOptions);
|
|
|
+}
|
|
|
+
|
|
|
+function handleRefresh() {
|
|
|
+ gridOptions.pagerConfig.page = 1;
|
|
|
+ gridOptions.pagerConfig.limit = 15;
|
|
|
+ fetchList();
|
|
|
+}
|
|
|
+
|
|
|
+async function batchOpen() {
|
|
|
+ const ids = Array.from(checkedList.value);
|
|
|
+ await useResponse(api.updateShopDetail, { ids, status: 1 });
|
|
|
+ await fetchList();
|
|
|
+}
|
|
|
+
|
|
|
+function selectChangeEvent({ checked, row }: any) {
|
|
|
+ if (checked) {
|
|
|
+ checkedList.value.add(row.id); // 获取单个数据
|
|
|
+ } else {
|
|
|
+ checkedList.value.delete(row.id);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function selectAllChangeEvent({ checked }: any) {
|
|
|
+ const $grid = gridRef.value;
|
|
|
+ if ($grid) {
|
|
|
+ const records = $grid.getData(); // 获取所有数据
|
|
|
+ if (checked) {
|
|
|
+ records.forEach((item: any) => {
|
|
|
+ checkedList.value.add(item.id);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ checkedList.value.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function handleEdit(row: any) {
|
|
|
+ editOpen.value = true;
|
|
|
+ rowData.value = row;
|
|
|
+}
|
|
|
+
|
|
|
+function handleNotice(row: any) {
|
|
|
+ dialogVisible.value = true;
|
|
|
+ rowData.value = row;
|
|
|
+}
|
|
|
+
|
|
|
+const value = ref();
|
|
|
+
|
|
|
+function downloadTemplate() {
|
|
|
+ console.log('111=> ');
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="layout-screen-height">
|
|
|
+ <vxe-grid ref="gridRef" v-bind="gridOptions"
|
|
|
+ @checkbox-change="selectChangeEvent"
|
|
|
+ @checkbox-all="selectAllChangeEvent">
|
|
|
+ <template #toolbar_buttons>
|
|
|
+ <div class="flex gap-2">
|
|
|
+ <PermissionButton :icon="Open" plain round type="primary" :disabled="!checkedList.size" @click="batchOpen">
|
|
|
+ 批量开启
|
|
|
+ </PermissionButton>
|
|
|
+ <VerticalDivider class="px-1" style="margin-left: 7px;"/>
|
|
|
+ <div class="custom-el-input">
|
|
|
+ <el-select
|
|
|
+ v-model="value"
|
|
|
+ placeholder="Select"
|
|
|
+ style="width: 190px"
|
|
|
+ >
|
|
|
+ <template #prefix>
|
|
|
+ <div class="flex items-center">
|
|
|
+ <el-button link type="success" style="margin-left: 0px; font-size: 14px"
|
|
|
+ @click.stop="downloadTemplate">下载
|
|
|
+ </el-button>
|
|
|
+ <VerticalDivider />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <el-option
|
|
|
+ label="商品通知模板"
|
|
|
+ value="item1"
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="商品模板"
|
|
|
+ value="item2"
|
|
|
+ />
|
|
|
+ <el-option
|
|
|
+ label="指导价格模板"
|
|
|
+ value="item3"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <ImportButton :icon="Message" text bg>
|
|
|
+ 变更通知导入
|
|
|
+ </ImportButton>
|
|
|
+ <ImportButton text bg>
|
|
|
+ <i class="bi bi-box-seam mr-3"></i>
|
|
|
+ 商品导入
|
|
|
+ </ImportButton>
|
|
|
+ <ImportButton :icon="Money" text bg>
|
|
|
+ 指导价格导入
|
|
|
+ </ImportButton>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <!-- 工具栏右侧插槽 -->
|
|
|
+ <template #toolbar_tools>
|
|
|
+ <el-button circle class="toolbar-btn" @click="handleRefresh">
|
|
|
+ <el-icon>
|
|
|
+ <Refresh/>
|
|
|
+ </el-icon>
|
|
|
+ </el-button>
|
|
|
+ <el-button circle class="mr-3 toolbar-btn">
|
|
|
+ <el-icon>
|
|
|
+ <Download/>
|
|
|
+ </el-icon>
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ <template #top>
|
|
|
+ <div class="mb-2"></div>
|
|
|
+ </template>
|
|
|
+ <!-- 分页插槽 -->
|
|
|
+ <template #pager>
|
|
|
+ <vxe-pager
|
|
|
+ v-model:currentPage="gridOptions.pagerConfig.page"
|
|
|
+ v-model:pageSize="gridOptions.pagerConfig.limit"
|
|
|
+ :total="gridOptions.pagerConfig.total"
|
|
|
+ @page-change="handlePageChange"
|
|
|
+ >
|
|
|
+ </vxe-pager>
|
|
|
+ </template>
|
|
|
+ <!-- 表格内容插槽 -->
|
|
|
+ <template #operate="{ row }">
|
|
|
+ <div class="flex justify-between">
|
|
|
+ <PermissionButton circle plain type="warning" @click="handleEdit(row)">
|
|
|
+ <el-icon>
|
|
|
+ <Operation/>
|
|
|
+ </el-icon>
|
|
|
+ </PermissionButton>
|
|
|
+ <PermissionButton circle plain type="info" @click="handleNotice(row)">
|
|
|
+ <el-icon>
|
|
|
+ <Message/>
|
|
|
+ </el-icon>
|
|
|
+ </PermissionButton>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </vxe-grid>
|
|
|
+
|
|
|
+ <EditDrawer v-if="editOpen" v-model="editOpen" :row-data="rowData"/>
|
|
|
+ <NoticeDialog v-if="dialogVisible" v-model="dialogVisible" :row-data="rowData"/>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.toolbar-btn {
|
|
|
+ width: 34px;
|
|
|
+ height: 34px;
|
|
|
+ font-size: 18px
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.custom-el-input .el-select__wrapper) {
|
|
|
+ border-radius: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+/* .screen-height {
|
|
|
+ height: calc(100vh - 300px);
|
|
|
+} */
|
|
|
+</style>
|