gaosp
2024-01-16 032a374b420f16b3a7c01a97e7b11913bd98043c
update
已修改6个文件
228 ■■■■■ 文件已修改
src/api/Api.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/container/Map/Map.vue 105 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/container/Map/index.vue 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/container/ledger/Manage-add-update.vue 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/container/workshop/device.vue 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/mixins/index.js 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/Api.js
@@ -1,7 +1,7 @@
/*
 * @Date: 2024-01-10 20:37:45
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-14 16:44:10
 * @LastEditTime: 2024-01-15 23:56:49
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/api/Api.js
 */
import ajax from '@/utils/ajax'
@@ -26,6 +26,10 @@
        url: '/account/remainings',
        method: 'GET'
    },
    deviceRemainings: {
        url: '/account/remainings',
        method: 'GET'
    },
    accountDel: {
        url: '/account/delete',
        method: 'POST'
src/container/Map/Map.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-01-05 23:47:53
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-15 23:13:00
 * @LastEditTime: 2024-01-16 00:19:18
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/Map.vue
-->
<template>
@@ -17,8 +17,8 @@
                <el-input class="input" v-show="status !==2" v-model="rows" />
                <span>列数:</span>
                <el-input class="input" v-show="status !==2" v-model="cols" />
                <div class="plant-name" v-if="status===2">{{plantName}}</div>
                <!-- <div class="plant-name" v-if="status===2">{{plantName}}</div> -->
                <el-input class="plant-name" v-model="plantName" placeholder="请输入厂名"/>
            </div>
            <div class="table" :class="$route.name ==='preview' ? 'active' : ''" >
                <div class="table-action" :style="position" v-show="showAction && status !== 2">
@@ -27,11 +27,6 @@
                    <div @click="sign(1)">过道</div>
                    <div @click="sign(2)">机床</div>
                    <div @click="sign(0)">取消</div>
                    <div @click="edit" v-if="showEdit">修改机床</div>
                    <!-- <div>增加行</div> -->
                    <!-- <div>删除行</div> -->
                    <!-- <div>增加列</div> -->
                    <!-- <div>删除列</div> -->
                </div>
                <div :style="{width: (cols * height + 'px'),height: rows * height + 'px'}">
                    <table >
@@ -41,14 +36,28 @@
                            :height="v.rowspan* height + 'px'"
                            :class="{'active': (range.x !=='' && v.rowIndex >=range.x && v.rowIndex<=range.x1 && v.colIndex>=range.y && v.colIndex<=range.y1),aisle: v.type ===1}" @mousedown="e => onMousedown(e, v)" @mousemove="e => onMouseMove(e, v)" v-for="v in item"
                                :rowspan="v.rowspan" :colspan="v.colspan" :key="v.rowIndex + '-' + v.colIndex">
                                <img @click="addDevice($event,v)" @mousedown="e => e.stopPropagation()" v-if="v.type ===2 && status!==2 && !v.id" src="./img/+.png" alt="">
                                <Device v-if="v.id" :id="v.id" style="width: 100%;height: 100%;"></Device>
                                <img @click="addDevice($event,v)" @mousedown="e => e.stopPropagation()" v-if="v.type ===2 && status!==2 && !v.id" src="./img/+.png" alt="添加机床" title="添加机床">
                                <Device v-if="v.id" :id="v.id" style="width: 100%;height: 100%;" :deviceList="deviceList"
:plantDeviceList="plantDeviceList"></Device>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <el-dialog
        :title="添加设备"
        :close-on-click-modal="false"
        width="20%"
        :visible.sync="addStatus">
        <el-select class="wkshoplist" clearable v-model="deviceId" placeholder="请选择">
            <el-option v-for="item in deviceList" :key="item.machineId" :label="item.machineName" :value="item.machineId">
            </el-option>
        </el-select>
        <span slot="footer" class="dialog-footer">
            <el-button size="mini" type="primary" style="background-color: #409EFF;" @click="saveDevice">保存</el-button>
        </span>
      </el-dialog>
    </div>
</template>
<script>
@@ -60,13 +69,13 @@
    }
}
import mixins  from '@/mixins/index'
import AddMachine from './addMachine.vue'
// import AddMachine from './addMachine.vue'
import Device from '../workshop/device.vue'
import  {mapGetters} from 'vuex'
export default {
    mixins: [mixins],
    components: {
        AddMachine,
        // AddMachine,
        Device
    },
    props: {
@@ -177,7 +186,7 @@
        },
        currentMap: {
            handler () {
                console.log(this.currentMap)
                if (!this.currentMap || this.currentMap.length === 0) return
                if (this.currentMap.length > 0) this.map = this.currentMap
                this.rows = this.currentMap.length;
@@ -226,7 +235,17 @@
        }
    },
    methods: {
        createMap() {
        async createMap() {
            let res=true
            if (this.id) {
                res = await this.$confirm('生成地图将覆盖当前所有设置,确定重新生成?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                })
                console.log(res)
            }
            if (res || res === 'confirm') {
            let data = []
            for (var i = 0; i < this.rows; i++) {
                let arr = []
@@ -242,6 +261,7 @@
                data.push(arr)
            }
            this.map = data
            }
        },
        contextmenu(e) {
            console.log(e)
@@ -331,6 +351,7 @@
                for(var j=y;j<=y1;j++) {
                    let arr = [...(this.map[i])]
                    arr[j].type = type
                    arr[j].id = undefined
                    this.$set(this.map,i,arr)
                }
            }
@@ -338,17 +359,37 @@
            this.$forceUpdate()
        },
        addDevice (e,v) {
            if(this.status ===2) return
            e.stopPropagation()
            this.addStatus = true
            this.currentAdd =  v
        },
        del () {
            this.$confirm('确定要永久删除此厂房,关联的设备将重置?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(res => {
            this.$http.postJson('/plant/delete',{
                    ids: [this.id]
                }).then(res => {
                    this.$emit('out')
                    this.$message({
                        type: 'info',
                        message: '删除成功'
                })
                    this.$emit('out')
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '删除失败'
                    })
                })
            }, () => {
                this.$message({
                    type: 'info',
                    message: '取消删除'
                })
            })
        },
        save () {
            if (!this.id) {
@@ -356,6 +397,10 @@
                    name: this.plantName,
                    gridSetting: JSON.stringify(this.map)
                }).then(res => {
                    this.$message({
                    type: 'info',
                        message: '操作成功'
                    })
                    this.$emit('out')
                    console.log(res)
                })
@@ -365,6 +410,10 @@
                    gridSetting: JSON.stringify(this.map),
                    id: this.id
                }).then(res => {
                    this.$message({
                    type: 'info',
                        message: '操作成功'
                    })
                    this.$emit('out')
                    console.log(res)
                })
@@ -377,20 +426,28 @@
        close () {
            this.addStatus = false
        },
        edit (e) {
            if(this.status ===2) return
            e.stopPropagation()
            this.addStatus = true
        saveDevice () {
            this.setmachineId(this.deviceId)
        },
        setmachineId (id) {
            console.log(id)
            if (!id) return
            try {
            let i = this.currentAdd.rowIndex
            let j = this.currentAdd.colIndex
            let arr = [...(this.map[i])];
            arr[j].id = id
            this.$set(this.map,i,arr)
            this.close()
                this.$message({
                    type: 'info',
                    message: '操作成功'
                })
            } catch (error) {
                this.$message({
                    type: 'info',
                    message: '操作失败,请重试'
                })
            }
            this.addStatus = false
        }
    },
}
@@ -438,8 +495,8 @@
    }
    .plant-name {
        width: 120px;
        margin-left: auto;
        margin-right: 30px;
        margin-left: 20px;
        // margin-right: 30px;
        text-align: center;
        line-height: 28px;
        background: rgba(23,38,67,0.6);
src/container/Map/index.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-01-05 22:26:22
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-15 23:00:09
 * @LastEditTime: 2024-01-16 00:30:16
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/index.vue
-->
<template>
@@ -47,22 +47,22 @@
            } catch (error) {
            }
            getRequest('machineList', {
                plantId: this.id,
            }).then(res => {
                // this.list = res.data.list
                this.info = {
                    runRate: res.data.runRate,
                    cutRate: res.data.cutRate,
                    alarmRate: res.data.alarmRate,
                    threeShiftRate: res.data.threeShiftRate,
                    twoShiftRate: res.data.twoShiftRate,
                    run: res.data.run,
                    alarm: res.data.alarm,
                    stop: res.data.stop,
                    idle: res.data.idle
                }
            })
            // getRequest('machineList', {
            //     plantId: this.id,
            // }).then(res => {
            //     // this.list = res.data.list
            //     this.info = {
            //         runRate: res.data.runRate,
            //         cutRate: res.data.cutRate,
            //         alarmRate: res.data.alarmRate,
            //         threeShiftRate: res.data.threeShiftRate,
            //         twoShiftRate: res.data.twoShiftRate,
            //         run: res.data.run,
            //         alarm: res.data.alarm,
            //         stop: res.data.stop,
            //         idle: res.data.idle
            //     }
            // })
        }
    },
    data() {
src/container/ledger/Manage-add-update.vue
@@ -8,18 +8,12 @@
      <!-- 添加内容-->
      <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-col :xs="24":sm="6":md="6":lg="6":xl="6">
            <el-form-item label="机床名" prop="machineName">
              <el-select filterable v-model="dataForm.machineName" placeholder="支持模糊查询" clearable>
                <el-option
                  v-for="item in machineNamelist"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
              <el-input v-model="dataForm.machineName" placeholder="机床ip" clearable></el-input>
            </el-form-item>
          </el-col>
          <!--
          <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
            <el-form-item label="机床ip" prop="machineIp">
              <el-input v-model="dataForm.machineIp" placeholder="机床ip" clearable></el-input>
@@ -275,7 +269,7 @@
      return {
        visible: false,
        dataForm: {
          id: 0, // title显示新增还是修改
          id: '', // title显示新增还是修改
          machineName: '', // 机床名
          machineIp: '', // 机床ip
          workshop: '', // 车间名
@@ -365,7 +359,7 @@
      },
      /* 提交*/
      dataFormSubmit() {
        if (this.dataForm.id === '') { // 新增
        if (!this.dataForm.id) { // 新增
          accountCreate(this.dataForm).then(res => {
            this.$message({
              message: '新增成功',
src/container/workshop/device.vue
@@ -1,13 +1,13 @@
<!--
 * @Date: 2024-01-13 20:46:33
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-14 13:18:54
 * @LastEditTime: 2024-01-16 00:32:38
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/workshop/device.vue
-->
<template>
    <div class="device-item">
        <el-checkbox class="care" v-model="care" @change="change"></el-checkbox>
        <p>YKX123123213</p>
        <p>{{ name }}</p>
        <div class="device-item-box">
            <div class="img">
                <span class="img-status" v-if="item.status === 'STOP'">停机</span>
@@ -54,6 +54,30 @@
            default: function () {
                return {}
            }
        },
        deviceList: {
            type: Array,
            default: function() {
                return []
            }
        },
        plantDeviceList: {
            type: Array,
            default: function() {
                return []
            }
        }
    },
    computed: {
        name () {
            let name = ''
            let arr = [...this.deviceList,...this.plantDeviceList]
            arr.find(item => {
                if(item.machineId=== this.id) {
                    name = item.machineName
                }
            })
            return machineName
        }
    },
    data () {
src/mixins/index.js
@@ -1,28 +1,39 @@
/*
 * @Date: 2024-01-07 22:18:41
 * @LastEditors: Sneed
 * @LastEditTime: 2024-01-07 22:21:40
 * @LastEditTime: 2024-01-16 00:36:21
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/mixins/index.js
 */
import { getUseDpts, getRequest } from '@/api/Api'
export  default {
    data  () {
        return {
            workshopIds: [],
            sectionIds: [],
            workshopIds: []
            deviceList: [], //待选设备
            deviceId: [],
            plantDeviceList: [],
        }
    },
    create () {
        this.getListinit()
    watch: {
        id: {
            handler (val) {
                if(val) {
                    getRequest('machineList',{plantId: val}).then(res => {
                        this.plantDeviceList = res.list.map(item => {
                            return {
                                machineId: item.id,
                                machineName: item.name
                            }
                        }) || []
                    })
                }
            }
        }
    },
    mounted () {
        getRequest('deviceRemainings').then(res => {
            this.deviceList = res.data || []
        })
    },
    methods: {
        getListinit () {
            this.$http.get('/machine/workshopList').then(res => {
            })
            this.$http.get('/machine/protocolList').then(res => {
            })
        }
    },
}