From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/mp/account/index.vue | 195 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 195 insertions(+), 0 deletions(-)
diff --git a/src/views/mp/account/index.vue b/src/views/mp/account/index.vue
new file mode 100644
index 0000000..6551707
--- /dev/null
+++ b/src/views/mp/account/index.vue
@@ -0,0 +1,195 @@
+<template>
+ <doc-alert title="鍏紬鍙锋帴鍏�" url="https://doc.iocoder.cn/mp/account/" />
+
+ <!-- 鎼滅储宸ヤ綔鏍� -->
+ <ContentWrap>
+ <el-form
+ class="-mb-15px"
+ :model="queryParams"
+ ref="queryFormRef"
+ :inline="true"
+ label-width="68px"
+ >
+ <el-form-item label="鍚嶇О" prop="name">
+ <el-input
+ v-model="queryParams.name"
+ placeholder="璇疯緭鍏ュ悕绉�"
+ clearable
+ @keyup.enter="handleQuery"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item>
+ <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" />鎼滅储</el-button>
+ <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" />閲嶇疆</el-button>
+ <el-button type="primary" @click="openForm('create')" v-hasPermi="['mp:account:create']">
+ <Icon icon="ep:plus" class="mr-5px" /> 鏂板
+ </el-button>
+ </el-form-item>
+ </el-form>
+ </ContentWrap>
+
+ <!-- 鍒楄〃 -->
+ <ContentWrap>
+ <el-table v-loading="loading" :data="list">
+ <el-table-column label="鍚嶇О" align="center" prop="name" />
+ <el-table-column label="寰俊鍙�" align="center" prop="account" width="180" />
+ <el-table-column label="appId" align="center" prop="appId" width="180" />
+ <el-table-column label="鏈嶅姟鍣ㄥ湴鍧�(URL)" align="center" prop="appId" width="360">
+ <template #default="scope">
+ {{ 'http://鏈嶅姟绔湴鍧�/admin-api/mp/open/' + scope.row.appId }}
+ </template>
+ </el-table-column>
+ <el-table-column label="浜岀淮鐮�" align="center" prop="qrCodeUrl">
+ <template #default="scope">
+ <img
+ v-if="scope.row.qrCodeUrl"
+ :src="scope.row.qrCodeUrl"
+ alt="浜岀淮鐮�"
+ style="display: inline-block; height: 100px"
+ />
+ <el-button
+ link
+ type="primary"
+ @click="handleGenerateQrCode(scope.row)"
+ v-hasPermi="['mp:account:qr-code']"
+ >
+ 鐢熸垚浜岀淮鐮�
+ </el-button>
+ </template>
+ </el-table-column>
+ <el-table-column label="澶囨敞" align="center" prop="remark" />
+ <el-table-column label="鎿嶄綔" align="center">
+ <template #default="scope">
+ <el-button
+ link
+ type="primary"
+ @click="openForm('update', scope.row.id)"
+ v-hasPermi="['mp:account:update']"
+ >
+ 缂栬緫
+ </el-button>
+ <el-button
+ link
+ type="danger"
+ @click="handleDelete(scope.row.id)"
+ v-hasPermi="['mp:account:delete']"
+ >
+ 鍒犻櫎
+ </el-button>
+ <el-button
+ link
+ type="danger"
+ @click="handleCleanQuota(scope.row)"
+ v-hasPermi="['mp:account:clear-quota']"
+ >
+ 娓呯┖ API 閰嶉
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <!-- 鍒嗛〉 -->
+ <Pagination
+ :total="total"
+ v-model:page="queryParams.pageNo"
+ v-model:limit="queryParams.pageSize"
+ @pagination="getList"
+ />
+ </ContentWrap>
+
+ <!-- 瀵硅瘽妗�(娣诲姞 / 淇敼) -->
+ <AccountForm ref="formRef" @success="getList" />
+</template>
+<script lang="ts" setup>
+import * as AccountApi from '@/api/mp/account'
+import AccountForm from './AccountForm.vue'
+
+defineOptions({ name: 'MpAccount' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+const { t } = useI18n() // 鍥介檯鍖�
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const queryParams = reactive({
+ pageNo: 1,
+ pageSize: 10,
+ name: null,
+ account: null,
+ appId: null
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+ loading.value = true
+ try {
+ const data = await AccountApi.getAccountPage(queryParams)
+ list.value = data.list
+ total.value = data.total
+ } finally {
+ loading.value = false
+ }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ queryParams.pageNo = 1
+ getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+ queryFormRef.value.resetFields()
+ handleQuery()
+}
+
+/** 娣诲姞/淇敼鎿嶄綔 */
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+ formRef.value.open(type, id)
+}
+
+/** 鍒犻櫎鎸夐挳鎿嶄綔 */
+const handleDelete = async (id) => {
+ try {
+ // 鍒犻櫎鐨勪簩娆$‘璁�
+ await message.delConfirm()
+ // 鍙戣捣鍒犻櫎
+ await AccountApi.deleteAccount(id)
+ message.success(t('common.delSuccess'))
+ // 鍒锋柊鍒楄〃
+ await getList()
+ } catch {}
+}
+
+/** 鐢熸垚浜岀淮鐮佺殑鎸夐挳鎿嶄綔 */
+const handleGenerateQrCode = async (row) => {
+ try {
+ // 鐢熸垚浜岀淮鐮佺殑浜屾纭
+ await message.confirm('鏄惁纭鐢熸垚鍏紬鍙疯处鍙风紪鍙蜂负"' + row.name + '"鐨勪簩缁寸爜?')
+ // 鍙戣捣鐢熸垚浜岀淮鐮�
+ await AccountApi.generateAccountQrCode(row.id)
+ message.success('鐢熸垚浜岀淮鐮佹垚鍔�')
+ // 鍒锋柊鍒楄〃
+ await getList()
+ } catch {}
+}
+
+/** 娓呯┖浜岀淮鐮� API 閰嶉鐨勬寜閽搷浣� */
+const handleCleanQuota = async (row) => {
+ try {
+ // 娓呯┖ API 閰嶉鐨勪簩娆$‘璁�
+ await message.confirm('鏄惁纭娓呯┖鐢熸垚鍏紬鍙疯处鍙风紪鍙蜂负"' + row.name + '"鐨� API 閰嶉?')
+ // 鍙戣捣娓呯┖ API 閰嶉
+ await AccountApi.clearAccountQuota(row.id)
+ message.success('娓呯┖ API 閰嶉鎴愬姛')
+ } catch {}
+}
+
+/** 鍒濆鍖� **/
+onMounted(() => {
+ getList()
+})
+</script>
--
Gitblit v1.8.0