dialog.editPoint.vue 4.8 KB

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