qtsk-vue3 0.0.9 → 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,4 +1,4 @@
1
- import Button from './components/Button/index.vue'
1
+ import CommonButton from './components/Button/index.vue'
2
2
  import Container from './components/Container/index.vue'
3
3
  import Menu from './components/Menu/index.vue'
4
4
  import Icons from './components/Icons/index.vue'
@@ -12,10 +12,11 @@ import Tree from './components/Tree/index.vue'
12
12
  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
+ import Empty from './components/Empty/index.vue'
15
16
 
16
17
  const components =
17
18
  [
18
- Button,
19
+ CommonButton,
19
20
  Container,
20
21
  Menu,
21
22
  Icons,
@@ -28,6 +29,7 @@ const components =
28
29
  Tree,
29
30
  Dialog,
30
31
  Form,
31
- FormItem
32
+ FormItem,
33
+ Empty
32
34
  ]
33
35
  export default components
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <div :class="[type === 'default' ? 'defaultClass' : 'normalClass']">
3
- <el-button :type="type" :color="color" :link="link">
2
+ <div class="normalClass">
3
+ <el-button :type="type" :color="color" :link="link" :loading="loading">
4
4
  <slot>按钮</slot>
5
5
  </el-button>
6
6
  </div>
@@ -11,35 +11,32 @@ import { ElButton} from 'element-plus'
11
11
  import '../../style/root.css'
12
12
 
13
13
  defineOptions({
14
- name: 'Button',
14
+ name: 'CommonButton',
15
15
  })
16
- const props = defineProps({
16
+ defineProps({
17
17
  type:{
18
18
  type: String,
19
19
  default: 'default', //可选数值有, primary/default
20
20
  },
21
21
  color: {
22
22
  type: String,
23
- default: '#4d4398'
23
+ default: ''
24
24
  },
25
25
  link: {
26
26
  type: Boolean,
27
27
  default: false
28
+ },
29
+ loading: {
30
+ type: Boolean,
31
+ default: false
28
32
  }
29
33
  })
30
34
  //根据不同的类型,自定义按钮颜色
31
- const color = props.type === 'primary' ? props.color : ''
35
+ // const color = props.type === 'primary' ? props.color : ''
32
36
  </script>
33
37
 
34
38
  <style lang="less" scoped>
35
39
  .normalClass{
36
40
  margin: 0 10px;
37
41
  }
38
- .defaultClass{
39
- margin: 0 10px;
40
- :deep(.el-button){
41
- color: var(--qt-main-color)!important;
42
- border-color: var(--qt-main-color)!important;
43
- }
44
- }
45
42
  </style>
@@ -38,6 +38,7 @@ defineOptions({
38
38
  .el-header{
39
39
  display: flex;
40
40
  align-items: center;
41
+ justify-content: space-between;
41
42
  height: 60px;
42
43
  }
43
44
  .el-aside, .el-main{
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <el-config-provider :locale="zhCn">
3
- <el-date-picker 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,9 +21,14 @@ 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
- const modelValue = defineModel('modelValue', { type: Boolean })
30
+ const modelValue = defineModel('modelValue', { type: String })
27
31
  </script>
28
32
 
29
- <style lang="less" scoped></style>
33
+ <style lang="less" scoped>
34
+ </style>
@@ -38,14 +38,14 @@ defineProps({
38
38
  })
39
39
 
40
40
  let modelValue = defineModel('modelValue', {type: Boolean})
41
-
41
+ let emits = defineEmits(['confirm'])
42
42
  // 点击取消
43
43
  const handleCancel = () => {
44
44
  modelValue.value = false
45
45
  }
46
46
  // 点击确认
47
47
  const handleConfirm = () => {
48
- modelValue.value = false
48
+ emits('confirm')
49
49
  }
50
50
  </script>
51
51
 
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <el-empty :description="description" />
3
+ </template>
4
+
5
+ <script setup>
6
+ import { ElEmpty} from 'element-plus'
7
+
8
+ defineOptions({
9
+ name: 'Empty',
10
+ })
11
+ defineProps({
12
+ description:{
13
+ type: String,
14
+ default: '敬请期待',
15
+ }
16
+ })
17
+ </script>
18
+
19
+ <style lang="less" scoped>
20
+ </style>
@@ -13,6 +13,7 @@
13
13
  </template>
14
14
 
15
15
  <script setup>
16
+ import { ref } from 'vue'
16
17
  import { ElForm } from 'element-plus'
17
18
 
18
19
  defineOptions({
@@ -21,8 +22,8 @@ defineOptions({
21
22
 
22
23
  defineProps({
23
24
  rules: {
24
- type: Array,
25
- default: () => ([])
25
+ type: Object,
26
+ default: () => ({})
26
27
  },
27
28
  inline: {
28
29
  type: Boolean,
@@ -31,6 +32,17 @@ defineProps({
31
32
  })
32
33
 
33
34
  let formData = defineModel('formData', {type: Object})
35
+ let ruleFormRef = ref(null)
36
+
37
+ const resetForm = () => {
38
+ if (!ruleFormRef.value) return
39
+ ruleFormRef.value.resetFields()
40
+ }
41
+
42
+ defineExpose({
43
+ resetForm,
44
+ ruleFormRef
45
+ })
34
46
 
35
47
  </script>
36
48
 
@@ -1,5 +1,14 @@
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
+ <template #prepend v-if="$slots.prepend">
4
+ <!-- 前缀 -->
5
+ <slot name="prepend" />
6
+ </template>
7
+ <template #append v-if="$slots.append">
8
+ <!-- 后缀 -->
9
+ <slot name="append" />
10
+ </template>
11
+ </ElInput>
3
12
  </template>
4
13
 
5
14
  <script setup>
@@ -24,6 +33,6 @@ const inputValue = defineModel('modelValue', {default: '',type: [String, Number]
24
33
 
25
34
  <style lang="less" scoped>
26
35
  :deep(.el-textarea__inner:focus), :deep(.el-input__wrapper.is-focus){
27
- box-shadow: 0 0 0 1px var(--qt-main-color) inset;
36
+ box-shadow: 0 0 0 1px var(--main-color) inset;
28
37
  }
29
38
  </style>
@@ -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
 
@@ -1,5 +1,11 @@
1
1
  <template>
2
- <el-select v-model="selectValue" :placeholder="placeholder" v-bind="$attrs" :teleported="false">
2
+ <el-select
3
+ v-model="selectValue"
4
+ :placeholder="placeholder"
5
+ v-bind="$attrs"
6
+ :teleported="false"
7
+ clearable
8
+ >
3
9
  <el-option v-for="item in options" :key="item[valueName]" :label="item[keyName]" :value="item[valueName]" />
4
10
  </el-select>
5
11
  </template>
@@ -29,14 +35,14 @@ defineProps({
29
35
  default: 'value'
30
36
  }
31
37
  })
32
- const selectValue = defineModel('modelValue', { default: '', type: [Number, String] })
38
+ const selectValue = defineModel('modelValue', { default: '', type: [Number, String, Array] })
33
39
  </script>
34
40
 
35
41
  <style lang="less" scoped>
36
42
  :deep(.el-select__wrapper.is-focused){
37
- box-shadow: 0 0 0 1px var(--qt-main-color) inset;
43
+ box-shadow: 0 0 0 1px var(--main-color) inset;
38
44
  }
39
45
  :deep(.el-select-dropdown__item.is-selected){
40
- color: var(--qt-main-color);
46
+ color: var(--main-color);
41
47
  }
42
48
  </style>
@@ -1,20 +1,21 @@
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"
7
7
  :width="column.width"
8
8
  :fixed="column.fixed"
9
9
  :key="index"
10
+ :show-overflow-tooltip="column.width?true:false"
10
11
  >
11
12
  <template #default="scope">
12
- <div v-if="column.key!=='operations'">
13
+ <template v-if="column.key!=='operations'">
13
14
  {{ scope.row[column.key] }}
14
- </div>
15
- <div v-else>
15
+ </template>
16
+ <template v-else>
16
17
  <slot name="operations" :data="scope.row" :index="scope.$index"/>
17
- </div>
18
+ </template>
18
19
  </template>
19
20
  </el-table-column>
20
21
  <template #empty>
@@ -35,6 +36,10 @@ defineProps({
35
36
  type: Object,
36
37
  default: () => ([])
37
38
  },
39
+ height: {
40
+ type: Number,
41
+ default: 400
42
+ },
38
43
  columns: {
39
44
  type: Array,
40
45
  default: () => ([])
@@ -1,15 +1,27 @@
1
1
  <template>
2
2
  <el-tree
3
3
  ref="treeRef"
4
- style="max-width: 600px"
4
+ style="max-width: 600px;padding-top: 4px;"
5
5
  :data="data"
6
6
  :props="defaultProps"
7
7
  :show-checkbox="showCheckBox"
8
8
  default-expand-all
9
9
  :node-key="nodeKey"
10
10
  :expand-on-click-node="false"
11
- @node-click="handleNodeClick"
12
- />
11
+ :default-checked-keys="checkedKeys"
12
+ @node-click="handleNodeClick"
13
+ @check-change="checkChange"
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>
13
25
  </template>
14
26
 
15
27
  <script setup>
@@ -17,11 +29,13 @@ import { ref } from 'vue'
17
29
  import { ElTree } from 'element-plus'
18
30
 
19
31
  const treeRef = ref(null)
32
+ const modelValue = defineModel('modelValue', { type: Array })
33
+
20
34
  defineOptions({
21
35
  name: 'Tree',
22
36
  })
23
37
 
24
- defineProps({
38
+ const props = defineProps({
25
39
  data: {
26
40
  type: Array,
27
41
  default: () => ([])
@@ -33,26 +47,61 @@ defineProps({
33
47
  nodeKey: {
34
48
  type: String,
35
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'
36
62
  }
37
63
  })
38
64
 
65
+ const emits = defineEmits(['handleTree', 'handleNode'])
39
66
  // 点击节点
40
67
  const handleNodeClick = (data) => {
41
- console.log('tree-data', data)
68
+ console.log('data', data)
69
+ emits('handleNode', data)
42
70
  }
43
71
 
44
72
  const defaultProps = {
45
73
  children: 'children',
46
- label: 'label',
74
+ label: props.labelName
47
75
  }
48
76
 
49
77
  // 获取选中的节点
50
78
  const getCheckedKeys = () => {
51
- console.log(treeRef.value.getCheckedKeys(false))
79
+ return treeRef.value.getCheckedKeys(false)
80
+ }
81
+
82
+ //当复选框被点击的时候触发, 用于获取所有的选中数据
83
+ const checkChange = () => {
84
+ modelValue.value = treeRef.value.getCheckedKeys(false)
85
+ }
86
+
87
+ const handleOperations = (data, type) => {
88
+ emits('handleTree', data, type)
52
89
  }
53
90
  defineExpose({
54
91
  getCheckedKeys
55
92
  })
56
93
  </script>
57
94
 
58
- <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>
@@ -1,5 +1,5 @@
1
1
  import Components from './component'
2
- import { QTMessage, QTMessageBox } from './components/Message'
2
+ import { Message, MessageBox } from './components/Message'
3
3
 
4
4
  const makeInstaller = (components = [], directives = []) => {
5
5
  const apps = []
@@ -17,6 +17,6 @@ const makeInstaller = (components = [], directives = []) => {
17
17
 
18
18
  const install = makeInstaller(Components)
19
19
 
20
- export { QTMessage, QTMessageBox, install, install as default }
20
+ export { Message, MessageBox, install, install as default }
21
21
 
22
- console.info('%c====== Editing in local package ======', 'font-size:16px;color:green;')
22
+ console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
package/package/index.js CHANGED
@@ -19,7 +19,4 @@ const install = makeInstaller(Components)
19
19
 
20
20
  export { Message, MessageBox, install, install as default }
21
21
 
22
- console.info('%c====== Editing in local package ======', 'font-size:16px;color:green;')
23
-
24
-
25
- console.info('%c====== Editing in local package ======', 'font-size:16px;color:yellow;')
22
+ console.info('%c====== Editing in local package ======', 'font-size:16px;color:pink;')
@@ -1,5 +1,5 @@
1
1
  /* 标准化样式定义 */
2
2
  :root{
3
3
  --main-color: #4d4398;
4
- --main-background-color: #e0edff;
5
- }
4
+ --main-background-color: #e0edff
5
+ }
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
- "name": "qtsk-vue3",
3
- "version": "0.0.9",
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
+ }