cangku.vue 21 KB

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