Rap 原分销系统代码Web
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

149 wiersze
5.3KB

  1. <template>
  2. <div class="app-container">
  3. <!--工具栏-->
  4. <div class="head-container">
  5. <div v-if="crud.props.searchToggle">
  6. <!-- 搜索 -->
  7. <el-input v-model="query.blurry" clearable placeholder="模糊搜索" style="width: 200px" class="filter-item" @keyup.enter.native="crud.toQuery" />
  8. <date-range-picker v-model="query.createTime" class="date-item" />
  9. <rrOperation />
  10. </div>
  11. <crudOperation :permission="permission">
  12. <el-button
  13. slot="right"
  14. v-permission="['admin','database:add']"
  15. :disabled="!selectIndex"
  16. class="filter-item"
  17. size="mini"
  18. type="warning"
  19. icon="el-icon-upload"
  20. @click="execute"
  21. >执行脚本
  22. </el-button>
  23. </crudOperation>
  24. </div>
  25. <!--表单组件-->
  26. <eForm ref="execute" :database-info="currentRow" />
  27. <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="530px">
  28. <el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
  29. <el-form-item label="连接名称" prop="name">
  30. <el-input v-model="form.name" style="width: 370px" />
  31. </el-form-item>
  32. <el-form-item label="JDBC地址" prop="jdbcUrl">
  33. <el-input v-model="form.jdbcUrl" style="width: 300px" />
  34. <el-button :loading="loading" type="success" @click="testConnectDatabase">测试</el-button>
  35. </el-form-item>
  36. <el-form-item label="用户" prop="userName">
  37. <el-input v-model="form.userName" style="width: 370px" />
  38. </el-form-item>
  39. <el-form-item label="密码" prop="pwd">
  40. <el-input v-model="form.pwd" type="password" style="width: 370px" />
  41. </el-form-item>
  42. </el-form>
  43. <div slot="footer" class="dialog-footer">
  44. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  45. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
  46. </div>
  47. </el-dialog>
  48. <!--表格渲染-->
  49. <el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row stripe style="width: 100%" @selection-change="handleCurrentChange">
  50. <el-table-column type="selection" width="55" />
  51. <el-table-column prop="name" width="130px" label="数据库名称" />
  52. <el-table-column prop="jdbcUrl" label="连接地址" />
  53. <el-table-column prop="userName" width="200px" label="用户名" />
  54. <el-table-column prop="createTime" width="200px" label="创建日期" />
  55. <el-table-column v-if="checkPer(['admin','database:edit','database:del'])" label="操作" width="150px" align="center">
  56. <template slot-scope="scope">
  57. <udOperation
  58. :data="scope.row"
  59. :permission="permission"
  60. />
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <!--分页组件-->
  65. <pagination />
  66. </div>
  67. </template>
  68. <script>
  69. import crudDatabase from '@/api/mnt/database'
  70. import { testDbConnect } from '@/api/mnt/connect'
  71. import eForm from './execute'
  72. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  73. import rrOperation from '@crud/RR.operation'
  74. import crudOperation from '@crud/CRUD.operation'
  75. import udOperation from '@crud/UD.operation'
  76. import pagination from '@crud/Pagination'
  77. import DateRangePicker from '@/components/DateRangePicker'
  78. const defaultForm = { id: null, name: null, jdbcUrl: 'jdbc:mysql://', userName: null, pwd: null }
  79. export default {
  80. name: 'DataBase',
  81. components: { eForm, pagination, crudOperation, rrOperation, udOperation, DateRangePicker },
  82. cruds() {
  83. return CRUD({ title: '数据库', url: 'api/database', crudMethod: { ...crudDatabase }})
  84. },
  85. mixins: [presenter(), header(), form(defaultForm), crud()],
  86. data() {
  87. return {
  88. currentRow: {},
  89. selectIndex: '',
  90. databaseInfo: '',
  91. loading: false,
  92. permission: {
  93. add: ['admin', 'database:add'],
  94. edit: ['admin', 'database:edit'],
  95. del: ['admin', 'database:del']
  96. },
  97. rules: {
  98. name: [
  99. { required: true, message: '请输入数据库名称', trigger: 'blur' }
  100. ],
  101. jdbcUrl: [
  102. { required: true, message: '请输入数据库连接地址', trigger: 'blur' }
  103. ],
  104. userName: [
  105. { required: true, message: '请输入用户名', trigger: 'blur' }
  106. ],
  107. pwd: [
  108. { required: true, message: '请输入数据库密码', trigger: 'blur' }
  109. ]
  110. }
  111. }
  112. },
  113. methods: {
  114. testConnectDatabase() {
  115. this.$refs['form'].validate((valid) => {
  116. if (valid) {
  117. this.loading = true
  118. testDbConnect(this.form).then((res) => {
  119. this.loading = false
  120. this.crud.notify(res ? '连接成功' : '连接失败', res ? 'success' : 'error')
  121. }).catch(() => {
  122. this.loading = false
  123. })
  124. }
  125. })
  126. },
  127. execute() {
  128. this.$refs.execute.dialog = true
  129. },
  130. handleCurrentChange(selection) {
  131. this.crud.selections = selection
  132. if (selection.length === 1) {
  133. const row = selection[0]
  134. this.selectIndex = row.id
  135. this.currentRow = row
  136. } else {
  137. this.currentRow = {}
  138. this.selectIndex = ''
  139. }
  140. }
  141. }
  142. }
  143. </script>
  144. <style scoped>
  145. </style>