selectProduct.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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">
  12. <uni-data-select v-model="dimension" :clear="false" :localdata="dimensionList"></uni-data-select>
  13. </uni-section>
  14. <button class="search_btn" @click="getData({})">搜索</button>
  15. <image class="menu_icon" @click="handleSearch" src="~@/static/pda/menu.svg"></image>
  16. </view>
  17. <view class="wrapper">
  18. <u-list @scrolltolower="scrolltolower" class="listContent">
  19. <checkbox-group v-for="(item, index) in tableList" :key="index"
  20. @change="e => selectVal(e, item, index)">
  21. <label>
  22. <view class="listBox">
  23. <view class="listBox-sel">
  24. <checkbox :value="item.id" color="#fff" :disabled="item.disabled"
  25. :checked="item.checked" />
  26. </view>
  27. <view class="listBox-con">
  28. <view class="listBox-bottom">
  29. <view> <text>编码:</text> <text class="value">{{ item.code }}</text> </view>
  30. <view> <text>名称:</text> <text class="value">{{ item.name }}</text> </view>
  31. <view> <text>型号:</text> <text class="value">{{ item.modelType }}</text> </view>
  32. <view> <text>规格:</text> <text class="value">{{ item.specification }}</text> </view>
  33. <view> <text>计量单位:</text> <text class="value">{{ item.measuringUnit }}</text>
  34. </view>
  35. <view> <text>重量单位:</text> <text class="value">{{ item.weightUnit }}</text> </view>
  36. <view> <text>分类:</text> <text class="value">{{ item.categoryLevelPath }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </label>
  42. </checkbox-group>
  43. <u-empty class="noDate" style="margin-top: 20vh" v-if="!tableList.length"></u-empty>
  44. </u-list>
  45. </view>
  46. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择分类"
  47. :selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
  48. childrenKey="children" />
  49. <view class="footer">
  50. <u-button type="success" size="small" class="u-reset-button" @click="jumpAdd">
  51. <view class="selBtn">选择( {{ checkListLen }} )</view>
  52. </u-button>
  53. </view>
  54. <prodctScreen ref="screen" @succeed="getData" />
  55. <u-toast ref="uToast"></u-toast>
  56. </view>
  57. </template>
  58. <script>
  59. import prodctScreen from './productScreen.vue'
  60. import {
  61. getInventoryTotalAPI
  62. } from '@/api/wms/index.js'
  63. import {
  64. treeByPid
  65. } from '@/api/pda/workOrder.js'
  66. import {
  67. getProductList,
  68. getBatchDetails,
  69. getInventoryDetails,
  70. getMaterielDetails,
  71. } from '@/api/repair'
  72. export default {
  73. data() {
  74. return {
  75. tableList: [],
  76. obtain: '主数据',
  77. dimension: '1', // 列表维度
  78. categoryLevelId: 6, // 分类id(默认6 查询备品备件)
  79. selectedData: ['6'],
  80. classificationList: [],
  81. pageNum: 1,
  82. isEnd: false,
  83. detailsData: {},
  84. checkedkList: [],
  85. searchVal: '',
  86. selectType: '1', // 1 单选 2 多选
  87. dimensionList: [{
  88. value: '4',
  89. text: '物料维度'
  90. },
  91. {
  92. value: '3',
  93. text: '包装维度'
  94. },
  95. {
  96. value: '2',
  97. text: '批次维度'
  98. },
  99. {
  100. value: '1',
  101. text: '物品维度'
  102. },
  103. ]
  104. }
  105. },
  106. components: {
  107. prodctScreen
  108. },
  109. computed: {
  110. checkListLen() {
  111. return this.checkedkList.length;
  112. },
  113. },
  114. onLoad(params) {
  115. this.obtain = params.obtain || '主数据';
  116. this.selectType = params.selectType || '1'
  117. },
  118. onShow() {
  119. this.getTreeList();
  120. // this.getData();
  121. },
  122. methods: {
  123. // 获取页面数据
  124. getData(parameter = {}) {
  125. // this.isEnd = false
  126. // this.pageNum = 1
  127. let data = parameter;
  128. if (!data.scroll) {
  129. this.isEnd = false;
  130. this.pageNum = 1;
  131. this.accessoriesList = [];
  132. } else {
  133. delete data.scroll;
  134. }
  135. if (this.obtain == '仓库') {
  136. this.changeDimension(this.dimension, parameter);
  137. } else {
  138. }
  139. },
  140. handleSearch() {
  141. this.$refs.screen.open();
  142. },
  143. //返回添加页
  144. backAdd() {
  145. uni.navigateBack();
  146. },
  147. // 仓库数据
  148. changeDimension(dimension, parameter = {}) {
  149. if (this.isEnd) {
  150. return
  151. }
  152. uni.showLoading({
  153. title: '加载中'
  154. })
  155. return new Promise(async (resolve, reject) => {
  156. try {
  157. let params = {
  158. // assetName: this.assetName,
  159. // dimension: this.dimension,
  160. ...parameter,
  161. pageNum: this.pageNum,
  162. size: 15,
  163. categoryLevelId: this.categoryLevelId
  164. }
  165. const api = dimension == 1 ? getProductList : dimension == 2 ?
  166. getBatchDetails : dimension == 3 ? getInventoryDetails : getMaterielDetails;
  167. let res = await api(params);
  168. let list = res.list.map((el) => {
  169. el.modelType = el.categoryModel;
  170. el.name = el.categoryName;
  171. el.code = el.categoryCode;
  172. return el;
  173. });
  174. if (this.pageNum == 1) {
  175. this.tableList = list;
  176. } else {
  177. this.tableList.push(...list);
  178. }
  179. this.pageNum += 1
  180. this.isEnd = this.tableList.length >= res.count;
  181. uni.hideLoading();
  182. resolve();
  183. } catch (error) {
  184. uni.hideLoading()
  185. reject()
  186. }
  187. })
  188. },
  189. classification() {
  190. this.$refs.treePicker._show();
  191. },
  192. scrolltolower() {
  193. if (this.isEnd) {
  194. return
  195. }
  196. this.getData({
  197. scroll: true
  198. });
  199. },
  200. // 选择
  201. selectVal(e, val, index) {
  202. this.$set(this.tableList[index], 'checked', !this.tableList[index].checked);
  203. this.tableList.forEach((item, i) => {
  204. if (item.id != val.id) {
  205. this.$set(this.tableList[i], 'checked', false)
  206. }
  207. })
  208. this.checkedkList = this.tableList.filter(item => item.checked)
  209. },
  210. getTreeList() {
  211. treeByPid({
  212. ids: [6]
  213. }).then(res => {
  214. this.classificationList = res;
  215. this.confirm(res[0].id, res[0].name, res[0].rootCategoryLevelId)
  216. })
  217. },
  218. confirm(id, name, rootCategoryLevelId) {
  219. // this.rootCategoryLevelId = rootCategoryLevelId
  220. this.categoryLevelId = id;
  221. this.tableList = [];
  222. this.getData();
  223. },
  224. async jumpAdd() {
  225. let list = this.checkedkList;
  226. if (list.length == 0) {
  227. this.$refs.uToast.show({
  228. type: "warning",
  229. message: "请至少选择一条产品数据",
  230. })
  231. return;
  232. }
  233. //获取仓库库存
  234. // if (this.obtain == '仓库') {
  235. // let codeList = list.map((item) => item.code);
  236. // let inventoryTotalList = await getInventoryTotalAPI(codeList);
  237. // list.forEach((item) => {
  238. // let find =
  239. // inventoryTotalList.find((key) => key.code == item.code) || {};
  240. // item.availableCountBase = find.availableCountBase;
  241. // });
  242. // }
  243. // 单选
  244. if (this.selectType == '1') {
  245. uni.$emit('updateScheme', list[0]);
  246. }
  247. this.back();
  248. }
  249. }
  250. }
  251. </script>
  252. <style scoped lang="scss">
  253. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  254. .mainBox {
  255. height: 100vh;
  256. display: flex;
  257. flex-direction: column;
  258. .wrapper {
  259. // flex: 1;
  260. height: calc(100vh - 250rpx);
  261. overflow: hidden;
  262. }
  263. //底部按钮
  264. .footer {
  265. height: 45px;
  266. position: relative;
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. bottom: 0;
  271. width: 100%;
  272. height: 50px;
  273. border-top: 1px solid #eeecec;
  274. background-color: #ffffff;
  275. z-index: 999;
  276. .bottom {
  277. margin-left: 10rpx;
  278. }
  279. .u-reset-button {
  280. position: absolute;
  281. right: 10rpx;
  282. top: 20rpx;
  283. width: 150rpx;
  284. }
  285. }
  286. .top-wrapper {
  287. background-color: #fff;
  288. display: flex;
  289. width: 750rpx;
  290. height: 88rpx;
  291. padding: 16rpx 32rpx;
  292. align-items: center;
  293. gap: 16rpx;
  294. /deep/.uni-section {
  295. margin-top: 0px;
  296. }
  297. /deep/.uni-section-header {
  298. padding: 0px;
  299. }
  300. .search_btn {
  301. width: 120rpx;
  302. height: 70rpx;
  303. line-height: 70rpx;
  304. padding: 0 24rpx;
  305. background: $theme-color;
  306. font-size: 32rpx;
  307. color: #fff;
  308. margin: 0;
  309. margin-left: 26rpx;
  310. }
  311. .menu_icon {
  312. width: 44rpx;
  313. height: 44rpx;
  314. margin-left: 14rpx;
  315. }
  316. }
  317. .dimension {
  318. width: calc(100% - 270rpx);
  319. }
  320. }
  321. </style>