From 45a084372cfd5aead36fa5944edabc722b2234d8 Mon Sep 17 00:00:00 2001 From: ZZJ <zzjdsg2300@163.com> Date: 星期一, 20 十二月 2021 11:38:12 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/web/vue-smart-ai --- src/components/licence/index.vue | 147 ++++++++++++++++-------------------- src/Pool/TreeData.ts | 76 ++++++++++-------- 2 files changed, 108 insertions(+), 115 deletions(-) diff --git a/src/Pool/TreeData.ts b/src/Pool/TreeData.ts index 27be295..a737b7e 100644 --- a/src/Pool/TreeData.ts +++ b/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++ } diff --git a/src/components/licence/index.vue b/src/components/licence/index.vue index 3bb0a6e..b200f0a 100644 --- a/src/components/licence/index.vue +++ b/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;"> 鏌ョ湅浜岀淮鐮�</a> + <a href="#" @click="showQrcode = true" style="font-size: 10px;"> 鏌ョ湅浜岀淮鐮�</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" } } } -- Gitblit v1.8.0