qtsk-vue3 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,10 @@ import Dialog from './components/Dialog/index.vue'
13
13
  import Form from './components/Form/index.vue'
14
14
  import FormItem from './components/FormItem/index.vue'
15
15
  import Empty from './components/Empty/index.vue'
16
-
16
+ import Tabs from './components/Tabs/index.vue'
17
+ import TabPane from './components/TabPane/index.vue'
18
+ import SelectRemote from './components/SelectRemote/index.vue'
19
+ import Timeline from './components/Timeline/index.vue'
17
20
  const components =
18
21
  [
19
22
  CommonButton,
@@ -30,6 +33,10 @@ const components =
30
33
  Dialog,
31
34
  Form,
32
35
  FormItem,
33
- Empty
36
+ Empty,
37
+ Tabs,
38
+ TabPane,
39
+ SelectRemote,
40
+ Timeline
34
41
  ]
35
42
  export default components
@@ -7,7 +7,7 @@
7
7
  </slot>
8
8
  </el-header>
9
9
  <el-container>
10
- <el-aside>
10
+ <el-aside v-if="$slots.menu">
11
11
  <slot name="menu">
12
12
  this is the menu
13
13
  </slot>
@@ -38,10 +38,11 @@ defineProps({
38
38
  })
39
39
 
40
40
  let modelValue = defineModel('modelValue', {type: Boolean})
41
- let emits = defineEmits(['confirm'])
41
+ let emits = defineEmits(['confirm', 'cancel'])
42
42
  // 点击取消
43
43
  const handleCancel = () => {
44
44
  modelValue.value = false
45
+ emits('cancel')
45
46
  }
46
47
  // 点击确认
47
48
  const handleConfirm = () => {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <el-empty :description="description" />
2
+ <el-empty :description="description" :image-size="70"/>
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <ElInput :type="type" :placeholder="placeholder" v-model="inputValue" v-bind="$attrs" clearable>
2
+ <ElInput :type="type" :placeholder="placeholder" v-model="inputValue" v-bind="$attrs" clearable :disabled="disabled">
3
3
  <template #prepend v-if="$slots.prepend">
4
4
  <!-- 前缀 -->
5
5
  <slot name="prepend" />
@@ -31,7 +31,8 @@ const props = defineProps({
31
31
  modelValue: {
32
32
  type: [String, Number],
33
33
  default: ''
34
- }
34
+ },
35
+ disabled: Boolean
35
36
  })
36
37
  const emits = defineEmits(['update:modelValue'])
37
38
  const inputValue = computed({
@@ -2,7 +2,7 @@
2
2
  <div class="menu">
3
3
  <el-menu class="el-menu-vertical-demo" router :collapse="isCollapse" :default-active="activeMenu"
4
4
  @open="handleOpen" @close="handleClose">
5
- <el-menu-item :index="menu.url" v-for="(menu, index) in menus" :key="index">
5
+ <el-menu-item :index="menu.url" v-for="(menu, index) in menus.filter(item => item)" :key="index">
6
6
  <Icons :type="menu.icon"></Icons>
7
7
  <template #title>
8
8
  <span>{{ menu.menuName }}</span>
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <el-select
3
+ v-model="selectValue"
4
+ :placeholder="placeholder"
5
+ v-bind="$attrs"
6
+ :teleported="false"
7
+ :loading="loading"
8
+ clearable
9
+ filterable
10
+ remote
11
+ :remote-method="remoteMethod"
12
+ :no-data-text="'暂无数据项'"
13
+ :loading-text="'加载中'"
14
+ :no-match-text="'暂无匹配数据'"
15
+ >
16
+ <el-option v-for="item in list" :key="item[valueName]" :label="item[keyName]" :value="item[valueName]">
17
+ <div v-if="item.icon" style="display: flex;align-items: center;justify-content: space-between;">
18
+ <Icons :type="item.icon"/>
19
+ <span>{{ item.icon }}</span>
20
+ </div>
21
+ </el-option>
22
+ </el-select>
23
+ </template>
24
+
25
+ <script setup>
26
+ import { ref } from 'vue'
27
+ import { ElSelect, ElOption } from 'element-plus'
28
+ import '../../style/root.css'
29
+
30
+ const loading = ref(false)
31
+
32
+ defineOptions({
33
+ name: 'SelectRemote'
34
+ })
35
+ const props = defineProps({
36
+ placeholder: {
37
+ type: String,
38
+ default: '请选择'
39
+ },
40
+ keyName: {
41
+ type: String,
42
+ default: 'label'
43
+ },
44
+ valueName: {
45
+ type: String,
46
+ default: 'value'
47
+ },
48
+ remoteMethod: {
49
+ type: Function
50
+ },
51
+ list: {
52
+ type: Array,
53
+ default: () => ([])
54
+ }
55
+ })
56
+ const selectValue = defineModel('modelValue', { default: '', type: [Number, String, Array] })
57
+ const options = ref([])
58
+ const remoteMethod = (query) => {
59
+ if (query) {
60
+ props.remoteMethod(query)
61
+ selectValue.value = query
62
+ } else {
63
+ options.value = []
64
+ }
65
+ }
66
+
67
+ </script>
68
+
69
+ <style lang="less" scoped>
70
+ :deep(.el-select__wrapper.is-focused){
71
+ box-shadow: 0 0 0 1px var(--main-color) inset;
72
+ }
73
+ :deep(.el-select-dropdown__item.is-selected){
74
+ color: var(--main-color);
75
+ }
76
+ </style>
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <el-tab-pane :label="label" :name="name">
3
+ <slot/>
4
+ </el-tab-pane>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { ElTabPane } from 'element-plus'
9
+
10
+ defineOptions({
11
+ name: 'TabPane'
12
+ })
13
+
14
+ defineProps({
15
+ label: String,
16
+ name: String
17
+ })
18
+ </script>
19
+
20
+ <style lang="less" scoped>
21
+ </style>
@@ -1,6 +1,15 @@
1
1
  <template>
2
2
  <div>
3
- <el-table :data="data" style="width: 100%" :height="height" :header-cell-style="{background:'#f2f4f7', color:'#606266',height: '60px'}" border>
3
+ <el-table
4
+ ref="tableRef"
5
+ border
6
+ :data="data"
7
+ style="width: 100%"
8
+ :height="height"
9
+ :header-cell-style="{background:'#f2f4f7', color:'#606266',height: '60px'}"
10
+ @selection-change="handleSelectionChange"
11
+ >
12
+ <el-table-column v-if="checkbox" type="selection" width="55" :selectable="selectable"/>
4
13
  <el-table-column
5
14
  v-for="(column, index) in columns"
6
15
  :label="column.label"
@@ -11,27 +20,33 @@
11
20
  >
12
21
  <template #default="scope">
13
22
  <template v-if="column.key!=='operations'">
14
- {{ scope.row[column.key] }}
23
+ <template v-if="column?.click==true">
24
+ <slot name="click" :data="scope.row" :index="scope.$index"/>
25
+ </template>
26
+ <template v-else>
27
+ {{ (column?.text && column.text(scope.row[column.key])) || scope.row[column.key] }}
28
+ </template>
15
29
  </template>
16
30
  <template v-else>
17
31
  <slot name="operations" :data="scope.row" :index="scope.$index"/>
18
32
  </template>
19
33
  </template>
20
34
  </el-table-column>
21
- <template #empty>
22
- <el-empty description="暂无数据" />
23
- </template>
24
35
  </el-table>
36
+ <Empty v-if="emptyStatus" description="暂无数据" />
25
37
  <slot v-if="data.length" name="pagination" />
26
38
  </div>
27
39
  </template>
28
40
 
29
41
  <script setup>
30
- import { ElTable, ElTableColumn, ElEmpty } from 'element-plus'
42
+ import { ref, watch } from 'vue'
43
+ import { ElTable, ElTableColumn } from 'element-plus'
44
+
31
45
  defineOptions({
32
46
  name: 'Table',
33
47
  })
34
- defineProps({
48
+ const emits = defineEmits('getSelection')
49
+ const props = defineProps({
35
50
  data: {
36
51
  type: Object,
37
52
  default: () => ([])
@@ -43,7 +58,36 @@ defineProps({
43
58
  columns: {
44
59
  type: Array,
45
60
  default: () => ([])
61
+ },
62
+ checkbox: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ selectable: {
67
+ type: Function
68
+ }
69
+ })
70
+ const tableRef = ref(null)
71
+ const emptyStatus = ref(false)
72
+ const multipleSelection = ref([])
73
+ watch(() => props.data, (nv) => {
74
+ if (!nv.length) {
75
+ emptyStatus.value = true
76
+ } else {
77
+ emptyStatus.value = false
78
+ }
79
+ })
80
+ const handleSelectionChange = (list) => {
81
+ multipleSelection.value = [];
82
+ if (list.length > 1) {
83
+ tableRef.value.clearSelection();
84
+ tableRef.value.toggleRowSelection(list[list.length - 1]);
46
85
  }
86
+ multipleSelection.value = [list[list.length - 1]];
87
+ }
88
+ defineExpose({
89
+ selection: multipleSelection,
90
+ clearSelection: () => { tableRef.value.clearSelection() }
47
91
  })
48
92
  </script>
49
93
 
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <el-tabs v-model="activeName" type="border-card" class="demo-tabs">
3
+ <slot/>
4
+ </el-tabs>
5
+ </template>
6
+
7
+ <script setup>
8
+ import { ElTabs } from 'element-plus'
9
+ import '../../style/root.css'
10
+
11
+ defineOptions({
12
+ name: 'Tabs'
13
+ })
14
+ const activeName = defineModel('activeName', {type: String})
15
+ </script>
16
+
17
+ <style lang="less" scoped>
18
+ </style>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <div class="normalClass">
3
+ <el-timeline style="max-width: 600px">
4
+ <el-timeline-item
5
+ v-for="(activity, index) in activities"
6
+ :key="index"
7
+ :timestamp="activity[timeKey]"
8
+ :color="activity.color"
9
+ >
10
+ <div class="content">{{ activity[contentKey] }}</div>
11
+ <div class="address">{{ activity[addressKey] }}</div>
12
+ </el-timeline-item>
13
+ </el-timeline>
14
+ </div>
15
+ </template>
16
+
17
+ <script setup>
18
+ import { ElTimeline, ElTimelineItem} from 'element-plus'
19
+
20
+ defineOptions({
21
+ name: 'Timeline'
22
+ })
23
+
24
+ defineProps({
25
+ activities: {
26
+ type: Array,
27
+ default: () => ([])
28
+ },
29
+ timeKey: {
30
+ type: String,
31
+ default: 'timestamp'
32
+ },
33
+ contentKey: {
34
+ type: String,
35
+ default: 'content'
36
+ },
37
+ addressKey: {
38
+ type: String,
39
+ default: 'address'
40
+ }
41
+ })
42
+ </script>
43
+
44
+ <style lang="less" scoped>
45
+ .normalClass {
46
+ margin: 0 10px;
47
+ .content {
48
+ font-size: 14px;
49
+ font-weight: bolder;
50
+ }
51
+ .address {
52
+ color: #909399;
53
+ margin-top: 5px;
54
+ }
55
+ }
56
+ :deep(.el-timeline-item__timestamp) {
57
+ font-size: 12px;
58
+ }
59
+ </style>
@@ -1,22 +1,23 @@
1
- import Components from './component'
2
- import { Message, MessageBox } from './components/Message'
3
-
4
- const makeInstaller = (components = [], directives = []) => {
5
- const apps = []
6
- const install = (app, opts) => {
7
- const option = opts
8
- if (apps.includes(app)) return
9
- apps.push(app)
10
- components.forEach((c) => {
11
- app.component(c.name, c)
12
- })
13
- app.config.globalProperties.$ELEMENT = option
14
- }
15
- return install
16
- }
17
-
18
- const install = makeInstaller(Components)
19
-
20
- export { Message, MessageBox, install, install as default }
21
-
22
- console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
1
+ import Components from './component'
2
+ import { Message, MessageBox } from './components/Message'
3
+
4
+ const makeInstaller = (components = [], directives = []) => {
5
+ const apps = []
6
+ const install = (app, opts) => {
7
+ const option = opts
8
+ if (apps.includes(app)) return
9
+ apps.push(app)
10
+ components.forEach((c) => {
11
+ app.component(c.name, c)
12
+ })
13
+ app.config.globalProperties.$ELEMENT = option
14
+ }
15
+ return install
16
+ }
17
+
18
+ const install = makeInstaller(Components)
19
+
20
+ export { Message, MessageBox, install, install as default }
21
+
22
+ console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
23
+
package/package/index.js CHANGED
@@ -1,22 +1,22 @@
1
- import Components from './component'
2
- import { Message, MessageBox } from './components/Message'
3
-
4
- const makeInstaller = (components = [], directives = []) => {
5
- const apps = []
6
- const install = (app, opts) => {
7
- const option = opts
8
- if (apps.includes(app)) return
9
- apps.push(app)
10
- components.forEach((c) => {
11
- app.component(c.name, c)
12
- })
13
- app.config.globalProperties.$ELEMENT = option
14
- }
15
- return install
16
- }
17
-
18
- const install = makeInstaller(Components)
19
-
20
- export { Message, MessageBox, install, install as default }
21
-
22
- console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
1
+ import Components from './component'
2
+ import { Message, MessageBox } from './components/Message'
3
+
4
+ const makeInstaller = (components = [], directives = []) => {
5
+ const apps = []
6
+ const install = (app, opts) => {
7
+ const option = opts
8
+ if (apps.includes(app)) return
9
+ apps.push(app)
10
+ components.forEach((c) => {
11
+ app.component(c.name, c)
12
+ })
13
+ app.config.globalProperties.$ELEMENT = option
14
+ }
15
+ return install
16
+ }
17
+
18
+ const install = makeInstaller(Components)
19
+
20
+ export { Message, MessageBox, install, install as default }
21
+
22
+ console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qtsk-vue3",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "vue3版组件库",
5
5
  "main": "./package/index.js",
6
6
  "scripts": {