Browse Source

feat: 用户操作日志固件按钮与分页切换到 TDesign

main
xiaosi 3 weeks ago
parent
commit
9461d1924b
  1. 31
      src/views/FirmwaresView/FirmwaresView.vue
  2. 21
      src/views/OperationLogsView/OperationLogsView.vue
  3. 21
      src/views/UsersView/UsersView.vue

31
src/views/FirmwaresView/FirmwaresView.vue

@ -6,8 +6,8 @@
<span>维护机巢固件版本发布后供用户对设备升级</span> <span>维护机巢固件版本发布后供用户对设备升级</span>
</div> </div>
<div class="page-actions"> <div class="page-actions">
<button class="icon-command" title="刷新" @click="load"><svg><use href="#i-refresh" /></svg></button>
<button class="primary-command" @click="openAdd"><svg><use href="#i-plus" /></svg>新增固件</button>
<t-button shape="square" variant="outline" title="刷新" @click="load"><svg><use href="#i-refresh" /></svg></t-button>
<t-button theme="primary" @click="openAdd"><svg><use href="#i-plus" /></svg>新增固件</t-button>
</div> </div>
</header> </header>
@ -54,8 +54,8 @@
<td>{{ f.createdAt }}</td> <td>{{ f.createdAt }}</td>
<td> <td>
<div class="row-actions"> <div class="row-actions">
<button @click="openEdit(f)">编辑</button>
<button class="more-action" @click="remove(f)"><svg><use href="#i-trash" /></svg></button>
<t-button variant="text" theme="primary" @click="openEdit(f)">编辑</t-button>
<t-button variant="text" theme="danger" shape="square" @click="remove(f)"><svg><use href="#i-trash" /></svg></t-button>
</div> </div>
</td> </td>
</tr> </tr>
@ -65,12 +65,12 @@
</div> </div>
<div class="table-footer"> <div class="table-footer">
<span> {{ total }} 个固件版本 · {{ pageNum }} / {{ pages }} </span>
<div>
<button @click="goPage(pageNum - 1)"><svg><use href="#i-chevron" /></svg></button>
<b>{{ pageNum }}</b>
<button @click="goPage(pageNum + 1)"><svg><use href="#i-chevron" /></svg></button>
</div>
<t-pagination
v-model:current="pageNum"
:total="total"
:page-size="pageSize"
@current-change="load"
/>
</div> </div>
</div> </div>
@ -105,8 +105,8 @@
<div class="form-error">{{ formError }}</div> <div class="form-error">{{ formError }}</div>
</form> </form>
<template #footer> <template #footer>
<button class="plain-command" type="button" @click="modalVisible = false">取消</button>
<button class="primary-command" type="button" @click="submit">{{ editingId ? '保存' : '确认新增' }}</button>
<t-button variant="outline" @click="modalVisible = false">取消</t-button>
<t-button theme="primary" @click="submit">{{ editingId ? '保存' : '确认新增' }}</t-button>
</template> </template>
</t-dialog> </t-dialog>
</section> </section>
@ -123,7 +123,6 @@ const list = ref([])
const total = ref(0) const total = ref(0)
const pageNum = ref(1) const pageNum = ref(1)
const pageSize = ref(10) const pageSize = ref(10)
const pages = ref(1)
const keyword = ref('') const keyword = ref('')
const statusFilter = ref('') const statusFilter = ref('')
@ -177,7 +176,6 @@ async function load() {
if (statusFilter.value) params.status = statusFilter.value if (statusFilter.value) params.status = statusFilter.value
const page = await request.get(urls.FIRMWARES, { params }) const page = await request.get(urls.FIRMWARES, { params })
total.value = page?.total || 0 total.value = page?.total || 0
pages.value = page?.pages || 1
list.value = (page?.records || []).map((f) => ({ list.value = (page?.records || []).map((f) => ({
id: String(f.id), id: String(f.id),
version: f.version, version: f.version,
@ -201,11 +199,6 @@ function reload() {
load() load()
} }
function goPage(p) {
if (p < 1 || p > pages.value) return
pageNum.value = p
load()
}
function openAdd() { function openAdd() {
Object.assign(form, { version: '', component: '', description: '', fileUrl: '', sha256: '', signature: '', fileSizeMb: undefined, mandatory: 0, status: 'draft' }) Object.assign(form, { version: '', component: '', description: '', fileUrl: '', sha256: '', signature: '', fileSizeMb: undefined, mandatory: 0, status: 'draft' })

21
src/views/OperationLogsView/OperationLogsView.vue

@ -5,7 +5,7 @@
<h1>设备操作记录</h1> <h1>设备操作记录</h1>
<span>你对机巢和无人机下发的控制指令</span> <span>你对机巢和无人机下发的控制指令</span>
</div> </div>
<button class="icon-command" title="刷新" @click="load"><svg><use href="#i-refresh" /></svg></button>
<t-button shape="square" variant="outline" title="刷新" @click="load"><svg><use href="#i-refresh" /></svg></t-button>
</header> </header>
<div class="business-workspace"> <div class="business-workspace">
@ -53,12 +53,12 @@
</div> </div>
<div class="table-footer"> <div class="table-footer">
<span> {{ total }} 条记录 · {{ pageNum }} / {{ pages }} </span>
<div>
<button @click="goPage(pageNum - 1)"><svg><use href="#i-chevron" /></svg></button>
<b>{{ pageNum }}</b>
<button @click="goPage(pageNum + 1)"><svg><use href="#i-chevron" /></svg></button>
</div>
<t-pagination
v-model:current="pageNum"
:total="total"
:page-size="pageSize"
@current-change="load"
/>
</div> </div>
</div> </div>
</section> </section>
@ -75,7 +75,6 @@ const list = ref([])
const total = ref(0) const total = ref(0)
const pageNum = ref(1) const pageNum = ref(1)
const pageSize = ref(20) const pageSize = ref(20)
const pages = ref(1)
const keyword = ref('') const keyword = ref('')
const statusFilter = ref('') const statusFilter = ref('')
@ -137,7 +136,6 @@ async function load() {
if (statusFilter.value) params.status = statusFilter.value if (statusFilter.value) params.status = statusFilter.value
const page = await request.get(urls.COMMANDS, { params }) const page = await request.get(urls.COMMANDS, { params })
total.value = page?.total || 0 total.value = page?.total || 0
pages.value = page?.pages || 1
list.value = (page?.records || []).map((c) => { list.value = (page?.records || []).map((c) => {
const status = STATUS_NAMES[c.status] || { name: c.status || '--', cls: 'offline' } const status = STATUS_NAMES[c.status] || { name: c.status || '--', cls: 'offline' }
return { return {
@ -162,11 +160,6 @@ function reload() {
load() load()
} }
function goPage(p) {
if (p < 1 || p > pages.value) return
pageNum.value = p
load()
}
onMounted(load) onMounted(load)
</script> </script>

21
src/views/UsersView/UsersView.vue

@ -5,7 +5,7 @@
<h1>用户列表</h1> <h1>用户列表</h1>
<span> {{ total }} 个注册用户</span> <span> {{ total }} 个注册用户</span>
</div> </div>
<button class="icon-command" title="刷新" @click="load"><svg><use href="#i-refresh" /></svg></button>
<t-button shape="square" variant="outline" title="刷新" @click="load"><svg><use href="#i-refresh" /></svg></t-button>
</header> </header>
<div class="business-workspace"> <div class="business-workspace">
@ -58,12 +58,12 @@
</div> </div>
<div class="table-footer"> <div class="table-footer">
<span> {{ total }} 个用户 · {{ pageNum }} / {{ pages }} </span>
<div>
<button @click="goPage(pageNum - 1)"><svg><use href="#i-chevron" /></svg></button>
<b>{{ pageNum }}</b>
<button @click="goPage(pageNum + 1)"><svg><use href="#i-chevron" /></svg></button>
</div>
<t-pagination
v-model:current="pageNum"
:total="total"
:page-size="pageSize"
@current-change="load"
/>
</div> </div>
</div> </div>
</section> </section>
@ -80,7 +80,6 @@ const users = ref([])
const total = ref(0) const total = ref(0)
const pageNum = ref(1) const pageNum = ref(1)
const pageSize = ref(20) const pageSize = ref(20)
const pages = ref(1)
const keyword = ref('') const keyword = ref('')
const roleFilter = ref('') const roleFilter = ref('')
@ -106,7 +105,6 @@ async function load() {
if (roleFilter.value) params.role = roleFilter.value if (roleFilter.value) params.role = roleFilter.value
const page = await request.get(urls.USERS, { params }) const page = await request.get(urls.USERS, { params })
total.value = page?.total || 0 total.value = page?.total || 0
pages.value = page?.pages || 1
users.value = (page?.records || []).map((u) => ({ users.value = (page?.records || []).map((u) => ({
id: String(u.id), id: String(u.id),
name: u.name, name: u.name,
@ -129,11 +127,6 @@ function reload() {
load() load()
} }
function goPage(p) {
if (p < 1 || p > pages.value) return
pageNum.value = p
load()
}
onMounted(load) onMounted(load)
</script> </script>

Loading…
Cancel
Save