mark
2022-09-30 2ec95b3d2fd484b44d5274054bcbd78307a76ef8
src/views/dataPush/components/point.vue
@@ -10,7 +10,6 @@
      <div class="right">
        <div class="button searchBtn" @click="checkCamerasList(1)">搜索</div>
        <!-- <div class="button resetBtn" @click="reset">重置</div> -->
      </div>
    </div>
    <div class="btns">
@@ -19,7 +18,16 @@
        <span>添加点位</span>
      </div>
      <div class="switchBox">
        <el-switch v-model="value1" @change="changeAll($event)" active-text="总点位开" inactive-text="总点位关">
        总点位开关
        <el-switch
          v-model="value1"
          width="60"
          active-color="#13ce66"
          inactive-color="#f0f3f5"
          @change="changeAll($event)"
        >
          <!-- active-text="总点位开"
          inactive-text="总点位关" -->
        </el-switch>
      </div>
    </div>
@@ -32,9 +40,9 @@
        :fit="true"
        :default-sort="{ prop: 'createTime', order: 'descending' }"
      >
        <el-table-column prop="cameraName" label="点位名称" show-overflow-tooltip></el-table-column>
        <el-table-column prop="cameraName" label="点位名称" width="130px" 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="companyCode" label="企业编码" width="130px" show-overflow-tooltip></el-table-column>
        <el-table-column prop="scenes" label="推送场景" show-overflow-tooltip></el-table-column>
        <el-table-column prop="updatedAt" label="推送时间" width="100px" show-overflow-tooltip>
          <template slot-scope="scope">{{ scope.row.startTime }}-{{ scope.row.endTime }}</template>
@@ -83,7 +91,7 @@
      class="add-ruleForm"
    >
      <el-form-item label="点位名称" prop="CameraName">
        <el-select style="width: 350px" v-model="ruleForm.CameraName" placeholder="请选择">
        <el-select filterable 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>
@@ -135,7 +143,7 @@
      </el-form-item>
    </el-form>
    <div class="right">
      <div class="button searchBtn" @click="saveUser">保存</div>
      <div class="button searchBtn" @click="save">保存</div>
      <div class="button resetBtn" @click="resetUser">重置</div>
      <div class="button resetBtn" style="margin-left:20px" @click="goback">返回</div>
    </div>
@@ -144,13 +152,16 @@
<script>
import { getLocalCameraTree } from "@/api/area"
import { traverse } from "./point"
import { getClusterDevList } from "@/api/clusterManage"
import { camerasList, camerasCreate, camerasConfig, camerasSwitch, camerasUpdate, camerasDelete } from "@/api/report"
import { traverse } from "./point/point"
import "./point/point.scss"
export default {
  data() {
    return {
      activeColor: "",
      inactiveColor: "#f0f3f5",
      value1: false,
      query: {},
      inputText: "", //输入框内容
@@ -218,9 +229,7 @@
        updatedAt: "",
        id: ""
      },
      dataList: [],
      tip: 1, // 区分保存还是编辑 但是现在没有编辑
      rules: {
        CameraName: [{ required: true, message: "请选择设备名称", trigger: "change" }],
@@ -235,6 +244,20 @@
      total: 0 //总数,
    }
  },
  // computed: {
  //   // activeColor() {
  //   //   return this.value1 ? "#13ce66" : "#f0f3f5"
  //   // }
  // },
  // watch: {
  //   value1: {
  //     handler(newVal, oldVal) {
  //       console.log(newVal, oldVal, "newVal, oldVal")
  //       newVal ? (this.activeColor = "#13ce66") : (this.activeColor = "#f0f3f5")
  //     },
  //     deep: true
  //   }
  // },
  async created() {
    let query = { pageIndex: this.page, pageSize: this.size, keyword: this.inputText }
    this.query = query
@@ -244,11 +267,8 @@
    this.aaaaa()
  },
  // const rsp: any = await getLocalCameraTree(params)
  // console.log(rsp, "rsp")
  methods: {
    async changeAll(val) {
      console.log(val)
      let enable
      val ? (enable = 1) : (enable = 0)
      let rsp = await camerasSwitch({ enable: enable })
@@ -261,7 +281,6 @@
      }
    },
    changeSwitch(val, row) {
      console.log(val, row, "val, rowval, row")
      let params = {
        CameraName: row.cameraName,
        ChannelCode: row.channelCode,
@@ -277,7 +296,6 @@
        id: row.id
      }
      camerasUpdate(params).then((res) => {
        console.log(res, "res")
        if (res && res.success) {
          this.$message({
            type: "success",
@@ -287,7 +305,6 @@
      })
    },
    editCameras(row) {
      console.log(row, "row")
      this.tip = 2
      this.isShowAdd = true
      this.resetUser()
@@ -305,20 +322,22 @@
      this.ruleForm.id = row.id
    },
    async aaaaa() {
      // 进入页面前的初始化
      let res = await camerasConfig()
      // 总开关
      if (res && res.success) {
        res.data.enable === 0 ? (this.value1 = false) : (this.value1 = true)
        console.log(this.value1)
      }
      let clusterId = ""
      let clusterReq = await getClusterDevList()
      // 查询
      if (clusterReq && clusterReq.success) {
        if (clusterReq.data.clusterList.length > 0) {
          clusterId = clusterReq.data.clusterList[0].cluster_id
        }
      }
      console.log(clusterId)
      let camereReq = await getLocalCameraTree({ clusterId: clusterId })
      // 这个是 添加时的点位 是从摄像机页面 来的
      let array = []
      this.cameraOptions = traverse(camereReq.data.treeMenu, array)
    },
@@ -327,12 +346,12 @@
      this.tip = 1
      this.resetUser()
    }, //y
    saveUser() {
    save() {
      this.$refs["ruleForm"].validate((valid) => {
        if (valid) {
          if (this.tip !== 1) {
            // tip1 是添加 其他是编辑
            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,
@@ -347,8 +366,8 @@
              updatedAt: this.ruleForm.updatedAt,
              id: this.ruleForm.id
            }
            //  编辑
            camerasUpdate(params).then((res) => {
              console.log(res, "res")
              if (res && res.success) {
                this.$message({
                  type: "success",
@@ -360,7 +379,6 @@
            })
          } else {
            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,
@@ -372,9 +390,8 @@
              Level: this.ruleForm.Level,
              Enable: this.ruleForm.Enable
            }
            console.log(params, "paramsv")
            // 新建
            camerasCreate(params).then((res) => {
              console.log(res, "res")
              if (res && res.success) {
                this.$message({
                  type: "success",
@@ -436,15 +453,6 @@
      this.ruleForm.Sceneslist = []
      this.ruleForm.StartTime = ""
      this.ruleForm.EndTime = ""
      //   Scenes: "",
      //   CameraId: "", // 摄像机id
      //   Level: "",
      //   Enable: false,
      //   createdAt: "",
      //   updatedAt: "",
      //   id: ""
      // }
    },
    goback() {
      this.isShowAdd = false
@@ -453,21 +461,8 @@
}
</script>
//
<style scoped lang="scss"></style>
<style scoped lang="scss">
//
</style>
<style scoped lang="scss">
::deep .el-switch {
  color: #f52323;
  .el-switch__core {
    height: 32px !important;
  }
  .el-switch__core::after {
    height: 30px !important;
    width: 30px !important;
  }
}
.sub-account {
  padding: 20px;
  .head-name {
@@ -628,13 +623,14 @@
  }
  .btns {
    display: flex;
    margin: 20px 0;
    text-align: center;
    justify-content: space-between;
    .switchBox {
      display: flex;
      align-items: center;
    }
    display: flex;
    margin: 20px 0;
    text-align: center;
    .add {
      margin-right: 20px;
      width: 126px;
@@ -764,6 +760,13 @@
</style>
<style>
/* .el-switch__core {
  height: 32px !important;
}
.el-switch__core::after {
  height: 30px !important;
  width: 30px !important;
} */
.el-date-table td.start-date span,
.el-date-table td.end-date span {
  background-color: #0065ff;