stockModal.vue 3.76 KB
<template>
  <el-dialog
    id="stockModal"
    :visible="stockModalVisible"
    @open="openDialog"
    @close="handleStockClose"
    append-to-body
    width="700px"
  >
    <div
      class="dialog-header"
      slot="title"
    >
      <h2 class="header-title">
        <template>库存详情</template>
      </h2>
    </div>
    <el-form
      ref="form"
      :model="searchForm"
      inline="true"
      size="mini"
      label-width="100px"
    >
      <el-form-item
        label="设备号"
        prop="snNum"
      >
        <el-input
          v-model="searchForm.snNum"
          placeholder="请输入设备号"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          @click="handleSearch"
          size="small"
        >查询</el-button>
      </el-form-item>
    </el-form>

    <div class="ibox-content">
      <el-table
        :data="tableData"
        border
        size="small"
        v-loading="loading"
        style="width: 100%"
      >
        <el-table-column
          type="index"
          label="序号"
          :index="(index) => (this.currentPage - 1) * this.pageSize + index + 1"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="snNum"
          label="设备号"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="snTypeName"
          label="设备类型"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="remark"
          label="备注"
          align="center"
        ></el-table-column>
      </el-table>
      <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
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        type="primary"
        @click="handleStockClose"
        size="small"
        :loading="draftSubmitting"
      >确认
      </el-button>

    </div>
  </el-dialog>
</template>
<script>
import { services } from '../../api'

const STOCK_SERVICE = services.stock
export default {
  props: ['stockModalVisible', 'fixedSearchForm'],
  data() {
    return {
      searchForm: {
        snNum: ''
      },
      tableData: [],
      loading: false,
      currentPage: 1,
      pageSize: 10,
      total: 0
    }
  },
  watch: {
    stockModalVisible(newVal) {
      if (newVal) {
        this.currentPage = 1
        this.pageSize = 10
        this.searchForm = {
          snNum: ''
        }
        this.getList()
      }
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      var params = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        ...this.fixedSearchForm,
        ...this.searchForm
      }
      STOCK_SERVICE.getStockDetail(params).then(res => {
        this.tableData = res.data
        this.total = res.recordsTotal
        this.loading = false
      })
    },
    handleStockClose() {
      this.$emit('handleStockClose', false)
    },

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

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

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

    handleCurrentChange(val) {
      this.currentPage = val;
      this.getList()
    }
  }
}
</script>
<style scoped>
h3 {
  margin: 10px 0px;
}
form.order-modal-form {
  overflow: auto;
  margin: -30px -20px;
  padding: 10px 100px 20px 30px;
}
.tab-content {
  margin-top: 20px;
}
.record-list {
  padding-left: 20px;
}
</style>