jihongshun
5 天以前 417c46988366e8c11f54230345f2e6840a0025f7
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
81
82
83
84
85
86
87
88
89
90
91
92
<template>
  <el-dialog
    title="选择飞行模板"
    :visible.sync="dialogVisible"
    @close="cancel"
    width="20%">
    <el-form ref="form" :model="form" label-width="80px" :rules="rules">
      <el-form-item label="飞行模板">
        <el-select v-model="form.modelObj" placeholder="请选择飞行模板" @change="handleChange">
          <el-option
              v-for="item in templateArr"
              :key="item.id"
              :label="item.templateName"
              :value="item.id">
            </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
 
<script>
import { flyDataInfo} from "@/api/system/template"
  export default {
    name:'chooseModelDialog',
    components: {
    },
    props: {
      deviceId: {
        type: String,
        defaule: null
      }
    },
    data() {
      return {
        dialogVisible: true,
        tableColumns: [
            {
              label: '设备名称',
              prop: 'deviceName'
            },
             {
              label: '所属线路',
              prop: 'belongingRoute'
            },
        ],
        selectArr:[],
        form:{
        },
        templateArr:[],
        rules:{
          modelObj: [
            { required: true, message: '请选择模板', trigger: 'change' }
          ]
        }
      };
    },
    mounted() {
      console.log(this.deviceId)
      if(this.deviceId){
        flyDataInfo(this.deviceId).then(res=>{
          console.log(res)
          if(res.code == 200 ) {
            this.templateArr = res.rows
          }
        })
        //点击模板查询设备下的关联模型的所有模板 
      }
    },  
    methods: {
      cancel(){
        this.$emit('cancelModel')
      }, 
      handleChange(value){
         this.form.deviceId = this.deviceId
        this.form.modelObj =this.templateArr.find(item => item.id === value)
      },
      submit(){
        // this.selectArr 
        // //反显参数传递option对象  
        // this.form.deviceId = this.deviceId
        // console.log(this.form)
        this.$emit('receiveModel',this.form)
        this.$emit('cancelModel')
      },
    }
  };
</script>