<template>
  <div id="window-judge" style="background:#F2F3F6;min-height:95vh;">
    <el-container>
      <el-main style="background:#ffffff;height:auto; width:94%;margin:3%; font-size:14px;border-radius:8px;">
        <el-form label-position="left" label-width="100px" :model="formLabelAlign">
          <el-form-item label="用例优先级：">
            {{ formLabelAlign.casePriorityName }}
          </el-form-item>
          <el-form-item label="API：">
            {{ formLabelAlign.api }}
          </el-form-item>
          <el-form-item label="前置条件:">
            {{ formLabelAlign.caseCondition }}
          </el-form-item>
          <el-form-item label="预期结果:">
            {{ formLabelAlign.expectedResult }}
          </el-form-item>
          <el-form-item label="附件:" />
          <el-table :data="uptataKey" fit border style="width: 70%; margin: 0% 0 2% 0;">
            <el-table-column label="文件名" min-width="150">
              <template slot-scope="scope">{{ scope.row.name }}</template>
            </el-table-column>
            <el-table-column label="URL" min-width="300">
              <template slot-scope="scope"><a :href="scope.row.url" style="color:blue;">{{ scope.row.url }}</a></template>
            </el-table-column>
          </el-table>
          <el-form-item label="备注:">
            {{ formLabelAlign.remark }}
          </el-form-item>
          <el-form-item label="创建人:">
            {{ formLabelAlign.creator }}
          </el-form-item>
          <el-form-item label="操作人:">
            {{ formLabelAlign.modifier }}
          </el-form-item>
          <el-form-item label="创建时间:">
            {{ formLabelAlign.createTime }}
          </el-form-item>
          <el-form-item label="修改时间:">
            {{ formLabelAlign.modifyTime }}
          </el-form-item>
        </el-form>
        <div align="center" style="margin: 5% 0;">
          <el-button @click="$router.go(-1)">返 回</el-button>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import { queryCase } from '@/api/caseProject.js'
export default {
  data() {
    return {
      formLabelAlign: {},
      caseFolderId: '',
      id: '',
      uptataKey: [],
      url: ''
    }
  },
  created() {
    this.initCode()
  },

  methods: {
    initCode() {
      this.url = window.location.href // 获取url中"?"符后的字串
      this.caseFolderId = this.url.split('&caseFolderId=')
      this.id = this.caseFolderId[0].split('?id=')
      queryCase({ id: this.id[1], caseFolderId: this.caseFolderId[1] }).then(res => {
        for (var el of res.data.list) {
          el.id === Number(this.id[1]) ? this.formLabelAlign = el : ''
          console.log(this.formLabelAlign)
          var obj = JSON.parse(this.formLabelAlign.accessory.split('{}')[0])
          for (var a of obj) {
            this.uptataKey.push(a)
          }
          break
        }
      })
    }
  }
}
</script>

<style>
</style>
