@idooel/components 0.0.0 → 0.0.1

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/packages/index.js CHANGED
@@ -1,50 +1,51 @@
1
- import EleButton from './button/index.js'
2
- import EleDate from './date/index.js'
3
- import EleInput from './input/index.js'
4
- import EleSelect from './select/index.js'
5
- import EleTable from './table/index.js'
6
- import EleTree from './tree/index.js'
7
- import EleTpl from './tpl/index.js'
8
-
9
- import EleButtonGroup from './composite-components/button-group/index.js'
10
- import EleSearchArea from './composite-components/search-area/index.js'
11
-
12
- import EleTreeTableModel from './tree-table-model/index.js'
13
-
14
- const compositeComponents = [
15
- EleButtonGroup,
16
- EleSearchArea
17
- ]
18
-
19
- const models = [
20
- EleTreeTableModel
21
- ]
22
-
23
- const components = [
24
- EleButton,
25
- EleDate,
26
- EleInput,
27
- EleSelect,
28
- EleTable,
29
- EleTree,
30
- EleTpl,
31
- ...compositeComponents,
32
- ...models
33
- ]
34
-
35
- const install = (Vue) => {
36
- if (install.installed) return
37
- install.installed = true
38
- components.forEach(component => {
39
- Vue.component(component.name, component)
40
- })
41
- }
42
- export default install
43
- export {
44
- EleButton,
45
- EleDate,
46
- EleInput,
47
- EleSelect,
48
- EleTable,
49
- EleTree
1
+ import EleButton from './button/index.js'
2
+ import EleDate from './date/index.js'
3
+ import EleInput from './input/index.js'
4
+ import EleSelect from './select/index.js'
5
+ import EleTable from './table/index.js'
6
+ import EleTree from './tree/index.js'
7
+ import EleTpl from './tpl/index.js'
8
+
9
+ import EleButtonGroup from './composite-components/button-group/index.js'
10
+ import EleSearchArea from './composite-components/search-area/index.js'
11
+
12
+ import EleTreeTableModel from './tree-table-model/index.js'
13
+
14
+ const compositeComponents = [
15
+ EleButtonGroup,
16
+ EleSearchArea
17
+ ]
18
+
19
+ export const models = [
20
+ EleTreeTableModel
21
+ ]
22
+
23
+ const components = [
24
+ EleButton,
25
+ EleDate,
26
+ EleInput,
27
+ EleSelect,
28
+ EleTable,
29
+ EleTree,
30
+ EleTpl,
31
+ ...compositeComponents,
32
+ ...models
33
+ ]
34
+
35
+ const install = (Vue) => {
36
+ if (install.installed) return
37
+ install.installed = true
38
+ components.forEach(component => {
39
+ Vue.component(component.name, component)
40
+ })
41
+ }
42
+ export default install
43
+ export {
44
+ EleButton,
45
+ EleDate,
46
+ EleInput,
47
+ EleSelect,
48
+ EleTable,
49
+ EleTree,
50
+ EleTpl
50
51
  }
@@ -1,5 +1,5 @@
1
- import EleInput from './src/index.vue'
2
-
3
- EleInput.install = Vue => Vue.component(EleInput.name, EleInput)
4
-
1
+ import EleInput from './src/index.vue'
2
+
3
+ EleInput.install = Vue => Vue.component(EleInput.name, EleInput)
4
+
5
5
  export default EleInput
@@ -1,24 +1,24 @@
1
- <template>
2
- <a-input :value="value" @change="onChange"></a-input>
3
- </template>
4
-
5
- <script>
6
- export default {
7
- name: 'ele-input',
8
- props: {
9
- value: {
10
- type: String
11
- }
12
- },
13
- methods: {
14
- onChange (e) {
15
- this.$emit('change', e.target.value)
16
- this.$emit('input', e.target.value)
17
- }
18
- }
19
- }
20
- </script>
21
-
22
- <style scoped>
23
-
1
+ <template>
2
+ <a-input :value="value" @change="onChange"></a-input>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ name: 'ele-input',
8
+ props: {
9
+ value: {
10
+ type: String
11
+ }
12
+ },
13
+ methods: {
14
+ onChange (e) {
15
+ this.$emit('change', e.target.value)
16
+ this.$emit('input', e.target.value)
17
+ }
18
+ }
19
+ }
20
+ </script>
21
+
22
+ <style scoped>
23
+
24
24
  </style>
@@ -1,5 +1,5 @@
1
- import EleSelect from './src/index.vue'
2
-
3
- EleSelect.install = Vue => Vue.component(EleSelect.name, EleSelect)
4
-
1
+ import EleSelect from './src/index.vue'
2
+
3
+ EleSelect.install = Vue => Vue.component(EleSelect.name, EleSelect)
4
+
5
5
  export default EleSelect
@@ -1,35 +1,35 @@
1
- <template>
2
- <a-select :value="value" style="width: 100%" @change="onChange">
3
- <a-select-option v-for="item in dataSource" :key="item.value" :value="item.value">
4
- {{ item.label }}
5
- </a-select-option>
6
- </a-select>
7
- </template>
8
-
9
- <script>
10
- export default {
11
- name: 'ele-select',
12
- props: {
13
- value: {
14
- type: [String, Array, Number]
15
- },
16
- defaultValue: {
17
- type: [String, Array, Number]
18
- },
19
- dataSource: {
20
- type: Array,
21
- default: () => []
22
- }
23
- },
24
- methods: {
25
- onChange (value) {
26
- this.$emit('change', value)
27
- this.$emit('input', value)
28
- }
29
- }
30
- }
31
- </script>
32
-
33
- <style lang="scss" scoped>
34
-
1
+ <template>
2
+ <a-select :value="value" style="width: 100%" @change="onChange">
3
+ <a-select-option v-for="item in dataSource" :key="item.value" :value="item.value">
4
+ {{ item.label }}
5
+ </a-select-option>
6
+ </a-select>
7
+ </template>
8
+
9
+ <script>
10
+ export default {
11
+ name: 'ele-select',
12
+ props: {
13
+ value: {
14
+ type: [String, Array, Number]
15
+ },
16
+ defaultValue: {
17
+ type: [String, Array, Number]
18
+ },
19
+ dataSource: {
20
+ type: Array,
21
+ default: () => []
22
+ }
23
+ },
24
+ methods: {
25
+ onChange (value) {
26
+ this.$emit('change', value)
27
+ this.$emit('input', value)
28
+ }
29
+ }
30
+ }
31
+ </script>
32
+
33
+ <style lang="scss" scoped>
34
+
35
35
  </style>
@@ -1,5 +1,5 @@
1
- import EleTable from './src/index.vue'
2
-
3
- EleTable.install = Vue => Vue.component(EleTable.name, EleTable)
4
-
1
+ import EleTable from './src/index.vue'
2
+
3
+ EleTable.install = Vue => Vue.component(EleTable.name, EleTable)
4
+
5
5
  export default EleTable
@@ -1,45 +1,104 @@
1
- <template>
2
- <div class="g-table__action">
3
- <div class="table-action__item" v-for="(item, idx) in dataSource" :key="idx">
4
- <template v-if="item.type == 'text'">
5
- <span @click="handleClickText(item)">{{ item.label }}</span>
6
- </template>
7
- </div>
8
- </div>
9
- </template>
10
-
11
- <script>
12
- export default {
13
- props: {
14
- record: {
15
- type: Object
16
- },
17
- dataSource: {
18
- type: Array,
19
- default: () => []
20
- }
21
- },
22
- methods: {
23
- handleClickText (props) {
24
- const { eventName, key } = props
25
- this.$emit(eventName, { key, record: this.record })
26
- }
27
- }
28
- }
29
- </script>
30
-
31
- <style lang="scss" scoped>
32
- .g-table__action {
33
- display: flex;
34
- flex-direction: row;
35
- .table-action__item {
36
- font-size: 14px;
37
- color: #409EFF;
38
- margin-left: 16px;
39
- cursor: pointer;
40
- &:first-child {
41
- margin-left: 0;
42
- }
43
- }
44
- }
1
+ <template>
2
+ <div class="g-table__action">
3
+ <div class="table-action__item" v-for="(item, idx) in dataSource" :key="idx">
4
+ <template v-if="item.type == 'text'">
5
+ <span>{{ item.label }}</span>
6
+ </template>
7
+ <template v-else-if="item.type == 'dropdown'">
8
+ <a-dropdown>
9
+ <a-menu slot="overlay" @click="handleDropdownClick">
10
+ <a-menu-item :key="`${item.key || ''}${menuKeyDelimiter}${opt.value || ''}`" v-for="opt in execDropdownOptExpression(item.optionList)">
11
+ <template v-if="opt.type == 'confirm'">
12
+ <a-popconfirm :title="opt.message" @confirm="handleClickConfirm(opt)">
13
+ {{ opt.label }}
14
+ </a-popconfirm>
15
+ </template>
16
+ <template v-else>
17
+ {{ opt.label }}
18
+ </template>
19
+ </a-menu-item>
20
+ </a-menu>
21
+ <span>{{ item.label }}</span>
22
+ </a-dropdown>
23
+ </template>
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ import { v5 as uuidv5 } from 'uuid'
30
+ import { type, route } from '@idooel/shared'
31
+ import { parse } from '@idooel/expression'
32
+ const MENU_KEY_NAMESPACE = 'f7b3b8b0-1b7b-11ec-9621-0242ac130002'
33
+ export default {
34
+ props: {
35
+ record: {
36
+ type: Object
37
+ },
38
+ dataSource: {
39
+ type: Array,
40
+ default: () => []
41
+ }
42
+ },
43
+ computed: {
44
+ menuKeyDelimiter () {
45
+ return uuidv5('_', MENU_KEY_NAMESPACE)
46
+ }
47
+ },
48
+ methods: {
49
+ execDropdownOptExpression (dataSource = []) {
50
+ const ret = dataSource.map(item => {
51
+ const { show } = item
52
+ if (type.isUndefined(show)) {
53
+ return item
54
+ } else if (type.isBool(show)) {
55
+ if (show) return item
56
+ } else if (type.isStr(show)) {
57
+ const parseRet = parse(show, { ...this.record, _route: route.searchToQueryParams(window.location.search) })
58
+ if (parseRet) return item
59
+ }
60
+ }).filter(item => item)
61
+ console.log('ret', ret)
62
+ return ret
63
+ },
64
+ handleClickConfirm (props) {
65
+ //TODO generate event by special rule
66
+ const { eventName, value } = props
67
+ this.$emit(eventName, { key: value, record: this.record })
68
+ },
69
+ handleDropdownClick (props) {
70
+ const { key } = props
71
+ const [parent, child] = key.split(this.menuKeyDelimiter)
72
+ if (!parent || !child) {
73
+ throw new Error('key is required')
74
+ }
75
+ const currentDropdown = this.dataSource.find(item => item.key === parent)
76
+ const currentClickTarget = currentDropdown.optionList.find(item => item.value === child)
77
+ const { eventName, type } = currentClickTarget
78
+ //TODO generate event by special rule
79
+ if (type === 'confirm') return
80
+ this.$emit(eventName, { key: child, record: this.record })
81
+ },
82
+ handleClickText (props) {
83
+ const { eventName, key } = props
84
+ this.$emit(eventName, { key, record: this.record })
85
+ }
86
+ }
87
+ }
88
+ </script>
89
+
90
+ <style lang="scss" scoped>
91
+ .g-table__action {
92
+ display: flex;
93
+ flex-direction: row;
94
+ .table-action__item {
95
+ font-size: 14px;
96
+ color: #409EFF;
97
+ margin-left: 16px;
98
+ cursor: pointer;
99
+ &:first-child {
100
+ margin-left: 0;
101
+ }
102
+ }
103
+ }
45
104
  </style>
@@ -1,89 +1,89 @@
1
- <template>
2
- <div class="g-table__wrapper">
3
- <a-table
4
- :pagination="false"
5
- :loading="loading"
6
- :columns="columns"
7
- :row-class-name="setRowClassName"
8
- :data-source="dataSource"
9
- :scroll="{ x: 1500, y: 500 }">
10
- <template slot="action" slot-scope="record">
11
- <Actions v-on="$listeners" :data-source="actions" :record="record"></Actions>
12
- </template>
13
- </a-table>
14
- <div class="g-table__pagination">
15
- <a-pagination
16
- :show-total="total => `共 ${total} 条数据`"
17
- show-size-changer
18
- show-quick-jumper
19
- :pageSize="pageSize"
20
- :pageSizeOptions="pageSizeOptions"
21
- @change="onChangePagination"
22
- :total="total">
23
- </a-pagination>
24
- </div>
25
- </div>
26
- </template>
27
-
28
- <script>
29
- import Actions from './action.vue'
30
- export default {
31
- name: 'ele-table',
32
- components: {
33
- Actions
34
- },
35
- props: {
36
- actions: {
37
- type: Array,
38
- default: () => []
39
- },
40
- total: {
41
- type: Number,
42
- default: 0
43
- },
44
- loading: {
45
- type: Boolean,
46
- default: false
47
- },
48
- columns: {
49
- type: Array,
50
- default: () => []
51
- },
52
- dataSource: {
53
- type: Array,
54
- default: () => []
55
- },
56
- pageSize: {
57
- type: Number,
58
- default: 10
59
- },
60
- pageSizeOptions: {
61
- type: Array,
62
- default: () => ['10', '20', '30', '40']
63
- }
64
- },
65
- methods: {
66
- setRowClassName (record, idx) {
67
- return idx % 2 === 0 ? 'g-table__row--even' : 'g-table__row--odd'
68
- },
69
- onChangePagination (page, pagrSize) {
70
- this.$emit('change-page', page, pagrSize)
71
- }
72
- }
73
- }
74
- </script>
75
-
76
- <style lang="scss" scoped>
77
- .g-table__wrapper {
78
- padding: 16px;
79
- padding-top: unset;
80
- .g-table__row--even {}
81
- .g-table__row--odd {}
82
- .g-table__pagination {
83
- margin-top: 8px;
84
- display: flex;
85
- flex-direction: row;
86
- justify-content: end;
87
- }
88
- }
1
+ <template>
2
+ <div class="g-table__wrapper">
3
+ <a-table
4
+ :pagination="false"
5
+ :loading="loading"
6
+ :columns="columns"
7
+ :row-class-name="setRowClassName"
8
+ :data-source="dataSource"
9
+ :scroll="{ x: 1500, y: 500 }">
10
+ <template slot="action" slot-scope="record">
11
+ <Actions v-on="$listeners" :data-source="actions" :record="record"></Actions>
12
+ </template>
13
+ </a-table>
14
+ <div class="g-table__pagination">
15
+ <a-pagination
16
+ :show-total="total => `共 ${total} 条数据`"
17
+ show-size-changer
18
+ show-quick-jumper
19
+ :pageSize="pageSize"
20
+ :pageSizeOptions="pageSizeOptions"
21
+ @change="onChangePagination"
22
+ :total="total">
23
+ </a-pagination>
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ import Actions from './action.vue'
30
+ export default {
31
+ name: 'ele-table',
32
+ components: {
33
+ Actions
34
+ },
35
+ props: {
36
+ actions: {
37
+ type: Array,
38
+ default: () => []
39
+ },
40
+ total: {
41
+ type: Number,
42
+ default: 0
43
+ },
44
+ loading: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ columns: {
49
+ type: Array,
50
+ default: () => []
51
+ },
52
+ dataSource: {
53
+ type: Array,
54
+ default: () => []
55
+ },
56
+ pageSize: {
57
+ type: Number,
58
+ default: 10
59
+ },
60
+ pageSizeOptions: {
61
+ type: Array,
62
+ default: () => ['10', '20', '30', '40']
63
+ }
64
+ },
65
+ methods: {
66
+ setRowClassName (record, idx) {
67
+ return idx % 2 === 0 ? 'g-table__row--even' : 'g-table__row--odd'
68
+ },
69
+ onChangePagination (page, pagrSize) {
70
+ this.$emit('change-page', page, pagrSize)
71
+ }
72
+ }
73
+ }
74
+ </script>
75
+
76
+ <style lang="scss" scoped>
77
+ .g-table__wrapper {
78
+ padding: 16px;
79
+ padding-top: unset;
80
+ .g-table__row--even {}
81
+ .g-table__row--odd {}
82
+ .g-table__pagination {
83
+ margin-top: 8px;
84
+ display: flex;
85
+ flex-direction: row;
86
+ justify-content: end;
87
+ }
88
+ }
89
89
  </style>
@@ -1,5 +1,5 @@
1
- import EleTpl from './src/index.vue'
2
-
3
- EleTpl.install = Vue => Vue.component(EleTpl.name, EleTpl)
4
-
1
+ import EleTpl from './src/index.vue'
2
+
3
+ EleTpl.install = Vue => Vue.component(EleTpl.name, EleTpl)
4
+
5
5
  export default EleTpl
@@ -1,39 +1,47 @@
1
- <template>
2
- <component
3
- v-if="modelName"
4
- :is="modelName"
5
- :ref="genModelRef"
6
- v-bind="$attrs"
7
- v-on="$listeners">
8
- <template v-for="(idx, name) in $scopedSlots" v-slot:[name]="data">
9
- <slot :name="name" v-bind="data"></slot>
10
- </template>
11
- </component>
12
- <div v-else>未正确配置模版</div>
13
- </template>
14
-
15
- <script>
16
- import EleTreeTableModel from '../../tree-table-model/src/index.vue'
17
- import { v4 as uuidv4 } from 'uuid'
18
- export default {
19
- name: 'ele-tpl',
20
- props: {
21
- modelName: {
22
- type: String
23
- }
24
- },
25
- components: {
26
- [EleTreeTableModel.name]: EleTreeTableModel
27
- },
28
- computed: {
29
- genModelRef () {
30
- return uuidv4()
31
- }
32
- },
33
- methods: {
34
- getModel () {
35
- return this.$refs[this.genModelRef]
36
- }
37
- }
38
- }
1
+ <template>
2
+ <component
3
+ v-if="modelNameValidator.existed"
4
+ :is="modelName"
5
+ :ref="genModelRef"
6
+ v-bind="$attrs"
7
+ v-on="$listeners">
8
+ <template v-for="(idx, name) in $scopedSlots" v-slot:[name]="data">
9
+ <slot :name="name" v-bind="data"></slot>
10
+ </template>
11
+ </component>
12
+ <div v-else v-html="modelNameValidator.message"></div>
13
+ </template>
14
+
15
+ <script>
16
+ import EleTreeTableModel from '../../tree-table-model/src/index.vue'
17
+ import { v4 as uuidv4 } from 'uuid'
18
+ import { models } from '../../index.js'
19
+ export default {
20
+ name: 'ele-tpl',
21
+ props: {
22
+ modelName: {
23
+ type: String
24
+ }
25
+ },
26
+ components: {
27
+ [EleTreeTableModel.name]: EleTreeTableModel
28
+ },
29
+ computed: {
30
+ modelNameValidator () {
31
+ const target = models.find(model => model.name === this.modelName)
32
+ return {
33
+ existed: !!target,
34
+ message: !!target ? '' : `Model <span style="color:red;">${this.modelName}</span> not found`
35
+ }
36
+ },
37
+ genModelRef () {
38
+ return uuidv4()
39
+ }
40
+ },
41
+ methods: {
42
+ getModel () {
43
+ return this.$refs[this.genModelRef]
44
+ }
45
+ }
46
+ }
39
47
  </script>