@ajaxjs/ui 1.1.9 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/package.json +3 -3
  2. package/src/App.vue +14 -0
  3. package/src/index.ts +50 -0
  4. package/src/main.ts +12 -0
  5. package/src/pages/calendar.vue +33 -0
  6. package/src/pages/form.vue +68 -0
  7. package/src/pages/html-editor.vue +44 -0
  8. package/src/pages/index.vue +150 -0
  9. package/src/pages/play-ground.vue +14 -0
  10. package/src/pages/widgets.vue +183 -0
  11. package/src/router/index.ts +19 -0
  12. package/src/shims-vue.d.ts +4 -0
  13. package/src/style/common-functions.less +294 -0
  14. package/src/style/reset.less +19 -0
  15. package/src/util/cookies.ts +43 -0
  16. package/src/util/dom.ts +47 -0
  17. package/src/util/utils.ts +184 -0
  18. package/src/util/xhr-config.ts +25 -0
  19. package/src/util/xhr.ts +296 -0
  20. package/src/widget/AccordionMenu.vue +140 -0
  21. package/src/widget/AdjustFontSize.vue +65 -0
  22. package/src/widget/Article.vue +59 -0
  23. package/src/widget/EmptyContent.js +4 -0
  24. package/src/widget/Expander.vue +65 -0
  25. package/src/widget/FileUploader/FileUploader.less +68 -0
  26. package/src/widget/FileUploader/FileUploader.ts +156 -0
  27. package/src/widget/FileUploader/FileUploader.vue +43 -0
  28. package/src/widget/HtmlEditor/HtmlEditor.less +345 -0
  29. package/src/widget/HtmlEditor/HtmlEditor.ts +339 -0
  30. package/src/widget/HtmlEditor/HtmlEditor.vue +70 -0
  31. package/src/widget/HtmlEditor/html-editor-HtmlSanitizer.js +103 -0
  32. package/src/widget/ImageEnlarger.vue +105 -0
  33. package/src/widget/OpacityBanner.vue +125 -0
  34. package/src/widget/ProcessLine.vue +133 -0
  35. package/src/widget/Resize.ts +152 -0
  36. package/src/widget/Resize.vue +104 -0
  37. package/src/widget/TreeSelector.vue +4 -0
  38. package/src/widget/calendar/BetweenDate.vue +63 -0
  39. package/src/widget/calendar/Calendar.less +210 -0
  40. package/src/widget/calendar/Calendar.ts +167 -0
  41. package/src/widget/calendar/Calendar.vue +52 -0
  42. package/src/widget/calendar/CalendarInput.vue +71 -0
  43. package/src/widget/form/validator.ts +289 -0
  44. package/src/widget/play-ground/sku.vue +93 -0
@@ -0,0 +1,125 @@
1
+ <template>
2
+ <ul class="aj-opacity-banner">
3
+ <slot></slot>
4
+ </ul>
5
+ </template>
6
+
7
+ <script lang="ts">
8
+ /**
9
+ * 渐显 banner
10
+ * 注意:定时器保存在 DOM 元素的属性上,是否会内存泄漏呢?
11
+ */
12
+ export default {
13
+ props: {
14
+ delay: { default: 3000 }, // 延时
15
+ fps: { default: 25 }, // 帧速
16
+ },
17
+ data(): any {
18
+ return {
19
+ active: 0, // 当前索引
20
+ };
21
+ },
22
+ mounted(): void {
23
+ this.list = this.$el.querySelectorAll("li"); // 各帧
24
+ this.list[0].style.opacity = "1";
25
+ this.run();
26
+ },
27
+ methods: {
28
+ /**
29
+ * 播放动画
30
+ *
31
+ * @param this
32
+ */
33
+ run(): void {
34
+ this.timer = window.setInterval(() => {
35
+ let active: number = this.active;
36
+ this.clear();
37
+ active += 1;
38
+ this.active = active % this.list.length;
39
+ this.animate(100);
40
+ }, this.delay);
41
+ },
42
+
43
+ /**
44
+ * 下一帧
45
+ *
46
+ * @param this
47
+ */
48
+ per(): void {
49
+ let active: number = this.active;
50
+ this.clear();
51
+ active -= 1;
52
+ active = active % this.list.length;
53
+
54
+ if (active < 0) active = this.list.length - 1;
55
+
56
+ this.active = active;
57
+ this.animate(100);
58
+ },
59
+
60
+ /**
61
+ * 内容淡出
62
+ */
63
+ clear(): void {
64
+ this.animate(0);
65
+ },
66
+
67
+ /**
68
+ *
69
+ * @param params
70
+ */
71
+ animate(params: number): void {
72
+ var el: HTMLLIElement = this.list[this.active],
73
+ fps: number = 1000 / this.fps;
74
+ // @ts-ignore
75
+ window.clearTimeout(el.timer);
76
+
77
+ window.setTimeout(function loop() {
78
+ var i: number = getOpacity(el);
79
+ let speed: number = (params - i) / 8;
80
+ speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
81
+ // console.log("i=" + i + "; speed="+ speed+"; s="+s+"; k="+k);
82
+ i += speed;
83
+ el.style.opacity = String(i / 100);
84
+ // @ts-ignore
85
+ window.clearTimeout(el.timer);
86
+ // params.complete && params.complete.call(elem);
87
+ // @ts-ignore
88
+ el.timer = window.setTimeout(loop, fps);
89
+ }, fps);
90
+ },
91
+ },
92
+ };
93
+
94
+ /**
95
+ * 获取元素的透明度
96
+ *
97
+ * @param el
98
+ */
99
+ function getOpacity(el: Element): number {
100
+ let v = Number(getComputedStyle(el)["opacity"]);
101
+ v *= 100;
102
+
103
+ return parseFloat(v + "") || 0;
104
+ }
105
+ </script>
106
+
107
+ <style lang="less" scoped>
108
+ .aj-opacity-banner {
109
+ position: relative;
110
+ min-height: 90px;
111
+
112
+ li {
113
+ position: absolute;
114
+ top: 0;
115
+ left: 0;
116
+ opacity: 0;
117
+ width: 100%;
118
+ }
119
+
120
+ img {
121
+ // border-top:solid 20px #00416d;
122
+ width: 100%;
123
+ }
124
+ }
125
+ </style>
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <div class="aj-process-line">
3
+ <div class="process-line">
4
+ <div v-for="(item, index) in items" :key="index" :class="{current: index == current, done: index < current}">
5
+ <span>{{index + 1}}</span>
6
+ <p>{{item}}</p>
7
+ </div>
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script lang="ts">
13
+ /**
14
+ * 进度条
15
+ */
16
+ export default {
17
+ props: {
18
+ items: {
19
+ type: Array,
20
+ default(): string[] {
21
+ return ["Step 1", "Step 2", "Step 3"];
22
+ },
23
+ },
24
+ },
25
+ data():any {
26
+ return {
27
+ current: 0,
28
+ };
29
+ },
30
+ methods: {
31
+ /**
32
+ *
33
+ * @param i
34
+ */
35
+ go(i: number): void {
36
+ this.current = i;
37
+ },
38
+
39
+ /**
40
+ *
41
+ */
42
+ perv(): void {
43
+ let perv: number = this.current - 1;
44
+ if (perv < 0) perv = this.items.length - 1;
45
+
46
+ this.go(perv);
47
+ },
48
+
49
+ /**
50
+ *
51
+ */
52
+ next(): void {
53
+ let next: number = this.current + 1;
54
+ if (this.items.length == next) next = 0; // 循环
55
+
56
+ this.go(next);
57
+ },
58
+ },
59
+ };
60
+ </script>
61
+
62
+ <style lang="less" scoped>
63
+ .aj-process-line {
64
+ display: flex;
65
+ padding: 5%;
66
+ justify-content: center;
67
+
68
+ .process-line {
69
+ font-size: 18px;
70
+ color: lightgray;
71
+ font-weight: bold;
72
+
73
+ & > div {
74
+ float: left;
75
+ width: 156px;
76
+ text-align: center;
77
+ position: relative;
78
+
79
+ &.current {
80
+ color: black;
81
+
82
+ span {
83
+ background-color: gray;
84
+ }
85
+ }
86
+
87
+ &.done {
88
+ // color: lighten(@mainColor, 80%);
89
+ span {
90
+ // background-color: lighten(@mainColor, 50%);
91
+ }
92
+
93
+ &::after {
94
+ // background-color: lighten(@mainColor, 50%);
95
+ }
96
+ }
97
+
98
+ p {
99
+ font-size: 1rem;
100
+ letter-spacing: 3px;
101
+ padding-top: 5%;
102
+ }
103
+
104
+ span {
105
+ display: inline-block;
106
+ width: 32px;
107
+ height: 32px;
108
+ border-radius: 50%;
109
+ color: #fff;
110
+ line-height: 32px;
111
+ font-size: 16px;
112
+ background-color: lightgray;
113
+ position: relative;
114
+ z-index: 1;
115
+ }
116
+
117
+ &:last-child::after {
118
+ display: none;
119
+ }
120
+
121
+ &::after {
122
+ content: "";
123
+ position: absolute;
124
+ top: 14px;
125
+ left: 94px;
126
+ width: 124px;
127
+ height: 4px;
128
+ background-color: lightgray;
129
+ }
130
+ }
131
+ }
132
+ }
133
+ </style>
@@ -0,0 +1,152 @@
1
+ export default {
2
+ data() {
3
+ return {
4
+ styleWidth: 0,// 样式参数值
5
+ styleHeight: 0,
6
+ styleLeft: 0,
7
+ styleTop: 0,
8
+ sideLeft: 0, // 四条边定位坐标
9
+ sideRight: 0,
10
+ sideUp: 0,
11
+ sideDown: 0,
12
+ fixLeft: 0, // top 和 left 定位参数
13
+ fixTop: 0,
14
+ fn: null,
15
+
16
+ LockX: false,// 是否锁定水平方向拖放
17
+ LockY: false,// 是否锁定垂直方向拖放
18
+ Lock: false,// 是否锁定
19
+
20
+ scale: { // 按比例缩放
21
+ enable: true, // 是否按比例缩放
22
+ ratio: 0, // 设置比例(宽/高)
23
+ left: 0,
24
+ top: 0,
25
+ },
26
+
27
+ min: { // 最小控制
28
+ enable: false,
29
+ height: 100,
30
+ width: 200,
31
+ },
32
+ max: { // 最大控制
33
+ enable: false,
34
+ height: 300,
35
+ width: 500,
36
+ }
37
+
38
+ };
39
+ },
40
+ methods: {
41
+ /**
42
+ * 准备拖动
43
+ */
44
+ start(e: MouseEvent, fn: Function): void {
45
+ this.styleWidth = this.$el.clientWidth;
46
+ this.styleHeight = this.$el.clientHeight;
47
+ this.styleLeft = this.$el.offsetLeft; // 记录鼠标相对拖放对象的位置
48
+ this.styleTop = this.$el.offsetTop;
49
+
50
+ this.sideLeft = e.clientX - this.styleWidth;
51
+ this.sideRight = e.clientX + this.styleWidth;
52
+ this.sideUp = e.clientY - this.styleHeight;
53
+ this.sideDown = e.clientY + this.styleHeight;
54
+
55
+ this.fixLeft = this.styleWidth + this.styleLeft;
56
+ this.fixTop = this.styleHeight + this.styleTop;
57
+ this.fn = fn;
58
+
59
+ if (this.scale.enable) {
60
+ this.scale.ratio = Math.max(this.scale.ratio, 0) || this.styleWidth / this.styleHeight; //设置比例
61
+ this.scale.left = this.styleLeft + this.styleWidth / 2;// left 和 top 的定位坐标
62
+ this.scale.top = this.styleTop + this.styleHeight / 2;
63
+ }
64
+
65
+ document.addEventListener("mousemove", this.resize);// mousemove 时移动 mouseup 时停止
66
+ document.addEventListener("mouseup", this.stop);
67
+ },
68
+
69
+ // 缩放
70
+ resize(e: MouseEvent): void {
71
+ window.getSelection().removeAllRanges(); // 清除选择
72
+ this.fn(e);
73
+
74
+ if (this.min.enable) {
75
+ if (this.styleHeight <= this.min.height)
76
+ return;
77
+ if (this.styleWidth <= this.min.width)
78
+ return;
79
+ }
80
+ if (this.max.enable) {
81
+ if (this.styleHeight >= this.max.height)
82
+ return;
83
+ if (this.styleWidth >= this.max.width)
84
+ return;
85
+ }
86
+
87
+ let s = this.$el.style;
88
+ s.width = this.styleWidth + "px";
89
+ s.height = this.styleHeight + "px";
90
+ s.top = this.styleTop + "px";
91
+ s.left = this.styleLeft + "px";
92
+ },
93
+
94
+ // 停止缩放
95
+ stop(): void {
96
+ document.removeEventListener("mousemove", this.resize);
97
+ document.removeEventListener("mouseup", this.stop);
98
+ },
99
+
100
+ //缩放程序
101
+
102
+ //上
103
+ up(e: MouseEvent): void {
104
+ this.styleHeight = Math.max(this.sideDown - e.clientY, 0);
105
+ this.styleTop = this.fixTop - this.styleHeight;
106
+ this.styleLeft = this.scale.left - this.styleWidth / 2;
107
+ console.log(this.styleLeft)
108
+ },
109
+
110
+ //下
111
+ down(e: MouseEvent): void {
112
+ this.styleHeight = Math.max(e.clientY - this.sideUp, 0);
113
+ this.styleLeft = this.scale.left - this.styleWidth / 2;
114
+
115
+ },
116
+
117
+ //右
118
+ right(e: MouseEvent): void {
119
+ this.styleWidth = Math.max(e.clientX - this.sideLeft, 0);
120
+ },
121
+
122
+ //左
123
+ left(e: MouseEvent): void {
124
+ this.styleWidth = Math.max(this.sideRight - e.clientX, 0);
125
+ this.styleLeft = this.fixLeft - this.styleWidth;
126
+ },
127
+
128
+ //右下
129
+ rightDown(e: MouseEvent): void {
130
+ this.right(e);
131
+ this.down(e);
132
+ },
133
+
134
+ //右上
135
+ rightUp(e: MouseEvent): void {
136
+ this.right(e);
137
+ this.up(e);
138
+ },
139
+
140
+ //左下
141
+ leftDown(e: MouseEvent): void {
142
+ this.left(e);
143
+ this.down(e);
144
+ },
145
+
146
+ //左上
147
+ leftUp(e: MouseEvent): void {
148
+ this.left(e);
149
+ this.up(e);
150
+ },
151
+ },
152
+ };
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <!-- 拖拉缩放效果 -->
3
+ <div class="resize-box">
4
+ <div class="rRightDown" @mousedown="start($event, rightDown)"> </div>
5
+ <div class="rLeftDown" @mousedown="start($event, leftDown)"> </div>
6
+ <div class="rRightUp" @mousedown="start($event, rightUp)"> </div>
7
+ <div class="rLeftUp" @mousedown="start($event, leftUp)"> </div>
8
+ <div class="rRight" @mousedown="start($event, right)"> </div>
9
+ <div class="rLeft" @mousedown="start($event, left)"> </div>
10
+ <div class="rDown" @mousedown="start($event, down)"></div>
11
+ <div class="rUp" @mousedown="start($event, up)"> </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script lang="ts" src="./Resize.ts"></script>
16
+
17
+ <style lang="less" scoped>
18
+ .rRightDown,
19
+ .rLeftDown,
20
+ .rLeftUp,
21
+ .rRightUp,
22
+ .rRight,
23
+ .rLeft,
24
+ .rUp,
25
+ .rDown {
26
+ position: absolute;
27
+ background: #c00;
28
+ width: 7px;
29
+ height: 7px;
30
+ z-index: 5;
31
+ font-size: 0;
32
+ }
33
+
34
+ .rLeftDown, .rRightUp {
35
+ cursor: ne-resize;
36
+ }
37
+
38
+ .rRightDown, .rLeftUp {
39
+ cursor: nw-resize;
40
+ }
41
+
42
+ .rRight, .rLeft {
43
+ cursor: e-resize;
44
+ }
45
+
46
+ .rUp, .rDown {
47
+ cursor: n-resize;
48
+ }
49
+
50
+ .rLeftDown {
51
+ left: -4px;
52
+ bottom: -4px;
53
+ }
54
+
55
+ .rRightUp {
56
+ right: -4px;
57
+ top: -4px;
58
+ }
59
+
60
+ .rRightDown {
61
+ right: -4px;
62
+ bottom: -4px;
63
+ background-color: 0f;
64
+ }
65
+
66
+ .rLeftUp {
67
+ left: -4px;
68
+ top: -4px;
69
+ }
70
+
71
+ .rRight {
72
+ right: -4px;
73
+ top: 50%;
74
+ margin-top: -4px;
75
+ }
76
+
77
+ .rLeft {
78
+ left: -4px;
79
+ top: 50%;
80
+ margin-top: -4px;
81
+ }
82
+
83
+ .rUp {
84
+ top: -4px;
85
+ left: 50%;
86
+ margin-left: -4px;
87
+ }
88
+
89
+ .rDown {
90
+ bottom: -4px;
91
+ left: 50%;
92
+ margin-left: -4px;
93
+ }
94
+
95
+ .resize-box {
96
+ border: 1px solid gray;
97
+ width: 100px;
98
+ height: 60px;
99
+ top: 150px;
100
+ left: 550px;
101
+ background: #fff;
102
+ position: absolute;
103
+ }
104
+ </style>
@@ -0,0 +1,4 @@
1
+ <!-- 下拉分类 -->
2
+ <template>
3
+
4
+ </template>
@@ -0,0 +1,63 @@
1
+ <template>
2
+ <form action="." method="GET" class="dateRange" @submit="valid">
3
+ <aj-form-calendar-input
4
+ :date-only="true"
5
+ :position-fixed="true"
6
+ placeholder="起始时间"
7
+ field-name="startDate"
8
+ ></aj-form-calendar-input>
9
+ -
10
+ <aj-form-calendar-input
11
+ :date-only="true"
12
+ :position-fixed="true"
13
+ placeholder="截至时间"
14
+ field-name="endDate"
15
+ ></aj-form-calendar-input>
16
+ <button class="aj-btn">按时间筛选</button>
17
+ </form>
18
+ </template>
19
+
20
+ <script lang="ts">
21
+ /**
22
+ * 起始时间、截止时间的范围选择
23
+ */
24
+ export default {
25
+ props: {
26
+ isAjax: { type: Boolean, default: true }, // 是否 AJAX 模式
27
+ },
28
+ methods: {
29
+ valid(this: Vue, ev: Event): void {
30
+ let start = (<HTMLInputElement>(
31
+ this.$el.querySelector("input[name=startDate]")
32
+ )).value,
33
+ end = (<HTMLInputElement>this.$el.querySelector("input[name=endDate]"))
34
+ .value;
35
+
36
+ if (!start || !end) {
37
+ alert("输入数据不能为空");
38
+ ev.preventDefault();
39
+ return;
40
+ }
41
+
42
+ if (new Date(start) > new Date(end)) {
43
+ alert("起始日期不能晚于结束日期");
44
+ ev.preventDefault();
45
+ return;
46
+ }
47
+
48
+ //@ts-ignore
49
+ if (this.isAjax) {
50
+ ev.preventDefault();
51
+ let grid: any = this.$parent.$parent;
52
+
53
+ Object.assign(grid.$refs.pager.extraParam, {
54
+ startDate: start,
55
+ endDate: end,
56
+ });
57
+
58
+ grid.reload();
59
+ }
60
+ },
61
+ },
62
+ };
63
+ </script>