Rap 原分销系统代码Web
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

137 rindas
5.1KB

  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.id" clearable placeholder="输入名称或IP搜索" 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. </div>
  13. <!--表单组件-->
  14. <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="470px">
  15. <el-form ref="form" :model="form" :rules="rules" size="small" label-width="55px">
  16. <el-form-item label="名称" prop="name">
  17. <el-input v-model="form.name" style="width: 370px" />
  18. </el-form-item>
  19. <el-form-item label="IP" prop="ip">
  20. <el-input v-model="form.ip" style="width: 370px" />
  21. </el-form-item>
  22. <el-form-item label="端口" prop="port">
  23. <el-input-number v-model.number="form.port" controls-position="right" style="width: 370px;" />
  24. </el-form-item>
  25. <el-form-item label="账号" prop="account">
  26. <el-input v-model="form.account" style="width: 370px" />
  27. </el-form-item>
  28. <el-form-item label="密码" prop="password">
  29. <el-input v-model="form.password" type="password" style="width: 200px" />
  30. <el-button :loading="loading" type="success" style="align: right;" @click="testConnectServer">测试连接</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <div slot="footer" class="dialog-footer">
  34. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  35. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
  36. </div>
  37. </el-dialog>
  38. <!--表格渲染-->
  39. <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%" @selection-change="crud.selectionChangeHandler">
  40. <el-table-column type="selection" width="55" />
  41. <el-table-column prop="name" label="名称" />
  42. <el-table-column prop="ip" label="IP" />
  43. <el-table-column prop="port" label="端口" />
  44. <el-table-column prop="account" label="账号" />
  45. <el-table-column prop="createTime" label="创建日期" />
  46. <el-table-column v-if="checkPer(['admin','serverDeploy:edit','serverDeploy:del'])" label="操作" width="150px" align="center">
  47. <template slot-scope="scope">
  48. <udOperation
  49. :data="scope.row"
  50. :permission="permission"
  51. />
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <!--分页组件-->
  56. <pagination />
  57. </div>
  58. </template>
  59. <script>
  60. import crudServer from '@/api/mnt/serverDeploy'
  61. import { testServerConnect } from '@/api/mnt/connect'
  62. import { validateIP } from '@/utils/validate'
  63. import CRUD, { presenter, header, form, crud } from '@crud/crud'
  64. import rrOperation from '@crud/RR.operation'
  65. import crudOperation from '@crud/CRUD.operation'
  66. import udOperation from '@crud/UD.operation'
  67. import pagination from '@crud/Pagination'
  68. import DateRangePicker from '@/components/DateRangePicker'
  69. const defaultForm = { id: null, name: null, ip: null, port: 22, account: 'root', password: null }
  70. export default {
  71. name: 'Server',
  72. components: { pagination, crudOperation, rrOperation, udOperation, DateRangePicker },
  73. cruds() {
  74. return CRUD({ title: '服务器', url: 'api/serverDeploy', crudMethod: { ...crudServer }})
  75. },
  76. mixins: [presenter(), header(), form(defaultForm), crud()],
  77. data() {
  78. return {
  79. accountList: [],
  80. accountMap: {},
  81. loading: false,
  82. permission: {
  83. add: ['admin', 'serverDeploy:add'],
  84. edit: ['admin', 'serverDeploy:edit'],
  85. del: ['admin', 'serverDeploy:del']
  86. },
  87. rules: {
  88. name: [
  89. { required: true, message: '请输入名称', trigger: 'blur' }
  90. ],
  91. ip: [
  92. { required: true, message: '请输入IP', trigger: 'blur' },
  93. { validator: validateIP, trigger: 'change' }
  94. ],
  95. port: [
  96. { required: true, message: '请输入端口', trigger: 'blur', type: 'number' }
  97. ],
  98. account: [
  99. { required: true, message: '请输入账号', trigger: 'blur' }
  100. ],
  101. password: [
  102. { required: true, message: '请输入密码', trigger: 'blur' }
  103. ]
  104. }
  105. }
  106. },
  107. methods: {
  108. testConnectServer() {
  109. this.$refs['form'].validate((valid) => {
  110. if (valid) {
  111. this.loading = true
  112. testServerConnect(this.form).then((res) => {
  113. this.loading = false
  114. this.$notify({
  115. title: res ? '连接成功' : '连接失败',
  116. type: res ? 'success' : 'error',
  117. duration: 2500
  118. })
  119. }).catch(() => {
  120. this.loading = false
  121. })
  122. }
  123. })
  124. }
  125. }
  126. }
  127. </script>
  128. <style rel="stylesheet/scss" lang="scss" scoped>
  129. ::v-deep .el-input-number .el-input__inner {
  130. text-align: left;
  131. }
  132. </style>