index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <a-card title="API服务中心" >
  3. <a-row>
  4. <a-col>
  5. <a-card title="分组" ></a-card>
  6. </a-col>
  7. <a-col>
  8. <a-row>
  9. <a-col>
  10. <a-space>
  11. <a-button>
  12. <a-input-search
  13. v-model:value="queryState.searchValue"
  14. @search="getAPiList"
  15. >
  16. <template #addonBefore>
  17. <select-tsx
  18. :request="async () => await searchKeys"
  19. v-model:value="queryState.searchKey"
  20. />
  21. </template>
  22. </a-input-search>
  23. </a-button>
  24. </a-space>
  25. </a-col>
  26. <a-col>
  27. <a-space>
  28. <a-button>新建API</a-button>
  29. <a-button>批量导出</a-button>
  30. <a-button>删除</a-button>
  31. <a-button>批量删除</a-button>
  32. </a-space>
  33. </a-col>
  34. </a-row>
  35. </a-col>
  36. </a-row>
  37. </a-card>
  38. <modal-pro
  39. :open="state.visible"
  40. height="300px"
  41. style="height: 300px"
  42. @cencal="state.visible = false"
  43. @ok="ok"
  44. >
  45. <a-form :labelCol="{span: 6}" :wrapperCol="{span: 14}" >
  46. <info-accordion title="API" >
  47. <a-row>
  48. <a-col>
  49. <a-form-item label="API标题" v-bind="validateInfos.serviceName" >
  50. <a-input allowClear v-model:value="apiState.serviceName" />
  51. </a-form-item>
  52. </a-col>
  53. <a-col>
  54. <a-form-item label="API标识" v-bind="validateInfos.serviceId" >
  55. <a-input allowClear v-model:value="apiState.serviceId" />
  56. </a-form-item>
  57. </a-col>
  58. <a-col>
  59. <a-form-item label="API说明" v-bind="validateInfos.serviceDesc" >
  60. <a-input allowClear v-model:value="apiState.serviceDesc" />
  61. </a-form-item>
  62. </a-col>
  63. <a-col>
  64. <a-form-item label="请求方法" v-bind="validateInfos.requestMethod" >
  65. <select-tsx :request="async () => await methodKeys" v-model:value="apiState.requestMethod" />
  66. </a-form-item>
  67. </a-col>
  68. <a-col>
  69. <a-form-item label="API类型" v-bind="validateInfos.serviceType" >
  70. <a-radio-group v-model:value="apiState.serviceType" button-style="solid">
  71. <a-radio-button :value="11">API</a-radio-button>
  72. <a-radio-button :value="12">服务编排</a-radio-button>
  73. </a-radio-group>
  74. </a-form-item>
  75. </a-col>
  76. <a-col>
  77. <a-form-item label="请求TOKEN" v-bind="validateInfos.permanentToken" >
  78. <a-input v-model:value="apiState.permanentToken" />
  79. </a-form-item>
  80. </a-col>
  81. </a-row>
  82. </info-accordion>
  83. <info-accordion title="基本信息" v-if="apiState.serviceType === 11">
  84. </info-accordion>
  85. <info-accordion title="节点配置" >
  86. </info-accordion>
  87. </a-form>
  88. </modal-pro>
  89. </template>
  90. <script setup lang="ts">
  91. import { reactive } from 'vue'
  92. import { SelectTsx } from '@/components/MicroComponents/index'
  93. import InfoAccordion from '@/components/InfoAccordion/index'
  94. import { Form } from 'ant-design-vue'
  95. const searchKeys = [
  96. {
  97. name: '标识',
  98. key: '',
  99. value: ''
  100. },
  101. {
  102. name: 'API标题',
  103. key: '',
  104. value: ''
  105. }
  106. ]
  107. const methodKeys = [
  108. {
  109. name: 'get',
  110. key: 'GET',
  111. value: 'GET'
  112. },
  113. {
  114. name: 'post',
  115. key: 'POST',
  116. value: 'POST'
  117. }
  118. ]
  119. const defaultApiData = {
  120. serviceName: '',
  121. serviceId: '',
  122. serviceDesc: '',
  123. requestMethod: '',
  124. permanentToken: '',
  125. groupKey: '',
  126. serviceType: 11,
  127. sourceName: '',
  128. targetName: '',
  129. title: '',
  130. url: '',
  131. method: 'GET',
  132. contentType: 'JSON',
  133. retry: 0,
  134. authType: 'NONE',
  135. basicUsername: '',
  136. basicPassword: '',
  137. jwtMethod: 'HS256',
  138. jwtKey: '',
  139. enableCustomInput: false,
  140. customInputMerge: false,
  141. inputMap: [],
  142. enableCustomQuery: false,
  143. customQueryMerge: false,
  144. queryMap: [],
  145. enableCustomHeader: false,
  146. customHeaderMerge: false,
  147. headerMap: [],
  148. isDownload: false,
  149. transformMerge: false,
  150. enableCustomOutput: false,
  151. outputTransform: [],
  152. enableResponseAdaptor: false,
  153. responseAdaptor: `// 支持ES6,
  154. // 仅支持原生js, 不支持导入第三方包
  155. // state: 全局根变量
  156. // js 代码里面每一行结束 要么添加换行符 要么添加 ;
  157. // 外部变量中的数组需要经过JSON.parse()处理,才可使用Map等方法,代码中自定义数组不需要JSON.parse()
  158. return responseData;`,
  159. enableCustomCa: false,
  160. httpsKey: '',
  161. httpsCert: '',
  162. reqParam: [],
  163. respParam: []
  164. }
  165. const queryState = reactive({
  166. page: 1,
  167. pageSize: 10,
  168. total: 0,
  169. searchKey: '',
  170. searchValue: ''
  171. })
  172. const state = reactive({
  173. loading: false,
  174. visible: false,
  175. dataSource: []
  176. })
  177. const apiState = reactive({ ...defaultApiData })
  178. const useForm = Form.useForm
  179. const { resetFields, validate, validateInfos } = useForm(apiState, reactive({
  180. }))
  181. const ok = () => {
  182. }
  183. const getAPiList = () => {
  184. }
  185. </script>
  186. <style>
  187. </style>