quanyawei
2023-11-20 5f8cd55f32939d15c6224d491f89743421cab0f9
pages/actionChange/agencyPage/index.vue
@@ -3,23 +3,35 @@
      <view class="hearderInfor">
         <view>
            <p class="unit">
               <text>责任单位:{{ userInfor.userName ||''}}</text>
               <text>责任单位:{{ unitName }}</text>
            </p>
         </view>
         <view class="headSculpture">
            <image alt="" src="/static/img/headSculpture.png" />
            <text>欢迎您:{{ userInfor.userName || ''}}</text>
            <button open-type="chooseAvatar" @chooseavatar='onChooseAvatar'
               style="padding: 0;margin: 0;border-radius: 100px;">
               <u-avatar :src="avatarUrl" randomBgColor size='60'></u-avatar>
            </button>
            <text style="margin-left: 46.15rpx;">欢迎您:{{ userName || ''}}</text>
         </view>
      </view>
      <view>
         <u-tabs :list="list" :scrollable="scrollable" @change="changeTap" />
         <u-tabs :list="list" :scrollable="scrollable" lineWidth="60" :current='current' @change="changeTap" />
      </view>
      <view class="" v-if="userInfor.userName">
      <view class="" v-if="userName">
         <view class="dataRangeSerch" v-if="current===3">
            <view class="dataRangeSerchLabel">
               <text style="margin-right: 8px;">日期:</text>
               <uni-datetime-picker v-model="range" type="daterange" rangeSeparator="至" />
            </view>
            <view>
               <u-button type="primary" size="small" text="查询" @click="getSearch" throttleTime='500'></u-button>
            </view>
         </view>
         <view :key="index" v-for="(item, index) in workOderList" class="workOrderDetail"
            @tap="handleClick(item, 'edit')">
            <view class="mainContent">
               <p class="rowTip" style="justify-content: space-between">
                  <text class=""> 交办单号: {{ item.allocationNum }}
                  <text class=" titleLable"> 交办单号: {{ item.allocationNum }}
                  </text>
                  <text class="rowTipContenet_right">
                     <text catchtap class="butsName" @tap.stop="handleClick(item, 'view')"> 查看 </text>
@@ -69,9 +81,14 @@
                  <view class="rowTipContenet">
                     <view class="wholeLine">
                        <text class="rowTipContenetLabel">流程状态:</text>
                        <text class="rowTipContenetAll">
                           {{ stateFormatter(item.state) }}
                        </text>
                        <u--text type="warning" :text="item.state |stateFormatter" size='30.77rpx'
                           v-if="item.state===20 ||item.state===9"></u--text>
                        <u--text type="primary" :text="item.state |stateFormatter" size='30.77rpx'
                           v-if="item.state===30"></u--text>
                        <u--text type="success" :text="item.state |stateFormatter" size='30.77rpx'
                           v-if="item.state===40"></u--text>
                        <u--text type="error" :text="item.state |stateFormatter" size='30.77rpx'
                           v-if="item.state===50"></u--text>
                     </view>
                  </view>
               </p>
@@ -90,11 +107,7 @@
                     <view class="wholeLine">
                        <text class="rowTipContenetLabel">上报单位:</text>
                        <text class="rowTipContenetAll">
                           {{ unitList.find(
                                 (a) =>
                                    item && parseInt(a.unitId) === item.escalationUnitId
                              ).unitName
                           }}
                           {{ item.escalationUnitName}}
                        </text>
                     </view>
                  </view>
@@ -108,7 +121,12 @@
                  </view>
               </p>
            </view>
            <view class="yingzhang" v-if="item.isInvalid===1">
               <view class="seal-red"> 已作废 </view>
            </view>
         </view>
         <u-loadmore :status="status" :loading-text="loadingText" @loadmore='getLoadmore'
            :loadmore-text="loadmoreText" dashed line :nomore-text="nomoreText" />
      </view>
   </view>
</template>
@@ -117,11 +135,13 @@
      httpPost,
      httpGet
   } from '@/utils/http.js'
   import store from '@/store/index.js'
   export default {
      data() {
         return {
            range: [],
            scrollable: false,
            userInfor: {},
            userInfor: null,
            dictObj: [],
            list: [{
               name: '全部',
@@ -136,66 +156,211 @@
               name: '已完成',
               value: 3,
            }, ],
            current: 0,
            showeEscalationTime: false,
            current: 1,
            startTime: '',
            endTime: '',
            workOderList: [],
            unitList: [],
            polluteList: [],
            avatarUrl: '',
            baseUrl: '',
            token: '',
            status: 'loadmore',
            loadingText: '努力加载中',
            loadmoreText: '加载更多',
            nomoreText: '实在没有了',
            isLoading: false,
            page: {
               currentPage: 1,
               pageSize: 10
            }
         }
      },
      mounted() {
         console.log('mounted this.userInfo', this.userInfo)
      watch: {
         range(newval) {
            console.log('newval', newval)
            this.startTime = newval[0]
            this.endTime = newval[1]
         },
      },
      created() {
         console.log('created this.userInfo', this.userInfo)
         this.getContaminateList()
         this.getUnitList()
         this.getWorkOrder()
      computed: {
         unitName() {
            let data = ''
            if (this.userInfor && this.unitList.length > 0) {
               data = this.unitList && this.unitList.find(a => Number(a.unitId) === Number(this.userInfor.unitId))
            }
            if (this.userInfor) {
               data = this.userInfor.unName
            }
            return data
         },
         userName() {
            let data = ''
            if (this.userInfor) {
               data = this.userInfor.userName
            }
            return data
         }
      },
      onShow() {
         uni.showTabBar()
      mounted() {},
      filters: {
         stateFormatter(val) {
            let information = JSON.parse(uni.getStorageSync('dictObj') || '[]')
            return information.allocationApproveEnum[val]
         }
      },
      onLoad: () => {},
      methods: {
         changeTap(data) {
            this.current = data.value
         onBottom() {
            //这里是判断是否需要继续掉接口
            console.log('1122111')
            this.status = 'loading'
            //请求一次接口,页码就++
            this.page.currentPage = ++this.page.currentPage
            //根据索引,点击哪个tab加载哪个
            this.getWorkOrder()
         },
         getLoadmore() {
            this.status = 'loading'
            //请求一次接口,页码就++
            this.page.currentPage = ++this.page.currentPage
            //根据索引,点击哪个tab加载哪个
            this.getWorkOrder()
         },
         async onChooseAvatar(e) {
            const {
               avatarUrl
            } = e.detail // 此返回的路径为临时路径,需转换为永久路径保存使用
            this.avatarUrl = avatarUrl
            uni.showToast({
               title: '成功',
               duration: 1000
            })
            let a = uni.uploadFile({
               url: this.baseUrl + '/file/upload',
               filePath: this.avatarUrl,
               header: {
                  token: this.token,
                  Authorization: this.token,
               },
               name: 'file',
               formData: {
                  sysCode: '1202401'
               },
               success: res => {
                  let resData = JSON.parse(res.data)
                  let parms = {
                     'file': resData.data,
                     'userId': this.userInfor.userId
                  }
                  this.$http.httpPost('/allocationApp/appFile', parms).then(res => {
                     uni.removeStorageSync('userInfor')
                     this.userInfor.file = resData.data
                     console.log('resData.data', resData.data)
                     uni.setStorageSync('userInfor', JSON.stringify(this.userInfor))
                     console.log('this.userInforSet', this.userInfor)
                  })
                  console.log(this.url)
               },
               fail: res => {
                  uni.showToast({
                     title: res.data,
                     icon: 'none',
                  })
               }
            })
         },
         changeTap(data) {
            console.log(data)
            this.current = data.value
            this.page = {
               currentPage: 1,
               pageSize: 10
            }
            this.workOderList = []
            this.startTime = ''
            this.endTime = ''
            uni.$u.throttle(this.getWorkOrder, 500)
         },
         getSearch() {
            this.workOderList = []
            this.page = {
               currentPage: 1,
               pageSize: 10
            }
            this.getWorkOrder()
         },
         setData() {
            this.workOderList = []
            this.page = {
               currentPage: 1,
               pageSize: 10
            }
            this.getContaminateList()
         },
         // 获取责任单位list
         getUnitList() {
            this.$http.httpGet('/allocation/unit').then(res => {
               this.unitList = res.data
               this.userInfor = this.$storage.getJson('userInfo')
               this.dictObj = this.$storage.getJson('dictObj')
               this.$storage.setJson('unitList', this.unitList)
            })
         },
         getContaminateList() {
            console.log('indexindex')
            this.$http.httpGet('/allocation/contaminate').then(res => {
               this.polluteList = res.data
               this.$storage.setJson('polluteList', this.polluteList)
               this.dictObj = JSON.parse(uni.getStorageSync('dictObj') || '[]')
               this.userInfor = JSON.parse(uni.getStorageSync('userInfor') || '{}')
               this.baseUrl = this.$storage.get('baseUrl')
               this.token = uni.getStorageSync('tonken')
               this.avatarUrl = `${this.baseUrl}/file/preview/${this.userInfor.file.fileId}`
               console.log('indexindexindexindexthis.userInfor', this.userInfor)
               this.getUnitList()
               this.getWorkOrder()
            }).catch(res => {
               console.log('错了么', res)
               // this.getContaminateList()
            })
         },
         stateFormatter(val) {
            return this.dictObj.allocationApproveEnum[val]
         },
         getWorkOrder() {
            httpGet('/allocationApp/select', {
            httpPost('/allocationApp/page', {
               state: this.current,
               startTime: '',
               endTime: '',
               startTime: this.startTime,
               endTime: this.endTime,
               page: {
                  'currentPage': this.page.currentPage,
                  'pageSize': this.page.pageSize
               },
            }).then(res => {
               this.workOderList = res.data
               console.log('indexindex', res.data.list)
               if (res.data.list) {
                  if (res.data.list.length < this.page.pageSize) {
                     //这里设置成false就不可以继续加载,不可以进入请求接口的方法里了
                     this.isLoading = false
                     this.status = 'nomore'
                  } else {
                     this.isLoading = true
                     this.status = 'loadmore'
                  }
                  res.data.list.forEach(el => {
                     this.workOderList.push(el)
                  })
               } else {
                  this.status = 'nomore'
               }
            })
         },
         handleClick(e, pageState) {
            this.$http.httpGet('/allocation/detail', {
               id: e.allocationId
            }).then(res => {
               let data = res.data
               data.pageState = pageState
               let myData = JSON.stringify(data)
               uni.navigateTo({
                  url: '/pages/actionChange/workOrderDetails/index?infor=' + myData,
               })
            let data = {}
            data.pageState = e.stateName === '待处理' ? pageState : 'view'
            data.stateName = e.stateName
            data.allocationId = e.allocationId
            data.state = e.state
            data.allocationNum = e.allocationNum
            data.current = this.current
            let myData = JSON.stringify(data)
            uni.navigateTo({
               url: '/pages/actionChange/workOrderDetails/index?infor=' + myData + '&type=jump',
            })
         },
      },
@@ -203,14 +368,18 @@
   }
</script>
<style scoped lang="scss">
   page {
      height: 101vh;
   }
   /deep/.uni-page-head {
      display: none;
   }
   .hearderInfor {
      font-size: 26.92rpx;
      height: 223.08rpx;
      font-size: 28.85rpx;
      background-color: #3875c5;
      padding-bottom: 8px;
      color: #f2f2f2;
      .unit {
@@ -222,8 +391,9 @@
      .headSculpture {
         display: flex;
         align-items: center;
         padding-left: 20px;
         image {
         .imageSrc {
            height: 117.31rpx;
            width: 117.31rpx;
            margin: 0rpx 46.15rpx;
@@ -234,25 +404,23 @@
   .textContent {
      text-align: left;
      width: 100%;
      font-size: 28.85rpx;
      font-size: 30.77rpx;
   }
   .workOrderDetail {
      border: 1px solid #bbb;
      border-radius: 5px;
      min-height: 288.46rpx;
      margin: 19.23rpx;
      padding: 19.23rpx;
      margin: 9.62rpx;
      padding: 9.62rpx 19.23rpx;
      color: #101010;
      font-weight: 700;
      font-size: 26.92rpx;
      font-size: 30.77rpx;
      /deep/.u-line {
         margin: 19.23rpx 0px !important;
         margin: 9.62rpx 0px !important;
      }
      .mainContent {
         margin-bottom: 10px;
         margin-bottom: 5px;
         .rowTip {
            display: flex;
@@ -283,9 +451,66 @@
            color: #1990ff;
         }
         .titleLable {
            font-size: 30.77rpx;
            font-weight: bold;
         }
         .rowTipContenet_right {
            text-align: right !important;
         }
      }
   }
   /deep/.u-tabs__wrapper__nav__item__text {
      font-size: 34.62rpx !important;
   }
   .yingzhang {
      position: relative;
      .seal-red {
         position: absolute;
         right: 0;
         top: -85px;
         display: inline-block;
         border: solid 2px #e93e00;
         border-radius: .2em;
         color: #e24c06;
         font-size: 19px;
         line-height: 1;
         opacity: 0;
         padding: .1em .5em;
         text-transform: uppercase;
         opacity: .75;
         transform: rotate(-15deg) scale(1);
         // animation: seal .3s cubic-bezier(0.6, 0.04, 0.98, 0.335) forwards;
      }
      @keyframes seal {
         100% {
            opacity: .75;
            transform: rotate(-15deg) scale(1);
         }
      }
   }
   .dataRangeSerch {
      display: flex;
      justify-content: space-around;
      align-items: center;
      padding: 10px 0 5px 0px;
      .dataRangeSerchLabel {
         display: flex;
         align-items: center;
         width: 75%;
      }
      /deep/.range-separator,
      /deep/.uni-date__x-inpu {
         height: 30px !important;
         line-height: 30px !important;
      }
   }
</style>