device_operate_frm.html 51.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960
<!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;
        }
        .el-tabs__item {
          font-size: 0.7rem;
          color: #828296;
        }
      </style>
  </head>
  <body>
    <div id="app" ontouchstart="" οnmοuseοver="">
      <template>
        <div class="store01001-operate-param-title" style="height: auto;">
          <div style="margin-left:15px;margin-right:15.5px;">
            <div class="aui-row aui-row-flex store01001-operate-top-14">
              <div class="aui-col aui-col-span-1" style="margin-top: 1rem;">
                <div class="store01001-operate-title-sign"></div>
              </div>
              <div class="aui-col aui-col-span-23">
                <span class="store01001-operate-device-name" id="device_imei">设备编号:{{ api.pageParam.imei }}</span>
              </div>
            </div>
            <el-tabs v-model="activeName" @tab-click="handleClick" stretch>
              <el-tab-pane label="设备控制" name="first"></el-tab-pane>
              <el-tab-pane label="参数设置" name="second"></el-tab-pane>
              <el-tab-pane label="使能控制" name="third"></el-tab-pane>
              <el-tab-pane label="报警返回值" name="fourth"></el-tab-pane>
              <el-tab-pane label="报警时间" name="fifth"></el-tab-pane>
              <el-tab-pane label="DO功能" name="sixth"></el-tab-pane>
            </el-tabs>
          </div>
        </div>


        <div v-if="opener===1" class="store01001-operate-info-panel">
          <div class="store01001-operate-info-inside-panel">
            <div v-for="(list_d, list_i) in deviceCtrList">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21" >
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list_d.name }}</span>
                </div>
                <div class="aui-col aui-col-span-8 aui-row-flex-end">
                  <div v-if="!list_d.doing" style="width: 60px;border: 1px solid #5C80F8;border-radius: 4px;height: 30px;text-align: center;" tapmode @click="deviceOperation(list_i+1, list_d.name ,'ctr', list_d.command);">
                    <span class="store01001-operate-num-value store01001-operate-num-unit" style="text-align: center;margin-left: 0px;">{{ list_d.paramValue }}</span>
                  </div>
                  <span v-else class="store01001-operate-num-value store01001-operate-num-unit aui-loading"></span>
                </div>
                <div class="aui-col aui-col-span-1 aui-row-flex-end">
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21"></div>
            </div>
          </div>
        </div>

        <div v-if="opener===2" class="store01001-operate-info-panel">
          <div class="store01001-operate-info-inside-panel">
            <div v-for="(list, i) in setParamList">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21" tapmode @click="showAmount(list)">
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
                </div>
                <div class="aui-col aui-col-span-5 aui-row-flex-end">
                  <span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;">{{ list.paramValue }}</span>
                </div>
                <div class="aui-col aui-col-span-3 aui-row-flex-start">
                  <span v-if="!list.doing" class="store01001-operate-num-value store01001-operate-num-unit">{{ list.paramUnit }}</span>
                  <span v-else class="store01001-operate-num-value store01001-operate-num-unit aui-loading"></span>
                </div>
                <div class="aui-col aui-col-span-1 aui-row-flex-end">
                  <i v-if="!list.doing" class="aui-iconfont aui-icon-right icon-right" style="color:#AEB8CE;margin-top: 0.1rem;"></i>
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21"></div>
            </div>
          </div>
        </div>

        <div v-if="opener===3" class="store01001-operate-info-panel">
          <div class="store01001-operate-info-inside-panel">
            <div style="height: 10px;"></div>
            <el-row>
              <el-col :span=2>
                <img src="http://iot.uccc.cc:9090/product/03001/icon_alert.png" style="height: 12px;width: 12px;margin-top:0.1rem;">
              </el-col>
              <el-col :span=22>
                <textarea style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(254,187,53,1);">提示:使能打开时,设备执行报警通知;使能关闭时,设备不执行报警通知。</textarea>
              </el-col>
            </el-row>

            <div v-for="(list, i) in snParamList1">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21" tapmode @click="openActionSheet(list)">
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
                </div>
                <div class="aui-col aui-col-span-7 aui-row-flex-end">
                  <span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;"> {{ list | snFilter }} </span>
                </div>
                <div class="aui-col aui-col-span-2 aui-row-flex-end">
                  <i style="border-left: 5px solid transparent;border-right: 5px solid transparent;border-top: 5px solid #999;margin-top: 0.5rem;"></i>
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21"></div>
            </div>

            <div v-for="(list, i) in snParamList2">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21">
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
                </div>
                <div class="aui-col aui-col-span-9 aui-row-flex-end">
                  <div class="aui-list-item-input" tapmode @click="switchChange(list)">
                    <input :id="'select_'+ list.order" v-if="list.status" type="checkbox"  class="aui-switch" checked >
                    <input :id="'select_'+ list.order" v-else type="checkbox" class="aui-switch" >
                  </div>
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21" style="margin-top: 30px;"></div>
            </div>
          </div>
        </div>

        <div v-if="opener===4" class="store01001-operate-info-panel">
          <div class="store01001-operate-info-inside-panel">
            <div style="height: 10px;"></div>
            <el-row>
              <el-col :span=2>
                <img src="http://iot.uccc.cc:9090/product/03001/icon_alert.png" style="height: 12px;width: 12px;margin-top:0.1rem;">
              </el-col>
              <el-col :span=22>
                <textarea style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(254,187,53,1);">提示:当电路参数恢复到返回值时,设备撤除报警提示,恢复正常。</textarea>
              </el-col>
            </el-row>
            <div v-for="(list, i) in alarmReturnList">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21" tapmode @click="showAmount(list)">
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
                </div>
                <div class="aui-col aui-col-span-5 aui-row-flex-end">
                  <span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;">{{ list.paramValue }}</span>
                </div>
                <div class="aui-col aui-col-span-3 aui-row-flex-start">
                  <span v-if="!list.doing" class="store01001-operate-num-value store01001-operate-num-unit">{{ list.paramUnit }}</span>
                  <span v-else class="store01001-operate-num-value store01001-operate-num-unit aui-loading"></span>
                </div>
                <div class="aui-col aui-col-span-1 aui-row-flex-end">
                  <i v-if="!list.doing" class="aui-iconfont aui-icon-right icon-right" style="color:#AEB8CE;margin-top: 0.1rem;"></i>
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21"></div>
            </div>
          </div>
        </div>

        <div v-if="opener===5" class="store01001-operate-info-panel">
          <div class="store01001-operate-info-inside-panel">
            <div style="height: 10px;"></div>
            <el-row>
              <el-col :span=2>
                <img src="http://iot.uccc.cc:9090/product/03001/icon_alert.png" style="height: 12px;width: 12px;margin-top:0.1rem;">
              </el-col>
              <el-col :span=22>
                <textarea style="font-size:12px;font-family:PingFang SC;font-weight:500;color:rgba(254,187,53,1);">提示:报警时间为出现异常持续多长时间后设备要上报报警通知。</textarea>
              </el-col>
            </el-row>
            <div v-for="(list, i) in alarmTime">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21" tapmode @click="showAmount(list)">
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
                </div>
                <div class="aui-col aui-col-span-5 aui-row-flex-end">
                  <span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;">{{ list.paramValue }}</span>
                </div>
                <div class="aui-col aui-col-span-3 aui-row-flex-start">
                  <span v-if="!list.doing" class="store01001-operate-num-value store01001-operate-num-unit">{{ list.paramUnit }}</span>
                  <span v-else class="store01001-operate-num-value store01001-operate-num-unit aui-loading"></span>
                </div>
                <div class="aui-col aui-col-span-1 aui-row-flex-end">
                  <i v-if="!list.doing" class="aui-iconfont aui-icon-right icon-right" style="color:#AEB8CE;margin-top: 0.1rem;"></i>
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21"></div>
            </div>
          </div>
        </div>

        <div v-if="opener===6" class="store01001-operate-info-panel">
          <div class="store01001-operate-info-inside-panel">
            <div v-for="(list, i) in DoFun">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21" tapmode @click="openActionSheet(list)">
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
                </div>
                <div class="aui-col aui-col-span-7 aui-row-flex-end">
                  <span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;"> {{ list | snFilter }} </span>
                </div>
                <div class="aui-col aui-col-span-2 aui-row-flex-end">
                  <i style="border-left: 5px solid transparent;border-right: 5px solid transparent;border-top: 5px solid #999;margin-top: 0.5rem;"></i>
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21"></div>
            </div>
            <div v-for="(list, i) in pulseWidth">
              <div class="aui-row aui-row-flex store01001-operate-padding-top-21" tapmode @click="showAmount(list)">
                <div class="aui-col aui-col-span-15 aui-row-flex-start">
                  <span class="store01001-operate-param-obj">{{ list.paramTitle }}</span>
                </div>
                <div class="aui-col aui-col-span-5 aui-row-flex-end">
                  <span style="height:1.26rem;margin-right:-0.2rem;text-align:right;font-family:DINPro-Medium;font-weight:500;color:rgba(91,127,248,1);font-size:16px;">{{ list.paramValue }}</span>
                </div>
                <div class="aui-col aui-col-span-3 aui-row-flex-start">
                  <span v-if="!list.doing" class="store01001-operate-num-value store01001-operate-num-unit">{{ list.paramUnit }}</span>
                  <span v-else class="store01001-operate-num-value store01001-operate-num-unit aui-loading"></span>
                </div>
                <div class="aui-col aui-col-span-1 aui-row-flex-end">
                  <i v-if="!list.doing" class="aui-iconfont aui-icon-right icon-right" style="color:#AEB8CE;margin-top: 0.1rem;"></i>
                </div>
              </div>
              <div class="panel-line store01001-operate-margin-top-21"></div>
            </div>
          </div>
        </div>
        <div style="height:21px;"></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/aui-tab.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" src="http://iot.uccc.cc:9090/app/js/moment.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/ctrl.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/md5.js"></script>
  <script type="text/javascript">
      var vm,
          that,
          inputDialogJSON;
      var tabTypeList = {
          "first": 1,
          "second": 2,
          "third": 3,
          "fourth": 4,
          "fifth": 5,
          "sixth": 6,
      }
      apiready = function(){
        api.parseTapmode();
        inputDialogJSON = returnInputDialogJSON()
          //---------初始化vue
          vm = new Vue({
            el: '#app',
            data: {
              imei: api.pageParam.imei,
              productId: api.pageParam.productId,
              user_id: api.getPrefs({sync: true,key: 'userID'}),
              token: api.getPrefs({sync: true,key: 'userToken'}),
              activeName: "first",
              opener: 1,
              deviceInfo: {},
              deviceCtrList: [
                {name: '复位', doing: false, command: 'RESET', paramValue: '操作'},
                {name: 'DO1动作', doing: false, command: 'OPEN', paramValue: '操作'},
                {name: 'DO2动作', doing: false, command: 'CLOSE', paramValue: '操作'},
                {name: '合闸继电器复位', doing: false, command: 'OPEN_RESET', paramValue: '操作'},
                {name: '分闸继电器复位', doing: false, command: 'CLOSE_RESET', paramValue: '操作'},
              ],
              setParamList: [
                {paramSign: "rw_lddl", paramTitle: "漏电报警值", paramValue: "", paramUnit: "mA", min: 30, max: 1000, closable: false, doing: false},
                {paramSign: "rw_wendu1cw", paramTitle: "T1温度报警值", paramValue: "", paramUnit: "℃", min: 20, max: 140, closable: false, doing: false},
                {paramSign: "rw_wendu2cw", paramTitle: "T2温度报警值", paramValue: "", paramUnit: "℃", min: 20, max: 140, closable: false, doing: false},
                {paramSign: "rw_wendu3cw", paramTitle: "T3温度报警值", paramValue: "", paramUnit: "℃", min: 20, max: 140, closable: false, doing: false},
                {paramSign: "rw_wendu4cw", paramTitle: "T4温度报警值", paramValue: "", paramUnit: "℃", min: 20, max: 140, closable: false, doing: false},
                {paramSign: "rw_gzdl", paramTitle: "过载报警值", paramValue: "", paramUnit: "A", min: 0 , max: 0 , closable: false, doing: false},
                {paramSign: "rw_glbh", paramTitle: "功率报警值", paramValue: "", paramUnit: "%", min: 40, max: 100, closable: false, doing: false},
                {paramSign: "rw_gysd", paramTitle: "过压报警值", paramValue: "", paramUnit: "V", min: 0 , max: 0 , closable: false, doing: false},
                {paramSign: "rw_qysd", paramTitle: "欠压报警值", paramValue: "", paramUnit: "V", min: 0 , max: 0 , closable: false, doing: false},
                {paramSign: "rw_dybph", paramTitle: "缺相报警值", paramValue: "", paramUnit: "%", min: 2, max: 20, closable: false, doing: false},
              ],
              alarmReturnList: [
                {paramSign: "rw_leakage_val", paramTitle: "漏电报警返回值", paramValue: "", paramUnit: "mA", min: 20 , max: 0 , closable: false, doing: false},
                {paramSign: "rw_T1_val", paramTitle: "T1温度报警返回值", paramValue: "", paramUnit: "℃", min: 20 , max: 0 , closable: false, doing: false},
                {paramSign: "rw_T2_val", paramTitle: "T2温度报警返回值", paramValue: "", paramUnit: "℃", min: 20, max: 0, closable: false, doing: false},
                {paramSign: "rw_T3_val", paramTitle: "T3温度报警返回值", paramValue: "", paramUnit: "℃", min: 20 , max: 0 , closable: false, doing: false},
                {paramSign: "rw_T4_val", paramTitle: "T4温度报警返回值", paramValue: "", paramUnit: "℃", min: 20, max: 0, closable: false, doing: false},
                {paramSign: "rw_overcurrent_val", paramTitle: "过载报警返回值", paramValue: "", paramUnit: "A", min: 0, max: 0, closable: false, doing: false},
                {paramSign: "rw_power_val", paramTitle: "功率报警返回值", paramValue: "", paramUnit: "%", min: 40, max: 0, closable: false, doing: false},
                {paramSign: "rw_overvol_val", paramTitle: "过压报警返回值", paramValue: "", paramUnit: "V", min: 0, max: 0, closable: false, doing: false},
                {paramSign: "rw_undervol_val", paramTitle: "欠压报警返回值", paramValue: "", paramUnit: "V", min: 0, max: 0, closable: false, doing: false},
                {paramSign: "rw_imbala_time", paramTitle: "缺相报警返回值", paramValue: "", paramUnit: "%", min: 2, max: 0, closable: false, doing: false},
              ],
              snParamList1: [
                {paramTitle: '报警总开关', paramSign: 'rw_alarm_mode',paramValue:  '',paramValues: [{key: '自动恢复', value: '2'}, {key: '保持', value: '1'}, {key: '关闭', value: '0'}], isDoing: false},
                {paramTitle: '静音使能', paramSign: 'mute_address',paramValue:  '',paramValues: [{key: '静音开启', value: '13107'},{key: '静音关闭', value: '17476'}], isDoing: false},
                {paramTitle: '联动1报警使能', paramSign: 'rw_dl1sn_switch',paramValue:  '',paramValues: [{key: '关闭', value: '0'},{key: '正联动', value: '1'}, {key: '反联动', value: '2'}], isDoing: false},
                {paramTitle: '联动2报警使能', paramSign: 'rw_dl2sn_switch',paramValue:  '',paramValues: [{key: '关闭', value: '0'},{key: '正联动', value: '1'}, {key: '反联动', value: '2'}], isDoing: false},
              ],
              snParamList2: [
                {paramTitle: "漏电报警", status: false,paramSign: 'rw_ldsn_switch'},
                {paramTitle: "T1温度报警", status: false, paramSign: 'rw_t1wendusn_switch'},
                {paramTitle: "T2温度报警", status: false, paramSign: 'rw_t2wendusn_switch'},
                {paramTitle: "T3温度报警", status: false, paramSign: 'rw_t3wendusn_switch'},
                {paramTitle: "T4温度报警", status: false, paramSign: 'rw_t4wendusn_switch'},
                {paramTitle: "过载报警", status: false, paramSign: 'rw_overloadsn_switch'},
                {paramTitle: "功率报警", status: false, paramSign: 'rw_powersn_switch'},
                {paramTitle: "过压报警", status: false,paramSign: 'rw_gysn_switch'},
                {paramTitle: "欠压报警", status: false, paramSign: 'rw_qysn_switch'},
                {paramTitle: "缺相报警", status: false, paramSign: 'rw_qxsn_switch'},
              ],
              alarmTime: [
                {paramSign: "rw_leakage_time", paramTitle: "漏电报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_T1_time", paramTitle: "T1温度报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_T2_time", paramTitle: "T2温度报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_T3_time", paramTitle: "T3温度报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_T4_time", paramTitle: "T4温度报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_overcurr_time", paramTitle: "过载报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_power_time", paramTitle: "功率报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_overvol_time", paramTitle: "过压报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_undervol_time", paramTitle: "欠压报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
                {paramSign: "rw_imbala_time", paramTitle: "缺相报警时间", paramValue: "", paramUnit: "s", min: 0.02 , max: 100 , closable: false, doing: false},
              ],
              DoFun: [
                {paramTitle: 'DO1功能', paramSign: 'rw_do1sz',paramValue:  '',paramValues: [{key: '漏电报警', value: '1'},
                                                                                         {key: '温度报警', value: '2'},
                                                                                         {key: '过载报警', value: '3'},
                                                                                         {key: '过压报警', value: '4'},
                                                                                         {key: '欠压报警', value: '5'},
                                                                                         {key: '缺相报警', value: '6'},
                                                                                         {key: '功率报警', value: '7'},
                                                                                         {key: 'DI1联动报警', value: '8'},
                                                                                         {key: 'DI2联动报警', value: '9'},
                                                                                         {key: '遥控合闸', value: '10'},
                                                                                         {key: '遥控分闸', value: '11'}], isDoing: false},
                  {paramTitle: 'DO2功能', paramSign: 'rw_do2sz',paramValue:  '',paramValues: [{key: '漏电报警', value: '1'},
                                                                                         {key: '温度报警', value: '2'},
                                                                                         {key: '过载报警', value: '3'},
                                                                                         {key: '过压报警', value: '4'},
                                                                                         {key: '欠压报警', value: '5'},
                                                                                         {key: '缺相报警', value: '6'},
                                                                                         {key: '功率报警', value: '7'},
                                                                                         {key: 'DI1联动报警', value: '8'},
                                                                                         {key: 'DI2联动报警', value: '9'},
                                                                                         {key: '遥控合闸', value: '10'},
                                                                                         {key: '遥控分闸', value: '11'}], isDoing: false},
              ],
              pulseWidth: [
                {paramSign: "rw_on_width", paramTitle: "合闸脉冲宽度", paramValue: "", paramUnit: "s", min: 0 , max: 10 , closable: false, doing: false},
                {paramSign: "rw_off_width", paramTitle: "分闸脉冲宽度", paramValue: "", paramUnit: "s", min: 0 , max: 10 , closable: false, doing: false},
              ],
              userType: Number(api.getPrefs({sync: true,key: 'userType'})),
            },
            filters: {
              snFilter(v) {
                let paramList = v.paramValues
                let paramValue = v.paramValue
                let name = ''
                paramList.forEach(d => {
                  if (d.value === paramValue) {
                    name = d.key
                  }
                });
                return name
              },
            },
            created() {
              that = this
              this.getDeviceInfo().then(val => {
                this.initFirstPage()
              })
              api.addEventListener({
                name: 'pageDownEvent'
              }, function(ret, err){
                setTimeout(() => {
                  api.pageDown(function(ret, err) {
                    if (!ret.scrolled) {
                    }
                  });
                }, 500);
              });
            },
            methods: {
              async getDeviceInfo() {
                let params = {
                  imei: this.imei,
                  userId: this.user_id,
                  token: this.token
                }
                //先全部get一遍!操蛋
                let params_ = {
                  user_id: this.user_id,
                  imei: this.imei,
                  type: this.productId,
                  command: 'set',
                  request_body: []
                }
                params_.command = 'get'
                this.setParamList.forEach(d => {
                  params_.request_body.push(d.paramSign)
                });
                this.alarmReturnList.forEach(d => {
                  params_.request_body.push(d.paramSign)
                });
                this.snParamList1.forEach(d => {
                  params_.request_body.push(d.paramSign)
                });
                this.snParamList2.forEach(d => {
                  params_.request_body.push(d.paramSign)
                });
                this.alarmTime.forEach(d => {
                  params_.request_body.push(d.paramSign)
                });
                this.DoFun.forEach(d => {
                  params_.request_body.push(d.paramSign)
                });
                this.pulseWidth.forEach(d => {
                  params_.request_body.push(d.paramSign)
                });
                params_.request_body = params_.request_body.filter((x) => x !== "mute_address");
                // api.showProgress({
                //     style: 'default',
                //     animationType: 'fade',
                //     title: '加载中...',
                //     text: '',
                //     modal: false
                // });
                let getCmdReq = await post_normal_set_device(params_,that.token)
                if (!getCmdReq) {
                  let getCmdReqAgain = await post_normal_set_device(params_,that.token)
                }
                // api.hideProgress();
                // return
                //-------
                let lastInfoRes = await get_device_infos_by_imei(params)
                this.deviceInfo = lastInfoRes.data.device.store02000
                for (var v1 in this.deviceInfo) {
                  this.setParamList.forEach(d => {
                    if (v1 === d.paramSign) {
                      if (d.paramSign === 'rw_lddl' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 300
                      }else if (d.paramSign === 'rw_wendu1cw' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 50
                      }else if (d.paramSign === 'rw_wendu2cw' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 50
                      }else if (d.paramSign === 'rw_wendu3cw' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 50
                      }else if (d.paramSign === 'rw_wendu4cw' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 50
                      }else if (d.paramSign === 'rw_gzdl' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 100
                      }else if (d.paramSign === 'rw_glbh' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 100
                      }else if (d.paramSign === 'rw_gysd' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 440
                      }else if (d.paramSign === 'rw_qysd' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 360
                      }else if (d.paramSign === 'rw_dybph' && this.deviceInfo[v1] === "0") {
                      	d.paramValue = 20
                      }else {
                        d.paramValue = this.deviceInfo[v1]
                      }
                    }
                  });
                }
                //另外计算个别取值范围
                this.setParamList[5].min = 0.4 * parseInt(this.deviceInfo.In)
                this.setParamList[5].max = 1.0 * parseInt(this.deviceInfo.In)
                this.setParamList[7].min = 1.0 * parseInt(this.deviceInfo.Un)
                this.setParamList[7].max = 1.4 * parseInt(this.deviceInfo.Un)
                this.setParamList[8].min = 0.8 * parseInt(this.deviceInfo.Un)
                this.setParamList[8].max = 1.0 * parseInt(this.deviceInfo.Un)
                //----
                for (var v1 in this.deviceInfo) {
                  this.alarmReturnList.forEach(d => {
                    if (v1 === d.paramSign) {
                      if (d.paramSign === 'rw_leakage_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 200
                      }
                      else if (d.paramSign === 'rw_T1_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 20
                      }
                      else if (d.paramSign === 'rw_T2_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 20
                      }
                      else if (d.paramSign === 'rw_T3_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 20
                      }
                      else if (d.paramSign === 'rw_T4_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 20
                      }
                      else if (d.paramSign === 'rw_overcurrent_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 40
                      }
                      else if (d.paramSign === 'rw_power_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 40
                      }
                      else if (d.paramSign === 'rw_overvol_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 440
                      }
                      else if (d.paramSign === 'rw_undervol_val' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 360
                      }
                      else if (d.paramSign === 'rw_imbala_time' && this.deviceInfo[v1] === "0") {
                        d.paramValue = 2
                      }else {
                        d.paramValue = this.deviceInfo[v1]
                      }
                    }
                    // }
                  });
                }
                //另外计算个别取值范围
                this.alarmReturnList[0].max = parseInt(this.deviceInfo.rw_lddl)
                this.alarmReturnList[1].max = parseInt(this.deviceInfo.rw_wendu1cw)
                this.alarmReturnList[2].max = parseInt(this.deviceInfo.rw_wendu2cw)
                this.alarmReturnList[3].max = parseInt(this.deviceInfo.rw_wendu3cw)
                this.alarmReturnList[4].max = parseInt(this.deviceInfo.rw_wendu4cw)
                this.alarmReturnList[5].min = 0.4 * parseInt(this.deviceInfo.In)
                this.alarmReturnList[5].max = parseInt(this.deviceInfo.rw_gzdl)
                this.alarmReturnList[6].max = parseInt(this.deviceInfo.rw_glbh)
                this.alarmReturnList[7].min = parseInt(this.deviceInfo.Un)
                this.alarmReturnList[7].max = parseInt(this.deviceInfo.rw_gysd)
                this.alarmReturnList[8].min = parseInt(this.deviceInfo.rw_qysd)
                this.alarmReturnList[8].max = parseInt(this.deviceInfo.Un)
                this.alarmReturnList[9].max = parseInt(this.deviceInfo.rw_dybph)
                //----

                for (var v2 in this.deviceInfo) {
                  this.alarmTime.forEach(d => {
                    if (v2 === d.paramSign) {
                      if (this.deviceInfo[v2] === "0") {
                        d.paramValue = 2
                      }else {
                        d.paramValue = this.deviceInfo[v2]
                      }
                    }
                  });
                }

                for (var v3 in this.deviceInfo) {
                  this.DoFun.forEach(d => {
                    if (v3 === d.paramSign) {
                      d.paramValue = this.deviceInfo[v3]
                    }
                  });
                }
                for (var v4 in this.deviceInfo) {
                  this.pulseWidth.forEach(d => {
                    if (v4 === d.paramSign) {
                      d.paramValue = this.deviceInfo[v4]
                    }
                  });
                }
              },
              handleClick(tab, event) {
                api.showProgress({
                  style: 'default',
                  animationType: 'fade',
                  title: '加载中...',
                  text: '',
                  modal: true
                });
                this.opener = tabTypeList[tab.name]
                switch (this.opener) {
                  case 1:
                    this.initFirstPage()
                    break;
                  case 2:
                    this.initSecondPage()
                    break;
                  case 3:
                    this.initThirdPage()
                    break;
                  case 4:
                    this.initFourthPage()
                    break;
                  case 5:
                    this.initFifthPage()
                    break;
                  case 6:
                    this.initSixthPage()
                    break;
                  default:
                    break;
                }
                api.hideProgress();
              },
              async initFirstPage() {
                this.getDeviceInfo()
              },
              async initSecondPage() {
                this.getDeviceInfo()
              },
              async initThirdPage() {
                this.getDeviceInfo()
                for (var v in this.deviceInfo) {
                  this.snParamList1.forEach(d => {
                    if (v === d.paramSign) {
                      d.paramValue = this.deviceInfo[v]
                    }
                  });
                }

                for (var v in this.deviceInfo) {
                  this.snParamList2.forEach(d => {
                    if (v === d.paramSign) {
                      d.paramValue = this.deviceInfo[v]
                      d.status = this.deviceInfo[v] === '0' ? false : true
                    }
                  });
                }
              },
              async initFourthPage() {

              },
              async initFifthPage() {

              },
              async initSixthPage() {

              },
              async showAmount(list) {
                if (list.doing) {
                  api.alert({
                    title: '系统繁忙',
                    msg: '正在操作'+ list.paramTitle +',请稍后再试!'
                  });
                  return;
                }
                let closeTitle = ''
                if (list.closable) {
                  closeTitle = ' 0关闭'
                }
                var dialogBox = api.require('dialogBox');
                dialogBox.amount({
                    texts: {
                        title: list.paramTitle + '(参数范围:' + list.min + '~' + list.max + list.paramUnit + closeTitle + ')' ,
                        default: list.paramValue,
                        leftBtnTitle: '取消',
                        rightBtnTitle: '完成'
                    },
                    tapClose: true,
                    decimal: true,
                    styles: {
                        bg: '#fff',
                        corner: 6,
                        w: 300,
                        h: 200,
                        title: {
                            marginT: 20,
                            size: 14,
                            color: '#000'
                        },
                        input: {
                            w: 150,
                            h: 44,
                            marginT: 15,
                            size: 14,
                            color: '#000'
                        },
                        dividingLine: {
                            marginT: 10,
                            width: 0.5,
                            color: '#696969'
                        },
                        left: {
                          marginB: 7,
                          marginL: 20,
                          w: 130,
                          h: 35,
                          corner: 10,
                          bg: '#5B7FF8',
                          color: '#FFFFFF',
                          size: 12
                        },
                        right: {
                            marginB: 7,
                            marginL: 10,
                            w: 130,
                            h: 35,
                            corner: 10,
                            bg: '#5B7FF8',
                            color: '#FFFFFF',
                            size: 12
                        }
                    }
                },async function(ret) {
                  var dialogBox = api.require('dialogBox');
                  if (ret.eventType == 'left') {
                    dialogBox.close({dialogName: 'amount'});
                  }else if (ret.eventType == 'right') {
                    let value_ = Number(ret.amount)

                    //可关闭但未
                    if (list.closable && value_ != 0 && (value_ < list.min || value_ > list.max)) {
                      api.alert({title: '提示',msg: '参数有误!'});
                      return;
                    }
                    if (!list.closable && (value_ < list.min || value_ > list.max)) {
                      api.alert({title: '提示',msg: '参数有误!'});
                      return;
                    }
                    let json_ = {}
                    eval('json_.'+list.paramSign+'=' + value_)
                    let params = {
                      user_id: that.user_id,
                      imei: that.imei,
                      type: that.productId,
                      command: 'set',
                      // control_name: ''
                      request_body: json_
                    }
                    dialogBox.close({dialogName: 'amount'});
                    that.setParamList.forEach((d,i) => { //锁定设置操作
                      if (d.paramSign === list.paramSign) {
                        d.doing = true
                      }
                    });
                    let setCmdReq = await post_normal_set_device(params,that.token)
                    console.log(JSON.stringify(setCmdReq));
                    that.setParamList.forEach((d,i) => {  //解锁设置操作
                      if (d.paramSign === list.paramSign) {
                        d.doing = false
                      }
                    });
                    if (setCmdReq.data.upRet) {
                      let upRet = JSON.parse(setCmdReq.data.upRet)
                      if (setCmdReq.code == 0 && setCmdReq.msg == '操作成功' && upRet.rescode == 200) {
                        api.toast({msg: '设置' + list.paramTitle + '成功',duration: 2000,location: 'bottom'});
                      }else {
                        api.toast({msg: '设置' + list.paramTitle + '失败',duration: 2000,location: 'bottom'});
                      }
                    }
                    // 射完立马get一下
                    params.command = 'get'
                    eval('params.request_body = ["' + list.paramSign + '"]')
                    console.log(JSON.stringify(params));
                    let getCmdReq = await post_normal_set_device(params,that.token)
                    console.log(JSON.stringify(getCmdReq));
                    that.initSecondPage()
                  }
                });
              },
              openActionSheet(v) {
                if (v.isDoing) {
                  api.alert({
                    title: '系统繁忙',
                    msg: '正在操作'+ v.paramTitle +',请稍后再试!'
                  });
                  return;
                }
                let keys = []
                let values = []
                v.paramValues.forEach(d => {
                  keys.push(d.key)
                  values.push(d.value)
                });
                let params = {
                  user_id: this.user_id,
                  imei: this.imei,
                  type: this.productId,
                  command: 'set',
                  request_body: {}
                }
                api.actionSheet({
                    title: v.paramTitle,
                    cancelTitle: '取消',
                    buttons: keys
                },async function(ret, err) {
                  let index = ret.buttonIndex;
                  if (index <= values.length) { //取消按钮忽略
                    //选中的value -- values[index-1]
                    let value = values[index-1]
                    v.isDoing = true
                    let sign_ = v.paramSign
                    if (v.paramSign === 'mute_address') {
                      sign_ = 'w_device_remote'
                    }
                    eval('params.request_body.' + sign_ + '= ' + value)
                    // console.log(JSON.stringify(params));
                    let setCmdReq = await post_normal_set_device(params,that.token)
                    console.log(JSON.stringify(setCmdReq));
                    v.isDoing = false
                    if (setCmdReq.data.upRet) {
                      let upRet = JSON.parse(setCmdReq.data.upRet)
                      if (setCmdReq.code == 0 && setCmdReq.msg == '操作成功' && upRet.rescode === 200) {
                        api.toast({msg: '设置成功',duration: 2000,location: 'bottom'});
                      }else {
                        api.toast({msg: '设置失败',duration: 2000,location: 'bottom'});
                      }
                    }
                    // // 射完立马get一下
                    params.command = 'get'
                    let _sign_ = v.paramSign
                    if (v.paramSign === 'mute_address') {
                      _sign_ = 'status'
                    }
                    params.request_body = [_sign_]
                    let getCmdReq = await post_normal_set_device(params,that.token)
                    console.log(JSON.stringify(getCmdReq));
                    that.getDeviceInfo().then(val => {
                      that.initThirdPage()
                    })
                  }
                })
              },
              async switchChange(list) {
                let value = ''
                let result_ = ''
                value = list.paramValue === '0' ? '1' : '0'
                result_ = list.paramValue === '0' ? '开启' : '关闭'
                let params = {
                                user_id: this.user_id,
                                imei: this.imei,
                                type: this.productId,
                                command: 'set',
                                request_body: {}
                              }
                eval('params.request_body.' + list.paramSign + ' = ' + value)
                api.showProgress({
                  style: 'default',
                  animationType: 'fade',
                  title: '加载中...',
                  text: '',
                  modal: true
                });
                let setCmdReq = await post_normal_set_device(params,that.token)
                if (setCmdReq.data.upRet) {
                  let upRet = JSON.parse(setCmdReq.data.upRet)
                  if (setCmdReq.code == 0 && setCmdReq.msg == '操作成功' && upRet.rescode == 200) {
                    api.toast({msg: '控制' + list.paramTitle + result_ + '成功',duration: 2000,location: 'bottom'});
                  }else {
                    // that.di1_str = oldDi1
                    // that.di2_str = oldDi2
                    api.toast({msg: '控制' + list.paramTitle + result_ + '失败',duration: 2000,location: 'bottom'});
                  }
                }
                // 射完立马get一下
                params.command = 'get'
                params.request_body = [list.paramSign]
                console.log(JSON.stringify(params));
                let getCmdReq = await post_normal_set_device(params,that.token)
                console.log(JSON.stringify(getCmdReq));
                api.hideProgress();
                this.getDeviceInfo().then(val => {
                  this.initThirdPage()
                })
              },
              async deviceOperation(index,name,cmd,val) {
                let dialogBox = api.require('dialogBox')
                let dom = $api.byId('btn_'+index);
                dialogBox.input(inputDialogJSON, async function(ret) {
                    if (ret.eventType == 'left') {
                        var dialogBox = api.require('dialogBox');
                        dialogBox.close({
                            dialogName: 'input'
                        });
                    }else if (ret.eventType == "right") {
                      // if (!api.pageParam.status) {
                      //   api.toast({msg: '该设备不在线无法操作!',duration: 2000,location: 'bottom'});
                      //   return;
                      // }
                      const params = {
                        imei: api.pageParam.imei,
                        userId: that.user_id,
                        token: that.token,
                      }
                      let deviceInfos = await get_device_infos_by_imei(params)
                      let pass = false
                      if (that.userType === 1) {
                        deviceInfos.data.device.password === ret.text ? pass = true : pass = false
                      }else if (that.userType === 2) {
                        deviceInfos.data.device.password === md5(ret.text) ? pass = true : pass = false
                      }
                      if (pass) {
                        //handle operate...
                        var dialogBox = api.require('dialogBox');
                        dialogBox.close({
                            dialogName: 'input'
                        });
                        that.deviceCtrList[index-1].doing = true
                        $.ajax({
                            url: HOST + '/iot_api/v2/app/tyControl',
                            type: 'POST',
                            dataType: 'json',
                            headers:{
                                'Content-Type':'application/json;charset=utf-8',
                                'token': api.pageParam.token
                            },
                            data: JSON.stringify({
                              user_id: that.user_id,
                              imei: api.pageParam.imei,
                              type: deviceInfos.data.device.storeType.table,
                              command: cmd,
                              control_name: val,
                            }),
                            complete: function() {
                                api.hideProgress();
                            },
                            success: function(ret) {
                              console.log(JSON.stringify(ret));
                              setTimeout(function(){
                                that.deviceCtrList[index-1].doing = false
                                if (ret.data.upRet) {
                                  let upRet = JSON.parse(ret.data.upRet)
                                  if (ret.code == 0 && ret.msg == '操作成功' && upRet.rescode == 200) {
                                    api.toast({
                                        msg: '操作' + name + '成功',
                                        duration: 2000,
                                        location: 'bottom'
                                    });
                                  }else {
                                    api.toast({
                                        msg: '操作' + name + '失败',
                                        duration: 2000,
                                        location: 'bottom'
                                    });
                                  }
                                }
                              }, 1000);
                            },
                            error: function() {
                              api.toast({
                                  msg: '操作' + name + '失败',
                                  duration: 2000,
                                  location: 'bottom'
                              });
                            }
                        });
                      }else {
                        api.toast({msg: '设备密码错误!',duration: 2000,location: 'bottom'});
                      }
                    }
                });
              },
            }
          })
      };
  </script>
</html>