accessoryAdd.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" @clickLeft="back">
  4. <template slot="right">
  5. <u-button type="success" size="small" class="u-reset-button" @click="classification"
  6. text="选择分类"></u-button>
  7. </template>
  8. </uni-nav-bar>
  9. <view class="top-wrapper">
  10. <uni-section class="dimension" v-if="dataSources == '0'">
  11. <uni-data-select @change="(e)=>onchange(e)" v-model="dimension" :clear="false"
  12. :localdata="dimensionList">
  13. </uni-data-select>
  14. </uni-section>
  15. <uni-section v-if="dataSources == '1'">
  16. <uni-easyinput prefixIcon="search" style="width: 460rpx" v-model="searchKey" placeholder="关键字">
  17. </uni-easyinput>
  18. </uni-section>
  19. <button class="search_btn" @click="getData({})">搜索</button>
  20. <image class="menu_icon" @click="handleSearch" src="~@/static/pda/menu.svg"></image>
  21. </view>
  22. <!-- <view class="nav_box rx-sc">
  23. <view class="nav_item " :class="{active: current == 0}" @click="handNav(0)">
  24. 库存台账</view>
  25. <view class="nav_item" :class="{active: current == 1}" @click="handNav(1)">
  26. 主数据</view>
  27. <view class="add btn" v-show="current == 0" @click="add">
  28. 添加
  29. </view>
  30. <view class="remove btn" v-show="current == 1" @click="remove">
  31. 移除
  32. </view>
  33. </view> -->
  34. <view class="wrapper">
  35. <!-- v-show="current == 0" -->
  36. <u-list @scrolltolower="scrolltolower" class="listContent">
  37. <checkbox-group v-for="(item, index) in accessoriesList" :key="index"
  38. @change="e => selectVal(e, item, index)">
  39. <label>
  40. <view class="listBox">
  41. <view class="listBox-sel">
  42. <checkbox :value="item.id" color="#fff" :disabled="item.disabled"
  43. :checked="item.checked" />
  44. </view>
  45. <view class="listBox-con">
  46. <view class="listBox-bottom">
  47. <view>
  48. <text>{{!fieldShow?'编码':'物品编码'}}:</text>
  49. <text class="value">{{ item.code }}</text>
  50. </view>
  51. <view>
  52. <text>{{!fieldShow?'名称':'物品名称'}}:</text>
  53. <text class="value">{{ item.name }}</text>
  54. </view>
  55. <view class="label-s">
  56. <text>牌号:</text>
  57. <text class="value">{{ item.brandNum }}</text>
  58. </view>
  59. <view class="label-s">
  60. <text>型号:</text>
  61. <text class="value">{{ item.categoryModel }}</text>
  62. </view>
  63. <view>
  64. <text>规格:</text>
  65. <text class="value">{{ item.specification }}</text>
  66. </view>
  67. <view class="label-s" v-if="dimension == 3">
  68. <text>批次号:</text>
  69. <text class="value">{{ item.batchNo }}</text>
  70. </view>
  71. <view class="label-s">
  72. <text>级别:</text>
  73. <text class="value">{{ item.level }}</text>
  74. </view>
  75. <view class="label-s" v-if="fieldShow">
  76. <text>计量数量:</text>
  77. <text class="value">{{ item.measureQuantity }}</text>
  78. </view>
  79. <view class="label-s" v-if="fieldShow">
  80. <text>计量单位:</text>
  81. <text class="value">{{ item.measureUnit }}</text>
  82. </view>
  83. <view class="label-s">
  84. <text>重量:</text>
  85. <text class="value">{{ item.weight }}</text>
  86. </view>
  87. <view class="label-s">
  88. <text>重量单位:</text>
  89. <text class="value">{{ item.weightUnit }}</text>
  90. </view>
  91. <view v-if="dimension == 3">
  92. <text>包装编码:</text>
  93. <text class="value">{{ item.packageNo }}</text>
  94. </view>
  95. <view class="label-s" v-if="dimension == 3">
  96. <text>包装数量:</text>
  97. <text class="value">{{ item.packingQuantity }}</text>
  98. </view>
  99. <view class="label-s" v-if="dimension == 3">
  100. <text>包装单位:</text>
  101. <text class="value">{{ item.packingUnit }}</text>
  102. </view>
  103. <view v-if="dimension == 3 || dimension == 4">
  104. <text>发货条码:</text>
  105. <text class="value">{{ item.barcodes }}</text>
  106. </view>
  107. <view v-if="dimension == 4">
  108. <text>物料编码:</text>
  109. <text class="value">{{ item.no }}</text>
  110. </view>
  111. <view v-if="dimension == 3 || dimension == 4">
  112. <text>物料代号:</text>
  113. <text class="value">{{ item.materielDesignation }}</text>
  114. </view>
  115. <view v-if="dimension == 3 || dimension == 4">
  116. <text>客户代号:</text>
  117. <text class="value">{{ item.clientCode }}</text>
  118. </view>
  119. <view v-if="dimension == 3 || dimension == 4">
  120. <text>刻码:</text>
  121. <text class="value">{{ item.engrave }}</text>
  122. </view>
  123. <view v-if="dimension == 3 || dimension == 4">
  124. <text>仓库:</text>
  125. <text class="value">{{ item.warehouseName }}</text>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </label>
  131. </checkbox-group>
  132. <u-empty class="noDate" style="margin-top: 20vh" v-if="!accessoriesList.length"></u-empty>
  133. </u-list>
  134. <!-- <u-list class="listContent" v-show="current == 1">
  135. <checkbox-group v-for="(item, index) in addList" :key="index"
  136. @change="e => selectAddVal(e, item, index)">
  137. <label>
  138. <view class="listBox">
  139. <view class="listBox-sel">
  140. <checkbox :value="item.id" color="#fff" :checked="item.checked" />
  141. </view>
  142. <view class="listBox-con">
  143. <view class="listBox-bottom">
  144. <view>{{!fieldShow ? '编码' : '物品编码'}}:{{ item.categoryCode }}</view>
  145. <view>{{!fieldShow ? '名称' : '物品名称'}}:{{ item.categoryName }}</view>
  146. <view>型号:{{ item.categoryModel }}</view>
  147. <view>规格:{{ item.specification }}</view>
  148. <view class="label-s">级别:{{ item.level }}</view>
  149. <view class="label-s">库存:{{ item.measureQuantity }}</view>
  150. <view v-if="dataSources == '0'">计量单位:{{ item.measureUnit }}</view>
  151. <view>仓库:{{ item.warehouseName }}</view>
  152. </view>
  153. </view>
  154. </view>
  155. </label>
  156. </checkbox-group>
  157. <u-empty class="noDate" style="margin-top: 20vh" v-if="!addList.length"></u-empty>
  158. </u-list> -->
  159. </view>
  160. <view class="footer">
  161. <u-button type="success" size="small" class="u-reset-button" @click="jumpAdd">
  162. <view class="selBtn">选择({{ addList.length }})</view>
  163. </u-button>
  164. </view>
  165. <screenAccess :dataSources="dataSources" ref="screen" @succeed="getData" />
  166. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  167. :selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
  168. childrenKey="children" />
  169. <u-toast ref="uToast"></u-toast>
  170. </view>
  171. </template>
  172. <script>
  173. import screenAccess from './screenAccess.vue'
  174. import {
  175. getProductList,
  176. getBatchDetails,
  177. getInventoryDetails,
  178. getMaterielDetails,
  179. } from '@/api/repair';
  180. import {
  181. treeByPid
  182. } from '@/api/pda/workOrder.js';
  183. import {
  184. getList
  185. } from '@/api/classifyManage/itemInformation.js'
  186. export default {
  187. components: {
  188. screenAccess
  189. },
  190. data() {
  191. return {
  192. title: '新增配件',
  193. dataSources: '0', // 0 仓库 1 主数据
  194. accessoriesList: [], // 配件列表
  195. addList: [], // 添加列表
  196. classificationList: [],
  197. categoryLevelId: 6, // 分类id(默认6 查询备品备件)
  198. selectedData: ['6'],
  199. isEnd: false,
  200. pageNum: 1,
  201. dimensionList: [{
  202. value: '4',
  203. text: '物料维度'
  204. },
  205. {
  206. value: '3',
  207. text: '包装维度'
  208. },
  209. {
  210. value: '2',
  211. text: '批次维度'
  212. },
  213. {
  214. value: '1',
  215. text: '物品维度'
  216. },
  217. ],
  218. dimension: '1', // 列表维度
  219. current: 0,
  220. searchKey: ''
  221. }
  222. },
  223. onLoad(params) {
  224. this.dataSources = params.dataSources || '0';
  225. },
  226. computed: {
  227. // 物品字段
  228. fieldShow() {
  229. return this.dataSources == '0';
  230. },
  231. },
  232. onShow() {
  233. this.getTreeList();
  234. },
  235. methods: {
  236. handleSearch() {
  237. this.$refs.screen.open();
  238. },
  239. confirm(id, name) {
  240. this.categoryLevelId = id;
  241. this.accessoriesList = [];
  242. this.getData();
  243. },
  244. onchange(e) {
  245. this.dimension = e;
  246. this.getData({});
  247. },
  248. // 获取页面数据
  249. getData(parameter = {}) {
  250. let data = parameter;
  251. if (!data.scroll) {
  252. this.isEnd = false;
  253. this.pageNum = 1;
  254. this.accessoriesList = [];
  255. } else {
  256. delete data.scroll;
  257. }
  258. if (this.dataSources == '0') {
  259. this.changeDimension(this.dimension, data);
  260. } else {
  261. let obj = this.$refs.screen.mainForm;
  262. // 查询主数据
  263. this.warehouseData(obj);
  264. }
  265. },
  266. // 主数据
  267. warehouseData(data = {}) {
  268. let form = {
  269. ...data,
  270. searchKey: this.searchKey,
  271. pageNum: this.pageNum,
  272. size: 15,
  273. categoryLevelId: this.categoryLevelId
  274. }
  275. uni.showLoading({
  276. title: '加载中'
  277. })
  278. getList(form).then((res) => {
  279. let list = res.list.map((el) => {
  280. el.categoryModel = el.modelType;
  281. el.categoryName = el.name;
  282. el.categoryCode = el.code;
  283. return el;
  284. });
  285. if (this.pageNum == 1) {
  286. this.accessoriesList = list;
  287. } else {
  288. this.accessoriesList.push(...list);
  289. }
  290. this.pageNum += 1
  291. this.isEnd = this.accessoriesList.length >= res.count;
  292. uni.hideLoading();
  293. }).then((e) => {
  294. uni.hideLoading();
  295. })
  296. },
  297. // 仓库数据
  298. changeDimension(dimension, parameter = {}) {
  299. if (this.isEnd) {
  300. return
  301. }
  302. uni.showLoading({
  303. title: '加载中'
  304. })
  305. return new Promise(async (resolve, reject) => {
  306. try {
  307. let params = {
  308. // assetName: this.assetName,
  309. // dimension: this.dimension,
  310. ...parameter,
  311. pageNum: this.pageNum,
  312. size: 15,
  313. categoryLevelId: this.categoryLevelId
  314. }
  315. const api = dimension == 1 ? getProductList : dimension == 2 ?
  316. getBatchDetails : dimension == 3 ? getInventoryDetails : getMaterielDetails;
  317. let res = await api(params);
  318. let list = res.list.map((el) => {
  319. el.modelType = el.categoryModel;
  320. el.name = el.categoryName;
  321. el.code = el.categoryCode;
  322. return el;
  323. });
  324. if (this.pageNum == 1) {
  325. this.accessoriesList = list;
  326. } else {
  327. this.accessoriesList.push(...list);
  328. }
  329. this.pageNum += 1
  330. this.isEnd = this.accessoriesList.length >= res.count;
  331. uni.hideLoading();
  332. resolve();
  333. } catch (error) {
  334. uni.hideLoading();
  335. reject();
  336. }
  337. })
  338. },
  339. scrolltolower() {
  340. if (this.isEnd) {
  341. return;
  342. }
  343. this.getData({
  344. scroll: true
  345. });
  346. },
  347. classification() {
  348. this.$refs.treePicker._show();
  349. },
  350. // 查部门
  351. getTreeList() {
  352. treeByPid({
  353. ids: [6]
  354. }).then(res => {
  355. this.classificationList = res;
  356. this.confirm(res[0].id, res[0].name);
  357. })
  358. },
  359. handNav(index) {
  360. this.current = index;
  361. },
  362. // remove() {
  363. // this.addList = this.addList.filter(item => !item.checked);
  364. // },
  365. // add() {
  366. // let checkedList = this.accessoriesList.filter(item => item.checked);
  367. // if (checkedList.length == 0) {
  368. // this.$refs.uToast.show({
  369. // type: "warning",
  370. // message: "请至少选择一条配件数据",
  371. // })
  372. // }
  373. // let obj = {};
  374. // this.addList.map(el => {
  375. // obj[el.id] = true;
  376. // })
  377. // checkedList.map((el) => {
  378. // if (!obj[el.id]) {
  379. // let data = JSON.parse(JSON.stringify(el));
  380. // delete data.checked;
  381. // this.addList.push(data);
  382. // }
  383. // })
  384. // this.current = 1;
  385. // },
  386. // 选择配件列表
  387. selectVal(e, val, index) {
  388. this.$set(this.accessoriesList[index], 'checked', !this.accessoriesList[index].checked);
  389. this.addList = this.accessoriesList.filter(item => item.checked)
  390. },
  391. // selectAddVal(e, val, index) {
  392. // this.$set(this.addList[index], 'checked', !this.addList[index].checked);
  393. // },
  394. jumpAdd() {
  395. let list = JSON.parse(JSON.stringify(this.addList));
  396. if (list.length == 0) {
  397. this.$refs.uToast.show({
  398. type: "warning",
  399. message: "请至少添加一条物品数据",
  400. })
  401. return;
  402. }
  403. list.forEach((el) => delete el.checked);
  404. uni.$emit('updateAddessory', list);
  405. this.back();
  406. }
  407. }
  408. }
  409. </script>
  410. <style scoped lang="scss">
  411. // @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  412. .listContent {
  413. height: 100% !important;
  414. .listBox {
  415. display: flex;
  416. // height: 180rpx;
  417. padding: 20rpx 0;
  418. border-bottom: 2rpx solid #e5e5e5;
  419. .listBox-sel {
  420. height: 90rpx;
  421. width: 80rpx;
  422. // line-height: 90rpx;
  423. text-align: center;
  424. checkbox {
  425. transform: scale(1.2);
  426. }
  427. }
  428. }
  429. .listBox-con {
  430. width: 100%;
  431. // display: flex;
  432. // flex-wrap: wrap;
  433. // justify-content: space-between;
  434. align-items: center;
  435. padding: 0 18rpx 0 0;
  436. .listBox-top {
  437. width: 100%;
  438. display: flex;
  439. justify-content: space-between;
  440. padding-bottom: 10rpx;
  441. .listBox-name,
  442. .listBox-code {
  443. display: inline-block;
  444. font-size: $uni-font-size-sm;
  445. font-weight: bold;
  446. }
  447. }
  448. .listBox-bottom {
  449. width: 100%;
  450. display: flex;
  451. justify-content: space-between;
  452. font-size: $uni-font-size-sm;
  453. flex-wrap: wrap;
  454. >view {
  455. width: 100%;
  456. overflow: hidden;
  457. white-space: nowrap;
  458. text-overflow: ellipsis;
  459. }
  460. .half {
  461. width: 50%;
  462. }
  463. .label-s{
  464. width: 50%;
  465. display: inline-block !important;
  466. }
  467. }
  468. }
  469. .noDate {
  470. height: 100%;
  471. }
  472. }
  473. .mainBox {
  474. height: 100vh;
  475. display: flex;
  476. flex-direction: column;
  477. .wrapper {
  478. // flex: 1;
  479. height: calc(100vh - 250rpx);
  480. overflow: hidden;
  481. }
  482. //底部按钮
  483. .footer {
  484. height: 45px;
  485. position: relative;
  486. display: flex;
  487. justify-content: space-between;
  488. align-items: center;
  489. bottom: 0;
  490. width: 100%;
  491. height: 50px;
  492. border-top: 1px solid #eeecec;
  493. background-color: #ffffff;
  494. z-index: 999;
  495. .bottom {
  496. margin-left: 10rpx;
  497. }
  498. .u-reset-button {
  499. position: absolute;
  500. right: 10rpx;
  501. top: 20rpx;
  502. width: 150rpx;
  503. }
  504. }
  505. .top-wrapper {
  506. background-color: #fff;
  507. display: flex;
  508. width: 750rpx;
  509. height: 88rpx;
  510. padding: 16rpx 32rpx;
  511. align-items: center;
  512. gap: 16rpx;
  513. /deep/.uni-section {
  514. margin-top: 0px;
  515. }
  516. /deep/.uni-section-header {
  517. padding: 0px;
  518. }
  519. .search_btn {
  520. width: 120rpx;
  521. height: 70rpx;
  522. line-height: 70rpx;
  523. padding: 0 24rpx;
  524. background: $theme-color;
  525. font-size: 32rpx;
  526. color: #fff;
  527. margin: 0;
  528. margin-left: 26rpx;
  529. }
  530. .menu_icon {
  531. width: 44rpx;
  532. height: 44rpx;
  533. margin-left: 14rpx;
  534. }
  535. }
  536. .dimension {
  537. width: calc(100% - 270rpx);
  538. }
  539. .nav_box {
  540. padding: 6rpx 32rpx;
  541. position: relative;
  542. .btn {
  543. width: 68rpx;
  544. text-align: center;
  545. background: #1890ff;
  546. color: #fff;
  547. border: 2rpx solid;
  548. border-color: #1890ff;
  549. height: 40rpx;
  550. line-height: 40rpx;
  551. font-size: 26rpx;
  552. margin-right: 10rpx;
  553. }
  554. .remove {
  555. color: #606266;
  556. border-color: #dddddd;
  557. background: #fff;
  558. }
  559. .nav_item {
  560. font-size: 28rpx;
  561. font-weight: 400;
  562. color: $theme-color;
  563. background: #F0F8F2;
  564. margin-right: 16rpx;
  565. padding: 4rpx 16rpx;
  566. border-radius: 8rpx;
  567. border: 2rpx solid #ACD4B5;
  568. }
  569. .menu_box {
  570. position: absolute;
  571. right: 20rpx;
  572. top: 10rpx;
  573. .menu_icon {
  574. width: 44rpx;
  575. height: 44rpx;
  576. }
  577. }
  578. .active {
  579. background: $theme-color;
  580. border: 2rpx solid $theme-color;
  581. color: #FFF;
  582. }
  583. }
  584. }
  585. // @import './accessory.scss';
  586. </style>