<template>
  <div class="app-container">
    <Form :formList="formList" :ruleFormData="ruleForm" :config="config" @fnClick="callback"></Form>
  </div>
</template>

<script setup name="Handle">
  import Form from '@/components/form/index.vue';
  import {addGroup, getGroup, updateGroup, resNameList} from "@/api/disRevenue/resource"
  export default {
    name: 'AlarmLogDetails',
    components: {Form},
    data() {
      return {
        ruleForm: {},
        formList: [],
        config: {
          buttonGroup: [{title: '返回', fnCode: 'goBack'}]
        },
        paramsData: {}
      }
    },
    created() {
      this.paramsData = this.$route && this.$route.query;
      if (this.paramsData && this.paramsData.id) {
        this.getFormDataList(this.paramsData.id);
      }
      this.fnFormList();
    },
    methods: {
      // formList集合
      fnFormList(objVal) {
        this.formList = [{
          config: {title: '基本信息',readonly: true},
          controls: {
            id: {label: 'ID',hidden: true},
            groupName: {label: '资源名称', span: 24, type: 'input', rules: [{required: true, message: '请输入名称', trigger: 'blur'}]},
            ip: {label: '源IP', span: 24, type: 'input'},
            time: {label: '发生时间', span: 24, type: 'date'},
            num: {label: '重复次数', span: 24, type: 'input'},
            type: {label: '状态', span: 24, type: 'input'},
            description: {label: '内容', span: 24, type: 'textarea'}
          }
        }];
      },
      // 获取详情
      getFormDataList(id) {
        getGroup(id).then(val => {
          if (val && val.data) {
            val.data['includedDevices'] = val.data['includedDevices'].split(',');
            this.ruleForm = val.data;
          }
        }).catch(() => {
          this.$modal.msgError("操作失败")
        });
      },
      // 监听事件
      callback(result, dataVal, formVal) {
        if (result && result.fnCode) {
          switch (result.fnCode) {
            case 'cancle':
              this.$router.push("/resource/alarmLog");
              break;
            default:
          }
        }
      }
    }
  }
</script>
<style>
</style>
