index.vue 3.57 KB
<!-- 物料列表 -->
<template>
  <d2-container>
    <el-form
      :inline="true"
      :model="searchForm"
      label-width="85px"
      slot="header"
    >
      <el-form-item label="物料">
        <el-input v-model="searchForm.keyWord" placeholder="请输入物料代码/编码/名称" @clear="loadingGetList" clearable></el-input>
      </el-form-item>
      <el-form-item>
          <el-button type="primary"  icon="el-icon-search" @click="handleSearch">查询</el-button>
      </el-form-item>
    </el-form>
     <el-row style="height: 40px; line-height: 40px">
        <el-col :span="12">物料列表</el-col>
    </el-row>
    <el-table
      :data="tableData"
      v-loading="tableLoading"
      border
      style="margin: 20px 0;"
    >
      <el-table-column
        align="center"
        width="60px"
        label="序号"
        type='index'
      ></el-table-column>
      <el-table-column
        v-for="(item, index) in tableColumns"
        :key="index"
        :label="item.label"
        :prop="item.prop"
        :width="item.width"
        align="center"
      >
        <!-- <template slot-scope="scope">
          <template v-if="item.formatter">
            {{item.formatter(scope.row)}}
          </template>
          <template v-else>
            {{tableData[scope.$index][item.prop]}}
          </template>
        </template> -->
      </el-table-column>
    </el-table>
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10,20,30,40]"
      :page-size="pageSize"
      :total="total"
      layout="sizes,total,->,prev,pager,next,jumper"
    >
    </el-pagination>
  </d2-container>
</template>

<script>
import { getListApi } from '@api/materialList'
import notice from '@/common/notice'
export default {
  name: 'fimsMaterialList',
  data () {
    return {
      searchForm: {
        keyWord: '',
        responsible: ''
      },
      // 表格
      tableLoading: false,
      tableData: [],
      tableColumns: [{
        label: '物料代码',
        prop: 'deviceNum'
      }, {
        label: '物料编码',
        prop: 'deviceCode'
      }, {
        label: 'CRC物料号',
        prop: 'crcCode'
      }, {
        label: '图号',
        prop: 'drawNum'
      }, {
        label: '物料名称',
        prop: 'deviceName'
      }, {
        label: '规格',
        prop: 'specifications'
      }, {
        label: '责任人',
        prop: 'responsible'
      }],
      // 页码
      currentPage: 1,
      pageSize: 10,
      total: 30
    }
  },

  mounted () {
    this.loadingGetList()
  },

  methods: {
    loadingGetList () {
      this.tableLoading = true
      this.getList()
    },
    /* 接口请求-start */
    getParams () {
      return {
        pageCount: this.pageSize,
        pageSize: this.currentPage,
        ...this.searchForm
      }
    },
    getList () {
      const params = this.getParams()
      getListApi(params).then(res => {
        this.tableData = res.deviceList
        this.total = res.pagination.totalCount
        this.tableLoading = false
      }).catch(() => {
        notice.errorTips()
        this.tableLoading = false
      })
    },
    /* 接口请求-end */
    // 搜索
    handleSearch () {
      this.loadingGetList()
    },

    // 页码
    handleSizeChange (value) {
      this.pageSize = value
      // 调接口
      this.loadingGetList()
    },

    handleCurrentChange (value) {
      this.currentPage = value
      // 调接口
      this.loadingGetList()
    }
  }
}

</script>
<style scoped>
</style>