|
|
1
|
+export default {
|
|
|
2
|
+ name: 'busyConfig',
|
|
|
3
|
+ template: '',
|
|
|
4
|
+ components: {
|
|
|
5
|
+ },
|
|
|
6
|
+ props: [],
|
|
|
7
|
+ setup(props, {attrs, slots, emit}) {
|
|
|
8
|
+ const {proxy} = Vue.getCurrentInstance();
|
|
|
9
|
+ let height = Vue.ref(window.innerHeight);
|
|
|
10
|
+ let yearCheckList=Vue.ref([]);//年选择数据
|
|
|
11
|
+ let monthCheckList=Vue.ref([]);//月选择数据
|
|
|
12
|
+ let dayCheckList=Vue.ref([]);//日选择数据
|
|
|
13
|
+ let hourCheckList=Vue.ref([]);//时选择数据
|
|
|
14
|
+ let dialog=Vue.ref({
|
|
|
15
|
+ title:'忙时配置',
|
|
|
16
|
+ show:false,
|
|
|
17
|
+ id:''
|
|
|
18
|
+ });
|
|
|
19
|
+ let search = Vue.ref({
|
|
|
20
|
+ status: 0,
|
|
|
21
|
+ keyWords: '',
|
|
|
22
|
+ page: 1,
|
|
|
23
|
+ limit: 50,
|
|
|
24
|
+ });
|
|
|
25
|
+
|
|
|
26
|
+ //表格字段
|
|
|
27
|
+ let tableData = Vue.ref({
|
|
|
28
|
+ count:0,
|
|
|
29
|
+ dataList: [],
|
|
|
30
|
+ columns: [
|
|
|
31
|
+ {
|
|
|
32
|
+ prop: 'years',
|
|
|
33
|
+ label: '年',
|
|
|
34
|
+ sortable: true,
|
|
|
35
|
+ align: 'center',
|
|
|
36
|
+ width: '200',
|
|
|
37
|
+ },
|
|
|
38
|
+ {
|
|
|
39
|
+ prop: 'months',
|
|
|
40
|
+ label: '月',
|
|
|
41
|
+ sortable: true,
|
|
|
42
|
+ align: '200',
|
|
|
43
|
+ },
|
|
|
44
|
+ {
|
|
|
45
|
+ prop: 'days',
|
|
|
46
|
+ label: '日',
|
|
|
47
|
+ sortable: true,
|
|
|
48
|
+ align: 'center',
|
|
|
49
|
+ }, {
|
|
|
50
|
+ prop: 'hours',
|
|
|
51
|
+ label: '时',
|
|
|
52
|
+ sortable: true,
|
|
|
53
|
+ align: 'center',
|
|
|
54
|
+ width: '200'
|
|
|
55
|
+ }
|
|
|
56
|
+ ]
|
|
|
57
|
+ })
|
|
|
58
|
+ // 表格全选事件
|
|
|
59
|
+ let checkData=Vue.ref([]);
|
|
|
60
|
+ let selectionChange = (val) => {
|
|
|
61
|
+ let checkArr = [];
|
|
|
62
|
+ val.map(item => {
|
|
|
63
|
+ checkArr.push(item.id)
|
|
|
64
|
+ })
|
|
|
65
|
+ checkData.value = checkArr;
|
|
|
66
|
+
|
|
|
67
|
+ }
|
|
|
68
|
+ // 获取列表
|
|
|
69
|
+ let getDataList = () => {
|
|
|
70
|
+ proxy.$http.get(`/api-analysis/busyAnalysis/getList?keyWords=`+search.value.keyWords, {
|
|
|
71
|
+ page: search.value.page,
|
|
|
72
|
+ limit: search.value.limit,
|
|
|
73
|
+ }, function (res) {
|
|
|
74
|
+ if (res && res.data) {
|
|
|
75
|
+ tableData.value.dataList = res.data;
|
|
|
76
|
+ tableData.value.count = res.count;
|
|
|
77
|
+ tableData.value.dataList.map(item=>{
|
|
|
78
|
+ if(item.year){
|
|
|
79
|
+ item.years=item.year.split(",");
|
|
|
80
|
+ }
|
|
|
81
|
+ if(item.month){
|
|
|
82
|
+ item.months=item.month.split(",");
|
|
|
83
|
+ }
|
|
|
84
|
+ if(item.day){
|
|
|
85
|
+ item.days=item.day.split(",");
|
|
|
86
|
+ }
|
|
|
87
|
+ if(item.hour){
|
|
|
88
|
+ item.hours=item.hour.split(",");
|
|
|
89
|
+ }
|
|
|
90
|
+
|
|
|
91
|
+ })
|
|
|
92
|
+ } else {
|
|
|
93
|
+ tableData.value.dataList = [];
|
|
|
94
|
+ tableData.value.count = 0;
|
|
|
95
|
+ }
|
|
|
96
|
+ });
|
|
|
97
|
+
|
|
|
98
|
+ }
|
|
|
99
|
+
|
|
|
100
|
+ let loaddata = ({page, limit}) => {
|
|
|
101
|
+ search.value.page = page;
|
|
|
102
|
+ search.value.limit = limit;
|
|
|
103
|
+ }
|
|
|
104
|
+
|
|
|
105
|
+ let hideDialog = (flg) => {
|
|
|
106
|
+ dialog.value.show = flg;
|
|
|
107
|
+ if(!flg){
|
|
|
108
|
+ dialog.value.id='';
|
|
|
109
|
+ yearCheckList.value=[];
|
|
|
110
|
+ monthCheckList.value=[];
|
|
|
111
|
+ dayCheckList.value=[];
|
|
|
112
|
+ hourCheckList.value=[];
|
|
|
113
|
+ }
|
|
|
114
|
+ }
|
|
|
115
|
+
|
|
|
116
|
+ // 处理弹框
|
|
|
117
|
+ let handle = (row) =>{
|
|
|
118
|
+ dialog.value.id = row.id;
|
|
|
119
|
+ yearCheckList.value=row.years?row.years:[];
|
|
|
120
|
+ monthCheckList.value=row.months?row.months:[];
|
|
|
121
|
+ dayCheckList.value=row.days?row.days:[];
|
|
|
122
|
+ hourCheckList.value=row.hours?row.hours:[];
|
|
|
123
|
+ console.log("////",yearCheckList.value,monthCheckList.value,dayCheckList.value,hourCheckList.value)
|
|
|
124
|
+ hideDialog(true);
|
|
|
125
|
+ }
|
|
|
126
|
+
|
|
|
127
|
+ //修改详情
|
|
|
128
|
+ let handleEdit = (row) =>{
|
|
|
129
|
+ handle(row);
|
|
|
130
|
+ }
|
|
|
131
|
+ //删除数据
|
|
|
132
|
+ let handleDelete=(row)=>{
|
|
|
133
|
+ deletData(row);
|
|
|
134
|
+ }
|
|
|
135
|
+ //获取当前年的前后三年
|
|
|
136
|
+ let yearData=Vue.ref([])
|
|
|
137
|
+ let getYearData=()=>{
|
|
|
138
|
+ let date=new Date();
|
|
|
139
|
+ let arr=[];
|
|
|
140
|
+ for(let i=0;i<=3;i++){
|
|
|
141
|
+ arr.push(date.getFullYear()-i);
|
|
|
142
|
+ if(i!=0){
|
|
|
143
|
+ arr.push(date.getFullYear()+i)
|
|
|
144
|
+ }
|
|
|
145
|
+ }
|
|
|
146
|
+ arr.sort((a, b) => {
|
|
|
147
|
+ return a - b
|
|
|
148
|
+ });
|
|
|
149
|
+ yearData.value=arr;
|
|
|
150
|
+ }
|
|
|
151
|
+ //新增配置
|
|
|
152
|
+ let addConfig=()=>{
|
|
|
153
|
+ hideDialog(true);
|
|
|
154
|
+ }
|
|
|
155
|
+ //批量删除配置
|
|
|
156
|
+ let delConfig=()=>{
|
|
|
157
|
+ if(checkData.value.length<1){
|
|
|
158
|
+ proxy.$global.showMsg('请至少选择一项','warning');
|
|
|
159
|
+ return;
|
|
|
160
|
+ }
|
|
|
161
|
+ deletData();
|
|
|
162
|
+ }
|
|
|
163
|
+ //删除操作
|
|
|
164
|
+ let deletData=(row)=>{
|
|
|
165
|
+ let idList='';
|
|
|
166
|
+ if(row){
|
|
|
167
|
+ idList=row.id;
|
|
|
168
|
+ }else{
|
|
|
169
|
+ if(checkData.value.length>0){
|
|
|
170
|
+ idList=checkData.value.join(',')
|
|
|
171
|
+ }
|
|
|
172
|
+ }
|
|
|
173
|
+
|
|
|
174
|
+ proxy.$global.confirm("确认删除数据吗?", function () {
|
|
|
175
|
+ proxy.$http.get(`/api-analysis/busyAnalysis/remove`, {
|
|
|
176
|
+ idList: idList
|
|
|
177
|
+ }, function (res) {
|
|
|
178
|
+ if(res && res.success){
|
|
|
179
|
+ proxy.$global.showMsg('删除成功');
|
|
|
180
|
+ }else{
|
|
|
181
|
+ proxy.$global.showMsg('删除失败','error');
|
|
|
182
|
+ }
|
|
|
183
|
+ getDataList();
|
|
|
184
|
+ })
|
|
|
185
|
+ })
|
|
|
186
|
+ }
|
|
|
187
|
+ //保存配置
|
|
|
188
|
+ let saveConfig=()=>{
|
|
|
189
|
+ if(hourCheckList.value.length<1){
|
|
|
190
|
+ proxy.$global.showMsg('请至少选择一个时间','warning');
|
|
|
191
|
+ return;
|
|
|
192
|
+ }
|
|
|
193
|
+ let year='';
|
|
|
194
|
+ if(yearCheckList.value.length>0){
|
|
|
195
|
+ year=yearCheckList.value.join(",");
|
|
|
196
|
+ }
|
|
|
197
|
+ let month='';
|
|
|
198
|
+ if(monthCheckList.value.length>0){
|
|
|
199
|
+ month=monthCheckList.value.join(",");
|
|
|
200
|
+ }
|
|
|
201
|
+ let day='';
|
|
|
202
|
+ if(dayCheckList.value.length>0){
|
|
|
203
|
+ day=dayCheckList.value.join(",");
|
|
|
204
|
+ }
|
|
|
205
|
+ let hour='';
|
|
|
206
|
+ if(hourCheckList.value.length>0){
|
|
|
207
|
+ hour=hourCheckList.value.join(",");
|
|
|
208
|
+ }
|
|
|
209
|
+ if(dialog.value.id){
|
|
|
210
|
+ proxy.$http.post(`/api-analysis/busyAnalysis/update`, {
|
|
|
211
|
+ year: year,
|
|
|
212
|
+ month: month,
|
|
|
213
|
+ day: day,
|
|
|
214
|
+ hour: hour,
|
|
|
215
|
+ id:dialog.value.id
|
|
|
216
|
+ }, function (res) {
|
|
|
217
|
+ if(res && res.success){
|
|
|
218
|
+ proxy.$global.showMsg('修改成功');
|
|
|
219
|
+ }else{
|
|
|
220
|
+ proxy.$global.showMsg('修改失败','error');
|
|
|
221
|
+ }
|
|
|
222
|
+ hideDialog(false);
|
|
|
223
|
+ getDataList();
|
|
|
224
|
+ })
|
|
|
225
|
+ }else{
|
|
|
226
|
+ proxy.$http.post(`/api-analysis/busyAnalysis/add`, {
|
|
|
227
|
+ year: year,
|
|
|
228
|
+ month: month,
|
|
|
229
|
+ day: day,
|
|
|
230
|
+ hour: hour
|
|
|
231
|
+ }, function (res) {
|
|
|
232
|
+ if(res && res.success){
|
|
|
233
|
+ proxy.$global.showMsg('保存成功');
|
|
|
234
|
+ }else{
|
|
|
235
|
+ proxy.$global.showMsg('保存失败','error');
|
|
|
236
|
+ }
|
|
|
237
|
+ hideDialog(false);
|
|
|
238
|
+ getDataList();
|
|
|
239
|
+ })
|
|
|
240
|
+ }
|
|
|
241
|
+
|
|
|
242
|
+
|
|
|
243
|
+
|
|
|
244
|
+ }
|
|
|
245
|
+ // 挂载完
|
|
|
246
|
+ Vue.onMounted(() => {
|
|
|
247
|
+ getYearData();
|
|
|
248
|
+ getDataList();
|
|
|
249
|
+ })
|
|
|
250
|
+
|
|
|
251
|
+
|
|
|
252
|
+ return {
|
|
|
253
|
+ saveConfig,
|
|
|
254
|
+ delConfig,
|
|
|
255
|
+ addConfig,
|
|
|
256
|
+ selectionChange,
|
|
|
257
|
+ handleDelete,
|
|
|
258
|
+ checkData,
|
|
|
259
|
+ yearData,
|
|
|
260
|
+ dialog,
|
|
|
261
|
+ getYearData,
|
|
|
262
|
+ height,
|
|
|
263
|
+ search,
|
|
|
264
|
+ hideDialog,
|
|
|
265
|
+ handle,
|
|
|
266
|
+ loaddata,
|
|
|
267
|
+ tableData,
|
|
|
268
|
+ getDataList,
|
|
|
269
|
+ handleEdit,
|
|
|
270
|
+ yearCheckList,
|
|
|
271
|
+ monthCheckList,
|
|
|
272
|
+ dayCheckList,
|
|
|
273
|
+ hourCheckList
|
|
|
274
|
+ }
|
|
|
275
|
+ }
|
|
|
276
|
+
|
|
|
277
|
+} |