remarkUserApiKey.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div id="remarkUserApiKey" v-loading="isLoading">
  3. <el-dialog
  4. title="ApiKey备注"
  5. width="40%"
  6. top="2rem"
  7. :close-on-click-modal="false"
  8. :visible.sync="showDialog"
  9. :destroy-on-close="true"
  10. @close="close()"
  11. >
  12. <div id="shared" style="margin-right: 20px;">
  13. <el-form ref="form" :rules="rules" status-icon label-width="80px">
  14. <el-form-item label="备注" prop="oldPassword">
  15. <el-input type="textarea" v-model="form.remark" autocomplete="off" :autosize="{ minRows: 5}" maxlength="255" show-word-limit></el-input>
  16. </el-form-item>
  17. <el-form-item>
  18. <div style="float: right;">
  19. <el-button type="primary" @click="onSubmit">保存</el-button>
  20. <el-button @click="close">取消</el-button>
  21. </div>
  22. </el-form-item>
  23. </el-form>
  24. </div>
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. name: "remarkUserApiKey",
  31. props: {},
  32. computed: {},
  33. created() {
  34. },
  35. data() {
  36. return {
  37. userApiKeyId: null,
  38. form: {
  39. remark: null
  40. },
  41. rules: {},
  42. listChangeCallback: null,
  43. showDialog: false,
  44. isLoading: false
  45. };
  46. },
  47. methods: {
  48. resetForm() {
  49. this.form = {
  50. remark: null
  51. }
  52. },
  53. openDialog(userApiKeyId, callback) {
  54. this.resetForm()
  55. this.userApiKeyId = userApiKeyId
  56. this.listChangeCallback = callback
  57. this.showDialog = true
  58. },
  59. onSubmit() {
  60. this.$axios({
  61. method: 'post',
  62. url: "/api/userApiKey/remark",
  63. params: {
  64. id: this.userApiKeyId,
  65. remark: this.form.remark
  66. }
  67. }).then((res) => {
  68. if (res.data.code === 0) {
  69. this.$message({
  70. showClose: true,
  71. message: '备注修改成功!',
  72. type: 'success'
  73. });
  74. this.showDialog = false;
  75. this.listChangeCallback()
  76. } else {
  77. this.$message({
  78. showClose: true,
  79. message: '备注修改失败',
  80. type: 'error'
  81. });
  82. }
  83. }).catch((error) => {
  84. console.error(error)
  85. });
  86. },
  87. close() {
  88. this.showDialog = false
  89. },
  90. },
  91. };
  92. </script>