datasource.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud
  21. ref="data-source-settings-crud"
  22. v-model="dsForm"
  23. :page="dsPage"
  24. :data="tableDsData"
  25. :option="tableDsOption"
  26. :before-open="handleOpenBefore"
  27. @row-update="handleUpdate"
  28. @row-save="handleSave"
  29. @row-del="rowDel"
  30. @size-change="sizeChange"
  31. @current-change="currentChange"
  32. @refresh-change="refreshDsChange"
  33. @on-load="getDsList"/>
  34. </basic-container>
  35. </div>
  36. </template>
  37. <script>
  38. import {addObj, delObj, fetchDsList, putObj} from '@/api/gen/gen'
  39. import {formOption, tableDsOption, tableOption} from '@/const/crud/gen/gen'
  40. export default {
  41. name: 'CodeGenerator',
  42. data() {
  43. return {
  44. dataSourceList: [],
  45. tableDsData: [],
  46. box: false,
  47. dsPage: {
  48. total: 0, // 总页数
  49. currentPage: 1, // 当前页数
  50. pageSize: 20 // 每页显示多少条
  51. },
  52. dsForm: {},
  53. tableLoading: false,
  54. tableOption: tableOption,
  55. tableDsOption: tableDsOption,
  56. formOption: formOption
  57. }
  58. },
  59. created() {
  60. },
  61. methods: {
  62. rowDel: function (row, index) {
  63. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  64. confirmButtonText: '确定',
  65. cancelButtonText: '取消',
  66. type: 'warning'
  67. }).then(function () {
  68. return delObj(row.id)
  69. }).then(() => {
  70. this.$message.success('删除成功')
  71. this.getDsList(this.dsPage)
  72. })
  73. },
  74. handleOpenBefore: function (show) {
  75. this.dsForm.password = undefined
  76. show()
  77. },
  78. handleUpdate: function (row, index, done) {
  79. putObj(row).then(res => {
  80. if (res.data.data){
  81. this.$message.success('修改成功')
  82. }else {
  83. this.$message.error('修改失败,数据源不可访问')
  84. }
  85. done()
  86. this.getDsList(this.dsPage)
  87. })
  88. },
  89. handleSave: function (row, done) {
  90. addObj(row).then(res => {
  91. if (res.data.data){
  92. this.$message.success('添加成功')
  93. }else {
  94. this.$message.error('添加失败,数据源不可访问')
  95. }
  96. done()
  97. this.getDsList(this.dsPage)
  98. })
  99. },
  100. getDsList(page, params) {
  101. fetchDsList(Object.assign({
  102. current: page.currentPage,
  103. size: page.pageSize
  104. }, params)).then(response => {
  105. this.tableDsData = response.data.data.records
  106. this.dsPage.total = response.data.data.total
  107. })
  108. },
  109. sizeChange(pageSize) {
  110. this.page.pageSize = pageSize
  111. },
  112. currentChange(current) {
  113. this.page.currentPage = current
  114. },
  115. refreshDsChange() {
  116. this.getDsList(this.dsPage)
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. </style>