zhanghua
2022-12-29 c8a167fd980901fb9aa83064d92ce04bbb9cd87e
src/views/systemSetting/device/loudspeaker/components/dialogForm.vue
@@ -58,7 +58,7 @@
              <el-button
                type="primary"
                class="btn submit"
                @click.native.prevent="handleUpdateLawCar"
                @click.native.prevent="handleSave"
                >确认
              </el-button>
            </div>
@@ -69,6 +69,8 @@
  </div>
</template>
  <script>
import { createNamespacedHelpers } from "vuex";
const { mapActions } = createNamespacedHelpers("loudspeaker");
export default {
  data() {
    const checkName = (rule, value, callback) => {
@@ -113,77 +115,40 @@
    };
  },
  created() {
    // 初始化数据
    this.form = JSON.parse(JSON.stringify(this.info));
    this.form = this.info;
  },
  watch: {
    info(newVal) {
      this.form = newVal; //对父组件传过来的值进行监听,如果改变也对子组件内部的值进行改变
    },
  },
  methods: {
    // 修改执法车
    handleUpdateLawCar() {
    ...mapActions(["saveLoudspeaker", "updateLoudspeaker"]),
    // 保存
    handleSave() {
      this.$refs.formRef.validate((valid) => {
        if (valid) {
          const { form } = this;
          this.$axios({
            method: "put",
            url: "sccg/car_Manage/modification_enforce",
            data: {
              ...form,
            },
          }).then((res) => {
            console.log(res);
            if (res.code === 200) {
          if (form.id > 0) {
            this.updateLoudspeaker(form).then((res) => {
              this.$message({
                type: "success",
                message: "修改车辆成功",
                message: "修改音柱成功",
              });
              this.$emit("closeDialog", { flag: false, index: 1 });
            } else {
            });
          } else {
            this.saveLoudspeaker(form).then((res) => {
              this.$message({
                type: "error",
                message: res.message,
                type: "success",
                message: "保存音柱成功",
              });
            }
          });
              this.$emit("closeDialog", { flag: false, index: 1 });
            });
          }
        } else {
          return false;
        }
      });
    },
    // 部门修改
    handleCheck(data, checked) {
      console.log(data);
      this.form.departId = data.id;
      this.form.departName = data.departName;
      // 获取当前选择的id在数组中的索引
      const indexs = this.selectOrg.orgsid.indexOf(data.id);
      // 如果不存在数组中,并且数组中已经有一个id并且checked为true的时候,代表不能再次选择。
      if (indexs < 0 && this.selectOrg.orgsid.length === 1 && checked) {
        this.$message({
          message: "只能选择一个部门!",
          type: "warning",
          showClose: true,
        });
        // 设置已选择的节点为false 很重要
        this.$refs.tree.setChecked(data, false);
      } else if (this.selectOrg.orgsid.length === 0 && checked) {
        // 发现数组为空 并且是已选择
        // 防止数组有值,首先清空,再push
        this.selectOrg.orgsid = [];
        this.selectOrg.orgsid.push(data.id);
      } else if (
        indexs >= 0 &&
        this.selectOrg.orgsid.length === 1 &&
        !checked
      ) {
        // 再次直接进行赋值为空操作
        this.selectOrg.orgsid = [];
        this.form.departName = "";
      }
    },
    // 获取部门树
    getDepartTree() {
      this.$axios.get("/sccg/depart/tree").then((res) => {
        this.departList = res.data;
      });
    },
  },
@@ -193,13 +158,13 @@
  <style lang="scss" scoped>
.create {
  border-radius: 1px;
  background-color: #09152f;
  // background-color: #09152f;
  main {
    // border: 1px solid #fff;
    text-align: left;
    padding: 0 55px;
    background-color: #09152f;
    // background-color: #09152f;
    padding-bottom: 50px;
    .mainContent {
@@ -239,18 +204,18 @@
    }
  }
  &::v-deep .el-textarea__inner {
    background-color: #09152f;
    border: 1px solid #17324c;
  }
  // &::v-deep .el-textarea__inner {
  //   background-color: #09152f;
  //   border: 1px solid #17324c;
  // }
  ::v-deep .el-form-item__label {
    color: #4b9bb7;
  }
  // ::v-deep .el-form-item__label {
  //   color: #4b9bb7;
  // }
  ::v-deep .el-input__inner {
    background-color: #09152f;
    border: 1px solid #17324c;
  }
  // ::v-deep .el-input__inner {
  //   background-color: #09152f;
  //   border: 1px solid #17324c;
  // }
}
</style>