<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input v-model="query.qqjk" clearable placeholder="请求接口(左模糊)" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <date-range-picker v-model="query.qqsj" startPlaceholder="请求日期" 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="qqjk">
                <el-input v-model="form.qqjk" 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="qqsj">
                <el-input v-model="form.qqsj" 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="qqnr">
                <el-input v-model="form.qqnr" 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="xysj">
                <el-input v-model.number="form.xysj" style="width: 370px;" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="8">
            <el-form-item label="响应状态" prop="xyzt">
              <el-input v-model.number="form.xyzt" style="width: 370px;" :disabled="true" />
            </el-form-item>
            <div class="grid-content bg-purple-light" />
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple" />
            <el-form-item label="响应内容" prop="xynr">
              <el-input v-model="form.xynr" style="width: 370px" :disabled="true" />
            </el-form-item>
          </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="entName">
                <el-input v-model="form.entName" 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="xynr">
                <el-input v-model="form.dom" 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="name">
                <el-input v-model="form.name" 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="uniscid">
                <el-input v-model="form.uniscid" 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="estDate">
                <el-input v-model="form.estDate" 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="name">
                <el-input v-model="form.regCap" 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="opFrom">
                <el-input v-model="form.opFrom" 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="opto">
                <el-input v-model="form.opto" 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="regOrgCn">
                <el-input v-model="form.regOrgCn" style="width: 370px" :disabled="true" />
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="登记登记状态" prop="regStateCn">
              <el-input v-model="form.regStateCn" style="width: 370px" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="企业经营范围" prop="opScope">
              <el-input v-model="form.opScope" type="textarea" style="width: 370px" :disabled="true" />
            </el-form-item>
          </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:check'])" label="操作" width="150px" align="center">
        <template slot-scope="scope">
          <retrieve
            :data="scope.row"
            :queryList="queryList"
            :permission="permission"
          />
        </template>
      </el-table-column>
      <!--            <el-table-column type="selection" width="55" />-->
      <el-table-column prop="qqjk" label="请求接口" />
      <el-table-column prop="qqsj" label="请求时间" />
      <el-table-column prop="xysj" label="响应时间" />
      <el-table-column prop="xyzt" label="响应状态" />
      <el-table-column prop="xynr" 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 retrieve from '@crud/Retrieve'
import pagination from '@crud/Pagination'
import DateRangePicker from '@/components/DateRangePicker'
import crudOperation from '@crud/CRUD.operation'

const defaultForm = { id: null, name: null, ip: null, port: 22, account: 'root', password: null }
export default {
  name: 'Qyxxcx',
  components: { pagination, rrOperation, retrieve, DateRangePicker, crudOperation },
  cruds() {
    return CRUD({ title: '企业信息详情', url: 'api/QyxxcxController', crudMethod: {}})
  },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  data() {
    return {
      // currView: 'index',
      queryList:{
        status:false
      },
      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>
