| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <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">
- <el-tab-pane label="全部"></el-tab-pane>
- <el-tab-pane label="上架"></el-tab-pane>
- <el-tab-pane label="下架"></el-tab-pane>
- </el-tabs>
- </template>
- <template #table-column-avatarUrl="{scope}">
- <div>
- <img :src="scope.row.imgList" alt />
- </div>
- </template>
- <template #table-column-goodsName="{scope}">
- <span>{{ scope.row.goodsName }}</span>
- <!-- <span>二维码</span> -->
- <span @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>
- <!-- 修改 -->
- <template #slot-modify="{scope}">
- <el-button type="text">修改</el-button>
- </template>
- <!-- 下架 -->
- <template #slot-takeOff="{scope}">
- <el-button type="text" @click="downFn(scope.row)">下架</el-button>
- </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 {
- dialogFormVisible: false,
- sortLink: ''
- };
- },
- methods: {
- // 打开链接
- openLinkFn(link) {
- this.sortLink = link || '';
- this.dialogFormVisible = true;
- },
- // 添加商品
- addFn() {
- this.$router.push('/goods/add');
- },
- downFn(item) {
- this.$confirm('是否下架该商品?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- this.$service.goods
- .changeStatus({
- id: item.id,
- status: item.status == 0 ? 1 : 0
- })
- .then(res => {
- item.status = item.status == 0 ? 1 : 0;
- this.$message.success('操作成功!');
- });
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- },
- // cl-crud 组件
- onLoad({ ctx, 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: 'mobile',
- label: '顺序',
- align: 'center'
- },
- {
- prop: 'price',
- label: '价格',
- align: 'center',
- emptyText: '无',
- 'min-width': 150
- },
- {
- prop: 'actualSold',
- label: '销量',
- align: 'center'
- },
- {
- prop: 'viewNum',
- label: '浏览量',
- align: 'center'
- },
- {
- prop: 'status',
- label: '状态',
- align: 'center'
- },
- {
- prop: 'createDate',
- label: '创建时间',
- align: 'center'
- }
- ],
- // 操作列
- op: {
- visible: true, // 是否显示
- // 同 element-ui Table-column Attributes
- props: {
- width: 150,
- align: 'center',
- fixed: 'right',
- label: '操作'
- },
- // 布局,请移步 `layout`
- layout: ['slot-modify', 'slot-takeOff']
- }
- })
- .set('layout', [
- ['slot-tabs'],
- ['search-key', 'flex1', 'refresh-btn', 'slot-add-goods-btn'],
- ['data-table'],
- ['flex1', 'pagination']
- ])
- .done();
- app.refresh({ status: 0 });
- }
- }
- };
- </script>
|