design.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * 空的验证组件,后续如果增加业务,则更改组件
  3. */
  4. var emptyHtml = '<div class="layui-form-item"></div>';
  5. Vue.component("title-empty", {
  6. template: emptyHtml,
  7. data: function () {
  8. return {
  9. }
  10. },
  11. created:function() {
  12. if(!this.$parent.data.verify) this.$parent.data.verify = [];
  13. this.$parent.data.verify.push(this.verify);//加载验证方法
  14. },
  15. methods: {
  16. verify : function () {
  17. var res = {code: true, message: ""};
  18. var _self = this;
  19. if (this.$parent.data.title.length == 0) {
  20. res.code = false;
  21. res.message = "顶部标题不能为空";
  22. setTimeout(function () {
  23. $("#title_" + _self.$parent.data.index).focus();
  24. }, 10);
  25. }else if (this.$parent.data.title.length > 24) {
  26. res.code = false;
  27. res.message = "顶部标题最多24个字符";
  28. setTimeout(function () {
  29. $("#title_" + _self.$parent.data.index).focus();
  30. }, 10);
  31. }else if (this.$parent.data.isOpenOperation) {
  32. if (this.$parent.data.operationName.length == 0) {
  33. res.code = false;
  34. res.message = "功能名称不能为空";
  35. setTimeout(function () {
  36. $("#top_operation_" + _self.$parent.data.index).focus();
  37. }, 10);
  38. }
  39. if (this.$parent.data.operationName.length > 10) {
  40. res.code = false;
  41. res.message = "功能名称最多10个字符";
  42. setTimeout(function () {
  43. $("#top_operation_" + _self.$parent.data.index).focus();
  44. }, 10);
  45. }
  46. }
  47. return res;
  48. }
  49. }
  50. });