手机h5端-提案管理-撰写提案-邀请附议人: 新增清空按钮(如有值),搜索框新增自动搜索事件(300毫秒防抖动),修复取消勾选人员不生效;

This commit is contained in:
dd3s_206
2026-05-16 17:55:52 +08:00
parent fbf51efa50
commit 530579e52b
@@ -4,15 +4,18 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = {
<van-search <van-search
v-model="pageForm.searchKeyword" v-model="pageForm.searchKeyword"
:show-action="false" :show-action="false"
clearable
placeholder="请输入工号或者姓名查询" placeholder="请输入工号或者姓名查询"
@input="onSearchInput"
@search="doSearch" @search="doSearch"
@clear="clearSearch"
></van-search> ></van-search>
<van-tabs v-model="isInvite" @click="isInviteClick"> <van-tabs v-model="isInvite" @click="isInviteClick">
<van-tab title="已邀请" name="1"></van-tab> <van-tab title="已邀请" name="1"></van-tab>
<van-tab title="可邀请" name="0"></van-tab> <van-tab title="可邀请" name="0"></van-tab>
</van-tabs> </van-tabs>
<van-checkbox-group v-model="tableSelection" v-if="tableData && tableData.length>0"> <van-checkbox-group v-model="selectedLoginNames" v-if="tableData && tableData.length>0">
<van-cell-group > <van-cell-group >
<van-cell <van-cell
v-for="(item, index) in tableData" v-for="(item, index) in tableData"
@@ -28,9 +31,10 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = {
{{item.unitName}} {{item.unitName}}
</span> </span>
<van-checkbox <van-checkbox
:name="item" :name="item.loginName"
:ref="'checkboxes'+item.loginName" :ref="'checkboxes'+item.loginName"
slot="right-icon" slot="right-icon"
@click.stop
v-if="!pageForm.isInvite"></van-checkbox> v-if="!pageForm.isInvite"></van-checkbox>
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
@@ -62,13 +66,21 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = {
}, },
config: {}, config: {},
isInvite: "0", isInvite: "0",
tableSelection: [] selectedLoginNames: [],
selectedSeconders: {},
searchTimer: null
} }
}, },
methods: { methods: {
async onOpen(record) { async onOpen(record) {
this.visible = true this.visible = true
this.record = record this.record = record
this.isInvite = "0"
this.pageForm.isInvite = false
this.pageForm.pageNumber = 1
this.pageForm.searchKeyword = null
this.selectedLoginNames = []
this.selectedSeconders = {}
await this.getConfig() await this.getConfig()
this.pageData() this.pageData()
@@ -77,15 +89,15 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = {
detail(id) { detail(id) {
}, },
invite() { invite() {
if (this.tableSelection.length === 0) { if (this.selectedLoginNames.length === 0) {
this.$toast("请先选择附议人后在点击邀请") this.$toast("请先选择附议人后在点击邀请")
return return
} }
const loginNames = [...new Set(this.tableSelection.map((s) => s.loginName))] const loginNames = [...new Set(this.selectedLoginNames)]
const userName = [...new Set(this.tableSelection.map((s) => s.userName))] const userName = loginNames.map((loginName) => {
return this.selectedSeconders[loginName]?.userName || loginName
console.log(this.tableSelection) })
this.$dialog.confirm({ this.$dialog.confirm({
title: '提示', title: '提示',
@@ -98,7 +110,8 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = {
if (res.code === 0) { if (res.code === 0) {
this.pageData() this.pageData()
this.$toast.success(res.msg) this.$toast.success(res.msg)
this.tableSelection = [] this.selectedLoginNames = []
this.selectedSeconders = {}
// this.visible = false // this.visible = false
this.$emit("refresh", null) this.$emit("refresh", null)
} }
@@ -117,20 +130,14 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = {
if (res.code === 0) { if (res.code === 0) {
this.tableData = res.data.list this.tableData = res.data.list
this.pageForm.totalCount = res.data.totalCount this.pageForm.totalCount = res.data.totalCount
this.echoCheckBox() this.cacheCurrentPageSeconders()
} }
}) })
}, },
// 翻页回显勾选 cacheCurrentPageSeconders() {
echoCheckBox() { this.tableData.forEach((item) => {
this.$nextTick(() => { this.$set(this.selectedSeconders, item.loginName, item)
this.tableData.forEach((item) => {
const checkboxRef = this.$refs['checkboxes' + item.loginName]
if (checkboxRef && this.tableSelection.map((s) => s.loginName).includes(item.loginName)) {
checkboxRef[0].toggle()
}
})
}) })
}, },
@@ -139,13 +146,39 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = {
this.pageData() this.pageData()
}, },
onSearchInput(val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.doSearch()
}, 300)
},
clearSearch() {
clearTimeout(this.searchTimer)
this.pageForm.searchKeyword = null
this.doSearch()
},
isInviteClick(index, title) { isInviteClick(index, title) {
this.pageForm.isInvite = index === "1" this.pageForm.isInvite = index === "1"
this.doSearch() this.doSearch()
}, },
tableRowToggle(index) { tableRowToggle(index) {
console.log(index) if (this.pageForm.isInvite) {
return
}
const item = this.tableData[index]
if (!item) {
return
}
this.$set(this.selectedSeconders, item.loginName, item)
const checkedIndex = this.selectedLoginNames.indexOf(item.loginName)
if (checkedIndex > -1) {
this.selectedLoginNames.splice(checkedIndex, 1)
} else {
this.selectedLoginNames.push(item.loginName)
}
}, },
async getConfig() { async getConfig() {