zhangzengfei
2022-09-02 904b214f0395fcd670fb60f84d31a0be842c4f73
src/Pool/VideoPhotoData.ts
@@ -6,69 +6,70 @@
  findPersonByPic,
  findPerson,
  addToBase
} from "@/api/search";
} from "@/api/search"
export default class VideoPhotoData {
  public searchFrom: string = 'search';
  public preCards: Array<object> = [];
  public cards: Array<object> = [];
  public persons: Array<object> = [];
  public searchFrom: string = "search"
  public preCards: Array<object> = []
  public cards: Array<object> = []
  public persons: Array<object> = []
  public activeName: string = "pic"
  public page: number = 1;
  public size: number;
  public pageSizeOption: Array<number>;
  public alarmlevel: Array<object>;
  public dictionary: object = {};
  public monitorLevel: Array<object> = [];
  public queryAlarmlevel: Array<string> = [];
  public inputValue: string;
  public searchTime: Array<string>;
  public showType: string;
  public tabs: Array<object>;
  public blackList: Array<object> = [];
  public selectBlacks: Array<object> = [];
  public whiteList: Array<object> = [];
  public selectWhites: Array<object> = [];
  public queryTabs: Array<string> = [];
  public compareTabs: Array<string> = [];
  public tasks: Array<object>;
  public queryTasks: Array<string> = [];
  public treeNodes: Array<string>;
  public total: number = 0;
  public tabsForUploadImg: Array<object> = [];
  public picUrl: string = "";
  public threshold: number = 60;
  public activeCard: number | string = "";
  public uploadImg: any = "";
  public captureId: string = "";
  public compareNum: string = "";
  public compTargetId: string = "";
  public compTargetType: string = "1";
  public rightSectionDisplay: boolean = false;
  public scrollContainDom: any = '';
  public uploadDiaplay: boolean = false;
  public uploadType: boolean = false;
  public page: number = 1
  public size: number
  public pageSizeOption: Array<number>
  public alarmlevel: Array<object>
  public dictionary: object = {}
  public monitorLevel: Array<object> = []
  public queryAlarmlevel: Array<string> = []
  public inputValue: string
  public searchTime: Array<string>
  public showType: string
  public tabs: Array<object>
  public blackList: Array<object> = []
  public selectBlacks: Array<object> = []
  public whiteList: Array<object> = []
  public selectWhites: Array<object> = []
  public queryTabs: Array<string> = []
  public compareTabs: Array<string> = []
  public tasks: Array<object>
  public queryTasks: Array<string> = []
  public treeNodes: Array<string>
  public total: number = 0
  public tabsForUploadImg: Array<object> = []
  public picUrl: string = ""
  public threshold: number = 60
  public activeCard: number | string = ""
  public uploadImg: any = ""
  public captureId: string = ""
  public compareNum: string = ""
  public compTargetId: string = ""
  public compTargetType: string = "1"
  public rightSectionDisplay: boolean = false
  public scrollContainDom: any = ""
  public uploadDiaplay: boolean = false
  public uploadType: boolean = false
  public warningFlag: number = 0
  constructor() {
    this.cards = [];
    this.size = 60;
    this.pageSizeOption = [30, 60, 120]
    this.alarmlevel = [];
    this.inputValue = "";
    this.searchTime = [];
    this.showType = "search";
    this.tabs = [];
    this.tasks = [];
    this.treeNodes = [];
    this.cards = []
    this.size = 60
    this.pageSizeOption = [30, 60, 120, 1200]
    this.alarmlevel = []
    this.inputValue = ""
    this.searchTime = []
    this.showType = "search"
    this.tabs = []
    this.tasks = []
    this.treeNodes = []
  }
  clearStatus() {
    //this.cards = [];
    this.page = 1;
    this.size = 60;
    this.page = 1
    this.size = 60
    this.pageSizeOption = [30, 60, 120]
    this.alarmlevel = [];
    this.inputValue = "";
    this.showType = "search";
    this.alarmlevel = []
    this.inputValue = ""
    this.showType = "search"
  }
  async querySearchList() {
@@ -80,30 +81,49 @@
      searchTime: this.searchTime,
      alarmlevel: this.queryAlarmlevel,
      inputValue: this.inputValue,
      warningFlag: this.warningFlag,
      tabs: this.queryTabs,
      tasks: this.queryTasks,
      treeNodes: this.treeNodes,
      dataSource: "camera"
    }
    if (this.searchFrom == 'cluster') {
    // 根据权限控制摄像机
    let userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
    // 未选择摄像机并且不是管理员
    if (!this.treeNodes.length && userInfo.username != "Administrator") {
      let checkedCameras = userInfo.email
      this.treeNodes = checkedCameras.split(",")
    }
    param.treeNodes = this.treeNodes
    if (this.searchFrom == "cluster") {
      param.isAll = true
    }
    const rsp: any = await getSearchList(param);
    const rsp: any = await getSearchList(param)
    if (rsp && rsp.success) {
      this.cards.length = 0 // 清两次,第一次是为了点完之后不会出现之前数据的残影,这次是为了防止因为异步问题两次请求会出现双倍数据的问题
      this.preCards.length = 0
      if (rsp.data.datalist) {
        rsp.data.datalist.forEach(element => {
        rsp.data.datalist.forEach((element) => {
          if (element.activeObject.targetInfo && element.activeObject.targetInfo.length === 0) {
            element.activeObject.targetInfo = null
          }
          if (element.list[0].targetInfo && element.list[0].targetInfo.length === 0) {
            element.list[0].targetInfo = null
          }
          element.ownerPage = this.page
          this.cards.push(element as any);
          this.cards.push(element as any)
          // 只允许每个card渲染一张图片
          // var obj = {activeObject: element.activeObject,ownerPage: element.ownerPage,list: [],length: element.list.length}
          // obj.list.push(element.activeObject)
          // this.preCards.push(obj)
        });
        })
      }
      //console.log("cards的数量",this.cards)
      this.total = rsp.data.total;
      this.total = rsp.data.total
    }
  }
@@ -122,17 +142,17 @@
      threshold: this.threshold,
      isAll: this.searchFrom == "cluster" ? true : false
    }
    const rsp: any = await findPersonByPic(param);
    const rsp: any = await findPersonByPic(param)
    if (rsp && rsp.success) {
      rsp.data.totalList.forEach(element => {
      rsp.data.totalList.forEach((element) => {
        var obj = {
          activeObject: (element as any),
          activeObject: element as any,
          list: []
        }
        element.ownerPage = this.page
        obj.list.push((element as any))
        obj.list.push(element as any)
        this.cards.push(obj)
      });
      })
      // console.log("以图搜图查回来的人",this.persons)
      this.total = rsp.data.total
      this.compareNum = rsp.data.compareNum
@@ -172,20 +192,20 @@
        compTargetId: this.compTargetId,
        compTargetType: compType,
        databases: this.compareTabs,
        threshold: this.threshold,
        threshold: this.threshold
      }
    }
    const rsp: any = await findPersonByPic(param);
    const rsp: any = await findPersonByPic(param)
    if (rsp && rsp.success) {
      rsp.data.totalList.forEach(element => {
      rsp.data.totalList.forEach((element) => {
        var obj = {
          activeObject: (element as any),
          activeObject: element as any,
          list: []
        }
        element.ownerPage = this.page
        obj.list.push((element as any))
        obj.list.push(element as any)
        this.cards.push(obj)
      });
      })
      this.total = rsp.data.total
      this.compareNum = rsp.data.compareNum
    }
@@ -206,65 +226,73 @@
      threshold: this.threshold,
      isAll: this.searchFrom == "cluster" ? true : false
    }
    const rsp: any = await findPerson(param);
    const rsp: any = await findPerson(param)
    if (rsp && rsp.success) {
      rsp.data.totalList.forEach(element => {
      rsp.data.totalList.forEach((element) => {
        var obj = {
          activeObject: (element as any),
          activeObject: element as any,
          list: []
        }
        element.ownerPage = this.page
        obj.list.push((element as any))
        obj.list.push(element as any)
        this.cards.push(obj)
      });
      })
      this.total = rsp.data.total
      // console.log("findPersonByPage---", this.total, this.persons)
    }
  }
  async queryTagList() {
    const rsp: any = await getTagList({});
    const rsp: any = await getTagList({})
    this.tabsForUploadImg.splice(0, this.tabsForUploadImg.length)
    if (rsp && rsp.success) {
      var arr1 = new Array
      arr1 = rsp.data&&rsp.data.tags.filter(i => {
        if (i.status === 1) {
          i.title = i.title + '(已删除)'
          return i
        }
      });
      this.tabs = rsp.data&&rsp.data.tags.filter(function (i) {
        if (i.status !== 1) {
          return i
        }
      })
      var arr1 = new Array()
      arr1 =
        rsp.data &&
        rsp.data.tags.filter((i) => {
          if (i.status === 1) {
            i.title = i.title + "(已删除)"
            return i
          }
        })
      this.tabs =
        rsp.data &&
        rsp.data.tags.filter(function(i) {
          if (i.status !== 1) {
            return i
          }
        })
      this.tabs.push(...arr1)
      this.tabsForUploadImg.push({ key: "esData", title: "抓拍库" });
      rsp.data.tags.forEach(element => {
        this.tabsForUploadImg.push(element as any);
      });
      this.tabsForUploadImg.push({ key: "esData", title: "抓拍库" })
      rsp.data.tags.forEach((element) => {
        this.tabsForUploadImg.push(element as any)
      })
      // 放置黑白名单 0为白名单
      this.blackList.length = 0
      this.whiteList.length = 0
      var josn = JSON.stringify(rsp)
      var resp = JSON.parse(josn)
      resp.data.tags.forEach(i => {
        if (i.status === 0 && i.bwType === "0") { //白名单
          if (i.analyServerId === "") { //同步库
            i.title = i.title + '(同步库)'
      resp.data.tags.forEach((i) => {
        if (i.status === 0 && i.bwType === "0") {
          //白名单
          if (i.analyServerId === "") {
            //同步库
            i.title = i.title + "(同步库)"
            this.whiteList.push(i)
          } else {
            this.whiteList.push(i)
          }
        }
        if (i.status === 0 && i.bwType === "1") { //黑名单
          if (i.analyServerId === "") { //同步库
            i.title = i.title + '(同步库)'
        if (i.status === 0 && i.bwType === "1") {
          //黑名单
          if (i.analyServerId === "") {
            //同步库
            i.title = i.title + "(同步库)"
            this.blackList.push(i)
          } else {
            this.blackList.push(i)
          }
        }
      });
      })
    } else {
      // this.$notify({
      //   title: "失败",
@@ -275,36 +303,36 @@
  }
  async queryTaskList() {
    let params: any = {};
    if (this.searchFrom == 'cluster') {
    let params: any = {}
    if (this.searchFrom == "cluster") {
      params.isPlatform = 1
    }
    console.log(params)
    const rsp: any = await getTaskList(params);
    // console.log(params)
    const rsp: any = await getTaskList(params)
    if (rsp && rsp.success) {
      // this.tasks.splice(0, this.tasks.length)
      // rsp.data.forEach(element => {
      //   this.tasks.push((element as any).task);
      // });
      let taskNames = [];
      this.tasks = [];
      let taskNames = []
      this.tasks = []
      rsp.data.aggs.forEach((d: any) => {
        if (taskNames.indexOf(d.name) < 0) {
          taskNames.push(d.name);
          taskNames.push(d.name)
          this.tasks.push(d)
        } else {
          let repeatOne = this.tasks.find((one: any) => one.name == d.name);
          repeatOne['id'] += `,${d.id}`;
          repeatOne['isDelete'] = repeatOne['isDelete'] && d.isDelete
          let repeatOne = this.tasks.find((one: any) => one.name == d.name)
          repeatOne["id"] += `,${d.id}`
          repeatOne["isDelete"] = repeatOne["isDelete"] && d.isDelete
        }
      });
      })
    }
  }
  async queryDictionary() {
    const rsp: any = await getAlarmLevel({});
    const rsp: any = await getAlarmLevel({})
    if (rsp && rsp.success) {
      this.dictionary = rsp.data;
      this.dictionary = rsp.data
      // console.log("字典是:", this.dictionary)
      //this.dictionary['ALARMLEVEL'].unshift({ name: '撤防', value: "-1" })