qtsk-vue3 0.0.10 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-config-provider :locale="zhCn">
3
- <el-date-picker style="width: 100%;" v-model="modelValue" type="date" :placeholder="placeholder" :format="format" :value-format="format"/>
3
+ <el-date-picker style="width: 100%;" v-model="modelValue" :type="type" :placeholder="placeholder" :format="format" :value-format="format"/>
4
4
  </el-config-provider>
5
5
  </template>
6
6
 
@@ -21,6 +21,10 @@ const props = defineProps({
21
21
  type: String,
22
22
  default: '请选择'
23
23
  },
24
+ type: {
25
+ type: String,
26
+ default: 'date'
27
+ }
24
28
  })
25
29
 
26
30
  const modelValue = defineModel('modelValue', { type: String })
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <ElInput :type="type" :placeholder="placeholder" v-model="inputValue" v-bind="$attrs">
2
+ <ElInput :type="type" :placeholder="placeholder" v-model="inputValue" v-bind="$attrs" clearable>
3
3
  <template #prepend v-if="$slots.prepend">
4
4
  <!-- 前缀 -->
5
5
  <slot name="prepend" />
@@ -2,10 +2,10 @@
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.path" v-for="(menu, index) in menus" :key="index">
5
+ <el-menu-item :index="menu.url" v-for="(menu, index) in menus" :key="index">
6
6
  <Icons :type="menu.icon"></Icons>
7
7
  <template #title>
8
- <span>{{ menu.name }}</span>
8
+ <span>{{ menu.menuName }}</span>
9
9
  </template>
10
10
  </el-menu-item>
11
11
  </el-menu>
@@ -33,10 +33,10 @@ defineProps({
33
33
  })
34
34
  const isCollapse = ref(false)
35
35
  const handleOpen = (key, keyPath) => {
36
- console.log(key, keyPath)
36
+ // console.log(key, keyPath)
37
37
  }
38
38
  const handleClose = (key, keyPath) => {
39
- console.log(key, keyPath)
39
+ // console.log(key, keyPath)
40
40
  }
41
41
 
42
42
  </script>
@@ -3,25 +3,26 @@
3
3
  */
4
4
  import { ElMessage, ElMessageBox } from 'element-plus'
5
5
 
6
- export const Message = {
7
- error: (message) => {
8
- ElMessage.error(message)
9
- },
10
- success: (message) => {
11
- ElMessage({
12
- message,
13
- type: 'success',
14
- })
15
- },
16
- warning: (message) => {
17
- ElMessage({
18
- message,
19
- type: 'warning',
20
- })
21
- },
22
- info: (message) => {
23
- ElMessage(message)
6
+ // 重置message,防止重复点击重复弹出message弹框
7
+ let messageInstance = null;
8
+ // 判断是否已经存在信息实例
9
+ const hasMessageInstance = (type, message) => {
10
+ if (messageInstance) {
11
+ messageInstance.close();
24
12
  }
13
+ messageInstance = ElMessage[type]({
14
+ message,
15
+ type,
16
+ })
25
17
  }
26
18
 
27
- export const MessageBox = ElMessageBox
19
+ export let Message = {};
20
+
21
+ ['error', 'success', 'info', 'warning'].forEach((type) => {
22
+ Message[type] =(message) => {
23
+ hasMessageInstance(type, message)
24
+ };
25
+ })
26
+
27
+
28
+ export const MessageBox = ElMessageBox
@@ -21,13 +21,16 @@ defineProps({
21
21
  default: 0
22
22
  }
23
23
  })
24
+ const emits = defineEmits(['handleChangePage'])
24
25
  // 条目个数改变
25
26
  const handleSizeChange = (val) => {
26
27
  console.log(`${val} items per page`)
28
+ emits('handleChangePage', 'size', val)
27
29
  }
28
30
  // 当前页码改变
29
31
  const handleCurrentChange = (val) => {
30
32
  console.log(`current page: ${val}`)
33
+ emits('handleChangePage', 'current', val)
31
34
  }
32
35
  </script>
33
36
 
@@ -6,7 +6,12 @@
6
6
  :teleported="false"
7
7
  clearable
8
8
  >
9
- <el-option v-for="item in options" :key="item[valueName]" :label="item[keyName]" :value="item[valueName]" />
9
+ <el-option v-for="item in options" :key="item[valueName]" :label="item[keyName]" :value="item[valueName]">
10
+ <div v-if="item.icon" style="display: flex;align-items: center;justify-content: space-between;">
11
+ <Icons :type="item.icon"/>
12
+ <span>{{ item.icon }}</span>
13
+ </div>
14
+ </el-option>
10
15
  </el-select>
11
16
  </template>
12
17
 
@@ -35,14 +40,14 @@ defineProps({
35
40
  default: 'value'
36
41
  }
37
42
  })
38
- const selectValue = defineModel('modelValue', { default: '', type: [Number, String] })
43
+ const selectValue = defineModel('modelValue', { default: '', type: [Number, String, Array] })
39
44
  </script>
40
45
 
41
46
  <style lang="less" scoped>
42
47
  :deep(.el-select__wrapper.is-focused){
43
- box-shadow: 0 0 0 1px var(--qt-main-color) inset;
48
+ box-shadow: 0 0 0 1px var(--main-color) inset;
44
49
  }
45
50
  :deep(.el-select-dropdown__item.is-selected){
46
- color: var(--qt-main-color);
51
+ color: var(--main-color);
47
52
  }
48
53
  </style>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div>
3
- <el-table :data="data" style="width: 100%" :header-cell-style="{background:'#f2f4f7', color:'#606266',height: '60px'}" border>
3
+ <el-table :data="data" style="width: 100%" :height="height" :header-cell-style="{background:'#f2f4f7', color:'#606266',height: '60px'}" border>
4
4
  <el-table-column
5
5
  v-for="(column, index) in columns"
6
6
  :label="column.label"
@@ -36,6 +36,10 @@ defineProps({
36
36
  type: Object,
37
37
  default: () => ([])
38
38
  },
39
+ height: {
40
+ type: Number,
41
+ default: 400
42
+ },
39
43
  columns: {
40
44
  type: Array,
41
45
  default: () => ([])
@@ -8,9 +8,20 @@
8
8
  default-expand-all
9
9
  :node-key="nodeKey"
10
10
  :expand-on-click-node="false"
11
+ :default-checked-keys="checkedKeys"
11
12
  @node-click="handleNodeClick"
12
13
  @check-change="checkChange"
13
- />
14
+ >
15
+ <template #default="{ node, data }" v-if="editable">
16
+ <span class="custom-tree-node">
17
+ <span>{{ node.label }}</span>
18
+ <span>
19
+ <Icons type="Delete" style="margin-right: 10px;" @click.stop="handleOperations(data,'delete')"/>
20
+ <Icons type="Edit" @click.stop="handleOperations(data, 'edit')"/>
21
+ </span>
22
+ </span>
23
+ </template>
24
+ </el-tree>
14
25
  </template>
15
26
 
16
27
  <script setup>
@@ -24,7 +35,7 @@ defineOptions({
24
35
  name: 'Tree',
25
36
  })
26
37
 
27
- defineProps({
38
+ const props = defineProps({
28
39
  data: {
29
40
  type: Array,
30
41
  default: () => ([])
@@ -36,22 +47,36 @@ defineProps({
36
47
  nodeKey: {
37
48
  type: String,
38
49
  default: 'id'
50
+ },
51
+ editable: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ checkedKeys: {
56
+ type: Array,
57
+ default: () => ([])
58
+ },
59
+ labelName: {
60
+ type: String,
61
+ default: 'name'
39
62
  }
40
63
  })
41
64
 
65
+ const emits = defineEmits(['handleTree', 'handleNode'])
42
66
  // 点击节点
43
67
  const handleNodeClick = (data) => {
44
- console.log('tree-data', data)
68
+ console.log('data', data)
69
+ emits('handleNode', data)
45
70
  }
46
71
 
47
72
  const defaultProps = {
48
73
  children: 'children',
49
- label: 'label',
74
+ label: props.labelName
50
75
  }
51
76
 
52
77
  // 获取选中的节点
53
78
  const getCheckedKeys = () => {
54
- console.log(treeRef.value.getCheckedKeys(false))
79
+ return treeRef.value.getCheckedKeys(false)
55
80
  }
56
81
 
57
82
  //当复选框被点击的时候触发, 用于获取所有的选中数据
@@ -59,9 +84,24 @@ const checkChange = () => {
59
84
  modelValue.value = treeRef.value.getCheckedKeys(false)
60
85
  }
61
86
 
87
+ const handleOperations = (data, type) => {
88
+ emits('handleTree', data, type)
89
+ }
62
90
  defineExpose({
63
91
  getCheckedKeys
64
92
  })
65
93
  </script>
66
94
 
67
- <style lang="less" scoped></style>
95
+ <style lang="less" scoped>
96
+ .custom-tree-node {
97
+ flex: 1;
98
+ display: flex;
99
+ align-items: center;
100
+ justify-content: space-between;
101
+ font-size: 14px;
102
+ padding-right: 8px;
103
+ }
104
+ .el-tree .is-current {
105
+ background: pink;
106
+ }
107
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qtsk-vue3",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "vue3版组件库",
5
5
  "main": "./package/index.js",
6
6
  "scripts": {