ZZJ
2022-04-12 994e5e08cba4e6b9ce321b7cf5cb1ec8d19dfa22
src/views/hashrate/CameraManage/CameraRules/components/RuleItem.vue
@@ -87,6 +87,7 @@
    </div>
    <div class="control">
      <div class="title">场景操作</div>
      <span class="close iconfont" @click="deleteRule">&#xe60f;</span>
      <div class="content">
        <div class="btns">
          <div class="button cancel" @click="backToOrigin">取消</div>
@@ -100,12 +101,13 @@
<script>
import bus from "@/plugin/bus";
import { saveLinkScene, saveCameraScene } from "@/api/scene";
import { saveLinkScene, saveCameraScene, deleteCameraScene } from "@/api/scene";
export default {
  props: {
    rule: {},
    ruleType: {},
    cameraId: {},
  },
  created() {
    this.getSdkConnection();
@@ -204,36 +206,46 @@
    },
    save() {
      if (this.ruleType === "separate") {
        this.rule.cameraIds = [this.rule.cameraId];
        this.rule.cameraIds = [this.cameraId];
        saveCameraScene(this.rule).then((rsp) => {
          if (rsp && rsp.success) {
            this.$notify({
              type: "success",
              message: "策略保存成功!",
            });
            this.backToOrigin();
          }
        });
      } else {
        saveLinkScene(this.rule)
          .then((rsp) => {
        saveLinkScene(this.rule).then((rsp) => {
            if (rsp && rsp.success) {
              this.$notify({
                type: "success",
                message: "任务保存成功!",
              });
            this.backToOrigin();
            } else {
              this.$notify({
                type: "error",
                message: rsp.data,
              });
            }
          })
          .catch((err) => {
            this.$message({
              type: "error",
              message: "保存失败!",
            });
      }
    },
    async deleteRule() {
      if (!this.rule.id) {
        console.log("87878");
        this.backToOrigin();
        return;
      }
      const res = await deleteCameraScene(this.rule.id);
      if (res && res.success) {
        this.$notify({
          type: "success",
          message: "删除成功",
          });
        this.$emit("deletRule");
      }
    },
    update() {
@@ -387,8 +399,18 @@
  }
  .control {
    position: relative;
    width: 128px;
    .close {
      position: absolute;
      top: 12px;
      right: 15px;
      font-size: 12px;
      color: #e34d59;
      cursor: pointer;
    }
    .btns {
      display: flex;
      margin-top: 68px;