zydx-plus 1.1.17 → 1.2.21

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.1.17",
3
+ "version": "1.2.21",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -2,32 +2,111 @@
2
2
  <useOffsetPagination :pageCount="pageCount"
3
3
  :total="total"
4
4
  :page="page"
5
+ :isFinished="isFinished"
5
6
  @page:change="pageChange"
6
7
  v-slot="{
7
8
  next,
8
9
  prev,
9
10
  isFirstPage,
10
- isLastPage
11
+ isLastPage,
12
+ isLoading,
13
+ isPrevClicked,
14
+ isNextClicked
11
15
  }">
12
16
 
13
17
  <div class="paginator">
14
- <button :disabled="isFirstPage"
18
+ <button :disabled="isFirstPage || isLoading"
15
19
  class="defaultButton"
16
20
  @click="prev">
17
- 上一页
21
+ <template v-if="isPrevClicked">
22
+ <svg xmlns="http://www.w3.org/2000/svg"
23
+ width="16"
24
+ height="16"
25
+ viewBox="0 0 24 24">
26
+ <g fill="none"
27
+ stroke="black"
28
+ stroke-linecap="round"
29
+ stroke-width="2">
30
+ <path stroke-dasharray="60"
31
+ stroke-dashoffset="60"
32
+ stroke-opacity=".3"
33
+ d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z">
34
+ <animate fill="freeze"
35
+ attributeName="stroke-dashoffset"
36
+ dur="1.3s"
37
+ values="60;0" />
38
+ </path>
39
+ <path stroke-dasharray="15"
40
+ stroke-dashoffset="15"
41
+ d="M12 3C16.9706 3 21 7.02944 21 12">
42
+ <animate fill="freeze"
43
+ attributeName="stroke-dashoffset"
44
+ dur="0.3s"
45
+ values="15;0" />
46
+ <animateTransform attributeName="transform"
47
+ dur="1.5s"
48
+ repeatCount="indefinite"
49
+ type="rotate"
50
+ values="0 12 12;360 12 12" />
51
+ </path>
52
+ </g>
53
+ </svg>
54
+ </template>
55
+ <template v-else>
56
+ 上一页
57
+ </template>
18
58
  </button>
19
59
  <div class="paginator_info">
20
- <input type="input"
60
+ <input type="text"
61
+ @keyup="handleKeyup"
21
62
  class="paginator_input"
22
- v-model.number="page" />
63
+ v-model.number="page"
64
+ @input="handleInput" />
23
65
  <span>/</span>
24
66
  <span>{{ pages }}</span>
25
67
  </div>
26
- <button :disabled="isLastPage"
68
+ <button :disabled="isLastPage || isLoading"
27
69
  class="defaultButton"
28
70
  @click="next">
29
- 下一页
71
+ <template v-if="isNextClicked">
72
+ <svg xmlns="http://www.w3.org/2000/svg"
73
+ width="16"
74
+ height="16"
75
+ viewBox="0 0 24 24">
76
+ <g fill="none"
77
+ stroke="black"
78
+ stroke-linecap="round"
79
+ stroke-width="2">
80
+ <path stroke-dasharray="60"
81
+ stroke-dashoffset="60"
82
+ stroke-opacity=".3"
83
+ d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z">
84
+ <animate fill="freeze"
85
+ attributeName="stroke-dashoffset"
86
+ dur="1.3s"
87
+ values="60;0" />
88
+ </path>
89
+ <path stroke-dasharray="15"
90
+ stroke-dashoffset="15"
91
+ d="M12 3C16.9706 3 21 7.02944 21 12">
92
+ <animate fill="freeze"
93
+ attributeName="stroke-dashoffset"
94
+ dur="0.3s"
95
+ values="15;0" />
96
+ <animateTransform attributeName="transform"
97
+ dur="1.5s"
98
+ repeatCount="indefinite"
99
+ type="rotate"
100
+ values="0 12 12;360 12 12" />
101
+ </path>
102
+ </g>
103
+ </svg>
104
+ </template>
105
+ <template v-else>
106
+ 下一页
107
+ </template>
30
108
  </button>
109
+
31
110
  </div>
32
111
  </useOffsetPagination>
33
112
  </template>
@@ -35,6 +114,18 @@
35
114
  <script>
36
115
  import { defineComponent } from 'vue'
37
116
  import useOffsetPagination from './useOffsetPagination.vue';
117
+ export const debounceTimer = 500
118
+ export function debounce(fn, delay = debounceTimer) {
119
+ var timeoutID = null
120
+ return function () {
121
+ clearTimeout(timeoutID)
122
+ var args = arguments
123
+ var that = this
124
+ timeoutID = setTimeout(function () {
125
+ fn.apply(that, args)
126
+ }, delay)
127
+ }
128
+ }
38
129
  export default defineComponent({
39
130
  name: 'zydx-pagination',
40
131
  components: {
@@ -44,15 +135,19 @@ export default defineComponent({
44
135
  props: {
45
136
  total: {
46
137
  type: Number,
47
- default: 0
138
+ default: 1
48
139
  },
49
140
  pageCount: {
50
141
  type: Number,
51
- default: 10
142
+ default: 1
52
143
  },
53
144
  currentPage: {
54
145
  type: Number,
55
146
  default: 1
147
+ },
148
+ isFinished: {
149
+ type: Boolean,
150
+ default: false
56
151
  }
57
152
  },
58
153
  data() {
@@ -64,6 +159,24 @@ export default defineComponent({
64
159
  pageChange: function (v) {
65
160
  this.$emit('page:change', v)
66
161
  this.page = v
162
+ },
163
+ handleInput: debounce(function (e) {
164
+ let input = Number(e.target.value)
165
+ if (input > this.pages) {
166
+ this.page = this.pages
167
+ this.$emit('page:change', this.page)
168
+ return
169
+ }
170
+ if (input < 1) {
171
+ this.page = 1
172
+ this.$emit('page:change', 1)
173
+ return
174
+ }
175
+ this.page = input
176
+ this.$emit('page:change', this.page)
177
+ }),
178
+ handleKeyup: function (e) {
179
+ this.page = e.target.value.replace(/[^\d]/, '')
67
180
  }
68
181
  },
69
182
  computed: {
@@ -73,16 +186,6 @@ export default defineComponent({
73
186
 
74
187
  },
75
188
  watch: {
76
- page: {
77
- handler: function (v) {
78
- if (v >= this.pages) {
79
- this.page = Number(String(this.page).slice(2))
80
- }
81
- if (v <= 1) {
82
- this.page = 1
83
- }
84
- }
85
- },
86
189
  currentPage: {
87
190
  handler: function (v) {
88
191
  if (v >= this.pages) {
@@ -1,17 +1,5 @@
1
1
 
2
2
  <script>
3
- export const debounceTimer = 500
4
- export function debounce(fn, delay = debounceTimer) {
5
- var timeoutID = null
6
- return function () {
7
- clearTimeout(timeoutID)
8
- var args = arguments
9
- var that = this
10
- timeoutID = setTimeout(function () {
11
- fn.apply(that, args)
12
- }, delay)
13
- }
14
- }
15
3
  import { defineComponent } from 'vue';
16
4
  export default defineComponent({
17
5
  props: {
@@ -26,21 +14,34 @@ export default defineComponent({
26
14
  pageCount: {
27
15
  type: Number,
28
16
  default: 10
29
- }
17
+ },
18
+ isFinished: {
19
+ type: Boolean,
20
+ default: false
21
+ },
30
22
  },
31
23
  inheritAttrs: false,
32
24
  data() {
33
25
  return {
34
- currentPage: 1
26
+ currentPage: 1,
27
+ isNextClicked: false,
28
+ isPrevClicked: false,
29
+ isLoading: false,
35
30
  }
36
31
  },
37
32
  methods: {
38
33
  clamp: (num, min, max) => Math.min(Math.max(num, min), max),
39
34
  prev: function () {
35
+ this.isLoading = true
36
+ this.isPrevClicked = true
40
37
  this.currentPage = this.clamp(this.currentPage - 1, 1, this.pages)
38
+ this.$emit('page:change', this.currentPage)
41
39
  },
42
40
  next: function () {
41
+ this.isLoading = true
42
+ this.isNextClicked = true
43
43
  this.currentPage = this.clamp(this.currentPage + 1, 1, this.pages)
44
+ this.$emit('page:change', this.currentPage)
44
45
  },
45
46
  },
46
47
  computed: {
@@ -61,13 +62,16 @@ export default defineComponent({
61
62
  },
62
63
  immediate: true
63
64
  },
64
- currentPage: {
65
- handler: debounce(function (v) {
66
- this.$emit('page:change', v)
67
- if (v < 1) {
68
- this.currentPage = 1
65
+ isFinished: {
66
+ handler: function (v) {
67
+ if (v) {
68
+ this.isLoading = false
69
+ this.isNextClicked = false
70
+ this.isPrevClicked = false
71
+ } else {
72
+ this.isLoading = true
69
73
  }
70
- }),
74
+ },
71
75
  immediate: true
72
76
  }
73
77
  },
@@ -77,7 +81,10 @@ export default defineComponent({
77
81
  next: this.next,
78
82
  prev: this.prev,
79
83
  isFirstPage: this.isFirstPage,
80
- isLastPage: this.isLastPage
84
+ isLastPage: this.isLastPage,
85
+ isLoading: this.isLoading,
86
+ isPrevClicked: this.isPrevClicked,
87
+ isNextClicked: this.isNextClicked,
81
88
  })
82
89
  }
83
90
 
@@ -0,0 +1,6 @@
1
+ import main from './src/select';
2
+
3
+ main.install = function(Vue) {
4
+ Vue.component(main.name, main);
5
+ };
6
+ export default main;
@@ -0,0 +1,198 @@
1
+ <template>
2
+ <div class="wrapper">
3
+ <!-- <div id='custom-select-status'
4
+ class='hidden-visually'
5
+ aria-live="polite"></div> -->
6
+ <div class="custom-select">
7
+ <input stype="text"
8
+ :value="selected"
9
+ :readonly="true"
10
+ @click="toggleDropDown"
11
+ class="select-css" />
12
+ <span class="custom-select-icons"
13
+ @click="toggleDropDown">
14
+ <svg xmlns="http://www.w3.org/2000/svg"
15
+ width="16"
16
+ height="16"
17
+ viewBox="0 0 24 24">
18
+ <g :transform="transform"
19
+ :style="style">
20
+ <path fill="#c0c4cc"
21
+ d="M15.125 21.1L6.7 12.7q-.15-.15-.213-.325T6.425 12q0-.2.062-.375T6.7 11.3l8.425-8.425q.35-.35.875-.35t.9.375q.375.375.375.875t-.375.875L9.55 12l7.35 7.35q.35.35.35.863t-.375.887q-.375.375-.875.375t-.875-.375Z" />
22
+ </g>
23
+ </svg>
24
+ </span>
25
+ <transition>
26
+ <ul v-if="isOpen"
27
+ class="custom-select-options">
28
+ <li v-for="(option, idx) in options"
29
+ :key="idx"
30
+ @click="handleClick(option)">{{ option.label }}</li>
31
+
32
+ </ul>
33
+ </transition>
34
+ </div>
35
+ </div>
36
+ </template>
37
+
38
+ <script>
39
+ import { defineComponent } from 'vue'
40
+ export default defineComponent({
41
+ name: 'zydx-select',
42
+ props: {
43
+ options: {
44
+ type: Array,
45
+ default: () => []
46
+ },
47
+ value: {
48
+ type: String,
49
+ default: ''
50
+ }
51
+ },
52
+ data() {
53
+ return {
54
+ isOpen: false,
55
+ selected: null
56
+ }
57
+ },
58
+ methods: {
59
+ toggleDropDown: function () {
60
+ this.isOpen = !this.isOpen
61
+ },
62
+ handleClick: function (option) {
63
+ this.$emit('update:value', option.value)
64
+ this.selected = option.label
65
+ this.isOpen = false
66
+ }
67
+ },
68
+ computed: {
69
+ transform: function () {
70
+ return this.isOpen
71
+ ? 'rotate(90 12 12)'
72
+ : 'rotate(-90 12 12)'
73
+ },
74
+ style: function () {
75
+ return 'transition: all 0.2s ease;'
76
+ }
77
+ },
78
+ watch: {
79
+ value: {
80
+ handler: function (v) {
81
+ const { label } = this.options.find(option => option.value === v)
82
+ this.selected = label
83
+ },
84
+ immediate: true
85
+ }
86
+ }
87
+ })
88
+
89
+ </script>
90
+ <style scoped>
91
+ .v-enter-active,
92
+ .v-leave-active {
93
+ transition: opacity 0.5s ease;
94
+ }
95
+
96
+ .v-enter-from,
97
+ .v-leave-to {
98
+ opacity: 0;
99
+ }
100
+
101
+ .wrapper {
102
+ text-align: left;
103
+ }
104
+
105
+ .sample {
106
+ border: 1px solid #eeeeee;
107
+ background: #ffffff;
108
+ max-width: 30em;
109
+ padding: 1em;
110
+ margin-bottom: 1em;
111
+ }
112
+
113
+ .custom-select {
114
+ position: relative;
115
+ }
116
+
117
+ .select-css {
118
+ display: block;
119
+ font-size: 14px;
120
+ font-family: inherit;
121
+ font-weight: 400;
122
+ color: #606266;
123
+ line-height: 30px;
124
+ padding: 0 30px 0 20px;
125
+ width: 100%;
126
+ max-width: 100%;
127
+ box-sizing: border-box;
128
+ margin: 0;
129
+ border: 1px solid #aaa;
130
+ box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.04);
131
+ border-radius: 3px;
132
+ -moz-appearance: none;
133
+ -webkit-appearance: none;
134
+ appearance: none;
135
+ background-color: #fff;
136
+ position: relative;
137
+ z-index: 10;
138
+ }
139
+
140
+ .select-css::-ms-expand {
141
+ display: none;
142
+ }
143
+
144
+ .select-css:hover {
145
+ border-color: #888;
146
+ }
147
+
148
+ .select-css:focus {
149
+ border-color: #C64C10;
150
+ }
151
+
152
+
153
+ .custom-select-icons {
154
+ position: absolute;
155
+ top: 0.5em;
156
+ right: 0.5em;
157
+ z-index: 20;
158
+ border: 1px solid white;
159
+ background: transparent;
160
+ }
161
+
162
+ .custom-select-options {
163
+ border: 1px solid #aaa;
164
+ border-radius: 0 0 0.25em 0.25em;
165
+ line-height: 1.5;
166
+ margin: 0;
167
+ margin-top: 0.5em;
168
+ padding: 0;
169
+ list-style-type: none;
170
+ font-weight: normal;
171
+ cursor: pointer;
172
+ z-index: 2;
173
+ position: absolute;
174
+ width: calc(100% - 1px);
175
+ background-color: #ffffff;
176
+ }
177
+
178
+ .custom-select-options li {
179
+ padding: 0 20px;
180
+ font-size: 14px;
181
+ line-height: 30px;
182
+ letter-spacing: 0px;
183
+ text-align: left;
184
+ color: #606266;
185
+ text-overflow: ellipsis;
186
+ white-space: nowrap;
187
+ overflow: hidden;
188
+ }
189
+
190
+ .custom-select-options li:hover {
191
+ color: #C64C10;
192
+ border-width: 0 0 0 1px;
193
+ }
194
+
195
+ .custom-select-options li:focus {
196
+ color: #C64C10;
197
+ }
198
+ </style>
@@ -0,0 +1,7 @@
1
+ import publicTable from './src/zydxTopicDry';
2
+
3
+ publicTable.install = function(Vue) {
4
+ Vue.component(publicTable.name, publicTable);
5
+ };
6
+
7
+ export default publicTable;
@@ -0,0 +1,39 @@
1
+ .title_box {
2
+ display: flex;
3
+ flex-direction: row;
4
+ }
5
+
6
+ .title_box>div:first-child {
7
+ flex-grow: 1;
8
+ text-overflow: ellipsis;
9
+ white-space: nowrap;
10
+ overflow: hidden;
11
+ line-height: 30px;
12
+ }
13
+
14
+ .title_box>div:last-child {
15
+ display: flex;
16
+ flex-wrap: nowrap;
17
+ align-items: center;
18
+ text-indent: 0em;
19
+ }
20
+
21
+ .title_box_a {
22
+ width: 100%;
23
+ text-align: left;
24
+ line-height: 30px;
25
+ overflow: hidden;
26
+ }
27
+
28
+ .title_box_a>div {
29
+ display: inline;
30
+ }
31
+
32
+ .title_box_a>div:last-child {
33
+ float: right;
34
+ flex-direction: row;
35
+ display: flex;
36
+ align-items: center;
37
+ height: 30px;
38
+ text-indent: 0em;
39
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @描述: 题干一类的通用样式(比如:左侧文字,右侧按钮)
3
+ * @创建时间: 2022-08-12 11:19:00
4
+ * @内容:
5
+ 必传值:名字/类型/默认值/作用
6
+ 非必传值:
7
+ isHide 是否都在一行显示, true 超出一行的部分。。。。。
8
+ * @回调事件:
9
+ @组件内方法:
10
+ */
11
+ <template>
12
+ <div>
13
+ <div :class="title_style" :style="text_indent">
14
+ <div>
15
+ <slot name="title_slot"></slot>
16
+ </div>
17
+ <div>
18
+ <slot name="button_slot"></slot>
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </template>
23
+
24
+ <script>
25
+ export default {
26
+ name: 'zydx-topic-dry',
27
+ computed: { // 计算属性
28
+ title_style () {
29
+ if (this.is_hide) {
30
+ return 'title_box'
31
+ }
32
+ return 'title_box_a'
33
+ },
34
+ text_indent () {
35
+ return "text-indent: "+this.indent_em+"em;"
36
+ }
37
+ },
38
+ props: {
39
+ is_hide: { // 是否都在一行显示, true 超出一行的部分显示...
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ indent_em: { // 首行缩进em
44
+ type: Number,
45
+ default: 0
46
+ }
47
+ },
48
+ mounted() {
49
+ }
50
+ }
51
+ </script>
52
+
53
+ <style scoped src="./zydxStyle.css">
54
+ </style>
@@ -47,6 +47,13 @@ export default {
47
47
  height: {
48
48
  type: String,
49
49
  default: '30px'
50
+ },
51
+ /**
52
+ **
53
+ */
54
+ default_expand_key: {
55
+ type: Array,
56
+ default: () => []
50
57
  }
51
58
  },
52
59
  data() {
@@ -55,8 +62,8 @@ export default {
55
62
  }
56
63
  },
57
64
  mounted() {
58
-
59
65
  },
66
+
60
67
  watch: {
61
68
  data: {
62
69
  handler: function (v) {
@@ -74,16 +81,17 @@ export default {
74
81
  }
75
82
  let output = []
76
83
  for (const leaf of array) {
84
+ const { id } = leaf
77
85
  let next = {
78
86
  ...leaf,
79
- isOpen: false,
87
+ isOpen: this.default_expand_key.includes(id),
80
88
  children: leaf.children ? this.traverse(leaf.children) : []
81
89
  }
82
90
  output.push(next)
83
91
  }
84
92
  return output
85
93
  },
86
- handleClick: function (tree) {
94
+ handleClick: async function (tree) {
87
95
  this.$emit('update:select', tree)
88
96
  const { id } = tree
89
97
  this.treeData = this.treeData.map((item) => {
@@ -115,7 +123,8 @@ export default {
115
123
  <div class="tree"
116
124
  :key="tree.id"
117
125
  v-for="(tree) in treeData">
118
- <div class="tree_node"
126
+ <div :data-id="tree.id"
127
+ class="tree_node"
119
128
  :class="{ 'tree_node_active': tree.isOpen }"
120
129
  @click="handleClick(tree)">
121
130
  <template v-if="tree.level">
@@ -143,6 +152,7 @@ export default {
143
152
  <tree :data="tree.children"
144
153
  :active_color="active_color"
145
154
  :border="border"
155
+ :default_expand_key="default_expand_key"
146
156
  :key="tree.id"
147
157
  @update:select="updateSelect"
148
158
  :accordian="accordian"></tree>
@@ -168,7 +178,7 @@ export default {
168
178
  justify-content: flex-start;
169
179
  text-align: left;
170
180
  height: v-bind(height);
171
- cursor: pointer;
181
+ cursor: grabbing;
172
182
  gap: 16px;
173
183
  border-bottom: v-bind(border)
174
184
  }
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ import menuTree from './components/menuTree/index';
5
5
  import coloring from './components/coloring/index';
6
6
  import tree from './components/tree/index';
7
7
  import Pagination from './components/pagination/index';
8
+ import Select from './components/select/index';
8
9
 
9
10
  const components = [
10
11
  Calendar,
@@ -12,7 +13,8 @@ const components = [
12
13
  menuTree,
13
14
  coloring,
14
15
  tree,
15
- Pagination
16
+ Pagination,
17
+ Select
16
18
  ];
17
19
 
18
20
  function install(app) {
@@ -23,7 +25,7 @@ function install(app) {
23
25
  }
24
26
 
25
27
  export default {
26
- version: '1.1.17',
28
+ version: '1.2.21',
27
29
  install,
28
30
  Calendar,
29
31
  Message,
@@ -31,6 +33,7 @@ export default {
31
33
  menuTree,
32
34
  coloring,
33
35
  tree,
34
- Pagination
36
+ Pagination,
37
+ Select
35
38
  };
36
39