ソースを参照

添加商户授权

hjs 1 年間 前
コミット
b3e47b66b9
2 ファイル変更70 行追加2 行削除
  1. 7 0
      src/api/merchant.js
  2. 63 2
      src/views/merchant/index.vue

+ 7 - 0
src/api/merchant.js

@@ -30,3 +30,10 @@ export function deleteById(id) {
     method: 'get'
   })
 }
+
+export function updateStatusById(id, status = false) {
+  return request({
+    url: `/api/v1/tenant/auth${status ? '' : '/cancel'}/${id}`,
+    method: 'post'
+  })
+}

+ 63 - 2
src/views/merchant/index.vue

@@ -43,7 +43,19 @@
           {{ scope.row.serviceAppId }}
         </template>
       </el-table-column>
-      <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
+      <el-table-column label="授权token">
+        <template slot-scope="scope">
+          {{ scope.row.appAuthToken }}
+        </template>
+      </el-table-column>
+      <el-table-column label="状态" align="center" class-name="status-col" width="100">
+        <template slot-scope="{row}">
+          <el-tag :type="row.appAuthTokenStatus | statusFilter">
+            {{ row.appAuthTokenStatus | statusFilterStr }}
+          </el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width">
         <template slot-scope="{row,$index}">
           <el-button type="primary" size="mini" @click="handleUpdate(row)">
             编辑
@@ -51,6 +63,10 @@
           <el-button size="mini" type="danger" @click="handleDelete(row, $index)">
             删除
           </el-button>
+          <template>
+            <el-button v-if="row.appAuthTokenStatus" size="mini" type="danger" @click="statusChange(row, false)">停用</el-button>
+            <el-button v-else size="mini" type="danger" @click="statusChange(row, true)">启用</el-button>
+          </template>
         </template>
       </el-table-column>
     </el-table>
@@ -68,11 +84,19 @@
 <script>
 import AddModal from './modal/AddModal.vue'
 import tableMixins from '@/mixins/tableMixins'
-import { getList, deleteById } from '@/api/merchant'
+import { getList, deleteById, updateStatusById } from '@/api/merchant'
 import Pagination from '@/components/Pagination'
 
 export default {
   components: { Pagination, AddModal },
+  filters: {
+    statusFilter(status) {
+      return status ? 'success' : 'info'
+    },
+    statusFilterStr(status) {
+      return status ? '已启用' : '已停用'
+    }
+  },
   mixins: [tableMixins],
   data() {
     return {
@@ -154,6 +178,43 @@ export default {
           }
         }
       }).then(() => {}).catch(() => {})
+    },
+    statusChange(row, status) {
+      const that = this
+      this.$confirm(`确定 ${status ? '启用授权' : '停用授权'} 操作吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        showClose: false,
+        type: 'warning',
+        beforeClose: async(action, instance, done) => {
+          if (action === 'confirm') {
+            instance.confirmButtonLoading = true
+            instance.cancelButtonLoading = true
+            instance.confirmButtonText = '提交中...'
+            try {
+              await updateStatusById(row.id, status)
+              this.$message({
+                type: 'success',
+                message: '操作成功!'
+              })
+              that.getTableList()
+            } catch (e) {
+              // this.$message({
+              //   type: 'error',
+              //   message: '删除失败!'
+              // })
+            } finally {
+              done()
+              setTimeout(() => {
+                instance.confirmButtonLoading = false
+                instance.cancelButtonLoading = false
+              }, 300)
+            }
+          } else {
+            done()
+          }
+        }
+      }).then(() => {}).catch(() => {})
     }
   }
 }