likang 2 years ago
parent
commit
bddaf4247c

+ 141 - 58
src/pages/kede/yys/alarms/add.vue

@@ -36,7 +36,7 @@
                 v-model="formData.fan_model"
                 name="fan_model"
                 label="风机型号"
-                placeholder="请输入部件类型"
+                placeholder="请选择部件类型"
                 clearable
                 required
                 @click="showFanModel = true"
@@ -58,7 +58,7 @@
                 v-model="formData.parts_sign"
                 name="parts_sign"
                 label="部件类型"
-                placeholder="请输入部件类型"
+                placeholder="请选择部件类型"
                 clearable
                 required
                 @click="showPart = true"
@@ -82,7 +82,7 @@
                 v-model="formData.work_sign"
                 name="work_sign"
                 label="工作位置"
-                placeholder="请输入工作位置"
+                placeholder="请选择工作位置"
                 clearable
                 required
                 @click="showWorkPage"
@@ -97,60 +97,92 @@
                     @cancel="showWork = false"
                 />
             </van-popup>
+
             <van-field
-                v-model="formData.device_name"
-                name="device_name"
+                v-model="formData.boit_type_sign"
+                name="boit_type_sign"
                 label="螺栓型号"
                 placeholder="请输入螺栓型号"
+                required
                 clearable
+                @click="showType= true"
             />
+            <van-popup v-model="showType" position="bottom">
+                <van-picker
+                    value-key="name"
+                    name="work_sign"
+                    show-toolbar
+                    :columns="Type"
+                    @confirm="onTypeConfirm"
+                    @cancel="showType= false"
+                />
+            </van-popup>
+
             <van-field
-                v-model="formData.device_name"
-                name="device_name"
-                label="螺栓总数"
-                placeholder="请输入螺栓总数"
+                v-model="formData.tighten_mode"
+                name="tighten_mode"
+                label="紧固模式"
+                placeholder="请选择紧固模式"
                 clearable
+                required
+                @click="showTightenMode= true"
             />
+            <van-popup v-model="showTightenMode" position="bottom">
+                <van-picker
+                    value-key="name"
+                    name="work_sign"
+                    show-toolbar
+                    :columns="TightenMode"
+                    @confirm="onTightenModeConfirm"
+                    @cancel="showTightenMode= false"
+                />
+            </van-popup>
+
+
             <van-field
-                v-model="formData.device_name"
-                name="device_name"
-                label="紧固模式"
-                placeholder="请输入紧固模式"
+                v-model="formData.bolt_num"
+                name="bolt_num"
+                label="螺栓总数"
+                placeholder="请输入螺栓总数"
                 clearable
                 required
+                type="digit"
             />
+           
+            
             <van-field
-                v-model="formData.device_name"
-                name="device_name"
+                v-model="formData.bias"
+                name="bias"
                 label="偏移紧固数值"
                 placeholder="请输入偏移紧固数值"
                 clearable
+                required
+                type="number"
             />
             <van-field
-                v-model="formData.device_name"
-                name="device_name"
+                v-model="formData.torque"
+                name="torque"
                 label="扭矩"
                 placeholder="请输入扭矩"
                 clearable
                 required
+                type="number"
             />
+          
+            <van-field name="status" label="启用状态">
+                <template #input>
+                    <van-switch v-model="formData.status" size="20" active-value=1 inactive-value=-1 inactive-color="#dcdee0" />
+                </template>
+            </van-field>
             <van-field
-                v-model="formData.device_name"
-                name="device_name"
-                label="使用状态"
-                placeholder="请输入使用状态"
-                clearable
-            />
-            <van-field
-                v-model="formData.device_name"
-                name="device_name"
+                v-model="formData.info"
+                name="info"
                 label="备注"
                 placeholder="请输入备注"
                 clearable
             />
 
-            
-
+        
             <div style="margin: 6px;">
                 <van-button round block type="info" size="small" native-type="submit">新增</van-button>
             </div>
@@ -162,7 +194,7 @@
 <script>
 import Vue from 'vue';
 import wx from 'weixin-js-sdk'
-import { Form, Field, Icon, NavBar, Dialog, Button, Popup,Picker } from 'vant';
+import { Form, Field, Icon, NavBar, Dialog, Button, Popup,Picker,Switch } from 'vant';
 
 Vue.use(Form);
 Vue.use(Field);
@@ -172,6 +204,7 @@ Vue.use(Dialog);
 Vue.use(Button); 
 Vue.use(Popup);
 Vue.use(Picker);
+Vue.use(Switch);
 
 export default {
     data() {
@@ -191,7 +224,7 @@ export default {
                 bias: '',
                 tighten_mode: '',
                 torque: '',
-                status: '',
+                status: 1,
                 info:'',
             },
             imei: '',
@@ -211,15 +244,19 @@ export default {
             Work: [],
             showWork: false,
             WorkObj: '',
-          
-        
+            
+            //获取型号
+            Type: [],
+            showType: false,
+            TypeObj: '',
+
+            TightenMode:[],
+            showTightenMode:false,
+            TightenModeObj:'',
 
+          
             wind_id:'',
-            rules: {
-                imei: [
-                    { required: true, message: '请输入设备号' },
-                ]
-            }
+           
         }
     },
     created() {
@@ -236,31 +273,33 @@ export default {
          */
         onSubmit(values) {
             let postData = {
-                device_name: values.device_name,
-                imei: values.imei,
-                userType: this.userType,
-                deviceType: this.deviceType,
+                plan_number:this.formData.plan_number,
+                plan_name:this.formData.plan_name,
+                wind_id:this.$route.query.wind_id,
+                fan_model:this.fanModelObj.id,
+                parts_sign:this.PartObj.id,
+                work_sign:this.WorkObj.id,
+                boit_type_sign:this.TypeObj.id,
+                bolt_num:this.formData.bolt_num,
+                bias: this.formData.bias,
+                tighten_mode:this.TightenModeObj.id,
+                torque:this.formData.torque,
+                status:this.formData.status,
+                info:this.formData.info,
             }
 
-            if (values.username) {
-                postData.username = values.username;
-            }
-            if (values.user_no) {
-                postData.user_no = values.user_no;
-            }
-           
-            this.$http.post('userBindDevice&userid=' + this.userid + '&openid=' + this.openid, JSON.stringify(postData))
+            this.$http.post('savePlan?userid=' + this.userid + '&openid=' + this.openid, JSON.stringify(postData))
                 .then(resp => {
-                    if (!resp.data.success) {
-                        this.$notify(resp.data.message || '绑定失败');
+                    if (resp.data.code!=10000) {
+                        this.$notify(resp.data.message || '保存失败');
                         return;
                     }
                     this.$notify({
                         type: 'success',
-                        message: resp.data.message || '绑定成功',
+                        message: resp.data.message || '保存成功',
                     })
                     // 刷新列表
-                    this.$router.replace('devices');
+                   // this.$router.replace('yys_alarms');
                 })
         },
     
@@ -291,11 +330,9 @@ export default {
 
 
         },
-
         //提交风场型号
         onPartConfirm(value)
         {   
-            console.log(value);
             this.PartObj = value;
             this.formData.parts_sign = value.name;
             this.getWork();
@@ -304,6 +341,7 @@ export default {
         },
 
 
+
         //提交上传部件
         getPart() {
             let query =
@@ -335,6 +373,50 @@ export default {
             });
 
         },
+        //获取螺栓型号
+        getType()
+        {
+            let query = { type: 4};
+            this.$http.post("getParts?openid=" + this.openid, JSON.stringify(query)).then((resp) => {
+                if (resp.data.code != 10000) {
+                    this.$notify(resp.data.message)
+                    return;
+                }
+                this.Type = resp.data.data;
+                
+            });
+
+        },
+        getTightenMode()
+        { 
+            let data = [
+                {id:0,name:'顺序紧固'},
+                {id:1,name:'对角紧固'},
+                {id:2,name:'偏移紧固 '}
+
+            ];
+
+            this.TightenMode = data;
+            
+        },
+       
+        //提交
+        onTightenModeConfirm(value)
+        {
+            this.TightenModeObj = value;
+            this.formData.tighten_mode = value.name;
+            this.showTightenMode = false;
+           
+        },
+         //确认螺栓型号
+        onTypeConfirm(value)
+        {
+            this.TypeObj = value;
+            this.formData.boit_type_sign = value.name;
+            this.showType = false;
+           
+
+        },
         //确认工作位置
         onWorkConfirm(value)
         {
@@ -349,7 +431,6 @@ export default {
             this.showWork = true
         },
 
-
         //提交风场型号
         onFanModelConfirm(value) {
             this.formData.fan_model = value.name;
@@ -358,7 +439,7 @@ export default {
             this.getWork();
         },
 
-
+        
 
         //初始化数据
         initdata()
@@ -367,7 +448,9 @@ export default {
             this.formData.wind_name = this.$route.query.wind_name;
             this.wind_id = this.$route.query.wind_id; 
             this.getWindModel();
-            this.getPart()
+            this.getPart();
+            this.getType();
+            this.getTightenMode();
 
         },
 

+ 0 - 1
src/pages/kede/yys/alarms/detail.vue

@@ -62,7 +62,6 @@
     </van-cell-group>
 
 
-    
     <van-form @submit="onSubmit">
      
       <div style="margin: 16px">

+ 0 - 1
src/pages/kede/yys/alarms/index.vue

@@ -157,7 +157,6 @@ export default {
     onLoad() {
       //获取风场列表
       this.getWind();
-      
       let params = {
         page: this.page,
         limit: this.limit,

+ 10 - 4
src/pages/kede/yys/location.vue

@@ -102,8 +102,13 @@ export default {
         let map = this.initMap();
 
         map.then((result) => {
+           
+            
+           
             if(result === false){
-                this.$toast('地图初始化失败,请刷新重试');
+                
+               // this.$toast('地图初始化失败,请刷新重试');
+                
                 return;
             }
             that.getLastPositon();
@@ -302,7 +307,7 @@ export default {
                        let geolocation = new AMap.Geolocation({
                             enableHighAccuracy: true,
                             // 设置定位超时时间,默认:无穷大
-                            timeout: 10000,
+                            timeout: 5000,
                             // 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
                             buttonOffset: new AMap.Pixel(10, 20),
                             //  定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
@@ -314,12 +319,12 @@ export default {
                        });
                         map.addControl(geolocation);
                         geolocation.getCurrentPosition()
-                        console.log(AMap.Event);
+                        
                         AMap.Event.addListener(geolocation, 'complete', onComplete);
                         AMap.Event.addListener(geolocation, 'error', onError);
                         function onComplete(data) {
                             // data是具体的定位信息
-                            console.log(data)
+                            
                             if (data.position) {
                                 that.saveLocationInfo(data.position);
                             } else {
@@ -330,6 +335,7 @@ export default {
                             }
                         }
                         function onError(data) {
+                          
                             // 定位出错
                             that.$notify({
                                 type: 'warning',