<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="模型编码" prop="modelCode">
        <el-input
          v-model="queryParams.modelCode"
          placeholder="请输入模型编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="模型名称" prop="modelName">
        <el-input
          v-model="queryParams.modelName"
          placeholder="请输入模型名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['ems:model:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ems:model:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ems:model:remove']"
        >删除
        </el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="modelList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="模型编码" align="center" prop="modelCode"/>
      <el-table-column label="模型名称" align="center" prop="modelName"/>
      <el-table-column label="对象类型" align="center">
        <template slot-scope="scope">
          {{ objTypeMapping[scope.row.objType] }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ems:model:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ems:model:remove']"
          >删除
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-info"
            @click="handleDetail(scope.row)"
          >
            特性
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改能源对象属性对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="模型编码" prop="modelCode">
          <el-input v-model="form.modelCode" placeholder="请输入模型code"/>
        </el-form-item>
        <el-form-item label="模型名称" prop="modelName">
          <el-input v-model="form.modelName" placeholder="请输入模型名称"/>
        </el-form-item>
        <el-form-item label="对象类型" prop="objType">
          <el-select v-model="form.objType" placeholder="请选择对象类型">
            <el-option v-for="item in objTypeOptions"
                       :label="item.name"
                       :value="item.code"
                       :key="item.code" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- ”特性“对话框   -->
    <el-drawer :title=curRow.modelName size="80%" :visible.sync="showDrawer" direction="rtl">
      <div class="drawer-content" style="padding-left:50px">
        <el-tabs v-model="subKey">
          <el-tab-pane label="对象属性" name="attr">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAttrAdd"
                           v-hasPermi="['ems:attr:add']">新增
                </el-button>
              </el-col>
            </el-row>
            <el-table v-loading="loading" :data="attrList">
              <el-table-column type="selection" width="55" align="center"/>
              <el-table-column label="属性名称" align="center" prop="attrName"/>
              <el-table-column label="属性标识" align="center" prop="attrKey"/>
              <el-table-column label="属性单位" align="center" prop="attrUnit"/>
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-edit" @click="handleAttrUpdate(scope.row)"
                             v-hasPermi="['ems:attr:edit']">修改
                  </el-button>
                  <el-button size="mini" type="text" icon="el-icon-delete" class="deleteBtn"
                             @click="handleAttrDelete(scope.row)" v-hasPermi="['ems:attr:remove']">删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <pagination v-show="total>0" :total="total" :page.sync="queryAttrParams.pageNum"
                        :limit.sync="queryAttrParams.pageSize"
                        @pagination="getAttrList"/>
            <!-- 添加或修改服务区用电属性对话框 -->
            <el-dialog :title="title" :visible.sync="attrOpen" width="500px" append-to-body>
              <el-form ref="attrForm" :model="attrForm" :rules="attrRules" label-width="150px">
                <el-form-item label="属性名称" prop="attrName">
                  <el-input v-model="attrForm.attrName" placeholder="请输入属性名称"/>
                </el-form-item>
                <el-form-item label="属性标识" prop="attrKey">
                  <el-input v-model="attrForm.attrKey" placeholder="请输入属性标识"/>
                </el-form-item>
                <el-form-item label="属性类型" prop="attrType">
                  <el-select v-model="attrForm.attrType" placeholder="请选择属性类型">
                    <el-option label="静态" value="0"></el-option>
                    <el-option label="动态" value="1"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="属性单位" prop="attrUnit">
                  <el-input v-model="attrForm.attrUnit" placeholder="请输入属性单位"/>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitAttrForm">确 定</el-button>
                <el-button @click="attrCancel">取 消</el-button>
              </div>
            </el-dialog>
          </el-tab-pane>


          <el-tab-pane label="对象事件" name="second">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleEventAdd"
                           v-hasPermi="['ems:event:add']">新增
                </el-button>
              </el-col>
            </el-row>
            <el-table v-loading="loading" :data="eventList">
              <el-table-column type="selection" width="55" align="center"/>
              <el-table-column label="事件名称" align="center" prop="eventKey"/>
              <el-table-column label="事件类型" align="center" prop="eventType">
                <template slot-scope="scope">
                  <span>{{ scope.row.eventType === 1 ? '消息上报' : '异常告警' }}</span>
                </template>
              </el-table-column>
              <el-table-column label="事件代码" align="center" prop="eventCode"/>
              <el-table-column label="外系统事件代码" align="center" prop="extEventCode"/>
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEventUpdate(scope.row)"
                             v-hasPermi="['ems:event:edit']">修改
                  </el-button>
                  <el-button size="mini" type="text" icon="el-icon-delete" class="deleteBtn"
                             @click="handleEventDelete(scope.row)" v-hasPermi="['ems:event:remove']">删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <pagination v-show="total>0" :total="total" :page.sync="queryEventParams.pageNum"
                        :limit.sync="queryEventParams.pageSize"
                        @pagination="getEventList"/>
            <!-- 添加或修改事件对话框 -->
            <el-dialog :title="title" :visible.sync="eventOpen" width="500px" append-to-body>
              <el-form ref="eventForm" :model="eventForm" :rules="eventRules" label-width="80px">
                <el-form-item label="事件名称" prop="eventKey">
                  <el-input v-model="eventForm.eventKey" placeholder="请输入事件名称"/>
                </el-form-item>
                <el-form-item label="事件类型" prop="eventType">
                  <el-select v-model="eventForm.eventType" placeholder="请选择对象类型">
                    <el-option v-for="item in objEventTypeOptions"
                               :label="item.name"
                               :value="item.code"
                               :key="item.code" />
                  </el-select>
                </el-form-item>
                <el-form-item label="事件代码" prop="eventCode">
                  <el-input v-model="eventForm.eventCode" placeholder="请输入事件代码"/>
                </el-form-item>
                <el-form-item label="外系统事件代码" prop="extEventCode">
                  <el-input v-model="eventForm.extEventCode" placeholder="请输入外系统事件代码"/>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitEventForm">确 定</el-button>
                <el-button @click="eventCancel">取 消</el-button>
              </div>
            </el-dialog>
          </el-tab-pane>

          <el-tab-pane label="对象能力" name="third">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAbilityAdd"
                           v-hasPermi="['ems:ability:add']">新增
                </el-button>
              </el-col>
            </el-row>
            <el-table v-loading="loading" :data="abilityList">
              <el-table-column type="selection" width="55" align="center"/>
              <el-table-column label="能力名称" align="center" prop="abilityName"/>
              <el-table-column label="能力键" align="center" prop="abilityKey"/>
              <el-table-column label="能力参数" align="center" prop="abilityParam"/>
              <el-table-column label="能力描述" align="center" prop="abilityDesc"/>
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" icon="el-icon-edit" @click="handleAbilityUpdate(scope.row)"
                             v-hasPermi="['ems:ability:edit']">修改
                  </el-button>
                  <el-button size="mini" type="text" icon="el-icon-delete" class="deleteBtn"
                             @click="handleAbilityDelete(scope.row)" v-hasPermi="['ems:ability:remove']">删除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>

            <!-- 添加或修改能力对话框 -->
            <el-dialog :title="title" :visible.sync="abilityOpen" width="500px" append-to-body>
              <el-form ref="abilityForm" :model="abilityForm" :rules="abilityRules" label-width="80px">
<!--                <el-form-item label="模型code" prop="modelCode">-->
<!--                  <el-input v-model="abilityForm.modelCode" placeholder="请输入模型code"/>-->
<!--                </el-form-item>-->
                <el-form-item label="能力键" prop="abilityKey">
                  <el-input v-model="abilityForm.abilityKey" placeholder="请输入能力键"/>
                </el-form-item>
                <el-form-item label="能力名称" prop="abilityName">
                  <el-input v-model="abilityForm.abilityName" placeholder="请输入能力名称"/>
                </el-form-item>
                <el-form-item label="能力描述" prop="abilityDesc">
                  <el-input v-model="abilityForm.abilityDesc" type="textarea" placeholder="请输入内容"/>
                </el-form-item>
                <el-form-item label="能力参数" prop="abilityParam">
                  <el-input v-model="abilityForm.abilityParam" type="textarea" placeholder="请输入内容"/>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitAbilityForm">确 定</el-button>
                <el-button @click="abilityCancel">取 消</el-button>
              </div>
            </el-dialog>
          </el-tab-pane>

        </el-tabs>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import { listModel, getModel, delModel, addModel, updateModel, getModelByCode } from '@/api/basecfg/objModel'
import { getEvent, delEvent, addEvent, updateEvent } from '@/api/basecfg/objEvent'
import { getAttr, delAttr, addAttr, updateAttr } from '@/api/basecfg/objAttribute'
import { getAbility, delAbility, addAbility, updateAbility } from '@/api/basecfg/objAbility'

export default {
  name: 'Model',
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 能源对象属性表格数据
      modelList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      eventOpen: false,
      attrOpen: false,
      abilityOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        modelCode: null,
        modelName: null,
        objType: null
      },
      objTypeMapping: {
        1: '设施',
        2: '设备',
        3: '设备部件'
      },
      objTypeOptions: [
        { code: 1, name: '设施' },
        { code: 2, name: '设备' },
        { code: 3, name: '设备部件' }
      ],
      objEventTypeOptions: [
        { code: 1, name: '信息上报' },
        { code: 2, name: '异常警告' },
      ],
      // 查询参数
      queryEventParams: {
        pageNum: 1,
        pageSize: 10
      },
      queryAttrParams: {
        pageNum: 1,
        pageSize: 10
      },
      queryAbilityParams: {
        pageNum: 1,
        pageSize: 10
      },
      curRow: {},
      // 表单参数
      form: {},
      eventForm: {},
      attrForm: {},
      abilityForm: {},
      //  表单校验
      rules: {
        modelCode: [
          { required: true, message: '模型code不能为空', trigger: 'blur' }
        ],
        modelName: [
          { required: true, message: '模型名称不能为空', trigger: 'blur' }
        ],
        objType: [
          { required: true, message: '对象类型不能为空', trigger: 'change' }
        ]
      },
      eventRules: {
        modelCode: [
          { required: true, message: '模型code不能为空', trigger: 'blur' }
        ],
        eventKey: [
          { required: true, message: '事件名称不能为空', trigger: 'blur' }
        ],
        eventType: [
          { required: true, message: '事件类型不能为空', trigger: 'change' }
        ],
        eventName: [
          { required: true, message: '事件名称不能为空', trigger: 'blur' }
        ]
      },
      attrRules: {
        modelCode: [
          { required: true, message: '模型code不能为空', trigger: 'blur' }
        ],
        attrKey: [
          { required: true, message: '属性标识不能为空', trigger: 'blur' }
        ],
        attrName: [
          { required: true, message: '属性名称不能为空', trigger: 'blur' }
        ]
      },
      abilityRules: {
        modelCode: [
          { required: true, message: '模型code不能为空', trigger: 'blur' }
        ],
        abilityKey: [
          { required: true, message: '能力键不能为空', trigger: 'blur' }
        ],
        abilityName: [
          { required: true, message: '能力名称不能为空', trigger: 'blur' }
        ]
      },

      // 能源对象事件表格数据
      eventList: [],
      // 能源对象属性表格数据
      attrList: [],
      // 能源对象能力表格数据
      abilityList: [],

      showDrawer: false,
      subDialogShow: false,
      // subTitle: '',
      subKey: 'attr'
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 设配详情
    handleDetail(row) {
      this.showDrawer = true
      this.curRow = row
      console.log('模型代码', this.modelCode)
      getModel(this.curRow.id).then(response => {
        const data = response.data
        console.log('data', data)
        this.attrList = data.attrList
        this.eventList = data.eventList
        this.abilityList = data.abilityList
      })
    },
    /** 新增按钮操作 */
    handleAttrAdd() {
      this.attrReset()
      this.attrOpen = true
      this.title = '添加能源对象属性'
      this.attrForm.modelCode= this.curRow.modelCode
    },
    handleEventAdd() {
      this.eventReset()
      this.eventOpen = true
      this.title = '添加能源对象事件'
      this.eventForm.modelCode= this.curRow.modelCode
    },
    handleAbilityAdd() {
      this.abilityReset()
      this.abilityOpen = true
      this.title = '添加能源对象事件'
      this.abilityForm.modelCode= this.curRow.modelCode
    },
    /** 查询能源对象属性列表 */
    getList() {
      this.loading = true
      listModel(this.queryParams).then(response => {
        this.modelList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    getEventList(modelcode) {
      console.log('对象事件!!!!')
      this.loading = true
      getModelByCode(modelcode).then(response => {
        const data = response.data
        console.log('data', data)
        this.attrList = data.attrList
        this.eventList = data.eventList
        this.abilityList = data.abilityList
      })
      this.loading = false

    },
    /** 查询能源对象属性列表 */
    getAttrList(modelcode) {
      this.loading = true
      console.log('对象属性!!!!')
      getModelByCode(modelcode).then(response => {
        const data = response.data
        console.log('data', data)
        this.attrList = data.attrList
        this.eventList = data.eventList
        this.abilityList = data.abilityList

      })
      this.loading = false
    },
    /** 查询能源对象能力列表 */
    getAbilityList(modelcode) {
      this.loading = true
      console.log('对象能力!!!!')
      getModelByCode(modelcode).then(response => {
        const data = response.data
        console.log('data', data)
        this.attrList = data.attrList
        this.eventList = data.eventList
        this.abilityList = data.abilityList

      })
      this.loading = false

    },

    // 表单重置
    attrReset() {
      this.attrForm = {
        id: null,
        modelCode:  this.curRow.modelCode || '',
        attrKey: null,
        attrType: null,
        attrName: null,
        attrValue: null,
        attrUnit: null
      }
      this.resetForm('attrForm')
    },
    eventReset() {
      this.eventForm = {
        id: null,
        modelCode:  this.curRow.modelCode || '',
        eventKey: null,
        eventType: null,
        eventName: null,
        eventDesc: null,
        eventCode: null,
        extEventCode: null
      }
      this.resetForm('eventForm')
    },
    abilityReset() {
      this.abilityForm = {
        id: null,
        modelCode:  this.curRow.modelCode || '',
        abilityKey: null,
        abilityName: null,
        abilityDesc: null,
        abilityParam: null
      }
      this.resetForm('abilityForm')
    },

    /** 修改按钮操作 */
    handleAttrUpdate(row) {
      this.attrReset()
      const id = row.id || this.ids
      getAttr(id).then(response => {
        this.attrForm = response.data
        this.attrOpen = true
        this.title = '修改能源对象属性'
        this.attrForm.modelCode= this.curRow.modelCode

      })
    },
    handleEventUpdate(row) {
      this.eventReset()
      const id = row.id || this.ids
      getEvent(id).then(response => {
        this.eventForm = response.data
        this.eventOpen = true
        this.title = '修改能源对象事件'
        this.attrForm.modelCode= this.curRow.modelCode

      })
    },
    handleAbilityUpdate(row) {
      this.abilityReset()
      const id = row.id || this.ids
      getAbility(id).then(response => {
        this.abilityForm = response.data
        this.abilityOpen = true
        this.title = '修改能源对象能力'
        this.attrForm.modelCode= this.curRow.modelCode

      })
    },

    /** 删除按钮操作 */
    handleAttrDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除能源对象属性编号为"' + ids + '"的数据项？').then(function() {
        return delAttr(ids)
      }).then(() => {
        console.log('删除row', row.modelCode)
        this.getAttrList(row.modelCode)
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    handleEventDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除能源对象事件编号为"' + ids + '"的数据项？').then(function() {
        return delEvent(ids)
      }).then(() => {
        console.log('删除row', row.modelCode)
        this.getEventList(row.modelCode)
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    handleAbilityDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除能源对象能力编号为"' + ids + '"的数据项？').then(function() {
        return delAbility(ids)
      }).then(() => {
        console.log('删除row', row.modelCode)
        this.getAbilityList(row.modelCode)
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },

    /** 提交按钮 */
    submitAttrForm() {
      this.$refs['attrForm'].validate(valid => {
        if (valid) {
          if (this.attrForm.id != null) {
            updateAttr(this.attrForm).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.attrOpen = false
              console.log('id', this.attrForm.modelCode)
              this.getAttrList(this.attrForm.modelCode)
            })
          } else {
            addAttr(this.attrForm).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.attrOpen = false
              this.getAttrList(this.attrForm.modelCode)
            })
          }
        }
      })
    },
    submitEventForm() {
      this.$refs['eventForm'].validate(valid => {
        if (valid) {
          if (this.eventForm.id != null) {
            updateEvent(this.eventForm).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.eventOpen = false
              console.log('id', this.eventForm)
              this.getEventList(this.eventForm.modelCode)
            })
          } else {
            addEvent(this.eventForm).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.eventOpen = false
              console.log('id', this.eventForm)
              this.getEventList(this.eventForm.modelCode)
            })
          }
        }
      })
    },
    submitAbilityForm() {
      this.$refs['abilityForm'].validate(valid => {
        if (valid) {
          if (this.abilityForm.id != null) {
            updateAbility(this.abilityForm).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.abilityOpen = false
              this.getAbilityList(this.abilityForm.modelCode)
            })
          } else {
            addAbility(this.abilityForm).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.abilityOpen = false
              this.getAbilityList(this.abilityForm.modelCode)
            })
          }
        }
      })
    },
    // 取消按钮
    attrCancel() {
      this.attrOpen = false
      this.attrReset()
    },
    eventCancel() {
      this.eventOpen = false
      this.eventReset()
    },
    // 取消按钮
    abilityCancel() {
      this.abilityOpen = false
      this.abilityReset()
    },

    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        modelCode: null,
        modelName: null,
        objType: null
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加能源对象属性'
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getModel(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = '修改能源对象属性'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateModel(this.form).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            addModel(this.form).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除能源对象属性编号为"' + ids + '"的数据项？').then(function() {
        return delModel(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    }
  }
}
</script>
