Gogs 4 年 前
コミット
d63d3ee35d
64 ファイル変更355 行追加231 行削除
  1. 1 0
      src/common/models.py
  2. 78 39
      src/manage/controls.py
  3. 1 0
      src/manage/views.py
  4. 1 0
      templates/css/chunk-138558fb.2d09ae5d.css
  5. 1 0
      templates/css/chunk-1a103b85.91a009b6.css
  6. 1 0
      templates/css/chunk-1d495490.96154822.css
  7. 1 0
      templates/css/chunk-1d495490.a784b958.css
  8. 1 0
      templates/css/chunk-32989564.22570e29.css
  9. 1 0
      templates/css/chunk-3c180540.fd32df16.css
  10. 1 0
      templates/css/chunk-4c394853.7223e3e5.css
  11. 1 0
      templates/css/chunk-53e0a5d8.e6fb0e23.css
  12. 1 0
      templates/css/chunk-599f6235.8c61a6e9.css
  13. 1 0
      templates/css/chunk-59e16508.739d4ade.css
  14. 1 0
      templates/css/chunk-5a5b9b54.faba7a3c.css
  15. 1 0
      templates/css/chunk-6a7519cf.f2e59cbf.css
  16. 1 0
      templates/css/chunk-80bcae6a.fd754df2.css
  17. 1 0
      templates/css/chunk-8372d988.b686f317.css
  18. 1 0
      templates/css/chunk-c0d61ea8.826b0a2e.css
  19. 1 0
      templates/css/chunk-ce5385fc.d12eafd8.css
  20. 1 0
      templates/css/chunk-ee2e69b8.e395cbb9.css
  21. BIN
      templates/img/survey_bg.1591555b.png
  22. 1 1
      templates/index.html
  23. 2 0
      templates/js/app.afe4c1ac.js
  24. 1 0
      templates/js/app.afe4c1ac.js.map
  25. 2 0
      templates/js/app.c4d1bbd2.js
  26. 1 0
      templates/js/app.c4d1bbd2.js.map
  27. 9 0
      templates/js/chunk-138558fb.51ab96ba.js
  28. 1 0
      templates/js/chunk-138558fb.51ab96ba.js.map
  29. 2 0
      templates/js/chunk-1a103b85.49c3217a.js
  30. 1 0
      templates/js/chunk-1a103b85.49c3217a.js.map
  31. 2 0
      templates/js/chunk-1b11583b.76b96cb0.js
  32. 1 0
      templates/js/chunk-1b11583b.76b96cb0.js.map
  33. 2 0
      templates/js/chunk-1d495490.663529f4.js
  34. 1 0
      templates/js/chunk-1d495490.663529f4.js.map
  35. 2 0
      templates/js/chunk-1d495490.f5bfa8eb.js
  36. 1 0
      templates/js/chunk-1d495490.f5bfa8eb.js.map
  37. 2 0
      templates/js/chunk-32989564.97c7bbb3.js
  38. 1 0
      templates/js/chunk-32989564.97c7bbb3.js.map
  39. 9 0
      templates/js/chunk-3c180540.8fb3e898.js
  40. 1 0
      templates/js/chunk-3c180540.8fb3e898.js.map
  41. 2 0
      templates/js/chunk-4c394853.320c29e9.js
  42. 1 0
      templates/js/chunk-4c394853.320c29e9.js.map
  43. 2 0
      templates/js/chunk-53e0a5d8.c5b288e4.js
  44. 1 0
      templates/js/chunk-53e0a5d8.c5b288e4.js.map
  45. 2 0
      templates/js/chunk-599f6235.89a1e3ce.js
  46. 1 0
      templates/js/chunk-599f6235.89a1e3ce.js.map
  47. 2 0
      templates/js/chunk-59e16508.2211c382.js
  48. 1 0
      templates/js/chunk-59e16508.2211c382.js.map
  49. 2 0
      templates/js/chunk-5a5b9b54.7080a273.js
  50. 1 0
      templates/js/chunk-5a5b9b54.7080a273.js.map
  51. 2 0
      templates/js/chunk-6a7519cf.a3dca53e.js
  52. 1 0
      templates/js/chunk-6a7519cf.a3dca53e.js.map
  53. 2 0
      templates/js/chunk-80bcae6a.9bb179ef.js
  54. 1 0
      templates/js/chunk-80bcae6a.9bb179ef.js.map
  55. 2 0
      templates/js/chunk-8372d988.cbd4e912.js
  56. 1 0
      templates/js/chunk-8372d988.cbd4e912.js.map
  57. 2 0
      templates/js/chunk-c0d61ea8.a63fedc2.js
  58. 1 0
      templates/js/chunk-c0d61ea8.a63fedc2.js.map
  59. 2 0
      templates/js/chunk-ce5385fc.c813c327.js
  60. 1 0
      templates/js/chunk-ce5385fc.c813c327.js.map
  61. 2 0
      templates/js/chunk-ee2e69b8.017902b2.js
  62. 1 0
      templates/js/chunk-ee2e69b8.017902b2.js.map
  63. 182 190
      templates/survey/answer.html
  64. 1 1
      templates/survey/login.html

+ 1 - 0
src/common/models.py

@@ -549,6 +549,7 @@ class Message(models.Model):
     filename = models.CharField(u"附件名称",max_length=50,blank=True,null=True)
     template_qrcode = models.TextField(u"问卷二维码",max_length=255,blank=True,null=True)
     type = models.IntegerField(u"消息类型",default=0)
+    widget = models.TextField(u"组件",blank=True,null=True)
 
     status = models.SmallIntegerField(u"状态",default=1)
     cid = models.IntegerField(u"创建人id")

+ 78 - 39
src/manage/controls.py

@@ -60,6 +60,12 @@ def add_model(cls,**kwargs):
     """
     model_name = re.search(r'.*\.(\w+)View',str(cls.__class__)).groups()[0]
     model = getattr(cm,model_name)
+    if model_name == "Message":
+        #拷贝模板字段
+        template_id = kwargs.get("template_id")
+        template = cm.Template.objects.filter(id=template_id).first()
+        widget = json.loads(template.widget) if template.widget else {}
+        kwargs["widget"] = json.dumps(widget)
     obj = model.objects.create(**kwargs)
     #生成文件分享图片
     if model_name == "Message":
@@ -92,6 +98,12 @@ def update_model(cls,**kwargs):
     model_name = re.search(r'.*\.(\w+)View',str(cls.__class__)).groups()[0]
     model = getattr(cm,model_name)
     id = kwargs.pop("id")
+    if model_name == "Message":
+        #拷贝模板字段
+        template_id = kwargs.get("template_id")
+        template = cm.Template.objects.filter(id=template_id).first()
+        widget = json.loads(template.widget) if template.widget else {}
+        kwargs["widget"] = json.dumps(widget)
     rst = model.objects.filter(id=id).update(**kwargs)
     if model_name == "Message":
         obj = model.objects.filter(id=id).first()
@@ -139,8 +151,8 @@ def delete_model(cls,**kwargs):
     ids = str(kwargs.get("id")).split(",")
 
     rst = model.objects.filter(id__in=ids).delete()
-    if model_name == "Template":
-        cm.Message.objects.filter(template_id__in=ids).delete()
+    #if model_name == "Template":
+    #    cm.Message.objects.filter(template_id__in=ids).delete()
     return ids
 
 def delete_model_actual(cls,**kwargs):
@@ -163,9 +175,10 @@ def get_detail_info(cls,**kwargs):
     rst = rst[0] if rst else {}
     if model_name == "Message":
         if rst.get("template_id"):
-            tpl = cm.Template.objects.filter(id=rst.get("template_id")).values()
-            tpl = tpl[0] if tpl else {}
-            widget = json.loads(tpl["widget"]) if tpl else []
+            #tpl = cm.Template.objects.filter(id=rst.get("template_id")).values()
+            #tpl = tpl[0] if tpl else {}
+            #widget = json.loads(tpl["widget"]) if tpl else []
+            widget = json.loads(rst["widget"]) if rst["widget"] else []
             #已填报则获取填报结果
             if cm.MessageSurveyResult.objects.filter(message_id=id).exists():
                 rst["edit"] = 1
@@ -184,9 +197,10 @@ def get_detail_info(cls,**kwargs):
     if model_name == "Notice":
         rst["fileurl"] = json.loads(rst["fileurl"]) if rst["fileurl"] else []
         viewer_ids = json.loads(rst["viewer_id"]) if rst["viewer_id"] else []
-        new_viewer_ids = filter(lambda x:x["id"]!=kwargs.get("cid"),viewer_ids)
-        new_viewer_ids.append({"id":kwargs.get("cid"),"time":ccf.get_now_str()})
-        model.objects.filter(id=id).update(viewer_id=json.dumps(new_viewer_ids))
+        if not kwargs.get("type"):
+            new_viewer_ids = filter(lambda x:x["id"]!=kwargs.get("cid"),viewer_ids)
+            new_viewer_ids.append({"id":kwargs.get("cid"),"time":ccf.get_now_str()})
+            model.objects.filter(id=id).update(viewer_id=json.dumps(new_viewer_ids))
     return rst
 
 def get_list_info(cls,**kwargs):
@@ -225,7 +239,10 @@ def get_list_info(cls,**kwargs):
                 d["journal_name"] = cm.Journal.objects.filter(id=d["journal_id"]).first().name
             except:
                 d["journal_name"] = ""
-            d["role_name"] = cm.Role.objects.filter(id=d["role_id"]).first().name
+            try:
+                d["role_name"] = cm.Role.objects.filter(id=d["role_id"]).first().name
+            except:
+                d["role_name"] = ""
     if model_name in ["Message"]:
         for d in data:
             if d["receiver_id"]:
@@ -261,11 +278,12 @@ def get_list_info(cls,**kwargs):
                 d["finish_ids"] = finish_ids
     if model_name == "Template":
         for d in data:
-            message_ids = list(cm.Message.objects.filter(template_id=d["id"]).values_list("id",flat=True))
-            if cm.MessageSurveyResult.objects.filter(message_id__in=message_ids).exists():
-                d["edit"] = 0 
-            else:
-                d["edit"] = 1
+            #message_ids = list(cm.Message.objects.filter(template_id=d["id"]).values_list("id",flat=True))
+            #if cm.MessageSurveyResult.objects.filter(message_id__in=message_ids).exists():
+            #    d["edit"] = 0 
+            #else:
+            #    d["edit"] = 1
+            d["edit"] = 1
 
     page = int(kwargs.get("page",0))
     page_size = int(kwargs.get("page_size",20))
@@ -1012,14 +1030,29 @@ def add_conference(**kwargs):
     return True
 
 
-def remove_empty(data):
-    if isinstance(data,type([])):
-        for i,item in enumerate(data):
-            if not item.get("children",[]):
-                print len(data),111111111
-                del data[i]
+def recurse_del(list_data):
+    if len(list_data) == 0:
+        return
+    
+    index = 0
+    while index < len(list_data):
+        if not list_data[index].has_key('children'):
+            index = index + 1
+            continue
+        
+        if not list_data[index].get("children"):
+            print "[Deleted] ", list_data[index]
+            del list_data[index]
+        else:
+            print "[Recurved] ", list_data[index].get("children")
+            recurse_del(list_data[index].get("children"))
+
+            if not list_data[index].get("children"):
+                print "[Deleted] ", list_data[index]
+                print 1111111111
+                del list_data[index]
             else:
-                return remove_empty(data[i]["children"])
+                index = index + 1
 
 
 def get_message_receiver_list(request):
@@ -1048,7 +1081,7 @@ def get_message_receiver_list(request):
                 jn["children"] = sysusers
             org["children"] = journals
         brc["children"] = orgs
-    #remove_empty(branchs)
+    recurse_del(branchs)
     return branchs
 
 
@@ -1133,9 +1166,10 @@ def get_survey_analyse_list_out(**kwargs):
     _type = kwargs.get("type")
 
     message = cm.Message.objects.filter(id=message_id).first()
-    template_id = message.template_id 
-    template = cm.Template.objects.filter(id=template_id).first()
-    widgets = json.loads(template.widget) if template.widget else []
+    #template_id = message.template_id 
+    #template = cm.Template.objects.filter(id=template_id).first()
+    #widgets = json.loads(template.widget) if template.widget else []
+    widgets = json.loads(message.widget) if message.widget else []
     headers = [x["label"] for x in widgets]
     msrset = cm.MessageSurveyResult.objects.filter(message_id=message_id)
     if kwargs.get("name"):
@@ -1167,8 +1201,9 @@ def get_survey_question_analyse_list(**kwargs):
     message_id = kwargs.get("id")
     _type = kwargs.get("type")
     message = cm.Message.objects.filter(id=message_id).first()
-    template = cm.Template.objects.filter(id=message.template_id).first()
-    widgets = json.loads(template.widget) if template.widget else []
+    #template = cm.Template.objects.filter(id=message.template_id).first()
+    #widgets = json.loads(template.widget) if template.widget else []
+    widgets = json.loads(message.widget) if message.widget else []
     #填报结果
     results = cm.MessageSurveyResult.objects.filter(message_id=message_id)
     for wd in widgets: 
@@ -1271,9 +1306,10 @@ def download_survey_result_out(request):
     _type = qdata.get("type")
 
     message = cm.Message.objects.filter(id=message_id).first()
-    template_id = message.template_id 
-    template = cm.Template.objects.filter(id=template_id).first()
-    widgets = json.loads(template.widget) if template.widget else []
+    #template_id = message.template_id 
+    #template = cm.Template.objects.filter(id=template_id).first()
+    #widgets = json.loads(template.widget) if template.widget else []
+    widgets = json.loads(message.widget) if message.widget else []
     headers = [x["label"] for x in widgets]
     msrset = cm.MessageSurveyResult.objects.filter(message_id=message_id)
     msrdata = list(msrset.values())
@@ -1304,9 +1340,10 @@ def download_survey_result_all(request):
     _type = qdata.get("type")
 
     message = cm.Message.objects.filter(id=message_id).first()
-    template_id = message.template_id 
-    template = cm.Template.objects.filter(id=template_id).first()
-    widgets = json.loads(template.widget) if template.widget else []
+    #template_id = message.template_id 
+    #template = cm.Template.objects.filter(id=template_id).first()
+    #widgets = json.loads(template.widget) if template.widget else []
+    widgets = json.loads(message.widget) if message.widget else []
     headers = [x["label"] for x in widgets]
     msrset = cm.MessageSurveyResult.objects.filter(message_id=message_id)
     msrdata = list(msrset.values())
@@ -1352,9 +1389,10 @@ def download_survey_result_item(request):
     item = qdata.get("item")
 
     message = cm.Message.objects.filter(id=message_id).first()
-    template_id = message.template_id 
-    template = cm.Template.objects.filter(id=template_id).first()
-    widgets = json.loads(template.widget) if template.widget else []
+    #template_id = message.template_id 
+    #template = cm.Template.objects.filter(id=template_id).first()
+    #widgets = json.loads(template.widget) if template.widget else []
+    widgets = json.loads(message.widget) if message.widget else []
     if item:
         widgets = filter(lambda x:x["label"]==item,widgets)
     headers = [x["label"] for x in widgets]
@@ -1484,7 +1522,8 @@ def get_message_out_info(**kwargs):
     data = list(cm.Message.objects.filter(id=id).values())
     rst = data[0] if data else {}
     if rst.get("template_id"):
-        tpl = cm.Template.objects.filter(id=rst.get("template_id")).values()
-        tpl = tpl[0] if tpl else {}
-        rst["widget"] = json.loads(tpl["widget"]) if tpl else []
+        #tpl = cm.Template.objects.filter(id=rst.get("template_id")).values()
+        #tpl = tpl[0] if tpl else {}
+        #rst["widget"] = json.loads(tpl["widget"]) if tpl else []
+        rst["widget"] = json.loads(rst["widget"]) if rst["widget"] else []
     return rst

+ 1 - 0
src/manage/views.py

@@ -2170,6 +2170,7 @@ class NoticeView(cv.AdminView):
             mse = ccf.check_params(*need_params,**qdata)
             if mse:
                 raise ce.TipException(mse)
+            need_params.append("type")
             vals = ccf.get_need_params(*need_params,**qdata)
             vals["cid"] = request.user.id
             rst = ctl.get_detail_info(self,**vals)

ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-138558fb.2d09ae5d.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-1a103b85.91a009b6.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-1d495490.96154822.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-1d495490.a784b958.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-32989564.22570e29.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-3c180540.fd32df16.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-4c394853.7223e3e5.css


+ 1 - 0
templates/css/chunk-53e0a5d8.e6fb0e23.css

@@ -0,0 +1 @@
+.editor[data-v-55e58fac]{width:100%;margin:0 auto;position:relative;z-index:0}.editor[data-v-55e58fac] .toolbar{border:1px solid #ccc}.editor[data-v-55e58fac] .text{border:1px solid #ccc;min-height:500px}

ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-599f6235.8c61a6e9.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-59e16508.739d4ade.css


+ 1 - 0
templates/css/chunk-5a5b9b54.faba7a3c.css

@@ -0,0 +1 @@
+.el-pagination button,.el-pagination li{border:1px solid #cacaca!important;background-color:#fff!important}.el-pagination .active{border:none!important;background:#3895fe!important}.signup_mannage .bh{font-size:14px;color:#666;line-height:27px;margin-bottom:10px}.signup_mannage .bh label{color:#333;font-size:16px;display:inline-block;padding-right:10px}.signup_mannage .hotel .el-dialog{margin-top:30px!important}.signup_mannage .hotel .el-dialog .el-form-item{margin-bottom:10px}

+ 1 - 0
templates/css/chunk-6a7519cf.f2e59cbf.css

@@ -0,0 +1 @@
+.el-pagination button,.el-pagination li{border:1px solid #cacaca!important;background-color:#fff!important}.el-pagination .active{border:none!important;background:#3895fe!important}

ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-80bcae6a.fd754df2.css


+ 1 - 0
templates/css/chunk-8372d988.b686f317.css

@@ -0,0 +1 @@
+.el-pagination button,.el-pagination li{border:1px solid #cacaca!important;background-color:#fff!important}.el-pagination .active{border:none!important;background:#3895fe!important}.checker .el-dialog__footer{text-align:right}

ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-c0d61ea8.826b0a2e.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-ce5385fc.d12eafd8.css


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/css/chunk-ee2e69b8.e395cbb9.css


BIN
templates/img/survey_bg.1591555b.png


ファイルの差分が大きいため隠しています
+ 1 - 1
templates/index.html


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/app.afe4c1ac.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/app.afe4c1ac.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/app.c4d1bbd2.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/app.c4d1bbd2.js.map


ファイルの差分が大きいため隠しています
+ 9 - 0
templates/js/chunk-138558fb.51ab96ba.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-138558fb.51ab96ba.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-1a103b85.49c3217a.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-1a103b85.49c3217a.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-1b11583b.76b96cb0.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-1b11583b.76b96cb0.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-1d495490.663529f4.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-1d495490.663529f4.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-1d495490.f5bfa8eb.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-1d495490.f5bfa8eb.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-32989564.97c7bbb3.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-32989564.97c7bbb3.js.map


ファイルの差分が大きいため隠しています
+ 9 - 0
templates/js/chunk-3c180540.8fb3e898.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-3c180540.8fb3e898.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-4c394853.320c29e9.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-4c394853.320c29e9.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-53e0a5d8.c5b288e4.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-53e0a5d8.c5b288e4.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-599f6235.89a1e3ce.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-599f6235.89a1e3ce.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-59e16508.2211c382.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-59e16508.2211c382.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-5a5b9b54.7080a273.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-5a5b9b54.7080a273.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-6a7519cf.a3dca53e.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-6a7519cf.a3dca53e.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-80bcae6a.9bb179ef.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-80bcae6a.9bb179ef.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-8372d988.cbd4e912.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-8372d988.cbd4e912.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-c0d61ea8.a63fedc2.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-c0d61ea8.a63fedc2.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-ce5385fc.c813c327.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-ce5385fc.c813c327.js.map


ファイルの差分が大きいため隠しています
+ 2 - 0
templates/js/chunk-ee2e69b8.017902b2.js


ファイルの差分が大きいため隠しています
+ 1 - 0
templates/js/chunk-ee2e69b8.017902b2.js.map


+ 182 - 190
templates/survey/answer.html

@@ -1,220 +1,212 @@
 <!DOCTYPE html>
 <html>
+
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=no,
     width=device-width,initial-scale=1.0">
-    <title>问卷调查</title>
+  <title>问卷调查</title>
   <!-- import CSS -->
   <link rel="stylesheet" href="static/index.css">
 </head>
 <style>
-   body{margin:0px;padding:0px;}
-  #app{
+  body {
+    margin: 0px;
+    padding: 0px;
+  }
+
+  #app {
     display: none;
   }
+
   .tpl_title {
     font-size: 18px;
     margin: 10px 0;
   }
-  .item-main{
-	padding:10px 15px;
-	}
-  .el-form-item__label{
-		font-weight:600;
-        float:none;   
-    }
-    .el-message-box{
-      width:80%;
-    }
-  .survey_logo{
+
+  .item-main {
+    padding: 10px 15px;
+  }
+
+  .el-form-item__label {
+    font-weight: 600;
+    float: none;
+  }
+
+  .el-message-box {
+    width: 80%;
+  }
+
+  .survey_logo {
     width: 125px;
   }
 </style>
+
 <body>
   <div id="app">
     <div class="item-main">
-        <img src="static/survey_logo.png" alt="" class="survey_logo" />
-        <h5 align="center" class="tpl_title">{{ title }}</h5>
-		    <el-form  ref="form" :model="form2" class="tpl_form over_y">
-          <el-form-item
-            v-for="(item, index) in widgetList"
-            :key="index"
-            :label="(index+1)+'、'+(item.label)"
-          >
-            <el-input
-              v-if="item.type == 'input'"
-              v-model="form2[item.label]"
-              :placeholder="item.placeholder"
-            ></el-input>
-            <el-input
-              v-if="item.type == 'textarea'"
-              type="textarea"
-              v-model="form2[item.label]"
-              :placeholder="item.placeholder"
-              :rows=4
-            ></el-input>
-            <el-radio-group
-              v-if="item.type == 'radio'"
-              v-model="form2[item.label]"
-            >
-              <el-radio
-                :label="iitem.label"
-                v-for="(iitem, index) in item.items"
-                :key="index"
-                >{{ iitem.label }}</el-radio
-              >
-            </el-radio-group>
+      <img src="static/survey_logo.png" alt="" class="survey_logo" />
+      <h5 align="center" class="tpl_title">{{ title }}</h5>
+      <el-form ref="form2" :model="form2" class="tpl_form over_y" :rules="rules1.rules">
+        <el-form-item v-for="(item, index) in widgetList" :key="index" :label="(index+1)+'、'+(item.label)"
+          :prop="item.label">
+          <el-input v-if="item.type == 'input'" v-model="form2[item.label]" :placeholder="item.placeholder"></el-input>
+          <el-input v-if="item.type == 'textarea'" type="textarea" v-model="form2[item.label]"
+            :placeholder="item.placeholder" :rows=4></el-input>
+          <el-radio-group v-if="item.type == 'radio'" v-model="form2[item.label]">
+            <el-radio :label="iitem.label" v-for="(iitem, index) in item.items" :key="index">{{ iitem.label }}
+            </el-radio>
+          </el-radio-group>
+
+          <el-checkbox-group v-else-if="item.type == 'checkbox'" v-model="form2[item.label]">
+            <el-checkbox :label="iitem.label" v-for="(iitem, index) in item.items" :key="index"></el-checkbox>
+          </el-checkbox-group>
+          <el-upload v-if="item.type == 'image'" action="/api/admin/uploadfile" list-type="picture-card"
+            :data="{ type: item.label }" :on-success="handleSuccess">
+            <i class="el-icon-plus"></i>
 
-            <el-checkbox-group
-              v-else-if="item.type == 'checkbox'"
-              v-model="form2[item.label]"
-            >
-              <el-checkbox
-                :label="iitem.label"
-                v-for="(iitem, index) in item.items"
-                :key="index"
-              ></el-checkbox>
-            </el-checkbox-group>
-            <el-upload
-              v-if="item.type == 'image'"
-              action="/api/admin/uploadfile"
-              list-type="picture-card"
-              :data="{ type: item.label }"
-              :on-success="handleSuccess"
-            >
-              <i class="el-icon-plus"></i>
-            
-            </el-upload>
-            <el-upload
-              v-if="item.type == 'file'"
-              class="upload-demo"
-              ref="upload"
-              action="/api/admin/uploadfile"
-              :data="{ type: item.label }"
-              :on-success="handleSuccess"
-            >
-              <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
-              <el-button
-                style="margin-left: 10px"
-                size="small"
-                type="primary"
-                plain
-                >添加文件</el-button
-              >
-              <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
-            </el-upload>
-          </el-form-item>
-          <el-form-item v-if="widgetList.length">
-            <el-button
-              size="medium"
-              type="primary"
-              @click="saveResult"
-              style="width: 100%;height: 45px;font-size: 16px;margin-top:20px;"
-			  :disabled="form2.status==0"
-              >{{this.form2.status==1?"提交":"该问卷已禁用"}}</el-button
-            >
-          </el-form-item>
-        </el-form>
+          </el-upload>
+          <el-upload v-if="item.type == 'file'" class="upload-demo" ref="upload" action="/api/admin/uploadfile"
+            :data="{ type: item.label }" :on-success="handleSuccess">
+            <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
+            <el-button style="margin-left: 10px" size="small" type="primary" plain>添加文件</el-button>
+            <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
+          </el-upload>
+        </el-form-item>
+        <el-form-item v-if="widgetList.length">
+          <el-button size="medium" type="primary" @click="saveResult"
+            style="width: 100%;height: 45px;font-size: 16px;margin-top:20px;" :disabled="form2.status==0">
+            {{this.form2.status==1?"提交":"该问卷已禁用"}}</el-button>
+        </el-form-item>
+      </el-form>
     </div>
   </div>
 </body>
-  <!-- import Vue before Element -->
-  <script src="static/jquery.min.js"></script>
-  <script src="static/vue.js"></script>
-  <!-- import JavaScript -->
-  <script src="static/index.js"></script>
-  <script>
-    new Vue({
-      el: '#app',
-      data: function() {
-        return { 
-            type:null,
-            form2:{
-              
-            },
-            widgetList:[],
-            id:'',
-            title:'',
-            show:0
+<!-- import Vue before Element -->
+<script src="static/jquery.min.js"></script>
+<script src="static/vue.js"></script>
+<!-- import JavaScript -->
+<script src="static/index.js"></script>
+<script>
+  new Vue({
+    el: '#app',
+    data: function () {
+      return {
+        rules1: {
+          rules: {},
+        },
+        type: null,
+        form2: {},
+        widgetList: [],
+        id: '',
+        title: '',
+        show: 0
+      }
+    },
+    methods: {
+      getData() {
+        let url = "/api/admin/message"
+        if (this.type == 1) {
+          url = "/api/admin/message/out"
         }
+        $.ajax({
+          url: url,
+          method: 'get',
+          data: {
+            id: this.id
+          },
+          success: res => {
+            document.getElementById('app').style.display = 'block'
+            this.form2.status = res.data.status
+            let widgetList = res.data.widget;
+            let rules1 = {};
+            for (let i = 0; i < widgetList.length; i++) {
+              if (widgetList[i].type == 'checkbox') {
+                let key = widgetList[i].label
+                this.$set(this.form2, key, [])
+              }
+              //组装rules
+              var item = widgetList[i];
+              if (item.type == "input" && item.require) {
+                rules1[item.label] = [
+                  { required: true, message: item.placeholder, trigger: "blur" },
+                ];
+              }
+              if (item.type == "textarea" && item.require) {
+                rules1[item.label] = [
+                  { required: true, message: item.placeholder, trigger: "blur" },
+                ];
+              }
+              if (item.type == "radio" && item.require) {
+                rules1[item.label] = [
+                  { required: true, message: item.placeholder, trigger: "change" },
+                ];
+              }
+              if (item.type == "checkbox" && item.require) {
+                rules1[item.label] = [
+                  { required: true, message: item.placeholder, trigger: "change" },
+                ];
+              }
+            }
+            this.$set(this.rules1, "rules", rules1);
+            this.title = res.data.name
+            this.widgetList = widgetList
+          },
+          error: res => {
+            if (res.status == 403) {
+              window.location.href = "/survey/login.html?id=" + this.id + "&type=" + this.type
+            }
+          }
+        })
       },
-      methods:{
-            getData(){
-                let url = "/api/admin/message"
-                if(this.type==1){
-                  url = "/api/admin/message/out"
+      saveResult() {
+        let url = "/api/admin/message/survey/result"
+        if (this.type == 1) {
+          url = "/api/admin/message/survey/result/out"
+        }
+        this.$refs["form2"].validate((valid) => {
+          if (valid) {
+            let result = JSON.stringify(this.form2);
+            $.ajax({
+              url: url,
+              method: 'post',
+              data: {
+                message_id: this.id,
+                result: result,
+              },
+              success: res => {
+                if (res.code == 0) {
+                  this.$alert('提交成功', "提交成功", {
+                    center: true,
+                    showClose: false,
+                    confirmButtonText: '确定',
+                    type: "success"
+                  });
+                  window.location.href = "/survey/success.html?title=" + encodeURIComponent(res.data)
+                } else {
+                  this.$alert("提交失败请稍后再试!", "提交失败", {
+                    center: true,
+                    showClose: false,
+                    confirmButtonText: '确定',
+                    type: "error"
+                  });
                 }
-                $.ajax({
-                        url:url,
-                        method:'get',
-                        data:{
-                            id:this.id
-                        },
-                        success:res=>{
-                            document.getElementById('app').style.display='block'
-							this.form2.status = res.data.status
-                            let widgetList=res.data.widget;
-                            for(let i=0;i<widgetList.length;i++){
-                              if(widgetList[i].type=='checkbox'){
-                                let key = widgetList[i].label
-                                this.$set(this.form2, key, [])
-
-                              }
-                            }
-                            this.title = res.data.name
-                            this.widgetList=widgetList
-                        },
-						error:res=>{
-							if(res.status==403){
-								window.location.href="/survey/login.html?id="+this.id+"&type="+this.type
-							}
-						}
-                })
-            },
-            saveResult(){
-              let url = "/api/admin/message/survey/result"
-              if(this.type==1){
-                url = "/api/admin/message/survey/result/out"
               }
-              let result = JSON.stringify(this.form2);
-              $.ajax({
-                        url:url,
-                        method:'post',
-                        data:{
-                          message_id: this.id,
-                          result: result,
-                        },
-                        success:res=>{
-                            if (res.code == 0) {
-                              this.$alert('提交成功',"提交成功", {
-                                center:true,
-                                showClose:false,
-                                confirmButtonText: '确定',
-                                type:"success"
-                              });
-                              window.location.href="/survey/success.html?title="+encodeURIComponent(res.data)
-                            } else {
-                              this.$alert("提交失败请稍后再试!","提交失败", {
-                                center:true,
-                                showClose:false,
-                                confirmButtonText: '确定',
-                                type:"error"
-                              });
-                            }
-                        }
-                })
-            },
-            handleSuccess(res, file) {
-                this.form2[res.data.type] = res.data.url;
-            },
-        },
-        created(){
-           var search=window.location.search.split('?')[1].split('&');
-           this.id=search[0].split('=')[1]
-           this.type = search[1].split('=')[1]
-           this.getData()
-        }
-    })
-  </script>
-</html>
+            })
+          }
+        });
+      },
+      handleSuccess(res, file) {
+        this.form2[res.data.type] = res.data.url;
+      },
+    },
+    created() {
+      var search = window.location.search.split('?')[1].split('&');
+      this.id = search[0].split('=')[1]
+      this.type = search[1].split('=')[1]
+      this.getData()
+    }
+  })
+</script>
+
+</html>

+ 1 - 1
templates/survey/login.html

@@ -88,7 +88,7 @@
         methods:{
            login(){
                 $.ajax({
-                    url:'https://test.scxjc.club/api/account/login',
+                    url:'/api/account/login',
                     method:'post',
                     data:this.form,
                     success:res=>{