goods.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="content">
  3. <!-- 自定义导航 -->
  4. <view class="navbar-box">
  5. <u-navbar title="选择物资" :safeAreaInsetTop="true" @leftClick="leftClick">
  6. </u-navbar>
  7. </view>
  8. <view class="screen-box">
  9. <view class="screen-class">
  10. <u-search
  11. placeholder="搜索"
  12. height="70"
  13. bg-color="#f7f7f7"
  14. v-model="keyword"
  15. @search="search"
  16. @custom="search"></u-search>
  17. </view>
  18. </view>
  19. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  20. <u-checkbox-group @change="checkboxGroupChange" active-color="#218AEC" style="display: block;">
  21. <view v-for="item in dataList" :key="item.id">
  22. <view class="item u-flex u-row-between u-border-bottom">
  23. <view class="left u-flex">
  24. <image :src="item.imgs|firstImg" mode="aspectFill"></image>
  25. <view class="text">
  26. <view class="name">{{item.mateName}}</view>
  27. <view class="name u-tips-color">规格:{{item.specCode}}{{filterUnitName(item.unitCode)}}</view>
  28. </view>
  29. </view>
  30. <view class="right">
  31. <u-checkbox v-model="item.checked" :name="item.id"></u-checkbox>
  32. <!-- <u-number-box v-model="item.value" @change="valChange(item)"></u-number-box> -->
  33. </view>
  34. </view>
  35. </view>
  36. </u-checkbox-group>
  37. </mescroll-body>
  38. <view class="fixed-button">
  39. <u-button type="success" @click="confirmEven">确定</u-button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {otherApiUrl} from '@/common/apiurl.js';
  45. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  46. export default {
  47. mixins: [MescrollMixin], // 使用mixin
  48. components: {
  49. },
  50. data() {
  51. return {
  52. // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  53. downOption: {
  54. },
  55. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  56. upOption: {
  57. page: {
  58. size: 10 // 每页数据的数量,默认10
  59. },
  60. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  61. empty: {
  62. tip: '暂无相关数据'
  63. }
  64. },
  65. keyword:'',
  66. // 列表数据
  67. dataList: [{id:1,value:1},{id:2,value:12}],
  68. checkboxList:[],
  69. choiceList:[],
  70. unitNameList:[],
  71. }
  72. },
  73. onLoad() {
  74. this.unitNameDict();
  75. },
  76. computed:{
  77. filterUnitName(){
  78. return function(value){
  79. let v = '';
  80. for (let i = 0; i < this.unitNameList.length; i++){
  81. // console.log('value',value);
  82. // console.log('value',this.unitNameList[i]);
  83. let item = this.unitNameList[i];
  84. if (value == item.value) {
  85. v = item.label;
  86. break;
  87. }
  88. }
  89. return v
  90. }
  91. }
  92. },
  93. methods: {
  94. /*上拉加载的回调*/
  95. upCallback(page) {
  96. let params ={
  97. pageNum:page.num,
  98. pageSize:page.size,
  99. keyword:this.keyword
  100. }
  101. this.$u.api.epiStoreInList(params).then(curPageData=>{
  102. // console.log('curPageData',curPageData)
  103. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  104. // this.mescroll.endSuccess(curPageData.rows.total);
  105. this.mescroll.endBySize(curPageData.rows.length, curPageData.rows.total);
  106. //设置列表数据
  107. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  108. this.dataList=this.dataList.concat(curPageData.rows); //追加新数据
  109. }).catch((err)=>{
  110. uni.showToast({
  111. title:'链接失败'
  112. });
  113. console.log('err',err)
  114. //联网失败, 结束加载
  115. this.mescroll.endErr();
  116. })
  117. },
  118. /*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
  119. reloadList(){
  120. this.mescroll.resetUpScroll();
  121. },
  122. leftClick() {
  123. let canNavBack = getCurrentPages();
  124. if(canNavBack && canNavBack.length>1) {
  125. uni.navigateBack({
  126. delta: 1
  127. });
  128. } else {
  129. history.back();
  130. }
  131. },
  132. goCheck(item){
  133. this.$u.route({
  134. url: 'pages/check/checkItem/checkItem',
  135. params: {
  136. id: item.id
  137. }
  138. })
  139. console.log('goPutOut',item)
  140. },
  141. search(){
  142. this.mescroll.resetUpScroll();
  143. },
  144. // valChange(item){
  145. // console.log('valChange',item);
  146. // },
  147. // 物资选择完成事件
  148. confirmEven(){
  149. this.choiceList = []
  150. this.dataList.forEach(item => {
  151. if(this.checkboxList.indexOf(item.id) > -1) {
  152. this.choiceList.push({
  153. mateId: item.id,
  154. classTypeName: item.classTypeName,
  155. mateName: item.mateName,
  156. unitCode: item.unitCode,
  157. mateNum:1,
  158. })
  159. }
  160. })
  161. console.log('this.choiceList',this.choiceList);
  162. this.$u.vuex('putinList', this.choiceList)
  163. this.$u.route({
  164. url:'pages/putin/putin',
  165. })
  166. },
  167. // 选中任一checkbox时,由checkbox-group触发
  168. checkboxGroupChange(e) {
  169. this.checkboxList = e;
  170. console.log('this.checkboxList',this.checkboxList);
  171. },
  172. async unitNameDict() {
  173. let { code, data, msg} = await this.$u.get(otherApiUrl.getDict + 'goods_unit_name')
  174. if(code === 200) {
  175. this.unitNameList = data.map(item => {
  176. return {
  177. label: item.dictLabel,
  178. value: item.dictValue
  179. }
  180. })
  181. }
  182. },
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .item{
  188. margin: 24rpx;
  189. padding-bottom: 24rpx;
  190. .left image {
  191. width: 120rpx;
  192. height: 120rpx;
  193. border-radius: 8rpx;
  194. margin-right: 12rpx;
  195. }
  196. }
  197. </style>