Update form.html

This commit is contained in:
Anyon 2019-12-17 14:33:29 +08:00
parent 22913c942a
commit 51915fcd1e

View File

@ -80,9 +80,9 @@
<script> <script>
require(['angular', 'ckeditor'], function () { require(['angular', 'ckeditor'], function () {
var editor;
var $form = $('form[name="news"]'); var $form = $('form[name="news"]');
var $vali = $form.vali().data('validate'); var $vali = $form.vali().data('validate');
var editor = window.createEditor('[name="content"]');
var app = angular.module("NewsEditor", []).run(callback); var app = angular.module("NewsEditor", []).run(callback);
angular.bootstrap(document.getElementById(app.name), [app.name]); angular.bootstrap(document.getElementById(app.name), [app.name]);
@ -108,10 +108,11 @@
$rootScope.list = list; $rootScope.list = list;
$rootScope.item = $rootScope.list[0]; $rootScope.item = $rootScope.list[0];
$rootScope.setItemValue('active', true); $rootScope.setItemValue('active', true);
$('.layui-card-body.layui-hide').removeClass('layui-hide');
setTimeout(function () { setTimeout(function () {
$vali.checkAllInput(); editor = window.createEditor('[name="content"]');
editor.setData($rootScope.item.content); editor.setData($rootScope.item.content);
$('.layui-card-body.layui-hide').removeClass('layui-hide'); $vali.checkAllInput();
}, 200); }, 200);
} }
@ -148,16 +149,16 @@
$event.stopPropagation(); $event.stopPropagation();
$vali.checkAllInput(); $vali.checkAllInput();
if ($form.find('.validate-error').size() > 0) return 0; if ($form.find('.validate-error').size() > 0) return 0;
if (editor.getData().length < 1) return $.msg.tips('文章内容不能为空请输入文章内容'); if (editor.getData().length < 1) {
for (var i in $rootScope.list) { return $.msg.tips('文章内容不能为空,请输入文章内容!');
if (parseInt(i) !== parseInt(index)) { }
$rootScope.list[i].active = false; for (var i in $rootScope.list) if (parseInt(i) !== parseInt(index)) {
} else { $rootScope.list[i].active = false;
$rootScope.item.content = editor.getData(); } else {
$rootScope.item = $rootScope.list[i]; $rootScope.item.content = editor.getData();
editor.setData($rootScope.item.content); $rootScope.item = $rootScope.list[i];
$rootScope.setItemValue('active', true); editor.setData($rootScope.item.content);
} $rootScope.setItemValue('active', true);
} }
}; };