index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <script lang="ts">
  2. // 声明额外的选项
  3. export default {
  4. name: "Edit"
  5. };
  6. </script>
  7. <script setup lang="ts">
  8. import { inject, onMounted, reactive, ref, Uploadfile, UploadImg, Editor, useRenderIcon, ElMessage, ElMessageBox, Upload, Close, http, getGroupUrl, RegularVerification, verification } from "@/utils/importUsed"
  9. // 接口列表实例
  10. let UrlList = reactive(null)
  11. // 获取当前板块接口列表
  12. onMounted(async () => {
  13. UrlList = await getGroupUrl(["kxsConfigServer"]);
  14. })
  15. const props = defineProps<{
  16. editVisible: {
  17. type: Boolean;
  18. default: false;
  19. };
  20. width: {
  21. type: Number;
  22. default: 50;
  23. };
  24. formData: {
  25. id: any;
  26. type: any;
  27. default: {};
  28. };
  29. }>();
  30. // 表单数据
  31. const UpdateForm: any = ref({
  32. id: "", //ID
  33. version: "", //版本号
  34. });
  35. // 表单实例
  36. const ruleFormRef = ref()
  37. // 选项卡参数(默认值为列表某项的id)
  38. const activeId = ref('1')
  39. // 提交函数
  40. const submit = async (formEl) => {
  41. // 表单校验拦截
  42. if (!formEl) return
  43. await formEl.validate(async (valid, fields) => {
  44. if (valid) {
  45. //表单校验成功回调
  46. console.log('submit!')
  47. // 需动态生成接口
  48. const { status, msg }: any = await http.Request({
  49. method: UrlList.kxsConfigServer.apiInfosetVersion.method,
  50. url: UrlList.kxsConfigServer.apiInfosetVersion.url,
  51. params: UpdateForm.value
  52. });
  53. if (status === 1) {
  54. //业务成功回调
  55. ElMessage({
  56. message: "修改成功",
  57. type: "success"
  58. });
  59. UpdateForm.value = {
  60. id: "", //ID
  61. version: "", //版本号
  62. };
  63. // 关闭修改弹窗;
  64. closeSetVersionVisible();
  65. } else {
  66. //业务失败回调
  67. ElMessageBox.alert(msg, "提示", {
  68. confirmButtonText: "关闭",
  69. type: "warning"
  70. });
  71. }
  72. } else {
  73. //表单校验失败回调
  74. ElMessage({
  75. message: "请输入完整信息",
  76. type: "error"
  77. });
  78. }
  79. })
  80. };
  81. // 表单校验规则
  82. const rules = reactive({
  83. })
  84. // 关闭弹窗回调函数
  85. const closeFn: any = inject('closeEditSetVersionVisible');
  86. const openVisible = async () => {
  87. //通过ID获取表格数据
  88. const { status, data }: any = await http.Request({ method: UrlList.kxsConfigServer.apiInfoquery.method, url: UrlList.kxsConfigServer.apiInfoquery.url, params: { id: props.formData.id }});
  89. if (status === 1) {
  90. UpdateForm.value = data;
  91. }
  92. };
  93. // 关闭弹窗回调函数
  94. const closeSetVersionVisible = () => {
  95. UpdateForm.value = {
  96. id: "", //ID
  97. version: "", //版本号
  98. };
  99. closeFn();
  100. };
  101. </script>
  102. <template lang="pug">
  103. .main
  104. el-dialog(v-model='props.editVisible' width="50%" title="修改" @close="closeSetVersionVisible()" @open="openVisible")
  105. el-form(:model='UpdateForm' label-position="right" ref="ruleFormRef" :rules="rules" label-width="100px")
  106. el-form-item(label='ID' prop="id")
  107. el-input-number(v-model='UpdateForm.id' :min="1" :max="1000"
  108. placeholder="请输入ID")
  109. el-form-item(label='版本号' prop="version")
  110. el-input-number(v-model='UpdateForm.version' :min="1" :max="1000"
  111. placeholder="请输入版本号")
  112. el-button(
  113. :icon="useRenderIcon(Close)",
  114. :loading="loading",
  115. @click="closeSetVersionVisible()"
  116. ) 关闭
  117. el-button(
  118. type="primary",
  119. :icon="useRenderIcon(Upload)",
  120. @click="submit(ruleFormRef)"
  121. ) 确认提交
  122. </template>
  123. <style scoped lang="scss">
  124. :deep(.el-dropdown-menu__item i) {
  125. margin: 0;
  126. }
  127. :deep(.el-form-item__label) {
  128. font-weight: 700;
  129. }
  130. :deep(.el-pagination) {
  131. flex-flow: wrap;
  132. }
  133. :deep(.is-draggable) {
  134. max-height: 80vh;
  135. overflow: auto;
  136. }
  137. :deep(.el-dialog__header) {
  138. position: sticky;
  139. top: 0;
  140. z-index: 2;
  141. background: #fff;
  142. }
  143. .collapsedom {
  144. padding: 0 20px;
  145. background-color: #fff;
  146. }
  147. .ovh-x {
  148. height: 40vh;
  149. overflow-y: auto;
  150. }
  151. :deep(.el-descriptions__header) {
  152. margin: 16px 0 !important;
  153. }
  154. </style>