| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 | <template>  <div class="rule-type">    <DialogCom      :title="id ? '编辑防区' : '新增防区'"      :visible.sync="isShow"      @close="onHide"      width="500px"    >      <div class="page-body">        <el-form          :model="formData"          :rules="formDataRules"          size="small"          ref="form"          label-position="right"          label-width="130px"          label-prefix=":"        >          <el-form-item label="所属机构" prop="orgId">            <orgDropDown              v-model="formData.orgId"              placeholder="选择所属机构"              @select="onOrgSelect"            />          </el-form-item>          <el-form-item prop="name" label="防区名称:">            <el-input            v-model="formData.name"              :maxlength="50"              name="name"              placeholder="请输入防区名称"              clearable            />          </el-form-item>          <el-form-item prop="type" label="24小时防区:">            <el-switch              v-model="formData.allHour"              :active-value="1"              :inactive-value="0"            >            </el-switch>          </el-form-item>        </el-form>      </div>      <div slot="footer" class="dialog-footer">        <el-button @click="isShow=false">取消</el-button>        <el-button type="primary" @click="onSubmit">确定</el-button>      </div>    </DialogCom>  </div></template><script>import { mapState, mapMutations, mapGetters } from "vuex";import * as api from "@/api/resumption/protection";import orgDropDown from "../../../components/orgTree/orgDropDown.vue";export default {  data() {    return {      id: null,      isShow: false,      formData: this.reset(),      // 机构树选项      formDataRules: {        orgId: [{ required: true, message: "请选择所属机构" }],        name: [{ required: true, message: "请输入防区名称" }],      },    };  },  props: {},  watch: {    // "formData.orgId":{    //   handler(v){    //     console.info("formData.orgId",v)    //   }    // }  },  computed: {    ...mapGetters(["orgId"]),  },  methods: {    ...mapMutations([]),    reset() {      return {        id: null,        orgId: null,        orgPath: null,        orgName: null,        name: null,        allHour: 0,      };    },    async refresh(id, other) {      this.formData = id ? (await api.get(id)).data : this.reset(other);    },    async show(id, other = {}) {      this.id = id;      await this.refresh(id, other);      this.isShow = true;    },    // 事件    onHide() {      this.$refs.form.resetFields();         },    onSubmit() {      this.$refs.form.validate(async (isValidate) => {        if (!isValidate) return;        await api.update(this.formData);        this.$emit("success");        this.isShow = false;      });    },    onOrgSelect(node) {      this.formData.orgPath = node.path;      this.formData.orgName = node.name;    },  },  created() {},  mounted() {},  components: { orgDropDown },};</script><style lang="scss" scoped>.brand_info {  .el-form {    width: 600px;    padding-top: 40px;  }}</style>
 |