xieb
2023-09-13 3667807a7b7418efc090ee3fa6a6b734bc3080bf
src/pages/page-web/projects/members.vue
@@ -3,8 +3,8 @@
  <div class="table flex-display flex-column">
    <a-table :columns="columns" :data-source="data.member" :pagination="paginationProp" @change="refreshData" row-key="user_id"
    :row-selection="rowSelection" :rowClassName="(record, index) => ((index % 2) === 0 ? 'table-striped' : null)" :scroll="{ x: '100%', y: 600 }">
      <template v-for="col in ['mqtt_username', 'mqtt_password']" #[col]="{ text, record }" :key="col">
        <div>
      <template v-for="col in ['organization_name', 'user_role', ]" #[col]="{ text, record }" :key="col">
        <div v-if="col == 'organization_name'">
          <a-input
            v-if="editableData[record.user_id]"
            v-model:value="editableData[record.user_id][col]"
@@ -14,19 +14,23 @@
            {{ text }}
          </template>
        </div>
        <!-- <div v-else-if="col == 'user_role'"> -->
          <!--  -->
        <!-- </div> -->
      </template>
      <template #action="{ record }">
        <div class="editable-row-operations">
          <span v-if="editableData[record.user_id]">
            <a-tooltip title="Confirm changes">
            <a-tooltip title="保存">
              <span @click="save(record)" style="color: #28d445;"><CheckOutlined /></span>
            </a-tooltip>
            <a-tooltip title="Modification canceled">
            <a-tooltip title="取消">
              <span @click="() => delete 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">
          <span v-else class="fz18 flex-align-center flex-justify-between flex-row" style="color: #2d8cf0">
            <EditOutlined @click="edit(record)" />
            <DeleteOutlined @click="del(record)" />
          </span>
        </div>
      </template>
@@ -39,31 +43,32 @@
import { TableState } from 'ant-design-vue/lib/table/interface'
import { onMounted, reactive, Ref, ref, UnwrapRef } from 'vue'
import { IPage } from '/@/api/http/type'
import { getAllUsersInfo, updateUserInfo } from '/@/api/manage'
import { getAllUsersInfo, getUserPage, updateUserInfo } from '/@/api/manage'
import { ELocalStorageKey } from '/@/types'
import { EditOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons-vue'
import { EditOutlined, DeleteOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons-vue'
import { useMyStore } from '/@/store'
export interface Member {
    user_id: string
    username: string
    user_type: string
    workspace_name: string
    organization_name: string
    project: string
    create_time: string
    mqtt_username: string
    mqtt_password: string
    user_role: string
    join_way: string
}
interface MemberData {
  member: Member[]
}
const columns = [
  { title: 'Account', dataIndex: 'username', width: 150, sorter: (a: Member, b: Member) => a.username.localeCompare(b.username), className: 'titleStyle' },
  { title: 'User Type', dataIndex: 'user_type', width: 150, className: 'titleStyle' },
  { title: 'Workspace Name', dataIndex: 'workspace_name', width: 150, className: 'titleStyle' },
  { title: 'Mqtt Username', dataIndex: 'mqtt_username', width: 150, className: 'titleStyle', slots: { customRender: 'mqtt_username' } },
  { title: 'Mqtt Password', dataIndex: 'mqtt_password', width: 150, className: 'titleStyle', slots: { customRender: 'mqtt_password' } },
  { title: 'Joined', dataIndex: 'create_time', width: 150, sorter: (a: Member, b: Member) => a.create_time.localeCompare(b.create_time), className: 'titleStyle' },
  { title: 'Action', dataIndex: 'action', width: 100, className: 'titleStyle', slots: { customRender: 'action' } },
  { title: '账号', dataIndex: 'username', width: 150, sorter: (a: Member, b: Member) => a.username.localeCompare(b.username), className: 'titleStyle' },
  { title: '人员组织名称', dataIndex: 'deptName', sorter: (a: Member, b: Member) => a.organization_name.localeCompare(b.organization_name), width: 150, className: 'titleStyle' },
  { title: '用户角色', dataIndex: 'roleName', width: 150, className: 'titleStyle', slots: { customRender: 'user_role' } },
  { title: '所属项目', dataIndex: 'projectName', width: 150, className: 'titleStyle' },
  { title: '加入方式', dataIndex: 'join_way', width: 150, className: 'titleStyle', slots: { customRender: 'join_way' } },
  { title: '加入时间', dataIndex: 'createTime', width: 150, sorter: (a: Member, b: Member) => a.create_time.localeCompare(b.create_time), className: 'titleStyle' },
  { title: '操作', dataIndex: 'action', width: 70, className: 'titleStyle', slots: { customRender: 'action' } },
]
const data = reactive<MemberData>({
@@ -100,23 +105,28 @@
  page_size: 50
}
const workspaceId: string = localStorage.getItem(ELocalStorageKey.WorkspaceId)!
const store = useMyStore()
const projectId:string = store.state.common.projectId
onMounted(() => {
  getAllUsers(workspaceId, body)
  getAllUsers({ projectId }, body)
})
function refreshData (page: Pagination) {
  body.page = page?.current!
  body.page_size = page?.pageSize!
  getAllUsers(workspaceId, body)
  getAllUsers({ projectId }, body)
}
function getAllUsers (workspaceId: string, page: IPage) {
  getAllUsersInfo(workspaceId, page).then(res => {
    const userList: Member[] = res.data.list
    data.member = userList
    paginationProp.total = res.data.pagination.total
    paginationProp.current = res.data.pagination.page
function getAllUsers (params:any, page: IPage) {
  getUserPage(params, page).then(res => {
    const resData = res.data
    data.member = resData.list
    paginationProp.total = resData.total
    paginationProp.current = resData.pageNum
  }).catch(err => {
    console.log(err)
  })
}
@@ -124,6 +134,10 @@
  editableData[record.user_id] = record
}
const del = (record: Member) => {
  console.log(record)
}
function save (record: Member) {
  delete editableData[record.user_id]
  updateUserInfo(workspaceId, record.user_id, record).then(res => {