Merge branch 'master' of git.code.tencent.com:xian-ncc-da/xian-ncc-da-client

This commit is contained in:
Yuan 2023-07-27 15:05:48 +08:00
commit 791857c1ba
4 changed files with 14 additions and 146 deletions

View File

@ -7,10 +7,6 @@ export function mockAlertSet(data: { lineId: number; alertType: string }) {
return api.post(`${alertUriBase}/set`, data);
}
export function mockAlertClear() {
return api.post(`${alertUriBase}/clear`);
}
export class PagingQueryParams extends PageQueryDto {
alertType?: string;
lineId?: number;

View File

@ -71,7 +71,3 @@ export async function pageQuery(
});
return response.data;
}
export function distributeRole(query: { userId: number; roleIds: number[] }) {
return api.post('/api/role/distribute', query);
}

View File

@ -26,18 +26,8 @@
color="info"
label="故障设置"
class="q-mr-sm"
>
<q-menu>
<q-list style="min-width: 100px">
<q-item clickable v-close-popup @click="alertSetShow = true">
<q-item-section>设置模拟故障</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="clearMockAlert">
<q-item-section>取消模拟故障</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
@click="alertSetShow = true"
/>
<div class="q-gutter-sm row items-center no-wrap">
<q-btn
@ -130,7 +120,7 @@ import SysMenu from 'src/components/SysMenu.vue';
import { useRouter, useRoute } from 'vue-router';
import { Dialog, useQuasar } from 'quasar';
import { clearJwtToken } from 'src/configs/TokenManage';
import { mockAlertSet, mockAlertClear } from 'src/api/AlertMock';
import { mockAlertSet } from 'src/api/AlertMock';
import alarmInfoList from 'src/components/alarm/alarmInfoList.vue';
const leftDrawerOpen = ref(false);
@ -209,17 +199,6 @@ async function alarmMockSet() {
}
}
async function clearMockAlert() {
try {
await mockAlertClear();
} catch (err) {
$q.notify({
type: 'negative',
message: '无法取消模拟故障',
});
}
}
//
const alarmListDialogInstance = ref();
function alarmListQuery() {

View File

@ -16,70 +16,23 @@
@request="onRequest"
>
<template v-slot:top-right>
<q-card-section>
<q-select
dense
debounce="1000"
v-model="filter.roleId"
:options="optionsSearch"
></q-select>
</q-card-section>
<q-input
dense
debounce="1000"
v-model="filter.name"
label="用户名"
></q-input>
<q-btn flat round color="primary" icon="search" />
</template>
<template v-slot:body-cell-operations="props">
<q-td :props="props">
<div class="q-gutter-sm row justify-center">
<q-btn
color="primary"
label="编辑"
@click="edieUserData(props.row)"
/>
</div>
</q-td>
</template>
</q-table>
<q-dialog
v-model="editFormShow"
persistent
transition-show="scale"
transition-hide="scale"
>
<q-card style="width: 300px">
<q-card-section>
<div class="text-h6">修改用户角色</div>
</q-card-section>
<q-card-section>
<q-input outlined disable label="用户名" v-model="userName" />
</q-card-section>
<q-card-section>
<q-select
standout="bg-primary text-white"
v-model="userRole"
:options="options"
label="用户角色"
></q-select>
</q-card-section>
<q-card-actions align="right">
<q-btn color="primary" label="提交" @click="edieUserRole" />
<q-btn label="取消" v-close-popup />
</q-card-actions>
</q-card>
</q-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue';
import { useQuasar, type QTableColumn } from 'quasar';
import { pageQuery, distributeRole } from '../api/UserApi';
import { successNotify, errorNotify } from '../utils/CommonNotify';
const $q = useQuasar();
import { type QTableColumn } from 'quasar';
import { pageQuery } from '../api/UserApi';
import { errorNotify } from '../utils/CommonNotify';
const props = withDefaults(
defineProps<{
@ -116,14 +69,12 @@ const columnDefs: QTableColumn[] = [
field: 'mobile',
align: 'center',
},
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
];
const operateDisabled = ref(false);
const tableRef = ref();
const rows = reactive([]);
const filter = reactive({
roleId: '选择角色',
name: '',
});
const loading = ref(false);
const pagination = ref({
@ -141,7 +92,7 @@ async function onRequest(props: any) {
loading.value = true;
try {
let response = await pageQuery({
roleId: (userRoleSearch as any)[filter.roleId],
name: filter.name,
current: page,
size: rowsPerPage,
});
@ -158,58 +109,4 @@ async function onRequest(props: any) {
loading.value = false;
}
}
const editFormShow = ref(false);
const userName = ref('');
const userRole = ref('');
const userId = ref(0);
const options = ['管理员', '调度员', '管理员/调度员'];
const optionsSearch = ['所有角色', '管理员', '调度员'];
const userRoleAll = {
管理员: [7],
调度员: [8],
'管理员/调度员': [7, 8],
};
enum userRoleSearch {
'管理员' = 7,
'调度员' = 8,
}
//
function edieUserData(row: any) {
userName.value = row.name;
userRole.value = '';
userId.value = Number(row.id);
editFormShow.value = true;
}
//
async function edieUserRole() {
operateDisabled.value = true;
$q.dialog({
title: '确认',
message: `确认将用户${userName.value}的角色修改为${userRole.value}吗?`,
cancel: true,
})
.onOk(async () => {
try {
await distributeRole({
userId: userId.value,
roleIds: (userRoleAll as any)[userRole.value],
});
tableRef.value.requestServerInteraction(); //
editFormShow.value = false;
successNotify('修改成功');
} catch (error: any) {
errorNotify(`修改失败:${error.message}`, error);
}
})
.onDismiss(() => {
operateDisabled.value = false;
});
}
</script>