index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <script lang="ts">
  2. // 声明额外的选项
  3. export default {
  4. name: "Add"
  5. };
  6. </script>
  7. <script setup lang="ts">
  8. import { inject, ref } from "vue";
  9. import { useRenderIcon } from "@/components/ReIcon/src/hooks";
  10. import { ElMessage, ElMessageBox } from "element-plus";
  11. import { http } from "@/utils/http";
  12. // 获取当前板块接口列表
  13. import Upload from "@iconify-icons/ri/upload-2-fill";
  14. import Close from "@iconify-icons/ri/close-fill";
  15. // 获取URLLIST
  16. import { getGroupUrl } from "@/utils/getUrl/getUrl";
  17. const props = defineProps<{
  18. submit: {
  19. type: Function;
  20. default: () => {};
  21. };
  22. addVisible: {
  23. type: Boolean;
  24. default: false;
  25. };
  26. width: {
  27. type: Number;
  28. default: 50;
  29. };
  30. }>();
  31. // 表单数据
  32. let UpdateForm = ref({
  33. groupId: "", //分组
  34. apiName: "", //接口名称
  35. apiKey: "", //接口关键字
  36. apiHost: "", //接口主机头
  37. apiPort: "", //接口端口号
  38. apiRouter: "", //接口路由
  39. apiMethod: "", //接口请求方式
  40. });
  41. // 分组选项数据
  42. let groupIdOptionList = []
  43. // 选项卡参数(默认值为列表某项的id)
  44. const activeId = ref('1')
  45. // 提交函数
  46. const submit = async () => {
  47. const UrlList = await getGroupUrl(['kxsConfigServer']);
  48. const { status, msg }: any = await http.Request({ method: UrlList.kxsConfigServer.apiInfoadd.method, url: UrlList.kxsConfigServer.apiInfoadd.url, params: UpdateForm.value });
  49. if (status === 1) {
  50. ElMessage({
  51. message: "新增成功",
  52. type: "success"
  53. });
  54. UpdateForm.value = {
  55. groupId: "", //分组
  56. apiName: "", //接口名称
  57. apiKey: "", //接口关键字
  58. apiHost: "", //接口主机头
  59. apiPort: "", //接口端口号
  60. apiRouter: "", //接口路由
  61. apiMethod: "", //接口请求方式
  62. };
  63. closeVisible();
  64. } else {
  65. ElMessageBox.alert(msg, "提示", {
  66. confirmButtonText: "关闭",
  67. type: "warning"
  68. });
  69. };
  70. };
  71. //获取分组数据
  72. const apiInfoquery = async () => {
  73. //通过ID获取表格数据
  74. const UrlList = await getGroupUrl(['kxsConfigServer']);
  75. const { status, data }: any = await http.Request({ method: UrlList.kxsConfigServer.apiGroupselectList.method, url: UrlList.kxsConfigServer.apiGroupselectList.url, params: {} });
  76. if (status === 1) {
  77. groupIdOptionList = data.records;
  78. }
  79. };
  80. apiInfoquery();
  81. const closeFn: any = inject('closeAddVisible');
  82. // 关闭弹窗回调函数
  83. const closeVisible = () => {
  84. UpdateForm.value = {
  85. groupId: "", //分组
  86. apiName: "", //接口名称
  87. apiKey: "", //接口关键字
  88. apiHost: "", //接口主机头
  89. apiPort: "", //接口端口号
  90. apiRouter: "", //接口路由
  91. apiMethod: "", //接口请求方式
  92. };
  93. closeFn();
  94. };
  95. </script>
  96. <template lang="pug">
  97. .main
  98. el-dialog(v-model='props.addVisible' width="50%" title="新增" @close="closeVisible()")
  99. el-form(:model='UpdateForm' label-position="right" label-width="100px")
  100. el-form-item(label="分组", prop="groupId")
  101. el-select(
  102. v-model="UpdateForm.groupId",
  103. placeholder="请选择分组",
  104. clearable,
  105. class="!w-[230px]"
  106. )
  107. el-option(:label="item.groupName", :value="item.id" v-for="(item,index) in groupIdOptionList")
  108. el-form-item(label='接口名称' prop="apiName")
  109. el-input(v-model='UpdateForm.apiName' autocomplete='off' class="!w-[230px]"
  110. placeholder="请输入接口名称")
  111. el-form-item(label='接口关键字' prop="apiKey")
  112. el-input(v-model='UpdateForm.apiKey' autocomplete='off' class="!w-[230px]"
  113. placeholder="请输入接口关键字")
  114. el-form-item(label='接口主机头' prop="apiHost")
  115. el-input(v-model='UpdateForm.apiHost' autocomplete='off' class="!w-[230px]"
  116. placeholder="请输入接口主机头")
  117. el-form-item(label='接口端口号' prop="apiPort")
  118. el-input-number(v-model='UpdateForm.apiPort' :min="1" :max="1000"
  119. placeholder="请输入接口端口号")
  120. el-form-item(label='接口路由' prop="apiRouter")
  121. el-input(v-model='UpdateForm.apiRouter' autocomplete='off' class="!w-[230px]"
  122. placeholder="请输入接口路由")
  123. el-form-item(label='接口请求方式' prop="apiMethod")
  124. el-input(v-model='UpdateForm.apiMethod' autocomplete='off' class="!w-[230px]"
  125. placeholder="请输入接口请求方式")
  126. el-button(
  127. :icon="useRenderIcon(Close)",
  128. :loading="loading",
  129. @click="closeVisible()"
  130. ) 关闭
  131. el-button(
  132. type="primary",
  133. :icon="useRenderIcon(Upload)",
  134. :loading="loading",
  135. @click="submit"
  136. ) 确认提交
  137. </template>
  138. <style scoped lang="scss">
  139. :deep(.el-dropdown-menu__item i) {
  140. margin: 0;
  141. }
  142. :deep(.el-form-item__label) {
  143. font-weight: 700;
  144. }
  145. :deep(.el-pagination) {
  146. flex-flow: wrap;
  147. }
  148. :deep(.is-draggable) {
  149. max-height: 80vh;
  150. overflow: auto;
  151. }
  152. :deep(.el-dialog__header) {
  153. position: sticky;
  154. top: 0;
  155. z-index: 2;
  156. background: #fff;
  157. }
  158. .collapsedom {
  159. padding: 0 20px;
  160. background-color: #fff;
  161. }
  162. .ovh-x {
  163. height: 40vh;
  164. overflow-y: auto;
  165. }
  166. :deep(.el-descriptions__header) {
  167. margin: 16px 0 !important;
  168. }
  169. </style>