dialog.edit.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 prop="name" label="履职内容库名称:">
  20. <el-input
  21. v-model.trim="formData.name"
  22. :maxlength="50"
  23. placeholder="请输入履职内容库名称"
  24. clearable
  25. style="width: 280px"
  26. />
  27. </el-form-item>
  28. <el-form-item prop="orgType" label="履职机构类型:">
  29. <el-select
  30. style="width: 280px"
  31. prop="orgType"
  32. label="履职机构类型"
  33. v-model="formData.orgType"
  34. placeholder="请选择履职机构类型"
  35. clearable
  36. >
  37. <el-option
  38. v-for="item in orgTypeOptions"
  39. :key="item.value"
  40. :label="item.label"
  41. :value="item.value"
  42. >
  43. </el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item prop="status" label="状态:">
  47. <el-select
  48. style="width: 280px"
  49. prop="status"
  50. label="状态"
  51. v-model="formData.status"
  52. placeholder="请选择状态"
  53. clearable
  54. >
  55. <el-option
  56. v-for="item in statusOptions"
  57. :key="item.value"
  58. :label="item.label"
  59. :value="item.value"
  60. >
  61. </el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item prop="remark" label="备注">
  65. <el-input
  66. v-model="formData.remark"
  67. :maxlength="255"
  68. clearable
  69. style="width: 280px"
  70. type="textarea"
  71. :rows="3"
  72. placeholder="请输入备注"
  73. />
  74. </el-form-item>
  75. </el-form>
  76. </div>
  77. <div slot="footer" class="dialog-footer">
  78. <el-button type="primary" @click="onSubmit">确定</el-button>
  79. <el-button @click="isShow = false">取消</el-button>
  80. </div>
  81. </DialogCom>
  82. </div>
  83. </template>
  84. <script>
  85. import { mapState, mapMutations } from "vuex";
  86. import * as api from "@/api/resumption/rule";
  87. export default {
  88. data() {
  89. return {
  90. id: null,
  91. isShow: false,
  92. formData: this.reset(),
  93. formDataRules: {
  94. name: [{ required: true, message: "请输入履职内容库名称" }],
  95. type: [{ required: true, message: "请选择履职类型" }],
  96. orgType: [{ required: true, message: "请选择履职机构类型" }],
  97. status: [{ required: true, message: "请选择状态" }],
  98. },
  99. };
  100. },
  101. props: {
  102. orgTypeOptions: {
  103. type: Array,
  104. },
  105. ruleTypeOptions: {
  106. type: Array,
  107. },
  108. statusOptions: {
  109. type: Array,
  110. },
  111. },
  112. watch: {},
  113. computed: {
  114. ...mapState([]),
  115. },
  116. methods: {
  117. ...mapMutations([]),
  118. reset() {
  119. return {
  120. id: null,
  121. name: null,
  122. type: null,
  123. orgType: null,
  124. status: null,
  125. remark: null,
  126. };
  127. },
  128. async refresh(id, other) {
  129. this.formData = id ? (await api.get(id)).data : this.reset(other);
  130. },
  131. async show(id, other = {}) {
  132. this.id = id;
  133. await this.refresh(id, other);
  134. this.isShow = true;
  135. },
  136. // 事件
  137. onHide() {
  138. this.formData = this.reset();
  139. this.$refs.form.resetFields();
  140. },
  141. onSubmit() {
  142. this.$refs.form.validate(async (isValidate) => {
  143. if (!isValidate) return;
  144. await api.update(this.formData);
  145. this.$message.info("保存成功");
  146. this.$emit("success");
  147. this.isShow = false;
  148. });
  149. },
  150. // 事件
  151. //apimark//
  152. },
  153. mounted() {},
  154. components: {},
  155. };
  156. </script>
  157. <style lang="scss" scoped>
  158. .brand_info {
  159. .el-form {
  160. width: 600px;
  161. padding-top: 40px;
  162. }
  163. }
  164. </style>