qtsk-vue3 0.0.10 → 0.0.11

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.
@@ -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" />
@@ -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
 
@@ -35,14 +35,14 @@ defineProps({
35
35
  default: 'value'
36
36
  }
37
37
  })
38
- const selectValue = defineModel('modelValue', { default: '', type: [Number, String] })
38
+ const selectValue = defineModel('modelValue', { default: '', type: [Number, String, Array] })
39
39
  </script>
40
40
 
41
41
  <style lang="less" scoped>
42
42
  :deep(.el-select__wrapper.is-focused){
43
- box-shadow: 0 0 0 1px var(--qt-main-color) inset;
43
+ box-shadow: 0 0 0 1px var(--main-color) inset;
44
44
  }
45
45
  :deep(.el-select-dropdown__item.is-selected){
46
- color: var(--qt-main-color);
46
+ color: var(--main-color);
47
47
  }
48
48
  </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,25 +1,25 @@
1
1
  {
2
- "name": "qtsk-vue3",
3
- "version": "0.0.10",
4
- "description": "vue3版组件库",
5
- "main": "./package/index.js",
6
- "scripts": {
7
- "patch": "node publish/build.js patch",
8
- "minor": "node publish/build.js minor",
9
- "major": "node publish/build.js major"
10
- },
11
- "keywords": [
12
- "qingtingzhiyun",
13
- "qtzy"
14
- ],
15
- "files": [
16
- "package"
17
- ],
18
- "author": "qingting_tech",
19
- "license": "MIT",
20
- "dependencies": {
21
- "@element-plus/icons-vue": "^2.3.1",
22
- "@vue/shared": "^3.5.6",
23
- "element-plus": "^2.8.3"
24
- }
25
- }
2
+ "name": "qtsk-vue3",
3
+ "version": "0.0.11",
4
+ "description": "vue3版组件库",
5
+ "main": "./package/index.js",
6
+ "scripts": {
7
+ "patch": "node publish/build.js patch",
8
+ "minor": "node publish/build.js minor",
9
+ "major": "node publish/build.js major"
10
+ },
11
+ "keywords": [
12
+ "qingtingzhiyun",
13
+ "qtzy"
14
+ ],
15
+ "files": [
16
+ "package"
17
+ ],
18
+ "author": "qingting_tech",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "@element-plus/icons-vue": "^2.3.1",
22
+ "@vue/shared": "^3.5.6",
23
+ "element-plus": "^2.8.3"
24
+ }
25
+ }