stockList.vue 5.81 KB
<template>
  <v-layout>
    <template slot="breadcrumb">
      <el-breadcrumb-item>库存管理</el-breadcrumb-item>
      <el-breadcrumb-item>库存信息</el-breadcrumb-item>
    </template>

    <template slot="main">
      <div class="ibox">
        <!-- 表单查询 -->
        <el-form
          :inline="true"
          ref="form"
          :model="searchForm"
        >
          <el-form-item
            v-for="(item, index) in formData"
            :key="index"
            :label="item.label"
          >
            <el-input
              v-if="item.type === 'input'"
              v-model="searchForm[item.name]"
              size="small"
              :placeholder="'请输入' + item.label"
              clearable
            ></el-input>
          </el-form-item>

          <el-form-item>
            <el-button
              type="primary"
              @click="handleSearch"
              size="small"
            >查询</el-button>
            <el-button
              @click="handleReset"
              size="small"
            >重置</el-button>
          </el-form-item>
        </el-form>
        <!-- 表单查询 /-->
      </div>
      <div class="ibox">
        <div class="ibox-title">
          <h3 class="pull-left">库存列表</h3>
        </div>
        <div class="ibox-content">
          <el-table
            :data="tableData"
            border
            size="small"
            v-loading="loading"
            style="width: 100%">
            <el-table-column
              prop="snTypeName"
              label="设备类型"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="receiverUser"
              label="收货人姓名"
              min-width="100"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="sendProvince"
              label="发往省份"
              min-width="160"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="sendCity"
              label="市"
              min-width="180"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="deviceStockCount"
              label="库存设备数量"
              min-width="100"
              align="center"
            >
              <template slot-scope="scope">
                <span v-if="!scope.row.deviceStockCount">{{scope.row.deviceStockCount}}</span>
                <el-button
                  v-else
                  type="text"
                  @click="handleOnline(1, scope.row)"
                >{{scope.row.deviceStockCount}}</el-button>
              </template></el-table-column>
            <el-table-column
              prop="deviceStockOnlineCount"
              label="在途库存数量"
              min-width="100"
              align="center"
            >
              <template slot-scope="scope">
                <span v-if="!scope.row.deviceStockOnlineCount">{{scope.row.deviceStockOnlineCount}}</span>
                <el-button
                  v-else
                  type="text"
                  @click="handleOnline(2, scope.row)"
                >{{scope.row.deviceStockOnlineCount}}</el-button>
              </template>
            </el-table-column>

          </el-table>
          <div class="table-page-wrap">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
            >
            </el-pagination>
          </div>
        </div>
      </div>

      <!-- 库存设备弹窗 -->
      <stock-modal
        :stockModalVisible="stockModalVisible"
        :fixedSearchForm="fixedSearchForm"
        @handleStockClose="handleStockClose"
      >
      </stock-modal>
      <!-- 库存设备弹窗 /-->

    </template>
  </v-layout>
</template>

<script>
import { services } from '../../api'
import stockModal from './stockModal'
const STOCK_SERVICE = services.stock
export default {
  data() {
    return {
      searchForm: {},
      tableData: [],
      loading: false,
      currentPage: 1,
      pageSize: 10,
      total: 0,
      formData: [{
        label: '设备类型',
        name: 'snTypeName',
        type: 'input'
      }, {
        label: '收货人姓名',
        name: 'receiverUser',
        type: 'input'
      }, {
        label: '发往省份',
        name: 'sendProvince',
        type: 'input'
      }, {
        label: '市',
        name: 'sendCity',
        type: 'input'
      }],
      stockModalVisible: false
    }
  },

  components: {
    stockModal
  },

  mounted() {
    this.getList()
  },

  methods: {
    getList() {
      this.loading = true
      var params = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        ...this.searchForm
      }
      STOCK_SERVICE.getStockList(params).then(res => {
        this.tableData = res.data
        this.total = res.recordsTotal
        this.loading = false
      })
    },

    handleSearch() {
      this.currentPage = 1
      this.getList()
    },

    handleReset() {
      this.searchForm = {}
    },

    handleSizeChange(val) {
      this.pageSize = val;
      this.getList()
    },

    handleCurrentChange(val) {
      this.currentPage = val;
      this.getList()
    },

    // 设备类型(stockType):1 - 库存设备;2 - 在途设备
    handleOnline(stockType = 1, row) {
      this.stockModalVisible = true
      this.fixedSearchForm = {
        stockType: stockType,
        dataSignId: row.dataSignId
      }
    },
    handleStockClose() {
      this.stockModalVisible = false
    }
  }
}
</script>

<style>
</style>