123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- <template>
- <view style="background-color: #fff;position: relative;">
- <tui-skeleton
- v-if="skeletonShow"
- backgroundColor="#fafafa"
- borderRadius="10rpx"
- :isLoading="true"
- :loadingType="5"
- ></tui-skeleton>
- <view class="procure_info" v-else>
- <view class="info_card">
- <view class="card_title">采购商品</view>
- <view class="card_line"></view>
- <view class="card_store">
- <image class="img" :src="procurement.productImage" mode="aspectFill"></image>
- <view class="store_title">{{procurement.productName | subText(22)}}</view>
- </view>
- <view class="back-filter" v-if="procurementStatus('isDelFlag')"></view>
- </view>
- <view class="info_Initiator">
- <view class="card_title">发起者需求</view>
- <view class="card_line"></view>
- <view class="Initiator_contant">
- <view class="Initiator_name">
- <view class="Initiator_icon">发起者</view>
- <view class="user">{{procurement.userName | subText(12)}}</view>
- </view>
- <view class="Initiator_price">
- <view class="unit_price">
- <view class="title">期望单价:</view>
- <view class="price">¥{{procurement.price}}</view>
- </view>
- <view class="unit_sum">
- <view class="title">采购数量:</view>
- <view class="price">{{procurement.number}}</view>
- </view>
- </view>
- </view>
- <view class="status">
- <image
- style="width: 100%;height: 100%;"
- src="@/static/procurement/success.png"
- mode="aspectFill"
- v-if="procurementStatus('isAchieve')"
- ></image>
- <image
- style="width: 100%;height: 100%;"
- src="@/static/procurement/delete.png"
- mode="aspectFill"
- v-if="procurementStatus('isDelFlag')"
- ></image>
- </view>
- <view class="back-filter" v-if="procurementStatus('isDelFlag')"></view>
- </view>
- <view class="info_Participant">
- <view class="card_title">参与者需求({{ procurementList.length }})</view>
- <view class="card_line"></view>
- <view v-if="procurementList.length !== 0">
- <view
- class="Initiator_contant"
- v-for="(item, index) in procurementList"
- :key="item"
- :style="{ margin: index !== 0 ? '24rpx 8rpx 16rpx 8rpx' : '40rpx 8rpx 16rpx 8rpx' }"
- >
- <view class="Initiator_name">
- <view class="Initiator_icon">参与者</view>
- <view class="user">{{item.userName | subText(12)}}</view>
- </view>
- <view class="Initiator_price">
- <view class="unit_price">
- <view class="title">期望单价:</view>
- <view class="price">¥{{procurement.price}}</view>
- </view>
- <view class="unit_sum">
- <view class="title">采购数量:</view>
- <view class="price">{{procurement.number}}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="empty" v-else>暂无参与者~</view>
- <view class="back-filter" v-if="procurementStatus('isDelFlag')"></view>
- </view>
- </view>
- <view v-if="!procurementStatus('isDelFlag') && !procurementStatus('isAchieve')">
- <view class="info_btn" v-if="!procurementStatus('isInvolved') && !procurementStatus('isAdd')">
- <proBtn color="#FFFFFF" background="#F3B574" width="640rpx" @click="popupAdd">我要参与</proBtn>
- </view>
- <view class="info_btn" v-else>
- <proBtn @click="procurementDelete" v-if="procurementStatus('isInvolved')">删除</proBtn>
- <proBtn @click="modelData" v-else>退出</proBtn>
- <proBtn color="#FFFFFF" background="#F3B574" @click="procurementChange(procurementStatus('isInvolved'))">修改</proBtn>
- </view>
- </view>
- <tui-bottom-popup :zIndex="1002" :maskZIndex="1001" :show="popupShow" @close="handlerPopupClose">
- <view class="popup_content">
- <view class="pro_popup_title">参与需求</view>
- <view class="popup_form">
- <view class="popup_form_item">商品图片:</view>
- <view class="popup_img">
- <image style="width: 100%;height: 100%;" :src="joinData.productImage" mode="aspectFill"></image>
- </view>
- </view>
- <view class="popup_form">
- <view class="popup_form_item">商品名称:</view>
- <view class="popup_form_name">{{ joinData.productName }}</view>
- </view>
- <form>
- <view class="uni-form-item uni-column">
- <view class="title">
- <text style="font-size: 26rpx;color: #F85050;">*</text>
- 期望单价:
- </view>
- <view style="position: relative;">
- <view class="input_icon">¥</view>
- <input class="uni-input" type="number" focus v-model="joinData.price" />
- </view>
- </view>
- <view class="uni-form-item uni-column">
- <view class="title">
- <text style="font-size: 26rpx;color: #F85050;">*</text>
- 采购数量:
- </view>
- <view style="position: relative;">
- <input class="uni-input" type="number" focus v-model="joinData.number" />
- </view>
- </view>
- <view class="submit_btn">
- <button class="popup_btn cancel" @click="handlerPopupClose">取消</button>
- <button class="popup_btn submit" @click="procurementParticipate">确定</button>
- </view>
- </form>
- </view>
- </tui-bottom-popup>
- <!-- 弹窗提示 -->
- <tui-modal
- :show="modal"
- @click="handleClick"
- @cancel="hideMobel"
- :content="contentModalText"
- :button="modalButton"
- color="#333"
- :size="32"
- shape="circle"
- :maskClosable="false"
- ></tui-modal>
- </view>
- </template>
- <script>
- import proBtn from './components/procurement-btn.vue'
- export default {
- components: {
- proBtn
- },
- data() {
- return {
- procurementList: [], // 参与者数量
- procurement: {}, // 发起者需求
- skeletonShow: true, // loading
- modal: false,
- contentModalText: '',
- // 弹窗配置
- modalButton: [
- {
- text: '取消',
- type: 'gray',
- plain: true //是否空心
- },
- {
- text: '确认',
- customStyle: {
- color: '#fff',
- bgColor: 'linear-gradient(90deg, #F28F31 0%, #F3B574 100%)'
- },
- plain: false
- }
- ],
- joinData: {}, // 我要参与
- userInfo: {},
- popupShow: false, // 底部上移栏
- proTabId: '', // tab id
- detailId: '', // 详情id
- }
- },
- filters: {
- subText(str, index) {
- if(str) {
- if (str.length <= index) {
- return str
- }
- return str.substring(0, index) + '...'
- }
- return str
- }
- },
- onLoad(options) {
- this.userInfo = uni.getStorageSync('userInfo')
- this.procurementDetail(options.id)
- this.detailId = options.id
- this.proTabId = options.proTabId
- uni.$on('refreshAddData',(id) => {
- if (id) {
- this.procurementDetail(id)
- }
- })
- },
- methods: {
- // 状态
- procurementStatus(str) {
- const userIdList = this.procurementList.map(i => i.userId)
- const form = {
- isDelFlag: () => this.procurement.delFlag == 1, // 是否删除
- isAchieve: () => this.procurement.isAchieve == 1, // 是否实现
- isAllTab: () => this.proTabId === 0, // 是否在全部的tab栏下
- isSelfParticipationTab: () => this.proTabId > 0, // 是否在已参与tab栏 是否在自已发布的tab中
- 'isInvolved': () => this.procurement.isInvolved === 2, // 是否我创建的
- 'isAdd': () => this.procurement.isInvolved === 1, // 是否参与
- }
- return form[str]()
- },
- // 删除
- procurementDelete() {
- this.contentModalText = '确定删除该需求吗?'
- this.modal = true
- this.joinData = $event
- },
- handleClick($event) {
- if ($event.index === 1) {
- if(this.joinData.isInvolved === 1) {
- // 退出参与
- this.procurementUpdate(1)
- } else{
- // 删除
- this.procurementUpdate(0)
- }
- }
- this.modal = false
- },
- hideMobel() {},
- // 关闭底部
- handlerPopupClose() {
- this.popupShow = false
- },
- // 我要参与
- popupAdd() {
- this.joinData = Object.assign(this.procurement, {number: '', price: '', userId: this.userInfo.userId})
- this.popupShow = true
- },
- // 组件传递商品详情 退出
- modelData(proData) {
- this.contentModalText = '确定退出参与该需求吗?'
- this.modal = true
- this.proDataInfo = proData
- },
- procurementChange(status) {
- if (status) {
- uni.navigateTo({
- url: '/pages/goods/procurementAdd?id='+this.procurement.id
- })
- } else {
- this.procurementEditData()
- }
- },
- // 详情
- async procurementDetail(id) {
- try {
- const { data } = await this.ProcurementService.procurementDetail({ id: id })
- this.procurement = data.procurement
- this.procurementList = data.procurementList
- this.skeletonShow = false
- } catch (error) {
- console.log(error)
- }
- },
- // 删除 退出
- async procurementUpdate(type) {
- const form = {
- id: this.detailId,
- userId: this.userInfo.userId,
- procurementType: type
- }
- try{
- await this.ProcurementService.procurementUpdate(form)
- this.procurementDetail(this.detailId)
- uni.$emit('refreshAddData') // 刷新修改的数据
- uni.showToast({
- title: `${type === 0 ? '删除' : '退出'}成功`,
- icon: 'success'
- })
- }catch(error){
- console.log(error)
- }
- },
- // 我要参与
- async procurementParticipate() {
- if(this.joinData.price === '') {
- return this.$util.msg('请输入期望单价', 2000)
- }
- if(this.joinData.number === '') {
- return this.$util.msg('请输入采购数量', 2000)
- }
- const form = {
- userId: this.userInfo.userId,
- productImage: this.joinData.productImage,
- productName: this.joinData.productName,
- price: this.joinData.price,
- number: this.joinData.number,
- status: 0,
- id: this.joinData.id
- }
- if (this.joinData.isInvolved === 1) {
- form.id = this.joinData.sid
- form.status = 1 // 0参与 1 修改
- }
- try{
- await this.ProcurementService.procurementParticipate(form)
- this.procurementDetail(this.detailId)
- uni.$emit('refreshAddData') // 刷新修改的数据
- uni.showToast({
- title:`${this.procurement.isInvolved === 0 ? '参与' : '修改'}成功`,
- icon: 'success'
- })
- }catch(error){
- console.log(error)
- }
- },
- // 参与集采详情
- async procurementEditData() {
- const form = {
- id: `${this.procurement.sid}`,
- userId: this.userInfo.userId,
- procurementType: 0
- }
- try{
- const data = await this.ProcurementService.procurementEditData(form)
- this.joinData = data.data
- this.popupShow = true
- }catch(error){
- console.log(error)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .img {
- width: 136rpx;
- height: 136rpx;
- border: 1px dotted black;
- margin-right: 24rpx;
- }
- .procure_info {
- background-color: #f7f7f7;
- padding: 24rpx;
- }
- .procure_info .info_card {
- height: 340rpx;
- padding: 24rpx;
- background-color: #fff;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- box-sizing: border-box;
- position: relative;
- }
- .card_title {
- color: #333333;
- font-size: 32rpx;
- font-weight: bold;
- }
- .card_line {
- border: 1rpx solid #e1e1e1;
- margin-top: 24rpx;
- }
- .info_card .card_store {
- margin: 40rpx 8px;
- padding: 12rpx;
- background-color: #f7f7f7;
- display: flex;
- align-items: center;
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- }
- .info_card .store_title {
- width: 442rpx;
- font-size: 26rpx;
- color: #333333;
- line-height: 48rpx;
- }
- .procure_info .info_Initiator {
- background-color: #fff;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- padding: 24rpx;
- margin: 24rpx 0;
- box-sizing: border-box;
- position: relative;
- }
- .Initiator_contant {
- height: 220rpx;
- background-color: #f7f7f7;
- margin: 40rpx 8rpx 16rpx 8rpx;
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- padding: 40rpx 24rpx;
- box-sizing: border-box;
- }
- .Initiator_contant .Initiator_name {
- display: flex;
- align-items: center;
- }
- .Initiator_contant .Initiator_icon {
- width: 96rpx;
- height: 40rpx;
- line-height: 40rpx;
- font-size: 24rpx;
- text-align: center;
- color: #fff;
- background-color: #f3b574;
- border-radius: 8rpx;
- margin-right: 24rpx;
- }
- .Initiator_name .user {
- color: #333333;
- font-size: 32rpx;
- font-weight: bold;
- }
- .Initiator_contant .Initiator_price {
- margin-top: 48rpx;
- display: flex;
- align-items: center;
- }
- .Initiator_price .unit_price,
- .Initiator_price .unit_sum {
- display: flex;
- align-items: center;
- }
- .Initiator_price .unit_sum {
- margin-left: 120rpx;
- }
- .title {
- color: #999999;
- font-size: 26rpx;
- font-weight: 400;
- }
- .price {
- color: #333333;
- font-size: 26rpx;
- }
- .info_Participant {
- background-color: #fff;
- padding: 24rpx;
- border-radius: 16rpx;
- margin-bottom: 256rpx;
- position: relative;
- }
- .empty {
- height: 250rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 26rpx;
- color: #b2b2b2;
- }
- .info_btn {
- position: fixed;
- bottom: 0%;
- left: 0;
- padding: 16rpx 56rpx 84rpx 56rpx;
- justify-content: space-between;
- display: flex;
- align-items: center;
- background-color: #fff;
- width: 100%;
- box-sizing: border-box;
- }
- .status {
- position: absolute;
- width: 150rpx;
- height: 100rpx;
- right: 48rpx;
- top: 48rpx;
- }
- .back-filter {
- position: absolute;
- left: 0;
- top: 0;
- background-color: rgba(255, 255, 255, 0.7);
- height: 100%;
- width: 100%;
- }
- </style>
|