dialog.edit.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="rule-type">
  3. <DialogCom
  4. :title="id ? '编辑防区' : '新增防区'"
  5. :visible.sync="isShow"
  6. @close="onHide"
  7. width="500px"
  8. >
  9. <div class="page-body">
  10. <el-form
  11. :model="formData"
  12. :rules="formDataRules"
  13. size="small"
  14. ref="form"
  15. label-position="right"
  16. label-width="130px"
  17. label-prefix=":"
  18. >
  19. <el-form-item label="所属机构" prop="orgId">
  20. <orgDropDown
  21. v-model="formData.orgId"
  22. placeholder="选择所属机构"
  23. @select="onOrgSelect"
  24. />
  25. </el-form-item>
  26. <el-form-item prop="name" label="防区名称:">
  27. <el-input
  28. v-model="formData.name"
  29. :maxlength="50"
  30. name="name"
  31. placeholder="请输入防区名称"
  32. clearable
  33. />
  34. </el-form-item>
  35. <el-form-item prop="type" label="24小时防区:">
  36. <el-switch
  37. v-model="formData.allHour"
  38. :active-value="1"
  39. :inactive-value="0"
  40. >
  41. </el-switch>
  42. </el-form-item>
  43. </el-form>
  44. </div>
  45. <div slot="footer" class="dialog-footer">
  46. <el-button @click="isShow=false">取消</el-button>
  47. <el-button type="primary" @click="onSubmit">确定</el-button>
  48. </div>
  49. </DialogCom>
  50. </div>
  51. </template>
  52. <script>
  53. import { mapState, mapMutations, mapGetters } from "vuex";
  54. import * as api from "@/api/resumption/protection";
  55. import orgDropDown from "../../../components/orgTree/orgDropDown.vue";
  56. export default {
  57. data() {
  58. return {
  59. id: null,
  60. isShow: false,
  61. formData: this.reset(),
  62. // 机构树选项
  63. formDataRules: {
  64. orgId: [{ required: true, message: "请选择所属机构" }],
  65. name: [{ required: true, message: "请输入防区名称" }],
  66. },
  67. };
  68. },
  69. props: {},
  70. watch: {
  71. // "formData.orgId":{
  72. // handler(v){
  73. // console.info("formData.orgId",v)
  74. // }
  75. // }
  76. },
  77. computed: {
  78. ...mapGetters(["orgId"]),
  79. },
  80. methods: {
  81. ...mapMutations([]),
  82. reset() {
  83. return {
  84. id: null,
  85. orgId: null,
  86. orgPath: null,
  87. orgName: null,
  88. name: null,
  89. allHour: 0,
  90. };
  91. },
  92. async refresh(id, other) {
  93. this.formData = id ? (await api.get(id)).data : this.reset(other);
  94. },
  95. async show(id, other = {}) {
  96. this.id = id;
  97. await this.refresh(id, other);
  98. this.isShow = true;
  99. },
  100. // 事件
  101. onHide() {
  102. this.$refs.form.resetFields();
  103. },
  104. onSubmit() {
  105. this.$refs.form.validate(async (isValidate) => {
  106. if (!isValidate) return;
  107. await api.update(this.formData);
  108. this.$emit("success");
  109. this.isShow = false;
  110. });
  111. },
  112. onOrgSelect(node) {
  113. this.formData.orgPath = node.path;
  114. this.formData.orgName = node.name;
  115. },
  116. },
  117. created() {},
  118. mounted() {},
  119. components: { orgDropDown },
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. .brand_info {
  124. .el-form {
  125. width: 600px;
  126. padding-top: 40px;
  127. }
  128. }
  129. </style>