index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <route lang="yaml">
  2. meta:
  3. enabled: false
  4. </route>
  5. <script lang="ts" setup name="PagesExampleTable">
  6. import type { FormInstance } from 'element-plus'
  7. import ModelObjectSelector from './components/ModelObjectSelector.vue'
  8. import useSettingsStore from '@/store/modules/settings'
  9. import { getApiById } from '@/api/paas/apiApi'
  10. import { getAtuByList } from '@/api/paas/apiTransUnitApi'
  11. const settingsStore = useSettingsStore()
  12. const route = useRoute()
  13. const router = useRouter()
  14. const tabbar = useTabbar()
  15. const modId = parseInt(route.params.modId.toString())
  16. const apiId = parseInt(route.params.apiId.toString())
  17. const state = reactive({
  18. loading: false,
  19. apiTitle: '',
  20. apiCode: '',
  21. keywords: '',
  22. atuList: [],
  23. dialogState: 1,
  24. search: {
  25. apiId,
  26. keywords: '',
  27. },
  28. data: '',
  29. result: '',
  30. })
  31. const ModelObjectSelectorRef = ref()
  32. const getAtuData = async () => {
  33. const { data } = await getAtuByList(state.search)
  34. state.atuList = data
  35. state.loading = false
  36. }
  37. // 查询数据
  38. const getData = async () => {
  39. state.loading = true
  40. const { data } = await getApiById(modId, apiId)
  41. state.apiTitle = data.apiTitle
  42. state.apiCode = data.apiCode
  43. await getAtuData()
  44. }
  45. onMounted(() => {
  46. getData()
  47. })
  48. const formRef = ref<FormInstance>()
  49. const onAdd = () => {
  50. ModelObjectSelectorRef.value.showModel()
  51. }
  52. const onEdit = (data: { atuId: number }) => {
  53. window.console.log(data.atuId)
  54. }
  55. const onDelete = (data: { atuId: number }) => {
  56. window.console.log(data.atuId)
  57. }
  58. const onGenerateData = () => {
  59. state.result = '生成参数'
  60. }
  61. const onExecute = () => {
  62. }
  63. // 选择对象模型回调
  64. const onObjectSel = (data: any) => {
  65. window.console.log('onObjectSel', data)
  66. }
  67. // function onCancel() {
  68. // goBack()
  69. // }
  70. // 返回列表页
  71. function goBack() {
  72. if (settingsStore.settings.tabbar.enable && settingsStore.settings.tabbar.mergeTabsBy !== 'activeMenu') {
  73. tabbar.close({ name: 'paas_api' })
  74. }
  75. else {
  76. router.push({ name: 'paas_api' })
  77. }
  78. }
  79. </script>
  80. <template>
  81. <div class="absolute-container">
  82. <page-header :title="state.apiTitle">
  83. <el-button size="default" round @click="goBack">
  84. <template #icon>
  85. <el-icon>
  86. <svg-icon name="i-ep:arrow-left" />
  87. </el-icon>
  88. </template>
  89. 返回
  90. </el-button>
  91. </page-header>
  92. <div class="page-main">
  93. <LayoutContainer left-side-width="520px" hide-left-side-toggle>
  94. <template #leftSide>
  95. <el-space wrap>
  96. <el-button type="primary" size="default" @click="onAdd">
  97. <template #icon>
  98. <el-icon>
  99. <svg-icon name="i-ep:plus" />
  100. </el-icon>
  101. </template>
  102. </el-button>
  103. </el-space>
  104. <el-table v-loading="state.loading" class="list-table" :data="state.atuList" border stripe highlight-current-row height="100%">
  105. <el-table-column prop="atuTitle" label="名称" min-width="150px" />
  106. <el-table-column label="操作" width="140" align="center" fixed="right">
  107. <template #default="scope">
  108. <el-button-group>
  109. <el-button type="primary" size="small" plain @click="onEdit(scope.row)">
  110. <template #icon>
  111. <el-icon>
  112. <svg-icon name="i-ep:edit" />
  113. </el-icon>
  114. </template>
  115. </el-button>
  116. <el-button type="danger" size="small" plain @click="onDelete(scope.row)">
  117. <template #icon>
  118. <el-icon>
  119. <svg-icon name="i-ep:delete" />
  120. </el-icon>
  121. </template>
  122. </el-button>
  123. </el-button-group>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. </template>
  128. <div class="form">
  129. <tool-header>
  130. <template #right>
  131. <el-button type="primary" @click="onGenerateData">
  132. 生成参数
  133. </el-button>
  134. </template>
  135. </tool-header>
  136. <el-form ref="formRef" label-width="100px" label-position="top">
  137. <el-form-item label="数据参数" prop="code">
  138. <el-input v-model="state.data" type="textarea" rows="10" placeholder="数据" />
  139. </el-form-item>
  140. <el-form-item v-if="state.result" label="生成参数" prop="code">
  141. <el-input v-model="state.result" type="textarea" rows="10" placeholder="数据" readonly />
  142. </el-form-item>
  143. <div class="action-bottom">
  144. <el-button type="primary" @click="onExecute">
  145. 立即执行
  146. </el-button>
  147. </div>
  148. </el-form>
  149. <ModelObjectSelector ref="ModelObjectSelectorRef" @on-object-sel="onObjectSel" />
  150. </div>
  151. </LayoutContainer>
  152. </div>
  153. </div>
  154. </template>
  155. <style lang="scss" scoped>
  156. .absolute-container {
  157. position: absolute;
  158. width: 100%;
  159. height: 100%;
  160. display: flex;
  161. flex-direction: column;
  162. .page-header {
  163. margin-bottom: 0;
  164. }
  165. .page-main {
  166. // 让 page-main 的高度自适应
  167. flex: 1;
  168. overflow: auto;
  169. display: flex;
  170. flex-direction: column;
  171. .flex-container {
  172. position: static;
  173. :deep(.left-side) {
  174. overflow: auto;
  175. display: flex;
  176. flex-direction: column;
  177. }
  178. :deep(.main-container) {
  179. height: 100%;
  180. display: flex;
  181. flex-direction: column;
  182. .empty {
  183. flex: 1;
  184. display: flex;
  185. align-items: center;
  186. justify-content: center;
  187. font-size: 32px;
  188. color: var(--el-text-color-placeholder);
  189. }
  190. }
  191. }
  192. .form {
  193. flex: 1;
  194. min-height: 0;
  195. display: flex;
  196. flex-direction: column;
  197. .el-form {
  198. flex: 1;
  199. min-height: 0;
  200. display: flex;
  201. flex-direction: column;
  202. .columns-table {
  203. flex: 1;
  204. height: 0;
  205. display: flex;
  206. flex-direction: column;
  207. :deep(.el-form-item__content) {
  208. min-height: 0;
  209. .el-table {
  210. height: 100%;
  211. }
  212. }
  213. }
  214. }
  215. .action-bottom {
  216. padding-top: 2px;
  217. text-align: center;
  218. }
  219. .el-table {
  220. .el-table__row {
  221. .index {
  222. display: inline-block;
  223. }
  224. .delete {
  225. display: none;
  226. }
  227. &:hover {
  228. .index {
  229. display: none;
  230. }
  231. .delete {
  232. display: inline-block;
  233. }
  234. }
  235. .el-tag.sortable,
  236. .el-tag.sortable .el-icon {
  237. cursor: s-resize;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. }
  244. </style>