123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <!DOCTYPE html>
- <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
- <head>
- <th:block th:include="include :: header('编辑话题')" />
- </head>
- <body class="white-bg">
- <div class="wrapper wrapper-content animated fadeInRight ibox-content">
- <form class="form-horizontal m" id="form-dict-edit" th:object="${topic}">
- <input name="id" type="hidden" th:field="*{id}" />
- <div class="form-group">
- <label class="col-sm-2 control-label">标题:</label>
- <div class="col-sm-10">
- <input name="title" id="title" class="form-control" th:field="*{title}" type="text" placeholder="请输入标题" required/>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">图片:</label>
- <div class="col-sm-10">
- <img src="" id="picImage" style="width:250px;height:90px;" alt="" th:src="*{pic}">
- <input type="file" id="picUploadFile" name="uploadFile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
- <button class="btn btn-success" type="button" id="picUploadBtn">上传</button>
- <input type="hidden" id="pic" name="pic" th:field="*{pic}" class="form-control"/>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">导语:</label>
- <div class="col-sm-10">
- <textarea name="lead" class="form-control" rows="5" th:field="*{lead}" cols="10" style="resize: none;" required></textarea>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">排序设置:</label>
- <div class="col-sm-10">
- <input id="sort" min="1" name="sort" class="form-control" th:field="*{sort}" type="number" placeholder="请输入排序" required/>
- </div>
- </div>
- <div class="form-group">
- <label for="activation" class="col-sm-2 control-label">激活设置:</label>
- <div class="col-sm-10">
- <select name="activation" id="activation" class="form-control m-b" th:with="type=${@dict.getType('enable_status')}">
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{activation}"></option>
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">PK设置:</label>
- <div class="col-sm-10">
- <select name="pk" id="pk" class="form-control m-b" th:with="type=${@dict.getType('pk_status')}" disabled="disabled">
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{pk}"></option>
- </select>
- </div>
- </div>
- <div class="form-group" id="redOption">
- <label class="col-sm-2 control-label">红方选项:</label>
- <div class="col-sm-10">
- <input class="form-control" type="text" placeholder="请输入红方选项" readonly="readonly" th:field="*{redOption}"/>
- </div>
- </div>
- <div class="form-group" id="redDesc">
- <label class="col-sm-2 control-label">红方描述:</label>
- <div class="col-sm-10">
- <textarea class="form-control" rows="5" cols="10" readonly="readonly" style="resize: none;" th:field="*{redDesc}"></textarea>
- </div>
- </div>
- <div class="form-group" id="blueOption" >
- <label class="col-sm-2 control-label">蓝方选项:</label>
- <div class="col-sm-10">
- <input class="form-control" type="text" placeholder="请输入蓝方选项" readonly="readonly" th:field="*{blueOption}"/>
- </div>
- </div>
- <div class="form-group" id="blueDesc">
- <label class="col-sm-2 control-label">蓝方描述:</label>
- <div class="col-sm-10">
- <textarea class="form-control" rows="5" cols="10" style="resize: none;" readonly="readonly" th:field="*{blueDesc}"></textarea>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">默认访问数:</label>
- <div class="col-sm-10">
- <input name="examine" id="examine" class="form-control" type="number" th:field="*{examine}" placeholder="请输入默认访问数" required/>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">访问叠加数:</label>
- <div class="col-sm-10">
- <input name="examineNum" id="examineNum" class="form-control" type="number" th:field="*{examineNum}" placeholder="请输入访问叠加数" required/>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">PK叠加次数:</label>
- <div class="col-sm-10">
- <input name="pkVoteNum" id="pkVoteNum" class="form-control" type="number" th:field="*{examineNum}" placeholder="请输入PK叠加次数" required/>
- </div>
- </div>
- </form>
- </div>
- <th:block th:include="include :: footer" />
- <script type="text/javascript">
- var prefix = ctx + "dynamic/circle/topic";
-
- $("#form-dict-edit").validate({
- focusCleanup: true
- });
- $(function(){
- var pks = $("#pk").val();
- if(pks == 1){
- $("#redOption").show();
- $("#redDesc").show();
- $("#blueOption").show();
- $("#blueDesc").show();
- $('input[name="redOption"]').attr("required", "true");
- $('input[name="redDesc"]').attr("required", "true");
- $('input[name="blueOption"]').attr("required", "true");
- $('input[name="blueDesc"]').attr("required", "true");
- }else {
- $("#redOption").hide();
- $("#redDesc").hide();
- $("#blueOption").hide();
- $("#blueDesc").hide();
- $('input[name="redOption"]').attr("required", "false");
- $('input[name="redDesc"]').attr("required", "false");
- $('input[name="blueOption"]').attr("required", "false");
- $('input[name="blueDesc"]').attr("required", "false");
- }
- });
- /**
- * 图片上传
- */
- $('#picUploadBtn').on('click',function () {
- if($('#picUploadFile').get(0).files[0]==undefined){
- $.modal.alertError("请选择要上传的文件!");
- return;
- }
- var formData = new FormData();
- formData.append("file", $('#picUploadFile').get(0).files[0]);
- $.ajax({
- url: ctx + "file/upload",
- data: formData,
- type: "post",
- processData: false,
- contentType: false,
- success: function(result) {
- $('#picImage').attr('src',result.data);
- $("#pic").val(result.data);
- }
- })
- });
- function submitHandler() {
- if ($.validate.form()) {
- $.operate.save(prefix + "/edit", $('#form-dict-edit').serialize());
- }
- }
- </script>
- </body>
- </html>
|