choosePickList.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="搜索"
  8. @clickLeft="back"
  9. >
  10. <!--右菜单-->
  11. <template slot="right">
  12. <u-button
  13. type="success"
  14. size="small"
  15. class="u-reset-button"
  16. @click="openTreePicker"
  17. text="选择分类"
  18. ></u-button>
  19. </template>
  20. </uni-nav-bar>
  21. <view class="top-wrapper">
  22. <view class="searchBox rx-bc">
  23. <input
  24. v-model="keyWord"
  25. placeholder="请输入关键字搜索"
  26. class="searchInput"
  27. />
  28. <view class="rx-sc">
  29. <image
  30. class="menu_icon"
  31. src="~@/static/pda/menu.svg"
  32. @click="handleSearch"
  33. ></image>
  34. <u-button
  35. @click="doSearch"
  36. type="success"
  37. size="small"
  38. class="u-reset-button"
  39. text="搜索"
  40. >
  41. </u-button>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="list_box">
  46. <u-list @scrolltolower="scrolltolower">
  47. <checkbox-group
  48. v-for="(item, index) in list"
  49. :key="index"
  50. @change="(e) => selectVal(e, item, index)"
  51. >
  52. <label class="listBox rx-bs">
  53. <view class="listBox-sel">
  54. <checkbox
  55. :value="item.code"
  56. color="#fff"
  57. :disabled="item.disabled"
  58. :checked="item.checked"
  59. />
  60. </view>
  61. <view class="listBox-con">
  62. <view class="listBox-top rx-bc">
  63. <view> {{ item.categoryName }}</view>
  64. <view class="code">{{ item.categoryCode }} </view>
  65. </view>
  66. <view class="listBox-bottom rx">
  67. <view class="items">
  68. <text>批次号</text>{{ item.batchNo }}
  69. </view>
  70. <view class="items">
  71. <text>型号</text>{{ item.categoryModel }}
  72. </view>
  73. <view class="items">
  74. <text>规格</text>{{ item.specification }}
  75. </view>
  76. <view class="items">
  77. <text>牌号</text>{{ item.brandNum }}
  78. </view>
  79. <view class="items">
  80. <text>可用库存</text>{{ item.measureQuantity }}
  81. {{ item.measureUnit }}
  82. </view>
  83. <view class="items">
  84. <text>重量</text>{{ item.weight }}
  85. {{ item.weightUnit }}
  86. </view>
  87. </view>
  88. </view>
  89. </label>
  90. </checkbox-group>
  91. <view v-if="list.length == 0" style="margin-top: 20vh">
  92. <u-empty iconSize="150" textSize="32" text="暂无数据"> </u-empty>
  93. </view>
  94. </u-list>
  95. </view>
  96. <view class="bottom-wrapper rx-bc">
  97. <view>
  98. <checkbox
  99. v-if="!seletedAll"
  100. color="#fff"
  101. :checked="seletedAll"
  102. @tap="_seletedAll"
  103. >全选</checkbox
  104. >
  105. <checkbox
  106. class="select-all"
  107. color="#fff"
  108. v-else
  109. :checked="seletedAll"
  110. @tap="_seletedAll"
  111. >取消全选
  112. </checkbox>
  113. </view>
  114. <view>
  115. <u-button
  116. type="success"
  117. size="small"
  118. class="u-reset-button"
  119. :disabled="!checkListLen"
  120. @click="jumpAdd(1)"
  121. >
  122. <view> 选择( {{ checkListLen }} ) </view>
  123. </u-button>
  124. <!-- <u-button v-if='rootCategoryLevelId == 23' type="success" size="small" class="u-reset-button"
  125. @click="jumpAdd(2)">
  126. <view> 确认 </view>
  127. </u-button> -->
  128. </view>
  129. </view>
  130. <ba-tree-picker
  131. ref="treePicker"
  132. key="verify"
  133. :multiple="false"
  134. @select-change="confirm"
  135. title="选择分类"
  136. :localdata="classificationList"
  137. valueKey="id"
  138. textKey="name"
  139. childrenKey="children"
  140. />
  141. <SearchPopup mode="top" v-if="searchShow">
  142. <template v-slot:list>
  143. <view class="search_list">
  144. <u-form
  145. labelPosition="left"
  146. :model="formData"
  147. labelWidth="180"
  148. labelAlign="left"
  149. class="baseForm"
  150. >
  151. <u-form-item
  152. label="仓库:"
  153. class="required-form"
  154. borderBottom
  155. prop="warehouseId"
  156. >
  157. <zxz-uni-data-select
  158. :localdata="warehouseList"
  159. v-model="formData.warehouseId"
  160. dataValue="id"
  161. format="{name}"
  162. dataKey="name"
  163. filterable
  164. ></zxz-uni-data-select>
  165. </u-form-item>
  166. <u-form-item
  167. label="维度:"
  168. class="required-form"
  169. borderBottom
  170. prop="dimension"
  171. >
  172. <zxz-uni-data-select
  173. :localdata="dimensionList"
  174. v-model="formData.dimension"
  175. dataValue="id"
  176. format="{name}"
  177. dataKey="name"
  178. filterable
  179. ></zxz-uni-data-select>
  180. </u-form-item>
  181. </u-form>
  182. </view>
  183. </template>
  184. <template v-slot:operate>
  185. <view class="operate_box rx-bc">
  186. <u-button size="small" class="u-reset-button" @click="searchCancel">
  187. 重置
  188. </u-button>
  189. <u-button
  190. type="success"
  191. size="small"
  192. class="u-reset-button"
  193. @click="doSearch"
  194. >
  195. 确定
  196. </u-button>
  197. </view>
  198. </template>
  199. </SearchPopup>
  200. </view>
  201. </template>
  202. <script>
  203. import baTreePicker from "@/components/ba-tree-picker/ba-tree-picker.vue";
  204. import { tableHeader } from "../../common.js";
  205. import {
  206. treeByPid,
  207. pageeLedgerMain,
  208. assetPage,
  209. getWarehouseList,
  210. getInventoryDetails,
  211. getMaterielDetails,
  212. listInProduct,
  213. listOutsourceInWarehouse,
  214. outsourceEndPick,
  215. categoryGetList,
  216. assetPdaPage,
  217. } from "@/api/pda/workOrder.js";
  218. import SearchPopup from "../../components/searchPopup.vue";
  219. import { getProductList, getBatchList } from "@/api/pda/selfBuiltPickOrder.js";
  220. import { EventBus } from "@/utils/eventBus.js";
  221. let [isEnd] = [false];
  222. export default {
  223. components: {
  224. baTreePicker,
  225. SearchPopup,
  226. },
  227. data() {
  228. return {
  229. keyWord: null,
  230. rootCategoryLevelId: null,
  231. categoryLevelId: null,
  232. classificationList: [],
  233. treePickerShow: false,
  234. list: [],
  235. page: 1,
  236. seletedAll: false, //全选状态
  237. memoList: [],
  238. isType: null,
  239. taskId: null,
  240. pid: null, // 上个页面id
  241. storageKey: null,
  242. formData: {
  243. produceRoutingId: "",
  244. dimension: 2,
  245. },
  246. warehouseList: [],
  247. searchShow: false,
  248. stateList: [
  249. "启动",
  250. "空闲",
  251. "运行",
  252. "故障",
  253. "检修",
  254. "停机",
  255. "待料",
  256. "占用",
  257. ],
  258. classIds: [],
  259. dimensionList: [
  260. {
  261. id: 1,
  262. name: "物品维度",
  263. },
  264. {
  265. id: 2,
  266. name: "批次维度",
  267. },
  268. ],
  269. clientEnvironmentId:
  270. uni.getStorageSync("userInfo") &&
  271. uni.getStorageSync("userInfo").clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  272. };
  273. },
  274. //选择的列表长度
  275. computed: {
  276. checkListLen() {
  277. return this.memoList.length;
  278. },
  279. },
  280. onLoad(option) {
  281. this.pid = option.id;
  282. this.classIds = option.classIds || [];
  283. this.isType = option.isType;
  284. if (option.taskId == "undefined") {
  285. this.taskId = null;
  286. } else {
  287. this.taskId = option.taskId || null;
  288. }
  289. if (Object.prototype.hasOwnProperty.call(option, "classIds")) {
  290. this.classIds = option.classIds;
  291. }
  292. if (option.storageKey) {
  293. this.storageKey = option.storageKey;
  294. this.memoList = [];
  295. if (this.isType == "feed") {
  296. let _arr =
  297. (this.storageKey && uni.getStorageSync(this.storageKey)) || [];
  298. this.memoList = [
  299. ..._arr[0].modelList,
  300. ..._arr[0].equipmentList,
  301. ..._arr[0].instanceList,
  302. ..._arr[0].aridRegionList,
  303. ..._arr[0].turnover,
  304. ..._arr[0].palletList,
  305. ..._arr[0].revolvingDiskList,
  306. ..._arr[0].semiProductList,
  307. ];
  308. } else if (this.isType == "pick") {
  309. this.memoList =
  310. (this.storageKey && uni.getStorageSync(this.storageKey)) || [];
  311. } else if (this.isType == "job") {
  312. let _obj =
  313. (this.storageKey && uni.getStorageSync(this.storageKey)) || {};
  314. if (Object.prototype.hasOwnProperty.call(_obj, "turnover")) {
  315. this.memoList = this.memoList.concat(_obj.turnover);
  316. } else if (
  317. Object.prototype.hasOwnProperty.call(_obj, "equipmentList")
  318. ) {
  319. this.memoList = this.memoList.concat(_obj.equipmentList);
  320. }
  321. } else if (this.isType == "zdy") {
  322. let _arr =
  323. (this.storageKey && uni.getStorageSync(this.storageKey)) || [];
  324. if (
  325. _arr.length != 0 &&
  326. Object.prototype.hasOwnProperty.call(_arr[0], "turnover")
  327. ) {
  328. this.memoList = this.memoList.concat(_arr[0].turnover);
  329. } else if (
  330. _arr.length != 0 &&
  331. Object.prototype.hasOwnProperty.call(_arr[0], "equipmentList")
  332. ) {
  333. this.memoList = this.memoList.concat(_arr[0].equipmentList);
  334. } else if (
  335. _arr.length != 0 &&
  336. Object.prototype.hasOwnProperty.call(_arr[0], "standardOutputList")
  337. ) {
  338. this.memoList = this.memoList.concat(_arr[0].standardOutputList);
  339. } else if (
  340. _arr.length != 0 &&
  341. Object.prototype.hasOwnProperty.call(_arr[0], "bomMaterialList")
  342. ) {
  343. this.memoList = this.memoList.concat(_arr[0].bomMaterialList);
  344. }
  345. }
  346. }
  347. this.getTreeList();
  348. this.getWarehouseFn();
  349. },
  350. onUnload() {
  351. if (this.storageKey) {
  352. uni.removeStorage(this.storageKey);
  353. }
  354. },
  355. methods: {
  356. _seletedAll() {
  357. if (!this.seletedAll) {
  358. this.seletedAll = true;
  359. this.list.map((item) => {
  360. this.$set(item, "checked", true);
  361. const idx = this.memoList.findIndex((itm) => itm.id === item.id);
  362. if (idx === -1) {
  363. this.memoList.push(item);
  364. }
  365. });
  366. } else {
  367. this.seletedAll = false;
  368. this.list.map((item) => {
  369. this.$set(item, "checked", false);
  370. const idx = this.memoList.findIndex((itm) => itm.id === item.id);
  371. if (idx > -1) {
  372. this.memoList.splice(idx, 1);
  373. }
  374. });
  375. }
  376. },
  377. openTreePicker() {
  378. this.$refs.treePicker._show();
  379. },
  380. tableH(type) {
  381. return tableHeader(type);
  382. },
  383. getTreeList() {
  384. let params = {};
  385. console.log(this.classIds, "option", this.isType);
  386. if (this.isType == "feed") {
  387. params.ids = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 26, 9, 28];
  388. } else if (this.isType == "pick") {
  389. // this.treeIds =
  390. // "9, 23, 2, 1, 4, 14, 5, 8, 16, 13, 15, 6, 10, 22, 1777158952502956034";
  391. params.ids = [9, 23, 2, 1, 4, 14, 5, 8, 16, 13, 15, 6, 10, 22];
  392. } else if (this.isType == "job") {
  393. if (this.clientEnvironmentId == 2) {
  394. params["ids"] = [7];
  395. } else {
  396. params["ids"] = [4, 7];
  397. }
  398. } else if (this.isType == "zdy") {
  399. params["ids"] = JSON.parse(this.classIds);
  400. } else if (this.isType == "weiwai") {
  401. // params['ids'] = JSON.parse(this.classIds)
  402. params["ids"] = [9, 23, 2, 1, 4, 14, 5, 8, 16, 13, 15, 6, 10, 22];
  403. }
  404. treeByPid(params).then((res) => {
  405. this.classificationList = res;
  406. this.confirm([res[0].id], res[0].name, res[0].rootCategoryLevelId);
  407. });
  408. },
  409. confirm(id, name, rootCategoryLevelId) {
  410. this.rootCategoryLevelId = rootCategoryLevelId;
  411. this.categoryLevelId = id;
  412. this.list = [];
  413. console.log("是这里嘛");
  414. this.getList();
  415. },
  416. doSearch() {
  417. this.list = [];
  418. this.getList();
  419. this.searchShow = false;
  420. },
  421. scrolltolower() {
  422. if (isEnd) return;
  423. this.page++;
  424. this.getList();
  425. },
  426. getList() {
  427. let param = {
  428. categoryLevelId: this.categoryLevelId,
  429. keyWord: this.keyWord,
  430. pageNum: this.page,
  431. size: 100,
  432. taskId: this.taskId,
  433. warehouseId: this.formData.warehouseId,
  434. };
  435. if (this.rootCategoryLevelId == "11") {
  436. // 干燥区特殊处理
  437. param.size = 5;
  438. }
  439. isEnd = false;
  440. let URL = null;
  441. if (this.isType == "pick") {
  442. param.dimension = this.formData.dimension;
  443. URL = this.formData.dimension == 2 ? getBatchList : getProductList;
  444. // else if (dimension == 3) {
  445. // URL = storageApi.getPackingList;
  446. // }
  447. // param.dimension = dimension;
  448. // 领料
  449. // if (this.rootCategoryLevelId == 23) {
  450. // this.list = []
  451. // param = {}
  452. // param.workOrderId = this.pid
  453. // URL = listOutsourceInWarehouse
  454. // } else {
  455. // param.dimension = 1
  456. // URL = pageeLedgerMain
  457. // }
  458. // param.dimension = 1;
  459. // URL = pageeLedgerMain;
  460. } else if (this.isType == "feed") {
  461. // 投料
  462. if ([4, 7, 14].includes(Number(this.rootCategoryLevelId))) {
  463. URL = assetPage;
  464. } else if (this.rootCategoryLevelId == 2) {
  465. param.workOrderId = this.pid;
  466. delete param.taskId;
  467. delete param.categoryLevelId;
  468. URL = listInProduct;
  469. } else if (![2, 4, 7, 14].includes(Number(this.rootCategoryLevelId))) {
  470. URL = assetPage;
  471. // if (this.formData.dimension == 3) { // 包装维度
  472. // URL = getInventoryDetails
  473. // param.dimension = 3
  474. // param.rootCategoryLevelId = this.rootCategoryLevelId
  475. // } else if (this.formData.dimension == 4) { // 物料维度
  476. // param.dimension = 4
  477. // param.rootCategoryLevelId = this.rootCategoryLevelId
  478. // URL = getMaterielDetails
  479. // }
  480. }
  481. } else if (this.isType == "job" || this.isType == "zdy") {
  482. // 报工
  483. URL = assetPage;
  484. } else if (this.isType == "weiwai") {
  485. // 出库
  486. if (this.pid == 3) {
  487. URL = categoryGetList;
  488. } else {
  489. // URL = assetPdaPage
  490. URL = pageeLedgerMain;
  491. }
  492. }
  493. URL(param).then((res) => {
  494. if (this.rootCategoryLevelId == "11") {
  495. res.list.forEach((e) => {
  496. if (e.aridRegionList && e.aridRegionList.length != 0) {
  497. e.aridRegionList.map((i) => {
  498. const checked =
  499. this.memoList.findIndex((itm) => itm.id === i.id) > -1;
  500. let obj = {
  501. checked,
  502. name: e.name,
  503. region: e.extInfo.region,
  504. rootCategoryLevelId: e.rootCategoryLevelId,
  505. ...i,
  506. instanceId: i.id,
  507. };
  508. this.list.push(obj);
  509. });
  510. }
  511. });
  512. } else {
  513. this.list.push(
  514. ...res.list.map((i) => {
  515. const checked =
  516. this.memoList.findIndex((itm) => itm.id === i.id) > -1;
  517. const warehouseId = i.pathIds && i.pathIds.split(",")[0];
  518. return {
  519. checked,
  520. warehouseId,
  521. ...i,
  522. instanceId: i.id,
  523. };
  524. })
  525. );
  526. }
  527. isEnd = this.list.length >= res.count;
  528. });
  529. },
  530. //勾选
  531. selectVal(e, val, index) {
  532. if (val.rootCategoryLevelId == 11 && val.status == 1) {
  533. return false;
  534. }
  535. this.list[index].checked = !this.list[index].checked;
  536. this.seletedAll = !this.list.some((item) => !item.checked);
  537. const idx = this.memoList.findIndex(
  538. (item) => item.id === this.list[index].id
  539. );
  540. if (this.list[index].checked) {
  541. if (idx === -1) {
  542. this.memoList.push(this.list[index]);
  543. }
  544. } else {
  545. if (idx > -1) {
  546. this.memoList.splice(idx, 1);
  547. }
  548. }
  549. },
  550. handleSearch() {
  551. this.searchShow = true;
  552. },
  553. searchCancel() {
  554. this.formData.warehouseId = "";
  555. this.formData.dimension = 2;
  556. this.keyWord = "";
  557. this.list = [];
  558. this.page = 1;
  559. this.getList();
  560. this.searchShow = false;
  561. },
  562. //跳转回添加页面
  563. jumpAdd(type) {
  564. if (type == 1) {
  565. if (
  566. this.isType == "pick" ||
  567. this.isType == "feed" ||
  568. this.isType == "job" ||
  569. this.isType == "zdy" ||
  570. this.isType == "weiwai"
  571. ) {
  572. this.memoList.map((item) => {
  573. item.extInfo.heatNumber = "";
  574. });
  575. if (
  576. (this.isType == "zdy" || this.isType == "weiwai") &&
  577. (this.pid == 2 || this.pid == 3)
  578. ) {
  579. let param = {
  580. memoList: this.memoList,
  581. pid: this.pid,
  582. };
  583. console.log(param, "paramparamparam");
  584. EventBus.$emit("outEvent", { message: param });
  585. } else {
  586. uni.$emit("setSelectList", this.memoList, this.pid);
  587. }
  588. uni.navigateBack();
  589. }
  590. } else if (type == 2) {
  591. uni.showModal({
  592. title: "提示",
  593. content: "是否领取该工单半成品到此工序!",
  594. confirmText: "确认", //这块是确定按钮的文字
  595. success: (rr) => {
  596. if (rr.confirm) {
  597. let param = {
  598. taskId: this.taskId,
  599. workOrderId: this.pid,
  600. pickOutInList: this.list,
  601. };
  602. outsourceEndPick(param).then((res) => {
  603. // uni.$emit('setSelectList', this.list, this.pid)
  604. uni.showToast({
  605. title: "半成品领料成功,请先去审核",
  606. icon: "none",
  607. });
  608. uni.navigateBack();
  609. });
  610. }
  611. },
  612. });
  613. }
  614. },
  615. getWarehouseFn() {
  616. getWarehouseList().then((res) => {
  617. this.warehouseList = res;
  618. });
  619. },
  620. },
  621. };
  622. </script>
  623. <style lang="scss" scoped>
  624. .content-box {
  625. height: 100vh;
  626. overflow: hidden;
  627. display: flex;
  628. flex-direction: column;
  629. background-color: $page-bg;
  630. }
  631. .searchBox {
  632. background-color: #dedede;
  633. height: 90rpx;
  634. padding: 0 20rpx;
  635. .menu_icon {
  636. width: 60rpx;
  637. height: 60rpx;
  638. margin-right: 20rpx;
  639. }
  640. input {
  641. height: 70rpx;
  642. width: 480rpx;
  643. background: #f9f9f9 !important;
  644. padding-left: 10rpx;
  645. border-radius: 5rpx;
  646. }
  647. }
  648. .list_box {
  649. flex: 1;
  650. overflow: hidden;
  651. padding: 6rpx 0;
  652. .u-list {
  653. height: 100% !important;
  654. }
  655. }
  656. .bottom-wrapper {
  657. height: 80rpx;
  658. background: #fff;
  659. padding: 0 32rpx;
  660. /deep/ .uni-checkbox-input-checked {
  661. background-color: $theme-color !important;
  662. border-color: $theme-color !important;
  663. }
  664. }
  665. .listBox {
  666. margin-top: 8rpx;
  667. padding: 8rpx 24rpx;
  668. background: #fff;
  669. /deep/ .uni-checkbox-input-checked {
  670. background-color: $theme-color !important;
  671. border-color: $theme-color !important;
  672. }
  673. .listBox-con {
  674. width: 650rpx;
  675. font-weight: 400;
  676. }
  677. .listBox-top {
  678. margin-top: 6rpx;
  679. color: #090a0a;
  680. font-size: 28rpx;
  681. font-style: normal;
  682. font-weight: 800;
  683. }
  684. .listBox-bottom {
  685. color: #090a0a;
  686. font-size: 24rpx;
  687. font-style: normal;
  688. flex-wrap: wrap;
  689. .items {
  690. width: calc(50% - 1px);
  691. border-left: 1rpx solid #e3e5e5;
  692. border-right: 1rpx solid #e3e5e5;
  693. border-bottom: 1rpx solid #e3e5e5;
  694. box-sizing: border-box;
  695. word-break: break-all;
  696. text {
  697. display: inline-block;
  698. background: #f7f9fa;
  699. padding: 8rpx 10rpx;
  700. color: #157a2c;
  701. }
  702. &:nth-child(1),
  703. &:nth-child(2) {
  704. border-top: 1rpx solid #e3e5e5;
  705. margin-top: 8rpx;
  706. }
  707. }
  708. }
  709. }
  710. .search_list {
  711. min-height: 100rpx;
  712. /deep/ .baseForm {
  713. padding: 0 20rpx;
  714. }
  715. }
  716. </style>