| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | :title="!dataForm.id ? '新建' : '编辑'" |
| | | :close-on-click-modal="false" |
| | | width="80%" |
| | | :visible.sync="addVisible"> |
| | | <!-- 添加内容--> |
| | | <el-form :model="dataForm" label-width="100px" ref="dataForm"> |
| | | <el-row :gutter="20"> |
| | | <el-col :xs="24":sm="6":md="6":lg="6":xl="6"> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="dataForm.name" placeholder="名称" clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | </el-row> |
| | | |
| | | </el-form> |
| | | <!-- 按钮 --> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button size="mini" @click="cancel">取消</el-button> |
| | | <el-button size="mini" class="active" type="primary" @click="dataFormSubmit()">保存</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | <div> |
| | | <el-dialog :title="!dataForm.id ? '新建' : '编辑'" :close-on-click-modal="false" width="80%" :visible.sync="addVisible"> |
| | | <!-- 添加内容--> |
| | | <el-form :model="dataForm" label-width="100px" ref="dataForm"> |
| | | <el-row :gutter="20"> |
| | | <el-col :xs="24" :sm="6" :md="6" :lg="6" :xl="6"> |
| | | <el-form-item label="机床名称" prop="machineName"> |
| | | <el-input v-model="dataForm.machineName" placeholder="机床名称" clearable></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="机床" prop="id"> |
| | | <el-select class="value" v-model="dataForm.id" placeholder="请选择"> |
| | | <el-option v-for="item in accountList" :key="item.machineId" :label="item.uuid" |
| | | :value="item.machineId"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="IP" prop="ip"> |
| | | <el-input v-model="dataForm.ip" placeholder="IP" clearable></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="端口" prop="port"> |
| | | <el-input v-model="dataForm.port" placeholder="端口" clearable></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="车间" prop="workshopId"> |
| | | <el-select class="value" v-model="dataForm.workshopId" @change="changewsl" placeholder="请选择"> |
| | | <el-option v-for="item in workshopList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="工段" prop="sectionId"> |
| | | <el-select class="value" v-model="dataForm.sectionId" placeholder="请选择"> |
| | | <el-option v-for="item in sectionIds" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="协议" prop="protocolId"> |
| | | <el-select class="value" v-model="dataForm.protocolId" placeholder="请选择"> |
| | | <el-option v-for="item in protocolList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="是否采集" prop="isCollect"> |
| | | <el-radio-group class="value" v-model="dataForm.isCollect"> |
| | | <el-radio :label="0">否</el-radio> |
| | | <el-radio :label="1">是</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="班制" prop="shiftType"> |
| | | <el-select class="value" v-model="dataForm.shiftType" placeholder="请选择"> |
| | | <el-option v-for="item in shiftTypes" :key="item.value" :label="item.label" |
| | | :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | </el-row> |
| | | |
| | | </el-form> |
| | | <!-- 按钮 --> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button size="mini" @click="cancel">取消</el-button> |
| | | <el-button size="mini" class="active" type="primary" @click="dataFormSubmit()">保存</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { deviceTypeUpdate,deviceTypeCreate } from '@/api/Api' |
| | | export default { |
| | | props: ['addVisible','row'], |
| | | data() { |
| | | return { |
| | | visible: false, |
| | | dataForm: { |
| | | id: 0, // title显示新增还是修改 |
| | | name: '' |
| | | } |
| | | |
| | | } |
| | | }, |
| | | watch: { |
| | | addVisible: { |
| | | handler (val) { |
| | | if (val) { |
| | | this.init() |
| | | } |
| | | }, |
| | | immediate: true |
| | | } |
| | | }, |
| | | created () { |
| | | console.log('add create'); |
| | | this.init(this.row) |
| | | }, |
| | | methods: { |
| | | init(row) { |
| | | if (this.$refs['dataForm']) { |
| | | this.$refs['dataForm'].resetFields() |
| | | } |
| | | if (row !== undefined) { |
| | | this.dataForm.id = row.id |
| | | this.dataForm.name = row.name |
| | | |
| | | } else { |
| | | this.dataForm.id = '' |
| | | import { getWsl, getPcl, getRequest } from '@/api/Api' |
| | | export default { |
| | | props: ['addVisible', 'row'], |
| | | data() { |
| | | return { |
| | | shiftTypes: [ |
| | | { |
| | | label: '1班', |
| | | value: '1' |
| | | }, |
| | | { |
| | | label: '2班', |
| | | value: '2' |
| | | }, |
| | | { |
| | | label: '3班', |
| | | value: '3' |
| | | }, |
| | | ], |
| | | protocolList: [], |
| | | sectionIds: [], |
| | | workshopList: [], |
| | | accountList: [], |
| | | dataForm: { |
| | | machineName: '', |
| | | id: '', |
| | | ip: '', |
| | | port: '', |
| | | workshopId: '', |
| | | sectionId: '', |
| | | protocolId: '', |
| | | isCollect: '', |
| | | shiftType: '', |
| | | }, |
| | | |
| | | } |
| | | }, |
| | | /* 查询使用部门*/ |
| | | cancel () { |
| | | this.$emit('close') |
| | | }, |
| | | /* 提交*/ |
| | | dataFormSubmit() { |
| | | if (this.dataForm.id === '') { // 新增 |
| | | deviceTypeCreate(this.dataForm).then(res => { |
| | | this.$message({ |
| | | message: '新增成功', |
| | | type: 'success', |
| | | duration: 1500, |
| | | onClose: () => { |
| | | this.$emit('confirm') |
| | | this.visible = false |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | deviceTypeUpdate(this.dataForm).then(res => { |
| | | this.$message({ |
| | | message: '修改成功', |
| | | type: 'success', |
| | | duration: 1500, |
| | | onClose: () => { |
| | | this.$emit('confirm') |
| | | this.visible = false |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | 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: { |
| | | changewsl(val) { |
| | | console.log(val, 'changewsl') |
| | | try { |
| | | this.sectionIds = this.workshopList.find(item => item.id === val).sections |
| | | } catch (error) { |
| | | this.sectionIds = [] |
| | | } |
| | | }, |
| | | /* 查询使用部门*/ |
| | | cancel() { |
| | | this.$emit('close') |
| | | }, |
| | | /* 提交*/ |
| | | dataFormSubmit() { |
| | | if (this.dataForm.id === '') { // 新增 |
| | | getRequest('machineSave',this.dataForm).then(res => { |
| | | |
| | | }) |
| | | } else { |
| | | // deviceTypeUpdate(this.dataForm).then(res => { |
| | | // this.$message({ |
| | | // message: '修改成功', |
| | | // type: 'success', |
| | | // duration: 1500, |
| | | // onClose: () => { |
| | | // this.$emit('confirm') |
| | | // this.visible = false |
| | | // } |
| | | // }) |
| | | // }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .el-form-item__content { |
| | | .el-select,.el-input { |
| | | width: 100%; |
| | | } |
| | | } |
| | | .avatar-uploader .el-upload { |
| | | border: 1px dashed #d9d9d9; |
| | | border-radius: 6px; |
| | | cursor: pointer; |
| | | position: relative; |
| | | overflow: hidden; |
| | | } |
| | | .avatar-uploader .el-upload:hover { |
| | | border-color: #409EFF; |
| | | } |
| | | .avatar-uploader-icon { |
| | | font-size: 28px; |
| | | color: #8c939d; |
| | | width: 178px; |
| | | height: 178px; |
| | | line-height: 178px; |
| | | text-align: center; |
| | | } |
| | | .avatar { |
| | | width: 178px; |
| | | height: 178px; |
| | | display: block; |
| | | } |
| | | .el-form-item__content { |
| | | |
| | | .el-select, |
| | | .el-input { |
| | | width: 100%; |
| | | } |
| | | } |
| | | |
| | | .avatar-uploader .el-upload { |
| | | border: 1px dashed #d9d9d9; |
| | | border-radius: 6px; |
| | | cursor: pointer; |
| | | position: relative; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .avatar-uploader .el-upload:hover { |
| | | border-color: #409EFF; |
| | | } |
| | | |
| | | .avatar-uploader-icon { |
| | | font-size: 28px; |
| | | color: #8c939d; |
| | | width: 178px; |
| | | height: 178px; |
| | | line-height: 178px; |
| | | text-align: center; |
| | | } |
| | | |
| | | .avatar { |
| | | width: 178px; |
| | | height: 178px; |
| | | display: block; |
| | | } |
| | | </style> |