procurement.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <view class="proInit">
  3. <tui-skeleton
  4. v-if="skeletonShow"
  5. backgroundColor="#fafafa"
  6. borderRadius="10rpx"
  7. :isLoading="true"
  8. :loadingType="5"
  9. ></tui-skeleton>
  10. <view v-else>
  11. <tui-tabs :tabs="tabs" :currentTab="currentTab" @change="handlerTabs" class="tab"></tui-tabs>
  12. <view
  13. class="tabsContent"
  14. v-for="(item, index) in procurementList"
  15. :key="index"
  16. :style="{ marginTop: index === 0 ? '40px' : '' }"
  17. >
  18. <proCard
  19. @modelData="modelData"
  20. :proTabId="currentTab"
  21. :procuretInfo="item"
  22. @popupAdd="popupAdd"
  23. @popupChange="popupChange"
  24. @proDelete="proDelete"
  25. @procureDetail="procureDetail"
  26. />
  27. </view>
  28. </view>
  29. <!-- 弹窗提示 -->
  30. <tui-modal
  31. :show="modal"
  32. @click="handleClick"
  33. @cancel="hideMobel"
  34. :content="contentModalText"
  35. :button="modalButton"
  36. color="#333"
  37. :size="32"
  38. shape="circle"
  39. :maskClosable="false"
  40. ></tui-modal>
  41. <view class="add_btn" @click="procurementAdd">
  42. <image style="width: 100%;height: 100%;" src="@/static/procurement/add_pro.png"></image>
  43. </view>
  44. <tui-bottom-popup :zIndex="1002" :maskZIndex="1001" :show="popupShow" @close="handlerPopupClose">
  45. <view class="popup_content">
  46. <view class="pro_popup_title">参与需求</view>
  47. <view class="popup_form">
  48. <view class="popup_form_item">商品图片:</view>
  49. <view class="popup_img">
  50. <image style="width: 100%;height: 100%;" :src="isImageUrl(joinData.productImage) ? imageUrl : joinData.productImage" mode="aspectFill"></image>
  51. </view>
  52. </view>
  53. <view class="popup_form">
  54. <view class="popup_form_item">商品名称:</view>
  55. <view class="popup_form_name">{{ joinData.productName }}</view>
  56. </view>
  57. <form>
  58. <view class="uni-form-item uni-column">
  59. <view class="title">
  60. <text style="font-size: 26rpx;color: #F85050;">*</text>
  61. 期望单价:
  62. </view>
  63. <view style="position: relative;">
  64. <view class="input_icon">¥</view>
  65. <input
  66. class="uni-input"
  67. type="number"
  68. focus
  69. v-model="joinData.price"
  70. @input="fpNumInput($event, 'joinData')"
  71. />
  72. </view>
  73. </view>
  74. <view class="uni-form-item uni-column">
  75. <view class="title">
  76. <text style="font-size: 26rpx;color: #F85050;">*</text>
  77. 采购数量:
  78. </view>
  79. <view style="position: relative;">
  80. <input
  81. class="uni-input"
  82. type="number"
  83. focus
  84. v-model="joinData.number"
  85. @input="NumberInput($event, 'joinData')"
  86. />
  87. </view>
  88. </view>
  89. <view class="submit_btn">
  90. <button class="popup_btn cancel" @click="handlerPopupClose">取消</button>
  91. <button class="popup_btn submit" @click="procurementParticipate">确定</button>
  92. </view>
  93. </form>
  94. </view>
  95. </tui-bottom-popup>
  96. <view v-if="procurementList.length > 2" :style="{ marginTop: procurementList.length > 0 ? '0' : '88rpx' }">
  97. <!--加载loadding-->
  98. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  99. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore>
  100. <!--加载loadding-->
  101. </view>
  102. <proEmpty v-if="procurementList.length === 0"/>
  103. </view>
  104. </template>
  105. <script>
  106. import proCard from './components/procurement_card.vue'
  107. import { mapState } from 'vuex'
  108. import procurementMixins from './mixins/procurementMixins.js'
  109. import proEmpty from './components/procurement-empty.vue'
  110. export default {
  111. components: {
  112. proCard,
  113. proEmpty
  114. },
  115. mixins: [procurementMixins],
  116. data() {
  117. return {
  118. skeletonShow: true, // loading
  119. // tab 栏切换
  120. tabs: [
  121. {
  122. name: '全部'
  123. },
  124. {
  125. name: '我参与的'
  126. },
  127. {
  128. name: '我发起的'
  129. }
  130. ],
  131. currentTab: 0, // tab 当前所在栏
  132. modal: false, // 弹窗
  133. contentModalText: '', // 弹窗内容
  134. // 弹窗配置
  135. modalButton: [
  136. {
  137. text: '取消',
  138. type: 'gray',
  139. plain: true //是否空心
  140. },
  141. {
  142. text: '确认',
  143. customStyle: {
  144. color: '#fff',
  145. bgColor: 'linear-gradient(90deg, #F28F31 0%, #F3B574 100%)'
  146. },
  147. plain: false
  148. }
  149. ],
  150. proDataInfo: {}, // 弹窗prodata
  151. popupShow: false, // 底部上移栏
  152. loadding: true, // 下拉刷新
  153. pullUpOn: true, // 下拉刷新
  154. // 分页参数
  155. pageInfo: {
  156. pageNo: 1,
  157. pageSize: 10,
  158. userId: '',
  159. status: 0
  160. },
  161. // 我参与的数据请求
  162. participate: {
  163. userId: '',
  164. procurementType: 0
  165. },
  166. // 所有数据
  167. procurementList: [],
  168. // 下拉刷新
  169. nomoreText: '已经没有了~',
  170. isLastPage: false, // 是否是最后一页
  171. joinData: {}, // 我要参与
  172. }
  173. },
  174. computed: {
  175. // 是否登录
  176. ...mapState(['hasLogin'])
  177. },
  178. onShow() {
  179. if(this.hasLogin){
  180. this.userInfo = uni.getStorageSync('userInfo')
  181. this.pageInfo.userId = this.userInfo.userId
  182. this.participate.userId = this.userInfo.userId
  183. this.procurementAllList()
  184. }else{
  185. this.$api.redirectTo('/pages/login/login')
  186. }
  187. },
  188. onLoad() {
  189. uni.$on('refreshAddData', () => {
  190. this.procurementAllAddList()
  191. })
  192. },
  193. onReachBottom() {
  194. if (!this.isLastPage) {
  195. this.loadding = true
  196. this.pullUpOn = true
  197. this.pageInfo.pageNo += 1
  198. this.procurementAllList()
  199. }
  200. },
  201. onPullDownRefresh() {
  202. this.isLastPage = false
  203. this.procurementList = []
  204. this.procurementAllList()
  205. uni.stopPullDownRefresh()
  206. },
  207. methods: {
  208. // tab 切换
  209. handlerTabs($event) {
  210. this.isLastPage = false
  211. this.procurementList = []
  212. this.currentTab = $event.index
  213. this.loadding = true
  214. this.pullUpOn = true
  215. this.pageInfo.pageNo = 1
  216. this.pageInfo.status = $event.index
  217. this.procurementAllList()
  218. },
  219. // 弹窗确认或取消
  220. handleClick($event) {
  221. if ($event.index === 1) {
  222. if (this.proDataInfo.isInvolved === 1) {
  223. // 退出参与
  224. this.procurementUpdate(1, this.proDataInfo.sid)
  225. } else {
  226. // 删除
  227. this.procurementUpdate(0, this.proDataInfo.id)
  228. }
  229. }
  230. this.modal = false
  231. },
  232. hideMobel($event) {},
  233. // 组件传递商品详情 退出
  234. modelData(proData) {
  235. this.contentModalText = '确定退出参与该需求吗?'
  236. this.modal = true
  237. this.proDataInfo = proData
  238. },
  239. // 关闭底部
  240. handlerPopupClose() {
  241. this.popupShow = false
  242. },
  243. // 我要参与
  244. popupAdd($event) {
  245. this.joinData = Object.assign($event, { userId: this.userInfo.userId })
  246. this.popupShow = true
  247. },
  248. // 修改
  249. popupChange($event) {
  250. this.joinData = $event
  251. if (this.joinData.isInvolved === 1) {
  252. this.procurementEditData()
  253. } else {
  254. uni.navigateTo({
  255. url: '/pages/goods/procurementAdd?id=' + $event.id
  256. })
  257. }
  258. },
  259. // 发布
  260. procurementAdd() {
  261. uni.navigateTo({
  262. url: `/pages/goods/procurementAdd?currentTab=${this.currentTab}`
  263. })
  264. },
  265. // 删除
  266. proDelete($event) {
  267. this.contentModalText = '确定删除该需求吗?'
  268. this.modal = true
  269. this.proDataInfo = $event
  270. },
  271. // 详情
  272. procureDetail($event) {
  273. uni.navigateTo({
  274. url: `/pages/goods/procurement_info?id=${$event.id}&proTabId=${this.currentTab}`
  275. })
  276. },
  277. /**
  278. * 网络请求
  279. */
  280. // 全部集采
  281. async procurementAllList() {
  282. if (!this.isLastPage) {
  283. try {
  284. const { data } = await this.ProcurementService.procurementAllList(this.pageInfo)
  285. this.procurementList = [...this.procurementList, ...data.list]
  286. this.isLastPage = data.total === this.procurementList.length
  287. this.loadding = !this.isLastPage
  288. this.pullUpOn = !this.isLastPage
  289. this.skeletonShow = false
  290. } catch (error) {
  291. console.log(error)
  292. }
  293. }
  294. },
  295. // 全部集采
  296. async procurementAllAddList() {
  297. const form = {
  298. pageNo: 1,
  299. userId: this.userInfo.userId,
  300. pageSize: this.pageInfo.pageNo * this.pageInfo.pageSize,
  301. status: this.currentTab
  302. }
  303. try {
  304. const { data } = await this.ProcurementService.procurementAllList(form)
  305. this.procurementList = data.list
  306. this.isLastPage = data.total === this.procurementList.length
  307. this.loadding = !this.isLastPage
  308. this.pullUpOn = !this.isLastPage
  309. } catch (error) {
  310. console.log(error)
  311. }
  312. },
  313. // 我要参与
  314. async procurementParticipate() {
  315. if (this.joinData.price === '') return this.$util.msg('请输入期望单价', 2000)
  316. if (this.joinData.number === '') return this.$util.msg('请输入期望数量', 2000)
  317. const form = {
  318. userId: this.userInfo.userId,
  319. productImage: this.joinData.productImage,
  320. productName: this.joinData.productName,
  321. price: this.joinData.price,
  322. number: this.joinData.number,
  323. status: 0,
  324. id: this.joinData.id,
  325. userName: this.userInfo.name
  326. }
  327. if (this.joinData.isInvolved === 1) {
  328. form.id = this.joinData.id
  329. form.status = 1 // 0参与 1 修改
  330. }
  331. try {
  332. const data = await this.ProcurementService.procurementParticipate(form)
  333. this.procurementAllAddList()
  334. this.popupShow = false
  335. uni.showToast({
  336. title: `${this.joinData.isInvolved === 0 ? '参与' : '修改'}成功`,
  337. icon: 'success'
  338. })
  339. } catch (error) {
  340. console.log(error)
  341. }
  342. },
  343. // 删除 退出
  344. async procurementUpdate(type, id) {
  345. const form = {
  346. id: `${type === 0 ? this.proDataInfo.id : this.proDataInfo.sid}`,
  347. userId: this.userInfo.userId,
  348. procurementType: type
  349. }
  350. try {
  351. await this.ProcurementService.procurementUpdate(form)
  352. this.procurementAllAddList()
  353. uni.showToast({
  354. title: `${type === 0 ? '删除' : '退出'}成功`,
  355. icon: 'success'
  356. })
  357. } catch (error) {
  358. console.log(error)
  359. }
  360. },
  361. // 参与详情
  362. async procurementEditData() {
  363. const form = {
  364. id: `${this.joinData.sid}`,
  365. userId: this.userInfo.userId,
  366. procurementType: 0
  367. }
  368. try {
  369. const {data} = await this.ProcurementService.procurementEditData(form)
  370. this.joinData = data
  371. this.popupShow = true
  372. } catch (error) {
  373. console.log(error)
  374. }
  375. },
  376. }
  377. }
  378. </script>
  379. <style lang="scss">
  380. page {
  381. background-color: #f7f7f7;
  382. }
  383. ::v-deep .tui-tabs-view {
  384. padding: 0 64rpx !important;
  385. }
  386. .proInit {
  387. background-color: #f7f7f7;
  388. }
  389. .proInit .tab {
  390. position: fixed;
  391. left: 0;
  392. top: 0;
  393. z-index: 9;
  394. }
  395. ::v-deep .tui-tabs-slider.data-v-9311a734 {
  396. background: #f3b574 !important;
  397. }
  398. ::v-deep .tui-tabs-title.tui-tabs-active {
  399. color: #f3b574 !important;
  400. }
  401. .tabsContent {
  402. background-color: #f7f7f7;
  403. padding: 16rpx 32rpx;
  404. }
  405. .add_btn {
  406. width: 100rpx;
  407. height: 100rpx;
  408. position: fixed;
  409. bottom: 129rpx;
  410. right: 34rpx;
  411. }
  412. .popup_content {
  413. padding: 0 64rpx;
  414. }
  415. .pro_popup_title {
  416. font-size: 32rpx;
  417. font-weight: bold;
  418. color: #333333;
  419. margin: 40rpx auto;
  420. text-align: center;
  421. }
  422. .popup_form {
  423. margin-bottom: 32rpx;
  424. }
  425. .popup_form .popup_form_item {
  426. color: #999999;
  427. font-size: 26rpx;
  428. margin-bottom: 16rpx;
  429. }
  430. .popup_form .popup_img {
  431. width: 136rpx;
  432. height: 136rpx;
  433. }
  434. .popup_form .popup_form_name {
  435. color: #333333;
  436. font-size: 26rpx;
  437. font-weight: 400;
  438. line-height: 44rpx;
  439. }
  440. .uni-form-item .title {
  441. color: #999999;
  442. font-size: 26rpx;
  443. margin-bottom: 16rpx;
  444. }
  445. .input_icon {
  446. position: absolute;
  447. left: 15rpx;
  448. top: 24rpx;
  449. color: #b2b2b2;
  450. font-size: 26rpx;
  451. }
  452. .uni-form-item .uni-input {
  453. height: 80rpx;
  454. border: 1px solid #b2b2b2;
  455. border-radius: 6rpx 6rpx 6rpx 6rpx;
  456. font-size: 26rpx;
  457. padding-left: 47rpx;
  458. margin-bottom: 32rpx;
  459. }
  460. .submit_btn {
  461. margin-top: 56rpx;
  462. height: 84rpx;
  463. display: flex;
  464. justify-content: space-between;
  465. align-items: center;
  466. margin-bottom: 50rpx;
  467. }
  468. .submit_btn .popup_btn {
  469. width: 280rpx;
  470. height: 100%;
  471. border-radius: 45rpx 45rpx 45rpx 45rpx;
  472. text-align: center;
  473. line-height: 84rpx;
  474. }
  475. ::v-deep .submit_btn .cancel {
  476. background-color: #fff4e6;
  477. color: #f3b574;
  478. font-size: 32rpx;
  479. }
  480. ::v-deep .submit_btn .submit {
  481. background-color: #f3b574;
  482. color: #ffffff;
  483. font-size: 32rpx;
  484. }
  485. </style>