| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471 |
- <!DOCTYPE html>
- <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="icon" href="{{asset('icon/faviconc.ico')}}" type="image/x-icon"/>
- <!-- CSRF Token -->
- <meta name="csrf-token" content="{{ csrf_token() }}">
- <title>设备平面</title>
- <link href="{{ mix('css/app.css') }}" rel="stylesheet">
- <link href="{{ mix('css/animation.css') }}" rel="stylesheet">
- <style>
- html{
- width: 100%;
- height: 100%;
- }
- body{
- width: 100%;
- height: 100%;
- }
- .p1{
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .el-center{
- display:flex;
- align-items:center;
- justify-content:center;
- }
- .el-left-bottom{
- position: absolute;
- bottom: 0;
- left: 0;
- }
- .el-right-bottom{
- position: absolute;
- bottom: 0;
- right: 0;
- }
- .txt-sty{
- filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
- font-family: "Microsoft YaHei Light","sans-serif";
- font-size: 10px;
- white-space:nowrap;
- font-weight:bold;
- }
- .re{transform:rotate(-90deg);
- -ms-transform:rotate(-90deg); /* Internet Explorer 9*/
- -moz-transform:rotate(-90deg); /* Firefox */
- -webkit-transform:rotate(-90deg); /* Safari 和 Chrome */
- -o-transform:rotate(-90deg); /* Opera */
- }
- /*opacity是设置遮罩透明度的,可以自己调节*/
- #loading{position:fixed;top:0;left:0;width:100%;height:100%;background:#f8f8f8;opacity:0.6;z-index:15000;}
- #loading i{position:absolute;top:50%;left:50%;font-size:33px;margin-top:-15px;margin-left:-40px;}
- #loading p{position:absolute;top:55%;left:48%;width:33px;height:33px;margin-top:-15px;margin-left:-15px;}
- .equipment{
- cursor: pointer
- }
- .equipment-exist{
- border-width:2px;
- border-style: groove;
- border-color: #0000FF;
- }
- .equipment-not-exist{
- opacity: 0.5;
- border-width:1px;
- border-style: dashed;
- border-color: #0070C0;
- }
- </style>
- </head>
- <body>
- <div class="container-fluid w-100 h-100" id="container" @mousemove="eqMove()" @mouseup="eqUp()">
- <div class="row w-100 h-100">
- <div class="col-2 " style="user-select: none;" id="tool">
- <div class="dropdown">
- <button type="button" class="btn p-0 w-100" id="dropdownMenu"
- data-toggle="dropdown">
- <h4 class="text-muted mt-1 p1">@{{ name }} <i class="fa fa-exchange text-info"></i></h4>
- </button>
- <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
- <li role="presentation" v-for="warehouse in warehouses" v-if="warehouse.id!==selected">
- <a role="menuitem" tabindex="-1" style="cursor: pointer" class="ml-3"
- @click="selectedWarehouse(warehouse)">@{{ warehouse.name }}</a>
- </li>
- <li role="presentation" class="text-center" @click="showAddWarehouseDetail()">
- <a role="menuitem" tabindex="-1" style="cursor: pointer" class="ml-3 text-primary"
- ><i class="fa fa-plus"></i> 新增</a>
- </li>
- </ul>
- </div>
- <button class="btn btn-info mt-5 w-100 text-white" @click="openRepository()">新增库区</button>
- <button class="btn btn-success mt-5 w-100 text-white" @click="searchingSelectEq()">批量构建库位</button>
- <p class="font-weight-bold p-0 mb-0 mt-1">位置</p>
- <div class="row text-muted small">
- <small class="col-6">X</small>
- <small class="col-6">Y</small>
- </div>
- <div class="row m-0 p-0">
- <input type="number" class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.x"
- @blur="changeNumber('x')"></input>
- <input type="number" class="col-5 offset-1 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.y"
- @blur="changeNumber('y')"></input>
- </div>
- <p class="font-weight-bold p-0 mb-0 mt-3">大小</p>
- <div class="row text-muted small">
- <small class="col-6">高</small>
- <small class="col-6">宽</small>
- </div>
- <div class="row m-0 p-0">
- <input type="number" class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.height" @blur="changeNumber('height')"></input>
- <input type="number" class="col-5 offset-1 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.width" @blur="changeNumber('width')"></input>
- </div>
- <p class="font-weight-bold p-0 mb-0 mt-3">其他</p>
- <div class="row text-muted small">
- <small class="col-6">层级</small>
- <small class="col-6">颜色</small>
- </div>
- <div class="row m-0 p-0">
- <input type="number" class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.index" @blur="changeNumber('index')"></input>
- <input class="col-5 offset-1 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.color" @blur="changeText('color')"></input>
- </div>
- <div class="row text-muted small">
- <small class="col-6">名称</small>
- <small class="col-6">名称位置</small>
- </div>
- <div class="row m-0 p-0">
- <input class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.name" @blur="changeText('name')"></input>
- <select class="col-5 offset-1 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" v-model="currentEl.coords">
- <option value="左上">左上</option>
- <option value="左下">左下</option>
- <option value="右上">右上</option>
- <option value="右下">右下</option>
- <option value="居中">居中</option>
- <option value="中上">中上</option>
- </select>
- </div>
- <div class="row text-muted small">
- <small class="col-6">边框</small>
- </div>
- <div class="m-0 small row">
- <div class="col-6 p-0">
- <div class="form-check">
- <label class="form-check-label">
- <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="top" :disabled="currentEl.x===undefined">上
- </label>
- </div>
- <div class="form-check">
- <label class="form-check-label">
- <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="bottom" :disabled="currentEl.x===undefined">下
- </label>
- </div>
- <div class="form-check">
- <label class="form-check-label">
- <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="left" :disabled="currentEl.x===undefined">左
- </label>
- </div>
- <div class="form-check">
- <label class="form-check-label">
- <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="right" :disabled="currentEl.x===undefined">右
- </label>
- </div>
- </div>
- <div class="col-6 p-0">
- <div class="form-check">
- <label class="form-check-label">
- <button class="btn btn-sm btn-success" @click="addCoords()">生成场景元素</button>
- </label>
- </div>
- <div class="form-check mt-1">
- <label class="form-check-label">
- <button class="btn btn-sm btn-success" @click="openBuildEquipmentGroup()">构建设备组</button>
- </label>
- </div>
- </div>
- </div>
- <p class="font-weight-bold p-0 mb-0 mt-5 h5">全局</p>
- <div class="row text-muted">
- <div class="col-4">缩放</div>
- <div class="input-group input-group-sm col-8 m-0">
- <input type="number" class="form-control" step="1" v-model="scale"></input>
- <div class="input-group-append">
- <span class="input-group-text">%</span>
- </div>
- </div>
- </div>
- <div class="row text-muted mt-1">
- <div class="col-4">库位比</div>
- <div class="input-group input-group-sm col-8 m-0">
- <input class="switch" type="checkbox" @change="loadElement()"/>
- </div>
- </div>
- <div class="row mt-3">
- <h5 class="font-weight-bold ml-3">设备</h5>
- <div class="form-check ml-3">
- <label class="form-check-label">
- <input type="checkbox" class="form-check-input" v-model="grid">网格
- </label>
- <label class="form-check-label ml-4">
- <input type="checkbox" class="form-check-input" v-model="turn">翻转
- </label>
- </div>
- </div>
- <div style="height: 250px;overflow-y: auto;overflow-x: hidden" class="w-100">
- <div class="row" v-for="equipment in equipments" @mousedown="eqDown(equipment)">
- <div class="col-5">
- <div style="border: 1px #0070C0 solid" :style="[{backgroundColor:equipment.color},{width:(equipment.h*ratio)+'px'},{height:(equipment.w*ratio)+'px'}]"></div>
- </div>
- <div class="col-7 p1">
- @{{ equipment.describe }}
- </div>
- </div>
- </div>
- <button @click="clickEditOrSave()" :class="isNotEdit ? 'btn-info' : 'btn-success'"
- style="position:absolute;bottom: 20px;cursor: pointer" class="btn col-10 text-white">
- <span v-if="isNotEdit">开启场景编辑</span>
- <span v-else>保存更改</span>
- </button>
- </div>
- <div class="col-10 p-0">
- <div class="w-100 bg-secondary" id="canvasApp" style="height: 100vh;overflow: auto;user-select: none;">
- <div id="canvas" v-if="isLoad" @keydown.delete="delElement()" :style="[{width:container.width*(scale/100)+'px'},{height:container.height*(scale/100)+'px'},{transform: 'scale('+(scale/100)+')'}]"
- style="position: relative;transform-origin: 0 0" class="bg-white"
- @mousedown="contentOnmousedown" @mousemove="contentOnmousemove" @mouseup="contentOnmouseup">
- <vue-drag-resize v-for="(element,index) in elements" v-if="!element.removeSign"
- @activated="onActivated(element)"
- @dragging="onDragging"
- @resizing="onResizing"
- :minw="1" :minh="1"
- :style="[{backgroundColor:element.color},
- element.border.indexOf('left')===-1 ? {borderLeft:'none'} : {},
- element.border.indexOf('right')===-1 ? {borderRight:'none'} : {},
- element.border.indexOf('top')===-1 ? {borderTop:'none'} : {},
- element.border.indexOf('bottom')===-1 ? {borderBottom:'none'} : {}]"
- style="border-width:1px;border-color: #000000;border-style: solid"
- :key="index" :prevent-active-behavior="isNotEdit"
- :parent-limitation="true" :w="element.width*ratio" :h="element.height*ratio"
- :x="element.x" :y="element.y" :z="element.index">
- <div :class="coordsMapping[element.coords]">@{{ element.name }}</div>
- </vue-drag-resize>
- <vue-drag-resize class="equipment"
- v-for="(element,index) in equipmentElements" @clicked="showDetail(element)"
- :id="'eq-'+index" :class="element.exist ? 'equipment-exist' : 'equipment-not-exist'"
- v-if="!element.removeSign"
- :is-resizable="false" :snap-to-grid="grid" :grid-x="40" :grid-y="30"
- :style="[{backgroundColor:element.color}]"
- @activated="onActivated(element)"
- @dragging="equipmentDrag"
- :key="'eq-'+index+element.turn" :prevent-active-behavior="isNotEdit"
- :parent-limitation="true" :w="(element.turn ? element.w : element.h)*ratio"
- :h="(element.turn ? element.h : element.w)*ratio"
- :x="element.x" :y="element.y" :z="90">
- <div class="h-100 w-100" v-if="isShowRatio">
- <div class="h-100 w-100 p-0" v-if="element.children && element.children.length>0">
- <div :style="{height:100/element.children.length+'%'}" v-for="(child,idx) in element.children"
- :class="(element.children[element.children.length-1-idx]).location_tab==='0-0' ? '' : 'bg-danger'"
- class="border border-dark text-dark small el-center w-100 m-0">
- @{{ (element.children[element.children.length-1-idx]).location_tab | formatCount }}
- </div>
- </div>
- <div class="h-100 w-100 txt-sty el-center" v-else>
- <i class="fa fa-spinner fa-spin"></i>
- </div>
- </div>
- <div class="h-100 txt-sty w-100 el-center" :class="element.turn ? 're' : ''" v-else>@{{ element.code}}</div>
- </vue-drag-resize>
- </div>
- </div>
- </div>
- <textarea hidden id="clipboardDiv" style="opacity:0"></textarea>
- <div id="loading" class="list-item">
- <i class="fa fa-spinner fa-spin"></i>
- <p style="line-height: 24px;">loading...</p>
- </div>
- </div>
- @include("equipment._detailInfo")
- @include("equipment._location")
- @include("equipment._warehouseDetail")
- @include("equipment._repository")
- @include("equipment._buildGroup")
- @include("equipment._locationAttr")
- @include("equipment._failTipList")
- </div>
- </body>
- <script src="{{ mix('js/app.js') }}"></script>
- <script src="{{ asset('js/utilities/drawCheckbox.js') }}"></script>
- <script src="{{ asset('js/utilities/h2can.min.js') }}"></script>
- <script src="{{ asset('js/utilities/jcanvas.min.js') }}"></script>
- <script src="{{ asset('js/utilities/toast.js') }}"></script>
- <script type="text/javascript">
- var vue = new Vue({
- el:"#container",
- data:{
- increment:true,
- group:[],//库区列表
- ws:[],//仓库列表
- locationMapping:{},//库位的信息映射
- warehouseDetail:{},//当前操作的仓库
- repository:{},//当前操作的库区
- warehouses:[], //仓库描述
- repositories:[], //库区
- selected:"", //当前选中的仓库ID
- container:{width:90,height:60}, //容器初始大小
- ratio:20, //设备大小缩放比例值
- name:"", //当前选中的仓库NAME
- isNotEdit:true, //是否允许编辑
- isLoad:true, //是否加载
- currentEl:{}, //当前选中的元素
- coordsMapping:{ //元素信息映射
- "居中":"h-100 w-100 el-center",
- "中上":"text-center",
- "左上":"",
- "左下":"el-left-bottom",
- "右上":"text-right",
- "右下":"el-right-bottom",
- },
- elements:[], //场景元素池
- clientCoords:{}, //坐标系记录
- scale:100, //缩放值
- equipments:[ //备选设备池
- ],
- currentEq:{ //选中的设备
- el:null,
- obj:null,
- },
- equipmentElements:[], //设备元素池
- grid:false, //设备拖拽是否开启网格
- turn:true, //设备是否翻转
- isLoadLocation:false, //开启加载库位
- //baseUrl:"http://127.0.0.1:8112/",
- baseUrl:"https://api.baoshi56.com/",
- current:{}, //当前操作的设备
- error:{},
- locations:[], //库位信息
- currentEqChildIndex:null, //当前节点下标
- buildPool:{}, //库位构建信息
- client:{}, //复制后的坐标记录
- buildEqInfo:{}, //设备组构建信息
- charArr : [...Array(26).keys()].map(i => String.fromCharCode(i + 65)), //A-Z字符
- elSeList:[
- {id:-1,w:1.2,h:2.4,grid:2,color:"RGB(255,255,0)",describe:"消防栓设施或立柱,不可设库位"},
- ],//场景元素预设列表
- locationAttr:null,//库位建立时的可选择属性
- batchEquipment:{
- },//设备类型 与设备下标的映射
- batchEquipmentSign:"",//当前选择的batchEquipment下标
- batchSign:false,//当前是否为批量构建
- failTipList:{},//构建失败的库位提示信息
- isShowRatio:undefined,//是否展示库位现存比例
- },
- mounted() {
- this._loadEquipmentCategory().then(()=>{
- this.initPage();
- let content = document.getElementById("canvasApp");
- content.onmousemove = (event)=>{
- this.client = {x:event.clientX,y:event.clientY};
- }
- })
- },
- computed:{
- flipLayer(){
- let layer = [];
- for (let i=this.current.layer;i>0;i--){
- layer.push(i);
- }
- return layer;
- },
- flipChildren(){
- if(!this.current.children){
- return [];
- }
- let children = [];
- for (let i=this.current.children.length - 1;i>=0;i--){
- let obj = this.current.children[i];
- obj.idx = i+1
- children.push(obj);
- }
- return children;
- },
- },
- created: function() {
- let content = document.getElementById("canvasApp");
- document.onkeydown = e=> {
- if (this.isNotEdit || !this.current)return;
- let key = e.keyCode;
- if (key === 8) {
- this.delElement();
- }
- if(key===67 && e.ctrlKey){
- this.copyEle();
- }
- if(key===86 && e.ctrlKey){
- let val = $('#clipboardDiv').val();
- if (!val || JSON.stringify(val)==="{}")return;
- let toolWid = document.getElementById("tool").offsetWidth;
- let obj = Object.assign({},JSON.parse(val));
- obj.x = this.client.x-toolWid+content.scrollLeft;
- obj.y = this.client.y+content.scrollTop;
- obj.children = [];
- for (let i=0;i<obj.layer;i++)obj.children.push({});
- if (this.currentEl.eqId){
- obj.eqId = undefined;
- this.current = obj;
- this.currentEl = obj;
- this.showAddModal(obj);
- }else{
- this.elements.push(obj);
- }
- }
- };
- },
- methods:{
- // 加载设备种类
- _loadEquipmentCategory() {
- return new Promise((resolve, reject)=>{
- $.ajax({
- url : this.baseUrl+"api/base/equipment/category",
- type : "GET",
- success : (res,status)=>{
- if(res.code != 200 || !res.data) {
- window.tempTip.show(res.message);
- return;
- }
- /*
- * {id:1,w:1.2,h:2.4,grid:2,layer:4,color:"RGB(252,228,214)",describe:"4层高位货架,可设八个标准托盘位"},
- {id:2,w:1.2,h:2.4,grid:2,layer:5,color:"RGB(255,255,255)",describe:"5层高位货架,可设十个标准托盘位"},
- {id:3,w:1.2,h:3.3,grid:3,layer:1,color:"RGB(169,208,142)",describe:"叉车通道,可设三个标准托盘位"},
- {id:4,w:1.2,h:3.3,grid:3,layer:2,color:"RGB(221,235,247)",describe:"叉车通道,可设六个标准托盘位"},
- {id:5,w:1.2,h:1.2,grid:1,layer:4,color:"RGB(255,255,0)",describe:"半组货架,可设四层高四个标准托盘位"},
- {id:6,w:1.2,h:2.4,grid:2,layer:1,color:"RGB(189,215,238)",describe:"叉车通道,顶上两个托盘位"},
- {id:7,w:1.2,h:1.2,grid:1,layer:5,color:"RGB(255,255,5)",describe:"半组货架,可设五层高五个标准托盘位"},
- {id:8,w:1.2,h:3.3,grid:3,layer:4,color:"RGB(146,208,80)",describe:"4层高位货架,可设十二个标准托盘位"},
- {id:9,w:1.2,h:2.4,grid:2,layer:2,color:"RGB(228,243,211)",describe:"叉车通道,可设四个标准托盘位"},
- {id:10,w:1,h:2,grid:1,layer:4,color:"RGB(211,160,160)",describe:"小型货架"},
- * */
- let equipments = [];
- if (res.data.length > 0) {
- res.data.forEach(category => {
- let info = JSON.parse(category.info);
- equipments.push({
- "id":category.id,
- "w":category.depth,
- "h":category.width,
- "grid":info.grid,
- "layer":category.layer,
- "color":info.color,
- "describe":category.name,
- });
- });
- }
- this.equipments = equipments;
- resolve();
- },
- error : (err,status)=>{
- window.tempTip.show("设备种类加载失败");
- },
- timeout:3000,
- })
- });
- },
- //仓库切换
- selectedWarehouse(warehouse){
- this.isLoad = false;
- setTimeout(()=>{
- this.selected = warehouse.id;
- this.name = warehouse.name;
- this.ratio = warehouse.ratio;
- this.container = {width:warehouse.length*this.ratio,height:warehouse.width*this.ratio};
- localStorage.setItem("equipment:warehouse", warehouse.id);
- $.ajax({
- url : this.baseUrl+"api/base/warehouse/detail/getCoordsInfo",
- type : "post",
- dataType : "JSON",
- data : {id:warehouse.id},
- success : (res,status)=>{
- this.elements = res.data[0] ? JSON.parse(res.data[0]) : [];
- if(res.data[1] && res.data[1].length>0){
- let equipmentElements = [];
- res.data[1].forEach(eq=>{
- let coords = JSON.parse(eq.info);
- let selfInfo = this.getCategory(coords.id);
- equipmentElements.push(Object.assign({
- eqId:eq.id,
- exist:eq.exist,
- code:eq.code,
- repository:eq.repositoryId,
- x:coords.x,
- y:coords.y,
- turn:!!coords.turn,
- },selfInfo));
- });
- this.equipmentElements = equipmentElements;
- }else this.equipmentElements = [];
- this.repositories = res.data[2];
- this.isNotEdit = true;
- this.isLoad = true;
- },
- error : (err,status)=>{
- window.tempTip.show("坐标信息加载失败");
- },
- timeout:30000,
- })
- },200);
- },
- getCategory(id) {
- for (let i = 0; i < this.equipments.length; i++) {
- if(Number(id) === Number(this.equipments[i].id)) {
- return this.equipments[i];
- }
- }
- return {}
- },
- /**
- * 初始页加载
- */
- initPage(){
- $.ajax({
- url : this.baseUrl+"api/base/warehouse/detail",
- type : "GET",
- success : (res,status)=>{
- this.warehouses = res.data;
- //这里获取warehouses
- let id = localStorage.getItem("equipment:warehouse");
- if (!id || !this.warehouses.some(warehouse=>{
- if (warehouse.id == id){
- this.selectedWarehouse(warehouse);
- return true;
- }
- })
- ){
- if (this.warehouses.length>0)this.selectedWarehouse(this.warehouses[0]);
- }
- $("#loading").hide();
- },
- error : (err,status)=>{
- window.tempTip.show("加载失败");
- },
- timeout:3000,
- })
- },
- flipArr(arr){
- let flip = [];
- for (let i=arr.length-1;i>=0;i--){
- flip.push(arr[i]);
- }
- return flip;
- },
- loadElement(){
- if (this.isShowRatio===undefined){
- this.isShowRatio = true;
- this.equipmentElements.forEach(eq=>{
- if (eq.exist){
- this.getChildren(eq);
- }else if(!eq.children){
- eq.children = [];
- }
- });
- }else{
- this.isShowRatio = !this.isShowRatio;
- }
- },
- //获取库位的可选择属性
- _getLocationAttr(){
- if (this.locationAttr!==null){
- return;
- }
- $.ajax({
- url : this.baseUrl+"api/base/location/getAttr",
- type : "post",
- dataType : "JSON",
- success : (res,status)=>{
- if (res.code===200){
- this.locationAttr = res.data;
- }else{
- window.toast.error(res.message);
- }
- },
- error : (err,status)=>{
- window.toast.error("库位选择属性加载失败");
- },
- timeout:3000,
- })
- },
- /**
- * 显示设备编码列表
- */
- showEquipmentCode(arr){
- event.stopPropagation();
- let obj = {};
- arr.forEach(index=>{
- obj[this.equipmentElements[index].code] = "";
- });
- this.failTipList = obj;
- $("#failTipList").modal("show");
- },
- //检索所有元素,获取在指定范围内的元素
- searchingSelectEq(){
- afterExt = function (){
- new Promise(function(resolve, reject) {
- let result = [];
- let els = $(".equipment");
- for (let i=0;i<els.length;i++){
- let client = els[i].getBoundingClientRect();
- if (client.x<0 || client.y<0){
- continue;
- }
- //四个角全部包含在此区域内 将元素下标加入结果数组
- if (client.x>=clipInfo.x && client.y>=clipInfo.y && client.x<=(clipInfo.x+clipInfo.w) && client.y<=(clipInfo.y+clipInfo.h)
- && (client.x+client.width)<=(clipInfo.x+clipInfo.w) && (client.y+client.height)<=(clipInfo.y+clipInfo.h)){
- result.push(els[i].id.split('-')[1]);
- }
- }
- resolve(result);
- }).then(indexArr=>{
- if (indexArr.length===0){
- toast.error("未选中任何设备");
- return;
- }
- vue.batchOperationEquipment(indexArr);
- });
- }
- clipScreenshots();
- },
- /**
- * 批量选中设备后唤起构建器
- */
- batchOperationEquipment(indexArr){
- this.current = {};
- let obj = {};
- indexArr.forEach(index=>{
- let eq = this.equipmentElements[index];
- let eqTypeIndex = this._getEqTypeIndex(eq.id);
- if (!obj[eqTypeIndex])obj[eqTypeIndex] = [];
- obj[eqTypeIndex].push(index);
- });
- this.batchEquipment = obj;
- $("#locationAttr").modal('show');
- },
- /**
- * 根据库位类型ID获取库位类型下标
- */
- _getEqTypeIndex(id){
- //当前是ID为下标+1,所以直接ID-1获取下标
- return id-1;
- for (let i=0;i<this.equipments.length;i++){
- if (this.equipments[i].id==id){
- return i;
- }
- }
- return null;
- },
- buildComponent(eq){
- let component = {
- "x":eq.x,"y":eq.y,"width":eq.turn ? eq.w : eq.h,"height":eq.turn ? eq.h : eq.w,"name":"","color":eq.color,
- "coords":"居中","border":["left","top","right","bottom"],"index":2
- };
- this.elements.push(component);
- },
- buildEquipment(eq){
- let children = [];
- let lastHeight = 1;
- for (let i=0;i<eq.layer;i++){
- let obj = this.currentEl.children[i];
- if (obj)lastHeight = obj.height;
- children.push({
- "height" : lastHeight,
- "row" : 0,
- "column" : 0,
- });
- }
- eq.children = children;
- this.equipmentElements.push(eq);
- this.exeSave(this.equipmentElements[this.equipmentElements.length-1]);
- },
- buildEquipmentGroup(){
- let x = this.currentEl.turn ? this.currentEl.x : Number(this.currentEl.x)+(Number(this.currentEl.w)*this.ratio);
- let y = this.currentEl.turn ? Number(this.currentEl.y)+(Number(this.currentEl.h)*this.ratio) : this.currentEl.y;
- this.buildEqInfo.list.forEach(eq=>{
- eq.x = x;
- eq.y = y;
- if (eq.id<0)this.buildComponent(eq); //构建组件
- else this.buildEquipment(eq); //构建设备
- if (this.currentEl.turn){
- y += eq.h*this.ratio+0.5;
- }else{
- x += eq.h*this.ratio+0.5;
- }
- });
- window.toast.success("构建完毕");
- this.buildEqInfo = {};
- $("#buildGroup").modal("hide");
- },
- getLastChar(str){
- let lastChar = str.substr(-1,1);
- if (lastChar.search(/[A-Z]/g)===0){
- let index = this.charArr.indexOf(lastChar);
- let residualCount = this.charArr.length-(index+1);
- if (residualCount<this.buildEqInfo.count)return null;
- return {type:"CHAR",val:index};
- }
- if (lastChar.search(/[\d]/g)===0){
- let strs = str.replace(/[^\d]/g,'*');
- let strsArr = strs.split('*');
- return {type:"NUMBER",val:strsArr[strsArr.length-1]};
- }
- return null;
- },
- buildGroup(){
- let count = this.buildEqInfo.count;
- if (!count)return;
- let result = this.getLastChar(this.currentEl.code);
- if(!result){
- window.toast.error("此设备编码不符合组规则");
- return;
- }
- let codeTran = (index)=>{
- let size = result.val.toString().length;
- let val;
- if(result.type==="CHAR"){
- if (this.increment){
- val=this.charArr[result.val+index];
- }else{
- val=this.charArr[result.val-index];
- }
- }else{
- if (this.increment){
- val=Number(result.val)+index;
- }else{
- val=Number(result.val)-index;
- }
- if (val.toString().length<size){
- val = (Array(size).join('0') + val).slice(-size);
- }
- }
- return this.currentEl.code.substr(0,this.currentEl.code.length-size)+val;
- };
- let list = [];
- for (let i=1;i<=count;i++){
- let obj = Object.assign({},this.currentEl);
- obj.eqId = undefined;
- obj.updateCoords = undefined;
- obj.code = codeTran(i);
- list.push(obj);
- }
- this.$set(this.buildEqInfo,"list",list);
- },
- pitchEq(el,index){
- this.$set(this.buildEqInfo,"current",index);
- this.$set(this.buildEqInfo,"currentEqId",el.id);
- },
- switchEq(el){
- if (this.buildEqInfo.currentEqId===el.id)return;
- let obj = this.buildEqInfo.list[this.buildEqInfo.current];
- obj.id = el.id;
- obj.w = el.w;
- obj.h = el.h;
- obj.describe = el.describe;
- obj.grid = el.grid;
- obj.layer = el.layer;
- obj.color = el.color;
- obj.width = el.w;
- obj.depth = el.h;
- this.$set(this.buildEqInfo,"currentEqId",el.id);
- },
- openBuildEquipmentGroup(){
- if (this.isNotEdit || !this.currentEl.eqId){
- window.toast.error("未开启编辑或未选中设备");
- return;
- }
- setTimeout(()=>{
- this.getChildren(this.currentEl);
- $("#buildGroup").modal("show");
- },100);
- },
- delCoords(){
- this.elements.some((el,index)=>{
- if (this.currentEl.name === el.name &&
- this.currentEl.x === el.x && this.currentEl.y === el.y){
- this.$set(this.elements[index],"removeSign",true);
- return true;
- }
- })
- },
- copyEle(){
- if (this.currentEl!=null && JSON.stringify(this.currentEl)!=="{}"){
- $('#clipboardDiv').text(JSON.stringify(this.currentEl));
- }
- },
- delEquipment(){
- this.equipmentElements.some((el,index)=>{
- if (this.currentEl.eqId === el.eqId){
- this.$set(this.equipmentElements[index],"removeSign",true);
- return true;
- }
- })
- },
- delElement(){
- if (this.currentEl.eqId)this.delEquipment();
- else this.delCoords();
- },
- addCoords(){
- if (this.isNotEdit)return;
- this.elements.push({"x":200,"y":200,"width":2,"height":2,"name":"","coords":"居中","border":["left","top","right","bottom"],"color":"white","index":1})
- },
- clickEditOrSave(){
- if(this.isNotEdit){this.isNotEdit = false;return;}
- let equipments = [];
- let delEquipments = [];
- let elements = [];
- this.equipmentElements.forEach(equipment=>{
- if (equipment.removeSign){
- delEquipments.push(equipment.eqId);
- }else if (equipment.updateCoords){
- equipments.push({
- id:equipment.eqId,
- info:JSON.stringify({x:equipment.x,y:equipment.y,id:equipment.id,turn:equipment.turn})
- });
- }
- });
- this.elements.forEach(el=>{
- if (!el.removeSign){
- elements.push(el);
- }
- });
- $.ajax({
- url : this.baseUrl+"api/base/warehouse/saveScene",
- type : "POST",
- headers:{'Content-Type':'application/json;charset=utf8'},
- data:JSON.stringify({id:this.selected,warehouse:JSON.stringify(elements),equipment:equipments,delEquipments:delEquipments}),
- success : (res,status)=>{
- if (res.code===200){
- this.isNotEdit = true;
- window.toast.success("场景更改保存成功");
- }else window.toast.error(res.message);
- },
- error : (err,status)=>{
- window.tempTip.show("加载失败");
- },
- complete:(req,status)=>{
- if (status==='timeout'){
- window.toast.error("服务器响应超时");
- }
- },
- timeout:10000,
- })
- },
- //备选设备拖拽按下事件
- eqDown(equipment){
- if (this.isNotEdit)return;
- if (this.currentEq.obj!==null)return;
- let wid = (this.turn ? equipment.w : equipment.h)*this.ratio;
- let hei = (this.turn ? equipment.h : equipment.w)*this.ratio;
- let div = document.createElement("div");
- div.style.width = wid+'px';
- div.style.height = hei+'px';
- div.style.backgroundColor = equipment.color;
- div.style.zIndex = '999';
- div.style.position = 'fixed';
- div.style.left = event.clientX+'px';
- div.style.top = event.clientY+'px';
- div.style.border = '1px #0070C0 solid';
- div.style.opacity = '0.5';
- document.getElementById("container").append(div);
- this.currentEq.el = div;
- this.currentEq.obj = equipment;
- },
- //备选设备拖拽移动事件
- eqMove(){
- if (this.isNotEdit)return;
- if (this.currentEq.obj===null)return;
- let x = event.clientX;
- let y = event.clientY;
- setTimeout(()=>{
- this.currentEq.el.style.left = x+'px';
- this.currentEq.el.style.top = y+'px';
- },10);
- },
- //备选设备拖拽松开事件
- eqUp(){
- if (this.isNotEdit)return;
- if (this.currentEq.obj===null)return;
- this.currentEq.el.remove();
- setTimeout(()=>{
- this.currentEq.el.remove();
- this.currentEq.el = null;
- },20);
- let content = document.getElementById("canvasApp");
- let toolWid = document.getElementById("tool").offsetWidth;
- let x = event.clientX-toolWid+content.scrollLeft;
- let y = event.clientY+content.scrollTop;
- if (x>=0 && y>=0){
- let children = [];
- for (let i=0;i<this.currentEq.obj.layer;i++)children.push({});
- let newEquipment = Object.assign({children:children,x:x,y:y}, this.currentEq.obj);
- newEquipment.turn = this.turn;
- newEquipment.width = newEquipment.w;
- newEquipment.depth = newEquipment.h;
- this.showAddModal(newEquipment);
- }
- this.currentEq.obj = null;
- },
- showAddModal(equipment){
- this.equipmentElements.push(equipment);
- this.current = this.equipmentElements[this.equipmentElements.length-1];
- setTimeout(()=>{
- $("#detailInfo").modal("show");
- },20);
- },
- //场景拖拽按下事件
- contentOnmousedown(event){
- if (!this.isNotEdit || this.clientCoords.x!==undefined)return;
- this.clientCoords = {
- x:event.clientX,
- y:event.clientY
- };
- },
- //场景拖拽移动事件
- contentOnmousemove(event){
- if (this.clientCoords.x===undefined)return;
- let diffX = event.clientX-this.clientCoords.x-2;
- let diffY = event.clientY-this.clientCoords.y-2;
- let content = document.getElementById("canvasApp");
- setTimeout(()=>{
- content.scrollTo(content.scrollLeft+diffX,content.scrollTop+diffY);
- },10);
- },
- //场景拖拽松开事件
- contentOnmouseup(){
- this.clientCoords = {};
- },
- onActivated(element){
- if (this.isNotEdit)return;
- this.currentEl = element;
- },
- //场景大小调整事件
- onResizing(newRect){
- if (this.isNotEdit)return;
- this.currentEl.width=this.accDiv(newRect.width,this.ratio);
- this.currentEl.height=this.accDiv(newRect.height,this.ratio);
- },
- accDiv(arg1,arg2){
- let t1=0,t2=0,r1,r2;
- try{t1=arg1.toString().split(".")[1].length}catch(e){}
- try{t2=arg2.toString().split(".")[1].length}catch(e){}
- with(Math){
- r1=Number(arg1.toString().replace(".",""))
- r2=Number(arg2.toString().replace(".",""))
- return this.accMul((r1/r2),pow(10,t2-t1));
- }
- },
- accMul(arg1,arg2){
- let m=0,s1=arg1.toString(),s2=arg2.toString();
- try{m+=s1.split(".")[1].length}catch(e){}
- try{m+=s2.split(".")[1].length}catch(e){}
- return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
- },
- //场景拖拽事件
- onDragging(newRect){
- if (this.isNotEdit)return;
- this.currentEl.x=newRect.left;
- this.currentEl.y=newRect.top;
- $("#canvas").focus();
- },
- equipmentDrag(newRect){
- if (this.isNotEdit)return;
- this.currentEl.x=newRect.left;
- this.currentEl.y=newRect.top;
- this.currentEl.updateCoords = true;
- $("#canvas").focus();
- },
- //文本类属性改变
- changeText(key){
- this.currentEl[key] = event.target.value;
- },
- //数值类属性改变
- changeNumber(key){
- let val = event.target.value;
- this.currentEl[key] = val ? parseFloat(val) : 0;
- },
- _getObjFirstKey(obj){
- for(let key in obj){
- return key;
- }
- return null;
- },
- /**
- * 构建库位的默认值信息
- * */
- _locationAttrDefault(){
- this.buildPool.usage = this._getObjFirstKey(this.locationAttr.usage);
- this.buildPool.handling = this._getObjFirstKey(this.locationAttr.handling);
- this.buildPool.attribute = this._getObjFirstKey(this.locationAttr.attribute);
- this.buildPool.category = this._getObjFirstKey(this.locationAttr.category);
- this.buildPool.demand = this._getObjFirstKey(this.locationAttr.demand);
- this.buildPool.mixFlag = true;
- this.buildPool.mixLotFlag = false;
- this.buildPool.loseIdFlag = true;
- },
- /**
- * 批量构建库位时的操作
- * */
- nextDetailBatch(index){
- if (!this.current.children || this.current.children.length===0){
- window.toast.error("设备信息尚未加载完毕,请稍后重试!");
- return;
- }
- this.batchSign = true;
- this.currentEqChildIndex = index-1;
- setTimeout(function (){
- let parentDom = document.getElementById("locationAttr").firstChild.firstChild;
- let childDom = document.getElementById("locationModal").firstChild.firstChild;
- childDom.style.minWidth = parentDom.offsetWidth+'px';
- childDom.style.minHeight = parentDom.offsetHeight+'px';
- $("#locationModal").modal("show");
- },20);
- this._locationAttrDefault();
- },
- //子设备选定时的库位加载
- nextDetail(index){
- if (!this.current.eqId) {
- window.tempTip.index = 1050;
- window.tempTip.inputVal("子设备编码", (val)=> {
- this.$set(this.current.children[index-1], 'code', val);
- })
- return;
- }
- this.batchSign = false;
- this.currentEqChildIndex = index-1;
- let children = this.current.children[index-1];
- this.isLoadLocation = true;
- this._locationAttrDefault();
- setTimeout(function (){
- let parentDom = document.getElementById("detailInfo").firstChild.firstChild;
- let childDom = document.getElementById("locationModal").firstChild.firstChild;
- childDom.style.minWidth = (parentDom.offsetWidth+200)+'px';
- childDom.style.minHeight = parentDom.offsetHeight+'px';
- $("#locationModal").modal("show");
- },20);
- this.current.children.forEach(item=>{
- item.row = Number(item.row);
- item.column = Number(item.column);
- });
- $.ajax({
- url : this.baseUrl+"api/base/location/get",
- type : "post",
- dataType : "JSON",
- data : {id:children.id},
- success : (res)=>{
- switch (res.code){
- case 200:
- this.locations = res.data[0];
- this.locationMapping = res.data[1] ? res.data[1] : {};
- this.isLoadLocation = false;
- break;
- default:
- window.toast.error(res.message);
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- timeout:3000,
- })
- },
- showDetail(equipment){
- this._getLocationAttr();
- if (!this.isNotEdit)return;
- this.current = equipment;
- setTimeout(()=>{
- $("#detailInfo").modal("show");
- this.contentOnmouseup();
- },20);
- this.getChildren(this.current);
- },
- getChildren(equipment){
- if (equipment.children && equipment.children.length>0){
- return;
- }
- $.ajax({
- url : this.baseUrl+"api/base/equipment/getChildren",
- type : "post",
- dataType : "JSON",
- data : {id:equipment.eqId},
- success : (res)=>{
- switch (res.code){
- case 200:
- res.data.forEach(eq=>{
- let tab = eq.location_tab.split("-");
- eq.row = Number(tab[0]);
- eq.column = Number(tab[1]);
- });
- this.$set(equipment,"children",res.data);
- break;
- default:
- window.toast.error("服务器错误");
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- timeout:3000,
- })
- },
- saveOrUpdate(){
- this.error = {};
- let error = this._checkEquipmentData(this.current);
- if (JSON.stringify(error)!=="{}"){
- console.log(error)
- this.error = error;return;
- }
- this.exeSave(this.current);
- },
- exeSave(equipment){
- let params = this._formatEquipmentData(equipment);
- params.warehouseDetailId = this.selected;
- $.ajax({
- url : this.baseUrl+"api/base/equipment/saveOrUpdate",
- type : "post",
- dataType : "JSON",
- headers:{'Content-Type':'application/json;charset=utf8'},
- data : JSON.stringify(params),
- success : (res)=>{
- switch (res.code){
- case 200:
- equipment.eqId = res.data[0];
- let locCount = 0;
- equipment.children.forEach((item,index)=>{
- item.id = res.data[1][index];
- if (item.row && Number(item.row) > 0){
- locCount += Number(item.row) * Number(item.column)
- }
- });
- equipment.exist = locCount;
- this.$forceUpdate();
- $("#detailInfo").modal("hide");
- window.toast.success("保存成功");
- break;
- case 701:
- this.error = res.data;
- break;
- case 414:
- this.error = {code:"设备编码重复"};
- window.toast.error(this.error.code);
- break;
- default:
- window.toast.error("服务器错误:"+res.message);
- }
- },
- error : (err)=>{
- console.error(err);
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- timeout:3000,
- })
- },
- _checkEquipmentData(equipment){
- let error = {};
- if (!equipment.code)error.code = "设备编号未填写";
- if (equipment.layer !== equipment.children.length)error.children = "设备绑定错误";
- for (let i=0;i<equipment.layer;i++){
- if (!equipment.children[i].height)error["children["+i+"].height"] = "设备高度不得为空"
- //if (!equipment.children[i].area)error["children["+i+"].area"] = "设备折算面积不得为空"
- if (!equipment.children[i].column && equipment.children[i].column!=0)error["children["+i+"].column"] = "库位列数不得为空"
- if (!equipment.children[i].row && equipment.children[i].row!=0)error["children["+i+"].row"] = "库位行数不得为空"
- }
- return error;
- },
- _formatEquipmentData(equipment){
- let eq = {};
- eq.id = equipment.eqId;
- eq.code = equipment.code;
- eq.repositoryId = equipment.repository;
- eq.info = JSON.stringify({'x':equipment.x,'y':equipment.y,'id':equipment.id,'turn':!!equipment.turn});
- eq.depth = equipment.depth;
- eq.width = equipment.width;
- eq.children = equipment.children;
- return eq;
- },
- removeLocationBind(){
- if (this.isLoadLocation)return;
- this.isLoadLocation = true;
- $.ajax({
- url : this.baseUrl+"api/base/location/removeLocationBind",
- type : "post",
- dataType : "JSON",
- data : {id:this.current.children[this.currentEqChildIndex].id},
- success : (res)=>{
- switch (res.code){
- case 200:
- this.current.children[this.currentEqChildIndex].row = 0;
- this.current.children[this.currentEqChildIndex].column = 0;
- this.locations = [];
- window.toast.success("解除成功!");
- break;
- default:
- window.toast.error("库位无法释放,解除失败");
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- complete:()=>{
- this.isLoadLocation = false;
- },
- timeout:3000,
- })
- },
- locationBatchBind(){
- $("#loading").show();
- let arr = this.batchEquipment[this.batchEquipmentSign];
- let request = [];
- let failTipList = {};
- arr.forEach(index=>{
- let eq = this.equipmentElements[index];
- if (!eq){
- window.toast.error("异常设备选择");
- }else if (!eq.children || eq.children.length===0 || !eq.children[this.currentEqChildIndex]){
- failTipList[eq.code]="详情尚未加载完毕";
- }else{
- let item = eq.children[this.currentEqChildIndex];
- let code = eq.code+'-'+(this.currentEqChildIndex+1);
- request.push(Object.assign({id:item.id,code:code},
- this.buildPool))
- }
- });
- $.ajax({
- url : this.baseUrl+"api/base/location/locationBatchBound",
- type : "post",
- dataType : "JSON",
- data : JSON.stringify(request),
- headers:{'Content-Type':'application/json;charset=utf8'},
- success : (res)=>{
- switch (res.code){
- case 200:
- $("#locationModal").modal('hide');
- window.toast.success("构建完毕!");
- this.failTipList = Object.assign(failTipList,res.data);
- if (JSON.stringify(this.failTipList)!=="{}"){
- $("#failTipList").modal("show");
- }
- let ele = document.querySelectorAll("#locationAttr span.el-center")[this.current.layer-1-this.currentEqChildIndex];
- ele.className += " bg-success";
- break;
- default:
- window.toast.error(res.message);
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- complete:(req,status)=>{
- $("#loading").hide();
- if (status==='timeout'){
- window.toast.error("库位批量构建失败,响应超时");
- }
- },
- timeout:3000,
- });
- },
- locationBind(){
- if (this.batchSign){
- this.locationBatchBind();
- return;
- }
- if (this.isLoadLocation)return;
- let eq = this.current.children[this.currentEqChildIndex];
- let code = this.current.code+'-'+(this.currentEqChildIndex+1);
- this.isLoadLocation = true;
- $.ajax({
- url : this.baseUrl+"api/base/location/locationBind",
- type : "post",
- dataType : "JSON",
- headers:{'Content-Type':'application/json;charset=utf8'},
- data : JSON.stringify(Object.assign({id:eq.id,code:code},this.buildPool)),
- success : (res)=>{
- switch (res.code){
- case 200:
- this.locations = res.data;
- window.toast.success("构建成功!");
- this.current.children[this.currentEqChildIndex].row = Number(this.buildPool.row);
- this.current.children[this.currentEqChildIndex].column = Number(this.buildPool.column);
- this._locationAttrDefault();
- $("#locationModal").modal("hide");
- this.$forceUpdate();
- break;
- default:
- window.toast.error(res.message);
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- complete:(req,status)=>{
- this.isLoadLocation = false;
- if (status==='timeout'){
- window.toast.error("库位建立失败,响应超时");
- }
- },
- timeout:3000,
- })
- },
- showAddWarehouseDetail(){
- if (this.ws.length>0){
- $("#warehouseDetail").modal("show");
- return;
- }
- $.ajax({
- url : this.baseUrl+"api/base/warehouse/getList",
- type : "get",
- dataType : "JSON",
- success : (res)=>{
- switch (res.code){
- case 200:
- this.ws = res.data;
- $("#warehouseDetail").modal("show");
- break;
- default:
- window.toast.error("仓库获取失败");
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- complete:(req,status)=>{
- this.isLoadLocation = false;
- if (status==='timeout'){
- window.toast.error("获取仓库超时");
- }
- },
- timeout:3000,
- })
- },
- addWarehouseDetail(){
- $.ajax({
- url : this.baseUrl+"api/base/warehouse/detail",
- type : "post",
- dataType : "JSON",
- headers:{'Content-Type':'application/json;charset=utf8'},
- data : JSON.stringify(this.warehouseDetail),
- success : (res)=>{
- switch (res.code){
- case 200:
- window.toast.success("仓库新建成功");
- this.warehouses = res.data;
- $("#warehouseDetail").modal("hide");
- break;
- default:
- window.toast.error(res.message);
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- timeout:3000,
- })
- },
- openRepository(){
- $.ajax({
- url : this.baseUrl+"api/base/repository/group",
- type : "get",
- dataType : "JSON",
- data:{id:this.selected},
- success : (res)=>{
- switch (res.code){
- case 200:
- this.group = res.data;
- $("#repository").modal("show");
- break;
- default:
- window.toast.error("获取区域失败");
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- complete:(req,status)=>{
- this.isLoadLocation = false;
- if (status==='timeout'){
- window.toast.error("获取区域超时");
- }
- },
- timeout:3000,
- })
- },
- addRepository(){
- this.repository.warehouseDetailId = this.selected;
- $.ajax({
- url : this.baseUrl+"api/base/repository/addRepository",
- type : "post",
- dataType : "JSON",
- headers:{'Content-Type':'application/json;charset=utf8'},
- data:JSON.stringify(this.repository),
- success : (res)=>{
- switch (res.code){
- case 200:
- this.repositories.push(res.data);
- $("#repository").modal("hide");
- this.repository = {};
- break;
- default:
- window.toast.error("库区建立失败");
- }
- },
- error : (err)=>{
- window.tempTip.setIndex(999);
- window.tempTip.show("网络错误");
- },
- complete:(req,status)=>{
- this.isLoadLocation = false;
- if (status==='timeout'){
- window.toast.error("建立库区超时");
- }
- },
- timeout:3000,
- })
- },
- /**
- * 批量构建设备库位时的选中操作
- * */
- batchEquipmentSelected(arr,index){
- this.current = this.equipmentElements[arr[0]];
- this.batchEquipmentSign = index;
- arr.forEach(i=>{
- this.getChildren(this.equipmentElements[i]);
- })
- this._getLocationAttr();
- },
- },
- filters:{
- qty(code){
- let inv = vue.locationMapping[code];
- if(!inv)return 0;
- return inv.QTY;
- },
- qtyOver(code){
- let inv = vue.locationMapping[code];
- if(!inv)return 0;
- return inv.QTYALLOCATED + inv.QTYMVIN + inv.QTYMVOUT + inv.QTYONHOLD + inv.QTYPA + inv.QTYRPIN + inv.QTYRPOUT;
- },
- childStyle(code){
- let inv = vue.locationMapping[code];
- if (!inv)return '';
- let qty = inv.QTY;
- let other = inv.QTYALLOCATED + inv.QTYMVIN + inv.QTYMVOUT + inv.QTYONHOLD + inv.QTYPA + inv.QTYRPIN + inv.QTYRPOUT;
- return (qty>0 || other>0) ?
- 'color: #fff;background-color: #38c172;border-color: #38c172;' : '';
- },
- formatCount(tab){
- let arr = tab.split("-");
- return arr[0]*arr[1];
- }
- }
- });
- </script>
- </html>
|