factory.vue 5.22 KB
<template>
  <d2-container>
    <el-card shadow="never" slot="header">
      <el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">
        <el-form-item label="属性">
          <el-select v-model="formInline.belong" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option value="FA" label="工厂">工厂</el-option>
            <el-option value="WA" label="仓库">仓库</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="工厂/仓库名">
          <el-input v-model="formInline.name" placeholder="请输入工厂/仓库名" clearable/>
        </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-item>
          <el-button type="primary" icon="el-icon-plus" :loading="tableLoading" @click="editInfo()">新建</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="name" label="工厂/仓库名称" :width="tdWidth" />
        <el-table-column prop="belong" label="属性" :width="tdWidth">
          <template slot-scope="scope">{{ BELONGTYPE[scope.row.belong] }}</template>
        </el-table-column>
        <el-table-column prop="address" label="地址" :width="tdWidth" />
        <el-table-column prop="mobile" label="电话" :width="tdWidth" />
        <el-table-column prop="contacts" label="联系人" :width="tdWidth" />
        <el-table-column prop="createdBy" label="创建人" :width="tdWidth" />
        <el-table-column prop="createdDate" label="创建时间" :width="tdWidth">
          <template slot-scope="scope">{{ DATEFORMATE(scope.row.createdDate, 'YYYY-MM-DD HH:mm:ss') }}</template>
        </el-table-column>
        <el-table-column prop="updatedDate" label="更新时间" :width="tdWidth">
          <template slot-scope="scope">{{ DATEFORMATE(scope.row.updatedDate, 'YYYY-MM-DD HH:mm:ss') }}</template>
        </el-table-column>
        <el-table-column prop="操作" label="操作" :width="tdWidth" fixed="right">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="editInfo(scope.row)">修改</el-button>
          </template>
        </el-table-column>
      </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 -->

    <!-- 新增工厂/仓库弹框 开始 -->
    <edit-fac :show="showAddDialog" v-if="showAddDialog" :info="info" @closed="closeAddDialog"/>
    <!-- 新增工厂/仓库弹框 结束 -->

  </d2-container>
</template>

<script>
import {
  GETLISTWAREHOUSEINFO
} from '@/http/interface'
import EditFac from './editFac'
export default {
  name: 'fimsTable2',
  components: {
    'edit-fac': EditFac,
  },
  data() {
    return {
      formInline: {},
      tableData: [],
      tableLoading: false,
      pageTotal: 0,
      Info: {},
      currentPage: 1,
      pageSizes: [10, 20, 30, 40],
      pageSize: 10,
      tdWidth: 170,
      DATEFORMATE: (str, type) => {
        return this.$Util.dateFormate(str, type)
      },
      BELONGTYPE: {
        'FA': '工厂',
        'WA': '仓库'
      },
      showAddDialog: false,
    }
  },
  created() {

  },

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

    /**
       * 查询列表
       */
    getList: function(current) {
      const _this = this
      const oParams = _this.getParams()
      console.log(current)
      oParams.pageNum = current || _this.currentPage
      _this.tableLoading = true
      GETLISTWAREHOUSEINFO(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
      oParams.pageSize = this.pageSize
      return oParams
    },

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


    /**
     * 新增或修改工厂/仓库
     */
    editInfo: function(row){
      if(row){
        this.info = row
      }else{
        this.info = {}
      }
      this.showAddDialog = true
    },

    /**
     * 关闭新增弹出框
     */
    closeAddDialog: function(isCancel){
      this.showAddDialog = false
      if(isCancel){
        return
      }
      this.getList()
    }
  }

}
</script>

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