procurement.vue 16 KB

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