天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 716|回复: 4

[已解决] 怎么做一个投票板块

[复制链接]
深圳国旅 发表于 2013-12-22 16:22:44 | 显示全部楼层 |阅读模式
本帖最后由 kimi 于 2013-12-23 16:06 编辑

如题,怎么在我们oa系统里面做出一个投票的功能
       比如:评选公司年度销售冠军
kimi 发表于 2013-12-23 11:18:14 | 显示全部楼层
您好:参考这个模块整个代码和具体的操作都可以看到啊,可以看我们这里的投票是一个主子表单,当用户进行投票后,就把该用户选择的记录自动插入到对应的子表中,并且在投票之前先去对应的子表中查询,该用户是否已经进行过投票,类似代码:

  1. var where = "aa";
  2. var document = getCurrentDocument();
  3. var voting = getItemValue("voting");
  4. var radio = getItemValue("radio");
  5. var check = getItemValue("check");
  6. var anonymous = document.getItemValueAsString("anonymous");

  7. if ("单选".equals(voting)) {
  8.         if (radio == null || radio.trim().length() <= 0) {
  9.                 where = "选项不能为空!";
  10.         }
  11. }
  12. if ("多选".equals(voting)) {
  13.         if (check == null || check.trim().length() <= 0) {
  14.                 where = "选项不能为空!";
  15.         }
  16. }
  17. if (anonymous == null || anonymous.trim().length() <= 0) {
  18.         where = "是否匿名不能为空!";
  19. }
  20. $PRINTER.print("-----------------------"+radio +"-----"+check +"-------------"+anonymous+document.getId());
  21. if ("aa".equals(where)) {
  22.         var user = getWebUser();
  23.         var doc = getCurrentDocument();
  24.         var domain = getDomainid();
  25.         var id = new Packages.cn.myapps.util.sequence.Sequence();
  26.         var application = getApplication();
  27.         var process = new Packages.cn.myapps.core.dynaform.document.ejb.DocumentProcessBean(application);
  28.         var dql = "$formname='voting_record' and $parent = '" + doc.getId() + "' and $author = '" + user.getId() + "'";  //去投票的子表中查询该用户是否已经投票
  29.         var budget = findByDQL(dql);
  30.         if (budget != null && budget.getId() != null) {
  31.                 where="已投票,不能重复投票!";  //如果投票了就不允许进行投票
  32.         } else {
  33.                                //如果没有投票,就把该用户选择的投票信息插入到对应的子表中
  34.                 budget.setId(id.getSequence());
  35.                 budget.setFormname("OA/投票/voting_record");
  36.                 budget.setFormid("11e0-197e-d3044197-b991-cf1024c68a7b");
  37.                 budget.setIstmp(false);
  38.                 budget.setParent(doc.getId());
  39.                 budget.setApplicationid(application);
  40.                 budget.setAuthor(user.getId());
  41.                 budget.setCreated(getToday());
  42.                 budget.setDomainid(domain);
  43.                 budget.addStringItem("topics", doc.getItemValueAsString("topic"));
  44.                 if ("单选".equals(doc.getItemValueAsString("voting"))) {
  45.                         budget.addStringItem("options", doc.getItemValueAsString("radio"));
  46.                 } else {
  47.                         budget.addStringItem("options", doc.getItemValueAsString("check"));
  48.                 }
  49.                 budget.addStringItem("voterid", user.getId());
  50.                 budget.addStringItem("pollid", doc.getId());
  51.                 if ("否".equals(doc.getItemValueAsString("anonymous"))) {
  52.                         budget.addStringItem("voters", user.getName());
  53.                 } else {
  54.                         budget.addStringItem("voters", "匿名");
  55.                 }
  56.                 budget.addDateItem("votetime", getToday());

  57.                 budget.addStringItem("comment",doc.getItemValueAsString("comment"));
  58.                 process.doCreate(budget);
  59.                 where = "";
  60.         }

  61. }
  62. where;
复制代码
回复 支持 1 反对 0

使用道具 举报

kimi 发表于 2013-12-23 08:58:03 | 显示全部楼层
您好:关于投票模块的做法您可以参考我们打包出去模板OA办公管理系统(标准版)中投票模块,具体如下图所示:
a22.jpg
 楼主| 深圳国旅 发表于 2013-12-23 11:08:31 | 显示全部楼层
我们按这个做了一个,一个账号可以重复进行投票。不知道是不是弄错了。能给一个具体的操作流程文档吗?谢谢
kimi 发表于 2013-12-23 16:05:52 | 显示全部楼层
Q上客户表示该问题已经没有问题了,故对应的帖子关闭。

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-13 14:14

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表