<template>
  <div class="detail-block">
    <el-form :model="form" label-width="auto">
          <baseTitle title="需求征集详情"></baseTitle>
          <div class="left-info">
            <el-row>
              <el-col :span="12">
                <el-form-item label="名称">
                  <span>{{ formData.requirementName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="名称">
                  <span>{{ formData.requirementName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="名称">
                  <span>{{ formData.requirementName }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="截止时间">
                  <span>{{ formData.deadline }}</span>
                </el-form-item>
              </el-col>
              <baseTitle title="征集说明"></baseTitle>
              <el-col :span="24">
                <el-form-item>
                  <el-card style="width: 100%">
                    <div v-html="formData.collectExplain">
                    </div>
                  </el-card>
                </el-form-item>
              </el-col>
              <baseTitle title="申请文件"></baseTitle>
              <el-col :span="24">
                <el-form-item>
                  <fvTable ref="tableIns" style="max-height: 200px;width: 100%" :tableConfig="tableConfig"
                           @headBtnClick="headBtnClick"
                           :pagination="false"></fvTable>
                </el-form-item>
              </el-col>
              <baseTitle title="审核意见"></baseTitle>
              <el-col :span="24">
                <el-form-item>
                  <el-input
                      v-model="auditOpinion"
                      :rows="3"
                      type="textarea"
                      placeholder="请输入审核意见"
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
<!--        </el-col>-->
<!--        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="10">-->
          <div class="approval-record">
            <baseTitle title="审批记录"></baseTitle>
            <div class="process" id="approvalRecord">
              <process-diagram-viewer v-if="processDiagramViewer"/>
            </div>
          </div>
<!--        </el-col>-->
<!--      </el-row>-->
    </el-form>
    <div class="oper-page-btn">
      <el-button @click="handleSubmit">驳回</el-button>
      <el-button color="#DED0B2" @click="handleBack">同意</el-button>
    </div>
  </div>
</template>

<script setup lang="jsx">
import {getInitiateInfo} from "@/api/workflow/process-definition.js";
import ProcessTree from '@/views/workflow/process/ProcessTree.vue';
import ProcessDiagramViewer from '@/views/workflow/common/ProcessDiagramViewer.vue'
import {useProcessStore} from '@/stores/processStore.js';
import {getInfo} from "@/api/project-demand/index.js";
import {ElMessage} from "element-plus";

const form = ref();
const processStore = useProcessStore()
const processInstanceData = ref()
const processDiagramViewer = ref(false)

const processTree = ref()
const formData = ref({})
const auditOpinion = ref('')
const tableConfig = reactive({
  columns: [
    {
      prop: 'roleName',
      label: '文件名',
      align: 'center'
    },
    {
      prop: 'roleKey',
      label: '标签',
      align: 'center'
    },
    {
      prop: 'oper',
      label: '操作',
      align: 'center',
      width: '200px',
      showOverflowTooltip: false,
      currentRender: ({row, index}) => {
        return (
            <div>
              <el-button type="primary" link onClick={() => handleDownload(row)}>下载
              </el-button>
            </div>
        )
      }
    }
  ],
  api: ''
})
const getTree = async () => {
  getInfo(10).then(res => {
    let data = res.data
    formData.value = data.formData;
    processInstanceData.value = data
    processStore.setDesign(data)
    processStore.runningList.value = data.runningList;
    processStore.endList.value = data.endList;
    processStore.noTakeList.value = data.noTakeList;
    processStore.refuseList.value = data.refuseList;
    processStore.passList.value = data.passList;
    nextTick(()=>{
      processDiagramViewer.value=true
    })
  })
}
getTree()
</script>

<style lang="scss" scoped>
.detail-block {
  display: flex;
  justify-content: space-between;
  overflow-x: hidden;
  overflow-y: auto;

  .left-info {
    flex: 0.6;

    .info {
      display: flex;
      flex-wrap: wrap;

      > div {
        width: 350px;
        margin-bottom: 15px;
        margin-right: 10px;

        > span:first-child {
          color: black;
          font-size: 16px;
          font-weight: bold;
        }
      }
    }
  }

  .approval-record {
    flex: 0.4;


    .process {
      //max-height: calc(100vh - 96px);
      height: calc(100vh - 250px);
      overflow: auto;

      &::-webkit-scrollbar {
        width: 6px;
        height: 6px;
      }

      // 滚动条轨道
      &::-webkit-scrollbar-track {
        background: rgb(239, 239, 239);
        border-radius: 2px;
      }

      // 小滑块
      &::-webkit-scrollbar-thumb {
        background: rgba(80, 81, 82, 0.29);
        border-radius: 10px;
      }
    }


  }
}

</style>
