procurement_info.vue 16 KB

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