@bsgoal/common 2.0.0 → 2.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsgoal/common",
3
- "version": "2.0.0",
3
+ "version": "2.3.0",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -0,0 +1,58 @@
1
+ <!--
2
+ * @Author: canlong.shen
3
+ * @Date: 2023-05-24 11:10:09
4
+ * @LastEditors: canlong.shen
5
+ * @LastEditTime: 2023-05-24 14:07:27
6
+ * @FilePath: \common\src\components\bsgoal-base-select\demo.vue
7
+ * @Description: select 演示
8
+ *
9
+ -->
10
+
11
+ <script setup>
12
+ /* setup模板
13
+ ---------------------------------------------------------------- */
14
+ import { ref } from 'vue'
15
+ import BsgoalBaseSelect from './index.vue'
16
+
17
+ const props = defineProps({})
18
+
19
+ const selectValue = ref('11')
20
+ const selectRange = ref([
21
+ {
22
+ label : '11' ,
23
+ value : '11'
24
+ },
25
+ {
26
+ label : '22' ,
27
+ value : '22'
28
+ },
29
+ {
30
+ label : '33' ,
31
+ value : '33'
32
+ },
33
+ ])
34
+
35
+
36
+
37
+ </script>
38
+ <script>
39
+ export default {
40
+ name: 'BsgoalBaseSelectDemo'
41
+ }
42
+ </script>
43
+ <template>
44
+ <div class="bsgoal-base-select-demo">
45
+ <div class="base_select_demo">
46
+ {{ selectValue }}
47
+ <BsgoalBaseSelect v-model="selectValue" :range="selectRange" />
48
+ </div>
49
+ </div>
50
+ </template>
51
+ <style lang="scss" scoped>
52
+ /* 自定义样式
53
+ ---------------------------------------------------------------- */
54
+ </style>
55
+ <style lang="scss">
56
+ /* 覆盖样式
57
+ ---------------------------------------------------------------- */
58
+ </style>
@@ -0,0 +1,90 @@
1
+ <!--
2
+ * @Author: canlong.shen
3
+ * @Date: 2023-05-24 11:09:59
4
+ * @LastEditors: canlong.shen
5
+ * @LastEditTime: 2023-05-24 14:07:10
6
+ * @FilePath: \common\src\components\bsgoal-base-select\index.vue
7
+ * @Description: Select 公共组件
8
+ *
9
+ -->
10
+
11
+ <script setup>
12
+ /* setup模板
13
+ ---------------------------------------------------------------- */
14
+ import { ref } from 'vue'
15
+ const props = defineProps({
16
+ /**
17
+ * 占位提示符
18
+ */
19
+ placeholder: {
20
+ type: [String],
21
+ default: '请选择'
22
+ },
23
+ /**
24
+ * 可选范围 { label : '' , value : ''}
25
+ */
26
+ range: {
27
+ type: [Array],
28
+ default: () => []
29
+ },
30
+ /**
31
+ * value
32
+ */
33
+ modelValue: {
34
+ type: [],
35
+ default: ''
36
+ },
37
+ /**
38
+ * 无数据提示
39
+ */
40
+ none: {
41
+ type: [String],
42
+ default: '暂无数据'
43
+ }
44
+ })
45
+
46
+ const emits = defineEmits(['update:modelValue'])
47
+
48
+ // ---> S 触发 方法 <---
49
+
50
+ /**
51
+ * @Author: canlong.shen
52
+ * @description: 触发 change
53
+ * @default:
54
+ * @return {*}
55
+ */
56
+ const triggerChange = (value = '') => {
57
+ emits('update:modelValue', value)
58
+ }
59
+
60
+ // ---> E 触发 方法 <---
61
+ </script>
62
+ <script>
63
+ export default {
64
+ name: 'BsgoalBaseSelect'
65
+ }
66
+ </script>
67
+ <template>
68
+ <div class="bsgoal-base-select">
69
+ <el-select
70
+ clearable
71
+ class="base_select"
72
+ :model-value="modelValue"
73
+ :no-data-text="none"
74
+ :placeholder="placeholder"
75
+ @change="triggerChange"
76
+ >
77
+ <template v-for="({ label = '', value = '' }, key) of range" :key="key">
78
+ <el-option :label="label" :value="value"></el-option>
79
+ </template>
80
+ </el-select>
81
+ </div>
82
+ </template>
83
+ <style lang="scss" scoped>
84
+ /* 自定义样式
85
+ ---------------------------------------------------------------- */
86
+ </style>
87
+ <style lang="scss">
88
+ /* 覆盖样式
89
+ ---------------------------------------------------------------- */
90
+ </style>
@@ -0,0 +1,38 @@
1
+ <!--
2
+ * @Author: canlong.shen
3
+ * @Date: 2023-05-24 14:58:50
4
+ * @LastEditors: canlong.shen
5
+ * @LastEditTime: 2023-05-24 15:37:12
6
+ * @FilePath: \common\src\components\bsgoal-base-time\demo.vue
7
+ * @Description: 时间选择器
8
+ *
9
+ -->
10
+ <script setup>
11
+ /* setup模板
12
+ ---------------------------------------------------------------- */
13
+ import { ref } from 'vue'
14
+ import BsgoalBaseTime from './index.vue'
15
+ const props = defineProps({})
16
+ const time = ref('11:22')
17
+ </script>
18
+ <script>
19
+ export default {
20
+ name: 'BsgoalBaseTimeDemo'
21
+ }
22
+ </script>
23
+ <template>
24
+ <div class="bsgoal-base-time-demo">
25
+ <div class="base_time_demo">
26
+ {{ time }}
27
+ <BsgoalBaseTime v-model="time" />
28
+ </div>
29
+ </div>
30
+ </template>
31
+ <style lang="scss" scoped>
32
+ /* 自定义样式
33
+ ---------------------------------------------------------------- */
34
+ </style>
35
+ <style lang="scss">
36
+ /* 覆盖样式
37
+ ---------------------------------------------------------------- */
38
+ </style>
@@ -0,0 +1,114 @@
1
+ <!--
2
+ * @Author: canlong.shen
3
+ * @Date: 2023-05-24 14:58:44
4
+ * @LastEditors: canlong.shen
5
+ * @LastEditTime: 2023-05-24 16:36:56
6
+ * @FilePath: \common\src\components\bsgoal-base-time\index.vue
7
+ * @Description: 时间选择器
8
+ *
9
+ -->
10
+
11
+ <script setup>
12
+ /* setup模板
13
+ ---------------------------------------------------------------- */
14
+ import { ref, unref, watchEffect } from 'vue'
15
+ import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
16
+ import { dayjs } from 'element-plus'
17
+ const emits = defineEmits(['update:modelValue'])
18
+ const props = defineProps({
19
+ /**
20
+ * 绑定的值
21
+ */
22
+ modelValue: {
23
+ type: [String],
24
+ default: ''
25
+ },
26
+ /**
27
+ * 提示占位符
28
+ */
29
+ placeholder: {
30
+ type: [String],
31
+ default: '请选择'
32
+ },
33
+ /**
34
+ * 格式 HH:mm:ss
35
+ */
36
+ format: {
37
+ type: [String],
38
+ default: 'HH:mm'
39
+ }
40
+ })
41
+
42
+ // ---> S 绑定值 <---
43
+
44
+ const bindValue = ref()
45
+
46
+ /**
47
+ * @Author: canlong.shen
48
+ * @description: 转换 字符串 time 为 Date
49
+ * @default:
50
+ * @return {*}
51
+ */
52
+ const stringToDate = (timeString = '') => {
53
+ return dayjs(`0000-00-00 ${timeString}`)
54
+ }
55
+
56
+ /**
57
+ * @Author: canlong.shen
58
+ * @description: 格式化 Date 为 time 字符串
59
+ * @default:
60
+ * @return {*}
61
+ */
62
+ const dateToString = (date = new Date()) => {
63
+ return dayjs(date).format(props.format)
64
+ }
65
+
66
+ watchEffect(() => {
67
+ const { modelValue } = props
68
+ const timeValue = unref(modelValue)
69
+ if (timeValue) {
70
+ bindValue.value = stringToDate(timeValue)
71
+ }
72
+ })
73
+
74
+ /**
75
+ * @Author: canlong.shen
76
+ * @description: 触发 值变化
77
+ * @default:
78
+ * @return {*}
79
+ */
80
+ const triggerChange = (date = new Date()) => {
81
+ const formatValue = dateToString(date)
82
+ emits('update:modelValue', formatValue)
83
+ }
84
+
85
+ // ---> E 绑定值 <---
86
+ </script>
87
+
88
+ <script>
89
+ export default {
90
+ name: 'BsgoalBaseTime'
91
+ }
92
+ </script>
93
+ <template>
94
+ <div class="bsgoal-base-time">
95
+ <el-config-provider :locale="zhCn">
96
+ <el-time-picker
97
+ v-model="bindValue"
98
+ class="base_time"
99
+ :format="format"
100
+ :clearable="false"
101
+ :placeholder="placeholder"
102
+ @change="triggerChange"
103
+ />
104
+ </el-config-provider>
105
+ </div>
106
+ </template>
107
+ <style lang="scss" scoped>
108
+ /* 自定义样式
109
+ ---------------------------------------------------------------- */
110
+ </style>
111
+ <style lang="scss">
112
+ /* 覆盖样式
113
+ ---------------------------------------------------------------- */
114
+ </style>
@@ -0,0 +1,48 @@
1
+ <!--
2
+ * @Author: canlong.shen
3
+ * @Date: 2023-05-24 14:10:03
4
+ * @LastEditors: canlong.shen
5
+ * @LastEditTime: 2023-05-24 16:40:42
6
+ * @FilePath: \common\src\components\bsgoal-base-time-range\demo.vue
7
+ * @Description: 时间选择 演示
8
+ *
9
+ -->
10
+
11
+ <script setup>
12
+ /* setup模板
13
+ ---------------------------------------------------------------- */
14
+ import { ref } from 'vue'
15
+ import BsgoalBaseTimeRange from './index.vue'
16
+ const props = defineProps({})
17
+
18
+ const timeRange = ref(['11:00', '12:12'])
19
+
20
+ const startTime = ref('12:11')
21
+ const endTime = ref('13:55')
22
+ </script>
23
+ <script>
24
+ export default {
25
+ name: 'BsgoalBaseTimeDemoRange'
26
+ }
27
+ </script>
28
+ <template>
29
+ <div class="bsgoal-base-time-range-demo">
30
+ <div>{{ timeRange }}</div>
31
+ <div>{{ startTime }}</div>
32
+ <div>{{ endTime }}</div>
33
+ <BsgoalBaseTimeRange
34
+ v-model:startTime="startTime"
35
+ v-model:endTime="endTime"
36
+ v-model="timeRange"
37
+ class="base_time_range_demo"
38
+ />
39
+ </div>
40
+ </template>
41
+ <style lang="scss" scoped>
42
+ /* 自定义样式
43
+ ---------------------------------------------------------------- */
44
+ </style>
45
+ <style lang="scss">
46
+ /* 覆盖样式
47
+ ---------------------------------------------------------------- */
48
+ </style>
@@ -0,0 +1,142 @@
1
+ <!--
2
+ * @Author: canlong.shen
3
+ * @Date: 2023-05-24 14:09:57
4
+ * @LastEditors: canlong.shen
5
+ * @LastEditTime: 2023-05-24 16:54:26
6
+ * @FilePath: \common\src\components\bsgoal-base-time-range\index.vue
7
+ * @Description: 时间选择 公共组件
8
+ *
9
+ -->
10
+
11
+ <script setup>
12
+ /* setup模板
13
+ ---------------------------------------------------------------- */
14
+ import { ref, unref, watch, watchEffect } from 'vue'
15
+ import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
16
+ import { dayjs } from 'element-plus'
17
+ const props = defineProps({
18
+ /**
19
+ * value
20
+ */
21
+ modelValue: {
22
+ type: [Array],
23
+ default: () => [new Date(), new Date()]
24
+ },
25
+
26
+ /**
27
+ * 开始时间 绑定的值
28
+ */
29
+ startTime: {
30
+ type: [String],
31
+ default: ''
32
+ },
33
+ /**
34
+ * 结束时间 绑定的值
35
+ */
36
+ endTime: {
37
+ type: [String],
38
+ default: ''
39
+ },
40
+ /**
41
+ * 格式 HH:mm:ss
42
+ */
43
+ format: {
44
+ type: [String],
45
+ default: 'HH:mm'
46
+ }
47
+ })
48
+
49
+ const emits = defineEmits(['update:modelValue', 'update:startTime', 'update:endTime'])
50
+ // ---> S 值绑定 <---
51
+ const bindValue = ref([])
52
+
53
+ /**
54
+ * @Author: canlong.shen
55
+ * @description: 转换 字符串 time 为 Date
56
+ * @default:
57
+ * @return {*}
58
+ */
59
+ const stringToDate = (timeString = '') => {
60
+ return dayjs(`0000-00-00 ${timeString}`)
61
+ }
62
+
63
+ /**
64
+ * @Author: canlong.shen
65
+ * @description: 格式化 Date 为 time 字符串
66
+ * @default:
67
+ * @return {*}
68
+ */
69
+ const dateToString = (date = new Date()) => {
70
+ return dayjs(date).format(props.format)
71
+ }
72
+
73
+ watchEffect(() => {
74
+ const { startTime = '', endTime = '', modelValue = [] } = props
75
+ let startDate = new Date()
76
+ let endDate = new Date()
77
+ const startTimeValue = unref(startTime)
78
+ const endTimeValue = unref(endTime)
79
+ const modelValueList = unref(modelValue)
80
+ if (startTimeValue && endTimeValue) {
81
+ startDate = stringToDate(startTimeValue)
82
+ endDate = stringToDate(endTimeValue)
83
+ } else if (Array.isArray(modelValueList) && modelValueList.length === 2) {
84
+ const { 0: startValue = '', 1: endValue = '' } = modelValueList
85
+ startDate = stringToDate(startValue)
86
+ endDate = stringToDate(endValue)
87
+ }
88
+
89
+ bindValue.value = [startDate, endDate]
90
+ })
91
+
92
+ /**
93
+ * @Author: canlong.shen
94
+ * @description: 触发 值变化
95
+ * @default:
96
+ * @return {*}
97
+ */
98
+ const triggerChange = (range = []) => {
99
+ const { startTime = '', endTime = '' } = props
100
+
101
+ const { 0: startDate, 1: endDate } = range
102
+ const startDateFormat = dateToString(startDate)
103
+ const endDateFormat = dateToString(endDate)
104
+ if (unref(startTime) && unref(endTime)) {
105
+ emits('update:startTime', startDateFormat)
106
+ emits('update:endTime', endDateFormat)
107
+ } else {
108
+ emits('update:modelValue', [startDateFormat, endDateFormat])
109
+ }
110
+ }
111
+
112
+ // ---> E 值绑定 <---
113
+ </script>
114
+ <script>
115
+ export default {
116
+ name: 'BsgoalBaseTimeRange'
117
+ }
118
+ </script>
119
+ <template>
120
+ <div class="bsgoal-base-time-range">
121
+ <el-config-provider :locale="zhCn">
122
+ <el-time-picker
123
+ v-model="bindValue"
124
+ is-range
125
+ class="base_time_range"
126
+ :format="format"
127
+ range-separator="至"
128
+ start-placeholder="开始时间"
129
+ end-placeholder="结束时间"
130
+ @change="triggerChange"
131
+ />
132
+ </el-config-provider>
133
+ </div>
134
+ </template>
135
+ <style lang="scss" scoped>
136
+ /* 自定义样式
137
+ ---------------------------------------------------------------- */
138
+ </style>
139
+ <style lang="scss">
140
+ /* 覆盖样式
141
+ ---------------------------------------------------------------- */
142
+ </style>
package/src/entry.js CHANGED
@@ -9,6 +9,9 @@ import BsgoalBaseLink from '@/components/bsgoal-base-link/index.vue'
9
9
  import BsgoalBaseButton from '@/components/bsgoal-base-button/index.vue'
10
10
  import BsgoalBaseLayout from '@/components/bsgoal-base-layout/index.vue'
11
11
  import BsgoalBaseAlert from '@/components/bsgoal-base-alert/index.vue'
12
+ import BsgoalBaseSelect from '@/components/bsgoal-base-select/index.vue'
13
+ import BsgoalBaseTime from '@/components/bsgoal-base-time/index.vue'
14
+ import BsgoalBaseTimeRange from '@/components/bsgoal-base-time-range/index.vue'
12
15
  import componentTypeEnums from '@/enums/componentTypeEnums.js'
13
16
  import { useFetch } from '@/combines/useFetchs.js'
14
17
 
@@ -31,7 +34,10 @@ export default {
31
34
  BsgoalBaseLink,
32
35
  BsgoalBaseButton,
33
36
  BsgoalBaseLayout,
34
- BsgoalBaseAlert
37
+ BsgoalBaseAlert,
38
+ BsgoalBaseSelect,
39
+ BsgoalBaseTime,
40
+ BsgoalBaseTimeRange,
35
41
  }
36
42
 
37
43
  for (const [name, component] of Object.entries(componentsMap)) {
@@ -2,7 +2,7 @@
2
2
  * @Author: canlong.shen
3
3
  * @Date: 2023-04-10 10:41:52
4
4
  * @LastEditors: canlong.shen
5
- * @LastEditTime: 2023-05-24 09:56:01
5
+ * @LastEditTime: 2023-05-24 15:06:30
6
6
  * @FilePath: \common\src\router\index.js
7
7
  * @Description: 路由配置
8
8
  *
@@ -98,6 +98,21 @@ const router = createRouter({
98
98
  name: 'alert提示',
99
99
  component: import('@/components/bsgoal-base-alert/demo.vue')
100
100
  },
101
+ {
102
+ path: 'bsgoal-base-select-demo',
103
+ name: '下拉选择器',
104
+ component: import('@/components/bsgoal-base-select/demo.vue')
105
+ },
106
+ {
107
+ path: 'bsgoal-base-time-range-demo',
108
+ name: '时间范围选择器',
109
+ component: import('@/components/bsgoal-base-time-range/demo.vue')
110
+ },
111
+ {
112
+ path: 'bsgoal-base-time-demo',
113
+ name: '时间选择器',
114
+ component: import('@/components/bsgoal-base-time/demo.vue')
115
+ },
101
116
  ]
102
117
  }
103
118
  ]