<template>
  <div class="supplierManage">
    <div class="head-title">
      供应商管理
      <el-button @click="CommonJump('supplierEdit')" style="float:right;margin-top: -5px;margin-left:20px;" size="small" type="primary">新增供应商</el-button>
    </div>
    <div class="content">
      <div>
        <div class="searchInput" style="width:250px">
          <el-input style="display:inline-block;width:225px;height:30px"
                    placeholder="请输入规格名搜索"
                    v-model="msg.Name"
                    @keyup.enter.native="msg.pageIndex=1,getList()"
                    @clear="msg.pageIndex=1,getList()"
                    size="small"
                    clearable>
          </el-input>
          <span @click="msg.pageIndex=1,getList()" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
        </div>

      </div>
      <el-table
        :data="tableData"
        v-loading="loading"
        border
        style="width: 100%;margin:20px 0">
        <el-table-column
          prop="Name"
          width="180"
          label="供应商名称">
        </el-table-column>
        <el-table-column
          prop="Mobile"
          width="150"
          label="电话">
        </el-table-column>
        <el-table-column
          prop="Address"
          label="地址">
        </el-table-column>

        <el-table-column
          prop="OpenBankName"
          width="200"
          label="开户支行">
        </el-table-column>
        <el-table-column
          prop="AccountHolder"
          width="100"
          label="开户人">
        </el-table-column>
        <el-table-column
          prop="CardNum"
          width="250"
          label="卡号 ">
        </el-table-column>
        <el-table-column
          prop="AccountAlias"
          width="240"
          label="账户别名">
        </el-table-column>
        <el-table-column
          prop="AccountClassifyStr"
          width="160"
          label="账户分类">
        </el-table-column>



        <el-table-column
          prop="address"
          label="操作">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="编辑" placement="top">
              <img @click="CommonJump('supplierEdit',{supplierId:scope.row.ID})" style="width:32px;height:32px;margin:0 10px" src="../../assets/img/userman/edit.png" alt="">
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top">
              <img @click="Delete(scope.row)" style="width:32px;height:32px;margin:0 10px" src="../../assets/img/userman/del.png" alt="">
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align:right"
                     background
                     @current-change="handleCurrentChange"
                     :page-size="msg.pageSize"
                     layout="prev, pager, next"
                     :current-page.sync="msg.pageIndex"
                     :total="total">
      </el-pagination>
    </div>

  </div>
</template>

<script>
  export default {
    name: "supplierManage",
    data(){
      return{
        editState:false,
        msg:{
          pageIndex:1,
          pageSize:15,
          Name:'',
        },
        total:0,
        tableData:[],
        loading:false,


      }
    },
    created(){
      this.getList();

    },
    methods:{
      Delete(item){
        let that=this;
        that.$confirm('是否删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.apipost('/api/Supplier/DelDiscountCoupon',{Id:item.ID,BackId:item.BackId},
            res => {
              if (res.data.resultCode === 1) {
                this.getList();
                this.Success(res.data.message)

              } else {
                this.Error(res.data.message);
              }
            },
            null
          );
        }).catch(() => {

        });
      },


      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      getList(){
        this.loading=true;
        this.apipost("/api/Supplier/GetSupplierList ", this.msg, res => {
          this.loading=false;
          if(res.data.resultCode==1){
            this.total=res.data.data.count;
            let pageData=res.data.data.pageData;
            pageData.forEach(item=>{
              item.SortNew=item.Sort;
              item.editState=false;
            })
            this.tableData=pageData;
          }

        })
      },
    },
  };
</script>

<style>

  .supplierManage .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
  }
  .supplierManage .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px;
    line-height: 30px;
  }
  .supplierManage .content .searchInput{
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
    margin-right: 20px;
  }
  .supplierManage .content{
    background: #fff;
    margin-top:10px;
    padding: 20px;
    box-sizing: border-box;
  }
</style>
