system-func.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <el-row style="text-align: center">
  3. <el-col :span="4">
  4. <el-button type="primary" @click="toMethod('initES')">{{ $t('pages.systemFunc.initES') }}</el-button>
  5. </el-col>
  6. <el-col :span="4">
  7. <el-button type="primary" @click="toMethod('cid')">{{ $t('pages.systemFunc.cid') }}</el-button>
  8. </el-col>
  9. <el-col :span="4">
  10. <el-button type="primary" @click="toMethod('ism')">{{ $t('pages.systemFunc.ism') }}</el-button>
  11. </el-col>
  12. <el-col :span="4">
  13. <el-button type="primary" @click="toMethod('ium')">{{ $t('pages.systemFunc.ium') }}</el-button>
  14. </el-col>
  15. <el-col :span="4">
  16. <el-button type="primary" @click="toMethod('ir')">{{ $t('pages.systemFunc.ir') }}</el-button>
  17. </el-col>
  18. <el-col :span="4">
  19. <el-button type="primary" @click="toMethod('irm')">{{ $t('pages.systemFunc.irm') }}</el-button>
  20. </el-col>
  21. <el-col :span="4">
  22. <el-button type="primary" @click="toMethod('dbBackUp')">数据库备份</el-button>
  23. </el-col>
  24. <el-col :span="4">
  25. <el-button type="primary" @click="toMethod('dbRestore')">数据库还原</el-button>
  26. </el-col>
  27. </el-row>
  28. </template>
  29. <script setup>
  30. import { ElMessage, ElMessageBox } from 'element-plus'
  31. import { SystemFuncStore } from '@/store/api/systemFunc'
  32. const $checkRes = inject('$checkRes')
  33. const store = SystemFuncStore()
  34. const toMethod = async (method) => {
  35. let res
  36. switch (method) {
  37. case 'initES':
  38. res = await store.initES()
  39. $checkRes(res, true, res.errmsg)
  40. break
  41. case 'cid':
  42. res = await store.correctImportData()
  43. $checkRes(res, true, res.errmsg)
  44. break
  45. case 'ism':
  46. res = await store.initSystemMenus()
  47. $checkRes(res, true, res.errmsg)
  48. break
  49. case 'ium':
  50. res = await store.initUserMenus()
  51. $checkRes(res, true, res.errmsg)
  52. break
  53. case 'ir':
  54. res = await store.initRoleData()
  55. $checkRes(res, true, res.errmsg)
  56. break
  57. case 'irm':
  58. res = await store.initRoleMenus()
  59. $checkRes(res, true, res.errmsg)
  60. break
  61. case 'dbBackUp':
  62. res = await store.dbBackUp()
  63. $checkRes(res, true, res.errmsg)
  64. break
  65. case 'dbRestore':
  66. // 需要输入还原文件夹
  67. ElMessageBox.prompt('请输入json文件所在目录地址,默认地址为备份地址', '数据库还原', {
  68. confirmButtonText: '确认',
  69. cancelButtonText: '取消'
  70. })
  71. .then(async ({ value }) => {
  72. res = await store.dbRestore(value)
  73. console.log(res)
  74. $checkRes(res, true, res.errmsg)
  75. })
  76. .catch(() => {})
  77. //
  78. break
  79. default:
  80. break
  81. }
  82. }
  83. </script>
  84. <style scoped>
  85. .el-col {
  86. margin-top: 10px;
  87. }
  88. </style>