|
|
@@ -3,49 +3,16 @@
|
|
|
<Search :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
|
|
|
<div class="mediaList-table">
|
|
|
<a-table :scroll="{ x: '100%', y: 500 }" rowKey="user_id" :loading="state.listLoading" :columns="columns"
|
|
|
- @change="refreshData" :rowClassName="rowClassName" :dataSource="state.list" :pagination="paginationConfig">
|
|
|
- <template v-for="col in ['mqtt_username', 'mqtt_password']" #[col]="{ text, record }" :key="col">
|
|
|
- <div>
|
|
|
- <a-input v-if="state.editableData[record.user_id]" v-model:value="state.editableData[record.user_id][col]"
|
|
|
- style="margin: -5px 0" />
|
|
|
- <template v-else>
|
|
|
- {{ text }}
|
|
|
- </template>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #action="{ record }">
|
|
|
- <div class="editable-row-operations">
|
|
|
- <span v-if="state.editableData[record.user_id]">
|
|
|
- <a-tooltip title="确定">
|
|
|
- <span @click="save(record)" style="color: #28d445;">
|
|
|
- <CheckOutlined />
|
|
|
- </span>
|
|
|
- </a-tooltip>
|
|
|
- <a-tooltip title="取消">
|
|
|
- <span @click="() => delete state.editableData[record.user_id]" class="ml15" style="color: #e70102;">
|
|
|
- <CloseOutlined />
|
|
|
- </span>
|
|
|
- </a-tooltip>
|
|
|
- </span>
|
|
|
- <span v-else class="fz18 flex-align-center flex-row" style="color: #2d8cf0">
|
|
|
- <a-tooltip title="编辑">
|
|
|
- <EditOutlined @click="edit(record)" />
|
|
|
- </a-tooltip>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </a-table>
|
|
|
+ @change="refreshData" :rowClassName="rowClassName" :dataSource="state.list" :pagination="paginationConfig" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { message } from 'ant-design-vue'
|
|
|
-import { onMounted, reactive, UnwrapRef } from 'vue'
|
|
|
+import { onMounted, reactive } from 'vue'
|
|
|
import Search from './components/Search.vue';
|
|
|
-import { getAllUsersInfo, updateUserInfo } from '/@/api/manage'
|
|
|
+import { getAllUsersInfo } from '/@/api/manage'
|
|
|
import { ELocalStorageKey } from '/@/types'
|
|
|
-import { EditOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons-vue'
|
|
|
|
|
|
export interface Member {
|
|
|
user_id: string
|
|
|
@@ -60,15 +27,11 @@ export interface Member {
|
|
|
interface State {
|
|
|
listLoading: boolean,
|
|
|
list: Member[],
|
|
|
- editableData: {
|
|
|
- [key: string]: any,
|
|
|
- },
|
|
|
}
|
|
|
|
|
|
const state: State = reactive({
|
|
|
listLoading: false,
|
|
|
list: [],
|
|
|
- editableData: {},
|
|
|
})
|
|
|
|
|
|
const paginationConfig = reactive({
|
|
|
@@ -121,29 +84,11 @@ const columns = [
|
|
|
dataIndex: 'workspace_name',
|
|
|
width: 150,
|
|
|
},
|
|
|
- {
|
|
|
- title: 'Mqtt 用户',
|
|
|
- dataIndex: 'mqtt_username',
|
|
|
- width: 150,
|
|
|
- slots: { customRender: 'mqtt_username' },
|
|
|
- },
|
|
|
- {
|
|
|
- title: 'Mqtt 密码',
|
|
|
- dataIndex: 'mqtt_password',
|
|
|
- width: 150,
|
|
|
- slots: { customRender: 'mqtt_password' },
|
|
|
- },
|
|
|
{
|
|
|
title: '创建时间',
|
|
|
dataIndex: 'create_time',
|
|
|
width: 150,
|
|
|
sorter: (a: Member, b: Member) => a.create_time.localeCompare(b.create_time),
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'action',
|
|
|
- width: 80,
|
|
|
- slots: { customRender: 'action' },
|
|
|
}
|
|
|
]
|
|
|
|
|
|
@@ -160,20 +105,6 @@ const refreshData = async (page: any) => {
|
|
|
paginationConfig.pageSize = page?.pageSize!
|
|
|
await fetchList();
|
|
|
}
|
|
|
-// 点击编辑
|
|
|
-const edit = (record: Member) => {
|
|
|
- state.editableData[record.user_id] = record;
|
|
|
-}
|
|
|
-
|
|
|
-// 点击保存
|
|
|
-const save = (record: Member) => {
|
|
|
- delete state.editableData[record.user_id]
|
|
|
- updateUserInfo(workspaceId, record.user_id, record).then(res => {
|
|
|
- if (res.code !== 0) {
|
|
|
- message.error(res.message)
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
|
|
|
// 点击搜索
|
|
|
const onClickSearch = async (query: any) => {
|