const branchUnionGroupManage = {
template: /*language=HTML*/ `
新增
编辑
删除
`,
mixins: [initTableMixins],
props: {
union_id: {
type: String,
required: true
},
// 工会小组列表包含分页,父页面传入高度后预留分页区域。
table_height: {
type: Number,
default: null
}
},
data() {
return {
pageForm: {},
formData: {},
rules: {
code: [{ required: true, message: "请输入小组编码", trigger: "blur" }],
name: [{ required: true, message: "请输入小组名称", trigger: "blur" }],
leaders: [{ required: true, message: "请选择小组长", trigger: "change" }],
unitIds: [{ required: true, message: "请选择组成单位", trigger: "change" }],
},
userOptions: [],
units: [],
}
},
methods: {
async openAdd() {
this.dialogFormVisible = true
await this.getUnits()
this.$nextTick(() => {
this.formData = {}
this.$refs.formRef.clearValidate()
})
},
async onEdit(row) {
this.formData = { ...row }
this.formData.unitIds = JSON.parse(row.unitIds)
this.formData.leaders = JSON.parse(row.leaders)
await this.getUnits(row.id)
this.getUserOptions(null, this.formData.leaders)
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs.formRef.clearValidate()
})
},
onSubmit() {
this.$refs.formRef.validate((valid) => {
if (valid) {
const { id } = this.formData
const url = "/platform/sys/unionGroup" + (id ? "/update" : "/insert")
const formData = clone(this.formData)
formData.unitIds = JSON.stringify(formData.unitIds)
formData.leaders = JSON.stringify(formData.leaders)
$.post(url, { ...formData, unionId: this.union_id }).then((res) => {
if (res.code === 0) {
this.$message.success(res.msg)
this.dialogFormVisible = false
this.doSearch()
}
})
}
})
},
onDelete(id) {
this.$confirm("您确定要删除吗, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
$.post("/platform/sys/unionGroup/delete/" + id).then((res) => {
if (res.code === 0) {
this.$message.success(res.msg)
this.pageData()
}
})
})
.catch(() => {})
},
pageData() {
$.get("/platform/sys/unionGroup/pageData", { ...this.pageForm, unionId: this.union_id }).then((res) => {
if (res.code === 0) {
this.tableData = res.data.list
this.pageForm.totalCount = res.data.totalCount
}
})
},
getUserOptions(keyword, userIds = null) {
$.get("/platform/sys/unionGroup/listUser", {
keyword,
unionId: this.union_id,
userIds: JSON.stringify(userIds)
}).then((res) => {
if (res.code === 0) {
this.userOptions = res.data
}
})
},
async getUnits(val) {
const resp = await this.$axios.post("/platform/sys/unionGroup/getUnits", {
unionId: this.union_id,
groupId: val
})
if (resp.code === 0) {
this.units = resp.data
}
}
}
}