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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
<div class="params-config-modal">
  <el-dialog
    title="配置"
    :visible.sync="visible"
    width="30%"
    :before-close="handleClose">
    <div class="content">
      <el-radio-group v-model="config" class="config-radio-group">
        <el-radio :label="false" size="large">无工艺参数,不允许下发生产任务</el-radio>
        <el-radio :label="true" size="large">无工艺参数,允许下发生产任务</el-radio>
      </el-radio-group>
    </div>
    <span slot="footer" class="dialog-footer">
    <el-button class="submit" @click="setConfig">确 定</el-button>
  </span>
  </el-dialog>
</div>
</template>
 
<script>
import {apiSetCurrentDeviceConfig, getDeviceList} from "@/api/home";
import {Message} from "element-ui";
 
export default {
  name: "ParamsConfigModal",
  props:{
    visible:{
      type: Boolean,
      default:false
    }
  },
  data(){
    return{
      config:false,
      deviceInfo:null
    }
  },
  watch:{
    visible(val){
      if (val){
        this.getDeviceInfo()
      }
    }
  },
  methods:{
    handleClose(){
      this.$emit('update:visible', false)
      this.$emit('close')
    },
    getDeviceInfo(){
      getDeviceList().then(res=>{
        this.deviceInfo = res.data
        this.config=this.getConfig(this.deviceInfo)
      }).catch(err=>{
        console.error(err)
      })
    },
    setConfig() {
      apiSetCurrentDeviceConfig({
        // 选中允许下发即不需要工艺参数 ,这俩是反的
        needSetProcessParams: !this.config
      })
        .then(() => {
          Message({
            message: '设置成功',
            type: 'success',
            duration: 3 * 1000
          })
          this.handleClose()
        })
        .catch((err) => {
          console.error(err)
        })
    },
    getConfig(deviceInfo){
      const currentDeviceInfo = deviceInfo.deviceList?.find((ele) => {
        return ele.deviceID === deviceInfo.currentDeviceID
      })
      return !currentDeviceInfo?.needSetProcessParams
    }
  }
}
</script>
 
<style scoped lang="scss">
::v-deep {
  .el-dialog{
    background-color: #10256c;
    color: #fff;
  }
  .el-dialog__title,.el-dialog__body{
    color: #fff;
  }
}
.submit{
  background-color: #0dfde6;
  outline: none;
  border: none;
  color:#333333;
  width: 100px;
  height: 40px;
  font-size: 14px;
  font-weight: 500;
  &:hover{
    background-color: #0dfde6;
    color:#333333;
  }
  &:focus{
    background-color: #0dfde6;
    color:#333333;
  }
  &:active{
    background-color: #0dfde6;
    color:#333333;
  }
}
.dialog-footer{
  display: flex;
  align-items: center;
  justify-content: center;
}
.content{
  height: 160px;
  padding:30px 20px;
  box-sizing: border-box;
}
 
.config-radio-group {
  display: flex;
  flex-direction: column;
  justify-content: start;
  align-items: start;
 
}
::v-deep .el-radio__label {
  color: #fff!important;
}
.el-radio{
  margin-bottom: 20px;
}
</style>