operaterLog_frm.html 12.3 KB
<!DOCTYPE html>
<html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
      <meta name="referrer" content="no-referrer">
      <title>操作日志_frm</title>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/api.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/aui.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/home.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/element.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/style.css"/>

      <style>
          html,
          body{
            background-color: #F4F6F9;
          }
      </style>
  </head>
  <body>
    <div id="app">
      <template>
        <div class="store01001-operate-log-protect-panel" id="operater_panel" v-for="(list_d, list_i) in list">
          <div v-if="list.length > 0" class="store01001-operate-log-protect-list">
            <div class="store01001-operate-log-info-panel">
              <div class="aui-row aui-row-flex store01001-operate-log-top-14">
                  <div class="aui-col aui-col-span-2 aui-row-flex-start">
                      <div class="store01001-operate-log-number-id">{{ list_i+1 }}</div>
                  </div>
                  <div class="aui-col aui-col-span-10 aui-row-flex-start">
                      <span class="store01001-operate-log-operator" id="operator">操作者:<span style="color:#5B7FF8;">{{ list_d.userName }}</span></span>
                  </div>
                  <div class="aui-col aui-col-span-12 aui-row-flex-end">
                    <div class="aui-row aui-row-flex">
                      <div class="aui-col aui-col-span-12 aui-row-flex-start">
                        <div v-if="list_d.downResult === '1'" class="store01001-operate-log-operater-status">发送成功</div>
                        <div v-if="list_d.downResult === '0'" class="store01001-operate-log-operater-status store01001-operate-log-err-status">发送失败</div>
                        <div v-if="list_d.downResult != '0' && list_d.downResult !='1'" class="store01001-operate-log-operater-status">发送中</div>
                      </div>
                      <div class="aui-col aui-col-span-12 aui-row-flex-end">
                        <div v-if="list_d.upResult === '1'" class="store01001-operate-log-operater-status">接收成功</div>
                        <div v-if="list_d.upResult === '0'" class="store01001-operate-log-operater-status store01001-operate-log-err-status">接收失败</div>
                        <div v-if="list_d.upResult != '0' && list_d.upResult != '1'" class="store01001-operate-log-operater-status">接收中</div>
                      </div>
                    </div>
                  </div>
              </div>
              <div class="store01001-operate-log-list-line"></div>
              <div class="aui-row aui-row-flex">
                  <div class="aui-col aui-col-span-12 aui-row-flex-start">
                    <div class="store01001-operate-log-operater-dot"></div>
                    <div class="store01001-operate-log-operater-cmd">&nbsp;操作指令</div>
                  </div>
                  <div class="aui-col aui-col-span-12 aui-row-flex-end">
                    <div class="store01001-operate-log-operater-cmd-value">{{ list_d.value | commandFilter }}</div>
                  </div>
              </div>
              <div v-if="list_d.value != '' || list_d.retValue != ''" class="aui-row aui-row-flex">
                  <div class="aui-col aui-col-span-12 aui-row-flex-start">
                    <div class="store01001-operate-log-operater-dot"></div>
                    <div class="store01001-operate-log-operater-cmd">&nbsp;参数</div>
                  </div>
                  <div class="aui-col aui-col-span-12 aui-row-flex-end">
                    <div class="store01001-operate-log-operater-cmd-value"> {{ list_d.value | valueFilter }}</div>
                  </div>
              </div>
              <div class="aui-row aui-row-flex" style="margin-top:0px;">
                <div class="aui-col aui-col-span-12 aui-row-flex-start">
                  <div class="store01001-operate-log-operater-dot"></div>
                  <div class="store01001-operate-log-operater-cmd">&nbsp;操作时间</div>
                </div>
                <div class="aui-col aui-col-span-12 aui-row-flex-end">
                  <div class="store01001-operate-log-operater-cmd-value">{{ parseTime(list_d.createdAt,'{y}-{m}-{d} {h}:{i}:{s}') }}</div>
                </div>
            </div>
              <div style="height:7px;"></div>
            </div>
          </div>
        </div>
        <div style="margin-top:50px;"></div>
      </template>
    </div>
  </body>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/api.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/jquery-3.3.1.min.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/vue.min.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/common.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/element.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/ctrl.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/fastclick.js "></script>
  <script type="text/javascript">
      var vm,
          that;
          var setParamList= [
            {paramSign: 'rw_overvol' ,paramsTitle: '过电压设置'},
            {paramSign: 'rw_undervol',paramsTitle: '欠电压设置'},
            {paramSign: 'rw_overcurr',paramsTitle: '过电流设置'},
            {paramSign: 'rw_temp_upval',paramsTitle: '温度上限值设置'},
            {paramSign: 'rw_temp_lowval',paramsTitle: '温度下限值设置'},
            {paramSign: 'rw_ACvol_upval',paramsTitle: '交流电压上限值整定'},
            {paramSign: 'rw_ACvol_lowval',paramsTitle: '交流电压下限值整定'},
            {paramSign: 'rw_cutoff_vol',paramsTitle: '断电电压'},
            {paramSign: 'rw_recovery_vol',paramsTitle: '恢复电压'},
            {paramSign: 'rw_battery',paramsTitle: '电池总容量'},
            {paramSign: 'rw_elec',paramsTitle: '电能'},
            {paramSign: 'rw_user_code',paramsTitle: '用户运营商代码'},
            {paramSign: 'rw_enable_sign',paramsTitle: '使能标志位'},
            {paramSign: 'rw_ele_set',paramsTitle: '备电量设置'},
            {paramSign: 'rw_time_set',paramsTitle: '备电时长设置'},
            {paramSign: 'rw_open_time',paramsTitle: '合闸时间整定时、合闸时间整定分'},
            {paramSign: 'rw_close_time',paramsTitle: '分闸时间整定时、分闸时间整定分'},
            {paramSign: 'rw_start_time',paramsTitle: '免责时段开始时、分'},
            {paramSign: 'rw_end_time',paramsTitle: '免责时段结束时、分'},
            {paramSign: 'w_open_close_command',paramsTitle: '分合闸命令'},
          ]

      function resultFormat(key, value) {
        let result = value;
        const map = {
          w_open_close_command: {
            "665": "分闸",
            "392": "合闸",
          },
        }
        if (map[key] && map[key][value]) result = map[key][value];
        return result;
      }    
      
      apiready = function(){
        api.parseTapmode();
        $(function() {
          FastClick.attach(document.body);
        }); 

        //---------初始化vue
        vm = new Vue({
          el: '#app',
          data: {
            page: 1,
            limit: 10,
            hasNext: true,
            imei: api.pageParam.imei,
            productId: api.pageParam.productId,
            token: api.getPrefs({sync: true,key: 'userToken'}),
            userId: api.getPrefs({sync: true,key: 'userId'}),
            time: "",
            type: 'set',
            list: [],
            
          },
          mounted() {
            //window.chooseProduct = this.chooseProduct;
          },
          created() {
            that = this
            /**上拉加载 */
            api.addEventListener({
              name: 'scrolltobottom',
              extra: {
                  threshold: 0
              }
            }, function(ret, err) {
              if (that.hasNext) {
                that.page += 1;
              }
              that.getLogList();
            });
            api.addEventListener({
              name: 'changeOperaterType4Log'
            }, function(ret, err){
                if( ret && ret.value.curName ){
                  that.type = ret.value.curCmd
                  that.page = 1
                  that.hasNext = true
                  that.list = []
                  that.getLogList()
                }
            });
            api.addEventListener({
                name: 'chanegOperateSearchDate'
            }, function(ret, err){
                if( ret && ret.value.selected_time ){
                  that.time = ret.value.selected_time
                  that.page = 1
                  that.hasNext = true
                  that.list = []
                  that.getLogList()
                }
            });
            /** 下拉刷新 */
            api.setRefreshHeaderInfo({
                loadingImg:'../../image/alpha0.png',
                bgColor: 'rgba(255,255,255,0)',
                textColor: '#AEB8CE',
                textDown: '刷新操作日志列表...',
                textUp: '松开刷新...'
            }, function(ret, err) {
              that.page = 1;
              that.time = '';
              that.hasNext = true;
              that.list = []
              //-----
              api.sendEvent({
                  name: 'cleanOperaterCondition',
              });
              that.getLogList()
              api.refreshHeaderLoadDone();
            });            
            that.getLogList()
          },
          filters: {
            valueFilter(v) {
              let params_ = JSON.parse(v).params
              let params = ''
              for (var val in params_) {
                params += params_[val] + ' '
              }
              return params
            },
            commandFilter(v) {
              let params_ = JSON.parse(v).params
              let params = ''
              console.log(JSON.stringify(params_));
              for (var val in params_) {
                setParamList.forEach(d => {
                  if (d.paramSign === val) {
                    if ('w_open_close_command' === d.paramSign) {
                      params += resultFormat(d.paramSign, params_[val]) + ' '
                    }else {
                      params += d.paramsTitle + ' '
                    }
                  }
                });
              }
              return params
            }
          },
          methods: {
            async getLogList() {
              if (!this.hasNext) {
                return;
              }
              let params = {
                imei: this.imei,
                limit: this.limit,
                page: this.page,
                token: this.token,
                type: this.type
              }
              if (this.time != '') {
                params.time = this.time
              }
              
              let listRes = await get_ty_operate_log_list(params)
              if (listRes.code === 0 && listRes.data.rows.length > 0) {
                let listD = listRes.data.rows
                listD.forEach(d => {
                  let count = 0
                  for(var key in JSON.parse(d.value).params){
                    if (key === 'rw_year' || key === 'rw_month_day' || key === 'rw_hour_min') {
                      count+=1
                    }
                  }
                  if (count === 0) {
                    this.list.push(d)
                  }
                });
              }else {
                // addAlert('网络错误!');
                api.toast({
                  msg: '暂无更多数据',
                  duration: 2000,
                  location: 'bottom'
                });
              }
            },
          }
        })
      };
  </script>
</html>