<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.casePriority }}
          </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="name" 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.creatorName }}
          </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="Return">返 回</el-button>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

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

  methods: {
    initCode() {
      this.id = this.$route.query.data.id
      this.caseFolderId = this.$route.query.data.caseFolderId
      queryCase({ id: this.id, caseFolderId: this.caseFolderId }).then(res => {
        for (var el of res.data.list) {
          el.id === this.id ? this.formLabelAlign = el : ''
          var obj = JSON.parse(this.formLabelAlign.accessory.split('{}')[0])
          for (var a of obj) {
            this.uptataKey.push(a)
          }
          console.log(this.uptataKey)
          break
        }
      })
    },

    // 返回
    Return() {
      this.$router.go(-1)
    }
  }
}
</script>

<style>
</style>
