selectEnterType.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. :title="`选择${warehousingName}`"
  8. @clickLeft="backAdd"
  9. >
  10. <!--右菜单-->
  11. <template slot="right">
  12. <u-button
  13. type="success"
  14. size="small"
  15. class="u-reset-button"
  16. @click="$refs.treePicker._show()"
  17. text="选择分类"
  18. ></u-button>
  19. </template>
  20. </uni-nav-bar>
  21. <view class="wrapper">
  22. <view class="searchBox">
  23. <input
  24. v-model="searchVal"
  25. placeholder="请输入编码搜索"
  26. class="searchInput"
  27. />
  28. <u-button
  29. type="icon-shixiangxinzeng"
  30. size="30"
  31. @click="doSearch"
  32. data-icon="Search"
  33. class="searchBtn"
  34. >
  35. <view class="iconfont icon-sousuo"> </view>
  36. <view class="text"> 搜索 </view>
  37. </u-button>
  38. </view>
  39. <view class="listContent">
  40. <checkbox-group
  41. v-for="(item, index) in listData"
  42. :key="index"
  43. @change="e => selectVal(e, item, index)"
  44. >
  45. <label>
  46. <view class="listBox">
  47. <view class="listBox-sel">
  48. <checkbox
  49. :value="item.code"
  50. color="#fff"
  51. :disabled="item.disabled"
  52. :checked="item.checked"
  53. />
  54. </view>
  55. <view class="listBox-con">
  56. <view class="listBox-top">
  57. <view class="listBox-name">
  58. {{ item.assetName }}
  59. </view>
  60. <view class="listBox-code">
  61. {{ item.assetCode }}
  62. </view>
  63. </view>
  64. <view class="listBox-bottom">
  65. <view v-for="(itm, index) in tableHeader" :key="index">
  66. {{ itm.label }}:{{ item[itm.prop] }}
  67. </view>
  68. </view>
  69. <!-- <view class="listBox-bottom">
  70. <view class="bot-left">
  71. 最小单元:{{ item.measurementUnit }}{{ item.unit }}/{{
  72. item.minPackUnit
  73. }}
  74. </view>
  75. </view> -->
  76. <!-- <view class="listBox-bottom">
  77. <view class="bot-left">
  78. 批次号:{{item.batchNumber}}
  79. </view>
  80. <view class="bot-right">
  81. 包装单位:{{item.packingUnit}}
  82. </view>
  83. </view> -->
  84. </view>
  85. </view></label
  86. >
  87. </checkbox-group>
  88. <u-empty style="margin-top: 20vh" v-if="!listData.length"> </u-empty>
  89. </view>
  90. </view>
  91. <view class="footer">
  92. <view class="bottom">
  93. <checkbox
  94. v-if="!seletedAll"
  95. color="#fff"
  96. :checked="seletedAll"
  97. @tap="_seletedAll"
  98. >全选</checkbox
  99. >
  100. <checkbox
  101. class="select-all"
  102. color="#fff"
  103. v-else
  104. :checked="seletedAll"
  105. @tap="_seletedAll"
  106. >取消全选
  107. </checkbox>
  108. </view>
  109. <u-button
  110. type="success"
  111. size="small"
  112. class="u-reset-button"
  113. :disabled="!checkListLen"
  114. @click="jumpAdd"
  115. >
  116. <view class="selBtn"> 选择( {{ checkListLen }} ) </view>
  117. </u-button>
  118. </view>
  119. <ba-tree-picker
  120. ref="treePicker"
  121. key="verify"
  122. :multiple="false"
  123. @select-change="confirm"
  124. title="选择分类"
  125. :localdata="classificationList"
  126. valueKey="id"
  127. textKey="name"
  128. childrenKey="children"
  129. />
  130. </view>
  131. </template>
  132. <script>
  133. import { warehousingType, tableContentData } from '../enum.js'
  134. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  135. import { post, postJ, get } from '@/utils/api.js'
  136. let [page, size, isEnd] = [1, 20, true]
  137. import { tableHeader } from '../common'
  138. export default {
  139. components: {
  140. baTreePicker
  141. },
  142. data () {
  143. return {
  144. searchVal: '',
  145. pickTabIndex: 1,
  146. popupShow: false, //右侧搜索窗
  147. typeIndex: 1,
  148. listData: [], //列表数据
  149. classificationList: [], //分类数据
  150. seletedAll: false, //全选状态
  151. bizScene: '',
  152. warehousingName: '',
  153. warehousingType: '',
  154. curId: ''
  155. }
  156. },
  157. //选择的列表长度
  158. computed: {
  159. tableHeader () {
  160. return tableHeader(+this.warehousingType)
  161. },
  162. checkListLen () {
  163. return this.listData.filter(el => el.checked).length
  164. },
  165. curTab () {
  166. return warehousingType.find(i => i.id == this.warehousingType) || {}
  167. }
  168. },
  169. onLoad ({ warehousingType, warehousingName, bizScene }) {
  170. this.bizScene = bizScene
  171. this.warehousingName = warehousingName
  172. this.warehousingType = warehousingType
  173. },
  174. //触底刷新
  175. onReachBottom: function () {
  176. if (isEnd) {
  177. return
  178. }
  179. // 显示加载图标
  180. uni.showLoading({
  181. title: '数据加载中'
  182. })
  183. //获取更多数据
  184. page++
  185. this.getList()
  186. },
  187. onShow () {
  188. this.getClassify()
  189. },
  190. methods: {
  191. //列表数据
  192. async getList () {
  193. isEnd = false
  194. if (this.bizScene == 5) {
  195. this._getAssetLedger()
  196. } else {
  197. this._getClassifyList()
  198. }
  199. },
  200. async _getClassifyList () {
  201. const params = {
  202. page,
  203. size,
  204. code: this.searchVal,
  205. classificationId: this.curId
  206. }
  207. const res = await get(
  208. this.apiUrl + `/outInWarehouse/select/getInformation`,
  209. params
  210. )
  211. uni.hideLoading()
  212. if (res?.success && this.curId == params.classificationId) {
  213. const curMap = {
  214. assetId: 'id',
  215. assetCode: 'informationCode', //编码
  216. assetName: 'informationName', //名称
  217. materialId: 'id',
  218. materialName: 'informationName',
  219. batchNo: '', //批次号
  220. unit: 'measuringUnit', //单位
  221. minPackUnit: 'packingUnit' //最小包装单位
  222. }
  223. if (page == 1) {
  224. this.listData = []
  225. }
  226. this.listData.push(
  227. ...res.data.records.map(item => {
  228. for (const key in curMap) {
  229. item[key] = curMap[key] ? item[curMap[key]] : ''
  230. }
  231. item.checked = false
  232. return item
  233. })
  234. )
  235. isEnd = this.listData.length >= res.data.total
  236. }
  237. },
  238. async _getAssetLedger () {
  239. const params = {
  240. assetCode: this.searchVal,
  241. materialId: this.curId,
  242. assetType: this.warehousingType
  243. }
  244. const res = await get(
  245. this.apiUrl + `/outInWarehouse/select/getAssetLedger`,
  246. params
  247. )
  248. uni.hideLoading()
  249. if (res?.success && this.curId == params.materialId) {
  250. const curMap = {
  251. materialName: 'assetName', //类型
  252. batchNo: 'batchNo', //批次号
  253. outInNum: '' //数量
  254. }
  255. this.listData = res.data.map(item => {
  256. for (const key in curMap) {
  257. item[key] = curMap[key] ? item[curMap[key]] : ''
  258. }
  259. item.checked = false
  260. return item
  261. })
  262. isEnd = true
  263. }
  264. },
  265. confirm ([id], name) {
  266. this.curId = id
  267. page = 1
  268. this.getList()
  269. },
  270. async getClassify () {
  271. const res = await get(this.apiUrl + `/classify/getClassify`, {
  272. id: '0',
  273. type: this.warehousingType
  274. })
  275. if (res?.success) {
  276. this.classificationList = res.data
  277. this.confirm([res.data[0].id])
  278. }
  279. },
  280. doSearch () {
  281. page = 1
  282. this.getList()
  283. },
  284. //勾选
  285. selectVal (e, val, index) {
  286. // console.log(this.listData);
  287. this.listData[index].checked = !this.listData[index].checked
  288. this.seletedAll = !this.listData.some(item => !item.checked)
  289. },
  290. //全选按钮
  291. _seletedAll () {
  292. if (!this.seletedAll) {
  293. this.seletedAll = true
  294. this.listData.map(item => {
  295. this.$set(item, 'checked', true)
  296. })
  297. } else {
  298. this.seletedAll = false
  299. //this.checkListLen = 0;
  300. this.listData.map(item => {
  301. this.$set(item, 'checked', false)
  302. })
  303. }
  304. },
  305. //跳转回添加页面
  306. jumpAdd () {
  307. uni.$emit(
  308. 'setSelectList',
  309. this.listData.filter(item => item.checked)
  310. )
  311. console.log(
  312. this.listData.filter(item => item.checked),
  313. '222'
  314. )
  315. uni.navigateBack()
  316. },
  317. //返回添加页
  318. backAdd () {
  319. uni.navigateBack()
  320. }
  321. }
  322. }
  323. </script>
  324. <style lang="scss" scoped>
  325. .mainBox {
  326. .wrapper {
  327. padding-top: 50px;
  328. position: relative;
  329. }
  330. .searchBox {
  331. position: absolute;
  332. top: 0;
  333. z-index: 99;
  334. background-color: #dedede;
  335. height: 50px;
  336. width: 100%;
  337. line-height: 50px;
  338. display: flex;
  339. justify-content: space-around;
  340. align-items: center;
  341. input {
  342. height: 40px;
  343. width: 65%;
  344. background: #f9f9f9 !important;
  345. margin-left: 20rpx;
  346. padding-left: 10rpx;
  347. border-radius: 5rpx;
  348. }
  349. .searchBtn {
  350. height: 80rpx;
  351. background: #f9f9f9 !important;
  352. color: #676767;
  353. font-size: 28rpx;
  354. padding: 0 42rpx;
  355. outline: none;
  356. border: none;
  357. width: 260rpx;
  358. .icon-sousuo {
  359. font-size: 22px;
  360. }
  361. .text {
  362. font-size: 16px;
  363. margin-left: 10px;
  364. }
  365. }
  366. }
  367. .tab-title {
  368. position: fixed;
  369. top: 190rpx;
  370. z-index: 99;
  371. width: 100%;
  372. display: flex;
  373. justify-content: space-between;
  374. align-items: center;
  375. height: $tab-height;
  376. line-height: $tab-height;
  377. background-color: #ffffff;
  378. border-bottom: 2rpx solid #f2f2f2;
  379. box-sizing: border-box;
  380. .tab-item {
  381. width: 25%;
  382. text-align: center;
  383. font-size: 32rpx;
  384. color: $uni-text-color-grey;
  385. }
  386. .tab-item.active {
  387. color: $j-primary-border-green;
  388. border-bottom: 1px solid $j-primary-border-green;
  389. font-weight: bold;
  390. }
  391. .tab-item.filter {
  392. flex: 1;
  393. padding: 0px 30rpx;
  394. .uni-icons {
  395. display: flex;
  396. padding-top: 5px;
  397. }
  398. }
  399. .screenIcon {
  400. display: flex;
  401. width: 80px;
  402. justify-content: center;
  403. .screenText {
  404. font-size: 32rpx;
  405. color: $uni-text-color-grey;
  406. }
  407. }
  408. }
  409. .listContent {
  410. // margin-top: 100rpx;
  411. padding-bottom: 100rpx;
  412. .listBox {
  413. display: flex;
  414. // height: 180rpx;
  415. padding: 20rpx 0;
  416. border-bottom: 2rpx solid #e5e5e5;
  417. .listBox-sel {
  418. height: 90rpx;
  419. width: 80rpx;
  420. line-height: 90rpx;
  421. text-align: center;
  422. checkbox {
  423. transform: scale(1.2);
  424. }
  425. }
  426. .listBox-con {
  427. width: 100%;
  428. // display: flex;
  429. // flex-wrap: wrap;
  430. // justify-content: space-between;
  431. align-items: center;
  432. padding: 0 18rpx 0 0;
  433. .listBox-top {
  434. width: 100%;
  435. display: flex;
  436. justify-content: space-between;
  437. padding-bottom: 10rpx;
  438. .listBox-name,
  439. .listBox-code {
  440. display: inline-block;
  441. font-size: $uni-font-size-sm;
  442. font-weight: bold;
  443. }
  444. .listBox-code {
  445. }
  446. }
  447. .listBox-bottom {
  448. width: 100%;
  449. display: flex;
  450. justify-content: space-between;
  451. font-size: $uni-font-size-sm;
  452. flex-wrap: wrap;
  453. > view {
  454. width: 50%;
  455. }
  456. .bot-right {
  457. }
  458. }
  459. }
  460. }
  461. }
  462. //底部按钮
  463. .footer {
  464. position: fixed;
  465. display: flex;
  466. justify-content: space-between;
  467. align-items: center;
  468. bottom: 0;
  469. width: 100%;
  470. height: 100rpx;
  471. border-top: 1rpx solid #eeecec;
  472. background-color: #ffffff;
  473. z-index: 999;
  474. .bottom {
  475. margin-left: 10rpx;
  476. }
  477. .u-reset-button {
  478. position: absolute;
  479. right: 10rpx;
  480. top: 20rpx;
  481. width: 150rpx;
  482. }
  483. }
  484. }
  485. </style>