procurement.vue 15 KB

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