<template> 
 | 
    <TableLayout :permissions="['business:company:query']"> 
 | 
        <!-- 搜索表单 --> 
 | 
        <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> 
 | 
            <el-form-item label="企业名称" prop="name"> 
 | 
                <el-input v-model="searchForm.name" placeholder="请输入企业名称" @keypress.enter.native="search"></el-input> 
 | 
            </el-form-item> 
 | 
            <el-form-item label="所属理赔员" prop="username"> 
 | 
                <el-input v-model="searchForm.username" placeholder="请输入所属理赔员" @keypress.enter.native="search"></el-input> 
 | 
            </el-form-item> 
 | 
            <section> 
 | 
                <el-button type="primary" @click="search">搜索</el-button> 
 | 
                <el-button @click="reset">重置</el-button> 
 | 
            </section> 
 | 
        </el-form> 
 | 
        <!-- 表格和分页 --> 
 | 
        <template v-slot:table-wrap> 
 | 
            <ul class="toolbar" v-permissions="['business:company:create']"> 
 | 
                <li><el-button type="primary" @click="$refs.operaCompanyWindow.open('新建企业')" v-permissions="['business:company:create']">新建企业</el-button></li> 
 | 
            </ul> 
 | 
            <el-table 
 | 
                v-loading="isWorking.search" 
 | 
                :data="tableData.list" 
 | 
                stripe 
 | 
            > 
 | 
                <el-table-column prop="username" label="登录账号" min-width="150px" fixed  align="center"></el-table-column> 
 | 
                <el-table-column prop="name" label="企业名称" min-width="150px" fixed  align="center"></el-table-column> 
 | 
                <el-table-column prop="code" label="统一信用代码" min-width="150px" fixed     align="center"></el-table-column> 
 | 
              <el-table-column prop="phone" label="绑定手机号" min-width="100px" fixed     align="center"></el-table-column> 
 | 
              <el-table-column label="启用状态" min-width="60px"> 
 | 
                <template slot-scope="{row}"> 
 | 
                  <el-switch 
 | 
                          @change="changeStatus($event, row)" 
 | 
                          v-model="row.status" 
 | 
                          active-color="#13ce66" 
 | 
                          inactive-color="#ff4949" 
 | 
                          :active-value="0" 
 | 
                          :inactive-value="1"> 
 | 
                  </el-switch> 
 | 
                </template> 
 | 
              </el-table-column> 
 | 
              <el-table-column label="电子签状态" min-width="80px" 
 | 
                               align="center"> 
 | 
                <template slot-scope="{row}"> 
 | 
                  <span v-if="row.signStatus === 0">待认证</span> 
 | 
                  <span v-if="row.signStatus === 1">认证中</span> 
 | 
                  <span v-if="row.signStatus === 2">认证失败</span> 
 | 
                  <span v-if="row.signStatus === 3">认证通过</span> 
 | 
                </template> 
 | 
              </el-table-column> 
 | 
              <el-table-column prop="createDate" label="添加时间" min-width="120px"    align="center"></el-table-column> 
 | 
              <el-table-column 
 | 
                    v-if="containPermissions(['business:company:update', 'business:company:delete'])" 
 | 
                    label="操作" 
 | 
                    min-width="120" 
 | 
                    align="center" 
 | 
                    fixed="right" 
 | 
                > 
 | 
                    <template slot-scope="{row}"> 
 | 
                        <el-button type="text" @click="$refs.OperaCompanyDescWindow.open('企业详情', row)"  v-permissions="['business:company:update']">查看详情</el-button> 
 | 
                        <el-button type="text" @click="edit(row)" v-permissions="['business:company:update']">修改</el-button> 
 | 
                      <!--                     <el-button type="text" @click="$refs.OperaCompanyRoleWindow.open('企业角色管理-'+row.name, row)"  v-permissions="['business:company:update']">角色管理</el-button> 
 | 
                                           <el-button type="text"  @click="$refs.OperaCompanyUserWindow.open('企业账号管理-'+row.name, row)" v-permissions="['business:company:update']">账号管理</el-button> 
 | 
  
 | 
                                           <el-button type="text" @click="$refs.operaCompanyWindow.open('编辑企业信息表', row)" v-permissions="['business:company:update']">电子签认证</el-button> 
 | 
                   --> 
 | 
                    </template> 
 | 
                </el-table-column> 
 | 
            </el-table> 
 | 
            <pagination 
 | 
                @size-change="handleSizeChange" 
 | 
                @current-change="handlePageChange" 
 | 
                :pagination="tableData.pagination" 
 | 
            > 
 | 
            </pagination> 
 | 
        </template> 
 | 
        <!-- 新建/修改 --> 
 | 
        <OperaCompanyWindow ref="operaCompanyWindow" @success="handlePageChange" /> 
 | 
        <!-- 详情 --> 
 | 
        <OperaCompanyDescWindow ref="OperaCompanyDescWindow" @success="handlePageChange" /> 
 | 
        <OperaCompanyUserWindow ref="OperaCompanyUserWindow" /> 
 | 
        <OperaCompanyRoleWindow ref="OperaCompanyRoleWindow"  /> 
 | 
    </TableLayout> 
 | 
</template> 
 | 
  
 | 
<script> 
 | 
import BaseTable from '@/components/base/BaseTable' 
 | 
import TableLayout from '@/layouts/TableLayout' 
 | 
import Pagination from '@/components/common/Pagination' 
 | 
import OperaCompanyWindow from '@/components/business/OperaCompanyWindow' 
 | 
import OperaCompanyRoleWindow from '@/components/business/OperaCompanyRoleWindow' 
 | 
import OperaCompanyUserWindow from '@/components/business/OperaCompanyUserWindow' 
 | 
import OperaCompanyDescWindow from '@/components/business/OperaCompanyDescWindow' 
 | 
import { updateStatus, getById } from '@/api/business/company' 
 | 
export default { 
 | 
  name: 'Company', 
 | 
  extends: BaseTable, 
 | 
  components: { TableLayout, Pagination, OperaCompanyWindow,OperaCompanyRoleWindow, OperaCompanyUserWindow,OperaCompanyDescWindow }, 
 | 
  data () { 
 | 
    return { 
 | 
      // 搜索 
 | 
      searchForm: { 
 | 
        name: '', 
 | 
        username: '', 
 | 
        type: 0 
 | 
      } 
 | 
    } 
 | 
  }, 
 | 
  created () { 
 | 
    this.config({ 
 | 
      module: '企业信息表', 
 | 
      api: '/business/company', 
 | 
      'field.id': 'id', 
 | 
      'field.main': 'id' 
 | 
    }) 
 | 
    this.search() 
 | 
  }, 
 | 
  methods: { 
 | 
    edit (row) { 
 | 
      getById(row.id) 
 | 
        .then(res => { 
 | 
          const form = res 
 | 
          form.type = 1 
 | 
          form.file = { 
 | 
            imgurl: '', 
 | 
            imgurlfull: '' 
 | 
          } 
 | 
          form.file1 = { 
 | 
            imgurl: '', 
 | 
            imgurlfull: '' 
 | 
          } 
 | 
          form.file2 = { 
 | 
            imgurl: '', 
 | 
            imgurlfull: '' 
 | 
          } 
 | 
          form.file3 = { 
 | 
            imgurl: '', 
 | 
            imgurlfull: '' 
 | 
          } 
 | 
          form.file.imgurl = res.businessImg ? res.businessImg.fileurl : null 
 | 
          form.file.imgurlfull = res.businessImg ? res.businessImg.fileurlFull : null 
 | 
          if (res.idcardImgList == null) { 
 | 
            res.idcardImgList = new Array() 
 | 
          } 
 | 
          if (res.idcardImgList && res.idcardImgList.length > 0) { 
 | 
            form.file1.imgurl = res.idcardImgList[0].fileurl 
 | 
            form.file1.imgurlfull = res.idcardImgList[0].fileurlFull 
 | 
          } 
 | 
          if (res.idcardImgList && res.idcardImgList.length > 1) { 
 | 
            form.file2.imgurl = res.idcardImgList[1].fileurl 
 | 
            form.file2.imgurlfull = res.idcardImgList[1].fileurlFull 
 | 
          } 
 | 
          form.file3.imgurl = res.signImg ? res.signImg.fileurl : null 
 | 
          form.file3.imgurlfull = res.signImg ? res.signImg.fileurlFull : null 
 | 
          this.$refs.operaCompanyWindow.open('编辑企业', form) 
 | 
        }) 
 | 
    }, 
 | 
    // 修改状态 
 | 
    changeStatus (status, row) { 
 | 
      updateStatus({ id: row.id, status }) 
 | 
        .then(res => { 
 | 
          this.search() 
 | 
        }) 
 | 
        .catch(err => { 
 | 
          row.status = row.status === 0 ? 1 : 0 
 | 
        }) 
 | 
    } 
 | 
  } 
 | 
} 
 | 
</script> 
 |