duhuizhe
2023-10-16 3aa55dd3f62cee2c1c4c0aa74e1570acf83f8927
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<template>
  <win-sm :title="setting.title" @close="close">
    <el-form :model="formData" :rules="rules" ref="ruleForm" label-width="100px">
      <el-form-item label="预警模板" prop="tempExpirationNotifyId">
        <el-select v-model="formData.tempExpirationNotifyId" placeholder="请选择预警模板" filterable >
          <el-option v-for="c in treeData" :key="c.id" :label="c.tempExpirationNotifyName" :value="c.id"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" align="center" class="dialog-footer">
      <my-button name="取消" site="form" @click="close" />
      <my-button name="保存" site="form" @click="save" />
    </div>
  </win-sm>
</template>
 
<script>
import winSm from '@/components/win/win-sm'
import myButton from "@/components/myButton/myButton";
import * as information from '@/api/projectManage/information'
export default {
  name: "warningSetting",
  components: { winSm, myButton},
  props: {
    setting: {
      type: Object,
      default: () => {
      }
    }
  },
  data() {
    return {
      treeData:[],
      formData:{
        id: '',
        tempExpirationNotifyId:null
      },
      rules: {
        tempExpirationNotifyId: [
          { required: true, message: '请选择预警模板', trigger: 'change' }
        ]
      }
    }
  },
  created() {
    this.formData.tempExpirationNotifyId = this.setting.tempExpirationNotifyId
    this.formData.id = this.setting.id
    this.loadTempList()
  },
  methods:{
    loadTempList(){
      information.getWarnTempletelist({
        createOrgId: this.setting.createOrgId
      }).then(res=>{
        this.treeData = res
      })
    },
    close(){
      this.$emit('close')
    },
    save(){
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          information.warnTempleteSave(this.formData).then(res=>{
            this.$message.success('保存成功')
            this.$emit('close')
            this.$emit('search')
          })
        } else {
          return false;
        }
      })
    }
  }
}
</script>
 
<style scoped>
 
</style>