gaosp
2024-01-14 48bc1beba0c69524a9c716f1a205e83a58c8171d
src/container/Map/addMachine.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-01-10 22:28:38
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-12 21:21:48
 * @LastEditTime: 2024-01-14 15:04:42
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/addMachine.vue
-->
<template>
@@ -11,12 +11,12 @@
            <el-input class="value" v-model="addInfo.name"></el-input>
        </div>
        <div class="map-add-item">
                <span>机床</span>
                <el-select 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>
            <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>
@@ -68,10 +68,10 @@
    </div>
</template>
<script>
import { getWsl,getPcl,getRequest } from '@/api/Api'
import { getWsl, getPcl, getRequest } from '@/api/Api'
export default {
    props: ['id'],
    data () {
    props: ['id', 'machineid'],
    data() {
        return {
            shiftTypes: [
                {
@@ -104,76 +104,112 @@
            },
        }
    },
    created () {
    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 => {
        getRequest('accountQuery', {}).then(res => {
            console.log(res)
            try {
                this.accountList = res.data
            } catch (error) {
                this.accountList = []
            }
        })
    },
    methods: {
        saveDevice () {
            this.$emit('setmachineId',this.addInfo.id)
            return
            this.$http.postJson('/machine/save',{
                ...this.addInfo,
                plantId: this.id
            }).then(res => {
                this.$emit('setmachineId',this.addInfo.id)
            })
        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(val) {
            console.log(val, 'changewsl')
            try {
                this.sectionIds = this.workshopList.find(item => item.id ===val).sections
                this.sectionIds = this.workshopList.find(item => item.id === val).sections
            } catch (error) {
                this.sectionIds = []
            }
        },
        close () {
        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;
.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;
            padding-right: 30px;
            width: 100%;
            margin-right: 16px;
        }
        .value {
            width: 400px;
        }
    }
</style>
    .map-add-footer {
        position: absolute;
        bottom: 0;
        text-align: right;
        padding-right: 30px;
        width: 100%;
    }
}</style>