tanghaolin
2022-11-15 a5423b5b554ecc3d54c4f0b0aac5cac71c1dab96
添加切换远程/本地控制的交互
已修改5个文件
155 ■■■■ 文件已修改
map/index.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
monitor/station/index.js 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
monitor/station/index.wxml 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project.private.config.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/api.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
map/index.js
@@ -72,22 +72,25 @@
        name: '巡检记录',
        icon: 'icon-lishi2',
        color: 'yellow'
      }, {
      },
      {
        type: 3,
        name: '报修',
        icon: 'icon-zengjia',
        color: 'green'
      }, {
      },
      {
        type: 4,
        name: '报修记录',
        icon: 'icon-wangshangbaoming',
        color: 'blue'
      }, {
      },
      {
        type: 5,
        name: '更多',
        icon: 'icon-icon-test1',
        color: 'olive'
      },
      }
    ]
  },
  onLoad: function (options) {
monitor/station/index.js
@@ -147,6 +147,13 @@
    isInOperationByEdit: false, //是在进行修改 
    isInOperationByOpenOrClose: false, //是否在进行开关机操作
    dialogModalVisibleByCtrl:false,//控制方式切换的模态款 显示/隐藏
    changeCtrlPwd:"",//改变控制方式是输入的密码
    ruleChangeCtrlPwd: {
      visibleStatus: false,
      message: "密码不能为空"
    }, //改变控制方式的密码校验
    m_currentEditSingleObj: {
      modelVisible: false, //当前模态款的显/隐状态
      parentID: null, //当前的泵组id
@@ -1016,20 +1023,102 @@
    })
  },
//监听开关机控制模式切换
  handlCloseOrOpen(e){
    this.setData({
      "kpiParas.operationModel":e.detail.value
    })
  },
  //监听开关机控制模式切换
  handlCloseOrOpenCtrl(e){
  handlCloseOrOpenCtrl(){
    //1 点击后先弹出 输入密码模态款
    //2 输入密码后才调用api
    // api 入参中 ReadOnly:表示是否修改  IsRemote:表示是否为远程
      // this.data.kpiParas.operationModel = !this.data.kpiParas.operationModel
      // console.log(this.data.kpiParas.operationModel,1033)
      this.setData({
        // "kpiParas.operationModel":this.data.kpiParas.operationModel,
        dialogModalVisibleByCtrl:true
      })
      //  console.log(this.data.kpiParas,1033)
  },
  //关闭切换远程/本地控制的模态框
  hideChangeCtrlModal(){
    this.setData({
      dialogModalVisibleByCtrl: false
    })
  },
// 远程/本地控制切换 确定按钮
  defindCtrlBtn(){
    let _this = this
      let isPassRule = true //判断是否通过校验
      // 判断当前是开机状态则调用关机api
      if (_this.data.kpiParas.operationModel) {
        let changeCtrlPwd = _this.data.changeCtrlPwd
        let changeCtrlPwdRuleVisible = false
        let changeCtrlPwdRuleMsg = ""
        if(changeCtrlPwd.length == 0 || changeCtrlPwd == ""){
          changeCtrlPwdRuleVisible = true
          changeCtrlPwdRuleMsg = "密码不能为空"
          isPassRule = false
        }else {
          changeCtrlPwdRuleVisible = true
          changeCtrlPwdRuleMsg = ""
        }
        if(!isPassRule){
          _this.setData({
            "ruleChangeCtrlPwd.visibleStatus":changeCtrlPwdRuleVisible,
            "ruleChangeCtrlPwd.message":changeCtrlPwdRuleMsg,
          })
          return
        }
        _this.setData({
          isInOperationByOpenOrClose: true,
          dialogModalVisibleByCtrl: false
        })
        // 判断当前是否已经是远程控制 如果则修改状态为本地控制
        if(_this.data.kpiParas.operationModel){
          _this.TestChangeByLocal()
        }else{
          _this.TestChangeByRemote()
        }
      }
  },
  //修改为远程控制
  TestChangeByRemote(){
    let _this = this
    Request({
      method:"POST",
      url:Constant.BASE_SERVER_URL + "Monitor/Control/NT/TestChange@V1.0",
          // api 入参中 ReadOnly:表示是否修改  IsRemote:表示是否为远程
      data:{
        ReadOnly:true,
        IsRemote:true
      },
      success:res=>{
        _this.setData({
           "kpiParas.operationModel":true,
        })
      },
      fail:err=>{
        console.log("修改失败")
      }
    })
  },
  //修改为本地控制
  TestChangeByLocal(){
    let _this = this
    Request({
      method:"POST",
      url:Constant.BASE_SERVER_URL + "Monitor/Control/NT/TestChange@V1.0",
          // api 入参中 ReadOnly:表示是否修改  IsRemote:表示是否为远程
      data:{
        ReadOnly:true,
        IsRemote:false
      },
      success:res=>{
        _this.setData({
          "kpiParas.operationModel":false,
       })
      },
      fail:err=>{
        console.log("修改失败")
      }
    })
  },
  //监听自动停止模式选择
  handleOperationModelRadio(e){
    // console.log(e,1012)
monitor/station/index.wxml
@@ -37,7 +37,7 @@
    </view>
    <view class="y_c_list">
    <view class="operation_model" style="width: 103px;height: 36px;" bindtap="handlCloseOrOpenCtrl">
      <switch class="cyan sm radius switch-open"  checked="{{kpiParas.operationModel}}" bindchange="handlCloseOrOpen">
      <switch class="cyan sm radius switch-open" disabled="{{true}}" checked="{{kpiParas.operationModel}}">
      </switch>
    </view>
      <view class="kpiText" wx:if="{{kpiParas.operationModel}}"><text>远程控制</text></view>
@@ -308,3 +308,30 @@
    </view>
  </view>
</view>
<!-- 远程控制密码模态框 -->
<view class="cu-modal {{dialogModalVisibleByCtrl?'show':''}}" style="{{dialogModalVisibleByCtrl?'z-index: 1200;':'z-index: 1100;'}}">
  <view class="cu-dialog">
    <view class="cu-bar bg-white justify-end">
      <!-- 点击开机时显示 -->
      <view wx:if="{{kpiParas.operationModel}}" class='content'>切换远程控制</view>
      <!-- 点击关机时显示 -->
      <view wx:else class='content'>切换本地控制</view>
      <view class='action' bindtap='hideChangeCtrlModal'>
        <text class='cuIcon-close text-red'></text>
      </view>
    </view>
    <!-- 切换控制模式 -->
      <view class="operation_item">
        <label>请输入密码</label>
        <input password="{{true}}"  model:value="{{changeCtrlPwd}}" />
        <view wx:if="{{ruleChangeCtrlPwd.visibleStatus}}" class="text-red text-sm" style="margin-top: 15rpx;">{{ruleChangeCtrlPwd.message}}</view>
      </view>
    <view class="cu-bar bg-white justify-end">
      <view class='action'>
        <button class='cu-btn line-green text-green' style="color: #16b5cb;" bindtap='hideChangeCtrlModal'>取消</button>
        <button class='cu-btn margin-left' style="background-color: #16b5cb;color: #fff;" bindtap='defindCtrlBtn'>确定</button>
      </view>
    </view>
  </view>
</view>
project.private.config.json
@@ -5,5 +5,5 @@
    "urlCheck": true
  },
  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
  "libVersion": "2.27.1"
  "libVersion": "2.16.0"
}
utils/api.js
@@ -103,7 +103,6 @@
    },
    success: function (res) {
      console.log(res,"新的token信息")
      console.debug("执行到了回调")
      var result = res.data;
      // console.log(result);
@@ -140,7 +139,6 @@
      wx.setStorageSync( "AccountInfo",JSON.stringify(data))
      // 获取新的token后重新调用接口
       apiCb(params)
       console.debug("执行到了回调")
    }
  });
}