const branchUnionUserManage = { template: /*language=HTML*/ `
{{ item.name }} * 添加
`, mixins: [initTableMixins], props: { union_id: { type: String, required: true }, // 父页面可传入可用高度;默认值保持组件在其他页面的原有展示能力。 table_height: { type: Number, default: null } }, data() { return { pageForm: { searchName: "username", j: "" }, dialogFormVisible: false, formData: {}, roleOptions: [], partySecretaryUnitOptions: [], leaveDialogVisible: false, leaveForm: { id: "", leaveDate: "" }, jOptions: [], usedJCodes: [] } }, watch: { union_id(val) { this.pageForm.j = "" this.initJSearch() } }, methods: { loadJOptions() { return $.get("/open/common/dictOptions", { code: "TEACHER_CONGRESS_J" }).then((res) => { this.jOptions = res.data || [] }) }, loadUsedJCodes() { if (!this.union_id) { this.usedJCodes = [] return $.Deferred().resolve().promise() } return $.get("/platform/sys/union/branchUnionUserUsedJData", { unionId: this.union_id }).then((res) => { if (res.code === 0) { this.usedJCodes = res.data || [] } }) }, hasCadreData(code) { return this.usedJCodes.includes(code) }, getHighestUsedJ() { if (!this.usedJCodes.length) { return "" } for (let i = this.jOptions.length - 1; i >= 0; i--) { if (this.usedJCodes.includes(this.jOptions[i].code)) { return this.jOptions[i].code } } return this.usedJCodes[0] }, initJSearch() { const optionTask = this.jOptions.length ? $.Deferred().resolve().promise() : this.loadJOptions() $.when(optionTask, this.loadUsedJCodes()).then(() => { // 页面初始化时不限定届次,默认展示该分工会所有届次的干部。 this.pageForm.j = "" this.pageData() }) }, handleJChange(val) { this.pageForm.j = val || "" this.doSearch() }, isLeft(row) { return row.isServing === false || row.isServing === 0 || row.displayStatus === "离任" }, isUnitPartySecretary() { return this.formData.roleCode === "UNIT_PARTY_SECRETARY" }, loadRoleOptions() { return $.get("/platform/sys/union/branchUnionRoleOptions").then((res) => { if (res.code === 0) { this.$set(this, "roleOptions", res.data || []) } }) }, loadPartySecretaryUnitOptions() { return $.get("/platform/sys/union/branchUnionPartySecretaryUnitOptions", { unionId: this.union_id }).then((res) => { if (res.code === 0) { this.$set(this, "partySecretaryUnitOptions", res.data || []) // 新增二级党委书记时,默认授权当前分工会下的全部二级单位。 this.$set(this.formData, "unitIds", this.partySecretaryUnitOptions.map(item => item.id)) } }) }, handleRoleChange() { if (this.isUnitPartySecretary()) { this.loadPartySecretaryUnitOptions() return } this.$set(this.formData, "unitIds", []) }, openAdd() { this.dialogFormVisible = true this.$nextTick(() => { this.formData = {} }) }, openLeave(row) { this.leaveForm = { id: row.id, leaveDate: "" } this.leaveDialogVisible = true }, doSubmit() { if (!this.formData.j) { this.$message.error("请选择届数") return } if (this.isUnitPartySecretary() && (!this.formData.unitIds || this.formData.unitIds.length === 0)) { this.$message.error("请选择所属单位") return } const submitUrl = this.isUnitPartySecretary() ? "/platform/sys/union/insertBranchUnionPartySecretaryRole" : "/platform/sys/union/insertBranchUnionUserRole" $.post(submitUrl, { ...this.formData, unitIds: JSON.stringify(this.formData.unitIds || []), unionId: this.union_id }).then((res) => { if (res.code === 0) { this.dialogFormVisible = false this.$message.success(res.msg) this.loadUsedJCodes() this.doSearch() } else { this.$message.error(res.msg) } }) }, doLeave() { if (!this.leaveForm.leaveDate) { this.$message.error("请选择离任时间") return } $.post("/platform/sys/union/leaveBranchUnionUserRole", this.leaveForm).then((res) => { if (res.code === 0) { this.leaveDialogVisible = false this.$message.success(res.msg) this.doSearch() } else { this.$message.error(res.msg) } }) }, doDelete({ userId, roleCode }) { this.$confirm("您确定要删除吗?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "info" }).then((res) => { $.post("/platform/sys/union/deleteBranchUnionUserRole", { userId, roleCode, unionId: this.union_id }).then((res) => { if (res.code === 0) { this.$message.success(res.msg) this.loadUsedJCodes() this.doSearch() } }) }) }, pageData() { $.get("/platform/sys/union/branchUnionUserPageData", { ...this.pageForm, unionId: this.union_id, j: this.pageForm.j || "" }).then((res) => { if (res.code === 0) { this.tableData = res.data } }) } }, created() { this.loadRoleOptions() this.initJSearch() }, style: /*language=CSS*/ ` /deep/ .el-select { width: 100% !important; } /deep/ .j-search-select { width: 80px !important; } .j-used-mark { color: #f56c6c; margin-left: 4px; font-weight: 700; } ` }