|
|
@@ -0,0 +1,199 @@
|
|
|
+<template>
|
|
|
+ <div class="app-list-content">
|
|
|
+ <cl-crud class="liu-crud-wrap" @load="onLoad">
|
|
|
+ <template #slot-tabs="{ scope }">
|
|
|
+ <el-tabs
|
|
|
+ class="liu-tabs"
|
|
|
+ type="border-card"
|
|
|
+ v-model="tabIndex"
|
|
|
+ @tab-click="handleClick"
|
|
|
+ >
|
|
|
+ <el-tab-pane
|
|
|
+ v-for="(item, index) in tabsData"
|
|
|
+ :key="index"
|
|
|
+ :label="`${item.text}(${item.val})`"
|
|
|
+ :name="item.key"
|
|
|
+ >
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #table-column-avatarUrl="{scope}">
|
|
|
+ <cl-avatar
|
|
|
+ shape="square"
|
|
|
+ :size="40"
|
|
|
+ :src="scope.row.imgList | default_avatar"
|
|
|
+ :style="{ margin: 'auto' }"
|
|
|
+ ></cl-avatar>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #table-column-goodsName="{scope}">
|
|
|
+ <span>{{ scope.row.goodsName }}</span>
|
|
|
+ <!-- <span>二维码</span> -->
|
|
|
+ <span class="short-link" @click="openLinkFn(scope.row.shortUrl)">链接</span>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 添加商品 -->
|
|
|
+ <template #slot-add-goods-btn="{scope}">
|
|
|
+ <el-button type="primary" size="mini" @click="addFn">添加</el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 状态 -->
|
|
|
+ <template #table-column-status="{scope}">
|
|
|
+ <span>{{ scope.row.status == 1 ? '上架' : '下架' }}</span>
|
|
|
+ </template>
|
|
|
+ </cl-crud>
|
|
|
+ <!-- 添加商品 -->
|
|
|
+ <el-dialog title="商品短链接:" :visible.sync="dialogFormVisible" width="40%">
|
|
|
+ <div>
|
|
|
+ <el-input v-model="sortLink" :disabled="true"></el-input>
|
|
|
+ </div>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="dialogFormVisible = false">发到手机</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ app: null,
|
|
|
+ dialogFormVisible: false,
|
|
|
+ sortLink: '',
|
|
|
+ tabIndex: '-1',
|
|
|
+ tabsData: [
|
|
|
+ {
|
|
|
+ text: '全部',
|
|
|
+ key: '-1',
|
|
|
+ val: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '上架',
|
|
|
+ key: '1',
|
|
|
+ val: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '下架',
|
|
|
+ key: '0',
|
|
|
+ val: 0
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleClick(tab, e) {
|
|
|
+ this.app.refresh({ type: this.tabIndex });
|
|
|
+ },
|
|
|
+ // 打开链接
|
|
|
+ openLinkFn(link) {
|
|
|
+ this.sortLink = link || '';
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ },
|
|
|
+ // cl-crud 组件
|
|
|
+ onLoad({ ctx, app }) {
|
|
|
+ this.app = app;
|
|
|
+ ctx.service(this.$service.goods)
|
|
|
+ .set('table', {
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ prop: 'id',
|
|
|
+ label: 'ID',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'avatarUrl',
|
|
|
+ label: '封面',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'goodsName',
|
|
|
+ label: '标题',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'price',
|
|
|
+ label: '价格',
|
|
|
+ align: 'center',
|
|
|
+ emptyText: '无',
|
|
|
+ 'min-width': 150
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'actualSold',
|
|
|
+ label: '销量',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'viewNum',
|
|
|
+ label: '浏览量',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'merchantName',
|
|
|
+ label: '商家',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'status',
|
|
|
+ label: '状态',
|
|
|
+ align: 'center'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'createDate',
|
|
|
+ label: '创建时间',
|
|
|
+ align: 'center'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ // 操作列
|
|
|
+ op: {
|
|
|
+ visible: false, // 是否显示
|
|
|
+ // 同 element-ui Table-column Attributes
|
|
|
+ props: {
|
|
|
+ width: 150,
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'right',
|
|
|
+ label: '操作'
|
|
|
+ },
|
|
|
+ // 布局,请移步 `layout`
|
|
|
+ layout: []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .set('dict', {
|
|
|
+ search: {
|
|
|
+ keyWord: 'goodsName'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .set('search', {
|
|
|
+ key: {
|
|
|
+ placeholder: '商品名称'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .set('layout', [
|
|
|
+ ['slot-tabs'],
|
|
|
+ ['flex1', 'refresh-btn'],
|
|
|
+ ['data-table'],
|
|
|
+ ['flex1', 'pagination']
|
|
|
+ ])
|
|
|
+ .on('refresh', async (params, { next }) => {
|
|
|
+ // 继续执行刷新
|
|
|
+ let { asset } = await next(params);
|
|
|
+ this.tabsData[0].val = asset.totalGoods;
|
|
|
+ this.tabsData[1].val = asset.onGoods;
|
|
|
+ this.tabsData[2].val = asset.offGoods;
|
|
|
+ })
|
|
|
+ .done();
|
|
|
+ app.refresh({ status: this.tabIndex });
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.short-link {
|
|
|
+ color: $mainColor;
|
|
|
+ margin-left: 10px;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+</style>
|