warehousingList.vue 5.15 KB
<template>
  <div>
    <div class="flex">
      <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="wareRef" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf">
      <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">
        <el-button type="text" @click="handleEdit(scope.scope)">修改价格</el-button>
        <el-button type="text" @click="handleDelete(scope.scope)">删除</el-button>
      </span>
    </GLTable>
    <!-- 表格区域 end -->

    <!-- 修改价格弹框 开始 -->
    <!-- <glsx-dialog title="修改价格" width="620px" :isVisible="showPriceDialog" @closeDialog="closePriceDialog" @confirmDialog="closePriceDialog">
      <el-form ref="priceForm" :rules="formRules" :model="form" label-width="120px">
        <el-form-item label="商品价格:" prop="price">
          <el-input v-model="form.price" maxlength="8" style="width:400px" />
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="resetPrice()">提交</el-button>
        <el-button @click="showPriceDialog = false">取消</el-button>
      </div>
    </glsx-dialog> -->
    <!-- 修改价格弹框 end -->
  </div>
</template>

<script>
import { getWarehousListApi, deleteGoodApi } from '@/api/modules/cmmodityLibrary'
// import glsxDialog from '@/components/glsx-dialog'
export default {
  // components: {
  //   glsxDialog
  // },
  data() {
    return {
      size: 'small',
      searchForm: {
        name: '',
        status: '2'
      },
      // 表格组件
      getListApi: getWarehousListApi,
      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: 'merchantName',
            line: 2
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // tableData: [
      //   {
      //     id: 1,
      //     pic: 'https://t7.baidu.com/it/u=4162611394,4275913936&fm=193&f=GIF',
      //     title: '商品标题',
      //     price: 999,
      //     merchant: 'xxx'
      //   }
      // ],
      // pageTotal: 0,
      // userInfo: {},
      // currentPage: 1,
      // pageSizes: [10, 20, 30, 40],
      // pageSize: 10,
      // tdWidth: 170,
      // DATEFORMATE: (str, type) => {
      //   return this.$Util.dateFormate(str, type)
      // }
      // showPriceDialog: false,
      // form: {},
      // formRules: {
      //   price: [{ required: true, message: '请输入价格', trigger: 'blur' }]
      // }
    }
  },
  created() {},

  mounted: function() {},
  methods: {
    handleReset() {
      this.searchForm = {
        name: '',
        status: '2'
      }
      this.handleSearch()
    },
    handleSearch() {
      this.$refs.wareRef.refreshTable()
    },

    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()
              }
            })
          }
        }
      })
    },
    // 1-新增;2-编辑;3-查看;4-修改价格
    handleEdit: function(row) {
      // this.showPriceDialog = true
      this.$router.push({
        // name: 'editProductGroup',
        // path: '/cmmodityLibrary/editProductGroup',
        name: 'ServicesCmmodityLibraryEditProductGroup',
        params: {
          addOrEdit: 4,
          id: row ? row.id : -1
        }
      })
    },

    // closePriceDialog: function() {
    //   this.showPriceDialog = false
    // }
  }
}
</script>

<style lang="scss">
.table_box {
  margin: 20px 0;
}
</style>