<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input v-model="query.xingming" clearable placeholder="姓名" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <date-range-picker v-model="query.crrq" class="date-item" />
        <rrOperation />
      </div>
      <crudOperation :permission="permission" />
    </div>
    <!--表单组件-->
    <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="100%" hight="100%">
      <el-form ref="form" :model="form" :rules="rules" size="small" label-width="130px">
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-form-item label="证件类型" prop="zjlx">
                <el-input v-model="form.zjlx" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple-light">
              <el-form-item label="证件号码" prop="zjhm">
                <el-input v-model="form.zjhm" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-form-item label="状态" prop="status">
                <el-input v-model="form.status" type="textarea" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-form-item label="姓名" prop="xingming">
                <el-input v-model.number="form.xingming" style="width: 370px;" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <el-form-item label="插入日期" prop="crrq">
              <el-input v-model.number="form.crrq" style="width: 370px;" :disabled="true" />
            </el-form-item>
            <div class="grid-content bg-purple-light" />
          </el-col>
        </el-row>
        <el-divider content-position="left">返回参数</el-divider>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-form-item label="贷款中心编号" prop="DKZXBH">
                <el-input v-model="form.DKZXBH" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple-light">
              <el-form-item label="贷款中心名称" prop="DKZXMC">
                <el-input v-model="form.DKZXMC" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-form-item label="贷款状态" prop="DKZT">
                <el-input v-model="form.DKZT" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-form-item label="是否共同借款人" prop="SFGTJKR">
                <el-input v-model="form.SFGTJKR" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple-light">
              <el-form-item label="返回数据产生时间" prop="CRRQ">
                <el-input v-model="form.CRRQ" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <el-form-item label="中心账务日期" prop="ZXZWRQ">
                <el-input v-model="form.ZXZWRQ" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align: center">
        <el-button type="primary" size="medium" @click="crud.cancelCU">确认</el-button>
      </div>
    </el-dialog>
    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%" @selection-change="crud.selectionChangeHandler">
      <el-table-column v-if="checkPer(['admin','serverDeploy:edit'])" label="操作" width="150px" align="center">
        <template slot-scope="scope">
          <Retrieve
            :data="scope.row"
            :query-list="queryList"
            :permission="permission"
          />
        </template>
      </el-table-column>
      <!--            <el-table-column type="selection" width="55" />-->
      <el-table-column prop="zjlx" label="证件类型" />
      <el-table-column prop="zjhm" label="证件号码" />
      <el-table-column prop="status" label="状态" />
      <el-table-column prop="xingming" label="姓名" />
      <el-table-column prop="crrq" label="插入日期" />
    </el-table>
    <!--分页组件-->
    <pagination />
  </div>
</template>

<script>

import { testServerConnect } from '@/api/mnt/connect'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker'
import crudOperation from '@crud/CRUD.operation'
import Retrieve from '@crud/Retrieve'

const defaultForm = { id: null, name: null, ip: null, port: 22, account: 'root', password: null }
export default {
  name: 'Dkzlcx',
  components: { Retrieve, pagination, rrOperation, DateRangePicker, crudOperation },
  cruds() {
    return CRUD({ title: '贷款纵览详情', url: 'api/DkzlcxController', crudMethod: {}})
  },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  data() {
    return {
      // currView: 'index',
      queryList: {
        status: true,
        url: 'api/DkzlcxController/QueryDkzlcxFhmx'
      },
      accountList: [],
      accountMap: {},
      loading: false,
      permission: {},
      // 规则验证
      rules: {
        Demo: [
          { required: true, message: '请输入Demo', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    testConnectServer() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.loading = true
          testServerConnect(this.form).then((res) => {
            this.loading = false
            this.$notify({
              title: res ? '连接成功' : '连接失败',
              type: res ? 'success' : 'error',
              duration: 2500
            })
          }).catch(() => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
  text-align: left;
}
</style>
