procurement_info.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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 | subText(22)}}</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 | subText(12)}}</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 procurementList"
  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 | subText(12)}}</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. modal: false,
  161. contentModalText: '',
  162. // 弹窗配置
  163. modalButton: [
  164. {
  165. text: '取消',
  166. type: 'gray',
  167. plain: true //是否空心
  168. },
  169. {
  170. text: '确认',
  171. customStyle: {
  172. color: '#fff',
  173. bgColor: 'linear-gradient(90deg, #F28F31 0%, #F3B574 100%)'
  174. },
  175. plain: false
  176. }
  177. ],
  178. joinData: {}, // 我要参与
  179. userInfo: {},
  180. popupShow: false, // 底部上移栏
  181. proTabId: '', // tab id
  182. detailId: '', // 详情id
  183. }
  184. },
  185. filters: {
  186. subText(str, index) {
  187. if(str) {
  188. if (str.length <= index) {
  189. return str
  190. }
  191. return str.substring(0, index) + '...'
  192. }
  193. return str
  194. }
  195. },
  196. onLoad(options) {
  197. this.userInfo = uni.getStorageSync('userInfo')
  198. this.procurementDetail(options.id)
  199. this.detailId = options.id
  200. this.proTabId = options.proTabId
  201. uni.$on('refreshAddData',(id) => {
  202. if (id) {
  203. this.procurementDetail(id)
  204. }
  205. })
  206. },
  207. methods: {
  208. // 状态
  209. procurementStatus(str) {
  210. const userIdList = this.procurementList.map(i => i.userId)
  211. const form = {
  212. isDelFlag: () => this.procurement.delFlag == 1, // 是否删除
  213. isAchieve: () => this.procurement.isAchieve == 1, // 是否实现
  214. isAllTab: () => this.proTabId === 0, // 是否在全部的tab栏下
  215. isSelfParticipationTab: () => this.proTabId > 0, // 是否在已参与tab栏 是否在自已发布的tab中
  216. 'isInvolved': () => this.procurement.isInvolved === 2, // 是否我创建的
  217. 'isAdd': () => this.procurement.isInvolved === 1, // 是否参与
  218. }
  219. return form[str]()
  220. },
  221. // 删除
  222. procurementDelete() {
  223. this.contentModalText = '确定删除该需求吗?'
  224. this.modal = true
  225. this.joinData = $event
  226. },
  227. handleClick($event) {
  228. if ($event.index === 1) {
  229. if(this.joinData.isInvolved === 1) {
  230. // 退出参与
  231. this.procurementUpdate(1)
  232. } else{
  233. // 删除
  234. this.procurementUpdate(0)
  235. }
  236. }
  237. this.modal = false
  238. },
  239. hideMobel() {},
  240. // 关闭底部
  241. handlerPopupClose() {
  242. this.popupShow = false
  243. },
  244. // 我要参与
  245. popupAdd() {
  246. this.joinData = Object.assign(this.procurement, {number: '', price: '', userId: this.userInfo.userId})
  247. this.popupShow = true
  248. },
  249. // 组件传递商品详情 退出
  250. modelData(proData) {
  251. this.contentModalText = '确定退出参与该需求吗?'
  252. this.modal = true
  253. this.proDataInfo = proData
  254. },
  255. procurementChange(status) {
  256. if (status) {
  257. uni.navigateTo({
  258. url: '/pages/goods/procurementAdd?id='+this.procurement.id
  259. })
  260. } else {
  261. this.procurementEditData()
  262. }
  263. },
  264. // 详情
  265. async procurementDetail(id) {
  266. try {
  267. const { data } = await this.ProcurementService.procurementDetail({ id: id })
  268. this.procurement = data.procurement
  269. this.procurementList = data.procurementList
  270. this.skeletonShow = false
  271. } catch (error) {
  272. console.log(error)
  273. }
  274. },
  275. // 删除 退出
  276. async procurementUpdate(type) {
  277. const form = {
  278. id: this.detailId,
  279. userId: this.userInfo.userId,
  280. procurementType: type
  281. }
  282. try{
  283. await this.ProcurementService.procurementUpdate(form)
  284. this.procurementDetail(this.detailId)
  285. uni.$emit('refreshAddData') // 刷新修改的数据
  286. uni.showToast({
  287. title: `${type === 0 ? '删除' : '退出'}成功`,
  288. icon: 'success'
  289. })
  290. }catch(error){
  291. console.log(error)
  292. }
  293. },
  294. // 我要参与
  295. async procurementParticipate() {
  296. if(this.joinData.price === '') {
  297. return this.$util.msg('请输入期望单价', 2000)
  298. }
  299. if(this.joinData.number === '') {
  300. return this.$util.msg('请输入采购数量', 2000)
  301. }
  302. const form = {
  303. userId: this.userInfo.userId,
  304. productImage: this.joinData.productImage,
  305. productName: this.joinData.productName,
  306. price: this.joinData.price,
  307. number: this.joinData.number,
  308. status: 0,
  309. id: this.joinData.id
  310. }
  311. if (this.joinData.isInvolved === 1) {
  312. form.id = this.joinData.sid
  313. form.status = 1 // 0参与 1 修改
  314. }
  315. try{
  316. await this.ProcurementService.procurementParticipate(form)
  317. this.procurementDetail(this.detailId)
  318. uni.$emit('refreshAddData') // 刷新修改的数据
  319. uni.showToast({
  320. title:`${this.procurement.isInvolved === 0 ? '参与' : '修改'}成功`,
  321. icon: 'success'
  322. })
  323. }catch(error){
  324. console.log(error)
  325. }
  326. },
  327. // 参与集采详情
  328. async procurementEditData() {
  329. const form = {
  330. id: `${this.procurement.sid}`,
  331. userId: this.userInfo.userId,
  332. procurementType: 0
  333. }
  334. try{
  335. const data = await this.ProcurementService.procurementEditData(form)
  336. this.joinData = data.data
  337. this.popupShow = true
  338. }catch(error){
  339. console.log(error)
  340. }
  341. }
  342. }
  343. }
  344. </script>
  345. <style lang="scss" scoped>
  346. .img {
  347. width: 136rpx;
  348. height: 136rpx;
  349. border: 1px dotted black;
  350. margin-right: 24rpx;
  351. }
  352. .procure_info {
  353. background-color: #f7f7f7;
  354. padding: 24rpx;
  355. }
  356. .procure_info .info_card {
  357. height: 340rpx;
  358. padding: 24rpx;
  359. background-color: #fff;
  360. border-radius: 16rpx 16rpx 16rpx 16rpx;
  361. box-sizing: border-box;
  362. position: relative;
  363. }
  364. .card_title {
  365. color: #333333;
  366. font-size: 32rpx;
  367. font-weight: bold;
  368. }
  369. .card_line {
  370. border: 1rpx solid #e1e1e1;
  371. margin-top: 24rpx;
  372. }
  373. .info_card .card_store {
  374. margin: 40rpx 8px;
  375. padding: 12rpx;
  376. background-color: #f7f7f7;
  377. display: flex;
  378. align-items: center;
  379. border-radius: 8rpx 8rpx 8rpx 8rpx;
  380. }
  381. .info_card .store_title {
  382. width: 442rpx;
  383. font-size: 26rpx;
  384. color: #333333;
  385. line-height: 48rpx;
  386. }
  387. .procure_info .info_Initiator {
  388. background-color: #fff;
  389. border-radius: 16rpx 16rpx 16rpx 16rpx;
  390. padding: 24rpx;
  391. margin: 24rpx 0;
  392. box-sizing: border-box;
  393. position: relative;
  394. }
  395. .Initiator_contant {
  396. height: 220rpx;
  397. background-color: #f7f7f7;
  398. margin: 40rpx 8rpx 16rpx 8rpx;
  399. border-radius: 8rpx 8rpx 8rpx 8rpx;
  400. padding: 40rpx 24rpx;
  401. box-sizing: border-box;
  402. }
  403. .Initiator_contant .Initiator_name {
  404. display: flex;
  405. align-items: center;
  406. }
  407. .Initiator_contant .Initiator_icon {
  408. width: 96rpx;
  409. height: 40rpx;
  410. line-height: 40rpx;
  411. font-size: 24rpx;
  412. text-align: center;
  413. color: #fff;
  414. background-color: #f3b574;
  415. border-radius: 8rpx;
  416. margin-right: 24rpx;
  417. }
  418. .Initiator_name .user {
  419. color: #333333;
  420. font-size: 32rpx;
  421. font-weight: bold;
  422. }
  423. .Initiator_contant .Initiator_price {
  424. margin-top: 48rpx;
  425. display: flex;
  426. align-items: center;
  427. }
  428. .Initiator_price .unit_price,
  429. .Initiator_price .unit_sum {
  430. display: flex;
  431. align-items: center;
  432. }
  433. .Initiator_price .unit_sum {
  434. margin-left: 120rpx;
  435. }
  436. .title {
  437. color: #999999;
  438. font-size: 26rpx;
  439. font-weight: 400;
  440. }
  441. .price {
  442. color: #333333;
  443. font-size: 26rpx;
  444. }
  445. .info_Participant {
  446. background-color: #fff;
  447. padding: 24rpx;
  448. border-radius: 16rpx;
  449. margin-bottom: 256rpx;
  450. position: relative;
  451. }
  452. .empty {
  453. height: 250rpx;
  454. display: flex;
  455. justify-content: center;
  456. align-items: center;
  457. font-size: 26rpx;
  458. color: #b2b2b2;
  459. }
  460. .info_btn {
  461. position: fixed;
  462. bottom: 0%;
  463. left: 0;
  464. padding: 16rpx 56rpx 84rpx 56rpx;
  465. justify-content: space-between;
  466. display: flex;
  467. align-items: center;
  468. background-color: #fff;
  469. width: 100%;
  470. box-sizing: border-box;
  471. }
  472. .status {
  473. position: absolute;
  474. width: 150rpx;
  475. height: 100rpx;
  476. right: 48rpx;
  477. top: 48rpx;
  478. }
  479. .back-filter {
  480. position: absolute;
  481. left: 0;
  482. top: 0;
  483. background-color: rgba(255, 255, 255, 0.7);
  484. height: 100%;
  485. width: 100%;
  486. }
  487. </style>