diff --git a/src/main/resources/views/platform/zhghh5/democratic/proposal/transact/mine/inviteSeconder.js b/src/main/resources/views/platform/zhghh5/democratic/proposal/transact/mine/inviteSeconder.js index 3b18c5f..e39b7b6 100644 --- a/src/main/resources/views/platform/zhghh5/democratic/proposal/transact/mine/inviteSeconder.js +++ b/src/main/resources/views/platform/zhghh5/democratic/proposal/transact/mine/inviteSeconder.js @@ -4,15 +4,18 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = { - + @@ -62,13 +66,21 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = { }, config: {}, isInvite: "0", - tableSelection: [] + selectedLoginNames: [], + selectedSeconders: {}, + searchTimer: null } }, methods: { async onOpen(record) { this.visible = true 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() this.pageData() @@ -77,15 +89,15 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = { detail(id) { }, invite() { - if (this.tableSelection.length === 0) { + if (this.selectedLoginNames.length === 0) { this.$toast("请先选择附议人后在点击邀请") return } - const loginNames = [...new Set(this.tableSelection.map((s) => s.loginName))] - const userName = [...new Set(this.tableSelection.map((s) => s.userName))] - - console.log(this.tableSelection) + const loginNames = [...new Set(this.selectedLoginNames)] + const userName = loginNames.map((loginName) => { + return this.selectedSeconders[loginName]?.userName || loginName + }) this.$dialog.confirm({ title: '提示', @@ -98,7 +110,8 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = { if (res.code === 0) { this.pageData() this.$toast.success(res.msg) - this.tableSelection = [] + this.selectedLoginNames = [] + this.selectedSeconders = {} // this.visible = false this.$emit("refresh", null) } @@ -117,20 +130,14 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = { if (res.code === 0) { this.tableData = res.data.list this.pageForm.totalCount = res.data.totalCount - this.echoCheckBox() + this.cacheCurrentPageSeconders() } }) }, - // 翻页回显勾选 - echoCheckBox() { - this.$nextTick(() => { - 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() - } - }) + cacheCurrentPageSeconders() { + this.tableData.forEach((item) => { + this.$set(this.selectedSeconders, item.loginName, item) }) }, @@ -139,13 +146,39 @@ const PROPOSAL_INVITE_SECONDER_COMPONENT = { 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) { this.pageForm.isInvite = index === "1" this.doSearch() }, 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() {