dialog.editPoint.vue 5.5 KB

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