<template>
  <el-dialog :visible.sync="dialogFormVisible" title="详细信息" append-to-body>
    <el-form ref="dataForm" :model="caseTypeForm" label-width="100px">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="类型名称" prop="typeDetailName">
            <el-input v-model.trim="caseTypeForm.typeDetailName" type="text" placeholder="未知" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="类型编码" prop="typeDetailCode">
            <el-input v-model.trim="caseTypeForm.typeDetailCode" type="text" placeholder="未知" disabled/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-form-item label="立案标准" prop="typesTime">
          <el-table :data="caseTypeForm.typesTime" border>
            <el-table-column type="index" align="center"/>
            <el-table-column prop="name" label="立案标准" align="center" width="150%"/>
            <el-table-column prop="description" label="结案标准" align="center" width="150%"/>
            <el-table-column prop="time" label="时限" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.day }}天{{ scope.row.hours }}小时{{ scope.row.minutes }}分钟</span>
              </template>
            </el-table-column>
            <el-table-column prop="deptName" label="默认部门" align="center"/>
          </el-table>
        </el-form-item>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">返回</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getCaseTypesTime } from '@/api/busAdmin/caseType'
export default {
  name: 'DetailCaseType',
  data() {
    return {
      dialogFormVisible: false, // 对话框是否显示
      caseTypeForm: {
        eorc: '',
        typeDetailName: '',
        typeDetailCode: '',
        typeId: '',
        deptName: '',
        deptId: '',
        typesTime: []
      }
    }
  },
  methods: {
    initDialog: function(dialogFormVisible, row = null) {
      this.dialogFormVisible = dialogFormVisible
      this.caseTypeForm.typesTime = []
      this.caseTypeForm.typeDetailName = row.typeDetailName
      this.caseTypeForm.typeDetailCode = row.typeDetailCode
      this.caseTypeForm.id = row.id

      getCaseTypesTime(this.caseTypeForm.id).then(response => {
        response.data.rows.forEach(element => {
          const typeTime = {
            name: element.name,
            description: element.description,
            day: element.day,
            hours: element.hours,
            minutes: element.minutes,
            deptId: element.deptId,
            deptName: element.deptName,
            edit: false
          }
          this.caseTypeForm.typesTime.push(typeTime)
        })
      })
    },
    cancel() {
      this.caseTypeForm.typesTime = []
      this.dialogFormVisible = false
    }
  }
}
</script>

<style scoped>

</style>
