wuliaoPosition.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <template>
  2. <div class="sample-content">
  3. <!-- 表格組件 -->
  4. <!-- <div @dblclick="clickBtn">{{ showValue }}</div> -->
  5. <div @click="clickBtn" style="cursor: pointer">
  6. <el-input
  7. placeholder="请输入内容"
  8. :value="showValue"
  9. id="valueDom"
  10. ></el-input>
  11. </div>
  12. <!-- <el-input></el-input> -->
  13. <div class="selectArea" v-if="ifshow">
  14. <div @click="close" class="close-content">
  15. <i class="el-icon-close"></i><el-button class="closeBtn">关闭视图</el-button>
  16. </div>
  17. <div class="top-content">
  18. <div class="top-title">库存可视化</div>
  19. <div class="query-content">
  20. <el-form :inline="true" :model="formInline" class="demo-form-inline">
  21. <el-form-item label="仓库名称:">
  22. <el-select
  23. v-model="formInline.cang_ku_ming_chen_value"
  24. placeholder="请选择样品"
  25. >
  26. <el-option
  27. v-for="(item, index) in cangkuOption"
  28. :key="index"
  29. placeholder="区域"
  30. :label="item.cang_ku_ming_chen"
  31. :value="item.cang_ku_ming_chen"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item style="margin-left: 50px" label="区域名称:">
  36. <el-select
  37. v-model="formInline.qu_yu_value"
  38. placeholder="请选择区域名称"
  39. >
  40. <el-option
  41. v-for="(item, index) in quyu_arr"
  42. :key="index"
  43. placeholder="区域"
  44. :label="item.qu_yu_"
  45. :value="item.qu_yu_"
  46. ></el-option>
  47. </el-select>
  48. </el-form-item>
  49. <el-form-item>
  50. <button
  51. type="button"
  52. class="el-button el-button--primary el-button--mini"
  53. @click="onSubmits"
  54. >
  55. <i class="ibps-icon-search"></i><span>查询</span>
  56. </button>
  57. </el-form-item>
  58. </el-form>
  59. </div>
  60. </div>
  61. <div class="test-quyu">
  62. <div class="test-list">
  63. <ul class="list-items">
  64. <li
  65. class="list-item quyu-item"
  66. :style="{
  67. background: quyuShow == item.qu_yu_ ? '#FF9900' : '#e5baba',
  68. }"
  69. @click="qu_yu_Event"
  70. v-for="item in quyu_arr"
  71. :key="item.qu_yu_"
  72. >
  73. <div v-if="item.qu_yu_.includes('冰箱')">
  74. {{ item.qu_yu_ | freezerFilters }}({{ item.cun_chu_tiao_jian }})
  75. </div>
  76. <div v-if="!item.qu_yu_.includes('冰箱')">
  77. {{ item.qu_yu_ | freezerFilters }}
  78. </div>
  79. </li>
  80. </ul>
  81. </div>
  82. </div>
  83. <div class="body-content">
  84. <div class="right-view">
  85. <div class="goods-items">
  86. <div
  87. class="show-demo"
  88. v-for="(item, index) in listData"
  89. :key="index"
  90. >
  91. <div>
  92. <div class="goods-level">
  93. <div class="level-dsc">
  94. <!-- 第{{ index | indexfilter(listData) }}层 -->
  95. 第{{ index }}层
  96. </div>
  97. <div class="goods-list">
  98. <div
  99. v-for="(it, index) in listData[index]"
  100. :key="index"
  101. class="goods-dsc"
  102. :style="{
  103. background:
  104. it.cun_fang_wei_zhi_ == '空' ? '' : '#67c23a',
  105. }"
  106. @click="closeView(it)"
  107. >
  108. <div class="top-dsc">
  109. <div class="position">
  110. <p>名称:{{ it.wu_liao_ming_chen || 空 }}</p>
  111. <p>
  112. 编码:{{
  113. it.wu_liao_bian_ma_ || it.wu_liao_bian_ma_
  114. }}
  115. </p>
  116. <p>位置:{{ it.wei_zhi_ || it.cun_fang_wei_zhi_ }}</p>
  117. <p>货号:{{ it.huo_hao_ || "空" }}</p>
  118. </div>
  119. <div class="right-content">
  120. <p>入库批号:{{ it.ru_ku_pi_hao_ || "空" }}</p>
  121. <p>存储条件:{{ it.cun_chu_yao_qiu_ || "空" }}</p>
  122. <p>有效期:{{ it.you_xiao_qi_ || "空" }}</p>
  123. <p>库存量:{{ it.ku_cun_liang_ || "空" }}</p>
  124. </div>
  125. <!-- <div class="condition">{{ it.cun_chu_tiao_jian }}</div> -->
  126. </div>
  127. <div class="bottom-dsc">
  128. <!-- {{ it.wu_pin_ming_cheng | specimenFilters }} -->
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. <div class="goodshelf-name" v-if="index == 1">
  135. {{ desString }}
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. import curdPost from "@/business/platform/form/utils/custom/joinCURD.js";
  146. export default {
  147. data() {
  148. return {
  149. cangkuOption: [],
  150. formInline: {
  151. cang_ku_ming_chen_value: "耗材库",
  152. qu_yu_value: "1号 货架",
  153. huo_jia_value: "",
  154. },
  155. huojiaInfo: {
  156. empty: "",
  157. al: "",
  158. },
  159. listData: [],
  160. desString: "",
  161. warehouseOptions: [],
  162. quyu_arr: [],
  163. huo_jia_arr: [],
  164. // qu_yu_value: "",
  165. desShow: true,
  166. quyuShow: "",
  167. huojiashow: "",
  168. firstLoadActive: "false",
  169. selectActive: "",
  170. cenghao: [],
  171. warehouse: [],
  172. loading: false,
  173. pagination: {},
  174. secondshow: false,
  175. ifshow: false,
  176. showValue: "",
  177. value: "111",
  178. };
  179. },
  180. props: {
  181. field: Object,
  182. formData: {
  183. type: Object,
  184. default() {
  185. return {};
  186. },
  187. },
  188. },
  189. filters: {
  190. indexfilter: function (value, data) {
  191. if (data[0]) {
  192. return value + 1;
  193. } else {
  194. return value;
  195. }
  196. },
  197. laySlice: function (value) {
  198. return value.split("-")[2];
  199. },
  200. freezerFilters: function (value) {
  201. if (value.includes("冷藏柜")) {
  202. return value.replace("冷藏柜", "冰箱");
  203. } else if (value.includes("冷冻柜")) {
  204. return value.replace("冷冻柜", "冰箱");
  205. } else {
  206. return value;
  207. }
  208. },
  209. specimenFilters: function (value) {
  210. if (value == "" || value == undefined) {
  211. return "未占用";
  212. } else {
  213. return value;
  214. }
  215. },
  216. bian_hao_Filters: function (value) {
  217. if (!value || value == undefined || value == "") {
  218. return "无";
  219. } else {
  220. return value;
  221. }
  222. },
  223. },
  224. mounted() {
  225. this.loadQueryData();
  226. this.firstLoadViewData();
  227. this.firstLoadQuyu("试剂库1");
  228. console.log(this.formData, "formData");
  229. },
  230. updated() {
  231. console.log(this.formData, "formData1");
  232. },
  233. // beforeDestroy() {
  234. // console.log(this.formData, "formData");
  235. // let id = this.formData.id;
  236. // let Status = this.formData.anNiugTai;
  237. // let ming_chen = this.formInline.cang_ku_ming_chen_value;
  238. // let weizhi = this.showValue;
  239. // console.log(weizhi, ming_chen);
  240. // if (weizhi !="" &&Status =="已入库") {
  241. // // 数据库更新
  242. // curdPost(
  243. // "update",
  244. // '{"tableName":"t_mjwlgl","paramWhere":{"wai_jian_":"' +
  245. // id +
  246. // '",},"paramCond":{"cang_ku_ming_chen":"' +
  247. // ming_chen +
  248. // '","cun_fang_wei_zhi_":"' +
  249. // weizhi +
  250. // '"}}'
  251. // )
  252. // .then((res) => {
  253. // this.$message({
  254. // message: "当前物料位置更新状态更新成功",
  255. // type: "success",
  256. // });
  257. // })
  258. // .catch((err) => {
  259. // console.log(err);
  260. // });
  261. // }
  262. // },
  263. methods: {
  264. closeView(value) {
  265. // let values = value[0];
  266. // console.log(value);
  267. // this.showValue = value[0].wei_zhi_?value[0].wei_zhi_:value[0].cun_fang_wei_zhi_;
  268. if (value.wei_zhi_) {
  269. this.showValue = value.wei_zhi_;
  270. } else if (value.cun_fang_wei_zhi_) {
  271. this.showValue = value.cun_fang_wei_zhi_;
  272. }
  273. // values.cun_fang_wei_zhi_;
  274. const name2 = "cunFangWeiZhi"; //位置
  275. const value2 = this.showValue; //字段的值
  276. this.$emit("change-data", name2, value2);
  277. const name1 = "cangKuMingCheng"; //仓库名
  278. const value1 = this.formInline.cang_ku_ming_chen_value; //字段的值
  279. this.$emit("change-data", name1, value1);
  280. this.ifshow = !this.ifshow;
  281. },
  282. close() {
  283. this.ifshow = !this.ifshow;
  284. },
  285. firstLoadQuyu(cang_ku) {
  286. let sqlString = `select distinct qu_yu_,cun_chu_tiao_jian from t_ck where cang_ku_ming_chen = '${cang_ku}' order by qu_yu_ asc`;
  287. var this_ = this;
  288. curdPost("sql", sqlString).then((response) => {
  289. this_.quyu_arr = response.variables.data;
  290. if (!this.firstLoadActive) {
  291. this_.formInline.qu_yu_value = "";
  292. }
  293. });
  294. },
  295. firstLoadViewData() {
  296. //首次加载视图数据 默认中心仓库 耗材区
  297. this.formInline.cang_ku_ming_chen_value = "试剂库1";
  298. this.formInline.qu_yu_value = "1号试剂柜";
  299. this.selectActive = 1;
  300. this.firstLoadActive = true;
  301. this.quyuShow = "1号试剂柜";
  302. var sqlString =
  303. "select * from t_mjwlgl where cang_ku_ming_chen = '试剂库1' and cun_fang_wei_zhi_ like" +
  304. "'%" +
  305. "SJG1" +
  306. "%'";
  307. this.queryLoad(sqlString, "SJG1");
  308. },
  309. sqlSlice(value) {
  310. switch (value) {
  311. case "货架":
  312. return "HJ";
  313. case "试剂柜":
  314. return "SJG";
  315. case "冰箱":
  316. return "BX";
  317. default:
  318. "";
  319. }
  320. },
  321. loadQueryData() {
  322. //查询选择仓库数据查询
  323. var sqlString = "select distinct cang_ku_ming_chen from t_ck ";
  324. var this_ = this;
  325. curdPost("sql", sqlString).then((response) => {
  326. this_.cangkuOption = response.variables.data;
  327. this_.cangkuOption.forEach((item, index) => {
  328. if (!item) {
  329. this_.cangkuOption.splice(index, 1);
  330. }
  331. });
  332. });
  333. },
  334. onSubmits() {
  335. this.desShow = false;
  336. //头部按钮查询事
  337. // var sqlString = `select * from t_mjwlgl where cang_ku_ming_chen = '${this.formInline.cang_ku_ming_chen_value}' and qu_yu_ = '${this.formInline.qu_yu_value}'`;
  338. let py = this.formInline.qu_yu_value.split("号")[1].replace(/^\s*/g, "");
  339. let num = this.formInline.qu_yu_value.split("号")[0];
  340. let quyu = this.sqlSlice(py);
  341. let type = (quyu + num).replace(/^\s*/g, "");
  342. var sqlString =
  343. "select * from t_mjwlgl where cang_ku_ming_chen = '" +
  344. this.formInline.cang_ku_ming_chen_value +
  345. "' and cun_fang_wei_zhi_ like " +
  346. "'%" +
  347. type +
  348. "%'";
  349. this.queryLoad(sqlString, type);
  350. },
  351. queryLoad(sql, py) {
  352. //数据加载
  353. let this_ = this;
  354. var datas = [];
  355. this.cenghao = [];
  356. const labelsMap = {}; // map存储
  357. let typeData = [];
  358. let typeArr = [];
  359. var sqltype =
  360. `select DISTINCT wei_zhi_ from t_ck where wei_zhi_ like ` +
  361. "'%" +
  362. py +
  363. "%'" +
  364. " and cang_ku_ming_chen ='" +
  365. this.formInline.cang_ku_ming_chen_value +
  366. "' ORDER BY wei_zhi_ ASC ";
  367. let classSql =
  368. `select DISTINCT SUBSTR(wei_zhi_,1,6) AS wei_zhi_ from t_ck where wei_zhi_ like ` +
  369. "'%" +
  370. py +
  371. "%'" +
  372. " and cang_ku_ming_chen ='" +
  373. this.formInline.cang_ku_ming_chen_value +
  374. "' ORDER BY wei_zhi_ ASC ";
  375. curdPost("sql", sqltype).then((res) => {
  376. typeData = res.variables.data; //查询具体仓库某个货架的所有位置
  377. // console.log(typeData, "位置");
  378. curdPost("sql", sql).then((res) => {
  379. datas = res.variables.data; //具体仓库某个货架的所有物料数据
  380. // console.log(datas, "数据");
  381. typeData.forEach((item) => {
  382. typeArr[item.wei_zhi_] = [];
  383. if (datas.length == 0) {
  384. typeArr[item.wei_zhi_].push(item);
  385. } else {
  386. datas.forEach((it, index) => {
  387. if (item.wei_zhi_ == it.cun_fang_wei_zhi_) {
  388. typeArr[item.wei_zhi_].push(it);
  389. } else if (
  390. item.wei_zhi_ != it.cun_fang_wei_zhi_ &&
  391. index == datas.length - 1
  392. ) {
  393. typeArr[item.wei_zhi_].push(item);
  394. }
  395. });
  396. }
  397. });
  398. // console.log(typeArr, "22222222222222");
  399. curdPost("sql", classSql).then((res2) => {
  400. let resData = res2.variables.data;
  401. resData.forEach((item) => {
  402. let layer = item.wei_zhi_;
  403. layer = layer.split("-")[1];
  404. labelsMap[layer] = [];
  405. for (var prop in typeArr) {
  406. if (typeArr.hasOwnProperty(prop)) {
  407. // console.log(prop,item.wei_zhi_);
  408. if (prop.includes(item.wei_zhi_)) {
  409. labelsMap[layer].push(...typeArr[prop]);
  410. // console.log(labelsMap)
  411. }
  412. }
  413. }
  414. });
  415. // console.log(labelsMap, "数据");
  416. this_.listData = labelsMap;
  417. });
  418. });
  419. });
  420. },
  421. qu_yu_Event(e) {
  422. //点击区域事件,加载可视化视\
  423. console.log(this.formData, "formData");
  424. let value = e.target.innerText;
  425. if (value.includes("(")) {
  426. let index = value.indexOf("(");
  427. value = value.slice(0, index);
  428. }
  429. let num = value.slice(0, 1);
  430. let py = value.split("号")[1].replace(/^\s*/g, "");
  431. let quyu = this.sqlSlice(py);
  432. let type = (quyu + num).replace(/^\s*/g, "");
  433. var sqlString =
  434. `select * from t_mjwlgl where cun_fang_wei_zhi_ like ` +
  435. "'%" +
  436. type +
  437. "%'" +
  438. " and cang_ku_ming_chen = '" +
  439. this.formInline.cang_ku_ming_chen_value +
  440. "'";
  441. // console.log(sqlString, type);
  442. this.queryLoad(sqlString, type);
  443. this.formInline.qu_yu_value = value;
  444. this.quyuShow = value;
  445. },
  446. blackEvent() {
  447. this.desShow = true;
  448. },
  449. clickBtn() {
  450. this.ifshow = !this.ifshow;
  451. },
  452. },
  453. watch: {
  454. //监控仓库名称变化 触发第一次加载数据
  455. "formInline.cang_ku_ming_chen_value": async function (newdata) {
  456. this.firstLoadQuyu(newdata);
  457. },
  458. "formInline.qu_yu_value": function (newdata) {
  459. this.qu_yu_value = newdata;
  460. this.quyuShow = newdata;
  461. this.firstLoadActive = false;
  462. },
  463. //。。。。。省略部分代码
  464. formData: {
  465. handler(val) {
  466. //根据实际逻辑处理
  467. if (!this.showValue) {
  468. this.showValue = val.cunFangWeiZhi;
  469. console.log("自定义组件formData", val);
  470. }
  471. },
  472. deep: true,
  473. immediate: true,
  474. },
  475. },
  476. };
  477. </script>
  478. <style lang="scss" scoped>
  479. ul {
  480. margin: 0;
  481. }
  482. p {
  483. padding: 0;
  484. margin: 0;
  485. }
  486. .close-content {
  487. position: absolute;
  488. right: 100px;
  489. top: 50px;
  490. //
  491. background: #f56c6c;
  492. font-size: 16px;
  493. padding:0px 4px;
  494. border-radius: 5px;
  495. color: #ffffff;
  496. .closeBtn {
  497. background: #f56c6c;
  498. border: none;
  499. padding: 2px;
  500. color: #ffffff;
  501. }
  502. }
  503. .sample-content {
  504. cursor: pointer;
  505. .selectArea {
  506. width: 100%;
  507. height: 100%;
  508. overflow: scroll;
  509. position: fixed;
  510. top: 0px;
  511. left: 0px;
  512. background: white;
  513. z-index: 2147483647!important;
  514. }
  515. .top-content {
  516. width: 100%;
  517. .top-title {
  518. text-align: center;
  519. font-weight: bold;
  520. width: 100%;
  521. font-size: 18px;
  522. line-height: 40px;
  523. }
  524. .query-content {
  525. display: flex;
  526. margin-left: 25px;
  527. }
  528. }
  529. .test-quyu,
  530. .huojia {
  531. width: 100%;
  532. .list-items {
  533. display: flex;
  534. cursor: pointer;
  535. .wDTianjian::after {
  536. content: "2-6";
  537. }
  538. .quyu-item {
  539. border: 1px solid #a172ab;
  540. background: #0099cc;
  541. }
  542. .huojia-item {
  543. background: #99ccff;
  544. }
  545. .list-item {
  546. padding: 4px 14px;
  547. height: 30px;
  548. background-color: #cec6a4;
  549. text-align: center;
  550. line-height: 30px;
  551. margin-left: 20px;
  552. margin-bottom: 6px;
  553. /* margin-top: 6px; */
  554. border-radius: 10px;
  555. position: relative;
  556. .tiaojian {
  557. // position: absolute;
  558. // right: 0px;
  559. // top: 0px;
  560. // background-color: #f56c6c;
  561. // border-radius: 10px;
  562. // color: #fff;
  563. // display: inline-block;
  564. // font-size: 12px;
  565. // height: 18px;
  566. // line-height: 18px;
  567. // padding: 0 6px;
  568. // text-align: center;
  569. // white-space: nowrap;
  570. // border: 1px solid #fff;
  571. font-size: 12px;
  572. }
  573. }
  574. }
  575. .cangku-mingchen {
  576. width: 100%;
  577. text-align: left;
  578. margin-left: 50px;
  579. }
  580. }
  581. .body-content {
  582. margin-bottom: 70px;
  583. display: flex;
  584. box-sizing: border-box;
  585. height: calc(100vh - 240px);
  586. overflow-x: hidden;
  587. overflow-y: scroll;
  588. .black {
  589. position: fixed;
  590. top: 300px;
  591. right: 100px;
  592. width: 100px;
  593. height: 40px;
  594. line-height: 40px;
  595. text-align: center;
  596. background-color: #e6a23c;
  597. z-index: 99;
  598. }
  599. .left-table {
  600. // width: 40%;
  601. ::v-deep .el-table {
  602. width: 40%;
  603. }
  604. }
  605. .right-view {
  606. z-index: 99;
  607. width: 100%;
  608. .goods-items {
  609. width: 100%;
  610. overflow-x: hidden;
  611. border: solid 2px rgb(202, 236, 247);
  612. display: flex;
  613. flex-direction: column-reverse;
  614. .show-demo {
  615. width: 100%;
  616. border-bottom: 1px solid bisque;
  617. margin: 0 auto;
  618. text-align: center;
  619. // overflow-y: scroll;
  620. .goods-level {
  621. display: flex;
  622. position: relative;
  623. margin-bottom: 6px;
  624. }
  625. .level-dsc {
  626. margin-top: 12px;
  627. position: absolute;
  628. bottom: 0;
  629. left: 10px;
  630. }
  631. .goods-list {
  632. display: flex;
  633. // justify-content: flex-start;
  634. flex-wrap: wrap-reverse;
  635. align-content: flex-start;
  636. margin-left: 50px;
  637. margin-right: 15px;
  638. .goods-dsc {
  639. cursor: pointer;
  640. // width: 170px;
  641. // height: 80px;
  642. padding: 6px 12px;
  643. border-radius: 5px;
  644. background: #e6a23c;
  645. margin-left: 12px;
  646. margin-top: 6px;
  647. // background-color: aliceblue;
  648. box-sizing: border-box;
  649. .top-dsc {
  650. display: flex;
  651. justify-content: space-between;
  652. font-size: 12px;
  653. height: 18px;
  654. line-height: 18px;
  655. .position > p {
  656. text-align: left;
  657. // color: #fbe8ff;
  658. }
  659. .right-content > p {
  660. margin-left: 15px;
  661. // color: #fbe8ff;
  662. text-align: left;
  663. }
  664. // .condition {
  665. // // color: #fbe8ff;
  666. // }
  667. }
  668. .bottom-dsc {
  669. width: 100%;
  670. font-size: 18px;
  671. height: 42px;
  672. line-height: 60px;
  673. margin-top: 20px;
  674. // color: #fbe8ff;
  675. }
  676. .goods-demo {
  677. display: block;
  678. width: 70px;
  679. height: 90px;
  680. border: 1px solid rgb(10, 9, 8);
  681. text-align: center;
  682. margin: 0;
  683. }
  684. .goods-code {
  685. text-align: center;
  686. width: 100%;
  687. height: 20px;
  688. line-height: 20px;
  689. }
  690. }
  691. }
  692. .goodshelf-name {
  693. margin-bottom: 49px;
  694. }
  695. .shelf {
  696. width: 100%;
  697. height: 40px;
  698. line-height: 40px;
  699. text-align: center;
  700. }
  701. }
  702. }
  703. }
  704. }
  705. .body-content::-webkit-scrollbar {
  706. display: none; /*隐藏滚动条*/
  707. }
  708. }
  709. </style>