From c5488b34876f863558219f998e75c798c34af3cd Mon Sep 17 00:00:00 2001 From: yangys <y_ys79@sina.com> Date: 星期二, 16 一月 2024 22:10:32 +0800 Subject: [PATCH] 修改标题错误 --- src/container/Map/Map.vue | 525 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 420 insertions(+), 105 deletions(-) diff --git a/src/container/Map/Map.vue b/src/container/Map/Map.vue index 77297aa..0b2c9b4 100644 --- a/src/container/Map/Map.vue +++ b/src/container/Map/Map.vue @@ -1,40 +1,63 @@ <!-- * @Date: 2024-01-05 23:47:53 * @LastEditors: Sneed - * @LastEditTime: 2024-01-06 16:12:18 + * @LastEditTime: 2024-01-16 01:03:35 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/mdc/src/container/Map/Map.vue --> <template> <div class="map"> - <div class="table-tool" v-if="status !== 2"> - <el-button @click="save">淇濆瓨</el-button> - <el-button @click="out">閫�鍑�</el-button> - <el-input v-show="status !== 2" v-model="plantName" placeholder="鍘傚悕"/> - <el-input v-show="status ===0 && !map" v-model="rows" /> - <el-input v-show="status ===0 && !map" v-model="cols" /> - <el-button v-show="status ===0 && !map" @click="createMap">鐢熸垚鍦板浘</el-button> - </div> - <div class="table" > - <div class="table-action" :style="position" v-show="showAction && status !== 2"> - <div @click="merge">鍚堝苟</div> - <div @click="split">鎷嗗垎</div> - <div @click="sign(1)">杩囬亾</div> - <div @click="sign(2)">鏈哄簥</div> - <div @click="sign(0)">鍙栨秷</div> - <!-- <div>澧炲姞琛�</div> --> - <!-- <div>鍒犻櫎琛�</div> --> - <!-- <div>澧炲姞鍒�</div> --> - <!-- <div>鍒犻櫎鍒�</div> --> + <div class="map-container"> + <div class="table-tool"> + <slot name="tool"></slot> + <el-button v-show="!id" class="input" type="primary" size="mini" @click="out">閫�鍑�</el-button> + <el-button class="input" type="primary" size="mini" @click="save">淇濆瓨</el-button> + <el-button v-show="id" class="input" type="primary" size="mini" @click="del">鍒犻櫎</el-button> + <el-button class="input" size="mini" type="primary" v-show="status !==2" @click="createMap">鐢熸垚鍦板浘</el-button> + <span>琛屾暟:</span> + <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> --> + <el-input class="plant-name" v-model="plantName" placeholder="璇疯緭鍏ュ巶鍚�"/> </div> - <table :style="{ width: 50 / 19 * rows + 'rem', height: 50 / 19 * cols + 'rem' }"> - <tr v-for="(item, index) in mapNew" :key="index"> - <td v-if="v.rowspan !==0 && v.colspan!==0" :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" src="./img/+.png" alt=""> - </td> - </tr> - </table> + <div class="table" :class="$route.name ==='preview' ? 'active' : ''" > + <div class="table-action" :style="position" v-show="showAction && status !== 2"> + <div @click="merge">鍚堝苟</div> + <div @click="split">鎷嗗垎</div> + <div @click="sign(1)">杩囬亾</div> + <div @click="sign(2)">鏈哄簥</div> + <div @click="sign(0)">鍙栨秷</div> + </div> + <div :style="{width: (cols * height + 'px'),height: rows * height + 'px'}"> + <table > + <tr v-for="(item, index) in map" :key="index"> + <td v-if="v.rowspan !==0 && v.colspan!==0" + :width="v.colspan* height + 'px'" + :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="娣诲姞鏈哄簥" title="娣诲姞鏈哄簥"> + <Device v-if="v.id" :id="v.id" style="width: 100%;height: 100%;" :deviceList="deviceList" +:plantDeviceList="plantDeviceList" ::info="info"></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> @@ -45,7 +68,16 @@ return v } } +import mixins from '@/mixins/index' +// import AddMachine from './addMachine.vue' +import Device from '../workshop/device.vue' +import {mapGetters} from 'vuex' export default { + mixins: [mixins], + components: { + // AddMachine, + Device + }, props: { status: { type: Number, @@ -58,31 +90,52 @@ type: String, }, id: { - type: Number + type: [Number,String] } }, computed: { - mapNew () { - if (this.currentMap.length > 0) return this.currentMap - if (!this.map) return [] - let arr = this.map.filter(item => item.rowspan !== 0 || item.colspan !== 0) - return arr + showEdit() { + try { + const { x, x1, y, y1 } = this.range + if (this.range && x && x1 && y && y1) { + let start = this.map[x][y] + return this.map[x][y].id && (start.rowIndex + start.rowspan -1) === x1 && (start.colIndex + start.colspan -1) === y1 + } + } catch (error) { + return false + } }, - tableW () { - this.mapNew - }, + machineid () { + try { + const { x, x1, y, y1 } = this.range + if (this.range && x && x1 && y && y1) { + let start = this.map[x][y] + if (this.map[x][y].id && (start.rowIndex + start.rowspan -1) === x1 && (start.colIndex + start.colspan -1) === y1) { + return start.id + } else { + return '' + } + } + } catch (error) { + return '' + } + } }, data() { return { + height: 0, plantName: '', - rows: 10, - cols: 10, + rows: 20, + cols: 50, map: null, // 鍦板浘鏁版嵁 + addStatus: false, position: {}, + selection:[], showAction: false, tdMounseDown: false, - selection: [], - range: {x: '',x1: '',y: '',y1: ''} + range: {x: '',x1: '',y: '',y1: ''}, + currentAdd: {}, + colgroups:[] } }, watch: { @@ -125,6 +178,42 @@ this.plantName = this.name }, immediate: true + }, + id (val) { + if (!val) { + this.map = [] + }else { + // getRequest('machineList',{plantId: val}).then(res => { + // this.plantDeviceList = res.list.map(item => { + // return { + // machineId: item.id, + // machineName: item.machineName + // } + // }) || [] + // }) + } + }, + 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; + this.cols = this.currentMap[0].length; + if (this.$route.name === 'preview') { + this.$nextTick(() => { + let {width} = document.querySelector('.table div').getBoundingClientRect() + console.log(document.querySelector('.table div').getBoundingClientRect()) + // document.querySelector('.table').scrollLeft + // document.querySelector('.table').scrollTo({left: }) + }) + } + + }, + immediate: true + }, + map () { + this.height = (document.querySelector('.table').getBoundingClientRect().height - 30) / 20 } }, mounted() { @@ -133,47 +222,78 @@ if(this.status ===2) return this.tdMounseDown = false }) - this.map = this.currentMap - if (this.id) { - this.getmachineList() + try { + this.height = (document.querySelector('.table').getBoundingClientRect().height - 30) / 20 + } catch (error) { } + console.log(this.$route.name) }, beforeUpdate() { - this.$el.querySelector('table').removeEventListener('contextmenu', this.contextmenu) + try { + this.$el.querySelector('table').removeEventListener('contextmenu', this.contextmenu) + } catch (error) { + + } + }, updated() { - this.$el.querySelector('table').addEventListener('contextmenu', this.contextmenu) + try { + this.$el.querySelector('table').addEventListener('contextmenu', this.contextmenu) + } catch (error) { + + } }, methods: { - createMap() { - let data = [] - for (var i = 0; i < this.rows; i++) { - let arr = [] - for (var j = 0; j < this.cols; j++) { - arr.push({ - rowspan: 1, - colspan: 1, - rowIndex: i, - colIndex: j, - type: '' - }) - } - data.push(arr) + async createMap() { + let res=true + if (this.id) { + res = await this.$confirm('鐢熸垚鍦板浘灏嗚鐩栧綋鍓嶆墍鏈夎缃紝纭畾閲嶆柊鐢熸垚?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }) + console.log(res) } - this.map = data + if (res || res === 'confirm') { + let data = [] + for (var i = 0; i < this.rows; i++) { + let arr = [] + for (var j = 0; j < this.cols; j++) { + arr.push({ + rowspan: 1, + colspan: 1, + rowIndex: i, + colIndex: j, + type: '' + }) + } + data.push(arr) + } + this.map = data + } }, contextmenu(e) { - if(this.status ===2) return + console.log(e) + if(this.status ===2) return + if (this.range.x === undefined) return // if (this.range.x !=='') return e.preventDefault() e.stopPropagation() let { pageX: left, pageY: top } = e this.showAction = true - let { top: t } = document.querySelector('.map').getBoundingClientRect() - this.position = { - left: left + 'px', - top: top - t + 10 + 'px' + let { top: t } = document.querySelector('.table').getBoundingClientRect() + if (window.innerWidth - left < 100) { + this.position = { + right: 0, + top: top + 10 + 'px' + } + } else { + this.position = { + left: left + 'px', + top: top + 10 + 'px' + } } + }, onMousedown(e, v) { if(this.status ===2) return @@ -229,9 +349,10 @@ } } } - setData(layoutNew) - setRange({x,y,x1:x,y1: y}) - setShowMenu(false) + this.showAction = false + // setData(layoutNew) + // setRange({x,y,x1:x,y1: y}) + // setShowMenu(false) }, sign (type) { const { x, x1, y, y1 } = this.range @@ -239,6 +360,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) } } @@ -246,32 +368,63 @@ this.$forceUpdate() }, addDevice (e,v) { - if(this.status ===2) return e.stopPropagation() - alert('娣诲姞璁惧') + this.addStatus = true + this.deviceId = '' + this.currentAdd = v }, - getmachineList () { - this.$http.post('/machine/list', { - status: '', - plantId: this.id + del () { + this.$confirm('纭畾瑕佹案涔呭垹闄ゆ鍘傛埧锛屽叧鑱旂殑璁惧灏嗛噸缃�?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' }).then(res => { - console.log(res) + this.$http.postJson('/plant/delete',{ + ids: [this.id] + }).then(res => { + this.$message({ + type: 'info', + message: '鍒犻櫎鎴愬姛' + }) + this.$emit('out') + }).catch(() => { + this.$message({ + type: 'info', + message: '鍒犻櫎澶辫触' + }) + }) + }, () => { + this.$message({ + type: 'info', + message: '鍙栨秷鍒犻櫎' + }) }) + }, save () { - if (this.status === 0) { - this.$http.post('/plant/save',{ + if (!this.id) { + this.$http.postJson('/plant/save',{ name: this.plantName, gridSetting: JSON.stringify(this.map) }).then(res => { + this.$message({ + type: 'info', + message: '鎿嶄綔鎴愬姛' + }) + this.$emit('out') console.log(res) }) - } else if(this.status === 1) { - this.$http.post('/plant/modify',{ + } else { + this.$http.postJson('/plant/modify',{ name: this.plantName, gridSetting: JSON.stringify(this.map), id: this.id }).then(res => { + this.$message({ + type: 'info', + message: '鎿嶄綔鎴愬姛' + }) + this.$emit('out') console.log(res) }) } @@ -279,64 +432,207 @@ }, out () { this.$emit('out') + }, + close () { + this.addStatus = false + }, + saveDevice () { + this.setmachineId(this.deviceId) + }, + setmachineId (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.$message({ + type: 'info', + message: '鎿嶄綔鎴愬姛' + }) + } catch (error) { + this.$message({ + type: 'info', + message: '鎿嶄綔澶辫触锛岃閲嶈瘯' + }) + } + this.addStatus = false } }, } </script> <style lang="scss" scoped> + +@keyframes move { + 0% { + // left: 100%; + // transform: translate(0,0); + // scrollTop: 0 + } + 100% { + // left: 100%; + // transform: translate(-100%,0); + // scrollTop: 100% + } +} .map { width: 100%; height: 100%; - overflow: auto; position: relative; -} - -.table-tool { - margin-top: 10px; - display: flex; - justify-content: flex-start; - - &>div { - width: 80px; - margin-inline: 10px; + .map-container { + width: 100%; + height: 100%; + padding: 20px; + overflow: hidden; + position: relative; + display: flex; + flex-direction: column; } } -.table { - padding: 10px; - margin-top: 10px; +.table-tool { + padding-bottom: 50px; display: flex; justify-content: flex-start; - overflow: auto; - + color: #fff; + font-size: 12px; + align-items: center; + &>.input { + min-width: 80px; + max-width: 200px; + margin-inline: 10px; + } + .plant-name { + width: 120px; + margin-left: 20px; + // margin-right: 30px; + text-align: center; + line-height: 28px; + background: rgba(23,38,67,0.6); + border-radius: 14px; + overflow: hidden; + color: #F7F8FA; + font-size: 12px; + border: 1px solid; + border-image: linear-gradient(180deg, rgba(154, 254, 254, 1), rgba(75, 120, 205, 1)) 1 1; + } +} +.table.active { + // position: relative; + // left: 100%; + // animation: move 6s infinite alternate; +} +.table { + // margin-top: 10px; + // display: flex; + // justify-content: flex-start; + width: 100%; + height: 100%; + position: relative; + overflow-x: scroll; + .table-action { - position: absolute; + position: fixed; z-index: 999; color: #fff; - + width: 100px; div { margin-top: 4px; cursor: pointer; } + div:hover { + color: #68D9FF; + } } table { - border: 1px solid #1662DB; + width: 100%; border-collapse: collapse; - table-layout: fixed; - word-wrap: break-word; - + // table-layout: fixed; + // word-wrap: break-word; + overflow: hidden; + border-radius: 10px; + // box-sizing: border-box; td { - width: 50px; - height: 50px; + // width: 50px; + // height: 50px; + box-sizing: border-box; border: 1px solid #1662DB; vertical-align: middle; text-align: center; - img { + & > img { width: 20px; height: 20px; cursor: pointer; + } + .machine { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + & > p { + margin-top: 20px; + color: #E9FFFF; + text-shadow: 0px 1px 11px #549BD4; + background: linear-gradient(180deg, #9AFEFE 0%, #4B78CD 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + text-align: center; + } + & > div { + flex: 1 1 auto; + margin-top: 20px; + display: flex; + align-items: center; + margin-bottom: 20px; + + overflow: hidden; + .img { + width: 50%; + height: 100%; + margin-left: 20px; + border: 1px solid #444C55; + border-radius: 10px; + position: relative; + img { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 80%; + } + } + ul { + flex: 1 1 auto; + height: 100%; + margin-left: 20px; + list-style: none; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-around; + li { + width: 100%; + display: flex; + font-size: 12px; + align-items: center; + & > div { + margin-left: 20px;; + } + p { + color: #E9FFFF; + text-shadow: 0px 1px 11px #549BD4; + } + img { + width: 40px; + height: 40px; + } + } + } + } + } } td.active { @@ -346,7 +642,26 @@ // width: 20px; // height: 20px; background: #1662DB; + div { + // width: 20px; + // height: 20px; + } } + td.device { + // width: 400px; + // height: 400px; + overflow: hidden; + div { + // width: 400px; + } + } + } +} +.grid { + width: 100%; + height: 100%; + div { + border: 1px solid red; } } </style> -- Gitblit v1.9.3