|
@@ -1,5 +1,208 @@
|
|
|
<template>
|
|
|
- <div> 商品列表 </div>
|
|
|
+ <div class="p-4">
|
|
|
+ <BasicTable @register="registerTable">
|
|
|
+ <template #toolbar> </template>
|
|
|
+ <template #link="{ record }">
|
|
|
+ <a :href="record.link" target="_blank">{{ record.link }}</a>
|
|
|
+ </template>
|
|
|
+ <template #orderType="{ record }"> {{ renderProductTypeLabel(record.orderType) }} </template>
|
|
|
+
|
|
|
+ <template #action="{ record }">
|
|
|
+ <TableAction
|
|
|
+ :actions="[
|
|
|
+ {
|
|
|
+ icon: 'mdi:information-outline',
|
|
|
+ label: '编辑',
|
|
|
+ onClick: handleEdit.bind(null, record),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ icon: 'ant-design:delete-outlined',
|
|
|
+ color: 'error',
|
|
|
+ label: '删除',
|
|
|
+ popConfirm: {
|
|
|
+ title: '是否确认删除',
|
|
|
+ confirm: () => {
|
|
|
+ createMessage.info(`暂未接入`);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
+ <ProductDrawer @register="registerDrawer" />
|
|
|
+ </div>
|
|
|
</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { defineComponent, h } from 'vue';
|
|
|
+ import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
|
|
|
+ import { Switch } from 'ant-design-vue';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import { uploadApi } from '/@/api/sys/upload';
|
|
|
+ // import { Switch } from 'ant-design-vue';
|
|
|
+ // import { h } from 'vue';
|
|
|
+ import { ListApi } from '/@/api/product/list';
|
|
|
+ import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ // import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
|
|
|
+ import { useGo } from '/@/hooks/web/usePage';
|
|
|
+ import { useDrawer } from '/@/components/Drawer';
|
|
|
+ import ProductDrawer from './productDrawer.vue';
|
|
|
+
|
|
|
+ export default defineComponent({
|
|
|
+ components: { BasicTable, TableAction, ProductDrawer },
|
|
|
+ setup() {
|
|
|
+ const { createMessage } = useMessage();
|
|
|
+ const go = useGo();
|
|
|
+ const { t } = useI18n();
|
|
|
+ const [registerDrawer, { openDrawer }] = useDrawer();
|
|
|
+ const columns: BasicColumn[] = [
|
|
|
+ {
|
|
|
+ title: 'ID',
|
|
|
+ dataIndex: 'id',
|
|
|
+ fixed: 'left',
|
|
|
+ width: 60,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '商品名称',
|
|
|
+ dataIndex: 'name',
|
|
|
+
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '商品描述',
|
|
|
+ dataIndex: 'desc',
|
|
|
+ width: 150,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '购买链接',
|
|
|
+ dataIndex: 'link',
|
|
|
+ slots: { customRender: 'link' },
|
|
|
+ width: 150,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '商品分类',
|
|
|
+ dataIndex: 'productType',
|
|
|
+ slots: { customRender: 'productType' },
|
|
|
+ sorter: true,
|
|
|
+ width: 120,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '直播间名称',
|
|
|
+ dataIndex: 'steamRoom.name',
|
|
|
+ sorter: true,
|
|
|
+ width: 120,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '零售价格',
|
|
|
+ dataIndex: 'unit',
|
|
|
+ sorter: true,
|
|
|
+ width: 80,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '销售量',
|
|
|
+ dataIndex: 'amount',
|
|
|
+ sorter: true,
|
|
|
+ width: 80,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '市场价',
|
|
|
+ dataIndex: 'marketingUnit',
|
|
|
+ sorter: true,
|
|
|
+ width: 80,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '下单时间',
|
|
|
+ dataIndex: 'createTime',
|
|
|
+ sorter: true,
|
|
|
+ width: 140,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '上架状态',
|
|
|
+ dataIndex: 'isLaunched',
|
|
|
+ width: 180,
|
|
|
+ customRender: ({ record }) => {
|
|
|
+ if (!Reflect.has(record, 'pendingStatus')) {
|
|
|
+ record.pendingStatus = false;
|
|
|
+ }
|
|
|
+ return h(Switch, {
|
|
|
+ checked: record.isLaunched,
|
|
|
+ checkedChildren: '上架',
|
|
|
+ unCheckedChildren: '下架',
|
|
|
+ loading: false,
|
|
|
+ onChange(checked: boolean) {
|
|
|
+ record.pendingStatus = true;
|
|
|
+ const newStatus = checked ? '1' : '0';
|
|
|
+ const { createMessage } = useMessage();
|
|
|
+ createMessage.info(`暂未接入` + newStatus);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: '',
|
|
|
+ slots: { customRender: 'action' },
|
|
|
+ fixed: 'right',
|
|
|
+ width: 140,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const searchForm: Partial<FormProps> = {
|
|
|
+ labelWidth: 100,
|
|
|
+ schemas: [
|
|
|
+ {
|
|
|
+ field: 'orderNo',
|
|
|
+ label: '商品名称',
|
|
|
+ component: 'Input',
|
|
|
+ colProps: {
|
|
|
+ xl: 5,
|
|
|
+ xxl: 5,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ const [registerTable] = useTable({
|
|
|
+ title: '商品列表',
|
|
|
+ api: ListApi,
|
|
|
+ columns: columns,
|
|
|
+ useSearchForm: true,
|
|
|
+ formConfig: searchForm,
|
|
|
+ showTableSetting: true,
|
|
|
+ tableSetting: { fullScreen: true },
|
|
|
+ showIndexColumn: false,
|
|
|
+ rowKey: 'id',
|
|
|
+ pagination: { pageSize: 20 },
|
|
|
+ bordered: true,
|
|
|
+ });
|
|
|
+
|
|
|
+ function renderProductTypeLabel(type: number): string {
|
|
|
+ switch (type) {
|
|
|
+ case 0:
|
|
|
+ return '立即购买';
|
|
|
+ case 1:
|
|
|
+ return '延后购买';
|
|
|
+ default:
|
|
|
+ return '立即购买';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function handleEdit(record: Recordable) {
|
|
|
+ openDrawer(true, {
|
|
|
+ record,
|
|
|
+ isUpdate: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
-<script lang="ts" setup></script>
|
|
|
+ return {
|
|
|
+ registerTable,
|
|
|
+ createMessage,
|
|
|
+ t,
|
|
|
+ go,
|
|
|
+ renderProductTypeLabel,
|
|
|
+ registerDrawer,
|
|
|
+ handleEdit,
|
|
|
+ uploadApi: uploadApi as any,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+</script>
|