Commit 8304bb74 authored by 小费同学阿's avatar 小费同学阿 💬

进度信息模块封装ui代码优化2

parent d309fdb2
...@@ -115,6 +115,7 @@ ...@@ -115,6 +115,7 @@
:data="recordList" :data="recordList"
:header-cell-style="{background:'#E8E9E8'}" :header-cell-style="{background:'#E8E9E8'}"
border border
@select="selectChange"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<el-table-column align="center" type="selection" width="55"/> <el-table-column align="center" type="selection" width="55"/>
...@@ -190,6 +191,12 @@ export default { ...@@ -190,6 +191,12 @@ export default {
dicts: ['pet_insure'], dicts: ['pet_insure'],
data() { data() {
return { return {
// 所有挂号信息ID(选择全部-临时表)
registerIds: [],
// 所有挂号信息ID(在不点击选择全部时-临时表)
registerEmptyIds: [],
// 所有挂号信息ID(用于辅助, 里面的数据永远不变, 除了 新增/删除 数据时)
registerIdsForever: [],
doctorNameList: [], doctorNameList: [],
deptIdList: [], deptIdList: [],
departIdList: [], departIdList: [],
...@@ -269,49 +276,72 @@ export default { ...@@ -269,49 +276,72 @@ export default {
name: 'MedicalDetail', params: { id: row.id } name: 'MedicalDetail', params: { id: row.id }
}) })
}, },
/**
* 全部选择 // 选择全部
* @param selection 已选择内容 checkAll() {
* @param all 是否永远进行全选操作 this.registerIds = this.registerIdsForever
*/ // 标志位, 使得@select回调函数判断往哪个临时集合里添加
async selectAll(selection = [], all = true) { this.isCheckAll = true
// 如果已经全选并且是非一直全选操作则清空选择 // 调用手动勾选
if (this.recordList.length !== selection.length && !all) { this.manualCheck()
this.effectTableSelect([]) console.log('全部选择', this.isCheckAll)
},
// 手动勾选
manualCheck() {
// 在下一个dom触发
this.$nextTick().then(() => {
// 当前页结合数据的id只要在临时集合里,就使得复选框勾选
this.registerList.forEach(item => {
if (this.isCheckAll) {
if (this.registerIds.includes(item.id)) {
this.$refs.table.toggleRowSelection(item, true)
}
} else {
if (this.registerEmptyIds.includes(item.id)) {
this.$refs.table.toggleRowSelection(item, true)
}
}
})
})
},
// 反向选择(把永久临时集合和变化的临时集合做减法重新赋给变化的临时集合赋给)
reverseSelection() {
console.log('永久的集合', this.registerIdsForever)
console.log('临时集合', this.registerEmptyIds)
if (this.isCheckAll) {
this.registerEmptyIds = this.registerIdsForever.filter(id => !this.registerIds.includes(id))
} else { } else {
await this.changeTableSelect() this.registerEmptyIds = this.registerIdsForever.filter(id => !this.registerEmptyIds.includes(id))
} }
this.isCheckAll = false
this.getList()
}, },
// 反向选择 // 表格当前手动勾选的
reverseSelect() { selectChange(selection, row) {
this.changeTableSelect(this.ids) console.log('selectChange', selection, '----', row)
}, if (this.isCheckAll) {
/** // 判断当前选中的存不存在,存在删除;不存在添加
* 改变table选择项 if (this.registerIds.includes(row.id)) {
* @param notIncludeIds 需要排除的id列表 this.registerIds = this.registerIds.filter(id => id !== row.id)
*/ console.log('filter', this.registerIds.filter(id => id !== row.id))
async changeTableSelect(notIncludeIds = []) { } else {
// 获取反选的数据 this.registerIds.push(row.id)
// 需要一个可以根据条件和params.notIncludeIds排除部分数据的不分页查询的接口
const { data } = await listAllArticle({
...this.queryParams,
params: {
notIncludeIds,
sort: this.queryParams.params.sort
} }
}) } else {
this.effectTableSelect(data) if (this.registerEmptyIds.includes(row.id)) {
}, this.registerEmptyIds = this.registerEmptyIds.filter(id => id !== row.id)
/** } else {
* 控制table的选择项 this.registerEmptyIds.push(row.id)
* @param data }
*/ }
effectTableSelect(data = []) {
this.$refs.table.store.states.selection = data
this.$refs.table.store.updateSelectionByRowKey()
this.$refs.table.store.updateAllSelected()
this.$refs.table.$emit('selection-change', data)
}, },
/** 功能按钮--导出按钮操作 */ /** 功能按钮--导出按钮操作 */
handleExport() { handleExport() {
console.log('queryParams', this.queryParams) console.log('queryParams', this.queryParams)
...@@ -325,10 +355,10 @@ export default { ...@@ -325,10 +355,10 @@ export default {
// 重置选择 // 重置选择
.then(_ => this.effectTableSelect([])) .then(_ => this.effectTableSelect([]))
}, },
/** 列表区--多选框选中数据 */ // /** 列表区--多选框选中数据 */
handleSelectionChange(selection) { // handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) // this.ids = selection.map(item => item.id)
}, // },
/** 查询病例管理列表 */ /** 查询病例管理列表 */
getList() { getList() {
this.loading = true this.loading = true
...@@ -336,8 +366,12 @@ export default { ...@@ -336,8 +366,12 @@ export default {
console.log('病历列表的数据:', response) console.log('病历列表的数据:', response)
this.recordList = response.rows.rows this.recordList = response.rows.rows
console.log('这是病历,我要开始取字段了!', this.recordList) console.log('这是病历,我要开始取字段了!', this.recordList)
// 获取全部挂号的id
this.registerIds = response.rows.idList
this.registerIdsForever = response.rows.idList
this.total = response.total this.total = response.total
this.loading = false this.loading = false
this.manualCheck()
// 取消按钮 // 取消按钮
}) })
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment