|
|
@@ -0,0 +1,264 @@
|
|
|
+<template>
|
|
|
+ <div class="app-list-content">
|
|
|
+ <x-crud class="liu-crud-wrap" @load="onLoad">
|
|
|
+ <template #slot-tabs>
|
|
|
+ <el-tabs class="liu-tabs" type="border-card" v-model="tabIndex">
|
|
|
+ <el-tab-pane v-for="(item, index) in tabsData" :key="index" :label="item.text" :name="item.key" >
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ </template>
|
|
|
+ <template #table-column-cover="{ scope }">
|
|
|
+ <cl-avatar shape="square" :size="36" :src="scope.row.cover" :style="{ margin: 'auto' }" >
|
|
|
+ </cl-avatar>
|
|
|
+ </template>
|
|
|
+ <template #table-column-goodsName="{ scope }">
|
|
|
+ <span>{{ scope.row.goodsName }}</span>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #table-column-unit="{scope}">
|
|
|
+ <span v-if="scope.row.ratioType == 0">{{ scope.row.ratio }}{{scope.row.smallUnit}}/{{ scope.row.bigUnit }}</span>
|
|
|
+ <span v-else>若干{{scope.row.smallUnit}}/{{ scope.row.bigUnit }}</span>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #table-column-inTurn="{ scope }">
|
|
|
+ <span v-if="!sort.status">{{ scope.row.inTurn }}</span>
|
|
|
+ <el-input ref="sort-input" focus size="mini" v-else v-model="scope.row.inTurn" @blur="changeSort(scope.row)" ></el-input>
|
|
|
+ </template>
|
|
|
+ <!-- 排序 -->
|
|
|
+ <template #table-header-inTurn>
|
|
|
+ <div class="set-sort">
|
|
|
+ <span>排序</span>
|
|
|
+ <el-button v-if="!sort.status" icon="el-icon-edit-outline" size="small" type="text" @click="showSort" class="show" >
|
|
|
+ </el-button>
|
|
|
+ <el-button class="hide" v-else size="mini" @click="hideSort" type="primary" >完成</el-button >
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #slot-cp-classStyle="{scope}">
|
|
|
+ <el-radio-group v-model="classStyle" @change="changeClassify" style="margin-right:20px;padding-top:6px;margin-left:20px;">
|
|
|
+ <el-radio label="-1">全部</el-radio>
|
|
|
+ <el-radio label="1">有归类</el-radio>
|
|
|
+ <el-radio label="0">未归类</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #slot-cp-class="{scope}">
|
|
|
+ <el-select size="mini" v-model="getCpClass" placeholder="请选分类" style="width:150px;margin-right:10px;">
|
|
|
+ <el-option v-for="item in cpClassData" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #slot-column-option="{scope}">
|
|
|
+ <template>
|
|
|
+ <el-popover placement="top" width="160" :ref="'popover-' + scope.row.id">
|
|
|
+ <p>确定要删除?</p>
|
|
|
+ <div style="text-align: right; margin: 0">
|
|
|
+ <el-button size="mini" type="text" @click="cancelDel(scope.row.id)">取消</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="confirmDel(scope.row)">确定</el-button>
|
|
|
+ </div>
|
|
|
+ <el-button type="text" size="small" slot="reference">删除</el-button>
|
|
|
+ </el-popover>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ </x-crud>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { mapGetters } from 'vuex';
|
|
|
+export default {
|
|
|
+ name: 'item_list',
|
|
|
+ components: {},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ cpClassData: [{
|
|
|
+ value: '选项1',
|
|
|
+ label: '黄金糕'
|
|
|
+ }, {
|
|
|
+ value: '选项2',
|
|
|
+ label: '双皮奶'
|
|
|
+ }, {
|
|
|
+ value: '选项3',
|
|
|
+ label: '蚵仔煎'
|
|
|
+ }, {
|
|
|
+ value: '选项4',
|
|
|
+ label: '龙须面'
|
|
|
+ }, {
|
|
|
+ value: '选项5',
|
|
|
+ label: '北京烤鸭'
|
|
|
+ }],
|
|
|
+ getCpClass: '',
|
|
|
+ app: null,
|
|
|
+ sortLink: '',
|
|
|
+ operateData: {},
|
|
|
+ tabIndex: '0',
|
|
|
+ tabsData: [
|
|
|
+ {
|
|
|
+ text: '产品列表',
|
|
|
+ key: '0',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ selects: {},
|
|
|
+ sort: {
|
|
|
+ status: false,
|
|
|
+ },
|
|
|
+ catId: '',
|
|
|
+ addDialog: false,
|
|
|
+ itemClassList: [],
|
|
|
+ unitList: [],
|
|
|
+ currentItemId: 0,
|
|
|
+ classStyle:"-1",//-1全部 1有归类 0未归类
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ methods: {
|
|
|
+ changeClassify(e){
|
|
|
+ this.classStyle = e
|
|
|
+ this.app.refresh({ classStyle:this.classStyle })
|
|
|
+ },
|
|
|
+ cancelDel(id) {
|
|
|
+ this.$refs[`popover-` + id].doClose();
|
|
|
+ },
|
|
|
+ confirmDel(item) {
|
|
|
+ this.$service.itemCatRelate.delRelate({ itemId: item.id }).then(res => {
|
|
|
+ this.$message.success('删除成功');
|
|
|
+ this.$refs[`popover-` + item.id].doClose();
|
|
|
+ this.app.refresh({ classStyle:this.classStyle })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onLoad({ ctx, app }) {
|
|
|
+ this.app = app;
|
|
|
+ if (this.$route.query.catId) {
|
|
|
+ this.catId = this.$route.query.catId;
|
|
|
+ if (this.$route.query.name != '') {
|
|
|
+ this.tabsData[0].text = this.$route.query.tabName;
|
|
|
+ this.$forceUpdate();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ctx.service(this.$service.cp)
|
|
|
+ .set('table', {
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ prop: 'id',
|
|
|
+ label: 'ID',
|
|
|
+ align: 'center',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'cover',
|
|
|
+ label: '封面',
|
|
|
+ align: 'center',
|
|
|
+ 'min-width': 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'name',
|
|
|
+ label: '名称',
|
|
|
+ align: 'center',
|
|
|
+ 'min-width': 180,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'maxPrice',
|
|
|
+ label: '最大价',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'miniPrice',
|
|
|
+ label: '最小价',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'auth',
|
|
|
+ label: '认证',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'inTurn',
|
|
|
+ label: '排序',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'addTime',
|
|
|
+ label: '创建时间',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 180,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ op: {
|
|
|
+ visible: true,
|
|
|
+ props: {
|
|
|
+ width: 250,
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'right',
|
|
|
+ label: '操作',
|
|
|
+ },
|
|
|
+ layout: ['slot-column-option'],
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .set('pagination', {
|
|
|
+ size: 50
|
|
|
+ })
|
|
|
+ .set('dict', {
|
|
|
+ search: {
|
|
|
+ keyWord: 'name'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .set('search', {
|
|
|
+ key: { placeholder: '产品名称' }
|
|
|
+ })
|
|
|
+ .set('layout', [
|
|
|
+ ['slot-tabs'],
|
|
|
+ ['slot-cp-classStyle','slot-cp-class','search-key', 'flex1','refresh-btn'],
|
|
|
+ ['data-table'],
|
|
|
+ ['flex1', 'pagination'],
|
|
|
+ ])
|
|
|
+ .done();
|
|
|
+ app.refresh({ classStyle:this.classStyle })
|
|
|
+ },
|
|
|
+ exeRefresh(params) {
|
|
|
+ this.app.refresh(params);
|
|
|
+ },
|
|
|
+ showSort(e) {
|
|
|
+ this.sort.status = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ hideSort(e) {
|
|
|
+ this.sort.status = false;
|
|
|
+ },
|
|
|
+ changeSort(d) {
|
|
|
+ this.$service.goods .sort({ inTurn: d.inTurn, id: d.id, })
|
|
|
+ .then(() => {
|
|
|
+ this.$message.success('修改成功')
|
|
|
+ this.exeRefresh({classStyle:this.classStyle})
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.$message.error(err)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.short-link {
|
|
|
+ color: $mainColor;
|
|
|
+ margin-left: 10px;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+.set-sort {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ .el-button {
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+ .show {
|
|
|
+ font-size: 16px;
|
|
|
+ }
|
|
|
+ .hide {
|
|
|
+ padding: 2px 5px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|