meixioacomponent 2.0.40 → 2.0.42

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": "meixioacomponent",
3
- "version": "2.0.40",
3
+ "version": "2.0.42",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -31,17 +31,17 @@
31
31
  "node-polyfill-webpack-plugin": "^2.0.1",
32
32
  "npm": "^9.6.1",
33
33
  "path-browserify": "^1.0.1",
34
+ "tdesign-vue": "^1.10.5-naruto",
34
35
  "ts-loader": "^9.4.2",
35
36
  "tslint": "^6.1.3",
36
37
  "tslint-config-standard": "^9.0.0",
37
38
  "tslint-loader": "^3.5.4",
38
39
  "typescript": "^4.9.4",
39
- "vue": "^2.7.10",
40
- "vue-class-component": "^7.2.6",
41
40
  "vue-cropper": "^0.5.8",
41
+ "vue": "^2.7.10",
42
42
  "vue-property-decorator": "^9.1.2",
43
- "vue-template-compiler": "^2.7.10",
44
- "tdesign-vue": "^1.10.5-naruto"
43
+ "vue-template-compiler": "^2.7.10"
44
+
45
45
  },
46
46
  "browserslist": [
47
47
  "> 1%",
@@ -0,0 +1,166 @@
1
+ <template>
2
+ <ol class="base-anchor-wrap">
3
+ <li
4
+ v-for="(item, index) in list"
5
+ :key="index"
6
+ :class="{
7
+ active: index === active,
8
+ }"
9
+ class="anchor-item-wrap"
10
+ >
11
+ <a
12
+ v-if="type === 'page'"
13
+ :href="`${currentPath}#${item.id}`"
14
+ @click="aTagClick(index)"
15
+ >
16
+ {{ item.title }}
17
+ </a>
18
+ <span v-else @click="toSetScrollTop(index)">{{ item.title }}</span>
19
+ </li>
20
+ </ol>
21
+ </template>
22
+
23
+ <script>
24
+ export default {
25
+ name:'baseAnchor'
26
+ }
27
+ </script>
28
+
29
+ <script setup>
30
+ import {getCurrentInstance, nextTick, onMounted, ref, computed} from "vue";
31
+ let _listenElement = null;
32
+ const instance = getCurrentInstance()
33
+ const props = defineProps({
34
+ listenElementId: {
35
+ //只接受id
36
+ type: String,
37
+ },
38
+ list: {
39
+ type: Array,
40
+ },
41
+ type: {
42
+ type: String,
43
+ default: 'page',
44
+ },
45
+ })
46
+
47
+ onMounted(() => {
48
+ nextTick(() => {
49
+ init()
50
+ })
51
+ })
52
+
53
+ const active = ref(0);
54
+
55
+ const currentPath = computed(() => {
56
+ return instance.proxy.$route.path
57
+ })
58
+
59
+ const init = () => {
60
+ let type = props.type
61
+ if (type === 'page') {
62
+ _listenElement = document.getElementsByClassName(
63
+ 'layout-contnet',
64
+ )[0]
65
+ _listenElement?.addEventListener('scroll', listenScroll)
66
+ } else {
67
+ _listenElement = document.getElementById(
68
+ `${props.listenElementId}`,
69
+ )
70
+ nextTick(() => {
71
+ _listenElement?.addEventListener('scroll', (e) => {
72
+ listenScroll(e)
73
+ })
74
+ })
75
+ }
76
+ }
77
+
78
+ const listenScroll = (e) => {
79
+ if (props.list.length <= 0) return
80
+ let type = props.type
81
+ let scrollTop = e.target.scrollTop
82
+ for (let i = 0; i < props.list.length; i++) {
83
+ let item = props.list[i]
84
+ let node = null
85
+ // 类型
86
+ if (type === 'page') {
87
+ // page 代表是全局 监听 layout 的滚动
88
+ node = document.getElementById(item.id)
89
+ } else {
90
+ // 指定的容器
91
+ node = _listenElement.querySelector(`#${item.id}`)
92
+ }
93
+ // 滑动到底部直接赋值
94
+ if (scrollTop + e.target.clientHeight >= e.target.scrollHeight - 5) {
95
+ active.value = props.list.length - 1
96
+ break
97
+ }
98
+ // 如果循环到最后一个dom也直接赋值
99
+ if (i === props.list.length - 1) {
100
+ active.value = i
101
+ break
102
+ } else {
103
+ let nextItem = props.list[i + 1]
104
+ let nextNode = null
105
+ if (type === 'page') {
106
+ nextNode = document.getElementById(nextItem.id)
107
+ } else {
108
+ nextNode = _listenElement.querySelector(`#${nextItem.id}`)
109
+ }
110
+ // 判单scrolltop是否小于下一个dom的高度
111
+ if (scrollTop < nextNode.offsetTop) {
112
+ active.value = i
113
+ break
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ const toSetScrollTop = (index) => {
120
+ if (index == active.value) {
121
+ return
122
+ }
123
+ let id = props.list[index].id
124
+ let dom = _listenElement.querySelector(`#${id}`)
125
+ if (dom) {
126
+ dom.scrollIntoView(true)
127
+ setTimeout(() => {
128
+ aTagClick(index)
129
+ }, 10)
130
+ }
131
+ }
132
+
133
+ const aTagClick = (index) => {
134
+ active.value = index
135
+ }
136
+ </script>
137
+
138
+ <style scoped lang="less">
139
+ .base-anchor-wrap {
140
+ width: auto;
141
+ height: auto;
142
+ overflow-y: auto;
143
+
144
+ .anchor-item-wrap {
145
+ padding-left: calc(var(--padding-4) * 2);
146
+ border-left: 2px solid var(--color-border);
147
+
148
+ a,
149
+ span {
150
+ display: inline-block;
151
+ color: var(--font-color-m);
152
+ margin: var(--margin-2) 0px;
153
+ font-size: var(--font-size-base);
154
+ }
155
+
156
+ span {
157
+ cursor: pointer;
158
+ }
159
+ }
160
+
161
+ .active {
162
+ border-left: 2px solid var(--color-primary);
163
+ color: var(--color-primary) !important;
164
+ }
165
+ }
166
+ </style>
@@ -1,6 +1,6 @@
1
- import baseAnchor from "./baseAnchor.vue";
1
+ import baseAnchor from "./baseAnchorV2.vue";
2
2
 
3
3
  baseAnchor.install = function (Vue) {
4
- Vue.component(baseAnchor.name, baseAnchor);
4
+ Vue.component(baseAnchor.default.name, baseAnchor);
5
5
  };
6
6
  export default baseAnchor;
@@ -20,43 +20,29 @@
20
20
 
21
21
  <script>
22
22
  import baseButtonHandleVue from '../baseButtonHandle/baseButtonHandle.vue'
23
- import {GetAreaTree} from "./api";
24
23
  import areaConfig from "./areaConfig";
25
24
  import {TransomComponentSize} from "../../../utils/utils";
25
+ import {mixinsByBaseArea} from "../../mixins/mixinsByBaseArea";
26
26
  //
27
27
 
28
28
  export default {
29
29
  name: 'baseArea',
30
30
  data() {
31
31
  return {
32
- loading: false,
33
32
  localValue: [],
34
33
  localDetailValue: {},
35
- placeholder: '请选择省市区镇',
36
- options: [],
37
34
  inputProps: {
38
35
  value: '',
39
36
  },
40
37
  }
41
38
  },
39
+ mixins: [mixinsByBaseArea],
42
40
  created() {
43
41
  },
44
-
45
- mounted() {
46
- this.loadArea('').then(res => {
47
- this.options = res;
48
- })
49
- },
50
-
51
42
  props: {
52
43
  value: {
53
44
  default: null,
54
45
  },
55
- disable: {
56
- type: Boolean,
57
- default: false,
58
- },
59
- size: {type: String, default: 'small'}
60
46
  },
61
47
 
62
48
  components: {
@@ -95,33 +81,6 @@ export default {
95
81
  }
96
82
  }
97
83
  },
98
- load(node) {
99
- const {value, data} = node;
100
- return new Promise((resolve) => {
101
- this.loadArea(data ? data.code : '').then(res => {
102
- resolve(res);
103
- })
104
- })
105
- },
106
-
107
- loadArea(keyword) {
108
- return new Promise((resolve) => {
109
- this.loading = true;
110
- GetAreaTree({
111
- keyword: keyword
112
- }).then(res => {
113
- if (Array.isArray(res)) {
114
- res.forEach(item => {
115
- item[`children`] = item.level !== 4;
116
- })
117
- this.loading = false;
118
- resolve(res);
119
- } else {
120
- resolve([]);
121
- }
122
- })
123
- })
124
- },
125
84
  onChange() {
126
85
  this.inputProps.value = '';
127
86
  this.$nextTick(() => {
@@ -0,0 +1,157 @@
1
+ <template>
2
+ <div class="base-area-select-wrap">
3
+ <t-cascader
4
+ ref="cascader"
5
+ :keys="{
6
+ value:'code',
7
+ label:'name',
8
+ children: 'children',
9
+ }"
10
+ :load="load"
11
+ :options="options"
12
+ :disabled="disable||loading"
13
+ :size="componentSize" @change="onChange"
14
+ :placeholder="placeholder"
15
+ :input-props="inputProps"
16
+ v-model="localValue">
17
+ </t-cascader>
18
+ </div>
19
+ </template>
20
+
21
+
22
+ <script>
23
+ export default {
24
+ name: 'baseArea'
25
+ }
26
+ </script>
27
+
28
+ <script setup>
29
+ import areaConfig from "./areaConfig";
30
+ import {TransomComponentSize} from "../../../utils/utils";
31
+ import useHookByBaseArea from "../../hooks/useHookByBaseArea";
32
+ import {computed, onMounted, reactive, ref, toRaw, watch, nextTick, getCurrentInstance} from "vue";
33
+
34
+
35
+ const cascader = ref();
36
+ console.log(cascader.value)
37
+
38
+ getCurrentInstance().proxy.$mount(() => {
39
+ loadArea('').then(res => {
40
+ console.log('v2');
41
+ options.value = res;
42
+ })
43
+ })
44
+
45
+
46
+ const localValue = ref([]);
47
+ const localDetailValue = reactive({});
48
+ const inputProps = reactive({
49
+ value: '',
50
+ },)
51
+
52
+
53
+ const emits = defineEmits(['input', 'confirmAreaValue'])
54
+ const {options, loading, placeholder, load, loadArea} = useHookByBaseArea();
55
+
56
+ const props = defineProps({
57
+ value: {
58
+ default: null,
59
+ },
60
+ disable: {
61
+ type: Boolean,
62
+ default: false,
63
+ },
64
+ size: {type: String, default: 'small'}
65
+ })
66
+
67
+
68
+ const module = computed({
69
+ set(val) {
70
+ emits('input', val)
71
+ },
72
+ get() {
73
+ return props.value;
74
+ },
75
+ })
76
+
77
+
78
+ const componentSize = computed(() => {
79
+ return TransomComponentSize(props.size);
80
+ })
81
+
82
+
83
+ const init = () => {
84
+ if (module.value) {
85
+ const {province, city, district, town} = module.value;
86
+ inputProps.value = `${province}/${city}/${district}`
87
+ if (town) {
88
+ inputProps.value += `/${town}`
89
+ localValue.value = [province, city, district, town]
90
+ } else {
91
+ localValue.value = [province, city, district]
92
+ }
93
+ Object.assign(localDetailValue, {
94
+ province,
95
+ city,
96
+ district,
97
+ town
98
+ })
99
+ }
100
+ }
101
+
102
+
103
+ const onChange = () => {
104
+ inputProps.value = '';
105
+ nextTick(() => {
106
+ const list = cascader.value.panels;
107
+ list.forEach(itemList => {
108
+ onAreaChange(itemList)
109
+ })
110
+ const _value = {
111
+ ...toRaw(localDetailValue),
112
+ }
113
+ emits('confirmAreaValue', _value)
114
+ module.value = _value;
115
+ })
116
+ }
117
+
118
+ const onAreaChange = (list) => {
119
+ try {
120
+ let index = null;
121
+ for (let i = 0; i < list.length; i++) {
122
+ const item = list[i];
123
+ if (item.indeterminate || item.checked) {
124
+ index = i;
125
+ }
126
+ }
127
+ const value = list[index];
128
+ const {data} = value;
129
+ const {name, code, level} = data;
130
+ if (!level) return;
131
+ if (!localDetailValue[`idList`]) {
132
+ localDetailValue[`idList`] = [0, 0, 0, 0];
133
+ }
134
+ localDetailValue[`${areaConfig[level - 1].value}`] = name;
135
+ localDetailValue[`idList`][level - 1] = code;
136
+ } catch (error) {
137
+ }
138
+ };
139
+
140
+
141
+ watch(() => module, () => {
142
+ nextTick(() => {
143
+ init();
144
+ })
145
+ }, {deep: true,})
146
+
147
+
148
+ </script>
149
+
150
+ <style scoped lang="less">
151
+ .base-area-select-wrap {
152
+ width: 100%;
153
+ height: auto;
154
+ overflow: hidden;
155
+ border-radius: calc(var(--radius) * 2);
156
+ }
157
+ </style>
@@ -0,0 +1,71 @@
1
+ <template>
2
+ <div class="base_area_by_multiple-wrap">
3
+ <t-cascader
4
+ ref="cascader"
5
+ v-model="value"
6
+ :options="options"
7
+ @change="onChange"
8
+ :load="load"
9
+ :keys="{
10
+ value:'value',
11
+ label:'name',
12
+ children: 'children',
13
+ }"
14
+ :disabled="disable||loading"
15
+ :placeholder="placeholder"
16
+ value-mode="all"
17
+ value-type="full"
18
+ multiple
19
+ clearable/>
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ /**
25
+ * 该组件不支持回显
26
+ */
27
+ import {defineComponent} from 'vue'
28
+ import {mixinsByBaseArea} from "../../mixins/mixinsByBaseArea";
29
+ import areaConfig from "../baseArea/areaConfig";
30
+
31
+ export default defineComponent({
32
+ name: "baseAreaByMultiple",
33
+ data() {
34
+ return {
35
+ options: [],
36
+ value: []
37
+ }
38
+ },
39
+ mixins: [mixinsByBaseArea],
40
+ methods: {
41
+ onChange() {
42
+ },
43
+ getCheckValue() {
44
+ const valueList = this.value;
45
+ const value = [];
46
+ for (let i = 0; i < valueList.length; i++) {
47
+ const itemLength = valueList[i];
48
+ const obj = {
49
+ idList: [],
50
+ };
51
+ for (let j = 0; j < itemLength.length; j++) {
52
+ const item = itemLength[j];
53
+ const splitList = item.split('-');
54
+ obj.idList.push(splitList[0]);
55
+ obj[`${areaConfig[j].value}`] = splitList[1];
56
+ }
57
+ value.push(obj);
58
+ }
59
+ return value;
60
+ }
61
+ }
62
+ })
63
+ </script>
64
+
65
+
66
+ <style scoped lang="less">
67
+ .base_area_by_multiple-wrap {
68
+ width: 100%;
69
+ height: auto;
70
+ }
71
+ </style>
@@ -0,0 +1,7 @@
1
+ import baseAreaByMultiple from "./baseAreaByMultiple.vue"
2
+
3
+ baseAreaByMultiple.install = function (Vue) {
4
+ Vue.component(baseAreaByMultiple.name, baseAreaByMultiple);
5
+ };
6
+
7
+ export default baseAreaByMultiple;
@@ -9,9 +9,11 @@
9
9
  :max-height="maxHeight"
10
10
  :columns="renderColumns"
11
11
  :tree="tree"
12
+ :sort="sortInfo"
12
13
  :default-selected-row-keys="preCheckValue"
13
14
  :selected-row-keys="preCheckValue"
14
15
  :rowspan-and-colspan='rowspanAndColspan'
16
+ @sort-change="sortChange"
15
17
  @select-change="onHandleSelectChange"
16
18
  >
17
19
  <template slot="empty">
@@ -64,7 +66,13 @@ export default {
64
66
  return {
65
67
  id: null,
66
68
  checkValue: null,
67
- tableColumns: []
69
+ tableColumns: [],
70
+ sortInfo: {
71
+ // 按照 status 字段进行排序
72
+ sortBy: '',
73
+ // 是否按照降序进行排序
74
+ descending: false,
75
+ },
68
76
  }
69
77
  },
70
78
  mixins: [tableSectionMixins],
@@ -155,6 +163,10 @@ export default {
155
163
  showSummary: {
156
164
  type: Boolean,
157
165
  default: false
166
+ },
167
+ sort: {
168
+ type: Boolean,
169
+ default: false
158
170
  }
159
171
 
160
172
  },
@@ -181,6 +193,7 @@ export default {
181
193
  return this.tableColumns.map((item, index) => {
182
194
  item['key'] = item.value;
183
195
  item['colkey'] = item.key;
196
+ item[`sorter`] = this.$props.sort
184
197
  TransomTableConfig(item, index)
185
198
  if (this.$props.showSummary) {
186
199
  if (index === 0) {
@@ -210,6 +223,10 @@ export default {
210
223
 
211
224
  },
212
225
  methods: {
226
+ sortChange(sortInfo) {
227
+ this.sortInfo = sortInfo;
228
+ this.$emit('sortChange',sortInfo);
229
+ },
213
230
  // 返回普通格式的样式
214
231
  nomalStyle(item) {
215
232
  return [
@@ -15,7 +15,7 @@
15
15
  size="large"
16
16
  :checked="selectLineItem?selectLineItem === cItem.key:cItem.key === module "
17
17
  @click="selectLineItem = cItem.key;timeModule=null"
18
- >{{ cItem.text }}
18
+ >{{ cItem.text }}
19
19
  </t-check-tag>
20
20
 
21
21
  </div>
@@ -26,8 +26,9 @@
26
26
  <div class="time-type-custom-content">
27
27
  <t-date-range-picker
28
28
  v-model="timeModule"
29
- size="small"
29
+ size="medium"
30
30
  enable-time-picker=""
31
+ :clearable="true"
31
32
  style="width: 100%; margin-top: var(--margin-4)"
32
33
  valueType="time-stamp"
33
34
  @change="onTimeChange"
@@ -81,7 +82,7 @@ export default {
81
82
  // 是否打开了选择器
82
83
  isOpen: false,
83
84
  // 内部是否选择了自定义时间
84
- timeModule: null,
85
+ timeModule: [],
85
86
  // 内部是否选择了某一个单项
86
87
  selectLineItem: null,
87
88
  // 按钮的配置
@@ -96,6 +97,7 @@ export default {
96
97
  this.handleConfig = [
97
98
  {
98
99
  text: "确定",
100
+ size: 'small',
99
101
  type: "primary",
100
102
  plain: false,
101
103
  click: () => {
@@ -175,14 +177,11 @@ export default {
175
177
  },
176
178
  eventShow() {
177
179
  this.isOpen = true;
178
-
179
180
  const {renderTime} = this.$props;
180
- if (renderTime && !this.selectLineItem) {
181
- this.timeModule = JSON.parse(JSON.stringify(renderTime));
182
- } else {
183
- this.timeModule = null;
181
+ console.log(this.$props);
182
+ if (renderTime && Array.isArray(renderTime) && !this.selectLineItem) {
183
+ this.timeModule = renderTime;
184
184
  }
185
-
186
185
  },
187
186
 
188
187
  doClose() {
@@ -193,8 +192,8 @@ export default {
193
192
  this.isOpen = false;
194
193
  },
195
194
 
196
- visibleChange() {
197
- if (this.isOpen) {
195
+ visibleChange(visible) {
196
+ if (visible) {
198
197
  this.eventShow()
199
198
  } else {
200
199
  this.eventHide();
@@ -207,7 +206,7 @@ export default {
207
206
  let _timeModule = this.timeModule;
208
207
  let _selectLineItem = this.selectLineItem;
209
208
 
210
- if ((typeof _timeModule === 'object' && _timeModule?.length >= 1)) {
209
+ if ((Array.isArray(_timeModule) && _timeModule?.length >= 1)) {
211
210
  this.module = _timeModule;
212
211
  }
213
212
  if (_selectLineItem) {
@@ -215,22 +214,20 @@ export default {
215
214
  }
216
215
  this.$nextTick(() => {
217
216
  this.$emit("selectConfirm", this.module);
218
- // this.$refs.popover.doClose();
217
+ this.isOpen = false;
219
218
  })
220
219
  },
221
220
  onTimeChange() {
222
221
  this.$nextTick(() => {
223
222
  this.selectLineItem = null;
224
223
  let time = null;
225
-
226
-
227
- if (this.timeModule && this.timeModule instanceof Array && this.timeModule.length >= 1) {
224
+ if (this.timeModule && Array.isArray(this.timeModule) && this.timeModule.length >= 1) {
228
225
  time = [this.timeModule[0], (this.timeModule[1] + 1000 * 60 * 60 * 24) - 1]
229
226
  } else {
230
- time = this.module;
227
+ time = null;
228
+ this.module = null;
231
229
  }
232
230
 
233
-
234
231
  this.$emit('onTimeChange', time);
235
232
  })
236
233
  }