warehousList.vue 5.84 KB
<!-- 未入库 -->
<template>
  <div class="warehous-list">
    <div class="flex">
      <el-form>
        <el-form-item>
          <el-button :size="size" type="primary" class="el-icon-plus" @click="handleEdit(1)">添加商品</el-button>
          <el-button :size="size" type="primary" class="el-icon-plus" @click="handleEditGroup(1)">添加商品组</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" :model="searchForm">
        <el-form-item label="商品搜索:">
          <el-input :size="size" v-model="searchForm.name" placeholder="请输入商品名称" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
          <el-button :size="size" @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <GLTable ref="warehousListRef" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
      <span slot="coverImgUrl" slot-scope="scope">
        <img class="img-60" :src="scope.scope.coverImgUrl" />
      </span>
      <span class="table-btns" slot="auth-button" slot-scope="scope" :data="scope.scope">
        <span v-show="scope.scope.auditStatus != 1" >
          <el-button type="text" @click="handleExamine(scope.scope)">提交审核</el-button>
          <el-button type="text" @click="scope.scope.goodsGroupFlag == 'N' ? handleEdit(2, scope.scope) : handleEditGroup(2, scope.scope)">编辑</el-button>
          <el-button type="text" @click="handleDelete(scope.scope)">删除</el-button>
        </span>
        <el-button v-show="scope.scope.auditStatus == 1" type="text" @click="scope.scope.goodsGroupFlag == 'N' ? handleEdit(3, scope.scope) : handleEditGroup(3, scope.scope)">查看</el-button>
      </span>
    </GLTable>
  </div>
</template>

<script>
import { getWarehousListApi, auditGoodApi, deleteGoodApi } from '@/api/modules/cmmodityLibrary'
import { auditStatusList } from '@/common/constant'
export default {
  name: 'warehousList',
  data() {
    return {
      size: 'small',
      searchForm: {
        name: '',
        status: '-1'
      },
      // 表格组件
      getListApi: getWarehousListApi,
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // 表格参数
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '商品标题',
            prop: 'name',
            line: 2
          },
          {
            label: '直播间图片',
            prop: 'coverImgUrl',
            addHtml: 'coverImgUrl'
          },
          {
            label: '价格(元)',
            prop: 'price',
            line: 1,
            formatter: cellValue => {
              return cellValue.price2 && cellValue.price1 != cellValue.price2 ? (cellValue.price1 / 100).toFixed(2) + '-' + (cellValue.price2 / 100).toFixed(2) : (cellValue.price1 / 100).toFixed(2)
            }
          },
          {
            label: '审核状态',
            prop: 'auditStatus',
            width: '80',
            formatter: cellValue => {
              return this.baseDataList.auditStatusList.find(item => item.confId == cellValue.auditStatus).confName
            }
          },
          {
            label: '来源门店',
            prop: 'merchantName',
            line: 2
          }
        ]
      },
      baseDataList: {
        auditStatusList: auditStatusList
      }
    }
  },

  components: {},

  computed: {},

  mounted() {},

  methods: {
    beforeSearchFn() {
      return new Promise(resolve => {
        resolve()
      })
    },
    // 1-新增;2-编辑;3-查看
    handleEdit(addOrEdit, row) {
      this.$router.push({
        // name: 'editProduct',
        // path: '/cmmodityLibrary/editProduct',
        name: 'ServicesCmmodityLibraryEditProduct',
        params: {
          addOrEdit: addOrEdit,
          id: row ? row.id : -1
        }
      })
    },
    // 1-新增;2-编辑;3-查看;4-修改价格
    handleEditGroup(addOrEdit, row) {
      this.$router.push({
        // name: 'editProductGroup',
        // path: '/cmmodityLibrary/editProductGroup',
        name: 'ServicesCmmodityLibraryEditProductGroup',
        params: {
          addOrEdit: addOrEdit,
          id: row ? row.id : -1
        }
      })
    },
    handleExamine(row) {
      this.$messageBox.confirm('审核大概需要1-7天', '提交审核', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        callback: action => {
          if (action == 'confirm') {
            auditGoodApi({ id: row.id }).then(res => {
              this.$message({
                message: res.code == '0' ? '操作成功' : res.message,
                type: res.code == '0' ? 'success' : 'error'
              })
              if (res.code == '0') {
                this.handleSearch()
              }
            })
          }
        }
      })
    },
    handleDelete(row) {
      this.$messageBox.confirm('是否删除该商品?', '删除', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error',
        callback: action => {
          if (action == 'confirm') {
            deleteGoodApi({ id: row.id }).then(res => {
              this.$message({
                message: res.code == '0' ? '操作成功' : res.message,
                type: res.code == '0' ? 'success' : 'error'
              })
              if (res.code == '0') {
                this.handleSearch()
              }
            })
          }
        }
      })
    },
    handleReset() {
      this.searchForm = {
        name: '',
        status: '-1'
      }
      this.handleSearch()
    },
    handleSearch() {
      this.$refs.warehousListRef.refreshTable()
    }
  }
}
</script>
<style scoped></style>