浏览代码

fixed: 2021/8/30更新

Vccc6 4 年之前
父节点
当前提交
07a0c9f6b0
共有 6 个文件被更改,包括 463 次插入115 次删除
  1. 3 2
      config/index.js
  2. 34 16
      src/pages/authentication/index.vue
  3. 191 55
      src/pages/download/index.vue
  4. 79 22
      src/pages/equipment/index.vue
  5. 21 8
      src/pages/home/index.vue
  6. 135 12
      src/pages/scene/index.vue

+ 3 - 2
config/index.js

@@ -13,7 +13,8 @@ module.exports = {
     proxyTable: {
       '/api': {
         //target: 'http://192.168.0.47:7081', // 接口的域名
-        target: 'https://zfb.4dkankan.com/zfb', // 接口的域名
+        // target: 'https://zfb.4dkankan.com/zfb', // 接口的域名
+        target: 'http://192.168.0.143:7081', // 接口的域名
         // secure: false,  // 如果是https接口,需要配置这个参数
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
         pathRewrite: {
@@ -66,7 +67,7 @@ module.exports = {
      * Source Maps
      */
 
-    productionSourceMap: true,
+    productionSourceMap: false,
     // https://webpack.js.org/configuration/devtool/#production
     devtool: '#source-map',
 

+ 34 - 16
src/pages/authentication/index.vue

@@ -74,6 +74,8 @@
       title="新增企业"
       width="45%"
       :visible.sync="dialogAddCpnyVisible"
+      :show-close="false"
+      :close-on-click-modal="false"
     >
       <el-form
         :model="form"
@@ -88,10 +90,10 @@
                 show-word-limit
                 maxlength="20"
                 v-model="form.ac_name"
+                style="padding: 0 45px 0 0"
               ></el-input>
             </el-form-item>
-            <el-form-item label="所属区域">
-              <!--<el-input v-model="form.ac_belongArea"  placeholder="请以一个空格为间隔,如“XX省 XX市 XX区”" rows="2" type="textarea" resize="none"></el-input>-->
+            <el-form-item label="所属区域" prop="ac_add_area">
               <el-input v-model="form.ac_add_province" style="width: 25%"></el-input
               ><span>省</span>
               <el-input v-model="form.ac_add_city" style="width: 25%"></el-input
@@ -104,6 +106,7 @@
                 show-word-limit
                 maxlength="50"
                 v-model="form.ac_address"
+                style="padding: 0 45px 0 0"
               ></el-input>
             </el-form-item>
             <el-form-item label="企业LOGO" prop="ac_logo">
@@ -151,6 +154,7 @@
                 show-word-limit
                 maxlength="20"
                 v-model="form.ac_user"
+                style="padding: 0 45px 0 0"
               ></el-input>
             </el-form-item>
             <el-form-item label="手机号" prop="ac_phone">
@@ -159,9 +163,6 @@
             <el-form-item label="企业官网">
               <el-input
                 v-model="form.ac_website"
-                rows="2"
-                type="textarea"
-                resize="none"
               ></el-input>
             </el-form-item>
             <el-form-item label="企业资质" prop="ac_zizhi">
@@ -195,7 +196,7 @@
       </el-form>
       <div style="text-align: center" class="dialog-footer">
         <div>
-          <el-button @click="dialogAddCpnyVisible = false">取 消</el-button>
+          <el-button @click="clearAc">取 消</el-button>
           <el-button type="primary" @click="addCompany()">提 交</el-button>
         </div>
       </div>
@@ -381,15 +382,13 @@ export default {
         ac_zizhi:'',
       },
       rules: {
-        ac_name: [{ required: true, message: '企业名称不能为空', trigger:'blur' }],
-        ac_add_province: [{ required: true, message: '所属区域不能为空', trigger:'blur' }],
-        ac_add_city: [{ required: true, message: '所属区域不能为空', trigger:'blur' }],
-        ac_add_area: [{ required: true, message: '所属区域不能为空', trigger:'blur' }],
-        ac_address: [{ required: true, message: '详细地址不能为空', trigger:'blur' }],
-        ac_logo: [{ required: true, message: '企业LOGO不能为空', trigger:'blur' }],
-        ac_user: [{ required: true, message: '联系人不能为空', trigger:'blur' }],
-        ac_phone: [{ required: true, message: '手机号不能为空', trigger:'blur' }],
-        ac_zizhi: [{ required: true, message: '企业资质不能为空', trigger:'blur' }],
+        ac_name: [{ required: true ,message: '企业名称不能为空'}],
+        ac_add_area: [{ required: true ,message: '所属区域不能为空'}],
+        ac_address: [{ required: true ,message: '详细地址不能为空'}],
+        ac_logo: [{ required: true ,message: '企业LOGO不能为空'}],
+        ac_user: [{ required: true ,message: '联系人不能为空'}],
+        ac_phone: [{ required: true ,message: '手机号不能为空'}],
+        ac_zizhi: [{ required: true ,message: '企业资质不能为空'}],
       },
       // ac_name:'',
       // ac_belongArea:'',
@@ -473,7 +472,23 @@ export default {
       this.$bus.$emit('refresh', true)                    //触发当前实例上的refresh()
       this.refresh()
     },
-
+    clearAc(){
+      this.dialogAddCpnyVisible = false
+      this.form = {
+        ac_name:'',
+        ac_belongArea: '',
+        ac_add_province:'',
+        ac_add_city:'',
+        ac_add_area:'',
+        ac_address:'',
+        ac_logo:'',
+        ac_introduce:'',
+        ac_user:'',
+        ac_phone:'',
+        ac_website:'',
+        ac_zizhi:'',
+      }
+    },
     async save (id = '', state = '') {
       await this.$http({
         method: 'post',
@@ -627,6 +642,9 @@ export default {
     },
     //新增企业
     addCompany(){
+      if(!this.form.ac_name || !(this.form.ac_add_area&&this.form.ac_add_city&&this.form.ac_add_province) || !this.form.ac_address || !this.form.ac_logo || !this.form.ac_user || !this.form.ac_phone || !this.form.ac_zizhi){
+        return this.$alert('请完善信息','提示')
+      }
       let params = {
         name: this.form.ac_name,
         area: this.form.ac_add_province + '省 ' + this.form.ac_add_city + '市 ' + this.form.ac_add_area + '区',

+ 191 - 55
src/pages/download/index.vue

@@ -1,77 +1,213 @@
 <!--  -->
 <template>
-<div class='con' v-loading.fullscreen.lock="loading">
-  <div class="h-body">
-     <div class="h-header">
-          <span>场景码:</span>
-          <el-input style="margin-right:10px;" v-model="inpuKey" placeholder="请输入场景码"></el-input>
-          <el-button type="primary" @click="save">下载</el-button>
+  <div class="con" v-loading.fullscreen.lock="loading">
+    <el-dialog
+      title="场景获取"
+      :close-on-click-modal="false"
+      :visible.sync="downloadingVisible"
+      width="400px"
+    >
+      <el-form
+        :model="downloading"
+        :label-position="'right'"
+        label-width="100px"
+      >
+        <div style="padding: 0 30px">
+          <div class="add-l">
+            <el-form-item label="场景名称:">
+              <span>{{ downloading.sceneName }}</span>
+            </el-form-item>
+            <el-form-item
+              label="下载进度:"
+              prop="percent"
+              v-if="downloading.status != 1003"
+            >
+              <!-- <span style="color:#0175dc">100%</span> -->
+              <span style="color: #0175dc">{{ downloading.percent }}%</span>
+            </el-form-item>
+            <el-form-item label="状态:" prop="status">
+              <span v-if="downloading.status == 1002" style="color: #0175dc"
+                >获取成功</span
+              >
+              <span
+                v-if="downloading.status == 1000 || downloading.status == 1001"
+                style="color: #0175dc"
+                >获取中</span
+              >
+              <span v-if="downloading.status == 1003" style="color: red"
+                >获取失败</span
+              >
+              <!-- <span style="color:#0175dc">下载成功</span> -->
+            </el-form-item>
+          </div>
+        </div>
+      </el-form>
+      <div style="text-align: center" class="dialog-footer">
+        <div>
+          <el-button
+            v-if="downloading.status == 1002 || downloading.status == 1003"
+            size="small"
+            type="primary"
+            @click="downloadingVisible = false"
+            >确 定</el-button
+          >
+        </div>
+      </div>
+    </el-dialog>
+    <div class="h-body">
+      <div class="h-header">
+        <span>场景码:</span>
+        <el-input
+          style="margin-right: 10px"
+          v-model="inpuKey"
+          placeholder="请输入场景码"
+        ></el-input>
+        <el-button type="primary" @click="save">下载</el-button>
+      </div>
     </div>
   </div>
-</div>
 </template>
 
 <script>
 // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 // 例如:import 《组件名称》 from '《组件路径》';
-import vcenter from '@/components/vcenter'
+import vcenter from "@/components/vcenter";
 
 export default {
   // import引入的组件需要注入到对象中才能使用
   components: {
-    vcenter
+    vcenter,
   },
-  data () {
+  data() {
     // 这里存放数据
     return {
-      inpuKey: '',
-      loading: false
-    }
+      inpuKey: "",
+      loading: false,
+      downloading: {
+        sceneName: "",
+        status: "",
+        percent: "",
+      },
+      downloadingVisible: false,
+    };
   },
   // 监听属性 类似于data概念
   computed: {
-    token () {
-      return window.localStorage.getItem('zfb_token')
-    }
+    token() {
+      return window.localStorage.getItem("zfb_token");
+    },
   },
   // 监控data中的数据变化
   watch: {
-    activeTagId () {
-      this.refresh()
-    }
+    activeTagId() {
+      this.refresh();
+    },
   },
   // 方法集合
   methods: {
-
-    save () {
+    save() {
       if (!this.inpuKey) {
         return this.$notify.error({
-          title: '错误',
-          message: '请输入场景码'
-        })
+          title: "错误",
+          message: "请输入场景码",
+        });
         // https://admin.zhifangbao.com/scene/downloadSceneData?sceneNum=zhZGWVrnO4
       }
-      this.loading = true
+      this.loading = true;
       this.$http({
-        method: 'get',
-        url: `/scene/downloadSceneData?sceneNum=${this.inpuKey}`,
-        headers: {
-          token: this.token
-        }
-      }).then(res => {
-        this.loading = false
-        if (res.code === 200) {
-          window.open(`/${res.message}`, '_blank')
-        } else {
-          return this.$alert(res.message, '提示', {
-            confirmButtonText: '确定'
-          })
-        }
-      })
-    }
-  }
-
-}
+          method: 'get',
+          url: `/scene/downloadSceneData?sceneNum=${this.inpuKey}`,
+          headers:{
+            token: window.localStorage.getItem('zfb_token')
+          }
+        }).then(res => {
+          this.loading = false
+          if(res.code === 200){
+            //链接存在时直接下载
+            if(res.message.indexOf('zip') != -1 && res.message.indexOf('http') == -1){
+              window.open(`/zfb/${res.message}`,'_blank')
+            }
+            //如果是完整的链接则直接下载
+            else if(res.message.indexOf('http') != -1){
+              window.open(res.message , '_blank')
+            }
+            //设置定时器实时获取下载链接的status和percent
+            else if(res.message == 'success'){
+              // setTimeout(()=>{
+              //   var get_process = setInterval(()=>{
+              //     this.getProcess(row , get_process)
+              //   },2000)
+              // },3000)
+              var get_process = setInterval(()=>{
+                this.getProcess(this.inputKey , get_process)
+              },2000)
+            }
+            else{
+              return this.$alert(res.error, '提示', {
+                confirmButtonText: '确定'
+              })
+            }
+          }
+          else if(res.code === 400){
+            return this.$alert(res.message, '提示', {
+              confirmButtonText: '确定'
+            })
+          }
+          else{
+            return this.$alert(res.error, '提示', {
+              confirmButtonText: '确定'
+            })
+          }
+        })
+      // this.$http({
+      //   method: "get",
+      //   url: `/scene/downloadSceneData?sceneNum=${this.inpuKey}`,
+      //   headers: {
+      //     token: this.token,
+      //   },
+      // }).then((res) => {
+      //   this.loading = false;
+      //   if (res.code === 200) {
+      //     window.open(`/${res.message}`, "_blank");
+      //   } else {
+      //     return this.$alert(res.message, "提示", {
+      //       confirmButtonText: "确定",
+      //     });
+      //   }
+      // });
+    },
+    getProcess(inputKey , get_process){
+        // let params = {
+        //   sceneNum: row.num
+        // }
+        this.$http({
+          method: 'get',
+          url: `/scene/getDownloadProcess?sceneNum=${inputKey}`,
+          // data: params,
+          headers: {
+            token: window.localStorage.getItem('zfb_token')
+          }
+        }).then(res => {
+          if(res.code === 200){
+            this.downloadingVisible = true
+            this.downloading.status = res.message.status
+            this.downloading.percent = res.message.percent
+            if(this.downloading.status == 1002 || this.downloading.status == 1003){
+                clearInterval(get_process)
+                if(res.message.url && this.downloading.status == 1002){
+                  window.open(res.message.url,'_blank')
+                }
+            }
+          }
+          else{
+            return this.$alert(res.error, '提示', {
+                confirmButtonText: '确定'
+              })
+          }
+        })
+      },
+  },
+};
 </script>
 
 <style lang="scss" scoped>
@@ -91,15 +227,15 @@ export default {
         border-radius: 6px;
       }
 
-      &:hover{
-          border-color: #409eff;
-          .v-mask{
-            display: inline-block;
-            width: 178px;
-            height: 128px;
-            border-radius: 6px;
-            background: rgba(0,0,0,0.5);
-          }
+      &:hover {
+        border-color: #409eff;
+        .v-mask {
+          display: inline-block;
+          width: 178px;
+          height: 128px;
+          border-radius: 6px;
+          background: rgba(0, 0, 0, 0.5);
+        }
       }
 
       .el-icon-plus {
@@ -116,12 +252,12 @@ export default {
     box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
     border-radius: 3px;
     background-color: #fff;
-    .h-header{
+    .h-header {
       width: 50%;
       display: flex;
       justify-content: flex-start;
       align-items: center;
-      >span{
+      > span {
         display: inline-block;
         min-width: 70px;
       }

+ 79 - 22
src/pages/equipment/index.vue

@@ -1,6 +1,6 @@
 <template slot-scope="scope">
   <div class="con" v-loading.fullscreen.lock="loading">
-    <el-dialog width="470px" title="添加相机" :visible.sync="cameraVisible">
+    <el-dialog width="470px" title="添加相机" :visible.sync="cameraVisible" :show-close="false" :close-on-click-modal="false">
       <el-form label-width="80px" :rules="rules" :model="ruleForm">
         <el-form-item label="出库类型" prop="own">
           <el-select v-model="ruleForm.own" placeholder="请选择出库类型">
@@ -10,10 +10,10 @@
             <el-option label="其他" value="3"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="相机类型" prop="type">
-          <el-select v-model="ruleForm.type" placeholder="请选择相机类型">
-            <el-option label="四维看看Pro八目相机" value="1"></el-option>
-            <el-option label="四维看看Lite双目相机" value="0"></el-option>
+        <el-form-item label="相机类型" prop="cameraType">
+          <el-select v-model="ruleForm.cameraType" placeholder="请选择相机类型">
+            <el-option label="四维看看Pro八目相机" value="4"></el-option>
+            <el-option label="四维看看Lite双目相机" value="1"></el-option>
             <el-option label="四维看看双目转台相机" value="9"></el-option>
             <el-option label="四维看看激光相机" value="10"></el-option>
             <el-option label="第三方相机" value="6"></el-option>
@@ -22,15 +22,15 @@
         <el-form-item label="设备ID" prop="childName">
           <el-input v-model="ruleForm.childName"></el-input>
         </el-form-item>
-        <el-form-item label="wifi名称" prop="wifi">
-          <el-input v-model="ruleForm.wifi"></el-input>
+        <el-form-item label="wifi名称" prop="wifiName">
+          <el-input v-model="ruleForm.wifiName"></el-input>
         </el-form-item>
         <el-form-item label="物理地址" prop="address">
           <el-input v-model="ruleForm.address"></el-input>
         </el-form-item>
         <el-form-item
-          v-if="ruleForm.type != '' && ruleForm.type != 6"
-          label="* sn码"
+          v-if="ruleForm.cameraType != '' && ruleForm.cameraType != 6"
+          label="sn码" prop="snCode"
         >
           <el-input v-model="ruleForm.snCode"></el-input>
         </el-form-item>
@@ -53,7 +53,7 @@
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button @click="cameraVisible = false">取 消</el-button>
+        <el-button @click="clearData">取 消</el-button>
         <el-button type="primary" @click="addCamera">确 定</el-button>
       </div>
     </el-dialog>
@@ -130,9 +130,10 @@ export default {
       tableHeader: [
         { name: "childName", label: "设备ID" },
         { name: "userName", label: "手机号(用户名)" },
-        { name: "goodsName", label: "设备类型" },
+        // { name: "goodsName", label: "设备类型" },
+        { name: "cameraType", label: "设备类型" },
         { name: "snCode", label: "sn码" },
-        { name: "wifi", label: "wifi"},
+        { name: "wifiName", label: "wifi"},
         { name: "activatedTime", label: "激活时间" },
         { name: "own", label: "出货类型" },
         { name: "companyName", label: "客户名称" },
@@ -141,11 +142,11 @@ export default {
       // ShebeiVisible: false,
       cameraVisible: false,
       ruleForm: {
-        wifi: "",
+        wifiName: "",
         address: "",
         // initPoint: "",
         balance:"",
-        type: [],
+        cameraType: [],
         own: [],
         snCode: "",
         orderSn: "",
@@ -153,10 +154,11 @@ export default {
         childName:""
       },
       rules:{
+        snCode: [{ required:true ,message:'sn码不能为空'}],
         own: [{required: true, message:'出库类型不能为空'}],
-        type: [{required: true, message:'相机类型不能为空'}],
+        cameraType: [{required: true, message:'相机类型不能为空'}],
         childName: [{required: true, message:'设备ID不能为空', trigger: 'blur'}],
-        wifi: [{required: true, message:'wifi名称不能为空', trigger: 'blur'}],
+        wifiName: [{required: true, message:'wifi名称不能为空', trigger: 'blur'}],
         address: [{required: true, message:'物理地址不能为空', trigger: 'blur'}],
         balance: [{required: true, message:'初始点数不能为空', trigger: 'blur'}],
         orderSn: [{required: true, message:'订单号不能为空', trigger: 'blur'}],
@@ -201,24 +203,29 @@ export default {
           pageSize: this.size,
         },
       }).then((res) => {
+        for(let i=0;i<res.message.list.length;i++){
+          res.message.list[i].activatedTime = this.$base.dateFormat('yyyy-MM-dd hh:mm',new Date(res.message.list[i].activatedTime))
+          res.message.list[i].own = this.ownToName(res.message.list[i].own)
+          res.message.list[i].cameraType = this.typeToName(res.message.list[i].cameraType)
+        }
         this.tableData = res.message.list;
         this.total = res.message.total;
-        // this.currentPage = res.message.pageNum
+        this.currentPage = res.message.pageNum
       });
     },
     addCamera() {
-      if (this.ruleForm.type != 6 && this.ruleForm.snCode == "") {
+      if (this.ruleForm.cameraType != 6 && this.ruleForm.snCode == "") {
         this.$alert("sn码不能为空!", "提示", {
           confirmButtonText: "确定",
         });
         return;
       }
       let params = {
-        wifi: this.ruleForm.wifi,
+        wifiName: this.ruleForm.wifiName,
         address: this.ruleForm.address,
         // initPoint: this.ruleForm.initPoint,
         balance: this.ruleForm.balance,
-        type: this.ruleForm.type,
+        cameraType: this.ruleForm.cameraType,
         own: this.ruleForm.own,
         snCode: this.ruleForm.snCode,
         orderSn: this.ruleForm.orderSn,
@@ -241,11 +248,11 @@ export default {
             callback: (action) => {
               this.getCompanyList();
               this.ruleForm = {
-                wifi: "",
+                wifiName: "",
                 address: "",
                 // initPoint: "",
                 balance:"",
-                type: [],
+                cameraType: [],
                 own: [],
                 snCode: "",
                 orderSn: "",
@@ -264,6 +271,56 @@ export default {
         }
       });
     },
+    clearData(){
+      this.cameraVisible = false
+      this.ruleForm = {
+        wifiName: "",
+        address: "",
+        // initPoint: "",
+        balance:"",
+        cameraType: [],
+        own: [],
+        snCode: "",
+        orderSn: "",
+        companyId: "",
+        childName:""
+      }
+    },
+    ownToName(own){
+      switch(own){
+        case 0:
+          return "正常销售"
+          break
+        case 2:
+          return "礼品赠送"
+          break
+        case 1:
+          return "员工自用"
+          break
+        case 3:
+          return "其它"
+          break
+      }
+    },
+    typeToName(cameraType){
+      switch(cameraType){
+        case 4:
+          return "四维看看Pro八目相机"
+          break
+        case 1:
+          return "四维看看Lite双目相机"
+          break
+        case 9:
+          return "四维看看双目转台相机"
+          break
+        case 10:
+          return "四维看看激光相机"
+          break
+        case 6:
+          return "第三方相机"
+          break
+      }
+    },
     async getCompanyList() {
       let result = await this.$http.post("/company/listAll");
       this.companyList = result.message;

+ 21 - 8
src/pages/home/index.vue

@@ -1,7 +1,7 @@
 <!--  -->
 <template>
   <div class="con" v-loading.fullscreen.lock="loading">
-    <el-dialog title="设备充值" width="30%" :visible.sync="chargeVisible">
+    <el-dialog title="设备充值" width="30%" :visible.sync="chargeVisible" :close-on-click-modal="false">
       <el-form :model="form_charge" :label-position="'right'" :label-width="formLabelWidth">
         <el-form-item label="充值账号:">
           <span>{{form_charge.userName}}</span>
@@ -23,8 +23,8 @@
         <el-button type="primary" @click="save_reCharge()">确 定</el-button>
       </div>
     </el-dialog>
-    <el-dialog title="子账号管理" width="30%" :visible.sync="dialogFormVisible">
-      <el-dialog title="新增子账号" :visible.sync="addZiVisible" append-to-body width="20%">
+    <el-dialog title="子账号管理" width="30%" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
+      <el-dialog title="新增子账号" :visible.sync="addZiVisible" append-to-body width="20%" :close-on-click-modal="false" :show-close="false">
         <el-form  style="padding-bottom:30px;">
           <el-form-item label="姓名">
             <el-input v-model="addZi.nickName" placeholder="请输入姓名"></el-input>
@@ -34,11 +34,11 @@
           </el-form-item>
         </el-form>
         <div style="text-align:center" class="dialog-footer">
-          <el-button @click="addZiVisible = false">取 消</el-button>
+          <el-button @click="addZiVisible = false;addZi = {id:'',nickName:'',phone:''}">取 消</el-button>
           <el-button type="primary" @click="addZi_save">保 存</el-button>
         </div>
       </el-dialog>
-      <el-dialog title="修改子账号" :visible.sync="changeZiVisible" append-to-body width="20%">
+      <el-dialog title="修改子账号" :visible.sync="changeZiVisible" append-to-body width="20%" :close-on-click-modal="false">
         <el-form style="padding-bottom:30px;">
           <el-form-item label="姓名">
             <el-input v-model="changeZi.nickName" placeholder="请输入姓名"></el-input>
@@ -155,7 +155,7 @@
       </div>
     </el-dialog>
 
-    <el-dialog width="700px" title="新增设备" :visible.sync="ShebeiVisible">
+    <el-dialog width="700px" title="新增设备" :visible.sync="ShebeiVisible" :show-close="false" :close-on-click-modal="false">
           <el-form label-width="80px">
             <el-form-item label="企业名称:">
               <span>{{c_userName}}</span>
@@ -186,12 +186,12 @@
             
           </el-form>
           <div style="text-align:center" class="dialog-footer">
-            <el-button @click="ShebeiVisible = false">取 消</el-button>
+            <el-button @click="clearDevies">取 消</el-button>
             <el-button type="primary" @click="save(c_userName)">保 存</el-button>
           </div>
         </el-dialog>
 
-    <el-dialog title="设备查看" width="30%" :visible.sync="deviceFormVisible">
+    <el-dialog title="设备查看" width="50%" :visible.sync="deviceFormVisible">
       <el-form :model="form_device" :label-position="'left'" :label-width="formLabelWidth">
         <el-form-item label="企业账号:">
           <span>{{form_device.d_userName}}</span>
@@ -895,6 +895,7 @@ export default {
           hasCheck: false
         }
       ]
+      this.ShebeiVisible = false
       this.dialogFormVisible = false
       this.chargeVisible = false
       this.recharge_id = ''
@@ -905,6 +906,17 @@ export default {
       }
       this.refresh()
     },
+    clearDevies(){
+      this.num = 0
+      this.addDevies = [
+        {
+          value: '',
+          isAvailable: false,
+          hasCheck: false
+        }
+      ]
+      this.ShebeiVisible = false
+    },
     //将addDevies[]里value为true的对象push进temp[]中,返回用 ; 间隔元素的temp[]
     canIsave () {
       let temp = []
@@ -969,6 +981,7 @@ export default {
           } else {
             item.isAvailable = false
             this.errMsg = '该ID不可用'
+
           }
           item.hasCheck = true
         })

+ 135 - 12
src/pages/scene/index.vue

@@ -1,5 +1,31 @@
 <template>
     <div class="con" v-loading.fullscreen.lock="loading">
+      <el-dialog title="场景获取" :close-on-click-modal="false" :visible.sync="downloadingVisible" width="400px">
+        <el-form :model="downloading" :label-position="'right'" label-width="100px">
+          <div style="padding: 0 30px">
+            <div class="add-l">
+              <el-form-item label="场景名称:">
+                <span>{{downloading.sceneName}}</span>
+              </el-form-item>
+              <el-form-item label="下载进度:" prop="percent" v-if="downloading.status != 1003">
+                <!-- <span style="color:#0175dc">100%</span> -->
+                <span style="color:#0175dc">{{downloading.percent}}%</span>
+              </el-form-item>
+              <el-form-item label="状态:" prop="status">
+                <span v-if="downloading.status == 1002" style="color:#0175dc">获取成功</span>
+                <span v-if="downloading.status == 1000 || downloading.status == 1001" style="color:#0175dc">获取中</span>
+                <span v-if="downloading.status == 1003" style="color:red">获取失败</span>
+                <!-- <span style="color:#0175dc">下载成功</span> -->
+              </el-form-item>
+            </div>
+          </div>
+        </el-form>
+        <div style="text-align: center" class="dialog-footer">
+          <div>
+            <el-button v-if="downloading.status == 1002 || downloading.status == 1003" size="small" type="primary" @click="downloadingVisible = false">确 定</el-button>
+          </div>
+        </div>
+      </el-dialog>
         <div class="h-header">
             <vcenter>
                 <div class="h-input">
@@ -36,7 +62,7 @@
                 </el-table-column>
                 <el-table-column label="操作">
                   <template slot-scope="scope">
-                  <span @click="S_download(scope.row)" style="cursor:pointer;color:#0175dc;">下载场景</span>
+                  <span @click="_S_download(scope.row)" style="cursor:pointer;color:#0175dc;">下载场景</span>
                   </template>
                 </el-table-column>
             </el-table>
@@ -57,6 +83,7 @@
 
 <script>
 import vcenter from '@/components/vcenter'
+import Vue from 'vue'
 export default {
     components:{vcenter},
     data(){
@@ -76,39 +103,133 @@ export default {
             tableData:[],
             loading: false,
             type:'',
-
+            downloading:{
+              sceneName:'',
+              status:'',
+              percent:''
+            },
+            downloadingVisible: false
         }
     },
     methods:{
-      S_download(row){
+      // S_download(row){
+      //   let webSite = row.num
+      //   /*let i = webSite.indexOf('=')
+      //   let sceneCode = webSite.slice(i+1)*/
+      //   this.loading = true
+      //   this.$http({
+      //     method: 'get',
+      //     url:`/scene/downloadSceneData?sceneNum=${webSite}`,
+      //     headers:{
+      //       token: window.localStorage.getItem('zfb_token')
+      //     }
+      //   }).then(res =>{
+      //     this.loading = false
+      //     if (res.code === 200){
+      //       window.open(`/${res.message}`, '_blank')
+      //     } else {
+      //       return this.$alert(res.message, '提示', {
+      //         confirmButtonText: '确定'
+      //       })
+      //     }
+      //   })
+      // },
+      // sleep(millisecond){
+      //   return new Promise(resolve => {
+      //     setTimeout(()=>{
+      //       resolve()
+      //     },millisecond)
+      //   })
+      // },
+      _S_download(row){
         let webSite = row.num
-        /*let i = webSite.indexOf('=')
-        let sceneCode = webSite.slice(i+1)*/
+        this.downloading.sceneName = row.sceneName
         this.loading = true
         this.$http({
           method: 'get',
-          url:`/scene/downloadSceneData?sceneNum=${webSite}`,
+          url: `/scene/downloadSceneData?sceneNum=${webSite}`,
           headers:{
             token: window.localStorage.getItem('zfb_token')
           }
-        }).then(res =>{
+        }).then(res => {
           this.loading = false
-          if (res.code === 200){
-            window.open(`/${res.message}`, '_blank')
-          } else {
+          if(res.code === 200){
+            //链接存在时直接下载
+            if(res.message.indexOf('zip') != -1 && res.message.indexOf('http') == -1){
+              window.open(`/zfb/${res.message}`,'_blank')
+            }
+            //如果是完整的链接则直接下载
+            else if(res.message.indexOf('http') != -1){
+              window.open(res.message , '_blank')
+            }
+            //设置定时器实时获取下载链接的status和percent
+            else if(res.message == 'success'){
+              // setTimeout(()=>{
+              //   var get_process = setInterval(()=>{
+              //     this.getProcess(row , get_process)
+              //   },2000)
+              // },3000)
+              var get_process = setInterval(()=>{
+                this.getProcess(row , get_process)
+              },2000)
+            }
+            else{
+              return this.$alert(res.error, '提示', {
+                confirmButtonText: '确定'
+              })
+            }
+          }
+          else if(res.code === 400){
             return this.$alert(res.message, '提示', {
               confirmButtonText: '确定'
             })
           }
+          else{
+            return this.$alert(res.error, '提示', {
+              confirmButtonText: '确定'
+            })
+          }
+        })
+      },
+      getProcess(row , get_process){
+        // let params = {
+        //   sceneNum: row.num
+        // }
+        this.$http({
+          method: 'get',
+          url: `/scene/getDownloadProcess?sceneNum=${row.num}`,
+          // data: params,
+          headers: {
+            token: window.localStorage.getItem('zfb_token')
+          }
+        }).then(res => {
+          if(res.code === 200){
+            this.downloadingVisible = true
+            this.downloading.status = res.message.status
+            this.downloading.percent = res.message.percent
+            if(this.downloading.status == 1002 || this.downloading.status == 1003){
+                clearInterval(get_process)
+                if(res.message.url && this.downloading.status == 1002){
+                  window.open(res.message.url,'_blank')
+                }
+            }
+          }
+          else{
+            return this.$alert(res.error, '提示', {
+                confirmButtonText: '确定'
+              })
+          }
         })
       },
         handleSizeChange(val){
             console.log(`每页 ${val} 条`)
         },
         handleCurrentChange(val){
+            // this.loading = true
             console.log(`当前页: ${val}`)
         },
         async getData () {
+           this.loading = true
           let params = {
             companyName: this.CompanyName || '',
             childName: this.ShebeiID || '',
@@ -143,11 +264,13 @@ export default {
 
           this.total = result.message.total
           this.currentPage = result.message.pageNum
+
+          this.loading = false
         },
         refresh () {
-          this.loading = true
+          // this.loading = true
           this.getData()
-          this.loading = false
+          // this.loading = false
         },
         search(){
           this.currentPage === 1 ? this.refresh() : this.currentPage = 1