whycwx
2021-08-06 11f794ee33771f9c1bab2d417247717d268896b5
src/pages/parameter/parameter.vue
@@ -257,7 +257,7 @@
        <!-- 两端对齐 -->
        <van-row type="flex" justify="end">
            <van-col span="6"><van-button type="primary" size="mini" style="width:95%" @click="startTest">启动</van-button></van-col>
            <van-col span="6"><van-button type="info" size="mini" style="width:95%">读取</van-button></van-col>
            <van-col span="6"><van-button type="info" size="mini" style="width:95%" @click="getData()">读取</van-button></van-col>
            <van-col span="6"><van-button type="warning" size="mini" style="width:95%">设定</van-button></van-col>
        </van-row>
        
@@ -273,18 +273,17 @@
    </div>
</template>
<script>
 import { checkUserPwd } from "@/assets/js/api";
// import {
//     const_aio
// } from "@/assets/js/const"
 import { checkUserPwd,start,getParams } from "@/assets/js/api";
import  const_aio from "@/assets/js/const_aio"
export default {
    data(){
        // let cmd = const_aio.cmd;
        let cmd = const_aio.cmd;
        // let testType = const_aio.testType;
        // let rules = const_aio.dischargeRules;
        // let cycleStart = const_aio.cycleStart;
        // let HourRate = const_aio.HourRate;
        return {
            cmd:cmd,
            show:false,
            pass:"",//启动口令
            opt:{//路由参数
@@ -340,6 +339,7 @@
            self.opt = this.$route.query;
            self.$nextTick(()=>{
                self.active = self.opt.num;
                self.getData();//获取参数
            })
            
        console.log(this.$route.query)  
@@ -360,6 +360,32 @@
            this.OffLineYHOnceCycle = value;
            this.showPicker3 = false;
        },
        // 获取参数
        getData(){
            let self = this;
                getParams({
                    dev_id:"618500001",//self.opt.id,
                    op_cmd:self.cmd.getParams
                }).then(res=>{
                    let rs = JSON.parse(res.data.result);
                    if(rs.code == 1) {
                        let fsparam = rs.data[0];
                            console.log(fsparam)
                        // // 遍历参数属性并赋值
                        // for (let key in this.params) {
                        //     this.params[key] = fsparam[key];
                        // }
                        // // 设置的命令和dev_id
                        // this.params.op_cmd = this.cmd.setParams;
                        // this.$layer.msg('读取成功!');
                    }else {
                        console.log(rs)
                        // this.$layer.msg('读取失败!');
                    }
                }).catch(err=>{
                })
        },
        typeStr(){
            let self = this;
            let res = '';
@@ -377,29 +403,38 @@
            return res;
        },
        // 启动
        startTest(){
            let self = this;
                self.show = true;
        },
        // 确认口令
        confirm(){
            let self = this;
            console.log(self.pass)
            // 核对口令
            checkUserPwd(self.pass).then(res=>{
                let rs = JSON.parse(res.data.result);
                    if(rs.code == 1) {
                        self.$toast("密码检测通过,启动测试");
                        // 启动测试
                        // this.startTest();
                    }else {
                        self.$toast("启动口令错误!");
                    }
            }).catch(err=>{
                self.$toast("网络请求异常");
            })
        }
                self.show = true;
                // 核对口令
                checkUserPwd(self.pass).then(res=>{
                    let rs = JSON.parse(res.data.result);
                        if(rs.code == 1) {
                            self.$toast("密码检测通过,启动测试");
                            // 启动测试
                            // this.startTest();
                        }else {
                            self.$toast("启动口令错误!");
                        }
                }).catch(err=>{
                    self.$toast("网络请求异常");
                })
        },
        // 启动程序运行
        startTest(){
            let self = this;
                start({
                    num:self.cmd,
                    dev_id:self.opt.id,
                    BattGroupNum:self.opt
                }).then(res=>{
                    let rs = JSON.parse(res.data.result);
                }).catch(err=>{
                })
        },
    },
}
</script>