index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <avue-crud
  3. :data="logsList"
  4. :option="option">
  5. <template slot="menuLeft">
  6. <el-button
  7. type="primary"
  8. size="mini"
  9. icon="el-icon-upload"
  10. @click="send">上传服务器</el-button>
  11. <el-button
  12. type="danger"
  13. size="mini"
  14. icon="el-icon-delete"
  15. @click="clear">清空本地日志</el-button>
  16. </template>
  17. <template
  18. slot-scope="scope"
  19. slot="type">
  20. <el-tag
  21. type="danger"
  22. size="mini">{{ scope.label }}</el-tag>
  23. </template>
  24. <template
  25. slot-scope="props"
  26. slot="expand">
  27. <pre class="code">
  28. {{ props.row.stack }}
  29. </pre>
  30. </template>
  31. </avue-crud>
  32. </template>
  33. <script>
  34. import { mapGetters } from 'vuex'
  35. import option from '@/const/logs/index'
  36. export default {
  37. name: 'ErrLogs',
  38. data() {
  39. return {
  40. option: option
  41. }
  42. },
  43. created() {
  44. },
  45. mounted() { },
  46. computed: {
  47. ...mapGetters(['logsList'])
  48. },
  49. methods: {
  50. send() {
  51. this.$confirm('确定上传本地日志到服务器?', '提示', {
  52. confirmButtonText: '确定',
  53. cancelButtonText: '取消',
  54. type: 'warning'
  55. }).then(() => {
  56. this.$store.dispatch('SendLogs').then(() => {
  57. this.$parent.$parent.box = false
  58. this.$message({
  59. type: 'success',
  60. message: '发送成功!'
  61. })
  62. })
  63. }).catch(() => {
  64. })
  65. },
  66. clear() {
  67. this.$confirm('确定清空本地日志记录?', '提示', {
  68. confirmButtonText: '确定',
  69. cancelButtonText: '取消',
  70. type: 'warning'
  71. }).then(() => {
  72. this.$store.commit('CLEAR_LOGS')
  73. this.$parent.$parent.box = false
  74. this.$message({
  75. type: 'success',
  76. message: '清空成功!'
  77. })
  78. }).catch(() => {
  79. })
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .code {
  86. font-size: 12px;
  87. display: block;
  88. font-family: monospace;
  89. white-space: pre;
  90. margin: 1em 0px;
  91. }
  92. </style>