selectProduct.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择产品" @clickLeft="backAdd">
  4. <!--右菜单-->
  5. <template slot="right">
  6. <u-button type="success" size="small" class="u-reset-button" @click="classification"
  7. text="选择分类"></u-button>
  8. </template>
  9. </uni-nav-bar>
  10. <view class="top-wrapper">
  11. <uni-section class="dimension" v-if="obtain == '仓库'">
  12. <uni-data-select @change="(e)=>onchange(e)" v-model="dimension" :clear="false"
  13. :localdata="dimensionList"></uni-data-select>
  14. </uni-section>
  15. <uni-section v-else>
  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="wrapper">
  23. <u-list @scrolltolower="scrolltolower" class="listContent">
  24. <checkbox-group v-for="(item, index) in tableList" :key="index"
  25. @change="e => selectVal(e, item, index)">
  26. <label>
  27. <view class="listBox">
  28. <view class="listBox-sel">
  29. <checkbox :value="item.id" color="#fff" :disabled="item.disabled"
  30. :checked="item.checked" />
  31. </view>
  32. <view class="listBox-con">
  33. <view class="listBox-bottom">
  34. <view>
  35. <text>{{!fieldShow?'编码':'物品编码'}}:</text>
  36. <text class="value">{{ item.code }}</text>
  37. </view>
  38. <view>
  39. <text>{{!fieldShow?'名称':'物品名称'}}:</text>
  40. <text class="value">{{ item.name }}</text>
  41. </view>
  42. <view class="label-s">
  43. <text>牌号:</text>
  44. <text class="value">{{ item.brandNum }}</text>
  45. </view>
  46. <view class="label-s">
  47. <text>型号:</text>
  48. <text class="value">{{ item.categoryModel }}</text>
  49. </view>
  50. <view>
  51. <text>规格:</text>
  52. <text class="value">{{ item.specification }}</text>
  53. </view>
  54. <view class="label-s" v-if="dimension == 3">
  55. <text>批次号:</text>
  56. <text class="value">{{ item.batchNo }}</text>
  57. </view>
  58. <view class="label-s">
  59. <text>级别:</text>
  60. <text class="value">{{ item.level }}</text>
  61. </view>
  62. <view class="label-s" v-if="fieldShow">
  63. <text>计量数量:</text>
  64. <text class="value">{{ item.measureQuantity }}</text>
  65. </view>
  66. <view class="label-s" v-if="fieldShow">
  67. <text>计量单位:</text>
  68. <text class="value">{{ item.measureUnit }}</text>
  69. </view>
  70. <view class="label-s">
  71. <text>重量:</text>
  72. <text class="value">{{ item.weight }}</text>
  73. </view>
  74. <view class="label-s">
  75. <text>重量单位:</text>
  76. <text class="value">{{ item.weightUnit }}</text>
  77. </view>
  78. <view class="label-s">
  79. <text>分类:</text>
  80. <text class="value">{{ item.categoryLevelPath }}</text>
  81. </view>
  82. <view v-if="dimension == 3">
  83. <text>包装编码:</text>
  84. <text class="value">{{ item.packageNo }}</text>
  85. </view>
  86. <view class="label-s" v-if="dimension == 3">
  87. <text>包装数量:</text>
  88. <text class="value">{{ item.packingQuantity }}</text>
  89. </view>
  90. <view class="label-s" v-if="dimension == 3">
  91. <text>包装单位:</text>
  92. <text class="value">{{ item.packingUnit }}</text>
  93. </view>
  94. <view v-if="dimension == 3 || dimension == 4">
  95. <text>发货条码:</text>
  96. <text class="value">{{ item.barcodes }}</text>
  97. </view>
  98. <view v-if="dimension == 4">
  99. <text>物料编码:</text>
  100. <text class="value">{{ item.no }}</text>
  101. </view>
  102. <view v-if="dimension == 3 || dimension == 4">
  103. <text>物料代号:</text>
  104. <text class="value">{{ item.materielDesignation }}</text>
  105. </view>
  106. <view v-if="dimension == 3 || dimension == 4">
  107. <text>客户代号:</text>
  108. <text class="value">{{ item.clientCode }}</text>
  109. </view>
  110. <view v-if="dimension == 3 || dimension == 4">
  111. <text>刻码:</text>
  112. <text class="value">{{ item.engrave }}</text>
  113. </view>
  114. <view v-if="dimension == 3 || dimension == 4">
  115. <text>仓库:</text>
  116. <text class="value">{{ item.warehouseName }}</text>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. </label>
  122. </checkbox-group>
  123. <u-empty class="noDate" style="margin-top: 20vh" v-if="!tableList.length"></u-empty>
  124. </u-list>
  125. </view>
  126. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  127. :selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
  128. childrenKey="children" />
  129. <view class="footer">
  130. <u-button type="success" size="small" class="u-reset-button" @click="jumpAdd">
  131. <view class="selBtn">选择( {{ checkListLen }} )</view>
  132. </u-button>
  133. </view>
  134. <screenAccess :dataSources="obtain =='主数据'?'1':'0'" ref="screen" @succeed="getData" />
  135. <u-toast ref="uToast"></u-toast>
  136. </view>
  137. </template>
  138. <script>
  139. import screenAccess from './screenAccess.vue'
  140. import {
  141. getInventoryTotalAPI
  142. } from '@/api/wms/index.js'
  143. import {
  144. treeByPid
  145. } from '@/api/pda/workOrder.js'
  146. import {
  147. getProductList,
  148. getBatchDetails,
  149. getInventoryDetails,
  150. getMaterielDetails,
  151. } from '@/api/repair'
  152. import {
  153. getList
  154. } from '@/api/classifyManage/itemInformation.js'
  155. export default {
  156. components: {
  157. screenAccess
  158. },
  159. data() {
  160. return {
  161. tableList: [],
  162. obtain: '主数据',
  163. dimension: '1', // 列表维度
  164. categoryLevelId: 6, // 分类id(默认6 查询备品备件)
  165. selectedData: ['6'],
  166. classificationList: [],
  167. pageNum: 1,
  168. isEnd: false,
  169. detailsData: {},
  170. checkedkList: [],
  171. searchKey: '',
  172. selectType: '1', // 1 单选 2 多选
  173. dimensionList: [{
  174. value: '4',
  175. text: '物料维度'
  176. },
  177. {
  178. value: '3',
  179. text: '包装维度'
  180. },
  181. {
  182. value: '2',
  183. text: '批次维度'
  184. },
  185. {
  186. value: '1',
  187. text: '物品维度'
  188. },
  189. ]
  190. }
  191. },
  192. computed: {
  193. checkListLen() {
  194. return this.checkedkList.length;
  195. },
  196. // 物品字段
  197. fieldShow() {
  198. return this.obtain == '仓库';
  199. },
  200. },
  201. onLoad(params) {
  202. this.obtain = params.obtain || '主数据';
  203. this.selectType = params.selectType || '1';
  204. },
  205. onShow() {
  206. this.getTreeList();
  207. // this.getData();
  208. },
  209. methods: {
  210. // 获取页面数据
  211. getData(parameter = {}) {
  212. let data = parameter;
  213. if (!data.scroll) {
  214. this.isEnd = false;
  215. this.pageNum = 1;
  216. this.tableList = [];
  217. } else {
  218. delete data.scroll;
  219. }
  220. if (this.obtain == '仓库') {
  221. this.changeDimension(this.dimension, parameter);
  222. } else {
  223. let obj = this.$refs.screen.mainForm || {};
  224. // 查询主数据
  225. this.warehouseData(obj);
  226. }
  227. },
  228. onchange(e) {
  229. this.dimension = e;
  230. this.getData({});
  231. },
  232. handleSearch() {
  233. this.$refs.screen.open();
  234. },
  235. //返回添加页
  236. backAdd() {
  237. uni.navigateBack();
  238. },
  239. // 主数据
  240. warehouseData(data = {}) {
  241. let form = {
  242. ...data,
  243. searchKey: this.searchKey,
  244. pageNum: this.pageNum,
  245. size: 15,
  246. categoryLevelId: this.categoryLevelId
  247. }
  248. uni.showLoading({
  249. title: '加载中'
  250. })
  251. getList(form).then((res) => {
  252. let list = res.list.map((el) => {
  253. el.categoryModel = el.modelType;
  254. el.categoryName = el.name;
  255. el.categoryCode = el.code;
  256. return el;
  257. });
  258. if (this.pageNum == 1) {
  259. this.tableList = list;
  260. } else {
  261. this.tableList.push(...list);
  262. }
  263. this.pageNum += 1
  264. this.isEnd = this.tableList.length >= res.count;
  265. uni.hideLoading();
  266. }).then((e) => {
  267. uni.hideLoading();
  268. })
  269. },
  270. // 仓库数据
  271. changeDimension(dimension, parameter = {}) {
  272. if (this.isEnd) {
  273. return
  274. }
  275. uni.showLoading({
  276. title: '加载中'
  277. })
  278. return new Promise(async (resolve, reject) => {
  279. try {
  280. let params = {
  281. // assetName: this.assetName,
  282. // dimension: this.dimension,
  283. ...parameter,
  284. pageNum: this.pageNum,
  285. size: 15,
  286. categoryLevelId: this.categoryLevelId
  287. }
  288. const api = dimension == 1 ? getProductList : dimension == 2 ?
  289. getBatchDetails : dimension == 3 ? getInventoryDetails : getMaterielDetails;
  290. let res = await api(params);
  291. let list = res.list.map((el) => {
  292. el.modelType = el.categoryModel;
  293. el.name = el.categoryName;
  294. el.code = el.categoryCode;
  295. return el;
  296. });
  297. if (this.pageNum == 1) {
  298. this.tableList = list;
  299. } else {
  300. this.tableList.push(...list);
  301. }
  302. this.pageNum += 1;
  303. this.isEnd = this.tableList.length >= res.count;
  304. uni.hideLoading();
  305. resolve();
  306. } catch (error) {
  307. uni.hideLoading()
  308. reject()
  309. }
  310. })
  311. },
  312. classification() {
  313. this.$refs.treePicker._show();
  314. },
  315. scrolltolower() {
  316. if (this.isEnd) {
  317. return
  318. }
  319. this.getData({
  320. scroll: true
  321. });
  322. },
  323. // 选择
  324. selectVal(e, val, index) {
  325. this.$set(this.tableList[index], 'checked', !this.tableList[index].checked);
  326. this.tableList.forEach((item, i) => {
  327. if (item.id != val.id) {
  328. this.$set(this.tableList[i], 'checked', false)
  329. }
  330. })
  331. this.checkedkList = this.tableList.filter(item => item.checked)
  332. },
  333. getTreeList() {
  334. treeByPid({
  335. ids: [6]
  336. }).then(res => {
  337. this.classificationList = res;
  338. this.confirm(res[0].id, res[0].name, res[0].rootCategoryLevelId)
  339. })
  340. },
  341. confirm(id, name, rootCategoryLevelId) {
  342. // this.rootCategoryLevelId = rootCategoryLevelId
  343. this.categoryLevelId = id;
  344. this.tableList = [];
  345. this.getData();
  346. },
  347. async jumpAdd() {
  348. let list = this.checkedkList;
  349. if (list.length == 0) {
  350. this.$refs.uToast.show({
  351. type: "warning",
  352. message: "请至少选择一条产品数据",
  353. })
  354. return;
  355. }
  356. //获取仓库库存
  357. // if (this.obtain == '仓库') {
  358. // let codeList = list.map((item) => item.code);
  359. // let inventoryTotalList = await getInventoryTotalAPI(codeList);
  360. // list.forEach((item) => {
  361. // let find =
  362. // inventoryTotalList.find((key) => key.code == item.code) || {};
  363. // item.availableCountBase = find.availableCountBase;
  364. // });
  365. // }
  366. // 单选
  367. if (this.selectType == '1') {
  368. uni.$emit('updateScheme', list[0]);
  369. }
  370. this.back();
  371. }
  372. }
  373. }
  374. </script>
  375. <style scoped lang="scss">
  376. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  377. .mainBox {
  378. height: 100vh;
  379. display: flex;
  380. flex-direction: column;
  381. .wrapper {
  382. // flex: 1;
  383. height: calc(100vh - 250rpx);
  384. overflow: hidden;
  385. }
  386. //底部按钮
  387. .footer {
  388. height: 45px;
  389. position: relative;
  390. display: flex;
  391. justify-content: space-between;
  392. align-items: center;
  393. bottom: 0;
  394. width: 100%;
  395. height: 50px;
  396. border-top: 1px solid #eeecec;
  397. background-color: #ffffff;
  398. z-index: 999;
  399. .bottom {
  400. margin-left: 10rpx;
  401. }
  402. .u-reset-button {
  403. position: absolute;
  404. right: 10rpx;
  405. top: 20rpx;
  406. width: 150rpx;
  407. }
  408. }
  409. .top-wrapper {
  410. background-color: #fff;
  411. display: flex;
  412. width: 750rpx;
  413. height: 88rpx;
  414. padding: 16rpx 32rpx;
  415. align-items: center;
  416. gap: 16rpx;
  417. /deep/.uni-section {
  418. margin-top: 0px;
  419. }
  420. /deep/.uni-section-header {
  421. padding: 0px;
  422. }
  423. .search_btn {
  424. width: 120rpx;
  425. height: 70rpx;
  426. line-height: 70rpx;
  427. padding: 0 24rpx;
  428. background: $theme-color;
  429. font-size: 32rpx;
  430. color: #fff;
  431. margin: 0;
  432. margin-left: 26rpx;
  433. }
  434. .menu_icon {
  435. width: 44rpx;
  436. height: 44rpx;
  437. margin-left: 14rpx;
  438. }
  439. }
  440. .dimension {
  441. width: calc(100% - 270rpx);
  442. }
  443. }
  444. </style>