ZZJ
2021-12-20 45a084372cfd5aead36fa5944edabc722b2234d8
Merge branch 'master' of http://192.168.5.5:10010/r/web/vue-smart-ai
2个文件已修改
223 ■■■■ 已修改文件
src/Pool/TreeData.ts 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/licence/index.vue 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Pool/TreeData.ts
@@ -9,7 +9,7 @@
  refreshGB28181Tree,
  updateCameraArea,
  getCameraBaseImage
} from '@/api/area'
} from "@/api/area"
export default class TreeDataPool {
  public openeds: Array<boolean>
@@ -30,7 +30,7 @@
  public readonly: boolean
  public gbReadonly: boolean
  public multiple: boolean
  public searchFrom: string = ''
  public searchFrom: string = ""
  public showTreeBox: boolean
  public selectedNodes: Array<string>
  public selectedNode: any
@@ -73,11 +73,11 @@
    this.treeDataPure = []
    this.gb28181DataPure = []
    this.clusterDataPure = []
    this.videoArr = ['']
    this.videoArr = [""]
    this.searchCamType = 0
    this.searchInput = ''
    this.activeVideoIndex = ''
    this.activeVideoId = ''
    this.searchInput = ""
    this.activeVideoIndex = ""
    this.activeVideoId = ""
    this.activeForceChoose = false
    this.showTreeBox = true
    this.readonly = true
@@ -85,15 +85,15 @@
    this.multiple = false
    this.selectedNodes = []
    this.selectedNode = {}
    this.treeType = ''
    this.treeType = ""
    this.foldNodeList = {}
    this.treeActiveName = 'camera'
    this.treeActiveName = "camera"
    this.searchLocalType = 0
    //1:暂停状态;2:等待状态;3:置灰
    this.btnStaus = '3'
    this.ctrlCameraId = ''
    this.ctrlCameraName = ''
    this.btnStaus = "3"
    this.ctrlCameraId = ""
    this.ctrlCameraName = ""
    this.zTree = false
    this.checkedTreeNode = []
    this.gb28181CheckedCount = 0
@@ -117,7 +117,7 @@
    }
    let _selected = this.selectedNodes
    function nodeFilter(node: any) {
      if (node.type === '4' && node.selected) {
      if (node.type === "4" && node.selected) {
        _selected.push(node.id)
      }
      if (node.children) {
@@ -128,11 +128,11 @@
    }
    if (this.selectedNode.cameraType === 0) {
      //摄像机树
      if (this.treeActiveName == 'camera') {
      if (this.treeActiveName == "camera") {
        this.treeData.forEach((n: any) => {
          nodeFilter(n)
        })
      } else if (this.treeActiveName == 'cluster') {
      } else if (this.treeActiveName == "cluster") {
        //集群树
        this.clusterData.forEach((n: any) => {
          nodeFilter(n)
@@ -160,7 +160,7 @@
    }
    function nodeFilter(node: any) {
      if (node.type === '4' && (node.selected || node.checked)) {
      if (node.type === "4" && (node.selected || node.checked)) {
        _this.selectedNodes.push(node.id)
      }
      if (node.children) {
@@ -232,7 +232,7 @@
  }
  getParent(id: string, isGB: boolean): string {
    let parent = '0'
    let parent = "0"
    function nodeFilter(node: Array<any>): any {
      for (let i = 0; i < node.length; i++) {
@@ -268,10 +268,10 @@
  }
  cleanTree(tree) {
    if (tree === 'localTree') {
    if (tree === "localTree") {
      this.treeData = JSON.parse(JSON.stringify(this.treeDataPure))
    }
    if (tree === 'gb28182Tree') {
    if (tree === "gb28182Tree") {
      this.gb28181Data = JSON.parse(JSON.stringify(this.gb28181DataPure))
    }
  }
@@ -280,7 +280,7 @@
    if (!node) {
      return
    }
    node.forEach(n => {
    node.forEach((n) => {
      // vue-js-tree 默认展开,控制部分折叠. z-tree 默认折叠, 控制部分展开
      if (this.foldNodeList[n.id]) {
        if (this.zTree) {
@@ -299,11 +299,11 @@
    if (!node) {
      return
    }
    node.forEach(n => {
    node.forEach((n) => {
      if (n.children && n.children.length > 0) {
        this.setDropDisable(n.children)
      } else {
        if (n.type === '4') {
        if (n.type === "4") {
          n.dropDisabled = true
        }
      }
@@ -314,7 +314,10 @@
    if (!node) {
      return
    }
    node.sort(function (obj1: any, obj2: any) {
    node.sort(function(obj1: any, obj2: any) {
      if (obj1.type == "menu") {
        return -1
      }
      var val1 = obj1.name
      var val2 = obj2.name
      if (val1 < val2) {
@@ -326,12 +329,17 @@
      }
    })
    node.forEach(n => {
    node.forEach((n) => {
      if (n.children && n.children.length > 0) {
        if (this.zTree) {
          n.open = true
        }
        this.sortTreeData(n.children)
      } else {
        if (n.type == "menu" && this.zTree) {
          n.isParent = true
          console.log(n)
        }
      }
    })
  }
@@ -342,7 +350,7 @@
      cameraName: this.searchInput
      //isPlatform: 1
    }
    if (this.searchFrom == 'cluster') {
    if (this.searchFrom == "cluster") {
      params.isPlatform = 1
    }
    const rsp: any = await getLocalCameraTree(params)
@@ -440,20 +448,20 @@
  getAllChildrenNodes(treeNode, arr) {
    for (var i = 0; i < treeNode.length; i++) {
      var sonList = treeNode[i].children;
      var sonList = treeNode[i].children
      if (!sonList) {
        if (treeNode[i].type == "camera") {
          arr.push(treeNode[i]);
          arr.push(treeNode[i])
          if (treeNode[i].checked) {
            this.gb28181CheckedCount += 1;
            this.gb28181CheckedCount += 1
          }
        }
      } else {
        this.getAllChildrenNodes(sonList, arr);
        this.getAllChildrenNodes(sonList, arr)
      }
    }
    return arr;
    return arr
  }
  countChildrenNodes(treeNode) {
    let arry = []
@@ -481,15 +489,15 @@
      this.setDropDisable(this.treeData)
      this.isFold(this.treeData)
      this.activeTreeData = this.treeData
      this.gb28181CheckedCount = 0;
      this.gb28181CheckedCount = 0
      this.gb28181ChildNodeCount = this.countChildrenNodes(this.treeData)
      this.activeTreeData = this.treeData
      console.log(this.activeTreeData)
    }
  }
  removeNoCheckedNode(nodes: Array<any>) {
    for (let i = 0; i < nodes.length;) {
    for (let i = 0; i < nodes.length; ) {
      if (!nodes[i].checked) {
        nodes.splice(i, 1)
        continue
@@ -504,7 +512,7 @@
  countCheckedNodes(nodes: Array<any>) {
    let count = 0
    nodes.forEach(n => {
    nodes.forEach((n) => {
      if (n.type == "camera") {
        count++
      }
src/components/licence/index.vue
@@ -1,7 +1,7 @@
<template>
  <div class="s-licence">
    <div class="licence" @click="dialogVisible = true">
      <span>{{tip}}</span>
      <span>{{ tip }}</span>
    </div>
    <el-dialog
      title="授权管理"
@@ -32,31 +32,23 @@
              <el-form-item label="手机号码" prop="phone">
                <el-input v-model="registe.phone" size="small" style="max-width:420px"></el-input>
              </el-form-item>
              <el-button
                type="primary"
                size="small"
                @click="getRegsiterCode()"
                style="float:right"
              >提交</el-button>
              <el-button type="primary" size="small" @click="getRegsiterCode()" style="float:right">提交</el-button>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="认证" name="second" style="text-align:left" :disabled="!regCode.length">
            <div v-show="!showQrcode" class="auth-box">
              <span style="line-height: 30px;">注册码</span>
              <a href="#" @click="showQrcode=true" style="font-size: 10px;">&nbsp;查看二维码</a>
              <a href="#" @click="showQrcode = true" style="font-size: 10px;">&nbsp;查看二维码</a>
              <el-input type="textarea" :readonly="true" :rows="4" placeholder v-model="regCode"></el-input>
              <span style="line-height: 30px;">授权码</span>
              <el-input type="textarea" :rows="5" placeholder="请输入授权码" v-model="license"></el-input>
              <el-button
                type="primary"
                size="small"
                @click="submitLicence()"
                style="margin-top: 15px;float: right;"
              >提交</el-button>
              <el-button type="primary" size="small" @click="submitLicence()" style="margin-top: 15px;float: right;"
                >提交</el-button
              >
            </div>
            <div v-show="showQrcode" style="text-align:right">
              <vue-qrcode :text="regCode" style="margin-left: 115px;"></vue-qrcode>
              <a href="#" @click="showQrcode=false">返回</a>
              <a href="#" @click="showQrcode = false">返回</a>
            </div>
          </el-tab-pane>
        </el-tabs>
@@ -67,7 +59,7 @@
          <p>用户名称:{{ registe.company }}</p>
          <p>电子邮箱:{{ registe.email }}</p>
          <p>
            授权期限:{{ '永久有效' }}
            授权期限:{{ registe.expireTime | TimeFormat }}
            <span v-show="expired" style="color:red">已过期</span>
          </p>
          <el-divider></el-divider>
@@ -75,12 +67,9 @@
            <b>授权码</b>
          </p>
          <el-input type="textarea" :readonly="true" :rows="4" placeholder v-model="licenseCode"></el-input>
          <el-button
            type="primary"
            size="small"
            @click="rereg()"
            style="margin-top: 15px;float: right;"
          >重新注册</el-button>
          <el-button type="primary" size="small" @click="rereg()" style="margin-top: 15px;float: right;"
            >重新注册</el-button
          >
        </div>
      </div>
    </el-dialog>
@@ -88,80 +77,74 @@
</template>
<script>
import { showLicence, getRegCode, updateLicence } from './api.ts'
import { isPhone, validEmail } from '../../scripts/validate.ts'
import VueQrcode from 'vue-qrcode-component'
import { showLicence, getRegCode, updateLicence } from "./api.ts"
import { isPhone, validEmail } from "../../scripts/validate.ts"
import VueQrcode from "vue-qrcode-component"
export default {
  name: 'LicenceManage',
  name: "LicenceManage",
  components: {
    VueQrcode
  },
  data() {
    return {
      registe: {
        company: '',
        email: '',
        phone: ''
        company: "",
        email: "",
        phone: "",
        expireTime: 0
      },
      dialogVisible: false,
      authStatus: '',
      active: 'first',
      regCode: '',
      license: '',
      licenseCode: '',
      expireTime: '',
      authStatus: "",
      active: "first",
      regCode: "",
      license: "",
      licenseCode: "",
      expired: false,
      showQrcode: false,
      tip: '',
      tip: "",
      rules: {
        email: [
          {
            required: true,
            message: '请输入正确的邮箱地址',
            trigger: 'change'
            message: "请输入正确的邮箱地址",
            trigger: "change"
          },
          { validator: validEmail, trigger: 'blur' }
          { validator: validEmail, trigger: "blur" }
        ],
        phone: [
          {
            required: true,
            message: '请输入正确的手机号码',
            trigger: 'change'
            message: "请输入正确的手机号码",
            trigger: "change"
          },
          { validator: isPhone, trigger: 'blur' }
          { validator: isPhone, trigger: "blur" }
        ],
        company: [
          {
            required: true,
            message: '公司名称不能为空',
            trigger: 'change'
            message: "公司名称不能为空",
            trigger: "change"
          }
        ]
      }
    }
  },
  filters: {
    timeFormat(timestamp) {
    TimeFormat(timestamp) {
      var now = new Date()
      var currentYear = now.getFullYear()
      var date = new Date(timestamp * 1000) //时间戳为10位需*1000,时间戳为13位的话不需乘1000
      var Y = date.getFullYear() + '-'
      var M =
        (date.getMonth() + 1 < 10
          ? '0' + (date.getMonth() + 1)
          : date.getMonth() + 1) + '-'
      var D =
        date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' '
      var h =
        date.getHours() < 10
          ? '0' + date.getHours() + ':'
          : date.getHours() + ':'
      var m =
        date.getMinutes() < 10
          ? '0' + date.getMinutes() + ':'
          : date.getMinutes() + ':'
      var s =
        date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
      return Y + M + D + h + m + s
      var Y = date.getFullYear()
      var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1
      var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate()
      if (Y - currentYear > 5) {
        return "永久有效"
      }
      return Y + "-" + M + "-" + D
    }
  },
  mounted() {
@@ -176,32 +159,34 @@
      let rsp = await showLicence()
      if (rsp && rsp.success) {
        if (rsp.data.License.Expires === 0) {
          this.authStatus = 'unregistered'
          this.tip = '未授权, 点击注册'
          this.authStatus = "unregistered"
          this.tip = "未授权, 点击注册"
        } else {
          this.authStatus = 'registered'
          this.authStatus = "registered"
          this.registe.company = rsp.data.License.RegCode.Company
          this.registe.email = rsp.data.License.RegCode.Email
          this.registe.phone = rsp.data.License.RegCode.Phone
          this.registe.expireTime = rsp.data.License.Expires
          console.log(this.registe.expireTime)
          this.licenseCode = rsp.data.License.LicenseCode
          this.expireTime = rsp.data.License.Expires
          this.expired = rsp.data.Expired
          if (this.expired) {
            this.tip = '授权已过期'
            this.tip = "授权已过期"
          } else {
            this.tip = '已授权'
            this.tip = "已授权"
          }
        }
      }
      this.showBtn = true
    },
    getRegsiterCode() {
      this.$refs['reginfo'].validate(valid => {
      this.$refs["reginfo"].validate((valid) => {
        if (valid) {
          getRegCode(this.registe).then(rsp => {
          getRegCode(this.registe).then((rsp) => {
            if (rsp && rsp.success) {
              this.regCode = rsp.data
              this.active = 'second'
              this.active = "second"
            }
          })
        }
@@ -209,27 +194,27 @@
    },
    submitLicence() {
      updateLicence({ license: this.license })
        .then(rsp => {
        .then((rsp) => {
          if (rsp && rsp.success) {
            this.$notify({
              type: 'success',
              message: '更新授权成功'
              type: "success",
              message: "更新授权成功"
            })
            this.authStatus = 'registered'
            this.authStatus = "registered"
            this.getLicence()
          }
        })
        .catch(err => {
        .catch((err) => {
          this.$notify({
            type: 'error',
            message: '授权更新失败'
            type: "error",
            message: "授权更新失败"
          })
        })
    },
    rereg() {
      this.active = 'first'
      this.authStatus = 'unregistered'
      this.active = "first"
      this.authStatus = "unregistered"
    }
  }
}