<template>
  <div class="edu-training-edit">
    <DialogCom
      :title="title"
      @close="onHide"
      :visible.sync="isShow"
      width="1000px"
    >
      <div class="page-body">
        <el-descriptions
          :column="2"
          border
          size="medium"
          :label-style="labelStyle"
          :contentStyle="content_style">
          <el-descriptions-item label="当前状态">
            <dict-tag :options="dict.type.letter_status" :value="formData.status"/>
          </el-descriptions-item>
          <el-descriptions-item label="介绍信编号">{{formData.letterNo}}</el-descriptions-item>
<!--          <el-descriptions-item label="接待机构">
            {{formData.receptionOrgNames}}
          </el-descriptions-item>-->



          <el-descriptions-item label="接待机构">
            <el-tooltip class="item" effect="dark" :content='formData.receptionOrgNames' placement="top">
              <div class="ellipsis-tooltip">
                {{ formData.receptionOrgNames}}
              </div>
            </el-tooltip>
            <div v-if="formData.receptionOrgIds" class="count">
              （{{formData.receptionOrgIds.length }}）
            </div>
          </el-descriptions-item>




          <el-descriptions-item label="出入事由">{{formData.reasons}}</el-descriptions-item>
          <el-descriptions-item label="开具日期">{{formData.startTimeStr}}</el-descriptions-item>
          <el-descriptions-item label="有效天数">{{formData.effectiveDays}}</el-descriptions-item>
          <el-descriptions-item label="介绍信附件" span="2">
            <image-file-list-preview v-model="formData.letterFile"></image-file-list-preview>
          </el-descriptions-item>
          <el-descriptions-item label="备注">{{formData.description}}</el-descriptions-item>

        </el-descriptions >
<!--        <el-form-->
<!--          ref="form"-->
<!--          :model="formData"-->
<!--          label-width="120px"-->
<!--          label-suffix=":"-->
<!--        >-->
<!--          <el-row>-->
<!--            <el-col :span="24">-->
<!--              <el-form-item label="当前状态">-->
<!--                <dict-tag :options="dict.type.letter_status" :value="formData.status"/>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :span="12">-->
<!--              <el-form-item label="介绍信编号" prop="letterNo">-->
<!--                {{formData.letterNo}}-->
<!--              </el-form-item>-->
<!--            </el-col>-->


<!--            <el-col :span="12">-->
<!--              <el-form-item label="接待机构" prop="receptionOrgIds">-->
<!--                &lt;!&ndash; <org-tree-select v-model="formData.receptionOrgIds" ref="orgTreeSelect">-->
<!--                </org-tree-select> &ndash;&gt;-->
<!--                {{formData.receptionOrgNames}}-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :span="24">-->
<!--              <el-form-item prop="reasons" label="出入事由">-->
<!--                {{formData.reasons}}-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :span="12">-->
<!--              <el-form-item  label="开具日期">-->
<!--                {{ formData.startTimeStr}}-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :span="12">-->
<!--              <el-form-item  label="有效天数">-->
<!--                {{ formData.effectiveDays}}-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :span="12">-->
<!--              <el-form-item label="介绍信附件">-->
<!--                <K-file-upload-->
<!--                  ref="upload"-->
<!--                  :isShowUploadBtn="false"-->
<!--                  :defaultValue="formData.letterFile"-->
<!--                />-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :span="12">-->
<!--              <el-form-item label="备注">-->
<!--                {{formData.description}}-->
<!--              </el-form-item>-->
<!--            </el-col>-->

<!--          </el-row>-->
<!--        </el-form>-->
        <el-row :gutter="10">
          <el-col :span="12">
            <h3>
              <i class="el-icon-collection-tag"></i>
              人员信息
            </h3>
          </el-col>
        </el-row>
        <el-table border size="small" :data="formData.userInfos" max-height="500" style="margin-bottom: 10px;">
          <el-table-column label="序号"  align="center"  type="index" width="70" />
          <el-table-column label="出入单位" width="150" align="center" prop="companyName" />
          <el-table-column label="出入人员" width="100" align="center" prop="userName" />
          <el-table-column label="证件类型" width="100" align="center" prop="idType">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.letter_id_type" :value="scope.row.idType"/>
            </template>
          </el-table-column>
          <el-table-column label="证件号码" width="200" align="center" prop="idCard">
          </el-table-column>
          <el-table-column label="证件图片" align="center" prop="imgFile">
            <template slot-scope="scope">
              <ImageListPreview v-model="scope.row.imgFile"></ImageListPreview>
            </template>
          </el-table-column>
        </el-table>

        <!-- <el-row :gutter="10">
          <el-col :span="12">
            <h3 >
              <i class="el-icon-collection-tag"></i>
              审批详情
            </h3>
          </el-col>
        </el-row>
        <el-table border size="small" :data="formData.approveInfos" max-height="500" style="margin-bottom: 10px;">
          <el-table-column label="机构名称" align="center" prop="orgName" />
          <el-table-column label="审批状态" align="center" prop="approveStatus" >
            <template slot-scope="scope">
              <dict-tag :options="dict.type.out_in_approve_status" :value="scope.row.approveStatus"/>
            </template>
          </el-table-column>
          <el-table-column label="审批说明" align="center"  prop="approveRemark">
          </el-table-column>
        </el-table> -->
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="onHide">关 闭</el-button>
      </div>
    </DialogCom>
  </div>
</template>
<script>
import { mapState, mapMutations } from "vuex";
import {
  listLetter,
  getLetter,
  delLetter,
  addLetter,
  updateLetter,
} from "@/api/core/letter";
import OrgTreeSelect from "@/components/orgTreeSelect";
import KFileUpload from "@/components/K-FileUpload/index.vue";
import dayjs from "dayjs";
import imgUpload from "@/components/ImageUpload";
import imageFileListPreview from "@/components/ImageFileListPreview";
import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
export default {
  components: { OrgTreeSelect, KFileUpload, imgUpload,DataRangePicker,imageFileListPreview },
  data() {
    const params = this.$route.params;
    return {
      labelStyle: {
        color: "#000",
        "text-align": "center",
        height: "40px",
        "min-width": "150px",
        "word-break": "keep-all",
      },
      content_style: {
        "text-align": "left",
        "min-width": "300px",
        "word-break": "break-all",
      },
      id: params ? params.id : null,
      isShow: false,
      title: "录入介绍信",
      formData: this.reset(),
      open: false,
      userInfo: this.resetUserInfo(),
      imageList: [],
    };
  },
  dicts: ["letter_status","out_in_approve_status","letter_id_type"],
  props: {},
  watch: {},
  created() {},
  computed: {
    ...mapState(["loginUser", "org"]),
  },
  methods: {
    ...mapMutations([]),
    reset(other = {}) {
      return {
        reasons: null,
        letterNo:null,
        receptionOrgIds: [],
        range:[],
        description: null,
        letterFile: [],
        userInfos: [],
        type:1,
        status:null,
        ...other,
      };
    },
    resetUserInfo() {
      return {
        userName: null,
        companyName: null,
        idCard: null,
        imgFile: null,
      };
    },

    async show(id) {
        this.title = "介绍信详情";
        this.isShow = true;
        getLetter(id).then((response) => {
          let tempRange=[];
          tempRange.push(dayjs(response.data.startTime));
          tempRange.push(new Date(response.data.endTime));
          response.data.range=tempRange;
          this.formData = response.data;
        });
    },
    onHide() {
      this.isShow = false;
      this.formData = this.reset();
    },
  },
  mounted() {},
};
</script>
<style scoped>
.ellipsis-tooltip {
  display: inline-block;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  float: left;

}

.count {
  white-space: nowrap;
  margin-left: 5px;
  float: left;
}
</style>





