yangys
2024-01-14 00c8943add0753245977bdc4eb3dc7d979cf3f45
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>
@@ -12,7 +12,7 @@
        </div>
        <div class="map-add-item">
                <span>机床</span>
                <el-select class="value" v-model="addInfo.id" placeholder="请选择">
            <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>
@@ -70,7 +70,7 @@
<script>
import { getWsl,getPcl,getRequest } from '@/api/Api'
export default {
    props: ['id'],
    props: ['id', 'machineid'],
    data () {
        return {
            shiftTypes: [
@@ -104,6 +104,31 @@
            },
        }
    },
    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
@@ -123,17 +148,25 @@
    },
    methods: {
        saveDevice () {
            this.$emit('setmachineId',this.addInfo.id)
            return
            this.$http.postJson('/machine/save',{
            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)
            console.log(val, 'changewsl')
            try {
                this.sectionIds = this.workshopList.find(item => item.id ===val).sections
            } catch (error) {
@@ -152,11 +185,13 @@
        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;
@@ -164,10 +199,12 @@
                text-align: right;
                margin-right: 16px;
            }
            .value {
                width: 400px;
            }
        }
        .map-add-footer {
            position: absolute;
            bottom: 0;
@@ -175,5 +212,4 @@
            padding-right: 30px;
            width: 100%;
        }
    }
</style>
}</style>