1
1
<template >
2
- <widget-edit-dialog :widget-params =" widgetParams" :widget-data =" widgetData"
3
- :option =" widgetConfigOption"
4
- @confirm =" onSaveClick()"
5
- :enable-background =" true" >
2
+ <widget-edit-dialog
3
+ :widget-params =" widgetParams"
4
+ :widget-data =" widgetData"
5
+ :option =" widgetConfigOption"
6
+ @confirm =" onSaveClick()"
7
+ :enable-background =" true" >
6
8
<template v-slot :widget >
7
9
<!-- 组件配置内容 -->
8
- <birthday-list-widget :style =" {width:`${widgetParams.widthPx}px`,height:`${widgetParams.heightPx}px`}"
9
- :border-radius =" widgetData.borderRadius"
10
- :birthday-list-data =" widgetData"
11
- :background-color =" widgetData.backgroundColor" />
10
+ <birthday-list-widget
11
+ :style =" { width: `${widgetParams.widthPx}px`, height: `${widgetParams.heightPx}px` }"
12
+ :border-radius =" widgetData.borderRadius"
13
+ :birthday-list-data =" widgetData"
14
+ :background-color =" widgetData.backgroundColor" />
12
15
</template >
13
16
<template v-slot :form >
14
17
<el-form label-width =" 120px" >
15
18
<el-form-item label =" 左上角标题" >
16
- <el-input v-model =" widgetData.title" maxlength =" 6" />
19
+ <el-input v-model =" widgetData.title" maxlength =" 6" />
17
20
</el-form-item >
18
21
</el-form >
19
22
<!-- <div style="color: red">注意:目前农历暂不支持,等待后续开放</div> -->
20
- <el-table :data =" widgetData.peopleList" max-height =" 250"
21
- row-key =" createdAt"
22
- style =" width : 100% ;" table-layout =" auto" >
23
+ <el-table
24
+ :data =" widgetData.peopleList"
25
+ max-height =" 250"
26
+ row-key =" createdAt"
27
+ style =" width : 100% "
28
+ table-layout =" auto" >
23
29
<el-table-column align =" center" width =" 100" >
24
30
<template #header >
25
31
<el-button size =" small" type =" primary" @click =" add" >新增</el-button >
32
38
<template #default =" scope " >{{ scope.$index + 1 }}</template >
33
39
</el-table-column >
34
40
<el-table-column label =" 姓名" prop =" name" align =" center" >
35
- <template #default =" {row } " >
36
- <el-input v-model =" row.name" maxlength =" 10" />
41
+ <template #default =" { row } " >
42
+ <el-input v-model =" row.name" maxlength =" 10" />
37
43
</template >
38
44
</el-table-column >
39
45
<el-table-column label =" 农历" prop =" type" align =" center" >
40
- <template #default =" {row } " >
46
+ <template #default =" { row } " >
41
47
<el-radio-group v-model =" row.type" >
42
48
<el-radio label =" Y" size =" large" >农历</el-radio >
43
49
<el-radio label =" N" size =" large" >公历</el-radio >
44
50
</el-radio-group >
45
51
</template >
46
52
</el-table-column >
47
53
<el-table-column label =" 月" prop =" month" align =" center" >
48
- <template #default =" {row } " >
49
- <el-input-number v-model =" row.month" :min =" 1" :max =" 12" />
54
+ <template #default =" { row } " >
55
+ <el-input-number v-model =" row.month" :min =" 1" :max =" 12" />
50
56
</template >
51
57
</el-table-column >
52
58
<el-table-column label =" 日" prop =" day" align =" center" >
53
- <template #default =" {row } " >
54
- <el-input-number v-model =" row.day" :min =" 1" :max =" 31" />
59
+ <template #default =" { row } " >
60
+ <el-input-number v-model =" row.day" :min =" 1" :max =" 31" />
55
61
</template >
56
62
</el-table-column >
57
63
</el-table >
60
66
</template >
61
67
62
68
<script lang="ts">
63
- import {NotificationApi , WidgetDataRepository } from " @widget-js/core" ;
64
- import BirthdayListWidget from " ./BirthdayListWidget.vue" ;
65
- import BirthdayListData , {BirthdayPeople } from " @/widgets/birthday-list/model/BirthdayListData" ;
66
- import {useWidget , WidgetConfigOption , WidgetEditDialog } from " @widget-js/vue3" ;
67
- import {reactive } from " vue" ;
69
+ import {NotificationApi , WidgetDataApi } from ' @widget-js/core'
70
+ import BirthdayListWidget from ' ./BirthdayListWidget.vue'
71
+ import BirthdayListData , { BirthdayPeople } from ' @/widgets/birthday-list/model/BirthdayListData'
72
+ import { useWidget , WidgetConfigOption , WidgetEditDialog } from ' @widget-js/vue3'
68
73
69
74
export default {
70
- name: " BirthdayListConfigView" ,
71
- components: {BirthdayListWidget , WidgetEditDialog },
75
+ name: ' BirthdayListConfigView' ,
76
+ components: { BirthdayListWidget , WidgetEditDialog },
72
77
setup() {
73
- const widgetConfigOption = new WidgetConfigOption ({backgroundColor: true , borderRadius: false })
74
- const {widgetData, widgetParams} = useWidget (BirthdayListData , {
75
- loadDataByWidgetName: true });
76
- return {widgetData , widgetParams , widgetConfigOption }
78
+ const widgetConfigOption = new WidgetConfigOption ({ backgroundColor: true , borderRadius: false })
79
+ const { widgetData, widgetParams } = useWidget (BirthdayListData , {
80
+ loadDataByWidgetName: true
81
+ })
82
+ return { widgetData , widgetParams , widgetConfigOption }
77
83
},
78
84
mounted() {
79
- document .title = " 组件设置"
85
+ document .title = ' 组件设置'
80
86
},
81
87
methods: {
82
88
/**
83
89
* 点击保存按钮
84
90
*/
85
91
async onSaveClick() {
86
- let that = this ;
92
+ let that = this
87
93
if (that .widgetData .peopleList && that .widgetData .peopleList .length > 0 ) {
88
- var names = [] as any [];
94
+ var names = [] as any []
89
95
for (let index in that .widgetData .peopleList ) {
90
96
if (! that .widgetData .peopleList [index ].name ) {
91
97
NotificationApi .error (' 第' + (parseInt (index ) + 1 ) + ' 行【姓名】不能为空!' )
92
- return ;
98
+ return
93
99
}
94
100
if (names .indexOf (that .widgetData .peopleList [index ].name ) >= 0 ) {
95
- NotificationApi .error (' 第' + (parseInt (index ) + 1 ) + ' 行与第' + (names .indexOf (that .widgetData .peopleList [index ].name ) + 1 ) + ' 行【姓名】名字重复!' )
96
- return ;
101
+ NotificationApi .error (
102
+ ' 第' +
103
+ (parseInt (index ) + 1 ) +
104
+ ' 行与第' +
105
+ (names .indexOf (that .widgetData .peopleList [index ].name ) + 1 ) +
106
+ ' 行【姓名】名字重复!'
107
+ )
108
+ return
97
109
}
98
110
if (! that .widgetData .peopleList [index ].month ) {
99
111
NotificationApi .error (' 第' + (parseInt (index ) + 1 ) + ' 行【月】不能为空!' )
100
- return ;
112
+ return
101
113
}
102
114
if (! that .widgetData .peopleList [index ].day ) {
103
115
NotificationApi .error (' 第' + (parseInt (index ) + 1 ) + ' 行【日】不能为空!' )
104
- return ;
116
+ return
105
117
}
106
- names .push (that .widgetData .peopleList [index ].name );
118
+ names .push (that .widgetData .peopleList [index ].name )
107
119
}
108
120
}
109
- await WidgetDataRepository .saveByName (this .widgetData );
110
- window .close ();
121
+ await WidgetDataApi .saveByName (this .widgetData )
122
+ window .close ()
111
123
},
112
124
add() {
113
- const newPeople: BirthdayPeople = {name: ' ' , type: ' N' , month: 1 , day: 1 , qty: 0 , createdAt: new Date ().getTime ()}
114
- this .widgetData .peopleList .splice (0 , 0 , newPeople );
125
+ const newPeople: BirthdayPeople = {
126
+ name: ' ' ,
127
+ type: ' N' ,
128
+ month: 1 ,
129
+ day: 1 ,
130
+ qty: 0 ,
131
+ createdAt: new Date ().getTime ()
132
+ }
133
+ this .widgetData .peopleList .splice (0 , 0 , newPeople )
115
134
},
116
135
del(scope ) {
117
- this .widgetData .peopleList .splice (scope .$index , 1 );
136
+ this .widgetData .peopleList .splice (scope .$index , 1 )
118
137
}
119
138
},
120
139
watch: {
@@ -126,10 +145,6 @@ export default {
126
145
}
127
146
}
128
147
}
129
-
130
-
131
148
</script >
132
149
133
- <style scoped>
134
-
135
- </style >
150
+ <style scoped></style >
0 commit comments