diff --git a/src/main/java/io/v/nutz/wakershome/controller/declaration/WakesHomeDeclarationMineController.java b/src/main/java/io/v/nutz/wakershome/controller/declaration/WakesHomeDeclarationMineController.java index 3f356ad..7b76ddb 100644 --- a/src/main/java/io/v/nutz/wakershome/controller/declaration/WakesHomeDeclarationMineController.java +++ b/src/main/java/io/v/nutz/wakershome/controller/declaration/WakesHomeDeclarationMineController.java @@ -1,6 +1,10 @@ package io.v.nutz.wakershome.controller.declaration; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import com.deepoove.poi.XWPFTemplate; +import com.deepoove.poi.config.Configure; +import com.deepoove.poi.policy.HackLoopTableRenderPolicy; import io.v.nutz.annontation.ViReturn; import io.v.nutz.base.utils.Vi; import io.v.nutz.modules.models.Audit; @@ -8,8 +12,10 @@ import io.v.nutz.modules.models.PageForm; import io.v.nutz.util.ShiroUtil; import io.v.nutz.wakershome.model.WakesHomeApply; import io.v.nutz.wakershome.service.IWakesHomeApplyService; +import io.v.nutz.web.commons.base.Globals; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.ddr.poi.html.HtmlRenderPolicy; import org.nutz.aop.interceptor.ioc.TransAop; import org.nutz.dao.Cnd; import org.nutz.dao.Sqls; @@ -17,10 +23,15 @@ import org.nutz.dao.sql.Sql; import org.nutz.ioc.aop.Aop; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.util.NutMap; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; +import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; +import java.util.HashMap; + /** * @version 1.0 * @Author zzr @@ -39,15 +50,16 @@ public class WakesHomeDeclarationMineController { @At("") @Ok("beetl:/platform/wakeshome/declaration/mine.html") @RequiresPermissions("wakeshome.declaration.mine") - public void index() {} + public void index() { + } @At @ViReturn @RequiresPermissions("wakeshome.declaration.mine") public Object pageData(PageForm pageForm, - @Param(value = "year",required = false) Integer year, - @Param(value = "unionId",required = false) String unionId){ + @Param(value = "year", required = false) Integer year, + @Param(value = "unionId", required = false) String unionId) { Sql sql = Sqls.create(""" SELECT wh.*, @@ -59,9 +71,9 @@ public class WakesHomeDeclarationMineController { $condition """); Cnd cnd = Cnd.NEW(); - cnd.andEX("YEAR(wh.applyDate)","=",year); - if (!ShiroUtil.hasAnyRoles("sysadmin,A06")){ - cnd.and("unionId","=", Vi.getUnionId()); + cnd.andEX("YEAR(wh.applyDate)", "=", year); + if (!ShiroUtil.hasAnyRoles("sysadmin,A06")) { + cnd.and("unionId", "=", Vi.getUnionId()); } else { cnd.andEX("unionId", "=", unionId); } @@ -73,16 +85,63 @@ public class WakesHomeDeclarationMineController { @At @ViReturn @Aop(TransAop.READ_COMMITTED) - @RequiresPermissions(value = {"wakeshome.declaration.apply","wakeshome.declaration.mine"},logical = Logical.OR) + @RequiresPermissions(value = {"wakeshome.declaration.apply", "wakeshome.declaration.mine"}, logical = Logical.OR) public Object doDelete(String id) { WakesHomeApply apply = wakesHomeApplyService.fetch(id); if (StrUtil.isNotBlank(apply.getOrganizationAuditId())) { - wakesHomeApplyService.dao().delete(Audit.class,apply.getOrganizationAuditId()); + wakesHomeApplyService.dao().delete(Audit.class, apply.getOrganizationAuditId()); } if (StrUtil.isNotBlank(apply.getSchoolAuditId())) { - wakesHomeApplyService.dao().delete(Audit.class,apply.getSchoolAuditId()); + wakesHomeApplyService.dao().delete(Audit.class, apply.getSchoolAuditId()); } wakesHomeApplyService.delete(id); return null; } + + @At + @Ok("void") + public void openExport(String id, HttpServletResponse response) { + + try { + NutMap nutMap = wakesHomeApplyService.findById(id); + + + HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); + HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy(); + htmlRenderPolicy.getConfig().setShowDefaultTableBorderInTableCell(true); + + Configure config = Configure.newBuilder() + .bind("basicInformation", htmlRenderPolicy) + .bind("constructionPlan", htmlRenderPolicy).build(); + HashMap map = new HashMap<>(); + String fileName = Globals.schoolName + "教工小家”建设计划书"; + map.put("fileName", fileName); + map.put("schoolName", Globals.schoolName); + map.put("unionName", nutMap.getString("unionName")); + map.put("applyDate", nutMap.getString("applyDate")); + map.put("username", nutMap.getString("username")); + map.put("mobile", nutMap.getString("mobile")); + map.put("basicInformation", nutMap.getString("basicInformation")); + map.put("constructionPlan", nutMap.getString("constructionPlan")); + NutMap schoolAudit = nutMap.getAs("schoolAudit", NutMap.class); + NutMap organizationAudit = nutMap.getAs("organizationAudit", NutMap.class); + schoolAudit.setv("auditTime", DateUtil.formatDate(schoolAudit.getTime("auditTime"))); + schoolAudit.setv("auditSign", Vi.getImg(schoolAudit.getString("auditSign"))); + organizationAudit.setv("auditTime", DateUtil.formatDate(organizationAudit.getTime("auditTime"))); + organizationAudit.setv("auditSign", Vi.getImg(organizationAudit.getString("auditSign"))); + map.put("organizationAudit", organizationAudit); + map.put("schoolAudit", schoolAudit); + + + response.addHeader("Content-Type", "application/octet-stream"); + response.addHeader("Content-Disposition", "attachment; filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\".docx"); + InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("docTemplate/wakeshome/wakeshome.docx"); + XWPFTemplate.compile(inputStream, config).render(map, response.getOutputStream()); + inputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + + } } diff --git a/src/main/java/io/v/nutz/wakershome/controller/info/WakesHomeApplyController.java b/src/main/java/io/v/nutz/wakershome/controller/info/WakesHomeApplyController.java index aec64f7..1a76629 100644 --- a/src/main/java/io/v/nutz/wakershome/controller/info/WakesHomeApplyController.java +++ b/src/main/java/io/v/nutz/wakershome/controller/info/WakesHomeApplyController.java @@ -65,6 +65,6 @@ public class WakesHomeApplyController { @RequiresPermissions("wakeshome.info.apply") public Object validateApply(){ int count = wakesHomeInfoService.dao().count(WakesHomeApply.class, Cnd.where("state", "=", "10030").and("unionId", "=", Vi.getUnionId())); - return (count > 0) ? Result.error() : Result.success(); + return (count > 0) ? Result.success() : Result.error(); } } diff --git a/src/main/resources/docTemplate/wakeshome/wakeshome.docx b/src/main/resources/docTemplate/wakeshome/wakeshome.docx new file mode 100644 index 0000000..92def59 Binary files /dev/null and b/src/main/resources/docTemplate/wakeshome/wakeshome.docx differ diff --git a/src/main/resources/static/assets/platform/module/basics/basics.js b/src/main/resources/static/assets/platform/module/basics/basics.js index 631e86d..be22517 100644 --- a/src/main/resources/static/assets/platform/module/basics/basics.js +++ b/src/main/resources/static/assets/platform/module/basics/basics.js @@ -55,6 +55,10 @@ const FILE_PREVIEW_ADDRESS = '/file_server/preview' const FILE_DOWNLOAD_ADDRESS = '/file_server/download' const FILE_STREAM_PREVIEW_ADDRESS = '/file_server/fileStreamPreview' +const CREATE_PREVIEW_URL = (val) => { + return FILE_STREAM_PREVIEW_ADDRESS + "?id=" + val +} + const preview = async (filename, id) => { const suffix = filename.substring(filename.lastIndexOf('.') + 1) @@ -1955,4 +1959,4 @@ const loc = () => { const clone = (obj) => { return JSON.parse(JSON.stringify(obj)) -} \ No newline at end of file +} diff --git a/src/main/resources/static/components/plugins/ImageUpload.vue b/src/main/resources/static/components/plugins/ImageUpload.vue new file mode 100644 index 0000000..9da8b47 --- /dev/null +++ b/src/main/resources/static/components/plugins/ImageUpload.vue @@ -0,0 +1,242 @@ + + + + + diff --git a/src/main/resources/static/components/wakeshome/declaration/WakesHomeInfoApply.vue b/src/main/resources/static/components/wakeshome/declaration/WakesHomeInfoApply.vue index cf48700..2b23de1 100644 --- a/src/main/resources/static/components/wakeshome/declaration/WakesHomeInfoApply.vue +++ b/src/main/resources/static/components/wakeshome/declaration/WakesHomeInfoApply.vue @@ -23,7 +23,9 @@ 基本情况简介 - {{ viewData.basicInformation }} + +
+ diff --git a/src/main/resources/static/components/wakeshome/info/WakesHomeInfo.vue b/src/main/resources/static/components/wakeshome/info/WakesHomeInfo.vue index 2c2a3f9..42799b1 100644 --- a/src/main/resources/static/components/wakeshome/info/WakesHomeInfo.vue +++ b/src/main/resources/static/components/wakeshome/info/WakesHomeInfo.vue @@ -131,8 +131,7 @@ module.exports = { }, methods: { async openView(id) { - console.log(id) - const resp = await $.get('/platform/wakeshome/mine/getInfoById', {id: id}) + const resp = await $.get('/platform/wakeshome/info/mine/getInfoById', {id: id}) if (resp.code === 0) { this.viewData = resp.data this.schoolAudit = resp.data.schoolAudit diff --git a/src/main/resources/views/layouts/platform.html b/src/main/resources/views/layouts/platform.html index 8c256c0..4db11aa 100644 --- a/src/main/resources/views/layouts/platform.html +++ b/src/main/resources/views/layouts/platform.html @@ -132,6 +132,7 @@ Vue.component('file-upload', httpVueLoader('/components/plugins/FileUpload.vue')) Vue.component('text-editor', httpVueLoader('/components/plugins/textEditor.vue')) Vue.component('border-table', httpVueLoader('/components/plugins/BorderTable.vue')) + Vue.component('image-upload', httpVueLoader('/components/plugins/ImageUpload.vue')) diff --git a/src/main/resources/views/platform/wakeshome/declaration/apply.html b/src/main/resources/views/platform/wakeshome/declaration/apply.html index d12c38c..c2fa196 100644 --- a/src/main/resources/views/platform/wakeshome/declaration/apply.html +++ b/src/main/resources/views/platform/wakeshome/declaration/apply.html @@ -30,7 +30,7 @@ layout("/layouts/platform.html"){ - + @@ -45,7 +45,7 @@ layout("/layouts/platform.html"){ - + @@ -58,28 +58,30 @@ layout("/layouts/platform.html"){ - + - - + + + - - + 保 存 - 提 交 + 提 交 + @@ -90,19 +92,43 @@ layout("/layouts/platform.html"){ const vue = new Vue({ el: '#app', mixins: [initTableMixins], - data:{ - id: '', - formData: {}, - formRules: { - mobile: [{ required: true, message: '手机号不能为空', trigger: 'blur' }, - { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号格式', trigger: 'blur' }], - basicInformation: [{required: true, message: '必填', trigger: ['blur', 'change']}], - constructionPlan: [{required: true, message: '必填', trigger: ['blur', 'change']}], - }, + data() { + const validBasicInformation = (rule, value, callback) => { + if (!this.formData.basicInformation || !dd3s.html2txt(this.formData.basicInformation)) { + callback(new Error('请填写基层工会简况')); + } else if (dd3s.html2txt(this.formData.basicInformation).length > 500) { + console.log(11) + callback(new Error('基层工会简况最多500字')); + } else { + callback(); + } + }; + return { + id: '', + formData: {}, + formRules: { + mobile: [{required: true, message: '手机号不能为空', trigger: 'blur'}, + {pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号格式', trigger: 'blur'}], + basicInformation: [{ + required: true, + message: '必填', + trigger: ['blur', 'change'] + }], + constructionPlan: [{ + required: true, + message: '必填', + trigger: ['blur', 'change'] + }], + basicInformation: [{ + validator: validBasicInformation, + trigger: ['blur', 'change'] + }], + }, + } }, - methods:{ - async doSave(){ - const resp = await $.post('/platform/wakeshome/declaration/apply/doSave',this.formData) + methods: { + async doSave() { + const resp = await $.post('/platform/wakeshome/declaration/apply/doSave', this.formData) if (resp.code === 0) { this.$message.success('保存成功') setTimeout(() => { @@ -112,11 +138,11 @@ layout("/layouts/platform.html"){ this.$message.warning('操作失败') } }, - async doSubmit(){ + async doSubmit() { try { const valid = await this.$refs.form.validate() if (valid) { - const resp = await $.post('/platform/wakeshome/declaration/apply/doSubmit',this.formData) + const resp = await $.post('/platform/wakeshome/declaration/apply/doSubmit', this.formData) if (resp.code === 0) { this.$message.success('提交成功') setTimeout(() => { @@ -127,7 +153,7 @@ layout("/layouts/platform.html"){ } } } catch (e) { - this.$message.warning('操作失败') + // this.$message.warning('请查看是否按要求填写') } }, async initFormData() { @@ -135,17 +161,17 @@ layout("/layouts/platform.html"){ this.$set(this.formData, 'username', "${@shiro.getPrincipalProperty('username')}") this.$set(this.formData, 'loginName', "${@shiro.getPrincipalProperty('loginname')}") this.$set(this.formData, 'mobile', "${@shiro.getPrincipalProperty('mobile')}") - this.$set(this.formData, 'applyTime', moment().format('YYYY-MM-DD')) + this.$set(this.formData, 'applyDate', moment().format('YYYY-MM-DD')) this.$set(this.formData, 'unionName', "${@shiro.getPrincipalProperty('union').getUnionname()}") } else { - const resp = await $.get('/platform/wakeshome/mine/getInfoById',{id:this.id}) - if (resp.code === 0){ + const resp = await $.get('/platform/wakeshome/declaration/apply/getInfoById', {id: this.id}) + if (resp.code === 0) { this.formData = resp.data } } }, }, - async created(){ + async created() { this.id = GetQueryString("id") this.initFormData(); } diff --git a/src/main/resources/views/platform/wakeshome/declaration/mine.html b/src/main/resources/views/platform/wakeshome/declaration/mine.html index ac26794..0380d4c 100644 --- a/src/main/resources/views/platform/wakeshome/declaration/mine.html +++ b/src/main/resources/views/platform/wakeshome/declaration/mine.html @@ -11,76 +11,89 @@ layout("/layouts/platform.html"){
年度:
+ type="year" + v-model="pageForm.year" + value-format="yyyy">
所属工会:
- - + v-model="pageForm.unionId"> +
- 搜索 + 搜索
- - + + - - + - + @@ -112,7 +125,7 @@ layout("/layouts/platform.html"){ {prop: 'username', label: '申报人', sortable: true}, {prop: 'loginName', label: '申报人工号', sortable: true}, {prop: 'mobile', label: '联系方式', sortable: true}, - {prop: 'basicInformation', label: '基本情况简介', sortable: true}, + // {prop: 'basicInformation', label: '基本情况简介', sortable: true}, {prop: 'applyDate', label: '申报日期', sortable: true}, {prop: 'stateName', label: '审核状态', sortable: true}, ], @@ -123,6 +136,9 @@ layout("/layouts/platform.html"){ 'wakes-info-apply': httpVueLoader('/components/wakeshome/declaration/WakesHomeInfoApply.vue') }, methods: { + openExport(id) { + window.open(loc() + "/openExport?id=" + id) + }, openView(row) { this.$refs.guava.view() this.$refs.viewInfo.openView(row.id) diff --git a/src/main/resources/views/platform/wakeshome/declaration/organizationAudit.html b/src/main/resources/views/platform/wakeshome/declaration/organizationAudit.html index 98e2ffc..1c18221 100644 --- a/src/main/resources/views/platform/wakeshome/declaration/organizationAudit.html +++ b/src/main/resources/views/platform/wakeshome/declaration/organizationAudit.html @@ -150,7 +150,7 @@ layout("/layouts/platform.html"){ {prop: 'username', label: '申报人', sortable: true}, {prop: 'loginName', label: '申报人工号', sortable: true}, {prop: 'mobile', label: '联系方式', sortable: true}, - {prop: 'basicInformation', label: '基本情况简介', sortable: true}, + // {prop: 'basicInformation', label: '基本情况简介', sortable: true}, {prop: 'applyDate', label: '申报日期', sortable: true}, {prop: 'stateName', label: '审核状态', sortable: true}, ], diff --git a/src/main/resources/views/platform/wakeshome/declaration/schoolAudit.html b/src/main/resources/views/platform/wakeshome/declaration/schoolAudit.html index 768dd63..e2c880d 100644 --- a/src/main/resources/views/platform/wakeshome/declaration/schoolAudit.html +++ b/src/main/resources/views/platform/wakeshome/declaration/schoolAudit.html @@ -150,7 +150,7 @@ layout("/layouts/platform.html"){ {prop: 'username', label: '申报人', sortable: true}, {prop: 'loginName', label: '申报人工号', sortable: true}, {prop: 'mobile', label: '联系方式', sortable: true}, - {prop: 'basicInformation', label: '基本情况简介', sortable: true}, + // {prop: 'basicInformation', label: '基本情况简介', sortable: true}, {prop: 'applyDate', label: '申报日期', sortable: true}, {prop: 'stateName', label: '审核状态', sortable: true}, ], diff --git a/src/main/resources/views/platform/wakeshome/info/apply.html b/src/main/resources/views/platform/wakeshome/info/apply.html index 27ce00d..f1575b5 100644 --- a/src/main/resources/views/platform/wakeshome/info/apply.html +++ b/src/main/resources/views/platform/wakeshome/info/apply.html @@ -134,7 +134,7 @@ layout("/layouts/platform.html"){ @@ -238,9 +238,9 @@ layout("/layouts/platform.html"){ async doSave() { let postUrl = '' if (this.formData.id) { - postUrl = '/platform/wakeshome/apply/doEdit' + postUrl = loc()+'/doEdit' } else { - postUrl = '/platform/wakeshome/apply/doAdd' + postUrl = loc()+'/doAdd' } const formData = this.doJsonStr(this.formData) formData.isSubmit = false; @@ -248,7 +248,7 @@ layout("/layouts/platform.html"){ if (resp.code === 0) { this.notifySuccess(resp.msg) setTimeout(() => { - sublime.jumpPagePjax('/platform/wakeshome/mine') + sublime.jumpPagePjax('/platform/wakeshome/declaration/mine') }, 500) } else { this.notifyWarning(resp.msg) @@ -260,9 +260,9 @@ layout("/layouts/platform.html"){ if (valid) { let postUrl = '' if (this.formData.id) { - postUrl = '/platform/wakeshome/apply/doEdit' + postUrl = loc()+'/doEdit' } else { - postUrl = '/platform/wakeshome/apply/doAdd' + postUrl = loc()+'/doAdd' } const formData = this.doJsonStr(this.formData) formData.isSubmit = true @@ -270,7 +270,7 @@ layout("/layouts/platform.html"){ if (resp.code === 0) { this.notifySuccess(resp.msg) setTimeout(() => { - sublime.jumpPagePjax('/platform/wakeshome/mine') + sublime.jumpPagePjax('/platform/wakeshome/declaration/mine') }, 500) } else { this.notifyWarning(resp.msg) @@ -296,7 +296,7 @@ layout("/layouts/platform.html"){ this.$set(this.formData, 'applyTime', moment().format('YYYY-MM-DD')) this.$set(this.formData, 'unionName', "${@shiro.getPrincipalProperty('union').getUnionname()}") } else { - const resp = await $.get('/platform/wakeshome/mine/getInfoById',{id:this.id}) + const resp = await $.get('/platform/wakeshome/declaration/mine/getInfoById',{id:this.id}) if (resp.code === 0){ this.formData = {...resp.data} } diff --git a/src/main/resources/views/platform/wakeshome/info/info.html b/src/main/resources/views/platform/wakeshome/info/info.html index 0984373..e0853a1 100644 --- a/src/main/resources/views/platform/wakeshome/info/info.html +++ b/src/main/resources/views/platform/wakeshome/info/info.html @@ -136,11 +136,11 @@ layout("/layouts/platform.html"){ -
+
{{item.unionName}}
|
- 位置:{{item.position}} + 查看位置
diff --git a/src/main/resources/views/platform/wakeshome/info/mine.html b/src/main/resources/views/platform/wakeshome/info/mine.html index 96eb385..421b010 100644 --- a/src/main/resources/views/platform/wakeshome/info/mine.html +++ b/src/main/resources/views/platform/wakeshome/info/mine.html @@ -11,62 +11,75 @@ layout("/layouts/platform.html"){
年度:
+ type="year" + v-model="pageForm.year" + value-format="yyyy">
所属工会:
- - + v-model="pageForm.unionId"> +
- 搜索 + 搜索
- - + + - - + - + @@ -83,13 +96,13 @@ layout("/layouts/platform.html"){