cangku.vue 22 KB

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