Переглянути джерело

[Feature] Message Send Interface: Update Message Sending Interface

AA 11 місяців тому
батько
коміт
449bfcf405

+ 1 - 1
src/api/info.js

@@ -9,7 +9,7 @@ export function fetchTableList(data) {
 
 export function pushSave(data) {
   return request({
-    url: 'api/message/publish',
+    url: 'messageInfo/publish',
     method: 'post',
     data: data
   })

+ 1 - 1
src/api/message.js

@@ -15,6 +15,6 @@ export function pushMarkRead(id) {
 
 export function fetchRealCount() {
   return request({
-    url: '/api/message/getCount'
+    url: '/messageInfo/getCount'
   })
 }

+ 7 - 0
src/api/system.js

@@ -45,3 +45,10 @@ export function pushSaveSystem(action, data) {
     data: data
   })
 }
+
+export function pushResetSecret(id) {
+  return request({
+    url: `app/resetSecret?id=${id}`,
+    method: 'get'
+  })
+}

+ 49 - 5
src/views/system/components/DetailEdit.vue

@@ -98,8 +98,14 @@
         </el-row>
       </el-form>
       <div slot="footer">
+        <el-button v-if="action === 'update'" type="primary" @click="resetSecret">重置密钥</el-button>
         <el-button @click="close">取消</el-button>
         <el-button v-if="!isView" type="primary" @click="save">确定</el-button>
+        <div v-if="action === 'add'" style="margin-top: 10px;">
+          <span>点击【<strong>确定</strong>】按钮新增应用成功后,会在对话框内显示应用密钥,</span>
+          <br>
+          <span style="color: red;">该值仅显示这一次,请妥善保存。</span><span>如遗失请点击修改页面中的【重置密钥】按钮重新生成。</span>
+        </div>
       </div>
     </el-dialog>
   </div>
@@ -107,7 +113,7 @@
 <script>
 import { isNull, isObject, formatDictData } from '@/utils/convert'
 
-import { pushSaveSystem } from '@/api/system'
+import { pushSaveSystem, pushResetSecret } from '@/api/system'
 import { getDeptRootData, getDeptChildren, getDeptTreeData } from '@/api/dept'
 
 import UploadFile from '@/components/Upload/UploadFile'
@@ -223,6 +229,7 @@ export default {
       } else {
         this.title = '详情'
         this.isView = true
+        this.action = 'view'
       }
       this.viewType = viewType
       if (isObject(data)) {
@@ -252,10 +259,19 @@ export default {
             this.visible = false
             this.loading = false
             this.$emit('refreshData')
-            this.$message({
-              type: 'success',
-              message: '保存成功!'
-            })
+            if (this.action === 'add') {
+              this.$message({
+                type: 'success',
+                duration: 0,
+                showClose: true,
+                message: '保存成功!请保存应用密钥: ' + res.data
+              })
+            } else {
+              this.$message({
+                type: 'success',
+                message: '保存成功!'
+              })
+            }
           }).catch(error => {
             console.log(error)
             this.loading = false
@@ -269,6 +285,34 @@ export default {
         }
       })
     },
+    resetSecret() {
+      this.$confirm('确定重置密钥吗??', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.loading = true
+        pushResetSecret(this.formData.id).then(res => {
+          this.visible = false
+          this.loading = false
+          this.$message({
+            type: 'success',
+            duration: 0,
+            showClose: true,
+            message: '重置密钥成功!请保存应用密钥: ' + res.data
+          })
+        }).catch(error => {
+          console.log(error)
+          this.loading = false
+          this.$message({
+            type: 'error',
+            duration: 0,
+            showClose: true,
+            message: '重置密钥出错:' + error.message
+          })
+        })
+      }).catch(() => {})
+    },
     getDeptData() {
       const params = { fromRoot: 0 }
       getDeptTreeData(params).then(res => {