selectProduct.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. isEnd: false,
  76. tableList: [],
  77. obtain: '主数据',
  78. dimension: '1', // 列表维度
  79. categoryLevelId: 6, // 分类id(默认6 查询备品备件)
  80. selectedData: ['6'],
  81. classificationList: [],
  82. pageNum: 1,
  83. isEnd: false,
  84. detailsData: {},
  85. checkedkList: [],
  86. searchVal: '',
  87. selectType: '1', // 1 单选 2 多选
  88. dimensionList: [{
  89. value: '4',
  90. text: '物料维度'
  91. },
  92. {
  93. value: '3',
  94. text: '包装维度'
  95. },
  96. {
  97. value: '2',
  98. text: '批次维度'
  99. },
  100. {
  101. value: '1',
  102. text: '物品维度'
  103. },
  104. ]
  105. }
  106. },
  107. components: {
  108. prodctScreen
  109. },
  110. computed: {
  111. checkListLen() {
  112. return this.checkedkList.length;
  113. },
  114. },
  115. onLoad(params) {
  116. console.log(params, '参数')
  117. this.obtain = params.obtain || '主数据';
  118. this.selectType = params.selectType || '1'
  119. },
  120. onShow() {
  121. this.getTreeList();
  122. // this.getData();
  123. },
  124. methods: {
  125. // 获取页面数据
  126. getData(parameter) {
  127. this.isEnd = false
  128. this.pageNum = 1
  129. if (this.obtain == '仓库') {
  130. this.changeDimension(this.dimension, parameter);
  131. } else {
  132. }
  133. },
  134. handleSearch() {
  135. this.$refs.screen.open();
  136. },
  137. //返回添加页
  138. backAdd() {
  139. uni.navigateBack();
  140. },
  141. // 仓库数据
  142. changeDimension(dimension, parameter = {}) {
  143. if (this.isEnd) {
  144. return
  145. }
  146. uni.showLoading({
  147. title: '加载中'
  148. })
  149. return new Promise(async (resolve, reject) => {
  150. try {
  151. let params = {
  152. // assetName: this.assetName,
  153. // dimension: this.dimension,
  154. ...parameter,
  155. pageNum: this.pageNum,
  156. size: 15,
  157. categoryLevelId: this.categoryLevelId
  158. }
  159. const api = dimension == 1 ? getProductList : dimension == 2 ?
  160. getBatchDetails : dimension == 3 ? getInventoryDetails : getMaterielDetails;
  161. let res = await api(params);
  162. this.tableList = res.list.map((el) => {
  163. el.modelType = el.categoryModel;
  164. el.name = el.categoryName;
  165. el.code = el.categoryCode;
  166. return el;
  167. });
  168. this.pageNum += 1
  169. this.isEnd = this.tableList.length >= res.count;
  170. uni.hideLoading();
  171. resolve();
  172. } catch (error) {
  173. uni.hideLoading()
  174. reject()
  175. }
  176. })
  177. },
  178. classification() {
  179. this.$refs.treePicker._show();
  180. },
  181. scrolltolower() {
  182. if (this.isEnd) {
  183. return
  184. }
  185. this.getData();
  186. },
  187. // 选择
  188. selectVal(e, val, index) {
  189. this.$set(this.tableList[index], 'checked', !this.tableList[index].checked);
  190. this.tableList.forEach((item, i) => {
  191. if (item.id != val.id) {
  192. this.$set(this.tableList[i], 'checked', false)
  193. }
  194. })
  195. this.checkedkList = this.tableList.filter(item => item.checked)
  196. },
  197. getTreeList() {
  198. treeByPid({
  199. ids: [6]
  200. }).then(res => {
  201. this.classificationList = res;
  202. this.confirm(res[0].id, res[0].name, res[0].rootCategoryLevelId)
  203. })
  204. },
  205. confirm(id, name, rootCategoryLevelId) {
  206. // this.rootCategoryLevelId = rootCategoryLevelId
  207. this.categoryLevelId = id;
  208. this.tableList = [];
  209. this.getData();
  210. },
  211. async jumpAdd() {
  212. let list = this.checkedkList;
  213. if (list.length == 0) {
  214. this.$refs.uToast.show({
  215. type: "warning",
  216. message: "请至少选择一条产品数据",
  217. })
  218. return;
  219. }
  220. //获取仓库库存
  221. // if (this.obtain == '仓库') {
  222. // let codeList = list.map((item) => item.code);
  223. // let inventoryTotalList = await getInventoryTotalAPI(codeList);
  224. // list.forEach((item) => {
  225. // let find =
  226. // inventoryTotalList.find((key) => key.code == item.code) || {};
  227. // item.availableCountBase = find.availableCountBase;
  228. // });
  229. // }
  230. // 单选
  231. if (this.selectType == '1') {
  232. uni.$emit('updateScheme', list[0]);
  233. }
  234. this.back();
  235. }
  236. }
  237. }
  238. </script>
  239. <style scoped lang="scss">
  240. @import url('@/pages/salesServiceManagement/demandList/components/invoice.scss');
  241. .mainBox {
  242. height: 100vh;
  243. display: flex;
  244. flex-direction: column;
  245. .wrapper {
  246. // flex: 1;
  247. height: calc(100vh - 250rpx);
  248. overflow: hidden;
  249. }
  250. //底部按钮
  251. .footer {
  252. height: 45px;
  253. position: relative;
  254. display: flex;
  255. justify-content: space-between;
  256. align-items: center;
  257. bottom: 0;
  258. width: 100%;
  259. height: 50px;
  260. border-top: 1px solid #eeecec;
  261. background-color: #ffffff;
  262. z-index: 999;
  263. .bottom {
  264. margin-left: 10rpx;
  265. }
  266. .u-reset-button {
  267. position: absolute;
  268. right: 10rpx;
  269. top: 20rpx;
  270. width: 150rpx;
  271. }
  272. }
  273. .top-wrapper {
  274. background-color: #fff;
  275. display: flex;
  276. width: 750rpx;
  277. height: 88rpx;
  278. padding: 16rpx 32rpx;
  279. align-items: center;
  280. gap: 16rpx;
  281. /deep/.uni-section {
  282. margin-top: 0px;
  283. }
  284. /deep/.uni-section-header {
  285. padding: 0px;
  286. }
  287. .search_btn {
  288. width: 120rpx;
  289. height: 70rpx;
  290. line-height: 70rpx;
  291. padding: 0 24rpx;
  292. background: $theme-color;
  293. font-size: 32rpx;
  294. color: #fff;
  295. margin: 0;
  296. margin-left: 26rpx;
  297. }
  298. .menu_icon {
  299. width: 44rpx;
  300. height: 44rpx;
  301. margin-left: 14rpx;
  302. }
  303. }
  304. .dimension {
  305. width: calc(100% - 270rpx);
  306. }
  307. }
  308. </style>