1. 机关教学日志2.新增全局表格横向拖拽滚动指令3.学员模块
This commit is contained in:
@@ -300,12 +300,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 模拟列表数据(后端接口未提供,接口就绪后可删除并改为接口加载)
|
||||
const mockTableData = [
|
||||
{ id: 1, bh: 'X101', xh: '2025010101', xm: '张三', xb: '男', nj: '2025级', zy: '炮兵装备运用', db: '54队', bc: '5区队', pxlx: '军官基础教育', pxcc: '本科', zzmm: '党员', mz: '汉族', jg: '江苏', xw: '学士', zczt: '已注册', xjyd: '无异动', ksqk: '正常', bjgm: '0', gljg: '教务处' },
|
||||
{ id: 2, bh: 'X102', xh: '2025010102', xm: '李四', xb: '男', nj: '2025级', zy: '通信工程', db: '32队', bc: '1区队', pxlx: '军官基础教育', pxcc: '本科', zzmm: '团员', mz: '汉族', jg: '山东', xw: '学士', zczt: '已注册', xjyd: '无异动', ksqk: '正常', bjgm: '1', gljg: '教务处' },
|
||||
{ id: 3, bh: 'X103', xh: '2024010101', xm: '王五', xb: '男', nj: '2024级', zy: '军事指挥', db: '51队', bc: '2区队', pxlx: '军官基础教育', pxcc: '本科', zzmm: '党员', mz: '汉族', jg: '河南', xw: '学士', zczt: '已注册', xjyd: '异动', ksqk: '正常', bjgm: '2', gljg: '教务处' }
|
||||
]
|
||||
import {
|
||||
listStudentRecord,
|
||||
getStudentRecord,
|
||||
addStudentRecord,
|
||||
updateStudentRecord,
|
||||
delStudentRecord
|
||||
} from "@/api/studentRecords/studentRecords"
|
||||
|
||||
export default {
|
||||
name: 'StudentInfoIndex',
|
||||
@@ -386,21 +387,58 @@ export default {
|
||||
},
|
||||
|
||||
// ==================== 列表加载 ====================
|
||||
// TODO: 后端接口未提供,暂用模拟数据;接口就绪后替换为 getStudentRecordsList
|
||||
loadData() {
|
||||
this.loading = true
|
||||
setTimeout(() => {
|
||||
this.tableData = mockTableData.slice()
|
||||
this.pagination.total = mockTableData.length
|
||||
const params = {
|
||||
pageNum: this.pagination.pageNum,
|
||||
pageSize: this.pagination.pageSize
|
||||
}
|
||||
this.buildQueryParams(params)
|
||||
listStudentRecord(params).then(res => {
|
||||
const data = res.data || {}
|
||||
this.tableData = data.records || []
|
||||
this.pagination.total = data.total || 0
|
||||
this.loading = false
|
||||
}, 200)
|
||||
}).catch(() => {
|
||||
this.tableData = []
|
||||
this.pagination.total = 0
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
/** 组装查询参数:文本非空才传,勾选启用的字段才传,门数范围二者其一非空才传 */
|
||||
buildQueryParams(params) {
|
||||
const textFields = ['xh', 'xm', 'sfzh', 'zjhm', 'zzmm', 'mz', 'jg', 'xw', 'ybzb', 'bq', 'whcd', 'bkbyyx', 'xylb', 'zdyfl', 'nj', 'zy', 'db', 'bc', 'sszq', 'jcqk']
|
||||
textFields.forEach(key => {
|
||||
const v = this.searchForm[key]
|
||||
if (v !== '' && v !== null && v !== undefined) params[key] = v.trim()
|
||||
})
|
||||
if (this.searchForm.pxlxChecked) params.pxlx = this.searchForm.pxlx
|
||||
if (this.searchForm.pxccChecked) params.pxcc = this.searchForm.pxcc
|
||||
if (this.searchForm.pxlx2Checked) params.pxlx2 = this.searchForm.pxlx2
|
||||
if (this.searchForm.xjydEnabled) params.xjyd = this.searchForm.xjyd
|
||||
if (this.searchForm.ksqkEnabled) params.ksqk = this.searchForm.ksqk
|
||||
if (this.searchForm.xbEnabled) params.xb = this.searchForm.xb
|
||||
if (this.searchForm.zcztEnabled) params.zczt = this.searchForm.zczt
|
||||
if (this.searchForm.txEnabled) params.txzt = this.searchForm.tx
|
||||
if (this.searchForm.gljgChecked) params.gljg = this.searchForm.gljg
|
||||
const ranges = [
|
||||
['bjgmMin', 'bjgmMax'],
|
||||
['lbjgmMin', 'lbjgmMax'],
|
||||
['bkcljgmMin', 'bkcljgmMax']
|
||||
]
|
||||
ranges.forEach(([minKey, maxKey]) => {
|
||||
if (this.searchForm[minKey] !== '' || this.searchForm[maxKey] !== '') {
|
||||
params[minKey] = this.searchForm[minKey]
|
||||
params[maxKey] = this.searchForm[maxKey]
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// ==================== 查询/分页 ====================
|
||||
handleSearch() {
|
||||
this.pagination.pageNum = 1
|
||||
this.loadData()
|
||||
this.$message.success('查询学员信息(前端模拟)')
|
||||
},
|
||||
handlePageChange(page) {
|
||||
this.pagination.pageNum = page
|
||||
@@ -428,38 +466,51 @@ export default {
|
||||
this.dialogVisible = true
|
||||
},
|
||||
|
||||
// TODO: 后端接口未提供,直接使用当前行数据;接口就绪后替换为 getStudentRecordsDetail
|
||||
handleEdit(row) {
|
||||
this.dialogTitle = '编辑学员'
|
||||
this.resetForm()
|
||||
Object.assign(this.formData, this.createEmptyForm(), row)
|
||||
this.dialogVisible = true
|
||||
if (!row.bh) {
|
||||
Object.assign(this.formData, this.createEmptyForm(), row)
|
||||
this.dialogVisible = true
|
||||
return
|
||||
}
|
||||
getStudentRecord(row.bh).then(res => {
|
||||
const data = res.data || {}
|
||||
Object.assign(this.formData, this.createEmptyForm(), data)
|
||||
this.dialogVisible = true
|
||||
}).catch(() => {})
|
||||
},
|
||||
|
||||
// TODO: 后端接口未提供,保存为前端模拟;接口就绪后替换为 addStudentRecords / updateStudentRecords
|
||||
// ==================== 新增/编辑提交 ====================
|
||||
handleSubmit() {
|
||||
this.$refs.formRef.validate((valid) => {
|
||||
this.$refs.formRef.validate(valid => {
|
||||
if (!valid) return
|
||||
this.submitting = true
|
||||
setTimeout(() => {
|
||||
this.$message.success(this.dialogTitle === '新增学员' ? '新增成功' : '编辑成功')
|
||||
const isAdd = this.dialogTitle === '新增学员'
|
||||
const payload = { ...this.formData }
|
||||
const request = isAdd ? addStudentRecord(payload) : updateStudentRecord(payload)
|
||||
request.then(() => {
|
||||
this.$message.success(isAdd ? '新增成功' : '编辑成功')
|
||||
this.dialogVisible = false
|
||||
this.loadData()
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
this.submitting = false
|
||||
}, 300)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// TODO: 后端接口未提供,删除为前端模拟;接口就绪后替换为 deleteStudentRecords
|
||||
// ==================== 删除 ====================
|
||||
handleDelete(row) {
|
||||
this.$confirm(`确定要删除"${row.xm}"吗?`, '删除确认', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.tableData = this.tableData.filter((r) => r.bh !== row.bh)
|
||||
this.pagination.total = this.tableData.length
|
||||
return delStudentRecord(row.bh)
|
||||
}).then(() => {
|
||||
this.$message.success('删除成功')
|
||||
this.loadData()
|
||||
}).catch(() => {})
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user