<template>
  <!-- 详情 -->
  <div v-if="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>
          <el-button @click="exportExcel()">{{ $t('form.export') }}</el-button>
        </div>
      </div>
      <div class="detail-title"><img src="@/assets/images/detail-title.png">{{ $t('page.business.resource.mjy.mjyxq')
      }}<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.mjy.jbxx') }}</div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.mjy.mc') }}</div>
              <el-input type="text" :value="form.mc" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.mjy.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.mjy.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.mjy.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.mjy.sxrq') }}</div>
              <el-input type="text" :value="form.sxrq" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.mjy.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.mjy.ccwz') }}</div>
              <el-input type="text" :value="form.ccwz" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.mjy.zjzt') }}</div>
              <el-select v-model="form.zjzt" disabled style="width: 100%;">
                <el-option key="1" :label="$t('page.business.resource.resource.zjzt.rk')" :value="1" />
                <el-option key="3" :label="$t('page.business.resource.resource.zjzt.yff')" :value="3" />
                <el-option key="5" :label="$t('page.business.resource.resource.zjzt.ysd')" :value="5" />
                <el-option key="7" :label="$t('page.business.resource.resource.zjzt.dgd')" :value="7" />
                <el-option key="9" :label="$t('page.business.resource.resource.zjzt.gd')" :value="9" />
                <el-option key="11" :label="$t('page.business.resource.resource.zjzt.djd')" :value="11" />
              </el-select>
            </div>
          </div>
          <div class="content-title">
            <div class="line"></div>
            <div class="subtitle"> {{ $t('page.business.resource.mjy.bdxx') }}</div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.mjy.sssy') }}</div>
              <el-input type="text" :value="form.studyMc" maxlength="50" disabled />
            </div>
            <div class="right">
              <div class="right-title">{{ $t('page.business.resource.mjy.ssbd') }}</div>
              <el-input type="text" :value="form.bdMc" maxlength="50" disabled />
            </div>
          </div>
          <div class="pal">
            <div class="left">
              <div class="left-title">{{ $t('page.business.resource.mjy.bdssr') }}</div>
              <el-input type="text" :value="form.bdgsrMc" maxlength="50" disabled />
            </div>
          </div>
          <div class="content-title">
            <div class="line"></div>
            <div class="subtitle"> {{ $t('page.business.resource.mjy.tz') }}</div>
          </div>
          <div class="pal">
            <el-table :data="tzList" v-loading="loadingTz">
              <el-table-column :label="$t('page.business.resource.mjy.syr')" align="center"
                :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{ scope.row.qmrMc }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('page.business.resource.mjy.lqghr')" align="center"
                :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{ scope.row.lqrMc }}{{ scope.row.ghrMc }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('page.business.resource.mjy.ffjsr')" align="center"
                :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{ scope.row.ffrMc }}{{ scope.row.jsrMc }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('page.business.resource.mjy.czlx')" align="center"
                :prop="$i18n.locale === 'zh_CN' ? 'qmyy' : 'qmyyEn'" width="100" />
              <el-table-column :label="$t('page.business.resource.mjy.bdmc')" align="center"
                prop="bdmc" width="100" />
              <el-table-column :label="$t('page.business.resource.mjy.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.mjy.bzyy')" align="center" prop="remark"
                :show-overflow-tooltip="true" />
              <el-table-column :label="$t('page.business.resource.mjy.ccsj')" 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.mjy.jcgj') }}</div>
          </div>
          <jcgjList ref="jcgjList" @handleQuery="getJjcgjList" />

          <pagination v-show="jcgjTotal > 0" :total="jcgjTotal" @pagination="getJjcgjList" />
        </div>
      </div>
    </div>
  </div>
</template>

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

export default {
  name: "Xq",
  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: 5,
      }
    }
  },
  created() {
  },
  methods: {
    exportExcel() {
      this.$modal.loading()
      exportDetail({ id: this.form.id,lang:this.$store.getters.language.split("_")[0]  }).then(response => {
        window.open(process.env.VUE_APP_FILE_DOMAIN  +response.msg)
        this.$modal.closeLoading()
      }).finally(() => {
        this.$modal.closeLoading()
      })
    },
    getJjcgjList(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()
      }).finally(() => {
        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.mjyId = row.id
      this.queryJcgjParams.mjyId = row.id
      this.$modal.loading()
      info({ id: row.id }).then(response => {
        this.form = response.data
        this.getTzList()
        this.open = true
      }).finally(() => {
        this.$modal.closeLoading()
      })
    }
  }
}
</script>
