dialog.editPoint.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="rule-type">
  3. <el-dialog
  4. width="600px"
  5. :title="index >= 0 ? '编辑检查内容' : '新增检查内容'"
  6. :visible.sync="dataVisible"
  7. :show-close="false"
  8. @close="
  9. () => {
  10. this.$refs.form.resetFields();
  11. }
  12. "
  13. append-to-body
  14. >
  15. <div>
  16. <el-form
  17. ref="form"
  18. :model="formData"
  19. :rules="formDataRules"
  20. label-width="110px"
  21. class="formbox"
  22. >
  23. <!-- <el-form-item label="检查要点编号" prop="pointNum">
  24. <el-input
  25. v-model="formData.pointNum"
  26. type="number"
  27. laceholder="请输入检查要点编号"
  28. @blur="check()"
  29. @input="formData.pointNum = Number(formData.pointNum)"
  30. ></el-input>
  31. </el-form-item> -->
  32. <el-form-item label="检查内容" prop="name">
  33. <el-input
  34. v-model="formData.name"
  35. placeholder="请输入检查内容"
  36. maxlength="100"
  37. ></el-input>
  38. </el-form-item>
  39. <el-form-item label="检查区域" prop="areaId">
  40. <el-select
  41. v-model="formData.areaId"
  42. placeholder="请选择检查区域"
  43. @change="onAreaChanged"
  44. clearable
  45. >
  46. <el-option
  47. v-for="item in areas"
  48. :key="item.id"
  49. :label="item.name"
  50. :value="item.id"
  51. ></el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="数据来源" prop="businessType">
  55. <el-select
  56. v-model="formData.businessType"
  57. placeholder="请选择数据来源"
  58. clearable
  59. >
  60. <el-option
  61. v-for="item in pointDataSource"
  62. :key="item.value"
  63. :label="item.label"
  64. :value="item.value"
  65. ></el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item label="备注" prop="remark">
  69. <el-input
  70. type="textarea"
  71. v-model="formData.remark"
  72. maxlength="200"
  73. :rows="3"
  74. clearable
  75. ></el-input>
  76. </el-form-item>
  77. </el-form>
  78. </div>
  79. <div slot="footer" class="dialog-footer">
  80. <el-button @click="dataVisible = false">取 消</el-button>
  81. <el-button type="primary" @click="onSubmit()">{{
  82. index >= 0 ? "保 存" : "添 加"
  83. }}</el-button>
  84. </div>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import { mapState, mapMutations } from "vuex";
  90. import { allAreaByOrgtype } from "@/api/system/area";
  91. export default {
  92. data() {
  93. return {
  94. index: null,
  95. dataVisible: false,
  96. formData: this.reset(),
  97. formDataRules: {
  98. name: [{ required: true, message: "请输入检查内容" }],
  99. areaId: [{ required: true, message: "请选择检查区域" }],
  100. },
  101. currentOrgType: null,
  102. areas: [],
  103. };
  104. },
  105. props: {
  106. rule: {
  107. type: Object,
  108. },
  109. pointDataSource: {
  110. type: Array,
  111. default: [],
  112. },
  113. },
  114. watch: {},
  115. computed: {
  116. ...mapState([]),
  117. },
  118. methods: {
  119. ...mapMutations([]),
  120. reset() {
  121. return {
  122. id: null,
  123. name: null,
  124. areaId: null,
  125. areaName: null,
  126. businessType: null,
  127. remark: null,
  128. };
  129. },
  130. async show(index, data) {
  131. if (index >= 0) {
  132. this.index = index;
  133. this.formData = data;
  134. } else {
  135. this.index = -1;
  136. this.formData = this.reset();
  137. }
  138. // if (this.currentOrgType != this.rule.orgType) {
  139. allAreaByOrgtype(this.rule.orgType).then((d) => {
  140. this.currentOrgType = this.rule.orgType;
  141. this.areas = d.data;
  142. });
  143. // }
  144. this.dataVisible = true;
  145. },
  146. onSubmit() {
  147. this.$refs.form.validate((isValidate) => {
  148. if (!isValidate) return;
  149. let obj = {};
  150. obj = { ...this.formData };
  151. if (obj.businessType == "") {
  152. obj.businessType = null;
  153. }
  154. this.$emit("submit", this.index, obj);
  155. this.dataVisible = false;
  156. });
  157. },
  158. // 事件
  159. onHide() {
  160. this.isShow = false;
  161. },
  162. onAreaChanged(val) {
  163. let area = this.areas.find((a) => a.id === val);
  164. if (area) {
  165. this.formData.areaName = area.name;
  166. }
  167. },
  168. },
  169. mounted() {},
  170. components: {},
  171. };
  172. </script>
  173. <style lang="scss">
  174. .brand_info {
  175. .el-form {
  176. width: 600px;
  177. padding-top: 40px;
  178. }
  179. }
  180. </style>