ソースを参照

feat: 移动端参标组件完善以及参标组件调用

cuiyalong 1 年間 前
コミット
d06b708e16

+ 22 - 0
apps/mobile/src/api/modules/project.js

@@ -85,3 +85,25 @@ export function projectDetailStatistics(data) {
     data
   })
 }
+
+/**
+ * 获取项目详情页参标数据
+ * @param data{sid}
+ * 返回参数
+ *
+ bool showParticipate = 1;// 是否显示参标按钮  true-显示  false-不显示
+ bool showStopParticipate = 2;// 是否显示终止参标参标按钮  true-显示  false-不显示
+ bool showTransfer = 3;// 转给同事按钮是否展示:true-展示 false-不展示
+ string userName = 4;//参标人姓名 逗号分割
+ string projectId = 5;// 项目id
+ int64 bidEndTime = 6 ;// 投标截止时间
+ int64 currentTime = 7 ;// 服务器当前时间
+ */
+export function getDetailBidIsJoin(data) {
+  return request({
+    url: '/jyapi/jybx/core/participate/info',
+    method: 'post',
+    noToast: true,
+    data
+  })
+}

+ 149 - 13
apps/mobile/src/views/article/components/ActionInBidding.vue

@@ -1,6 +1,7 @@
 <template>
   <van-popover
     v-model="showPopover"
+    v-if="canJoinBid"
     :actions="actions"
     trigger="click"
     :placement="placement"
@@ -22,18 +23,38 @@
         ></AppIcon>
         <template #text>参标管理</template>
       </TabActionItem>
+      <van-popup
+        :style="popupHeight"
+        v-model="showBidStatus"
+        get-container="body"
+        round
+        position="bottom"
+      >
+        <bidStatusNode
+          @cancel-update="cancelUpdate"
+          @save-success="saveSuccess"
+          :project-cell-info="projectCellInfo"
+          @set-height="setHeight"
+        ></bidStatusNode>
+      </van-popup>
     </template>
   </van-popover>
 </template>
 <script>
 import TabActionItem from '@/views/article/ui/TabActionItem.vue'
-import { Popover } from 'vant'
+import bidStatusNode from '@/components/bid-update/BidUpdate'
+import { Popover, Popup } from 'vant'
 import { AppIcon } from '@/ui'
+import { getDetailBidIsJoin, ajaxCanBiaoAction } from '@/api/modules/'
+// import { openLinkOfOther } from '@/utils'
+// import { LINKS } from '@/data'
 
 export default {
   name: 'ActionInBidding',
   components: {
     [Popover.name]: Popover,
+    [Popup.name]: Popup,
+    bidStatusNode,
     TabActionItem,
     AppIcon
   },
@@ -43,10 +64,6 @@ export default {
       default: '',
       required: true
     },
-    value: {
-      type: Boolean,
-      default: false
-    },
     direction: {
       type: String,
       default: 'column',
@@ -64,10 +81,38 @@ export default {
   data() {
     return {
       showPopover: false,
-      actions: [{ text: '参标' }, { text: '终止参标' }]
+      // 参标弹窗相关
+      popupHeight: 'height: 440px',
+      showBidStatus: false,
+      canBiaoInfo: {
+        bidEndTime: 1711267101,
+        currentTime: 1711016637,
+        projectId: '',
+        showStopParticipate: false,
+        showParticipate: false,
+        showUpdate: false,
+        userName: ''
+      },
+      projectCellInfo: {
+        sid: ''
+      }
     }
   },
   computed: {
+    canJoinBid() {
+      return this.actions.length > 0
+    },
+    actions() {
+      const { showStopParticipate, showParticipate } = this.canBiaoInfo
+      const arr = []
+      if (showParticipate) {
+        arr.push({ text: '参标', value: 'join' })
+      }
+      if (showStopParticipate) {
+        arr.push({ text: '终止参标', value: 'stopJoin' })
+      }
+      return arr
+    },
     calcOffset() {
       if (this.placement === 'top-start') {
         return [5, 10]
@@ -78,11 +123,16 @@ export default {
       }
     }
   },
-  created() {},
+  created() {
+    this.getDetailBidIsJoin()
+  },
   methods: {
     onSelected(s) {
-      console.log(s)
-      this.doBidding()
+      if (s.value === 'join') {
+        this.doBidding()
+      } else {
+        this.cancelBidding()
+      }
     },
     showPopoverList(f = false) {
       this.showPopover = f
@@ -90,6 +140,28 @@ export default {
     changePopoverState() {
       this.showPopoverList(!this.showPopover)
     },
+    syncValue() {
+      this.$emit('change', {
+        ...this.canBiaoInfo
+      })
+    },
+    async getDetailBidIsJoin() {
+      this.projectCellInfo.sid = this.id
+      const { data, error_code: code } = await getDetailBidIsJoin({
+        sid: this.id
+      })
+      if (code === 0 && data) {
+        if (!data.bidEndTime) {
+          data.bidEndTime = 0
+        }
+        if (!data.currentTime) {
+          data.currentTime = 0
+        }
+        this.canBiaoInfo = data
+        this.syncValue()
+      }
+    },
+    // 参标操作
     async doBidding() {
       if (this.beforeAction) {
         const r = await this.beforeAction()
@@ -97,11 +169,75 @@ export default {
           return
         }
       }
-      // do something...
-      this.syncValue(!this.value)
+      // if (!this.isLogin) {
+      //   return openLinkOfOther(LINKS.APP登录页.app, {
+      //     query: {
+      //       to: 'back'
+      //     }
+      //   })
+      // }
+      this.projectCellInfo.sid = this.id
+      try {
+        const {
+          error_code: code,
+          data,
+          error_msg: msg
+        } = await ajaxCanBiaoAction('in', {
+          bidIds: this.id
+        })
+        if (code === 0 && data) {
+          this.$toast('已参标,请前往我的参标项目列表查看。')
+          this.showBidStatus = true
+          this.getDetailBidIsJoin()
+        } else {
+          this.$toast(msg || '参标失败,请重试。')
+        }
+      } catch (e) {
+        console.error(e)
+      }
+    },
+    async cancelBidding() {
+      this.projectCellInfo.sid = this.id
+      try {
+        const {
+          error_code: code,
+          data,
+          error_msg: msg
+        } = await ajaxCanBiaoAction('out', {
+          projectIds: this.id
+        })
+        if (code === 0 && data) {
+          this.$toast('已取消参标')
+          this.getDetailBidIsJoin()
+        } else {
+          this.$toast(msg || '取消参标失败,请重试。')
+        }
+      } catch (e) {
+        console.error(e)
+      }
+    },
+    setHeight(data) {
+      if (data === 2) {
+        if (this.$envs.inWX && this.$envs.inIOS) {
+          this.popupHeight = 'height: 596px;padding-bottom: 50px'
+        } else {
+          this.popupHeight = 'height: 546px'
+        }
+      } else {
+        if (this.$envs.inWX && this.$envs.inIOS) {
+          this.popupHeight = 'height: 490px;padding-bottom: 50px'
+        } else {
+          this.popupHeight = 'height: 440px'
+        }
+      }
+    },
+    // 取消更新投标状态
+    cancelUpdate() {
+      this.showBidStatus = false
     },
-    syncValue(v) {
-      this.$emit('input', v)
+    // 更新投标状态成功
+    saveSuccess() {
+      this.showBidStatus = false
     }
   }
 }

+ 18 - 30
apps/mobile/src/views/article/components/ContentHeader.vue

@@ -13,7 +13,6 @@
     <h2
       class="article-title"
       :class="{ 'van-multi-ellipsis--l2': false }"
-      @click="toProjectDetail"
       v-html="content.titleHighlighted"
     ></h2>
     <div class="tag-list">
@@ -33,13 +32,15 @@
     </div>
     <div class="sub-info-line">
       <span class="info-publish-time">{{ content.time }}</span>
-      <span class="info-canbiao-persons" v-if="false">参标人:张xxxxxx等</span>
+      <span class="info-canbiao-persons" v-if="cbPersonText">
+        参标人:{{ cbPersonText }}
+      </span>
     </div>
   </section>
 </template>
 <script>
 import { Icon } from 'vant'
-import { mapState, mapGetters } from 'vuex'
+import { mapState } from 'vuex'
 import { LINKS } from '@/data'
 import { openAppOrWxPage } from '@/utils/'
 
@@ -54,10 +55,22 @@ export default {
       summary: (state) => state.article.mainModel.summary,
       otherModel: (state) => state.article.otherModel
     }),
+    cbPersonText() {
+      const { inBiddingPersonList: bList } = this.otherModel
+      if (Array.isArray(bList) && bList.length > 0) {
+        const list = bList.map((b) => b.trim()).filter((b) => !!b)
+        if (list.length > 1) {
+          return `${list.slice(0, 1).join(',')}等`
+        } else {
+          return list.join(',')
+        }
+      } else {
+        return ''
+      }
+    },
     collectionTags() {
       return this.otherModel.collectionTags
-    },
-    ...mapGetters('user', ['isLogin', 'isSuper', 'isMember', 'isNewBusiness'])
+    }
   },
   created() {},
   methods: {
@@ -67,31 +80,6 @@ export default {
           tag: encodeURIComponent(tag.id)
         }
       })
-    },
-    toProjectDetail() {
-      // if (this.isNewBusiness) {
-      // }
-      // function goMemberFollowPage (url) {
-      //   var objId = {
-      //     fid:'',
-      //     sid:''
-      //   }
-      //   if (followId && jumpFlag){
-      //     objId.fid = followId
-      //     objId.sid = id
-      //     sessionStorage.setItem('bigvip-fid',JSON.stringify(objId))
-      //   }else{
-      //     objId.fid = ''
-      //     objId.sid = id
-      //     sessionStorage.setItem('bigvip-fid',JSON.stringify(objId))
-      //   }
-      //   location.href = url
-      // }
-      // if (newEntNiche) {
-      //   goMemberFollowPage('/jyapp/big/page/client_follow_detail?from=client&industry=' + "交通")
-      // }else{
-      //   goMemberFollowPage('/jyapp/big/page/pro_follow_detail')
-      // }
     }
   }
 }

+ 13 - 1
apps/mobile/src/views/article/components/TabActions.vue

@@ -12,7 +12,11 @@
       @change="afterMonitorFetch"
     />
     <ActionShareToWorkmate class="tab-action" :id="id" />
-    <ActionInBidding v-if="false" class="tab-action" :id="id" />
+    <ActionInBidding
+      class="tab-action"
+      :id="id"
+      @change="biddingStatusChange"
+    />
   </section>
 </template>
 <script>
@@ -89,6 +93,14 @@ export default {
         this.showForecast()
         this.removeHideUnderline()
       }
+    },
+    biddingStatusChange(i) {
+      const userName = i.userName || ''
+      const userNameList = userName.split(',').filter((i) => i)
+      this.setOtherModelChild({
+        key: 'inBiddingPersonList',
+        data: userNameList
+      })
     }
   }
 }