mark
2022-09-27 600f3c72842b59fc368c2512f1ded25687d104ae
点位信息维护
2个文件已修改
639 ■■■■■ 已修改文件
src/api/report.ts 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dataPush/components/point.vue 611 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/report.ts
@@ -104,3 +104,31 @@
    params: query
  })
}
/**
 *
 * 点位信息维护
查询
 */
export const camerasList = (query: any) => {
  return request({
    url: "/api-a/v1/cameras/list",
    method: "get",
    params: query
  })
}
//添加点位
export const camerasCreate = (query: any) => {
  return request({
    url: "/api-a/v1/cameras/create",
    method: "post",
    data: query
  })
}
//删除
export const camerasDelete = (query: any) => {
  return request({
    url: "/api-a/v1/cameras/delete",
    method: "get",
    params: query
  })
}
src/views/dataPush/components/point.vue
@@ -15,15 +15,15 @@
        :fit="true"
        :default-sort="{ prop: 'createTime', order: 'descending' }"
      >
        <el-table-column prop="a" label="点位名称" show-overflow-tooltip></el-table-column>
        <el-table-column prop="b" label="报警通道编码" show-overflow-tooltip></el-table-column>
        <el-table-column prop="c" label="企业编码" show-overflow-tooltip></el-table-column>
        <el-table-column prop="d" label="推送场景" show-overflow-tooltip></el-table-column>
        <el-table-column prop="e" label="推动时间" show-overflow-tooltip></el-table-column>
        <el-table-column prop="cameraName" label="点位名称" show-overflow-tooltip></el-table-column>
        <el-table-column prop="channelCode" label="报警通道编码" show-overflow-tooltip></el-table-column>
        <el-table-column prop="companyCode" label="企业编码" show-overflow-tooltip></el-table-column>
        <el-table-column prop="scenes" label="推送场景" show-overflow-tooltip></el-table-column>
        <el-table-column prop="updatedAt" label="推动时间" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作" align="center" width="100px">
          <template slot-scope="scope">
            <span class="iconfont option" style="color:red" @click="delUser(scope.row)">删除</span>
            <span class="iconfont option" style="color:red" @click="delCameras(scope.row)">删除</span>
          </template>
        </el-table-column>
      </el-table>
@@ -42,10 +42,6 @@
    </div>
  </div>
  <div class="sub-account" v-else-if="isShowAdd">
    <!-- <div class="add-title" @click="isShowAdd = false">
      <span class="iconfont">&#xe614;</span>
      <span>子账户管理</span>
    </div> -->
    <div class="head-name" style="margin-bottom:20px">编辑点位</div>
    <el-form
      :model="ruleForm"
@@ -55,20 +51,55 @@
      label-width="100px"
      class="add-ruleForm"
    >
      <el-form-item label="点位名称" prop="a">
        <el-input v-model="ruleForm.a" placeholder="请输入点位名称" style="width: 350px"></el-input>
      <el-form-item label="点位名称" prop="CameraName">
        <!-- <el-input v-model="ruleForm.CameraName" placeholder="请输入点位名称" style="width: 350px"></el-input> -->
        <el-select style="width: 350px" v-model="ruleForm.CameraName" placeholder="请选择">
          <el-option v-for="item in cameraOptions" :key="item.id" :label="item.name" :value="item.name"> </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="报警通道编码" prop="b">
        <el-input v-model="ruleForm.b" placeholder="请输入报警通道编码" style="width: 350px"></el-input>
      <el-form-item label="报警通道编码" prop="ChannelCode">
        <el-input v-model="ruleForm.ChannelCode" placeholder="请输入报警通道编码" style="width: 350px"></el-input>
      </el-form-item>
      <el-form-item label="企业编码" prop="c">
        <el-input v-model="ruleForm.c" placeholder="请输入企业编码" style="width: 350px"></el-input>
      <el-form-item label="企业编码" prop="CompanyCode">
        <el-input v-model="ruleForm.CompanyCode" placeholder="请输入企业编码" style="width: 350px"></el-input>
      </el-form-item>
      <el-form-item label="推送场景" prop="d">
        <el-input v-model="ruleForm.d" placeholder="请输入推送场景" style="width: 350px"></el-input>
      <el-form-item label="推送场景" prop="Sceneslist">
        <el-select multiple style="width: 350px" v-model="ruleForm.Sceneslist" filterable placeholder="请选择">
          <el-option v-for="item in scene_nameOptions" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="推动时间" prop="e">
        <el-input v-model="ruleForm.e" placeholder="请输入推动时间" style="width: 350px"></el-input>
      <el-form-item label="推动时间">
        <el-col :span="12" style="width: 175px">
          <el-form-item prop="StartTime">
            <el-time-select
              style="width: 175px"
              placeholder="起始时间"
              v-model="ruleForm.StartTime"
              :picker-options="{
                start: '00:00',
                step: '00:30',
                end: '23:30'
              }"
            >
            </el-time-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" style="width: 175px">
          <el-form-item prop="EndTime">
            <el-time-select
              style="width: 175px"
              placeholder="结束时间"
              v-model="ruleForm.EndTime"
              :picker-options="{
                start: '00:00',
                step: '00:30',
                end: '23:30'
              }"
            >
            </el-time-select>
          </el-form-item>
        </el-col>
      </el-form-item>
    </el-form>
    <div class="right">
@@ -80,424 +111,202 @@
</template>
<script>
import { findUserList, saveSubUser, getMenu, getDataTree, deleteUser } from "@/api/user"
import { findTaskById, updateTask } from "@/api/report"
import { getAreas, getDic } from "@/api/login"
import { getLocalCameraTree } from "@/api/area"
import { getClusterDevList } from "@/api/clusterManage"
import { camerasList, camerasCreate, camerasDelete } from "@/api/report"
export default {
  computed: {
    taskOptions() {
      return this.VideoPhotoData.tasks.filter((item) => !item.isDelete)
    }
  },
  data() {
    const validateTree = (rule, value, callback) => {
      if (
        this.ruleForm.menuIds &&
        this.ruleForm.dataIds &&
        this.ruleForm.menuIds.length > 0 &&
        this.ruleForm.dataIds.length > 0
      ) {
        callback()
      } else {
        callback(new Error("请选菜单权限和数据权限"))
      }
    }
    return {
      searchTime: [this.$moment().format("YYYY-MM-DD 00:00:00"), this.$moment().format("YYYY-MM-DD HH:mm:ss")], //搜索时间
      cameraOptions: [],
      scene_nameOptions: [
        {
          value: "明火",
          label: "明火"
        },
        {
          value: "烟雾",
          label: "烟雾"
        },
        {
          value: "翻越围栏",
          label: "翻越围栏"
        },
        {
          value: "区域入侵",
          label: "区域入侵"
        },
        {
          value: "人员撤离",
          label: "人员撤离"
        },
        {
          value: "人员离岗",
          label: "人员离岗"
        },
        {
          value: "人员聚集",
          label: "人员聚集"
        },
        {
          value: "打电话",
          label: "打电话"
        },
        {
          value: "抽烟",
          label: "抽烟"
        },
        {
          value: "未佩戴安全帽",
          label: "未佩戴安全帽"
        },
        {
          value: "未穿着工作服",
          label: "未穿着工作服"
        },
        {
          value: "睡岗",
          label: "睡岗"
        }
      ],
      isShowAdd: false, //是否展示新增弹窗
      ruleForm: {
        CameraName: "", // 摄像机名称
        ChannelCode: "", // 报警通道编号
        CompanyCode: "", // 所属企业编号
        Scenes: "", // 推送场景
        Sceneslist: [], // 推送场景
        StartTime: "", // 开始时间
        EndTime: "", // 结束时间
        CameraId: "", // 摄像机id
        Level: "",
        Enable: true
      },
      dataList: [],
      tip: 1,
      rules: {
        CameraName: [{ required: true, message: "请选择设备名称", trigger: "change" }],
        ChannelCode: [{ required: true, message: "请输入报警通道编码", trigger: "blur" }],
        CompanyCode: [{ required: true, message: "请输入企业编码", trigger: "blur" }],
        Sceneslist: [{ type: "array", required: true, message: "请选择推送场景", trigger: "change" }]
        // StartTime: [{ required: true, message: "请选择开始时间", trigger: "change" }],
        // EndTime: [{ required: true, message: "请选择结束时间", trigger: "change" }]
      },
      page: 1,
      size: 10, //分页相关
      total: 0, //总数,
      inputText: "", //输入框内容
      activeStep: 0,
      activeIndex: 0,
      industrys: [],
      treeHeight: 750,
      treeData: [],
      treeSettings: {
        check: {
          enable: true
        }
      },
      options: {
        lazy: true,
        lazyLoad(node, resolve) {
          // 懒加载节点省市数据
          const { level } = node
          let nodes
          getAreas({ parentId: level == 0 ? 0 : node.value })
            .then((json) => {
              nodes = json.data.list
              nodes = nodes.map((item) => ({
                value: item.id,
                label: item.name,
                level: item.level,
                leaf: level >= 1
              }))
              resolve(nodes)
            })
            .catch((err) => {
              console.log(err)
            })
        }
      },
      dataList: [],
      isShowAdd: false, //是否展示新增弹窗
      isShowUnbind: false, //是否展示解绑弹窗
      isShowRelate: false,
      isEditing: false,
      unbindId: "",
      durationArr: [
        {
          value: 1,
          label: "1年"
        },
        {
          value: 2,
          label: "2年"
        },
        {
          value: 3,
          label: "3年"
        }
      ], //所属集群下拉框
      timeLength: null, //选中的授权时长
      showQuit: false, //展示退出集群的弹窗
      showJoin: false, //展示加入集群的弹窗
      activeEquipment: null, //处理中的设备
      checkedData: [],
      checkedMenu: [],
      ruleForm: {
        //y
        a: "",
        b: "",
        c: "",
        d: "",
        e: "",
        id: "",
        username: "",
        userType: "",
        password: "",
        trueName: "",
        companyName: "",
        phoneNum: "",
        email: "basic",
        isChangePwd: false,
        industryId: "",
        address: [],
        authDuration: 3,
        areaId: "",
        provinceId: "",
        menuIds: [],
        dataIds: []
      },
      rules: {
        //y
        a: [{ required: true, message: "请输入点位名称", trigger: "blur" }],
        b: [{ required: true, message: "请输入报警通道编码", trigger: "blur" }],
        c: [{ required: true, message: "请输入企业编码", trigger: "blur" }],
        d: [{ required: true, message: "请输入推送场景", trigger: "blur" }],
        e: [{ required: true, message: "请输入推动时间", trigger: "blur" }]
      },
      sysMenus: [],
      DataTree: [],
      smsSceneConfig: [],
      smsLevelConfig: [],
      smsEnable: false,
      userInfo: {},
      curEditId: "",
      defaultProp: {
        children: "children",
        label: "name"
      },
      levelOptions: [
        { value: "一级", label: "一级" },
        { value: "二级", label: "二级" },
        { value: "三级", label: "三级" },
        { value: "四级", label: "四级" },
        { value: "五级", label: "五级" }
      ]
      total: 0 //总数,
    }
  },
  // created() {
  //   this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
  //   this.findUserList()
  //   this.getIndustrys()
  //   this.fetchSysMenus()
  //   this.fetchDataTree()
  // },
  // mounted() {
  //   this.TreeDataPool.reset()
  //   this.TreeDataPool.multiple = true
  //   this.VideoPhotoData.queryTaskList()
  // },
  created() {
    this.checkCamerasList()
    this.aaaaa()
  },
  // const rsp: any = await getLocalCameraTree(params)
  // console.log(rsp, "rsp")
  methods: {
    fetchDataTree() {
      getDataTree({ userId: this.userInfo.id }).then((res) => {
        this.DataTree = res.data.dataTree
      })
    },
    fetchSysMenus() {
      getMenu().then((rsp) => {
        if (rsp && rsp.success) {
          this.sysMenus = rsp.data.menus
          // this.userMenus = [];
    async aaaaa() {
      let clusterId = ""
      let clusterReq = await getClusterDevList()
      if (clusterReq && clusterReq.success) {
        if (clusterReq.data.clusterList.length > 0) {
          clusterId = clusterReq.data.clusterList[0].cluster_id
        }
      })
    },
    selectDevice(node, checked, hasChildren) {
      if (checked) {
        sessionStorage.setItem("clusterId", node.id)
        this.TreeDataPool.fetchTreeData()
        this.treeData = this.TreeDataPool.treeData
      } else {
        this.treeData = []
        this.TreeDataPool.reset()
      }
      console.log(clusterId)
      let camereReq = await getLocalCameraTree({ clusterId: clusterId })
      console.log(camereReq.data.treeMenu, "camereReqcamereReqcamereReq")
      let array = camereReq.data.treeMenu
      for (let i = 0; i < array.length; i++) {
        console.log(array[i].children, "11111111")
        for (let j = 0; j < array[i].children.length; j++) {
          this.cameraOptions.push(array[i].children[j])
        }
      }
      console.log(this.cameraOptions, "arrrrrrrrrrrrrrrr")
    },
    addPoint() {
      this.isShowAdd = true
      this.tip = 1
      this.resetUser()
    },
    async editUser(row) {
      this.isShowAdd = true
      this.isEditing = true
      this.ruleForm.id = row.id
      this.ruleForm.username = row.username
      this.ruleForm.userType = row.userType
      this.ruleForm.password = row.password
      this.ruleForm.trueName = row.trueName
      this.ruleForm.companyName = row.companyName
      this.ruleForm.phoneNum = row.phoneNum
      this.ruleForm.email = row.email
      this.ruleForm.isChangePwd = false
      this.ruleForm.industryId = row.industryId
      this.ruleForm.areaId = row.areaId
      this.ruleForm.address = [row.provinceId, row.areaId]
      this.ruleForm.provinceId = row.provinceId
      this.ruleForm.authDuration = row.authDuration
      this.checkedMenu = row.menuIds
      this.checkedData = row.dataIds
      this.smsSceneConfig = []
      this.smsLevelConfig = []
      this.smsEnable = false
      findTaskById({ id: row.id }).then((rsp) => {
        if (rsp && rsp.success && rsp.data != "") {
          if (rsp.data.taskName != "") {
            this.smsSceneConfig = rsp.data.taskName.split(",")
    }, //y
    saveUser() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          let obj = this.cameraOptions.find((item) => item.name === this.ruleForm.CameraName)
          console.log(obj, "dddddddd")
          let params = {
            CameraName: this.ruleForm.CameraName,
            ChannelCode: this.ruleForm.ChannelCode,
            CompanyCode: this.ruleForm.CompanyCode,
            Scenes: this.ruleForm.Sceneslist.toString(),
            StartTime: this.ruleForm.StartTime,
            EndTime: this.ruleForm.EndTime,
            CameraId: obj.id, //
            Level: this.ruleForm.Level,
            Enable: this.ruleForm.Enable
          }
          if (rsp.data.level != "") {
            this.smsLevelConfig = rsp.data.level.split(",")
          }
          this.smsEnable = rsp.data.enable
          console.log(params, "paramsv")
          camerasCreate(params).then((res) => {
            console.log(res, "res")
            if (res && res.success) {
              this.$message({
                type: "success",
                message: res.msg
              })
              this.goback()
            }
          })
        } else {
          return false
        }
      })
      // 查询当前用户权限下所有可管理的摄像机
      if (row.dataIds) {
        sessionStorage.setItem("clusterId", row.dataIds[0])
        await this.TreeDataPool.fetchTreeData()
      }
      // 用email字段暂时代替摄像机集合字段
      let checkedCameras = row.email
      // basic 为子账户默认的空字段,表示可管理的摄像机目录为空
      if (checkedCameras == "basic") {
        return
      }
      // 反选摄像机
      if (checkedCameras.length) {
        let cameraIds = checkedCameras.split(",")
        this.$refs.ztreeMenus.updateNodes(cameraIds)
      }
    },
    delUser(row) {
      this.$confirm("确认要删除该用户吗, 是否继续?", "提示", {
    handleSizeChange(size) {
      this.size = size
      this.checkCamerasList()
    },
    //分页功能
    refrash(page) {
      this.page = page
      this.checkCamerasList()
    },
    delCameras(row) {
      this.$confirm("确认要删除该点位吗, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(async () => {
        let rsp = await deleteUser({ id: row.id })
        let rsp = await camerasDelete({ id: row.id })
        if (rsp && rsp.success) {
          this.$message({
            type: "success",
            message: "删除成功!"
          })
        }
        this.findUserList()
        this.checkCamerasList()
      })
    },
    async checkCamerasList() {
      let res = await camerasList({ pageIndex: this.page, pageSize: this.size })
      this.dataList = res.data
      this.total = res.total
    },
    resetUser() {
      this.ruleForm = {
        id: "",
        username: "",
        userType: "",
        password: "",
        trueName: "",
        companyName: "",
        phoneNum: "",
        email: "",
        isChangePwd: false,
        address: [],
        industryId: "",
        areaId: "",
        provinceId: "",
        authDuration: 1
        CameraName: "",
        ChannelCode: "",
        CompanyCode: "",
        Sceneslist: [],
        StartTime: "",
        EndTime: ""
      }
      this.smsSceneConfig = []
      this.smsLevelConfig = []
      this.smsEnable = false
      this.$nextTick(() => {
        this.$refs.treeMenus.setCheckedKeys([])
        this.$refs.treeData.setCheckedKeys([])
      })
    },
    async getIndustrys() {
      let res = await getDic()
      if (res.success) {
        this.industrys = res.data.dics
      } else {
        console.log("查询行业列表失败!")
      }
    },
    saveUser() {
      let _this = this
      this.ruleForm.menuIds = this.$refs.treeMenus.getCheckedKeys()
      this.ruleForm.dataIds = this.$refs.treeData.getCheckedKeys()
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          let json = {
            id: this.isEditing ? this.ruleForm.id : "",
            username: this.ruleForm.username,
            password: this.ruleForm.password,
            isChangePwd: this.ruleForm.isChangePwd,
            userType: this.ruleForm.userType,
            trueName: this.ruleForm.trueName,
            companyName: this.ruleForm.companyName,
            phoneNum: this.ruleForm.phoneNum,
            industryId: this.ruleForm.industryId,
            areaId: this.ruleForm.address.length == 2 ? this.ruleForm.address[1] : "",
            authDuration: this.ruleForm.authDuration,
            menuIds: this.ruleForm.menuIds,
            dataIds: this.ruleForm.dataIds
          }
          // 获取子账户选中的摄像机列表
          let cameraIds = this.TreeDataPool.selectedNodes
          if (cameraIds.length == 0) {
            json.email = "basic"
          } else {
            json.email = cameraIds.join(",")
          }
          // 编辑不提交密码
          if (this.isEditing) {
            delete json.password
            json.isChangePwd = false
          }
          if (typeof json.areaId === "string") {
            delete json.areaId
          }
          if (typeof json.authDuration === "string") {
            delete json.authDuration
          }
          // return
          saveSubUser(json)
            .then((res) => {
              if (res.success) {
                // 保存消息推送
                if (_this.isEditing) {
                  let smsTaskInfo = {
                    id: _this.ruleForm.id,
                    taskName: _this.smsSceneConfig.join(","),
                    level: _this.smsLevelConfig.join(","),
                    cameras: json.email,
                    person: json.trueName,
                    tel: json.phoneNum,
                    enable: _this.smsEnable,
                    IsDel: "0"
                  }
                  updateTask(smsTaskInfo).then((rsp) => {
                    // console.log(rsp)
                  })
                }
                _this.$notify.success(res.data)
                _this.isShowAdd = false
                _this.isEditing = false
                _this.findUserList()
              } else {
                _this.$notify.error(res.msg)
              }
            })
            .catch((err) => {
              _this.$notify.error(err.data.msg)
            })
        } else {
          return false
        }
      })
    },
    findUserList() {
      findUserList({
        inputText: this.inputText,
        page: this.page,
        size: this.size,
        authDuration: this.timeLength
      })
        .then((res) => {
          if (res.success) {
            this.dataList = res.data.dataList
            this.total = res.data.total
          } else {
            this.$notify.error("加载子账户列表失败")
          }
        })
        .catch((e) => {
          this.$notify.error(e.msg)
        })
    },
    goback() {
      this.isShowAdd = false
      this.isEditing = false
      this.isShowRelate = false
      this.activeIndex = 0
    },
    goto(i) {
      this.activeIndex = i
    },
    reset() {
      this.inputText = ""
      this.timeLength = null
    },
    //分页功能
    handleSizeChange(size) {
      this.size = size
      this.findUserList()
    },
    //分页功能
    refrash(page) {
      this.page = page
      this.findUserList()
    },
    // 生成uuid
    getUuid() {
      let originStr = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      let originChar = "0123456789abcdef"
      let len = originChar.length
      return originStr.replace(/x/g, function(match) {
        return originChar.charAt(Math.floor(Math.random() * len))
      })
    }
  }
}