stock.vue 4.85 KB
<template>
  <d2-container>
    <el-card shadow="never">
      <el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">
        <el-form-item label="商户名称">
          <el-input v-model="formInline.merchantName" placeholder="请输入商户名称" />
        </el-form-item>
        <el-form-item label="物料编码/名称">
          <el-input v-model="formInline.materialCode" placeholder="请输入物料编码/名称" />
        </el-form-item>
        <el-form-item label="设备类型">
          <el-select v-model="formInline.materialDeviceTypeId" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option v-for="item in deviceTypeList" :key="item.id" :value="item.id" :label="item.name">{{ item.name }}</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="库存数量">
          <el-col :span="11">
            <el-input v-model="formInline.minStockNum" placeholder="0" />
          </el-col>
          <el-col class="line" :span="2">~</el-col>
          <el-col :span="11">
            <el-input v-model="formInline.maxStockNum" placeholder="100" />
          </el-col>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" :loading="tableLoading" @click="getList()">搜索</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 表格区域 开始 -->
    <div class="table_box">
      <el-table v-loading="tableLoading" :data="tableData" stripe style="width: 100%" size="small" border>
        <el-table-column type="index" :index="index => {return index+1}" label="序号" width="80" />
        <el-table-column prop="merchantName" label="商户名称" />
        <el-table-column prop="materialCode" label="物料编码" />
        <el-table-column prop="materialName" label="物料名称" />
        <el-table-column prop="materialDeviceTypeId" label="设备类型" />
        <el-table-column prop="statSellNum" label="出货数量" />
        <el-table-column prop="statRetnNum" label="退货数量" />
        <el-table-column prop="statSettNum" label="结算数量" />
        <el-table-column prop="statCainNum" label="调入数量" />
        <el-table-column prop="statCaouNum" label="调出数量" />
        <el-table-column prop="statStckNum" label="库存数量" />
      </el-table>
      <div class="pagination_list">
        <el-pagination
          background
          layout="sizes, total,prev, pager, next, jumper"
          :total="pageTotal"
          :page-size="pageSize"
          :page-sizes="pageSizes"
          @current-change="getList"
          @size-change="changePageSize"
        />
      </div>
    </div>
    <!-- 表格区域 end -->

  </d2-container>
</template>

<script>
import {
  GETLISTMERCHANTSTOCK,
  GETDEVICETYPE
} from '@/http/interface'
export default {
  data() {
    return {
      formInline: {},
      tableData: [],
      dialogVisible: false,
      tableLoading: false,
      pageTotal: 0,
      userInfo: {},
      currentPage: 1,
      pageSizes: [10, 20, 30, 40],
      pageSize: 10,
      registerDate: [],
      tdWidth: 170,
      DATEFORMATE: str => {
        return this.$Util.dateFormate(str)
      },
      deviceTypeList: []
    }
  },
  created() {

  },

  mounted: function() {
    this.getList()
    this.getDeviceList()
  },
  methods: {

    /**
       * 查询列表
       */
    getList: function(current) {
      const _this = this
      const oParams = _this.getParams()
      console.log(current)
      oParams.pageNum = current || _this.currentPage
      _this.tableLoading = true
      GETLISTMERCHANTSTOCK(oParams).then(res => {
        console.log(res)
        _this.tableLoading = false
        if (res.returnCode == 0) {
          const {
            data
          } = res
          const {
            total,
            list
          } = data
          _this.tableData = list || []
          _this.pageTotal = total
        }
      })
    },

    /**
       * 获取查询参数
       */
    getParams: function() {
      const oParams = this.formInline
      const m = this.registerDate
      if (m && m.length > 0) {
        n.startDate = m[0]
        n.endDate = m[1]
      } else {
        delete this.formInline.startDate
        delete this.formInline.endDate
      }
      oParams.pageSize = this.pageSize
      return oParams
    },

    /**
       * 每页展示
       */
    changePageSize: function(e) {
      this.pageSize = e
      this.getList()
    },

    /**
       * 获取设备类型列表
       */
    getDeviceList: function() {
      const _this = this
      GETDEVICETYPE().then(res => {
        const {
          data
        } = res
        _this.deviceTypeList = data || []
      })
    }

  }

}
</script>

<style lang="scss" scoped>
  .table_box {
    margin: 20px 0;
  }
  .line{
    text-align:center !important;
  }
</style>