管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-04-03 786b2ae462000deb67669f614fc4ba6fe63149c5
src/components/MapView/mapMenuPop.vue
@@ -144,6 +144,7 @@
  decr,
  encr,
  dataLib_selectDepsByIds,
  dataLib_selectDbOverflowDep
} from "../../api/api.js"
import { getToken } from "@/utils/auth"
import $ from "jquery"
@@ -232,6 +233,7 @@
      // this.dialogInsertVisible = false
      // this.dialogVisible = true
      this.codeForm = res;
      this.download();
    },
@@ -254,29 +256,105 @@
      this.dialogInsertVisible = false
    },
    async getDownloadDep() {
      var std = []
      this.$bus.$emit("setDialogInsertVisible", true)
      // var std = []
      // for (var i in this.option) {
      //   std.push(this.option[i].entity)
      // }
      // var obj = {
      //   entities: std,
      //   wkt: this.listdata.wkt,
      // }
      // const data = await dataQuery_selectDbOverflowDep(JSON.stringify(obj))
      // if (data.code != 200) {
      //   this.$message.error("数据请求失败")
      //   return
      // }
      // if (data.result.length == 0 || data.result == null) {
      //   this.insertFlag = 1
      //   // this.dialogVisible = true
      //
      // } else {
      //   this.insertFlag = 2
      //   var std = []
      //   this.insertOption.ids = data.result
      //   var val = ""
      //   for (var i in data.result) {
      //     if (val == "") {
      //       val += "codes=" + data.result[i]
      //     } else {
      //       val += "&codes=" + data.result[i]
      //     }
      //     std.push({
      //       name: data.result[i],
      //     })
      //   }
      //   const data1 = await dataLib_selectDepsByIds(val)
      //   this.ruleForm.depid = data1.result
      //   this.ruleForm.depname = std
      //   this.ruleForm.wkt = decr(this.listdata.wkt)
      //   this.ruleForm.tabs = this.option
      //   // this.dialogInsertVisible = true
      //   this.$bus.$emit("setDialogInsertVisible", this.ruleForm)
      // }
    },
    async signGetPublicKey() {
      const res = await sign_getPublicKey()
      if (res && res.code == 200) {
        window.encrypt = new JSEncrypt()
        encrypt.setPublicKey(res.result)
      }
    },
    async download() {
      if (this.codeForm.password == "") return
      var entities = [];
      for (var i in this.option) {
        std.push(this.option[i].entity)
        entities.push(this.option[i].entity)
      }
      var obj = {
        entities: std,
        pwd: encrypt.encrypt(this.codeForm.password),
        entities: entities,
        wkt: this.listdata.wkt,
        filter: null,
        ids: null,
        depcode: null,
        dirs: null
      }
      const data = await dataQuery_selectDbOverflowDep(JSON.stringify(obj))
      const data = await dataLib_selectDbOverflowDep(obj)
      if (data.code != 200) {
        this.$message.error("数据请求失败")
        return
      }
      if (data.result.length == 0 || data.result == null) {
        this.insertFlag = 1
        // this.dialogVisible = true
        this.$bus.$emit("setDialogInsertVisible", true)
      if (data.result.length == 0) {
        var that = this;
        $.ajax({
          url: BASE_URL + "/dataLib/downloadDbData?token=" + getToken(),
          type: "POST",
          data: JSON.stringify(obj),
          dataType: 'json', // html、json、jsonp、script、text
          contentType: "application/json", // "application/x-www-form-urlencoded"
          success: (data) => {
            if (data.code == 200) {
              if (data.result) {
                that.selectDownloadFile(data.result, obj.pwd)
              }
            }
          },
          error: function (e) {
          }
        });
      } else {
        this.insertFlag = 2
        var std = []
        this.insertOption.ids = data.result
        var val = ""
        var std = [];
        for (var i in data.result) {
          if (val == "") {
            val += "codes=" + data.result[i]
@@ -289,78 +367,94 @@
          })
        }
        const data1 = await dataLib_selectDepsByIds(val)
        this.ruleForm.depid = data1.result
        this.ruleForm.depname = std
        this.ruleForm.wkt = decr(this.listdata.wkt)
        this.ruleForm.tabs = this.option
        // this.dialogInsertVisible = true
        this.$bus.$emit("setDialogInsertVisible", this.ruleForm)
      }
    },
    async signGetPublicKey() {
      const res = await sign_getPublicKey()
      if (res && res.code == 200) {
        window.encrypt = new JSEncrypt()
        encrypt.setPublicKey(res.result)
      }
    },
    async download() {
      if (this.codeForm.password == "") return
      if (this.insertFlag == 1) {
        var obj = {
          pwd: encrypt.encrypt(this.codeForm.password),
          entities: [],
          wkt: this.listdata.wkt,
        }
        for (var i in this.option) {
          obj.entities.push(this.option[i].entity)
        }
        var token = getToken()
        var that = this
        $.ajax(BASE_URL + "/dataLib/downloadDbReq?token=" + token, {
          type: "post",
          data: JSON.stringify(obj),
          async: true,
          cache: false,
          processData: false,
          contentType: false,
          success: res => {
            if (res.code != 200) {
              return
            }
            this.selectDownloadFile(res.result, obj.pwd)
          },
        })
      } else if (this.insertFlag == 2) {
        var std = []
        var std1 = []
        for (var i in this.option) {
          std.push(this.option[i].tabDesc)
          std1.push(this.option[i].entity)
        }
        var obj = {
          depcodes: this.insertOption.ids,
          pwd: encr(this.codeForm.password),
          tabs: std,
          entities: std1,
          wkt: this.listdata.wkt,
          descr: this.ruleForm.descr,
        }
        const data1 = await apply_insertApply(JSON.stringify(obj))
        if (data1.code != 200) {
          this.$message.error("数据申请失败")
          return
        }
        this.$message({
          message: "数据申请成功",
          type: "success",
        })
      // if (this.insertFlag == 1) {
        this.closeDown()
      }
      //   for (var i in this.option) {
      //     obj.entities.push(this.option[i].entity)
      //   }
      //   var token = getToken()
      //   var that = this
      //   $.ajax(BASE_URL + "/dataLib/downloadDbReq?token=" + token, {
      //     type: "post",
      //     data: JSON.stringify(obj),
      //     async: true,
      //     cache: false,
      //     processData: false,
      //     contentType: false,
      //     success: res => {
      //       if (res.code != 200) {
      //         return
      //       }
      //       this.selectDownloadFile(res.result, obj.pwd)
      //     },
      //   })
      // } else if (this.insertFlag == 2) {
      //   var std = []
      //   var std1 = []
      //   for (var i in this.option) {
      //     std.push(this.option[i].tabDesc)
      //     std1.push(this.option[i].entity)
      //   }
      //   var obj = {
      //     depcodes: this.insertOption.ids,
      //     pwd: encr(this.codeForm.password),
      //     tabs: std,
      //     entities: std1,
      //     wkt: this.listdata.wkt,
      //     descr: this.ruleForm.descr,
      //   }
      //   const data1 = await apply_insertApply(JSON.stringify(obj))
      //   this.closeDown()
      // }
    },
    async getInsertApply(res) {
      var entities = [];
      var tabs = [];
      for (var i in this.option) {
        entities.push(this.option[i].entity)
        tabs.push(this.option[i].tabDesc)
      }
      var std = [];
      for (var i in this.ruleForm.depname) {
        std.push(this.ruleForm.depname[i].name)
      }
      var obj = {
        pwd: encr(this.codeForm.password),
        entities: entities,
        wkt: this.listdata.wkt,
        filter: null,
        ids: null,
        depcode: null,
        dirs: null,
        depcodes: std,
        descr: res.descr,
        tabs: tabs
      }
      const data = await apply_insertApply(JSON.stringify(obj))
      if (data.code != 200) {
        this.$message.error("数据申请失败")
        return
      }
      this.$message({
        message: "数据申请成功",
        type: "success",
      })
    },
    async selectDownloadFile(rsid, rspwd) {
      var downObj = {
        guid: rsid,
@@ -834,6 +928,9 @@
    this.$bus.$on("setInsertDown", res => {
      this.getInsertDown(res)
    })
    this.$bus.$on("setInsertApply", res => {
      this.getInsertApply(res)
    })
  },
  destroyed() {
    this.$store.state.propertiesFlag = null