supplierManageList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择供应商" @clickLeft="handleClose">
  4. </uni-nav-bar>
  5. <view class="searchBox">
  6. <input v-model="searchVal" placeholder="请输入供应商名称" class="searchInput" @confirm="doSearch" />
  7. <u-button type="icon-shixiangxinzeng" size="30" @click="doSearch" class="searchBtn">
  8. <view class="iconfont icon-sousuo"></view>
  9. <view class="text">搜索</view>
  10. </u-button>
  11. </view>
  12. <view class="wrapper">
  13. <scroll-view scroll-y class="listContent" @scrolltolower="scrolltolower">
  14. <checkbox-group @change="e => onCheckChange(e)">
  15. <label v-for="(item, index) in listData" :key="index">
  16. <view class="listBox">
  17. <view class="listBox-sel">
  18. <checkbox :value="item.id" :checked="item.checked" color="#157A2C" style="transform: scale(1.2)" />
  19. </view>
  20. <view class="listBox-con">
  21. <view class="listBox-top">
  22. <view class="listBox-name">{{ item.name || '-' }}</view>
  23. <view class="listBox-code">{{ item.code || '' }}</view>
  24. </view>
  25. <view class="listBox-bottom">
  26. <view>代号:{{ item.serialNo || '-' }}</view>
  27. <view>电话:{{ item.phone || '-' }}</view>
  28. <view>地址:{{ item.address || '-' }}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </label>
  33. </checkbox-group>
  34. <u-loadmore v-if="listData.length" :status="loadStatus" />
  35. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length && !loading"></u-empty>
  36. </scroll-view>
  37. </view>
  38. <view class="footer">
  39. <view class="count-text" v-if="checkedCount > 0">已选 {{ checkedCount }} 个</view>
  40. <u-button type="success" size="small" :disabled="checkedCount === 0" @click="confirmSelect">
  41. 选择({{ checkedCount }})
  42. </u-button>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import { contactPage } from '@/api/saleManage/contact/index.js'
  48. export default {
  49. data() {
  50. return {
  51. page: 1,
  52. size: 20,
  53. isEnd: false,
  54. loading: false,
  55. searchVal: '',
  56. listData: [],
  57. loadStatus: 'loadmore'
  58. }
  59. },
  60. computed: {
  61. checkedCount() {
  62. return this.listData.filter(item => item.checked).length
  63. }
  64. },
  65. onLoad() {
  66. this.getList()
  67. },
  68. methods: {
  69. scrolltolower() {
  70. if (this.isEnd || this.loading) return
  71. this.page++
  72. this.getList()
  73. },
  74. doSearch() {
  75. this.page = 1
  76. this.listData = []
  77. this.getList()
  78. },
  79. async getList() {
  80. this.loading = true
  81. this.loadStatus = 'loading'
  82. try {
  83. const result = await contactPage({
  84. pageNum: this.page,
  85. size: this.size,
  86. name: this.searchVal || undefined,
  87. type: 2,
  88. status: 1
  89. })
  90. const newList = (result.list || []).map(item => ({
  91. ...item,
  92. checked: false
  93. }))
  94. if (this.page === 1) {
  95. this.listData = newList
  96. } else {
  97. this.listData = this.listData.concat(newList)
  98. }
  99. const total = result.count || result.total || 0
  100. this.isEnd = this.listData.length >= total
  101. this.loadStatus = this.isEnd ? 'nomore' : 'loadmore'
  102. } catch (e) {
  103. console.error(e)
  104. this.loadStatus = 'nomore'
  105. }
  106. this.loading = false
  107. },
  108. onCheckChange(e) {
  109. const values = e.detail.value || []
  110. this.listData.forEach((item, i) => {
  111. this.$set(this.listData[i], 'checked', values.includes(item.id))
  112. })
  113. },
  114. confirmSelect() {
  115. const selected = this.listData.filter(item => item.checked)
  116. if (!selected.length) {
  117. uni.showToast({ title: '请选择供应商', icon: 'none' })
  118. return
  119. }
  120. const list = selected.map(item => ({
  121. id: item.id,
  122. supplierId: item.id,
  123. supplierName: item.name,
  124. supplierCode: item.code,
  125. name: item.name,
  126. code: item.code,
  127. files: [],
  128. preferentialPrice: '',
  129. settlementMode: '4',
  130. settlementModeName: '分期付款',
  131. taxRate: '',
  132. totalPrice: '',
  133. resultList: []
  134. }))
  135. uni.$emit('supplierManageChange', list)
  136. uni.navigateBack()
  137. },
  138. handleClose() {
  139. uni.navigateBack()
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .mainBox {
  146. height: 100vh;
  147. display: flex;
  148. flex-direction: column;
  149. background: #f5f5f5;
  150. .wrapper {
  151. flex: 1;
  152. overflow: hidden;
  153. }
  154. .searchBox {
  155. padding: 10rpx 0;
  156. box-sizing: border-box;
  157. background-color: #dedede;
  158. height: 90rpx;
  159. width: 100%;
  160. display: flex;
  161. justify-content: space-around;
  162. align-items: center;
  163. input {
  164. height: 70rpx;
  165. width: 65%;
  166. background: #f9f9f9;
  167. margin: 0 10rpx;
  168. padding: 0 20rpx;
  169. box-sizing: border-box;
  170. border-radius: 8rpx;
  171. font-size: 28rpx;
  172. }
  173. .searchBtn {
  174. height: 70rpx;
  175. background: #f9f9f9;
  176. color: #676767;
  177. font-size: 28rpx;
  178. padding: 0 30rpx;
  179. box-sizing: border-box;
  180. outline: none;
  181. border: none;
  182. width: 240rpx;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. .icon-sousuo {
  187. font-size: 22px;
  188. }
  189. .text {
  190. font-size: 26rpx;
  191. margin-left: 10rpx;
  192. }
  193. }
  194. }
  195. .listContent {
  196. height: 100%;
  197. padding: 0 20rpx;
  198. .listBox {
  199. display: flex;
  200. padding: 24rpx 0;
  201. border-bottom: 2rpx solid #e5e5e5;
  202. background: #fff;
  203. margin-bottom: 2rpx;
  204. .listBox-sel {
  205. width: 80rpx;
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. flex-shrink: 0;
  210. }
  211. .listBox-con {
  212. flex: 1;
  213. padding-right: 18rpx;
  214. .listBox-top {
  215. display: flex;
  216. justify-content: space-between;
  217. align-items: center;
  218. padding-bottom: 8rpx;
  219. .listBox-name {
  220. font-size: 28rpx;
  221. font-weight: bold;
  222. color: #333;
  223. }
  224. .listBox-code {
  225. font-size: 22rpx;
  226. color: #999;
  227. }
  228. }
  229. .listBox-bottom {
  230. font-size: 22rpx;
  231. color: #666;
  232. >view {
  233. padding: 3rpx 0;
  234. overflow: hidden;
  235. white-space: nowrap;
  236. text-overflow: ellipsis;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. .footer {
  243. height: 100rpx;
  244. display: flex;
  245. justify-content: space-between;
  246. align-items: center;
  247. border-top: 1rpx solid #eeecec;
  248. background-color: #fff;
  249. padding: 0 30rpx;
  250. flex-shrink: 0;
  251. .count-text {
  252. font-size: 26rpx;
  253. color: #666;
  254. }
  255. }
  256. }
  257. </style>