ModifyArchives.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <el-dialog
  3. class="modify-archives"
  4. :visible.sync="modalIsShow"
  5. :title="title"
  6. top="10vh"
  7. width="500px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <el-form
  14. ref="modalFormComp"
  15. :model="modalForm"
  16. :rules="rules"
  17. label-width="110px"
  18. >
  19. <el-form-item prop="archivesName" label="档案名称:">
  20. <el-input
  21. v-model.trim="modalForm.archivesName"
  22. placeholder="请输入档案名称"
  23. clearable
  24. ></el-input>
  25. </el-form-item>
  26. <el-form-item prop="archivesTypeId" label="档案类型:">
  27. <archives-type-select
  28. class="width-full"
  29. v-model="modalForm.archivesTypeId"
  30. placeholder="档案类型"
  31. >
  32. </archives-type-select>
  33. </el-form-item>
  34. <el-form-item prop="semesterId" label="所属学期:">
  35. <semester-select
  36. class="width-full"
  37. v-model="modalForm.semesterId"
  38. ></semester-select>
  39. </el-form-item>
  40. <el-form-item prop="managerId" label="档案管理员:">
  41. <archives-manage-user-select
  42. class="width-full"
  43. v-model="modalForm.managerId"
  44. placeholder="档案管理员"
  45. >
  46. </archives-manage-user-select>
  47. </el-form-item>
  48. <el-form-item prop="managerOrgId" label="档案管理部门:">
  49. <org-select
  50. class="width-full"
  51. v-model="modalForm.managerOrgId"
  52. :semesterId="modalForm.semesterId"
  53. ></org-select>
  54. </el-form-item>
  55. <el-form-item prop="warningTime" label="到期预警时间:">
  56. <el-date-picker
  57. v-model="modalForm.warningTime"
  58. type="datetime"
  59. value-format="timestamp"
  60. placeholder="请选择到期预警时间"
  61. style="width: 100%"
  62. >
  63. </el-date-picker>
  64. </el-form-item>
  65. </el-form>
  66. <div slot="footer">
  67. <el-button type="primary" :disabled="isSubmit" @click="submit"
  68. >确认</el-button
  69. >
  70. <el-button @click="cancel">取消</el-button>
  71. </div>
  72. </el-dialog>
  73. </template>
  74. <script>
  75. import { updateArchives } from "../api";
  76. const initModalForm = {
  77. id: "",
  78. archivesName: "",
  79. archivesTypeId: "",
  80. semesterId: "",
  81. managerId: "",
  82. managerOrgId: "",
  83. warningTime: undefined
  84. };
  85. export default {
  86. name: "modify-archives",
  87. props: {
  88. instance: {
  89. type: Object,
  90. default() {
  91. return {};
  92. }
  93. }
  94. },
  95. computed: {
  96. isEdit() {
  97. return !!this.instance.id;
  98. },
  99. title() {
  100. return (this.isEdit ? "编辑" : "新增") + "档案";
  101. }
  102. },
  103. data() {
  104. return {
  105. modalIsShow: false,
  106. isSubmit: false,
  107. modalForm: {},
  108. rules: {
  109. name: [
  110. {
  111. required: true,
  112. message: "请输入档案名称",
  113. trigger: "change"
  114. },
  115. {
  116. max: 100,
  117. message: "档案名称不能超过100字符",
  118. trigger: "change"
  119. }
  120. ],
  121. archivesTypeId: [
  122. {
  123. required: true,
  124. message: "请选择档案类型",
  125. trigger: "change"
  126. }
  127. ],
  128. semesterId: [
  129. {
  130. required: true,
  131. message: "请选择学期",
  132. trigger: "change"
  133. }
  134. ],
  135. managerId: [
  136. {
  137. required: true,
  138. message: "请选择档案管理员",
  139. trigger: "change"
  140. }
  141. ],
  142. managerOrgId: [
  143. {
  144. required: true,
  145. message: "请选择档案管理部门",
  146. trigger: "change"
  147. }
  148. ]
  149. },
  150. orgs: [],
  151. archivesTypes: [],
  152. adminUsers: []
  153. };
  154. },
  155. methods: {
  156. initData(val) {
  157. if (val.id) {
  158. this.modalForm = this.$objAssign(initModalForm, val);
  159. } else {
  160. this.modalForm = { ...initModalForm };
  161. this.$nextTick(() => {
  162. this.$refs.modalFormComp.clearValidate();
  163. });
  164. }
  165. },
  166. visibleChange() {
  167. this.initData(this.instance);
  168. },
  169. cancel() {
  170. this.modalIsShow = false;
  171. },
  172. open() {
  173. this.modalIsShow = true;
  174. },
  175. async submit() {
  176. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  177. if (!valid) return;
  178. if (this.isSubmit) return;
  179. this.isSubmit = true;
  180. const datas = { ...this.modalForm };
  181. const data = await updateArchives(datas).catch(() => {});
  182. this.isSubmit = false;
  183. if (!data) return;
  184. this.$message.success("修改成功!");
  185. this.cancel();
  186. this.$emit("modified");
  187. }
  188. }
  189. };
  190. </script>