<!--
|
* @Date: 2024-01-10 22:28:38
|
* @LastEditors: Sneed
|
* @LastEditTime: 2024-01-16 00:45:48
|
* @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/addMachine.vue
|
-->
|
<template>
|
<div class="map-add">
|
<div class="map-add-item">
|
<span>机床名称</span>
|
<el-input class="value" v-model="addInfo.machineName"></el-input>
|
</div>
|
<div class="map-add-item">
|
<span>机床</span>
|
<el-select :disabled="!!machineid" class="value" v-model="addInfo.id" placeholder="请选择">
|
<el-option v-for="item in accountList" :key="item.machineId" :label="item.uuid" :value="item.machineId">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="map-add-item">
|
<span>IP</span>
|
<el-input class="value" v-model="addInfo.ip"></el-input>
|
</div>
|
<div class="map-add-item">
|
<span>端口</span>
|
<el-input class="value" v-model="addInfo.port"></el-input>
|
</div>
|
<div class="map-add-item">
|
<span>车间</span>
|
<!-- <el-input class="value"></el-input> -->
|
<el-select class="value" v-model="addInfo.workshopId" @change="changewsl" placeholder="请选择">
|
<el-option v-for="item in workshopList" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="map-add-item">
|
<span>工段</span>
|
<el-select class="value" v-model="addInfo.sectionId" placeholder="请选择">
|
<el-option v-for="item in sectionIds" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="map-add-item">
|
<span>协议</span>
|
<el-select class="value" v-model="addInfo.protocolId" placeholder="请选择">
|
<el-option v-for="item in protocolList" :key="item.id" :label="item.name" :value="item.id">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="map-add-item">
|
<span>是否采集</span>
|
<el-radio-group class="value" v-model="addInfo.isCollect">
|
<el-radio :label="0">否</el-radio>
|
<el-radio :label="1">是</el-radio>
|
</el-radio-group>
|
</div>
|
<div class="map-add-item">
|
<span>班制</span>
|
<el-select class="value" v-model="addInfo.shiftType" placeholder="请选择">
|
<el-option v-for="item in shiftTypes" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
</el-select>
|
</div>
|
<div class="map-add-footer">
|
<el-button size="mini" @click="close">关闭</el-button>
|
<el-button type="primary" size="mini" @click="saveDevice">保存</el-button>
|
</div>
|
</div>
|
</template>
|
<script>
|
import { getWsl, getPcl, getRequest } from '@/api/Api'
|
export default {
|
props: ['id', 'machineid'],
|
data() {
|
return {
|
shiftTypes: [
|
{
|
label: '1班',
|
value: '1'
|
},
|
{
|
label: '2班',
|
value: '2'
|
},
|
{
|
label: '3班',
|
value: '3'
|
},
|
],
|
protocolList: [],
|
sectionIds: [],
|
workshopList: [],
|
accountList: [],
|
addInfo: {
|
machineName: '',
|
id: '',
|
ip: '',
|
port: '',
|
workshopId: '',
|
sectionId: '',
|
protocolId: '',
|
isCollect: '',
|
shiftType: '',
|
},
|
}
|
},
|
watch: {
|
machineid: {
|
handler(val) {
|
if (val) {
|
setTimeout(() => {
|
getRequest('machineQuery', { size: 10, machineId: val }).then(res => {
|
this.changewsl(res.data.records[0].workshopId)
|
this.$nextTick(() => {
|
try {
|
Object.keys(this.addInfo).forEach(item => {
|
this.addInfo[item] = res.data.records[0][item]
|
})
|
// this.addInfo.id = res.data.records[0].id
|
} catch (error) {
|
console.error(error)
|
}
|
})
|
})
|
}, 1000)
|
|
}
|
},
|
immediate: true
|
}
|
},
|
created() {
|
getPcl().then(res => {
|
this.protocolList = res.data
|
})
|
getWsl().then(res => {
|
this.workshopList = res.data
|
})
|
getRequest('accountQuery', {}).then(res => {
|
console.log(res)
|
try {
|
this.accountList = res.data
|
} catch (error) {
|
this.accountList = []
|
}
|
|
})
|
},
|
methods: {
|
saveDevice() {
|
let url = '/machine/save'
|
if (this.machineid) {
|
getRequest('machineUpdate',{
|
...this.addInfo,
|
plantId: this.id
|
}).then(res => {
|
this.$emit('setmachineId', this.addInfo.id)
|
})
|
} else {
|
getRequest('machineSave',{
|
...this.addInfo,
|
plantId: this.id
|
}).then(res => {
|
this.$emit('setmachineId', this.addInfo.id)
|
})
|
}
|
},
|
changewsl(val) {
|
console.log(val, 'changewsl')
|
try {
|
this.sectionIds = this.workshopList.find(item => item.id === val).sections
|
} catch (error) {
|
this.sectionIds = []
|
}
|
},
|
close() {
|
this.$emit('close')
|
}
|
},
|
}
|
</script>
|
<style lang="scss" scoped>
|
.map-add {
|
width: 100%;
|
height: 100%;
|
overflow: auto;
|
position: relative;
|
|
.map-add-item {
|
margin-top: 24px;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
|
span {
|
width: 150px;
|
font-size: 16px;
|
color: #C6DCE0;
|
text-align: right;
|
margin-right: 16px;
|
}
|
|
.value {
|
width: 400px;
|
}
|
}
|
|
.map-add-footer {
|
position: absolute;
|
bottom: 0;
|
text-align: right;
|
padding-right: 30px;
|
width: 100%;
|
}
|
}</style>
|