changePushKey.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div id="changepushKey" v-loading="isLoging">
  3. <el-dialog
  4. title="修改pushKey"
  5. width="42%"
  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: 18px;">
  13. <el-form ref="pushKeyForm" :rules="rules" status-icon label-width="86px">
  14. <el-form-item label="新pushKey" prop="newPushKey" >
  15. <el-input v-model="newPushKey" autocomplete="off"></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: "changePushKey",
  31. props: {},
  32. computed: {},
  33. created() {},
  34. data() {
  35. let validatePass1 = (rule, value, callback) => {
  36. if (value === '') {
  37. callback(new Error('请输入新pushKey'));
  38. } else {
  39. callback();
  40. }
  41. };
  42. return {
  43. newPushKey: null,
  44. confirmpushKey: null,
  45. userId: null,
  46. showDialog: false,
  47. isLoging: false,
  48. listChangeCallback: null,
  49. form: {},
  50. rules: {
  51. newpushKey: [{ required: true, validator: validatePass1, trigger: "blur" }],
  52. },
  53. };
  54. },
  55. methods: {
  56. openDialog: function (row, callback) {
  57. console.log(row)
  58. this.showDialog = true;
  59. this.listChangeCallback = callback;
  60. if (row != null) {
  61. this.form = row;
  62. }
  63. },
  64. onSubmit: function () {
  65. this.$axios({
  66. method: 'post',
  67. url:"/api/user/changePushKey",
  68. params: {
  69. pushKey: this.newPushKey,
  70. userId: this.form.id,
  71. }
  72. }).then((res)=> {
  73. if (res.data.code === 0) {
  74. this.$message({
  75. showClose: true,
  76. message: '修改成功',
  77. type: 'success'
  78. });
  79. this.showDialog = false;
  80. this.listChangeCallback();
  81. }else {
  82. this.$message({
  83. showClose: true,
  84. message: '修改pushKey失败,是否已登录(接口鉴权关闭无法修改pushKey)',
  85. type: 'error'
  86. });
  87. }
  88. }).catch((error)=> {
  89. console.error(error)
  90. });
  91. },
  92. close: function () {
  93. this.showDialog = false;
  94. this.newpushKey = null;
  95. this.userId=null;
  96. this.adminId=null;
  97. },
  98. },
  99. };
  100. </script>