procurement.vue 15 KB

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