<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-demo__appsysuser}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
          <el-form-item>
            <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
          </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.username" placeholder="用户名" clearable></el-input>
        </el-form-item>
          <el-form-item>
          <el-select v-model="dataForm.superUser" placeholder="是否超级用户" clearable>
            <el-option label="是" :value="1"></el-option>
            <el-option label="否" :value="0"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
<!--        <el-form-item>-->
<!--          <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>-->
<!--        </el-form-item>-->
        <el-form-item>
          <el-button v-if="$hasPermission('demo:appsysuser:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('demo:appsysuser:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="id" header-align="center" align="center"></el-table-column>
        <el-table-column prop="username" label="用户名" header-align="center" align="center"></el-table-column>
        <el-table-column prop="password" label="密码" header-align="center" align="center"></el-table-column>
        <el-table-column prop="realName" label="姓名" header-align="center" align="center"></el-table-column>
        <el-table-column prop="gender" label="性别" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.gender === 0" size="small">男</el-tag>
            <el-tag v-if="scope.row.gender === 1" size="small">女</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="email" label="邮箱" header-align="center" align="center"></el-table-column>
        <el-table-column prop="mobile" label="手机号" header-align="center" align="center"></el-table-column>
<!--        <el-table-column prop="deptId" label="部门ID" header-align="center" align="center"></el-table-column>-->
        <el-table-column prop="superUser" label="是否为超级用户" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.superUser === 0" size="small">否</el-tag>
            <el-tag v-if="scope.row.superUser === 1" size="small">是</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="defaultVerificationCode" label="默认手机验证码" header-align="center" align="center"></el-table-column>
<!--        <el-table-column prop="creator" label="创建者" header-align="center" align="center"></el-table-column>-->
        <el-table-column prop="createDate" label="创建时间" header-align="center" align="center"></el-table-column>
        
        <el-table-column prop="idCard" label="身份证" header-align="center" align="center"></el-table-column>
        <el-table-column prop="workUnit" label="工作单位" header-align="center" align="center"></el-table-column>
        <el-table-column prop="monthlyIncome" label="月收入" header-align="center" align="center"></el-table-column>
        <el-table-column prop="isSocialSecurity" label="是否缴纳社保" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isSocialSecurity === 0" size="small">否</el-tag>
            <el-tag v-if="scope.row.isSocialSecurity === 1" size="small">是</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="isHavingHouse" label="是否有房" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isHavingHouse === 0" size="small">否</el-tag>
            <el-tag v-if="scope.row.isHavingHouse === 1" size="small">是</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="isHavingCar" label="是否有车" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isHavingCar === 0" size="small">否</el-tag>
            <el-tag v-if="scope.row.isHavingCar === 1" size="small">是</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="province" label="省" header-align="center" align="center"></el-table-column>
        <el-table-column prop="city" label="市" header-align="center" align="center"></el-table-column>
        <el-table-column prop="region" label="区" header-align="center" align="center"></el-table-column>
        <el-table-column prop="addr" label="详细地址" header-align="center" align="center"></el-table-column>
        <el-table-column prop="bankCard" label="银行卡号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="belongingBank" label="所属银行" header-align="center" align="center"></el-table-column>
        <el-table-column prop="relativeName" label="亲属姓名" header-align="center" align="center"></el-table-column>
        <el-table-column prop="relativePhone" label="亲属手机号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="relativeRelation" label="亲属关系" header-align="center" align="center"></el-table-column>
        <el-table-column prop="friendName" label="朋友姓名" header-align="center" align="center"></el-table-column>
        <el-table-column prop="friendPhone" label="朋友手机号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="friendRelation" label="朋友关系" header-align="center" align="center"></el-table-column>
        <el-table-column prop="negativeUrl" label="身份证正面" header-align="center" width="700px" align="center"></el-table-column>
        <el-table-column prop="frontUrl" label="身份证反面" header-align="center" width="700px" align="center"></el-table-column>
        
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <!-- v-if="$hasPermission('sys:apploanapply:view')"-->
            <el-button v-if="$hasPermission('sys:apploanapply:view')" type="text" size="small" @click="viewAppLoanApply(scope.row.id)">申请记录</el-button>
            <el-button v-if="$hasPermission('demo:appsysuser:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('demo:appsysuser:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <loan-apply v-if="addOrUpdateVisible" ref="loanApply" @refreshDataList="getDataList"></loan-apply>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './appsysuser-add-or-update'
import LoanApply from './appsysuser-loan-apply'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/demo/appsysuser/page',
        getDataListIsPage: true,
        exportURL: '/demo/appsysuser/export',
        deleteURL: '/demo/appsysuser',
        deleteIsBatch: true
      },
      dataForm: {
        id: ''
      }
    }
  },
  methods: {
    viewAppLoanApply (id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.loanApply.dataForm.id = id
        this.$refs.loanApply.init()
      })
    }
  },
  components: {
    AddOrUpdate,
    LoanApply
  }
}
</script>
