<template>
  <div>
    <el-tabs v-model="activeName">
      <el-tab-pane label="详细信息" name="详细信息">
        <el-descriptions border>
          <el-descriptions-item label="活动名称">{{ taskList.acname }}</el-descriptions-item>
          <el-descriptions-item label="任务启动时间">
            {{ taskList.beginTime ? taskList.beginTime.substr(0, 10) : '无' }}
          </el-descriptions-item>
          <el-descriptions-item label="业务备注">{{ taskList.fromKeyword }}</el-descriptions-item>
          <el-descriptions-item label="流程名称">{{ taskList.proname }}</el-descriptions-item>
          <el-descriptions-item label="审核状态">
            <el-tag v-if="taskList.status == 1" type="success">同意</el-tag>
            <el-tag v-else-if="taskList.status == 2" type="danger">驳回</el-tag>
            <el-tag v-else-if="taskList.status == 3" type="info">退回</el-tag>
            <el-tag v-else-if="taskList.status == 0">待审核</el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="审核意见">{{ taskList.comments ? taskList.comments : '无' }}</el-descriptions-item>
        </el-descriptions>

        <el-form ref="form" :model="taskList" label-width="80px" style="margin-top: 20px">
          <el-form-item label="标题" prop="title">{{ taskList.formobj.title }}</el-form-item>
<!--          <el-form-item label="图片" prop="fileUrl" disabled>-->
<!--            <el-upload-->
<!--              action="#"-->
<!--              list-type="picture-card"-->
<!--              :limit="1"-->
<!--              :auto-upload="false"-->
<!--              :file-list="fileList"-->
<!--              :disabled="true"-->
<!--            >-->
<!--              <i slot="default" class="el-icon-plus"></i>-->
<!--              <div slot="file" slot-scope="{ file }">-->
<!--                <img class="el-upload-list__item-thumbnail" :src="file.url" />-->

<!--                &lt;!&ndash; 放大预览 &ndash;&gt;-->
<!--                <span class="el-upload-list__item-actions">-->
<!--                  <span-->
<!--                    class="el-upload-list__item-preview"-->
<!--                    @click="handlePictureCardPreview(file)"-->
<!--                  >-->
<!--                    <i class="el-icon-zoom-in"></i>-->
<!--                  </span>-->
<!--                </span>-->
<!--              </div>-->
<!--            </el-upload>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="新闻内容" prop="content">-->
<!--            <editor v-model="taskList.formobj.content" :min-height="192" :readOnly="true" />-->
<!--          </el-form-item>-->
          <el-form-item label="内容" prop="content">
            <editor v-model="taskList.formobj.content"/>
          </el-form-item>
        </el-form>

        <el-dialog :visible="BigImgVisible" fullscreen append-to-body @close="BigImgVisible = false">
          <img width="100%" :src="taskList.formobj.fileUrl" alt="" />
        </el-dialog>
      </el-tab-pane>
      <el-tab-pane label="审批记录" name="审批记录">
        <el-timeline>
          <el-timeline-item v-for="(item, index) in taskList.taskHisAction" :timestamp="item.createTime" placement="top" :key="index + 'taskHisAction'">
            <el-card>
              <p>{{ item.execId }} {{ item.acname }} 于 {{ item.createTime }}</p>
            </el-card>
          </el-timeline-item>
        </el-timeline>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  data() {
    return {
      baseURL: process.env.VUE_APP_BASE_API,
      activeName: '详细信息',
      fileList: [],
      BigImgVisible: false
    };
  },
  props: ['taskList'],
  created() {
    if (this.taskList.formobj.fileUrl) {
      this.fileList.push({
        url: this.baseURL + this.taskList.formobj.fileUrl,
        name: "xxx",
      });
    }
  },
  watch: {
    taskList(curVal, oldVal) {
      if (curVal) {
        curVal.formobj.content = curVal.formobj.content.replace(new RegExp('/profile/upload/', 'g'), this.baseUrl + '/profile/upload/');
        this.fileList.pop();
        this.fileList.push({
          url: this.baseUrl + curVal.formobj.fileUrl,
          name: "xxx",
        });
      }
    },
  },
  methods: {
    handlePictureCardPreview(file) {
      this.taskList.formobj.fileUrl = file.url;
      this.BigImgVisible = true;
    }
  }
};
</script>

<style></style>
