cangku.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <div class="sample-content">
  3. <!-- 表格組件 -->
  4. <div class="top-content">
  5. <div class="top-title">仓库可视化</div>
  6. <div class="query-content">
  7. <el-form :inline="true" :model="formInline" class="demo-form-inline">
  8. <el-form-item label="仓库名称:">
  9. <el-select
  10. v-model="formInline.cang_ku_ming_chen_value"
  11. placeholder="请选择样品"
  12. >
  13. <el-option
  14. v-for="(item, index) in cangkuOption"
  15. :key="index"
  16. placeholder="区域"
  17. :label="item.cang_ku_ming_chen"
  18. :value="item.cang_ku_ming_chen"
  19. ></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item style="margin-left: 50px" label="区域名称:">
  23. <el-select
  24. v-model="formInline.qu_yu_value"
  25. placeholder="请选择区域名称"
  26. >
  27. <el-option
  28. v-for="(item, index) in quyu_arr"
  29. :key="index"
  30. placeholder="区域"
  31. :label="item.qu_yu_"
  32. :value="item.qu_yu_"
  33. ></el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item>
  37. <button
  38. type="button"
  39. class="el-button el-button--primary el-button--mini"
  40. @click="onSubmits"
  41. >
  42. <i class="ibps-icon-search"></i><span>查询</span>
  43. </button>
  44. </el-form-item>
  45. </el-form>
  46. </div>
  47. </div>
  48. <div class="test-quyu">
  49. <div class="test-list">
  50. <ul class="list-items">
  51. <li
  52. class="list-item quyu-item"
  53. :style="{
  54. background: quyuShow == item.qu_yu_ ? '#FF9900' : '#e5baba',
  55. }"
  56. @click="qu_yu_Event"
  57. v-for="item in quyu_arr"
  58. :key="item.qu_yu_"
  59. >
  60. <div v-if="item.qu_yu_.includes('冰箱')">
  61. {{ item.qu_yu_ | freezerFilters }}({{ item.cun_chu_tiao_jian }})
  62. </div>
  63. <div v-if="!item.qu_yu_.includes('冰箱')">
  64. {{ item.qu_yu_ | freezerFilters }}
  65. </div>
  66. </li>
  67. </ul>
  68. </div>
  69. </div>
  70. <div class="body-content">
  71. <div class="right-view">
  72. <div class="goods-items">
  73. <div class="show-demo" v-for="(item, index) in listData" :key="index">
  74. <div>
  75. <div class="goods-level">
  76. <div class="level-dsc">第{{ index | indexfilter(listData) }}层</div>
  77. <div class="goods-list">
  78. <div
  79. v-for="(it, index) in listData[index]"
  80. :key="index"
  81. class="goods-dsc"
  82. :style="{
  83. background: !it.wu_liao_bian_ma_ ? '#67c23a':'' ,
  84. }"
  85. >
  86. <div class="top-dsc">
  87. <div class="position">
  88. <p>名称:{{ it.wu_liao_ming_chen }}</p>
  89. <p>编码:{{ it.wu_liao_bian_ma_ || "空" }}</p>
  90. <p>位置:{{ it.cun_fang_wei_zhi_ || "空" }}</p>
  91. <p>货号:{{ it.huo_hao_ || "空" }}</p>
  92. </div>
  93. <div class="right-content">
  94. <p>入库批号:{{ it.ru_ku_pi_hao_ || "空" }}</p>
  95. <p>存储条件:{{ it.cun_chu_yao_qiu_ || "空" }}</p>
  96. <p>有效期:{{ it.you_xiao_qi_ || "空" }}</p>
  97. <p>库存量:{{ it.ku_cun_liang_ || "空" }}</p>
  98. </div>
  99. <!-- <div class="condition">{{ it.cun_chu_tiao_jian }}</div> -->
  100. </div>
  101. <div class="bottom-dsc">
  102. <!-- {{ it.wu_pin_ming_cheng | specimenFilters }} -->
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <!-- <div class="goodshelf-name" v-if="index == 1">
  109. {{ desString }}
  110. </div> -->
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </template>
  117. <script>
  118. import curdPost from "@/business/platform/form/utils/custom/joinCURD.js";
  119. // import curdPost from "@/business/platform/form/utils/custom/joinCURD.js";
  120. /*
  121. [
  122. 1:{ //第一层
  123. 1: {[{item:1},{item2:2}]} //第一个区域
  124. 2:{[{item:1},{item2:2}]} //第二个区域
  125. },
  126. 2:{ //第二层
  127. 1:{[{item:1},{item2:2}]} //第一个区域
  128. 2:{[{item:1},{item2:2}]} //第二个区域
  129. }
  130. ]
  131. */
  132. export default {
  133. data() {
  134. return {
  135. cangkuOption: [],
  136. formInline: {
  137. cang_ku_ming_chen_value: " 主仓库",
  138. qu_yu_value: "1号冰箱",
  139. huo_jia_value: "",
  140. },
  141. huojiaInfo: {
  142. empty: "",
  143. al: "",
  144. },
  145. listData: [],
  146. desString: "",
  147. warehouseOptions: [],
  148. quyu_arr: [],
  149. huo_jia_arr: [],
  150. // qu_yu_value: "",
  151. desShow: true,
  152. quyuShow: "",
  153. huojiashow: "",
  154. firstLoadActive: "false",
  155. selectActive: "",
  156. cenghao: [],
  157. warehouse: [],
  158. loading: false,
  159. pagination: {},
  160. secondshow: false,
  161. };
  162. },
  163. filters: {
  164. indexfilter: function (value,data) {
  165. if (data[0]) {
  166. return value + 1;
  167. } else {
  168. return value;
  169. }
  170. },
  171. laySlice: function (value) {
  172. return value.split("-")[2];
  173. },
  174. freezerFilters: function (value) {
  175. if (value.includes("冷藏柜")) {
  176. return value.replace("冷藏柜", "冰箱");
  177. } else if (value.includes("冷冻柜")) {
  178. return value.replace("冷冻柜", "冰箱");
  179. } else {
  180. return value;
  181. }
  182. },
  183. specimenFilters: function (value) {
  184. if (value == "" || value == undefined) {
  185. return "未占用";
  186. } else {
  187. return value;
  188. }
  189. },
  190. bian_hao_Filters: function (value) {
  191. if (!value || value == undefined || value == "") {
  192. return "无";
  193. } else {
  194. return value;
  195. }
  196. },
  197. },
  198. mounted() {
  199. this.loadQueryData();
  200. this.firstLoadViewData();
  201. this.firstLoadQuyu("主仓库");
  202. },
  203. methods: {
  204. firstLoadQuyu(cang_ku) {
  205. let sqlString = `select DISTINCT subStr(wei_zhi_,1,4) as wei_zhi_,cun_chu_tiao_jian,qu_yu_ from t_ck where cang_ku_ming_chen = '${cang_ku}' order by wei_zhi_ asc`;
  206. var this_ = this;
  207. curdPost("sql", sqlString).then((response) => {
  208. this_.quyu_arr = response.variables.data;
  209. this_.quyu_arr.forEach(it=>{
  210. it.wei_zhi_.includes("-")?"":it.qu_yu_ =it.qu_yu_+it.wei_zhi_.slice(3,4);
  211. })
  212. if (!this.firstLoadActive) {
  213. this_.formInline.qu_yu_value = "";
  214. }
  215. });
  216. },
  217. firstLoadViewData() {
  218. //首次加载视图数据 默认中心仓库 耗材区
  219. this.formInline.cang_ku_ming_chen_value = "主仓库";
  220. this.formInline.qu_yu_value = "1号冰箱";
  221. this.selectActive = 1;
  222. this.firstLoadActive = true;
  223. this.quyuShow = "1号冰箱";
  224. var sqlString ="select * from t_mjwlgl where cun_fang_wei_zhi_ like" +"'%" +"BX1T" +"%'";
  225. this.queryLoad(sqlString, "BX1T");
  226. },
  227. sqlSlice(value,num) {
  228. if(value.includes("冰箱")){
  229. if(value.includes("T")||value.includes("B")||value.includes("L")||value.includes("R")){
  230. return 'BX'+num+value.slice(4,5);
  231. }else{
  232. return 'BX' +num
  233. }
  234. }else if(value.includes("货架")){
  235. return "HJ"+num;
  236. }else if(value.includes("试剂柜")){
  237. return "SJG"+num;
  238. }
  239. },
  240. loadQueryData() {//查询选择仓库数据查询
  241. var sqlString = "select distinct cang_ku_ming_chen from t_ck ";
  242. var this_ = this;
  243. curdPost("sql", sqlString).then((response) => {
  244. this_.cangkuOption = response.variables.data;
  245. this_.cangkuOption.forEach((item, index) => {
  246. if (!item) {
  247. this_.cangkuOption.splice(index, 1);
  248. }
  249. });
  250. });
  251. },
  252. onSubmits() { //头部按钮查询事
  253. this.desShow = false;
  254. let value = this.formInline.qu_yu_value
  255. let num = value.split("号")[0];
  256. let type = this.sqlSlice(value,num);
  257. var sqlString =`select * from t_mjwlgl where cun_fang_wei_zhi_ like ` +
  258. "'%" +
  259. type +
  260. "%'";
  261. this.queryLoad(sqlString, type);
  262. this.formInline.qu_yu_value = value;
  263. this.quyuShow = value
  264. },
  265. queryLoad(sql, py) {
  266. var datas = [];
  267. this.cenghao = [];
  268. const labelsMap = {}; // 货架分层的数据初始化
  269. let typeData = [];
  270. var sqltype =
  271. `select DISTINCT SUBSTR(wei_zhi_,1,6) as wei_zhi_ from t_ck where wei_zhi_ like ` +"'%" +py +"%'" +"ORDER BY wei_zhi_ ASC "; //
  272. curdPost("sql", sqltype).then((res) => {
  273. typeData = res.variables.data; //查询该位置具有多少层
  274. curdPost("sql", sql).then((res) => {//sql 查询该位置在物料管理库存信息的物料
  275. datas = res.variables.data;// 该位置的所有物料信息
  276. typeData.forEach((item) => { //组件以货架分层的数据: {1:[],2:[],3:[],4:[],5:[],6}
  277. let num = item.wei_zhi_.split("-")[1];
  278. labelsMap[num] = [];// 货架分层的数据初始化
  279. });
  280. if (datas.length == 0) { //该位置(冰箱)一个物料都没有
  281. for (var prop in labelsMap) {
  282. typeData.forEach((item) => { //组件以货架分层的数据: {1:[],2:[],3:[],4:[],5:[],6}
  283. let num = item.wei_zhi_.split("-")[1];
  284. if(num == prop){
  285. labelsMap[prop].push({ cun_fang_wei_zhi_: item.wei_zhi_ });
  286. }
  287. });
  288. }
  289. this.listData = labelsMap;
  290. return;
  291. }
  292. datas.forEach((item) => {//有物料存在该区域
  293. let props1 = item.cun_fang_wei_zhi_.split("-")[1];
  294. for (var prop in labelsMap) {
  295. if (labelsMap.hasOwnProperty(prop)) {
  296. if (prop == props1) {
  297. labelsMap[prop].push(item);
  298. }
  299. if (prop != props1 && labelsMap[prop].length == 0) {
  300. typeData.forEach((item) => { //组件以货架分层的数据: {1:[],2:[],3:[],4:[],5:[],6}
  301. let num = item.wei_zhi_.split("-")[1];
  302. if(num == prop){
  303. labelsMap[prop].push({ cun_fang_wei_zhi_: item.wei_zhi_});
  304. // labelsMap[prop].push({ "zhuangtai": "空"});
  305. }
  306. });
  307. // labelsMap[prop].push({ cun_fang_wei_zhi_: "空" });
  308. }
  309. }
  310. }
  311. });
  312. let newarr = [];
  313. for (var prop in labelsMap) {
  314. if (labelsMap.hasOwnProperty(prop)) {
  315. if (labelsMap[prop].length > 1) {
  316. var item = labelsMap[prop].slice(1);
  317. newarr.push(item);
  318. } else {
  319. newarr.push(labelsMap[prop]);
  320. }
  321. }
  322. }
  323. this.listData = newarr;
  324. console.log(this.listData, "listData");
  325. });
  326. });
  327. },
  328. qu_yu_Event(e) { //点击区域事件,加载可视化视图
  329. let value = e.target.innerText;
  330. let num = value.split("号")[0];
  331. let type = this.sqlSlice(value,num);
  332. var sqlString =`select * from t_mjwlgl where cun_fang_wei_zhi_ like ` +
  333. "'%" +
  334. type +
  335. "%'";
  336. this.queryLoad(sqlString, type);
  337. this.formInline.qu_yu_value = value;
  338. this.quyuShow = value;
  339. },
  340. blackEvent() {
  341. this.desShow = true;
  342. },
  343. },
  344. watch: {
  345. //监控仓库名称变化 触发第一次加载数据
  346. "formInline.cang_ku_ming_chen_value": async function (newdata) {
  347. this.firstLoadQuyu(newdata);
  348. },
  349. "formInline.qu_yu_value": function (newdata) {
  350. this.qu_yu_value = newdata;
  351. this.quyuShow = newdata;
  352. this.firstLoadActive = false;
  353. },
  354. },
  355. };
  356. </script>
  357. <style lang="scss" scoped>
  358. ul {
  359. margin: 0;
  360. }
  361. p {
  362. padding: 0;
  363. margin: 0;
  364. }
  365. .sample-content {
  366. width: 100%;
  367. .top-content {
  368. width: 100%;
  369. .top-title {
  370. text-align: center;
  371. font-weight: bold;
  372. width: 100%;
  373. font-size: 18px;
  374. line-height: 40px;
  375. }
  376. .query-content {
  377. display: flex;
  378. margin-left: 25px;
  379. }
  380. }
  381. .test-quyu,
  382. .huojia {
  383. width: 100%;
  384. .list-items {
  385. display: flex;
  386. cursor: pointer;
  387. .wDTianjian::after {
  388. content: "2-6";
  389. }
  390. .quyu-item {
  391. border: 1px solid #a172ab;
  392. background: #0099cc;
  393. }
  394. .huojia-item {
  395. background: #99ccff;
  396. }
  397. .list-item {
  398. padding: 4px 14px;
  399. height: 30px;
  400. background-color: #cec6a4;
  401. text-align: center;
  402. line-height: 30px;
  403. margin-left: 20px;
  404. margin-bottom: 6px;
  405. /* margin-top: 6px; */
  406. border-radius: 10px;
  407. position: relative;
  408. .tiaojian {
  409. // position: absolute;
  410. // right: 0px;
  411. // top: 0px;
  412. // background-color: #f56c6c;
  413. // border-radius: 10px;
  414. // color: #fff;
  415. // display: inline-block;
  416. // font-size: 12px;
  417. // height: 18px;
  418. // line-height: 18px;
  419. // padding: 0 6px;
  420. // text-align: center;
  421. // white-space: nowrap;
  422. // border: 1px solid #fff;
  423. font-size: 12px;
  424. }
  425. }
  426. }
  427. .cangku-mingchen {
  428. width: 100%;
  429. text-align: left;
  430. margin-left: 50px;
  431. }
  432. }
  433. .body-content {
  434. margin-bottom: 70px;
  435. display: flex;
  436. box-sizing: border-box;
  437. height: calc(100vh - 240px);
  438. overflow-x: hidden;
  439. overflow-y: scroll;
  440. .black {
  441. position: fixed;
  442. top: 300px;
  443. right: 100px;
  444. width: 100px;
  445. height: 40px;
  446. line-height: 40px;
  447. text-align: center;
  448. background-color: #e6a23c;
  449. z-index: 99;
  450. }
  451. .left-table {
  452. // width: 40%;
  453. ::v-deep .el-table {
  454. width: 40%;
  455. }
  456. }
  457. .right-view {
  458. z-index: 99;
  459. width: 100%;
  460. .goods-items {
  461. width: 100%;
  462. overflow-x: hidden;
  463. border: solid 2px rgb(202, 236, 247);
  464. display: flex;
  465. flex-direction: column-reverse;
  466. .show-demo {
  467. width: 100%;
  468. border-bottom: 1px solid bisque;
  469. margin: 0 auto;
  470. text-align: center;
  471. // overflow-y: scroll;
  472. .goods-level {
  473. display: flex;
  474. position: relative;
  475. margin-bottom: 6px;
  476. }
  477. .level-dsc {
  478. margin-top: 12px;
  479. position: absolute;
  480. bottom: 0;
  481. left: 10px;
  482. }
  483. .goods-list {
  484. display: flex;
  485. // justify-content: flex-start;
  486. flex-wrap: wrap-reverse;
  487. align-content: flex-start;
  488. margin-left: 50px;
  489. margin-right: 15px;
  490. .goods-dsc {
  491. cursor: pointer;
  492. // width: 170px;
  493. // height: 80px;
  494. padding: 6px 12px;
  495. border-radius: 5px;
  496. background: #e6a23c;
  497. margin-left: 12px;
  498. margin-top: 6px;
  499. // background-color: aliceblue;
  500. box-sizing: border-box;
  501. .top-dsc {
  502. display: flex;
  503. justify-content: space-between;
  504. font-size: 12px;
  505. height: 18px;
  506. line-height: 18px;
  507. .position > p {
  508. text-align: left;
  509. // color: #fbe8ff;
  510. }
  511. .right-content > p {
  512. margin-left: 15px;
  513. // color: #fbe8ff;
  514. text-align: left;
  515. }
  516. // .condition {
  517. // // color: #fbe8ff;
  518. // }
  519. }
  520. .bottom-dsc {
  521. width: 100%;
  522. font-size: 18px;
  523. height: 42px;
  524. line-height: 60px;
  525. margin-top: 20px;
  526. // color: #fbe8ff;
  527. }
  528. .goods-demo {
  529. display: block;
  530. width: 70px;
  531. height: 90px;
  532. border: 1px solid rgb(10, 9, 8);
  533. text-align: center;
  534. margin: 0;
  535. }
  536. .goods-code {
  537. text-align: center;
  538. width: 100%;
  539. height: 20px;
  540. line-height: 20px;
  541. }
  542. }
  543. }
  544. .goodshelf-name {
  545. margin-bottom: 49px;
  546. }
  547. .shelf {
  548. width: 100%;
  549. height: 40px;
  550. line-height: 40px;
  551. text-align: center;
  552. }
  553. }
  554. }
  555. }
  556. }
  557. .body-content::-webkit-scrollbar {
  558. display: none; /*隐藏滚动条*/
  559. }
  560. }
  561. </style>