index.blade.php 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  1. <!DOCTYPE html>
  2. <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <link rel="icon" href="{{asset('icon/faviconc.ico')}}" type="image/x-icon"/>
  7. <!-- CSRF Token -->
  8. <meta name="csrf-token" content="{{ csrf_token() }}">
  9. <title>设备平面</title>
  10. <link href="{{ mix('css/app.css') }}" rel="stylesheet">
  11. <link href="{{ mix('css/animation.css') }}" rel="stylesheet">
  12. <style>
  13. html{
  14. width: 100%;
  15. height: 100%;
  16. }
  17. body{
  18. width: 100%;
  19. height: 100%;
  20. }
  21. .p1{
  22. overflow: hidden;
  23. text-overflow: ellipsis;
  24. display: -webkit-box;
  25. -webkit-line-clamp: 2;
  26. -webkit-box-orient: vertical;
  27. }
  28. .el-center{
  29. display:flex;
  30. align-items:center;
  31. justify-content:center;
  32. }
  33. .el-left-bottom{
  34. position: absolute;
  35. bottom: 0;
  36. left: 0;
  37. }
  38. .el-right-bottom{
  39. position: absolute;
  40. bottom: 0;
  41. right: 0;
  42. }
  43. .txt-sty{
  44. filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
  45. font-family: "Microsoft YaHei Light","sans-serif";
  46. font-size: 10px;
  47. white-space:nowrap;
  48. font-weight:bold;
  49. }
  50. .re{transform:rotate(-90deg);
  51. -ms-transform:rotate(-90deg); /* Internet Explorer 9*/
  52. -moz-transform:rotate(-90deg); /* Firefox */
  53. -webkit-transform:rotate(-90deg); /* Safari 和 Chrome */
  54. -o-transform:rotate(-90deg); /* Opera */
  55. }
  56. /*opacity是设置遮罩透明度的,可以自己调节*/
  57. #loading{position:fixed;top:0;left:0;width:100%;height:100%;background:#f8f8f8;opacity:0.6;z-index:15000;}
  58. #loading i{position:absolute;top:50%;left:50%;font-size:33px;margin-top:-15px;margin-left:-40px;}
  59. #loading p{position:absolute;top:55%;left:48%;width:33px;height:33px;margin-top:-15px;margin-left:-15px;}
  60. .equipment{
  61. cursor: pointer
  62. }
  63. .equipment-exist{
  64. border-width:2px;
  65. border-style: groove;
  66. border-color: #0000FF;
  67. }
  68. .equipment-not-exist{
  69. opacity: 0.5;
  70. border-width:1px;
  71. border-style: dashed;
  72. border-color: #0070C0;
  73. }
  74. </style>
  75. </head>
  76. <body>
  77. <div class="container-fluid w-100 h-100" id="container" @mousemove="eqMove()" @mouseup="eqUp()">
  78. <div class="row w-100 h-100">
  79. <div class="col-2 " style="user-select: none;" id="tool">
  80. <div class="dropdown">
  81. <button type="button" class="btn p-0 w-100" id="dropdownMenu"
  82. data-toggle="dropdown">
  83. <h4 class="text-muted mt-1 p1">@{{ name }}&nbsp;&nbsp;<i class="fa fa-exchange text-info"></i></h4>
  84. </button>
  85. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
  86. <li role="presentation" v-for="warehouse in warehouses" v-if="warehouse.id!==selected">
  87. <a role="menuitem" tabindex="-1" style="cursor: pointer" class="ml-3"
  88. @click="selectedWarehouse(warehouse)">@{{ warehouse.name }}</a>
  89. </li>
  90. <li role="presentation" class="text-center" @click="showAddWarehouseDetail()">
  91. <a role="menuitem" tabindex="-1" style="cursor: pointer" class="ml-3 text-primary"
  92. ><i class="fa fa-plus"></i> 新增</a>
  93. </li>
  94. </ul>
  95. </div>
  96. <button class="btn btn-info mt-5 w-100 text-white" @click="openRepository()">新增库区</button>
  97. <button class="btn btn-success mt-5 w-100 text-white" @click="searchingSelectEq()">批量构建库位</button>
  98. <p class="font-weight-bold p-0 mb-0 mt-1">位置</p>
  99. <div class="row text-muted small">
  100. <small class="col-6">X</small>
  101. <small class="col-6">Y</small>
  102. </div>
  103. <div class="row m-0 p-0">
  104. <input type="number" class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.x"
  105. @blur="changeNumber('x')"></input>
  106. <input type="number" class="col-5 offset-1 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.y"
  107. @blur="changeNumber('y')"></input>
  108. </div>
  109. <p class="font-weight-bold p-0 mb-0 mt-3">大小</p>
  110. <div class="row text-muted small">
  111. <small class="col-6">高</small>
  112. <small class="col-6">宽</small>
  113. </div>
  114. <div class="row m-0 p-0">
  115. <input type="number" class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.height" @blur="changeNumber('height')"></input>
  116. <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>
  117. </div>
  118. <p class="font-weight-bold p-0 mb-0 mt-3">其他</p>
  119. <div class="row text-muted small">
  120. <small class="col-6">层级</small>
  121. <small class="col-6">颜色</small>
  122. </div>
  123. <div class="row m-0 p-0">
  124. <input type="number" class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.index" @blur="changeNumber('index')"></input>
  125. <input class="col-5 offset-1 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.color" @blur="changeText('color')"></input>
  126. </div>
  127. <div class="row text-muted small">
  128. <small class="col-6">名称</small>
  129. <small class="col-6">名称位置</small>
  130. </div>
  131. <div class="row m-0 p-0">
  132. <input class="col-5 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" :value="currentEl.name" @blur="changeText('name')"></input>
  133. <select class="col-5 offset-1 form-control form-control-sm p-0" :disabled="currentEl.x===undefined" v-model="currentEl.coords">
  134. <option value="左上">左上</option>
  135. <option value="左下">左下</option>
  136. <option value="右上">右上</option>
  137. <option value="右下">右下</option>
  138. <option value="居中">居中</option>
  139. <option value="中上">中上</option>
  140. </select>
  141. </div>
  142. <div class="row text-muted small">
  143. <small class="col-6">边框</small>
  144. </div>
  145. <div class="m-0 small row">
  146. <div class="col-6 p-0">
  147. <div class="form-check">
  148. <label class="form-check-label">
  149. <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="top" :disabled="currentEl.x===undefined">上
  150. </label>
  151. </div>
  152. <div class="form-check">
  153. <label class="form-check-label">
  154. <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="bottom" :disabled="currentEl.x===undefined">下
  155. </label>
  156. </div>
  157. <div class="form-check">
  158. <label class="form-check-label">
  159. <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="left" :disabled="currentEl.x===undefined">左
  160. </label>
  161. </div>
  162. <div class="form-check">
  163. <label class="form-check-label">
  164. <input type="checkbox" class="form-check-input" v-model="currentEl.border" value="right" :disabled="currentEl.x===undefined">右
  165. </label>
  166. </div>
  167. </div>
  168. <div class="col-6 p-0">
  169. <div class="form-check">
  170. <label class="form-check-label">
  171. <button class="btn btn-sm btn-success" @click="addCoords()">生成场景元素</button>
  172. </label>
  173. </div>
  174. <div class="form-check mt-1">
  175. <label class="form-check-label">
  176. <button class="btn btn-sm btn-success" @click="openBuildEquipmentGroup()">构建设备组</button>
  177. </label>
  178. </div>
  179. </div>
  180. </div>
  181. <p class="font-weight-bold p-0 mb-0 mt-5 h5">全局</p>
  182. <div class="row text-muted">
  183. <div class="col-4">缩放</div>
  184. <div class="input-group input-group-sm col-8 m-0">
  185. <input type="number" class="form-control" step="1" v-model="scale"></input>
  186. <div class="input-group-append">
  187. <span class="input-group-text">%</span>
  188. </div>
  189. </div>
  190. </div>
  191. <div class="row text-muted mt-1">
  192. <div class="col-4">库位比</div>
  193. <div class="input-group input-group-sm col-8 m-0">
  194. <input class="switch" type="checkbox" @change="loadElement()"/>
  195. </div>
  196. </div>
  197. <div class="row mt-3">
  198. <h5 class="font-weight-bold ml-3">设备</h5>
  199. <div class="form-check ml-3">
  200. <label class="form-check-label">
  201. <input type="checkbox" class="form-check-input" v-model="grid">网格
  202. </label>
  203. <label class="form-check-label ml-4">
  204. <input type="checkbox" class="form-check-input" v-model="turn">翻转
  205. </label>
  206. </div>
  207. </div>
  208. <div style="height: 250px;overflow-y: auto;overflow-x: hidden" class="w-100">
  209. <div class="row" v-for="equipment in equipments" @mousedown="eqDown(equipment)">
  210. <div class="col-5">
  211. <div style="border: 1px #0070C0 solid" :style="[{backgroundColor:equipment.color},{width:(equipment.h*ratio)+'px'},{height:(equipment.w*ratio)+'px'}]"></div>
  212. </div>
  213. <div class="col-7 p1">
  214. @{{ equipment.describe }}
  215. </div>
  216. </div>
  217. </div>
  218. <button @click="clickEditOrSave()" :class="isNotEdit ? 'btn-info' : 'btn-success'"
  219. style="position:absolute;bottom: 20px;cursor: pointer" class="btn col-10 text-white">
  220. <span v-if="isNotEdit">开启场景编辑</span>
  221. <span v-else>保存更改</span>
  222. </button>
  223. </div>
  224. <div class="col-10 p-0">
  225. <div class="w-100 bg-secondary" id="canvasApp" style="height: 100vh;overflow: auto;user-select: none;">
  226. <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)+')'}]"
  227. style="position: relative;transform-origin: 0 0" class="bg-white"
  228. @mousedown="contentOnmousedown" @mousemove="contentOnmousemove" @mouseup="contentOnmouseup">
  229. <vue-drag-resize v-for="(element,index) in elements" v-if="!element.removeSign"
  230. @activated="onActivated(element)"
  231. @dragging="onDragging"
  232. @resizing="onResizing"
  233. :minw="1" :minh="1"
  234. :style="[{backgroundColor:element.color},
  235. element.border.indexOf('left')===-1 ? {borderLeft:'none'} : {},
  236. element.border.indexOf('right')===-1 ? {borderRight:'none'} : {},
  237. element.border.indexOf('top')===-1 ? {borderTop:'none'} : {},
  238. element.border.indexOf('bottom')===-1 ? {borderBottom:'none'} : {}]"
  239. style="border-width:1px;border-color: #000000;border-style: solid"
  240. :key="index" :prevent-active-behavior="isNotEdit"
  241. :parent-limitation="true" :w="element.width*ratio" :h="element.height*ratio"
  242. :x="element.x" :y="element.y" :z="element.index">
  243. <div :class="coordsMapping[element.coords]">@{{ element.name }}</div>
  244. </vue-drag-resize>
  245. <vue-drag-resize class="equipment"
  246. v-for="(element,index) in equipmentElements" @clicked="showDetail(element)"
  247. :id="'eq-'+index" :class="element.exist ? 'equipment-exist' : 'equipment-not-exist'"
  248. v-if="!element.removeSign"
  249. :is-resizable="false" :snap-to-grid="grid" :grid-x="40" :grid-y="30"
  250. :style="[{backgroundColor:element.color}]"
  251. @activated="onActivated(element)"
  252. @dragging="equipmentDrag"
  253. :key="'eq-'+index+element.turn" :prevent-active-behavior="isNotEdit"
  254. :parent-limitation="true" :w="(element.turn ? element.w : element.h)*ratio"
  255. :h="(element.turn ? element.h : element.w)*ratio"
  256. :x="element.x" :y="element.y" :z="90">
  257. <div class="h-100 w-100" v-if="isShowRatio">
  258. <div class="h-100 w-100 p-0" v-if="element.children && element.children.length>0">
  259. <div :style="{height:100/element.children.length+'%'}" v-for="(child,idx) in element.children"
  260. :class="(element.children[element.children.length-1-idx]).location_tab==='0-0' ? '' : 'bg-danger'"
  261. class="border border-dark text-dark small el-center w-100 m-0">
  262. @{{ (element.children[element.children.length-1-idx]).location_tab | formatCount }}
  263. </div>
  264. </div>
  265. <div class="h-100 w-100 txt-sty el-center" v-else>
  266. <i class="fa fa-spinner fa-spin"></i>
  267. </div>
  268. </div>
  269. <div class="h-100 txt-sty w-100 el-center" :class="element.turn ? 're' : ''" v-else>@{{ element.code }}</div>
  270. </vue-drag-resize>
  271. </div>
  272. </div>
  273. </div>
  274. <textarea hidden id="clipboardDiv" style="opacity:0"></textarea>
  275. <div id="loading" class="list-item">
  276. <i class="fa fa-spinner fa-spin"></i>
  277. <p style="line-height: 24px;">loading...</p>
  278. </div>
  279. </div>
  280. @include("equipment._detailInfo")
  281. @include("equipment._location")
  282. @include("equipment._warehouseDetail")
  283. @include("equipment._repository")
  284. @include("equipment._buildGroup")
  285. @include("equipment._locationAttr")
  286. @include("equipment._failTipList")
  287. </div>
  288. </body>
  289. <script src="{{ mix('js/app.js') }}"></script>
  290. <script src="{{ asset('js/utilities/drawCheckbox.js') }}"></script>
  291. <script src="{{ asset('js/utilities/h2can.min.js') }}"></script>
  292. <script src="{{ asset('js/utilities/jcanvas.min.js') }}"></script>
  293. <script src="{{ asset('js/utilities/toast.js') }}"></script>
  294. <script type="text/javascript">
  295. var vue = new Vue({
  296. el:"#container",
  297. data:{
  298. increment:true,
  299. group:[],//库区列表
  300. ws:[],//仓库列表
  301. locationMapping:{},//库位的信息映射
  302. warehouseDetail:{},//当前操作的仓库
  303. repository:{},//当前操作的库区
  304. warehouses:[], //仓库描述
  305. repositories:[], //库区
  306. selected:"", //当前选中的仓库ID
  307. container:{width:90,height:60}, //容器初始大小
  308. ratio:20, //设备大小缩放比例值
  309. name:"", //当前选中的仓库NAME
  310. isNotEdit:true, //是否允许编辑
  311. isLoad:true, //是否加载
  312. currentEl:{}, //当前选中的元素
  313. coordsMapping:{ //元素信息映射
  314. "居中":"h-100 w-100 el-center",
  315. "中上":"text-center",
  316. "左上":"",
  317. "左下":"el-left-bottom",
  318. "右上":"text-right",
  319. "右下":"el-right-bottom",
  320. },
  321. elements:[], //场景元素池
  322. clientCoords:{}, //坐标系记录
  323. scale:100, //缩放值
  324. equipments:[ //备选设备池
  325. {id:1,w:1.2,h:2.4,grid:2,layer:4,color:"RGB(252,228,214)",describe:"4层高位货架,可设八个标准托盘位"},
  326. {id:2,w:1.2,h:2.4,grid:2,layer:5,color:"RGB(255,255,255)",describe:"5层高位货架,可设十个标准托盘位"},
  327. {id:3,w:1.2,h:3.3,grid:3,layer:1,color:"RGB(169,208,142)",describe:"叉车通道,可设三个标准托盘位"},
  328. {id:4,w:1.2,h:3.3,grid:3,layer:2,color:"RGB(221,235,247)",describe:"叉车通道,可设六个标准托盘位"},
  329. {id:5,w:1.2,h:1.2,grid:1,layer:4,color:"RGB(255,255,0)",describe:"半组货架,可设四层高四个标准托盘位"},
  330. {id:6,w:1.2,h:2.4,grid:2,layer:1,color:"RGB(189,215,238)",describe:"叉车通道,顶上两个托盘位"},
  331. {id:7,w:1.2,h:1.2,grid:1,layer:5,color:"RGB(255,255,5)",describe:"半组货架,可设五层高五个标准托盘位"},
  332. {id:8,w:1.2,h:3.3,grid:3,layer:4,color:"RGB(146,208,80)",describe:"4层高位货架,可设十二个标准托盘位"},
  333. {id:9,w:1.2,h:2.4,grid:2,layer:2,color:"RGB(228,243,211)",describe:"叉车通道,可设四个标准托盘位"},
  334. ],
  335. currentEq:{ //选中的设备
  336. el:null,
  337. obj:null,
  338. },
  339. equipmentElements:[], //设备元素池
  340. grid:false, //设备拖拽是否开启网格
  341. turn:true, //设备是否翻转
  342. isLoadLocation:false, //开启加载库位
  343. //baseUrl:"http://127.0.0.1:8112/",
  344. baseUrl:"https://swms.baoshi56.com/",
  345. current:{}, //当前操作的设备
  346. error:{},
  347. locations:[], //库位信息
  348. currentEqChildIndex:null, //当前节点下标
  349. buildPool:{}, //库位构建信息
  350. client:{}, //复制后的坐标记录
  351. buildEqInfo:{}, //设备组构建信息
  352. charArr : [...Array(26).keys()].map(i => String.fromCharCode(i + 65)), //A-Z字符
  353. elSeList:[
  354. {id:-1,w:1.2,h:2.4,grid:2,color:"RGB(255,255,0)",describe:"消防栓设施或立柱,不可设库位"},
  355. ],//场景元素预设列表
  356. locationAttr:null,//库位建立时的可选择属性
  357. batchEquipment:{
  358. },//设备类型 与设备下标的映射
  359. batchEquipmentSign:"",//当前选择的batchEquipment下标
  360. batchSign:false,//当前是否为批量构建
  361. failTipList:{},//构建失败的库位提示信息
  362. isShowRatio:undefined,//是否展示库位现存比例
  363. },
  364. mounted() {
  365. this.initPage();
  366. let content = document.getElementById("canvasApp");
  367. content.onmousemove = (event)=>{
  368. this.client = {x:event.clientX,y:event.clientY};
  369. }
  370. },
  371. computed:{
  372. flipLayer(){
  373. let layer = [];
  374. for (let i=this.current.layer;i>0;i--){
  375. layer.push(i);
  376. }
  377. return layer;
  378. },
  379. },
  380. created: function() {
  381. let content = document.getElementById("canvasApp");
  382. document.onkeydown = e=> {
  383. if (this.isNotEdit || !this.current)return;
  384. let key = e.keyCode;
  385. if (key === 8) {
  386. this.delElement();
  387. }
  388. if(key===67 && e.ctrlKey){
  389. this.copyEle();
  390. }
  391. if(key===86 && e.ctrlKey){
  392. let val = $('#clipboardDiv').val();
  393. if (!val || JSON.stringify(val)==="{}")return;
  394. let toolWid = document.getElementById("tool").offsetWidth;
  395. let obj = Object.assign({},JSON.parse(val));
  396. obj.x = this.client.x-toolWid+content.scrollLeft;
  397. obj.y = this.client.y+content.scrollTop;
  398. obj.children = [];
  399. for (let i=0;i<obj.layer;i++)obj.children.push({});
  400. if (this.currentEl.eqId){
  401. obj.eqId = undefined;
  402. this.current = obj;
  403. this.currentEl = obj;
  404. this.showAddModal(obj);
  405. }else{
  406. this.elements.push(obj);
  407. }
  408. }
  409. };
  410. },
  411. methods:{
  412. loadElement(){
  413. if (this.isShowRatio===undefined){
  414. this.isShowRatio = true;
  415. this.equipmentElements.forEach(eq=>{
  416. if (eq.exist){
  417. this.getChildren(eq);
  418. }else if(!eq.children){
  419. eq.children = [];
  420. }
  421. });
  422. }else{
  423. this.isShowRatio = !this.isShowRatio;
  424. }
  425. },
  426. //获取库位的可选择属性
  427. _getLocationAttr(){
  428. if (this.locationAttr!==null){
  429. return;
  430. }
  431. $.ajax({
  432. url : this.baseUrl+"location/getAttr",
  433. type : "post",
  434. dataType : "JSON",
  435. success : (res,status)=>{
  436. if (res.code===200){
  437. this.locationAttr = res.data;
  438. }else{
  439. window.toast.error(res.message);
  440. }
  441. },
  442. error : (err,status)=>{
  443. window.toast.error("库位选择属性加载失败");
  444. },
  445. timeout:3000,
  446. })
  447. },
  448. /**
  449. * 显示设备编码列表
  450. */
  451. showEquipmentCode(arr){
  452. event.stopPropagation();
  453. let obj = {};
  454. arr.forEach(index=>{
  455. obj[this.equipmentElements[index].code] = "";
  456. });
  457. this.failTipList = obj;
  458. $("#failTipList").modal("show");
  459. },
  460. //检索所有元素,获取在指定范围内的元素
  461. searchingSelectEq(){
  462. afterExt = function (){
  463. new Promise(function(resolve, reject) {
  464. let result = [];
  465. let els = $(".equipment");
  466. for (let i=0;i<els.length;i++){
  467. let client = els[i].getBoundingClientRect();
  468. if (client.x<0 || client.y<0){
  469. continue;
  470. }
  471. //四个角全部包含在此区域内 将元素下标加入结果数组
  472. if (client.x>=clipInfo.x && client.y>=clipInfo.y && client.x<=(clipInfo.x+clipInfo.w) && client.y<=(clipInfo.y+clipInfo.h)
  473. && (client.x+client.width)<=(clipInfo.x+clipInfo.w) && (client.y+client.height)<=(clipInfo.y+clipInfo.h)){
  474. result.push(els[i].id.split('-')[1]);
  475. }
  476. }
  477. resolve(result);
  478. }).then(indexArr=>{
  479. if (indexArr.length===0){
  480. toast.error("未选中任何设备");
  481. return;
  482. }
  483. vue.batchOperationEquipment(indexArr);
  484. });
  485. }
  486. clipScreenshots();
  487. },
  488. /**
  489. * 批量选中设备后唤起构建器
  490. */
  491. batchOperationEquipment(indexArr){
  492. this.current = {};
  493. let obj = {};
  494. indexArr.forEach(index=>{
  495. let eq = this.equipmentElements[index];
  496. let eqTypeIndex = this._getEqTypeIndex(eq.id);
  497. if (!obj[eqTypeIndex])obj[eqTypeIndex] = [];
  498. obj[eqTypeIndex].push(index);
  499. });
  500. this.batchEquipment = obj;
  501. $("#locationAttr").modal('show');
  502. },
  503. /**
  504. * 根据库位类型ID获取库位类型下标
  505. */
  506. _getEqTypeIndex(id){
  507. //当前是ID为下标+1,所以直接ID-1获取下标
  508. return id-1;
  509. for (let i=0;i<this.equipments.length;i++){
  510. if (this.equipments[i].id==id){
  511. return i;
  512. }
  513. }
  514. return null;
  515. },
  516. buildComponent(eq){
  517. let component = {
  518. "x":eq.x,"y":eq.y,"width":eq.turn ? eq.w : eq.h,"height":eq.turn ? eq.h : eq.w,"name":"","color":eq.color,
  519. "coords":"居中","border":["left","top","right","bottom"],"index":2
  520. };
  521. this.elements.push(component);
  522. },
  523. buildEquipment(eq){
  524. let children = [];
  525. let lastHeight = 1;
  526. for (let i=0;i<eq.layer;i++){
  527. let obj = this.currentEl.children[i];
  528. if (obj)lastHeight = obj.height;
  529. children.push({
  530. "height" : lastHeight,
  531. "row" : 0,
  532. "column" : 0,
  533. });
  534. }
  535. eq.children = children;
  536. this.equipmentElements.push(eq);
  537. this.exeSave(this.equipmentElements[this.equipmentElements.length-1]);
  538. },
  539. buildEquipmentGroup(){
  540. let x = this.currentEl.turn ? this.currentEl.x : Number(this.currentEl.x)+(Number(this.currentEl.w)*this.ratio);
  541. let y = this.currentEl.turn ? Number(this.currentEl.y)+(Number(this.currentEl.h)*this.ratio) : this.currentEl.y;
  542. this.buildEqInfo.list.forEach(eq=>{
  543. eq.x = x;
  544. eq.y = y;
  545. if (eq.id<0)this.buildComponent(eq); //构建组件
  546. else this.buildEquipment(eq); //构建设备
  547. if (this.currentEl.turn){
  548. y += eq.h*this.ratio+0.5;
  549. }else{
  550. x += eq.h*this.ratio+0.5;
  551. }
  552. });
  553. window.toast.success("构建完毕");
  554. this.buildEqInfo = {};
  555. $("#buildGroup").modal("hide");
  556. },
  557. getLastChar(str){
  558. let lastChar = str.substr(-1,1);
  559. if (lastChar.search(/[A-Z]/g)===0){
  560. let index = this.charArr.indexOf(lastChar);
  561. let residualCount = this.charArr.length-(index+1);
  562. if (residualCount<this.buildEqInfo.count)return null;
  563. return {type:"CHAR",val:index};
  564. }
  565. if (lastChar.search(/[\d]/g)===0){
  566. let strs = str.replace(/[^\d]/g,'*');
  567. let strsArr = strs.split('*');
  568. return {type:"NUMBER",val:strsArr[strsArr.length-1]};
  569. }
  570. return null;
  571. },
  572. buildGroup(){
  573. let count = this.buildEqInfo.count;
  574. if (!count)return;
  575. let result = this.getLastChar(this.currentEl.code);
  576. if(!result){
  577. window.toast.error("此设备编码不符合组规则");
  578. return;
  579. }
  580. let codeTran = (index)=>{
  581. let size = result.val.toString().length;
  582. let val;
  583. if(result.type==="CHAR"){
  584. if (this.increment){
  585. val=this.charArr[result.val+index];
  586. }else{
  587. val=this.charArr[result.val-index];
  588. }
  589. }else{
  590. if (this.increment){
  591. val=Number(result.val)+index;
  592. }else{
  593. val=Number(result.val)-index;
  594. }
  595. if (val.toString().length<size){
  596. val = (Array(size).join('0') + val).slice(-size);
  597. }
  598. }
  599. return this.currentEl.code.substr(0,this.currentEl.code.length-size)+val;
  600. };
  601. let list = [];
  602. for (let i=1;i<=count;i++){
  603. let obj = Object.assign({},this.currentEl);
  604. obj.eqId = undefined;
  605. obj.updateCoords = undefined;
  606. obj.code = codeTran(i);
  607. list.push(obj);
  608. }
  609. this.$set(this.buildEqInfo,"list",list);
  610. },
  611. pitchEq(el,index){
  612. this.$set(this.buildEqInfo,"current",index);
  613. this.$set(this.buildEqInfo,"currentEqId",el.id);
  614. },
  615. switchEq(el){
  616. if (this.buildEqInfo.currentEqId===el.id)return;
  617. let obj = this.buildEqInfo.list[this.buildEqInfo.current];
  618. obj.id = el.id;
  619. obj.w = el.w;
  620. obj.h = el.h;
  621. obj.describe = el.describe;
  622. obj.grid = el.grid;
  623. obj.layer = el.layer;
  624. obj.color = el.color;
  625. obj.width = el.w;
  626. obj.depth = el.h;
  627. this.$set(this.buildEqInfo,"currentEqId",el.id);
  628. },
  629. openBuildEquipmentGroup(){
  630. if (this.isNotEdit || !this.currentEl.eqId){
  631. window.toast.error("未开启编辑或未选中设备");
  632. return;
  633. }
  634. setTimeout(()=>{
  635. this.getChildren(this.currentEl);
  636. $("#buildGroup").modal("show");
  637. },100);
  638. },
  639. delCoords(){
  640. this.elements.some((el,index)=>{
  641. if (this.currentEl.name === el.name &&
  642. this.currentEl.x === el.x && this.currentEl.y === el.y){
  643. this.$set(this.elements[index],"removeSign",true);
  644. return true;
  645. }
  646. })
  647. },
  648. copyEle(){
  649. if (this.currentEl!=null && JSON.stringify(this.currentEl)!=="{}"){
  650. $('#clipboardDiv').text(JSON.stringify(this.currentEl));
  651. }
  652. },
  653. delEquipment(){
  654. this.equipmentElements.some((el,index)=>{
  655. if (this.currentEl.eqId === el.eqId){
  656. this.$set(this.equipmentElements[index],"removeSign",true);
  657. return true;
  658. }
  659. })
  660. },
  661. delElement(){
  662. if (this.currentEl.eqId)this.delEquipment();
  663. else this.delCoords();
  664. },
  665. addCoords(){
  666. if (this.isNotEdit)return;
  667. this.elements.push({"x":200,"y":200,"width":2,"height":2,"name":"","coords":"居中","border":["left","top","right","bottom"],"color":"white","index":1})
  668. },
  669. clickEditOrSave(){
  670. if(this.isNotEdit){this.isNotEdit = false;return;}
  671. let equipments = [];
  672. let delEquipments = [];
  673. let elements = [];
  674. this.equipmentElements.forEach(equipment=>{
  675. if (equipment.removeSign){
  676. delEquipments.push(equipment.eqId);
  677. }else if (equipment.updateCoords){
  678. equipments.push({
  679. id:equipment.eqId,
  680. info:JSON.stringify({x:equipment.x,y:equipment.y,id:equipment.id,turn:equipment.turn})
  681. });
  682. }
  683. });
  684. this.elements.forEach(el=>{
  685. if (!el.removeSign){
  686. elements.push(el);
  687. }
  688. });
  689. $.ajax({
  690. url : this.baseUrl+"warehouse/saveScene",
  691. type : "POST",
  692. headers:{'Content-Type':'application/json;charset=utf8'},
  693. data:JSON.stringify({id:this.selected,warehouse:JSON.stringify(elements),equipment:equipments,delEquipments:delEquipments}),
  694. success : (res,status)=>{
  695. if (res.code===200){
  696. this.isNotEdit = true;
  697. window.toast.success("场景更改保存成功");
  698. }else window.toast.error(res.message);
  699. },
  700. error : (err,status)=>{
  701. window.tempTip.show("加载失败");
  702. },
  703. complete:(req,status)=>{
  704. if (status==='timeout'){
  705. window.toast.error("服务器响应超时");
  706. }
  707. },
  708. timeout:10000,
  709. })
  710. },
  711. initPage(){
  712. $.ajax({
  713. url : this.baseUrl+"warehouse/detail",
  714. type : "GET",
  715. success : (res,status)=>{
  716. this.warehouses = res.data;
  717. //这里获取warehouses
  718. let id = localStorage.getItem("equipment:warehouse");
  719. if (!id || !this.warehouses.some(warehouse=>{
  720. if (warehouse.id == id){
  721. this.selectedWarehouse(warehouse);
  722. return true;
  723. }
  724. })
  725. ){
  726. if (this.warehouses.length>0)this.selectedWarehouse(this.warehouses[0]);
  727. }
  728. $("#loading").hide();
  729. },
  730. error : (err,status)=>{
  731. window.tempTip.show("加载失败");
  732. },
  733. timeout:3000,
  734. })
  735. },
  736. //备选设备拖拽按下事件
  737. eqDown(equipment){
  738. if (this.isNotEdit)return;
  739. if (this.currentEq.obj!==null)return;
  740. let wid = (this.turn ? equipment.w : equipment.h)*this.ratio;
  741. let hei = (this.turn ? equipment.h : equipment.w)*this.ratio;
  742. let div = document.createElement("div");
  743. div.style.width = wid+'px';
  744. div.style.height = hei+'px';
  745. div.style.backgroundColor = equipment.color;
  746. div.style.zIndex = '999';
  747. div.style.position = 'fixed';
  748. div.style.left = event.clientX+'px';
  749. div.style.top = event.clientY+'px';
  750. div.style.border = '1px #0070C0 solid';
  751. div.style.opacity = '0.5';
  752. document.getElementById("container").append(div);
  753. this.currentEq.el = div;
  754. this.currentEq.obj = equipment;
  755. },
  756. //备选设备拖拽移动事件
  757. eqMove(){
  758. if (this.isNotEdit)return;
  759. if (this.currentEq.obj===null)return;
  760. let x = event.clientX;
  761. let y = event.clientY;
  762. setTimeout(()=>{
  763. this.currentEq.el.style.left = x+'px';
  764. this.currentEq.el.style.top = y+'px';
  765. },10);
  766. },
  767. //备选设备拖拽松开事件
  768. eqUp(){
  769. if (this.isNotEdit)return;
  770. if (this.currentEq.obj===null)return;
  771. this.currentEq.el.remove();
  772. setTimeout(()=>{
  773. this.currentEq.el.remove();
  774. this.currentEq.el = null;
  775. },20);
  776. let content = document.getElementById("canvasApp");
  777. let toolWid = document.getElementById("tool").offsetWidth;
  778. let x = event.clientX-toolWid+content.scrollLeft;
  779. let y = event.clientY+content.scrollTop;
  780. if (x>=0 && y>=0){
  781. let children = [];
  782. for (let i=0;i<this.currentEq.obj.layer;i++)children.push({});
  783. let newEquipment = Object.assign({children:children,x:x,y:y}, this.currentEq.obj);
  784. newEquipment.turn = this.turn;
  785. newEquipment.width = newEquipment.w;
  786. newEquipment.depth = newEquipment.h;
  787. this.showAddModal(newEquipment);
  788. }
  789. this.currentEq.obj = null;
  790. },
  791. showAddModal(equipment){
  792. this.equipmentElements.push(equipment);
  793. this.current = this.equipmentElements[this.equipmentElements.length-1];
  794. setTimeout(()=>{
  795. $("#detailInfo").modal("show");
  796. },20);
  797. },
  798. //场景拖拽按下事件
  799. contentOnmousedown(event){
  800. if (!this.isNotEdit || this.clientCoords.x!==undefined)return;
  801. this.clientCoords = {
  802. x:event.clientX,
  803. y:event.clientY
  804. };
  805. },
  806. //场景拖拽移动事件
  807. contentOnmousemove(event){
  808. if (this.clientCoords.x===undefined)return;
  809. let diffX = event.clientX-this.clientCoords.x-2;
  810. let diffY = event.clientY-this.clientCoords.y-2;
  811. let content = document.getElementById("canvasApp");
  812. setTimeout(()=>{
  813. content.scrollTo(content.scrollLeft+diffX,content.scrollTop+diffY);
  814. },10);
  815. },
  816. //场景拖拽松开事件
  817. contentOnmouseup(){
  818. this.clientCoords = {};
  819. },
  820. onActivated(element){
  821. if (this.isNotEdit)return;
  822. this.currentEl = element;
  823. },
  824. //场景大小调整事件
  825. onResizing(newRect){
  826. if (this.isNotEdit)return;
  827. this.currentEl.width=this.accDiv(newRect.width,this.ratio);
  828. this.currentEl.height=this.accDiv(newRect.height,this.ratio);
  829. },
  830. accDiv(arg1,arg2){
  831. let t1=0,t2=0,r1,r2;
  832. try{t1=arg1.toString().split(".")[1].length}catch(e){}
  833. try{t2=arg2.toString().split(".")[1].length}catch(e){}
  834. with(Math){
  835. r1=Number(arg1.toString().replace(".",""))
  836. r2=Number(arg2.toString().replace(".",""))
  837. return this.accMul((r1/r2),pow(10,t2-t1));
  838. }
  839. },
  840. accMul(arg1,arg2){
  841. let m=0,s1=arg1.toString(),s2=arg2.toString();
  842. try{m+=s1.split(".")[1].length}catch(e){}
  843. try{m+=s2.split(".")[1].length}catch(e){}
  844. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
  845. },
  846. //场景拖拽事件
  847. onDragging(newRect){
  848. if (this.isNotEdit)return;
  849. this.currentEl.x=newRect.left;
  850. this.currentEl.y=newRect.top;
  851. $("#canvas").focus();
  852. },
  853. equipmentDrag(newRect){
  854. if (this.isNotEdit)return;
  855. this.currentEl.x=newRect.left;
  856. this.currentEl.y=newRect.top;
  857. this.currentEl.updateCoords = true;
  858. $("#canvas").focus();
  859. },
  860. //仓库切换
  861. selectedWarehouse(warehouse){
  862. this.isLoad = false;
  863. setTimeout(()=>{
  864. this.selected = warehouse.id;
  865. this.name = warehouse.name;
  866. this.ratio = warehouse.ratio;
  867. this.container = {width:warehouse.length*this.ratio,height:warehouse.width*this.ratio};
  868. localStorage.setItem("equipment:warehouse", warehouse.id);
  869. $.ajax({
  870. url : this.baseUrl+"warehouse/detail/getCoordsInfo",
  871. type : "post",
  872. dataType : "JSON",
  873. data : {id:warehouse.id},
  874. success : (res,status)=>{
  875. this.elements = res.data[0] ? JSON.parse(res.data[0]) : [];
  876. if(res.data[1] && res.data[1].length>0){
  877. let equipmentElements = [];
  878. res.data[1].forEach(eq=>{
  879. let coords = JSON.parse(eq.info);
  880. let selfInfo = this.equipments[coords.id-1];
  881. equipmentElements.push(Object.assign({
  882. eqId:eq.id,
  883. exist:eq.exist,
  884. code:eq.code,
  885. width:eq.width,
  886. depth:eq.depth,
  887. repository:eq.repositoryId,
  888. x:coords.x,
  889. y:coords.y,
  890. turn:!!coords.turn,
  891. },selfInfo));
  892. });
  893. this.equipmentElements = equipmentElements;
  894. }else this.equipmentElements = [];
  895. this.repositories = res.data[2];
  896. this.isNotEdit = true;
  897. this.isLoad = true;
  898. },
  899. error : (err,status)=>{
  900. window.tempTip.show("坐标信息加载失败");
  901. },
  902. timeout:3000,
  903. })
  904. },200);
  905. },
  906. //文本类属性改变
  907. changeText(key){
  908. this.currentEl[key] = event.target.value;
  909. },
  910. //数值类属性改变
  911. changeNumber(key){
  912. let val = event.target.value;
  913. this.currentEl[key] = val ? parseFloat(val) : 0;
  914. },
  915. _getObjFirstKey(obj){
  916. for(let key in obj){
  917. return key;
  918. }
  919. return null;
  920. },
  921. /**
  922. * 构建库位的默认值信息
  923. * */
  924. _locationAttrDefault(){
  925. this.buildPool.usage = this._getObjFirstKey(this.locationAttr.usage);
  926. this.buildPool.handling = this._getObjFirstKey(this.locationAttr.handling);
  927. this.buildPool.attribute = this._getObjFirstKey(this.locationAttr.attribute);
  928. this.buildPool.category = this._getObjFirstKey(this.locationAttr.category);
  929. this.buildPool.demand = this._getObjFirstKey(this.locationAttr.demand);
  930. this.buildPool.mixFlag = true;
  931. this.buildPool.mixLotFlag = false;
  932. this.buildPool.loseIdFlag = true;
  933. },
  934. /**
  935. * 批量构建库位时的操作
  936. * */
  937. nextDetailBatch(index){
  938. if (!this.current.children || this.current.children.length===0){
  939. window.toast.error("设备信息尚未加载完毕,请稍后重试!");
  940. return;
  941. }
  942. this.batchSign = true;
  943. this.currentEqChildIndex = index-1;
  944. setTimeout(function (){
  945. let parentDom = document.getElementById("locationAttr").firstChild.firstChild;
  946. let childDom = document.getElementById("locationModal").firstChild.firstChild;
  947. childDom.style.minWidth = parentDom.offsetWidth+'px';
  948. childDom.style.minHeight = parentDom.offsetHeight+'px';
  949. $("#locationModal").modal("show");
  950. },20);
  951. this._locationAttrDefault();
  952. },
  953. //子设备选定时的库位加载
  954. nextDetail(index){
  955. if (!this.current.eqId)return;
  956. this.batchSign = false;
  957. this.currentEqChildIndex = index-1;
  958. this.isLoadLocation = true;
  959. this._locationAttrDefault();
  960. setTimeout(function (){
  961. let parentDom = document.getElementById("detailInfo").firstChild.firstChild;
  962. let childDom = document.getElementById("locationModal").firstChild.firstChild;
  963. childDom.style.minWidth = (parentDom.offsetWidth+200)+'px';
  964. childDom.style.minHeight = parentDom.offsetHeight+'px';
  965. $("#locationModal").modal("show");
  966. },20);
  967. let children = this.current.children[this.currentEqChildIndex];
  968. $.ajax({
  969. url : this.baseUrl+"location/get",
  970. type : "post",
  971. dataType : "JSON",
  972. data : {id:children.id},
  973. success : (res)=>{
  974. switch (res.code){
  975. case 200:
  976. this.locations = res.data[0];
  977. this.locationMapping = res.data[1] ? res.data[1] : {};
  978. this.isLoadLocation = false;
  979. break;
  980. default:
  981. window.toast.error(res.message);
  982. }
  983. },
  984. error : (err)=>{
  985. window.tempTip.setIndex(999);
  986. window.tempTip.show("网络错误");
  987. },
  988. timeout:3000,
  989. })
  990. },
  991. showDetail(equipment){
  992. this._getLocationAttr();
  993. if (!this.isNotEdit)return;
  994. this.current = equipment;
  995. setTimeout(()=>{
  996. $("#detailInfo").modal("show");
  997. this.contentOnmouseup();
  998. },20);
  999. this.getChildren(this.current);
  1000. },
  1001. getChildren(equipment){
  1002. if (equipment.children && equipment.children.length>0){
  1003. return;
  1004. }
  1005. $.ajax({
  1006. url : this.baseUrl+"equipment/getChildren",
  1007. type : "post",
  1008. dataType : "JSON",
  1009. data : {id:equipment.eqId},
  1010. success : (res)=>{
  1011. switch (res.code){
  1012. case 200:
  1013. res.data.forEach(eq=>{
  1014. let tab = eq.location_tab.split("-");
  1015. eq.row = Number(tab[0]);
  1016. eq.column = Number(tab[1]);
  1017. });
  1018. this.$set(equipment,"children",res.data);
  1019. break;
  1020. default:
  1021. window.toast.error("服务器错误");
  1022. }
  1023. },
  1024. error : (err)=>{
  1025. window.tempTip.setIndex(999);
  1026. window.tempTip.show("网络错误");
  1027. },
  1028. timeout:3000,
  1029. })
  1030. },
  1031. saveOrUpdate(){
  1032. this.error = {};
  1033. let error = this._checkEquipmentData(this.current);
  1034. if (JSON.stringify(error)!=="{}"){
  1035. this.error = error;return;
  1036. }
  1037. this.exeSave(this.current);
  1038. },
  1039. exeSave(equipment){
  1040. let params = this._formatEquipmentData(equipment);
  1041. params.warehouseDetailId = this.selected;
  1042. $.ajax({
  1043. url : this.baseUrl+"equipment/saveOrUpdate",
  1044. type : "post",
  1045. dataType : "JSON",
  1046. headers:{'Content-Type':'application/json;charset=utf8'},
  1047. data : JSON.stringify(params),
  1048. success : (res)=>{
  1049. switch (res.code){
  1050. case 200:
  1051. equipment.eqId = res.data[0];
  1052. equipment.children.forEach((item,index)=>{
  1053. item.id = res.data[1][index];
  1054. })
  1055. $("#detailInfo").modal("hide");
  1056. window.toast.success("保存成功");
  1057. break;
  1058. case 701:
  1059. this.error = res.data;
  1060. break;
  1061. case 414:
  1062. this.error = {"code":"设备编码重复"};
  1063. this.toast.error(this.error.code);
  1064. break;
  1065. default:
  1066. window.toast.error("服务器错误:"+res.message);
  1067. }
  1068. },
  1069. error : (err)=>{
  1070. window.tempTip.setIndex(999);
  1071. window.tempTip.show("网络错误");
  1072. },
  1073. timeout:3000,
  1074. })
  1075. },
  1076. _checkEquipmentData(equipment){
  1077. let error = {};
  1078. if (!equipment.code)error.code = "设备编号未填写";
  1079. if (!equipment.width)error.width = "设备宽度未填写";
  1080. if (!equipment.depth)error.depth = "设备深度未填写";
  1081. //if (!equipment.repository)error.repositoryId = "设备库区未选定";
  1082. if (equipment.layer !== equipment.children.length)error.children = "设备绑定错误";
  1083. for (let i=0;i<equipment.layer;i++){
  1084. if (!equipment.children[i].height)error["children["+i+"].height"] = "设备高度不得为空"
  1085. if (!equipment.children[i].column && equipment.children[i].column!=0)error["children["+i+"].column"] = "库位列数不得为空"
  1086. if (!equipment.children[i].row && equipment.children[i].row!=0)error["children["+i+"].row"] = "库位行数不得为空"
  1087. }
  1088. return error;
  1089. },
  1090. _formatEquipmentData(equipment){
  1091. let eq = {};
  1092. eq.id = equipment.eqId;
  1093. eq.code = equipment.code;
  1094. eq.repositoryId = equipment.repository;
  1095. eq.info = JSON.stringify({'x':equipment.x,'y':equipment.y,'id':equipment.id,'turn':!!equipment.turn});
  1096. eq.depth = equipment.depth;
  1097. eq.width = equipment.width;
  1098. eq.children = equipment.children;
  1099. return eq;
  1100. },
  1101. removeLocationBind(){
  1102. if (this.isLoadLocation)return;
  1103. this.isLoadLocation = true;
  1104. $.ajax({
  1105. url : this.baseUrl+"location/removeLocationBind",
  1106. type : "post",
  1107. dataType : "JSON",
  1108. data : {id:this.current.children[this.currentEqChildIndex].id},
  1109. success : (res)=>{
  1110. switch (res.code){
  1111. case 200:
  1112. this.current.children[this.currentEqChildIndex].row = 0;
  1113. this.current.children[this.currentEqChildIndex].column = 0;
  1114. this.locations = [];
  1115. window.toast.success("解除成功!");
  1116. break;
  1117. default:
  1118. window.toast.error("库位无法释放,解除失败");
  1119. }
  1120. },
  1121. error : (err)=>{
  1122. window.tempTip.setIndex(999);
  1123. window.tempTip.show("网络错误");
  1124. },
  1125. complete:()=>{
  1126. this.isLoadLocation = false;
  1127. },
  1128. timeout:3000,
  1129. })
  1130. },
  1131. locationBatchBind(){
  1132. $("#loading").show();
  1133. let arr = this.batchEquipment[this.batchEquipmentSign];
  1134. let request = [];
  1135. let failTipList = {};
  1136. arr.forEach(index=>{
  1137. let eq = this.equipmentElements[index];
  1138. if (!eq){
  1139. window.toast.error("异常设备选择");
  1140. }else if (!eq.children || eq.children.length===0 || !eq.children[this.currentEqChildIndex]){
  1141. failTipList[eq.code]="详情尚未加载完毕";
  1142. }else{
  1143. let item = eq.children[this.currentEqChildIndex];
  1144. let code = eq.code+'-'+((this.currentEqChildIndex+1)<10 ? '0'+(this.currentEqChildIndex+1) : (this.currentEqChildIndex+1));
  1145. request.push(Object.assign({id:item.id,code:code},
  1146. this.buildPool))
  1147. }
  1148. });
  1149. $.ajax({
  1150. url : this.baseUrl+"location/locationBatchBound",
  1151. type : "post",
  1152. dataType : "JSON",
  1153. data : JSON.stringify(request),
  1154. headers:{'Content-Type':'application/json;charset=utf8'},
  1155. success : (res)=>{
  1156. switch (res.code){
  1157. case 200:
  1158. $("#locationModal").modal('hide');
  1159. window.toast.success("构建完毕!");
  1160. this.failTipList = Object.assign(failTipList,res.data);
  1161. if (JSON.stringify(this.failTipList)!=="{}"){
  1162. $("#failTipList").modal("show");
  1163. }
  1164. let ele = document.querySelectorAll("#locationAttr span.el-center")[this.current.layer-1-this.currentEqChildIndex];
  1165. ele.className += " bg-success";
  1166. break;
  1167. default:
  1168. window.toast.error(res.message);
  1169. }
  1170. },
  1171. error : (err)=>{
  1172. window.tempTip.setIndex(999);
  1173. window.tempTip.show("网络错误");
  1174. },
  1175. complete:(req,status)=>{
  1176. $("#loading").hide();
  1177. if (status==='timeout'){
  1178. window.toast.error("库位批量构建失败,响应超时");
  1179. }
  1180. },
  1181. timeout:3000,
  1182. });
  1183. },
  1184. locationBind(){
  1185. if (this.batchSign){
  1186. this.locationBatchBind();
  1187. return;
  1188. }
  1189. if (this.isLoadLocation)return;
  1190. let eq = this.current.children[this.currentEqChildIndex];
  1191. let code = this.current.code+'-'+((this.currentEqChildIndex+1)<10 ? '0'+(this.currentEqChildIndex+1) : (this.currentEqChildIndex+1));
  1192. this.isLoadLocation = true;
  1193. $.ajax({
  1194. url : this.baseUrl+"location/locationBind",
  1195. type : "post",
  1196. dataType : "JSON",
  1197. headers:{'Content-Type':'application/json;charset=utf8'},
  1198. data : JSON.stringify(Object.assign({id:eq.id,code:code},this.buildPool)),
  1199. success : (res)=>{
  1200. switch (res.code){
  1201. case 200:
  1202. this.locations = res.data;
  1203. window.toast.success("构建成功!");
  1204. this.current.children[this.currentEqChildIndex].row = Number(this.buildPool.row);
  1205. this.current.children[this.currentEqChildIndex].column = Number(this.buildPool.column);
  1206. this.buildPool = {};
  1207. this.$forceUpdate();
  1208. break;
  1209. default:
  1210. window.toast.error(res.message);
  1211. }
  1212. },
  1213. error : (err)=>{
  1214. window.tempTip.setIndex(999);
  1215. window.tempTip.show("网络错误");
  1216. },
  1217. complete:(req,status)=>{
  1218. this.isLoadLocation = false;
  1219. if (status==='timeout'){
  1220. window.toast.error("库位建立失败,响应超时");
  1221. }
  1222. },
  1223. timeout:3000,
  1224. })
  1225. },
  1226. showAddWarehouseDetail(){
  1227. if (this.ws.length>0){
  1228. $("#warehouseDetail").modal("show");
  1229. return;
  1230. }
  1231. $.ajax({
  1232. url : this.baseUrl+"warehouse/getList",
  1233. type : "get",
  1234. dataType : "JSON",
  1235. success : (res)=>{
  1236. switch (res.code){
  1237. case 200:
  1238. this.ws = res.data;
  1239. $("#warehouseDetail").modal("show");
  1240. break;
  1241. default:
  1242. window.toast.error("仓库获取失败");
  1243. }
  1244. },
  1245. error : (err)=>{
  1246. window.tempTip.setIndex(999);
  1247. window.tempTip.show("网络错误");
  1248. },
  1249. complete:(req,status)=>{
  1250. this.isLoadLocation = false;
  1251. if (status==='timeout'){
  1252. window.toast.error("获取仓库超时");
  1253. }
  1254. },
  1255. timeout:3000,
  1256. })
  1257. },
  1258. addWarehouseDetail(){
  1259. $.ajax({
  1260. url : this.baseUrl+"warehouse/detail",
  1261. type : "post",
  1262. dataType : "JSON",
  1263. headers:{'Content-Type':'application/json;charset=utf8'},
  1264. data : JSON.stringify(this.warehouseDetail),
  1265. success : (res)=>{
  1266. switch (res.code){
  1267. case 200:
  1268. window.toast.success("仓库新建成功");
  1269. this.warehouses = res.data;
  1270. $("#warehouseDetail").modal("hide");
  1271. break;
  1272. default:
  1273. window.toast.error(res.message);
  1274. }
  1275. },
  1276. error : (err)=>{
  1277. window.tempTip.setIndex(999);
  1278. window.tempTip.show("网络错误");
  1279. },
  1280. timeout:3000,
  1281. })
  1282. },
  1283. openRepository(){
  1284. $.ajax({
  1285. url : this.baseUrl+"repository/group",
  1286. type : "get",
  1287. dataType : "JSON",
  1288. data:{id:this.selected},
  1289. success : (res)=>{
  1290. switch (res.code){
  1291. case 200:
  1292. this.group = res.data;
  1293. $("#repository").modal("show");
  1294. break;
  1295. default:
  1296. window.toast.error("获取区域失败");
  1297. }
  1298. },
  1299. error : (err)=>{
  1300. window.tempTip.setIndex(999);
  1301. window.tempTip.show("网络错误");
  1302. },
  1303. complete:(req,status)=>{
  1304. this.isLoadLocation = false;
  1305. if (status==='timeout'){
  1306. window.toast.error("获取区域超时");
  1307. }
  1308. },
  1309. timeout:3000,
  1310. })
  1311. },
  1312. addRepository(){
  1313. this.repository.warehouseDetailId = this.selected;
  1314. $.ajax({
  1315. url : this.baseUrl+"repository/addRepository",
  1316. type : "post",
  1317. dataType : "JSON",
  1318. headers:{'Content-Type':'application/json;charset=utf8'},
  1319. data:JSON.stringify(this.repository),
  1320. success : (res)=>{
  1321. switch (res.code){
  1322. case 200:
  1323. this.repositories.push(res.data);
  1324. $("#repository").modal("hide");
  1325. break;
  1326. default:
  1327. window.toast.error("库区建立失败");
  1328. }
  1329. },
  1330. error : (err)=>{
  1331. window.tempTip.setIndex(999);
  1332. window.tempTip.show("网络错误");
  1333. },
  1334. complete:(req,status)=>{
  1335. this.isLoadLocation = false;
  1336. if (status==='timeout'){
  1337. window.toast.error("建立库区超时");
  1338. }
  1339. },
  1340. timeout:3000,
  1341. })
  1342. },
  1343. /**
  1344. * 批量构建设备库位时的选中操作
  1345. * */
  1346. batchEquipmentSelected(arr,index){
  1347. this.current = this.equipmentElements[arr[0]];
  1348. this.batchEquipmentSign = index;
  1349. arr.forEach(i=>{
  1350. this.getChildren(this.equipmentElements[i]);
  1351. })
  1352. this._getLocationAttr();
  1353. },
  1354. },
  1355. filters:{
  1356. qty(code){
  1357. let inv = vue.locationMapping[code];
  1358. if(!inv)return 0;
  1359. return inv.QTY;
  1360. },
  1361. qtyOver(code){
  1362. let inv = vue.locationMapping[code];
  1363. if(!inv)return 0;
  1364. return inv.QTYALLOCATED + inv.QTYMVIN + inv.QTYMVOUT + inv.QTYONHOLD + inv.QTYPA + inv.QTYRPIN + inv.QTYRPOUT;
  1365. },
  1366. childStyle(code){
  1367. let inv = vue.locationMapping[code];
  1368. if (!inv)return '';
  1369. let qty = inv.QTY;
  1370. let other = inv.QTYALLOCATED + inv.QTYMVIN + inv.QTYMVOUT + inv.QTYONHOLD + inv.QTYPA + inv.QTYRPIN + inv.QTYRPOUT;
  1371. return (qty>0 || other>0) ?
  1372. 'color: #fff;background-color: #38c172;border-color: #38c172;' : '';
  1373. },
  1374. formatCount(tab){
  1375. let arr = tab.split("-");
  1376. return arr[0]*arr[1];
  1377. }
  1378. }
  1379. });
  1380. </script>
  1381. </html>