<template>
  <!-- 详情 -->
  <div v-show="open">
    <div class="detail-container">
      <div class="detail-top">
        <div class="left-top">
          <img src="@/assets/images/back.png" @click="cancel()" />
          <div class="left-title"></div>
        </div>
        <div class="right-top">
          <el-button @click="cancel()">{{ $t('form.cancel') }}</el-button>
        </div>
      </div>
      <div class="detail-title"><img src="@/assets/images/detail-title.png">{{ $t('page.business.resource.sj.sjxq')
        }}<img src="@/assets/images/detail-title.png" /></div>
      <div class="detail-content">
        <div class="content-left">
          <div class="content-title">
            <div class="line"></div>
            <div class="subtitle"> {{ $t('page.business.resource.sj.jbxx') }}</div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.mc') }}</div>
              <el-input type="text" :value="form.mc" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.bh') }}</div>
              <el-input type="text" :value="form.bh" maxlength="50" disabled />
            </div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.ph') }}</div>
              <el-input type="text" :value="form.ph" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.gg') }}</div>
              <el-input type="text" :value="form.gg" maxlength="50" disabled />
            </div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.nd') }}</div>
              <el-input type="text" :value="form.nd" maxlength="50" disabled> <template slot="append">{{
                form.nddw }}</template>
              </el-input>
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.kcl') }}</div>
              <el-input type="text" :value="form.kc" maxlength="50" disabled> <template slot="append">{{
                form.kcdw }}</template> </el-input>
            </div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.ly') }}</div>
              <el-input type="text" :value="form.ly" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.cctj') }}</div>
              <el-input type="text" :value="form.cctj" maxlength="50" disabled />
            </div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.ccwz') }}</div>
              <el-input type="text" :value="form.ccwz" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.yxzq') }}</div>
              <el-input type="text" :value="form.yxzq" maxlength="50" disabled />
            </div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.sxr') }}</div>
              <el-input type="text" :value="form.sxr" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.pzrq') }}</div>
              <el-input type="text" :value="form.pzrq" maxlength="50" disabled />
            </div>
          </div>
          <div class="content-title">
            <div class="line"></div>
            <div class="subtitle"> 表单信息</div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.ssbd') }}</div>
              <el-input type="text" :value="form.formName" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.bdsssy') }}</div>
              <el-input type="text" :value="form.studyName" maxlength="50" disabled />
            </div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.sj.bdssr') }}</div>
              <el-input type="text" :value="form.formUserName" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.sj.bdssbm') }}</div>
              <el-input type="text" :value="form.deptName" maxlength="50" disabled />
            </div>
          </div>
          <div class="content-title">
            <div class="line"></div>
            <div class="subtitle"> {{ $t('page.business.resource.sj.tz') }}</div>
          </div>
          <div class="pal">
            <el-table :data="tzList" v-loading="loadingTz">
              <el-table-column :label="$t('page.business.resource.sj.qmr')" align="center" prop="qmrMc"
                :show-overflow-tooltip="true" >
                <template slot-scope="scope">
                  {{ $i18n.locale === 'zh_CN' ? scope.row.qmrMc : scope.row.qmrMcEn }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('page.business.resource.sj.czlx')" align="center" prop="qmyy"
                :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  {{ $i18n.locale === 'zh_CN' ? scope.row.qmyy : scope.row.qmyyEn }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('page.business.resource.sj.czl')" align="center"
                :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  {{ scope.row.czl }}{{ scope.row.czldw }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('page.business.resource.sj.bz')" align="center" prop="remark"
                :show-overflow-tooltip="true" />
              <el-table-column :label="$t('page.business.resource.sj.czsj')" align="center" prop="createTime"
                width="150px" />
            </el-table>
          </div>
          <div class="pal">
            <pagination v-show="totalTz > 0" :total="totalTz" :page.sync="queryParamstZ.pageNum"
              :limit.sync="queryParamstZ.pageSize" @pagination="getTzList" />
          </div>
        </div>
        <div class="content-right">
          <div class="content-title">
            <div class="line"></div>
            <div class="subtitle"> {{ $t('page.business.resource.sj.jcgj') }}</div>
          </div>
          <jcgjList ref="jcgjList" @handleQuery="jcgjListHandleQuery" />

          <pagination v-show="jcgjTotal > 0" small layout="prev, pager, next" :total="jcgjTotal"
            @pagination="getJjcgjList" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { sj_info, tzList, jcgjList } from "@/api/business/sj/sj"
import JcgjList from "@/views/business/comps/common/JcgjList";

export default {
  name: "SjXq",
  components: { JcgjList },
  data() {
    return {
      form: {},
      tzList: [],
      totalTz: 0,
      loadingTz: true,
      open: false,
      queryParamstZ: {
        mjyId: null,
        pageNum: 1,
        pageSize: 10
      },
      jcgjTotal: 0,
      jcgjList: [],
      queryJcgjParams: {
        pageNum: 1,
        mjyId: null,
        pageSize: 10,
      }
    }
  },
  created() {
  },
  methods: {
    exportExcel() {
      alert('todo')
    },
    jcgjListHandleQuery(val) {
      this.$modal.loading()
      jcgjList(_.merge({}, this.queryJcgjParams, val)).then(response => {
        this.jcgjList = response.rows
        this.jcgjTotal = response.total
        this.$refs.jcgjList.init(this.jcgjList)
        this.$modal.closeLoading()
      })
    },
    getJjcgjList() {
      jcgjList(this.queryJcgjParams).then(response => {
        this.jcgjList = response.rows
        this.jcgjTotal = response.total
        this.$refs.jcgjList.init(this.jcgjList)
        this.$modal.closeLoading()
      })
    },
    cancel() {
      this.open = false
      this.$emit('callback')
    },
    getTzList() {
      this.loadingTz = true
      tzList(this.queryParamstZ).then(response => {
        this.tzList = response.rows
        this.totalTz = response.total
        this.loadingTz = false
        this.getJjcgjList()
      })
    },
    show(row) {
      this.$modal.loading()
      this.queryParamstZ.sjId = row.id
      this.queryJcgjParams.sjId = row.id
      sj_info({ id: row.id }).then(response => {
        this.form = response.data
        this.getTzList()
        this.open = true
      })
    }
  }
}
</script>
