2025-09-05 09:26:14 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="user">
|
2025-09-12 16:27:06 +08:00
|
|
|
<searchBox :btn-option-list="btnOptionList" @operateForm="operateForm"></searchBox>
|
2025-09-04 16:04:37 +08:00
|
|
|
|
2025-09-05 09:26:14 +08:00
|
|
|
<div class="content-table">
|
|
|
|
|
<ComTable
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:table-data="tableData"
|
|
|
|
|
@handlePagesizeChange="handlePagesizeChange"
|
|
|
|
|
ref="comTable"
|
|
|
|
|
:table-option="tableOption"
|
|
|
|
|
:page-option="pageOption"
|
|
|
|
|
>
|
2025-09-05 16:40:35 +08:00
|
|
|
<template #gender="record">
|
|
|
|
|
<!-- 0:女; 1:男 -->
|
2025-09-05 09:26:14 +08:00
|
|
|
<span>{{ ['女', '男'][record.gender] }}</span>
|
|
|
|
|
</template>
|
2025-09-05 16:40:35 +08:00
|
|
|
|
2025-09-05 09:26:14 +08:00
|
|
|
<template #action="record">
|
|
|
|
|
<OperateCom :record="record" :operate-list="operateList" @operateForm="operateForm" />
|
|
|
|
|
</template>
|
2025-09-05 16:40:35 +08:00
|
|
|
</ComTable>
|
2025-09-05 09:26:14 +08:00
|
|
|
</div>
|
2025-09-12 16:27:06 +08:00
|
|
|
<a-modal
|
|
|
|
|
v-model:open="formModal"
|
|
|
|
|
width="750px"
|
|
|
|
|
style="top: 20px"
|
|
|
|
|
:footer="null"
|
|
|
|
|
:destroy-on-close="true"
|
|
|
|
|
>
|
2025-09-05 16:40:35 +08:00
|
|
|
<!-- action:edit add -->
|
|
|
|
|
<EditCom
|
|
|
|
|
:record="record"
|
|
|
|
|
@operateForm="operateForm"
|
|
|
|
|
type="user"
|
|
|
|
|
:action="formStatus"
|
|
|
|
|
></EditCom>
|
|
|
|
|
</a-modal>
|
|
|
|
|
</div>
|
2025-09-05 09:26:14 +08:00
|
|
|
</template>
|
2025-09-04 16:04:37 +08:00
|
|
|
|
2025-09-01 16:55:44 +08:00
|
|
|
<script>
|
2025-09-05 16:40:35 +08:00
|
|
|
import { columnList, userOptions } from '../../../public/config/columnList'
|
2025-09-05 09:26:14 +08:00
|
|
|
import { getReq, postReq } from '@/request/api.js'
|
2025-09-05 16:40:35 +08:00
|
|
|
import EditCom from '@/components/EditCom.vue'
|
|
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
|
|
|
|
import { Modal } from 'ant-design-vue'
|
|
|
|
|
import { createVNode } from 'vue'
|
2025-09-01 16:55:44 +08:00
|
|
|
export default {
|
|
|
|
|
name: '',
|
2025-09-05 09:26:14 +08:00
|
|
|
components: {
|
2025-09-12 16:27:06 +08:00
|
|
|
EditCom
|
2025-09-01 16:55:44 +08:00
|
|
|
},
|
2025-09-05 09:26:14 +08:00
|
|
|
props: {},
|
|
|
|
|
data() {
|
2025-09-01 16:55:44 +08:00
|
|
|
return {
|
2025-09-12 16:51:32 +08:00
|
|
|
tableData:[],
|
2025-09-11 19:01:01 +08:00
|
|
|
tableOption: {
|
2025-09-12 16:27:06 +08:00
|
|
|
select: false
|
2025-09-11 19:01:01 +08:00
|
|
|
},
|
2025-09-05 16:40:35 +08:00
|
|
|
formModal: false,
|
|
|
|
|
formState: {},
|
|
|
|
|
formStatus: 'add', //表单状态辑状态 add:新增 edit:编辑
|
|
|
|
|
pageOption: {
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
page: 1
|
|
|
|
|
},
|
2025-09-05 09:26:14 +08:00
|
|
|
btnOptionList: [],
|
2025-09-05 16:40:35 +08:00
|
|
|
paramsDate: {}
|
2025-09-01 16:55:44 +08:00
|
|
|
}
|
|
|
|
|
},
|
2025-09-05 16:40:35 +08:00
|
|
|
computed: {},
|
2025-09-05 09:26:14 +08:00
|
|
|
created() {
|
|
|
|
|
let info = []
|
|
|
|
|
let col = columnList.find((i) => i.page == 'user').columns
|
|
|
|
|
if (col.length) {
|
|
|
|
|
col.forEach((item) => {
|
|
|
|
|
info.push(this.$setWidth(item))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.columns = info
|
|
|
|
|
},
|
2025-09-05 16:40:35 +08:00
|
|
|
|
2025-09-05 09:26:14 +08:00
|
|
|
mounted() {
|
2025-09-05 16:40:35 +08:00
|
|
|
this.operateList = this.$getBtns(['查看', '修改', '删除'])
|
|
|
|
|
this.btnOptionList = this.$getBtns(['新增'])
|
2025-09-05 09:26:14 +08:00
|
|
|
this.getList()
|
2025-09-01 16:55:44 +08:00
|
|
|
},
|
2025-09-05 09:26:14 +08:00
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
async getList() {
|
|
|
|
|
this.$refs.comTable.loading = true
|
|
|
|
|
|
|
|
|
|
const { page, pageSize } = this.pageOption
|
|
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
...this.paramsDate,
|
|
|
|
|
page_size: pageSize,
|
|
|
|
|
page
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2025-09-05 16:40:35 +08:00
|
|
|
const res = await getReq('/queryUserList', params)
|
2025-09-05 09:26:14 +08:00
|
|
|
if (res.errcode === 0) {
|
|
|
|
|
this.$refs.comTable.loading = false
|
|
|
|
|
|
|
|
|
|
this.tableData = res.data
|
|
|
|
|
|
|
|
|
|
this.pageOption = {
|
|
|
|
|
page: res.page,
|
|
|
|
|
pageSize: res.page_size,
|
|
|
|
|
count: res.count
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const err = { tip: res.errmsg }
|
|
|
|
|
throw err
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2025-09-12 10:58:59 +08:00
|
|
|
this.$refs.comTable.loading = false
|
|
|
|
|
|
2025-09-05 09:26:14 +08:00
|
|
|
//统一处理报错提示
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
operateForm(type, record = {}) {
|
2025-09-05 16:40:35 +08:00
|
|
|
this.formStatus = type
|
2025-09-05 09:26:14 +08:00
|
|
|
switch (type) {
|
2025-09-05 16:40:35 +08:00
|
|
|
case 'add':
|
|
|
|
|
this.formModal = true
|
|
|
|
|
this.formState = {}
|
|
|
|
|
this.getRuleFormInfo()
|
2025-09-05 09:26:14 +08:00
|
|
|
|
2025-09-05 16:40:35 +08:00
|
|
|
break
|
|
|
|
|
case 'edit':
|
|
|
|
|
case 'read':
|
|
|
|
|
this.formModal = true
|
|
|
|
|
this.formState = record
|
2025-09-05 09:26:14 +08:00
|
|
|
this.getRuleFormInfo(record)
|
|
|
|
|
break
|
2025-09-12 16:27:06 +08:00
|
|
|
|
2025-09-05 16:40:35 +08:00
|
|
|
case 'del':
|
2025-09-12 16:27:06 +08:00
|
|
|
this.handleDelete([record.user_id], this.getList)
|
2025-09-05 16:40:35 +08:00
|
|
|
|
|
|
|
|
break
|
2025-09-05 09:26:14 +08:00
|
|
|
|
|
|
|
|
case 'back':
|
2025-09-05 16:40:35 +08:00
|
|
|
this.formModal = false
|
2025-09-05 09:26:14 +08:00
|
|
|
this.getList()
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-09-05 16:40:35 +08:00
|
|
|
// 删除操作
|
2025-09-12 16:27:06 +08:00
|
|
|
async handleDelete(id, callback) {
|
2025-09-05 16:40:35 +08:00
|
|
|
const that = this
|
2025-09-10 09:23:47 +08:00
|
|
|
this.$Modal.confirm({
|
2025-09-05 16:40:35 +08:00
|
|
|
title: '你确认删除数据吗?',
|
|
|
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
|
|
|
|
|
|
|
|
async onOk() {
|
|
|
|
|
try {
|
2025-09-12 16:27:06 +08:00
|
|
|
const res = await getReq('/deleteUser', { user_id: id })
|
2025-09-05 16:40:35 +08:00
|
|
|
if (res.errcode === 0) {
|
|
|
|
|
this.$message.success(res.errmsg)
|
2025-09-12 16:27:06 +08:00
|
|
|
this.pageOption.page = 1
|
2025-09-05 16:40:35 +08:00
|
|
|
callback()
|
|
|
|
|
} else {
|
|
|
|
|
throw res
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
callback()
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-09-12 16:27:06 +08:00
|
|
|
onCancel() {},
|
2025-09-05 16:40:35 +08:00
|
|
|
class: 'test'
|
|
|
|
|
})
|
|
|
|
|
},
|
2025-09-05 09:26:14 +08:00
|
|
|
async getRuleFormInfo(record) {
|
|
|
|
|
function getInfo(data, url) {
|
|
|
|
|
return new Promise((reslove, reject) => {
|
|
|
|
|
getReq(data, url).then((res) => {
|
|
|
|
|
reslove(res.data)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let row = {}
|
2025-09-05 16:40:35 +08:00
|
|
|
if (record && record.user_id) {
|
|
|
|
|
// row = await getInfo({ id: record.id },'/queryUserList')
|
|
|
|
|
this.record = record
|
|
|
|
|
row = record
|
|
|
|
|
// this.type='edit'
|
2025-09-05 09:26:14 +08:00
|
|
|
}
|
2025-09-05 16:40:35 +08:00
|
|
|
userOptions.forEach((e, index) => {
|
2025-09-05 09:26:14 +08:00
|
|
|
e.list.forEach((i) => {
|
2025-09-05 16:40:35 +08:00
|
|
|
e.ruleForm[i.key] = row ? row[i.key] : ''
|
|
|
|
|
e.ruleForm.id = row.id
|
2025-09-05 09:26:14 +08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlePagesizeChange(pageOption) {
|
|
|
|
|
this.pageOption.pageSize = pageOption.pageSize
|
|
|
|
|
this.pageOption.page = pageOption.page
|
|
|
|
|
this.getList()
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
2025-09-05 09:26:14 +08:00
|
|
|
|
2025-09-05 16:40:35 +08:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.user {
|
|
|
|
|
height: 100%;
|
2025-09-12 16:27:06 +08:00
|
|
|
padding: 0 20px;
|
2025-09-05 16:40:35 +08:00
|
|
|
.content-table {
|
2025-09-12 16:27:06 +08:00
|
|
|
height: calc(100% - 92px);
|
2025-09-05 16:40:35 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|