<template>
  <div class="app-container">
    <!-- 仪器详情弹窗 -->
    <el-dialog :title="$t('form.detail')" :visible.sync="open" width="800px" append-to-body
      :close-on-click-modal="false">
      <el-form ref="form" :model="form" label-width="130px">
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.yq.yqmc')" prop="mc">
              <el-input v-model="form.mc" disabled :placeholder="$t('form.placeholderInput')" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.yq.yqbh')" prop="bh">
              <el-input v-model="form.bh" disabled :placeholder="$t('form.placeholderInput')" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.yq.yqxh')" prop="xh">
              <el-input v-model="form.xh" disabled :placeholder="$t('form.placeholderInput')" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.yq.yqly')" prop="ly">
              <el-input v-model="form.ly" disabled :placeholder="$t('form.placeholderInput')" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.yq.xcjzrq')" prop="jzrq">
              <el-date-picker clearable v-model="form.jzrq" type="date" value-format="yyyy-MM-dd"
                :placeholder="$t('form.placeholderSelect')" style="width: 100%;" disabled>
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.yq.ssbm')" prop="bmId">
              <el-input v-model="form.bmId" :placeholder="$t('form.placeholderSelect')" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('page.business.resource.yq.wc')" prop="wc">
              <el-input v-model="form.wc" :placeholder="$t('form.placeholderSelect')" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item :label="$t('form.remark')" prop="remark">
              <el-input v-model="form.remark" type="textarea" :placeholder="$t('form.placeholderInput')" maxlength="500"
                disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table v-loading="loading" :data="qmList">
        <el-table-column :label="$t('form.signer')" align="center" prop="qmrMc" />
        <el-table-column :label="$t('form.qmyy')" align="center" prop="jcmc" />
        <el-table-column :label="$t('form.signTime')" align="center" prop="createTime" />
        <el-table-column :label="$t('page.business.resource.yq.xgnr')" align="center">
          <template slot-scope="scope">
            <div v-for="(pitem, pindex) in scope.row.jcnrList" :key="pindex">
              {{ pitem.name }}：{{ pitem.value }}
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">{{ $t('form.cancel') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { yq_info, yqJcgj_list } from '@/api/business/yq/yq'
export default {
  name: "YqDetail",
  data() {
    return {
      loading: true,
      open: false,
      form: {},
      // 签名列表
      qmList: [],
      // 总条数
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: '',
      },
    }
  },
  created() {
  },
  methods: {
    cancel() {
      this.open = false
    },
    show(row) {
      yq_info({ id: row.id }).then((response) => {
        this.form = response.data
        this.open = true
      })
      this.queryParams.id = row.id
      yqJcgj_list(this.queryParams).then((response) => {
        this.qmList = response.rows
        this.qmList.forEach(item => {
          if(item.jcnr) {
            item.jcnrList = JSON.parse(item.jcnr)
            //item.jcnr = Object.entries(JSON.parse(item.jcnr)).map(([key, value]) => `${key}:${value}`).join('\r\n');
          } else {
            item.jcnrList = []
          }
        })
        this.total = response.total
        this.loading = false
      })
    },
    getList() {

    }
  }
}
</script>
