123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <!DOCTYPE html>
- <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
- <head>
- <th:block th:include="include :: header('新增卡种信息')" />
- <th:block th:include="include :: datetimepicker-css" />
- <th:block th:include="include :: bootstrap-fileinput-css"/>
- </head>
- <body class="white-bg">
- <div class="wrapper wrapper-content animated fadeInRight ibox-content">
- <form class="form-horizontal m" id="form-information-add">
- <div class="col-xs-12">
- <div class="form-group">
- <label class="col-sm-2 control-label is-required">名称:</label>
- <div class="col-sm-4">
- <input name="name" class="form-control" type="text" maxlength="20" required>
- </div>
- <label class="col-sm-2 control-label is-required">类型:</label>
- <div class="col-sm-4">
- <select name="type" class="form-control" th:with="type=${@dict.getType('site_type')}" required>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- <div class="col-xs-12">
- <div class="form-group">
- <label class="col-sm-2 control-label is-required">可用次数:</label>
- <div class="col-sm-4">
- <input name="totalNumber" class="form-control" type="number" min="0" step="1" maxlength="8" required>
- </div>
- <label class="col-sm-2 control-label is-required">原价格:</label>
- <div class="col-sm-4">
- <input name="originalPrice" class="form-control" type="number" min="0" step="0.01" maxlength="8" required>
- </div>
- </div>
- </div>
- <div class="col-xs-12">
- <div class="form-group">
- <label class="col-sm-2 control-label is-required">会员价格:</label>
- <div class="col-sm-4">
- <input name="memberPrice" class="form-control" type="number" min="0" step="0.01" maxlength="8" required>
- </div>
- <label class="col-sm-2 control-label is-required">单次积分:</label>
- <div class="col-sm-4">
- <input name="point" class="form-control" type="number" min="0" step="1" maxlength="8" required>
- </div>
- </div>
- </div>
- <div class="col-xs-12">
- <div class="form-group">
- <label class="col-sm-2 control-label">使用规则:</label>
- <div class="col-sm-8">
- <input name="notes" class="form-control" type="hidden" maxlength="255">
- <div class="summernote" id = "notes"></div>
- </div>
- </div>
- </div>
- <div class="col-xs-12">
- <div class="form-group">
- <label class="col-sm-2 control-label is-required">图片:</label>
- <div class="col-sm-8">
- <input type="hidden" name="file">
- <div class="file-loading">
- <input class="form-control file-upload" id="file" name="file" type="file">
- </div>
- </div>
- </div>
- </div>
- </form>
- </div>
- <th:block th:include="include :: footer" />
- <th:block th:include="include :: datetimepicker-js" />
- <th:block th:include="include :: summernote-js"/>
- <th:block th:include="include :: bootstrap-fileinput-js"/>
- <th:block th:include="include :: summernote-css"/>
- <script th:inline="javascript">
- var prefix = ctx + "information"
- $("#form-information-add").validate({
- focusCleanup: true
- });
- function submitHandler() {
- if ($.validate.form()) {
- const originalPrice = parseInt(document.getElementsByName("originalPrice")[0].value);
- const memberPrice = parseInt(document.getElementsByName("memberPrice")[0].value);
- if (memberPrice>originalPrice){
- alert("会员价格不能大于原价格")
- }else {
- $.operate.save(prefix + "/add", $('#form-information-add').serialize());
- }
- }
- }
- $("input[name='expirationDate']").datetimepicker({
- format: "yyyy-mm-dd",
- minView: "month",
- autoclose: true
- });
- $(".file-upload").fileinput({
- uploadUrl: ctx + 'common/upload',
- maxFileCount: 1,
- allowedFileExtensions:['jpg','png'],
- maxFileSize: 10240,
- multiple: true,
- }).on('fileuploaded', function (event, data, previewId, index) {
- var inputName = event.currentTarget.id;
- var existingValue = $("input[name='" + inputName + "']").val();
- var newValue = data.response.url;
- // 如果已经存在值,则在后面加上逗号分隔的新值
- if (existingValue) {
- $("input[name='" + inputName + "']").val(existingValue + ',' + newValue);
- } else {
- $("input[name='" + inputName + "']").val(newValue);
- }
- }).on('fileremoved', function (event, id, index) {
- var inputName = event.currentTarget.id;
- var existingValue = $("input[name='" + inputName + "']").val();
- var fileUrls = existingValue.split(',');
- // 移除对应的文件路径
- fileUrls.splice(index, 1);
- // 重新拼接文件路径
- $("input[name='" + inputName + "']").val(fileUrls.join(','));
- });
- $(function () {
- $('.summernote').summernote({
- lang: 'zh-CN',
- dialogsInBody: true,
- height: 150,
- callbacks: {
- onChange: function (contents, $edittable) {
- $("input[name='" + this.id + "']").val(contents);
- },
- onImageUpload: function (files) {
- var obj = this;
- var data = new FormData();
- data.append("file", files[0]);
- $.ajax({
- type: "post",
- url: ctx + "common/upload",
- data: data,
- cache: false,
- contentType: false,
- processData: false,
- dataType: 'json',
- success: function (result) {
- if (result.code == web_status.SUCCESS) {
- $('#' + obj.id).summernote('insertImage', result.url);
- } else {
- $.modal.alertError(result.msg);
- }
- },
- error: function (error) {
- $.modal.alertWarning("图片上传失败。");
- }
- });
- }
- }
- });
- });
- </script>
- </body>
- </html>
|