diff --git a/src/main/resources/views/platform/zhgh/dayofficework/workflowmessage/form.js b/src/main/resources/views/platform/zhgh/dayofficework/workflowmessage/form.js new file mode 100644 index 0000000..059d716 --- /dev/null +++ b/src/main/resources/views/platform/zhgh/dayofficework/workflowmessage/form.js @@ -0,0 +1,363 @@ +const WORKFLOW_MESSAGE_FORM = { + template: /*language=HTML*/ ` +
+ + + + + + +
(温馨提醒:如选择是,将会在审核通过后同步发送到企业微信。)
+ + + + +
+ + + + 选择用户 + 清空用户 + + + + + + + + + + + +

总计:{{ userTableData.length }}人

+
+ + + + + + + + 取消 + 提交审核 + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
人员列表
+ + + + + + + + + + + + + + + + 取 消 + 确 定 + +
+
+ `, + mixins: [initTableMixins], + data() { + return { + formData: {}, + taskId: null, + userTableData: [], + tableData: [], + selectUsers: [], + selectUnitList: [], + unionList: [], + unitList: [], + clubList: [], + roleList: [], + selectDialogVisible: false, + tableLoading: false, + formLoading: false, + pageForm: { + searchName: "u.username", + searchKeyword: "", + pageNumber: 1, + pageSize: 10, + totalCount: 0, + pageOrderName: "", + pageOrderBy: "" + }, + formRules: { + title: [{ required: true, message: "必填", trigger: ["blur", "change"] }], + note: [{ required: true, message: "必填", trigger: ["blur", "change"] }], + needBack: [{ required: true, message: "必填", trigger: ["blur", "change"] }], + wechatEnterprise: [{ required: true, message: "必填", trigger: ["blur", "change"] }] + } + } + }, + computed: { + isSchoolMsgScope() { + return this.$auth.hasPermission("dayofficework.message.workflow.school") + }, + isUnionMsgScope() { + return !this.isSchoolMsgScope && this.$auth.hasPermission("dayofficework.message.workflow.union") + }, + isClubMsgScope() { + return !this.isSchoolMsgScope && this.$auth.hasPermission("dayofficework.message.workflow.club") + }, + showUnionSelect() { + return this.isSchoolMsgScope + }, + showUnitSelect() { + return this.isSchoolMsgScope || this.isUnionMsgScope + }, + showClubSelect() { + return this.isSchoolMsgScope || this.isClubMsgScope + }, + showRoleSelect() { + return this.isSchoolMsgScope + } + }, + methods: { + initAdd() { + this.formData = { + id: "", + needBack: false, + wechatEnterprise: false + } + this.taskId = null + this.userTableData = [] + this.selectUsers = [] + if (this.$refs.formRef) { + this.$refs.formRef.resetFields() + } + if (this.$refs.tableRef) { + this.$refs.tableRef.clearSelection() + } + }, + // 编辑撤回后的消息申请:row 为申请列表当前行,需包含 id 和 startTaskId;详情接口返回 message 与 receivers 用于回填表单。 + initEdit(row) { + this.taskId = row.startTaskId || row.taskId + this.$axios.post("/platform/dayofficework/workflowmessage/info", { id: row.id }).then((res) => { + if (res.code === 0) { + this.formData = res.data.message + this.userTableData = res.data.receivers.map((receiver) => { + return { + id: receiver.userId, + loginname: receiver.loginName, + username: receiver.userName, + sex: receiver.sex, + mobile: receiver.mobile, + userState: receiver.userState, + personType: receiver.personType, + unitname: receiver.unitName, + unionname: receiver.unionName + } + }) + this.selectUsers = [] + if (this.$refs.formRef) { + this.$refs.formRef.clearValidate() + } + if (this.$refs.tableRef) { + this.$refs.tableRef.clearSelection() + } + } else { + this.$message.warning(res.msg) + } + }) + }, + back() { + this.$emit("back") + }, + // 初始化表单选人基础数据:单位、工会、协会、角色用于选人弹窗筛选条件。 + initSelectData() { + this.$businessTool.listUnit().then((data) => { + this.unitList = data + if (this.isSchoolMsgScope) { + this.selectUnitList = data + } + }) + this.$businessTool.listUnion().then((data) => { + this.unionList = data + }) + this.$businessTool.listCLubByRole().then((data) => { + this.clubList = data + }) + this.$axios.post("/platform/dayofficework/workflowmessage/roleList").then((res) => { + if (res.code === 0) { + this.roleList = res.data + } + }) + }, + getCurrentUnionId() { + return this.$store.state.user.union && this.$store.state.user.union.id ? this.$store.state.user.union.id : "" + }, + applyMsgScope(resetUnitId) { + if (!this.showRoleSelect) { + this.$set(this.pageForm, "roleId", null) + } + if (!this.showUnitSelect) { + this.$set(this.pageForm, "unitId", null) + } + if (!this.showClubSelect) { + this.$set(this.pageForm, "clubId", null) + } + if (this.isUnionMsgScope) { + const unionId = this.getCurrentUnionId() + this.$set(this.pageForm, "unionId", unionId) + if (resetUnitId) { + this.$set(this.pageForm, "unitId", null) + this.selectUnitList = [] + } + if (unionId && (resetUnitId || this.selectUnitList.length === 0)) { + this.$businessTool.listUnit(unionId).then((data) => { + this.selectUnitList = data + }) + } + return + } + if (this.isSchoolMsgScope) { + this.selectUnitList = this.unitList + return + } + this.$set(this.pageForm, "unionId", null) + this.selectUnitList = [] + }, + flushUnits() { + this.$set(this.pageForm, "unitId", null) + this.selectUnitList = [] + if (this.pageForm.unionId) { + this.$businessTool.listUnit(this.pageForm.unionId).then((data) => { + this.selectUnitList = data + }) + } + this.doSearch() + }, + openSelect() { + this.applyMsgScope(true) + this.selectDialogVisible = true + this.pageData() + }, + clearSelect() { + this.userTableData = [] + if (this.$refs.tableRef) { + this.$refs.tableRef.clearSelection() + } + }, + handleSelectionChange(val) { + this.selectUsers = val + }, + pageData() { + this.applyMsgScope(false) + this.tableLoading = true + this.$axios.post("/platform/dayofficework/workflowmessage/userData", this.pageForm).then((res) => { + if (res.code === 0) { + this.tableData = res.data.list + this.pageForm.totalCount = res.data.totalCount + } else { + this.$message.warning(res.msg) + } + }).finally(() => { + this.tableLoading = false + }) + }, + doSelect() { + const tableLoginNames = this.userTableData.map((v) => v.loginname) + const selectUsers = this.selectUsers.length > 0 ? this.selectUsers : (this.$refs.tableRef && this.$refs.tableRef.selection ? this.$refs.tableRef.selection : []) + if (selectUsers.length === 0) { + this.$message.warning("请选择用户") + return + } + selectUsers.forEach((o) => { + if (!tableLoginNames.includes(o.loginname)) { + this.userTableData.push(o) + } + }) + if (this.$refs.tableRef) { + this.$refs.tableRef.clearSelection() + } + this.selectDialogVisible = false + }, + doSubmit() { + this.$refs.formRef.validate((valid) => { + if (!valid) { + return + } + const loginNames = this.userTableData.map((u) => u.loginname) + if (loginNames.length === 0) { + this.$message.warning("请选择用户") + return + } + if (loginNames.length > 100) { + this.$message.warning("单条消息最多发送100人,请分批次发送。") + return + } + this.$confirm("您确定要提交消息发送申请吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(() => { + this.formLoading = true + const url = this.formData.id ? "/platform/dayofficework/workflowmessage/updateSubmit" : "/platform/dayofficework/workflowmessage/submit" + const params = { + message: JSON.stringify(this.formData), + users: JSON.stringify(loginNames) + } + if (this.formData.id) { + this.$set(params, "taskId", this.taskId) + } + this.$axios.post(url, params).then((res) => { + if (res.code === 0) { + this.$message.success(res.msg) + this.$emit("success") + this.back() + } else { + this.$message.error(res.msg) + } + }).finally(() => { + this.formLoading = false + }) + }) + }) + } + }, + created() { + this.initSelectData() + } +}