qingyiay
2023-08-01 99a5ffe50a0441dbd09f9b9af027f8941f33b3ac
pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue
@@ -5,8 +5,8 @@
      background-size: cover;">
         <view class="top">
            <view class="top_left">
               <text>{{ realTimeWeigh }}</text>
               <!-- <text>{{ globalweigh }}</text> -->
               <!-- <text>{{ realTimeWeigh }}</text> -->
               <text>{{ globalweigh }}</text>
            </view>
            <view class="top_right">
               <view class="">
@@ -183,7 +183,29 @@
            class="jiajian"
            v-if="outBuy"></u-button>
      </view>
      <!-- <view class="four" v-if="weighList.orderType !== '外购'">如您需要调整装载货品吨数,请点击返回加减吨</view> -->
      <view style="width: 200rpx;margin: auto;position: relative;"
         v-if="historyBtn"><u-button type="primary"
            text="显示历史皮重"
            @click.stop="displayHistory"></u-button></view>
      <Transition name="slide-fade">
         <view class="history-skin"
            v-if="historyShow">
            <view class="history-skin_item"
               v-for="item in tmTaskCoalList">
               <view class="createTime">
                  日期:{{item.createTime.slice(0,10)}}
               </view>
               <view class="skin">
                  <view class="">
                     皮重:
                  </view>
                  <view class="">
                     {{item.skin}}
                  </view>
               </view>
            </view>
         </view>
      </Transition>
      <!-- 放空弹窗 -->
      <view class="evacuationModal">
         <u-modal :show="evacuationModalShow"
@@ -192,6 +214,29 @@
            :showCancelButton="true"
            @confirm="evacuationConfirm"
            @cancel="evacuationCancel"></u-modal>
      </view>
      <!-- 称重异常弹窗 -->
      <view class="">
         <u-modal :show="abnormalModalShow"
            title="异常原因"
            :showCancelButton="true"
            @confirm="abnormalConfirm"
            @cancel="abnormalCancel"
            confirmText="提交">
            <view class="slot-content">
               <u--form labelPosition="top">
                  <u-form-item>
                     <u-textarea v-model="abnormalContent"
                        confirmType="done"
                        placeholder="请输入异常原因"
                        height='140'
                        count
                        border="surround"
                        autoHeight></u-textarea>
                  </u-form-item>
               </u--form>
            </view>
         </u-modal>
      </view>
   </view>
</template>
@@ -271,50 +316,57 @@
            isfocus1: false,
            isfocus2: false,
            // 外购第一次称毛重不需要加减吨
            outBuy: true
            outBuy: true,
            // 皮重异常相关
            abnormalContent: '',
            avgSkin: null, // 平均皮重
            tmTaskCoalList: [],
            abnormalModalShow: false,
            historyBtn: false,
            historyShow: false
         };
      },
      watch: {
         realTimeWeigh(newV, oldV) {
            if (this.weighList.orderType == '外销' || this.weighList.orderType == '内销' || this.weighList.orderType ==
               '转出') {
               if (this.weighList.skin == 0) {
                  // this.temporaryWeighObj.skin = this.realTimeWeigh;
                  this.temporaryWeighObj.skin = newV;
                  this.isweigh = this.temporaryWeighObj.skin > this.weighList.orderSurplus;
               } else {
                  // this.temporaryWeighObj.hair = this.realTimeWeigh;
                  this.temporaryWeighObj.hair = newV;
                  this.temporaryWeighObj.clean = (this.temporaryWeighObj.hair - this.weighList.skin).toFixed(2);
                  this.isweigh = this.temporaryWeighObj.clean > this.weighList.orderSurplus || this.temporaryWeighObj
                     .clean < 0;
               }
            } else if (this.weighList.orderType == '外购' || this.weighList.orderType == '内购' || this.weighList
               .orderType == '转入') {
               if (this.weighList.hair == 0) {
                  // this.temporaryWeighObj.hair = this.realTimeWeigh;
                  this.temporaryWeighObj.hair = newV;
                  this.isweigh = this.temporaryWeighObj.hair > this.weighList.orderSurplus;
               } else {
                  // this.temporaryWeighObj.skin = this.realTimeWeigh;
                  this.temporaryWeighObj.skin = newV;
                  this.temporaryWeighObj.clean = (this.weighList.hair - this.temporaryWeighObj.skin).toFixed(2);
                  this.isweigh = this.temporaryWeighObj.clean > this.weighList.orderSurplus || this.temporaryWeighObj
                     .clean < 0;
               }
            }
         },
         // 监听重量变化
         // globalweigh: {
         //    handler(v) {
         //       this.weighData.weigh = this.realTimeWeigh = v;
         //       console.log(this.realTimeWeigh, '真实重量改变了');
         //    },
         //    deep: true
         // },
         globalweigh(newV) {
            this.weighData.weigh = this.realTimeWeigh = newV;
            console.log(this.realTimeWeigh, '真实重量改变了');
         globalweigh: {
            deep: true,
            handler: function(newV) {
               this.weighData.weigh = this.realTimeWeigh = newV;
               if (this.weighList.orderType == '外销' || this.weighList.orderType == '内销' || this.weighList
                  .orderType ==
                  '转出') {
                  if (this.weighList.skin == 0) {
                     this.getAverageSkin()
                     this.temporaryWeighObj.skin = newV;
                     if (this.avgSkin < newV) {
                        this.abnormalModalShow = true
                        this.historyBtn = true
                     }
                  } else {
                     this.temporaryWeighObj.hair = newV;
                     this.temporaryWeighObj.clean = (this.temporaryWeighObj.hair - this.weighList.skin).toFixed(
                        2);
                     this.isweigh = this.temporaryWeighObj.clean > this.weighList.orderSurplus || this
                        .temporaryWeighObj
                        .clean < 0;
                  }
               } else if (this.weighList.orderType == '外购' || this.weighList.orderType == '内购' || this.weighList
                  .orderType == '转入') {
                  if (this.weighList.hair == 0) {
                     this.temporaryWeighObj.hair = newV;
                  } else {
                     this.temporaryWeighObj.skin = newV;
                     this.temporaryWeighObj.clean = (this.weighList.hair - this.temporaryWeighObj.skin).toFixed(
                        2);
                     this.isweigh = this.temporaryWeighObj.clean > this.weighList.orderSurplus || this
                        .temporaryWeighObj
                        .clean < 0;
                  }
               }
            }
         }
      },
      onShow() {
@@ -336,13 +388,6 @@
         // 加减煤按钮禁用与否
         addAndSubtractCoalDisabled() {
            return this.realTimeWeigh == 0;
            // if (this.weighList.orderType == '外销' || this.weighList.orderType == '内销' || this.weighList.orderType == '转出') {
            //    if (this.weighList.hair == 0) {
            //       return true;
            //    } else if (this.weighList.hair != 0) {
            //       return false;
            //    }
            // }
         },
         // 是否放空按钮禁用
         isEvacuation() {
@@ -350,15 +395,11 @@
               '转出') {
               return (this.weighList.skin === 0 ? this.temporaryWeighObj.skin : this.weighList.skin) == this
                  .temporaryWeighObj.hair;
               // return this.weighList.skin == this.temporaryWeighObj.hair || this.temporaryWeighObj.skin == this
               //    .temporaryWeighObj.hair;
            }
            if (this.weighList.orderType == '外购' || this.weighList.orderType == '内购' || this.weighList.orderType ==
               '转入') {
               return (this.weighList.hair === 0 ? this.temporaryWeighObj.skin : this.weighList.hair) == this
                  .temporaryWeighObj.hair;
               // return this.weighList.hair == this.temporaryWeighObj.skin || this.temporaryWeighObj.skin == this
               //    .temporaryWeighObj.hair;
            }
         },
         sideline() {
@@ -368,10 +409,14 @@
      methods: {
         ...mapMutations(['changeweighHouseCode', 'changeisLogin']),
         init() {
            uni.showLoading({
               title: "加载中"
            })
            // 获取称重信息
            this.$reqGet('weighList', { id: this.takeCoalId }).then(res => {
               console.log(res, '获取称重信息');
               if (res.code == 0) {
                  uni.hideLoading()
                  this.weighList = res.data;
                  this.weighData.deptId = res.data.deptId;
                  this.weighData.tmId = res.data.id;
@@ -392,6 +437,9 @@
                  } else {
                     this.isInputOrigin = true;
                  }
               } else {
                  uni.hideLoading()
                  this.$u.toast('加载失败')
               }
            });
         },
@@ -446,7 +494,9 @@
            this.$reqPost('addAndSubtractCoal', {
               deptId: this.weighData.deptId,
               sceneId: this.weighData.sceneId,
               carNo: this.weighData.carNo
               carNo: this.weighData.carNo,
               tmId: this.weighData.tmId,
               filedId: this.weighData.filedId
            }, 'json').then(res => {
               if (res.code == 0) {
                  this.$u.toast('操作成功,即将返回上一页');
@@ -498,6 +548,46 @@
            if (this.weighData.coalContactHair > 0 && this.weighData.coalContactSkin > 0) {
               this.isInputOrigin = true;
            }
         },
         getAverageSkin() {
            uni.showLoading({
               title: "加载中"
            })
            this.$reqGet('getAvgSkin').then(res => {
               if (res.code === 0) {
                  uni.hideLoading()
                  this.avgSkin = res.data.avgSkin
                  this.tmTaskCoalList = res.data.tmTaskCoalList
               } else {
                  uni.hideLoading()
                  this.$u.toast('加载失败')
               }
            })
         },
         abnormalCancel() {
            this.abnormalModalShow = false
         },
         abnormalConfirm() {
            uni.showLoading({
               title: "提交中"
            })
            this.$reqPost('tmAbnormalTextAdd', { tmId: this.weighData.tmId, abnormalText: this.abnormalContent },
               'params').then(
               res => {
                  if (res.code == 0) {
                     uni.hideLoading()
                     this.$u.toast('提交成功')
                     this.abnormalModalShow = false
                  } else {
                     uni.hideLoading()
                     this.$u.toast('提交失败')
                     this.abnormalModalShow = true
                  }
               })
         },
         displayHistory() {
            this.historyShow = true
         }
      }
   };
@@ -513,9 +603,14 @@
   ::v-deep.weighingDevice {
      width: 100%;
      height: 100vh;
      height: 100%;
      display: flex;
      flex-direction: column;
      .slot-content {
         width: 96%;
         border: 1rpx solid rgb(220, 223, 230);
      }
      .one {
         // flex: 3;
@@ -736,6 +831,41 @@
         margin-top: vww(5);
         text-align: center;
      }
      .slide-fade-enter-active {
         transition: all 0.3s ease-out;
      }
      .history-skin {
         width: 96%;
         height: vww(300);
         margin: vww(50) auto;
         margin-top: vww(10);
         background: #ffffff;
         box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
         border-radius: 20rpx;
         overflow: scroll;
         color: #000;
         .history-skin_item {
            width: 80%;
            height: vww(30);
            @include flex;
            margin: vww(10) auto;
            .createTime {
               color: rgb(60, 156, 255);
            }
            .skin {
               color: #f81414;
               @include flex;
               width: 180rpx;
               height: vww(30);
            }
         }
      }
   }
   .secondary-confirmation__main {