幻雨堂
2024-03-01 d773f9777df29f5e17e45148326cbd784c328dac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<template>
  <div class="p-2">
    <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
      <el-tab-pane label="交通指数" name="first"></el-tab-pane>
      <el-tab-pane label="配置" name="second"></el-tab-pane>
    </el-tabs>
    <div v-show="activeName=='first'">
        <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
          <el-form ref="form" :model="form" label-width="80px">
            统计周期
            <el-select v-model="form.year" placeholder="请选择年份">
              <el-option label="2024年" value="2024" />
              <el-option label="2023年" value="2023" />
              <el-option label="2022年" value="2022" />
            </el-select>
            <el-select v-model="form.month" placeholder="请选择月份">
              <el-option label="12月" value="12" />
              <el-option label="11月" value="11" />
              <el-option label="10月" value="10" />
            </el-select>
            状态
            <el-select v-model="form.status" placeholder="请选择状态">
              <el-option label="全部" value="0" />
              <el-option label="已启用" value="1" />
              <el-option label="已禁用" value="2" />
            </el-select>
                &nbsp;&nbsp;&nbsp;
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            
          </el-form>
        </transition>
 
        <el-card shadow="never">
          <template #header>
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['rs:trafficIndex:add']">新增</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['rs:trafficIndex:edit']">修改</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['rs:trafficIndex:remove']">删除</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['rs:trafficIndex:export']">导出</el-button>
              </el-col>
              <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
            </el-row>
          </template>
 
          <el-table v-loading="loading" :data="trafficIndexList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="序号" type="index" width="50"/>
            <el-table-column label="模块名称" align="center" prop="modeName" />
            <el-table-column label="指标1名称" align="center" prop="targetOneName" />
            <el-table-column label="指标1值" align="center" prop="targetOneValue" />
            <el-table-column label="指标1单位" align="center" prop="targetOneUnit" />
            <el-table-column label="指标1状态 1 上浮 2下降" align="center" prop="targetOneStatus" />
            <el-table-column label="指标1上浮或下降值" align="center" prop="targetOneCompareValue" />
            <el-table-column label="指标2名称" align="center" prop="targetTwoName" />
            <el-table-column label="指标2值" align="center" prop="targetTwoValue" />
            <el-table-column label="指标2单位" align="center" prop="targetTwoUnit" />
            <el-table-column label="指标2状态 1 上浮 2下降" align="center" prop="targetTwoStatus" />
            <el-table-column label="指标2上浮或下降值" align="center" prop="targetTwoCompareValue" />
            <el-table-column label="指标3名称" align="center" prop="targetThreeName" />
            <el-table-column label="指标3值" align="center" prop="targetThreeValue" />
            <el-table-column label="指标3单位" align="center" prop="targetThreeUnit" />
            <el-table-column label="指标3状态 1 上浮 2下降" align="center" prop="targetThreeStatus" />
            <el-table-column label="指标3上浮或下降值" align="center" prop="targetThreeCompareValue" />
            <el-table-column label="指标4名称" align="center" prop="targetFourName" />
            <el-table-column label="指标4值" align="center" prop="targetFourValue" />
            <el-table-column label="指标4单位" align="center" prop="targetFourUnit" />
            <el-table-column label="指标4状态 1 上浮 2下降" align="center" prop="targetFourStatus" />
            <el-table-column label="指标4上浮或下降值" align="center" prop="targetFourCompareValue" />
            <el-table-column label="启用状态 1启用 2未启用" align="center" prop="status" />
            <el-table-column label="周期 1 月  2年" align="center" prop="periodName" />
            <el-table-column label="周期值" align="center" prop="periodValue" />
            <el-table-column label="0未删除   1已删除" align="center" prop="del" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template #default="scope">
                <el-tooltip content="修改" placement="top">
                  <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['rs:trafficIndex:edit']"></el-button>
                </el-tooltip>
                <el-tooltip content="删除" placement="top">
                  <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['rs:trafficIndex:remove']"></el-button>
                </el-tooltip>
              </template>
            </el-table-column>
          </el-table>
 
          <pagination
              v-show="total>0"
              :total="total"
              v-model:page="queryParams.pageNum"
              v-model:limit="queryParams.pageSize"
              @pagination="getList"
          />
        </el-card>
      </div>
      <div v-show="activeName=='second'">
      <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
        <div class="search" v-show="showSearch">
          <el-upload
            action="#"
            list-type="picture-card"
            :auto-upload="false">
              <i slot="default" class="el-icon-plus"></i>
              <div slot="file" slot-scope="{file}">
                <img
                  class="el-upload-list__item-thumbnail"
                  :src="file.url" alt=""
                >
                <span class="el-upload-list__item-actions">
                  <span
                    class="el-upload-list__item-preview"
                    @click="handlePictureCardPreview(file)"
                  >
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span
                    v-if="!disabled"
                    class="el-upload-list__item-delete"
                    @click="handleDownload(file)"
                  >
                    <i class="el-icon-download"></i>
                  </span>
                  <span
                    v-if="!disabled"
                    class="el-upload-list__item-delete"
                    @click="handleRemove(file)"
                  >
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
          <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
        </div>
      </transition>
 
      
    </div>
    <!-- 添加或修改交通指数对话框 -->
    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
      <el-form ref="trafficIndexFormRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="模块名称" prop="modeName">
          <el-input v-model="form.modeName" placeholder="请输入模块名称" />
        </el-form-item>
        <el-form-item label="指标1名称" prop="targetOneName">
          <el-input v-model="form.targetOneName" placeholder="请输入指标1名称" />
        </el-form-item>
        <el-form-item label="指标1值" prop="targetOneValue">
          <el-input v-model="form.targetOneValue" placeholder="请输入指标1值" />
        </el-form-item>
        <el-form-item label="指标1单位" prop="targetOneUnit">
          <el-input v-model="form.targetOneUnit" placeholder="请输入指标1单位" />
        </el-form-item>
        <el-form-item label="指标1上浮或下降值" prop="targetOneCompareValue">
          <el-input v-model="form.targetOneCompareValue" placeholder="请输入指标1上浮或下降值" />
        </el-form-item>
        <el-form-item label="指标2名称" prop="targetTwoName">
          <el-input v-model="form.targetTwoName" placeholder="请输入指标2名称" />
        </el-form-item>
        <el-form-item label="指标2值" prop="targetTwoValue">
          <el-input v-model="form.targetTwoValue" placeholder="请输入指标2值" />
        </el-form-item>
        <el-form-item label="指标2单位" prop="targetTwoUnit">
          <el-input v-model="form.targetTwoUnit" placeholder="请输入指标2单位" />
        </el-form-item>
        <el-form-item label="指标2上浮或下降值" prop="targetTwoCompareValue">
          <el-input v-model="form.targetTwoCompareValue" placeholder="请输入指标2上浮或下降值" />
        </el-form-item>
        <el-form-item label="指标3名称" prop="targetThreeName">
          <el-input v-model="form.targetThreeName" placeholder="请输入指标3名称" />
        </el-form-item>
        <el-form-item label="指标3值" prop="targetThreeValue">
          <el-input v-model="form.targetThreeValue" placeholder="请输入指标3值" />
        </el-form-item>
        <el-form-item label="指标3单位" prop="targetThreeUnit">
          <el-input v-model="form.targetThreeUnit" placeholder="请输入指标3单位" />
        </el-form-item>
        <el-form-item label="指标3上浮或下降值" prop="targetThreeCompareValue">
          <el-input v-model="form.targetThreeCompareValue" placeholder="请输入指标3上浮或下降值" />
        </el-form-item>
        <el-form-item label="指标4名称" prop="targetFourName">
          <el-input v-model="form.targetFourName" placeholder="请输入指标4名称" />
        </el-form-item>
        <el-form-item label="指标4值" prop="targetFourValue">
          <el-input v-model="form.targetFourValue" placeholder="请输入指标4值" />
        </el-form-item>
        <el-form-item label="指标4单位" prop="targetFourUnit">
          <el-input v-model="form.targetFourUnit" placeholder="请输入指标4单位" />
        </el-form-item>
        <el-form-item label="指标4上浮或下降值" prop="targetFourCompareValue">
          <el-input v-model="form.targetFourCompareValue" placeholder="请输入指标4上浮或下降值" />
        </el-form-item>
        <el-form-item label="周期 1 月  2年" prop="periodName">
          <el-input v-model="form.periodName" placeholder="请输入周期 1 月  2年" />
        </el-form-item>
        <el-form-item label="周期值" prop="periodValue">
          <el-input v-model="form.periodValue" placeholder="请输入周期值" />
        </el-form-item>
        <el-form-item label="0未删除   1已删除" prop="del">
          <el-input v-model="form.del" placeholder="请输入0未删除   1已删除" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
 
<script setup name="TrafficIndex" lang="ts">
import { listTrafficIndex, getTrafficIndex, delTrafficIndex, addTrafficIndex, updateTrafficIndex } from '@/api/ti/trafficIndex';
import { TrafficIndexVO, TrafficIndexQuery, TrafficIndexForm } from '@/api/ti/trafficIndex/types';
import type { TabsPaneContext, UploadProps, UploadUserFile } from "element-plus";
 
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const trafficIndexList = ref<TrafficIndexVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const activeName = ref('first');
const queryFormRef = ref<ElFormInstance>();
const trafficIndexFormRef = ref<ElFormInstance>();
const dialogImageUrl =ref('');
const dialogVisible= ref(false);
const disabled= ref(false);
const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});
const options = {
  label: false,
  value: ''
};
const initFormData: TrafficIndexForm = {
  id: undefined,
  modeName: undefined,
  targetOneName: undefined,
  targetOneValue: undefined,
  targetOneUnit: undefined,
  targetOneStatus: undefined,
  targetOneCompareValue: undefined,
  targetTwoName: undefined,
  targetTwoValue: undefined,
  targetTwoUnit: undefined,
  targetTwoStatus: undefined,
  targetTwoCompareValue: undefined,
  targetThreeName: undefined,
  targetThreeValue: undefined,
  targetThreeUnit: undefined,
  targetThreeStatus: undefined,
  targetThreeCompareValue: undefined,
  targetFourName: undefined,
  targetFourValue: undefined,
  targetFourUnit: undefined,
  targetFourStatus: undefined,
  targetFourCompareValue: undefined,
  status: undefined,
  periodName: undefined,
  periodValue: undefined,
  del: undefined
}
const data = reactive<PageData<TrafficIndexForm, TrafficIndexQuery>>({
  form: {...initFormData},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    modeName: undefined,
    targetOneName: undefined,
    targetOneValue: undefined,
    targetOneUnit: undefined,
    targetOneStatus: undefined,
    targetOneCompareValue: undefined,
    targetTwoName: undefined,
    targetTwoValue: undefined,
    targetTwoUnit: undefined,
    targetTwoStatus: undefined,
    targetTwoCompareValue: undefined,
    targetThreeName: undefined,
    targetThreeValue: undefined,
    targetThreeUnit: undefined,
    targetThreeStatus: undefined,
    targetThreeCompareValue: undefined,
    targetFourName: undefined,
    targetFourValue: undefined,
    targetFourUnit: undefined,
    targetFourStatus: undefined,
    targetFourCompareValue: undefined,
    status: undefined,
    periodName: undefined,
    periodValue: undefined,
    del: undefined,
    params: {
    }
  },
  rules: {
    id: [
      { required: true, message: "主键id不能为空", trigger: "blur" }
    ],
    modeName: [
      { required: true, message: "模块名称不能为空", trigger: "blur" }
    ],
    targetOneName: [
      { required: true, message: "指标1名称不能为空", trigger: "blur" }
    ],
    targetOneValue: [
      { required: true, message: "指标1值不能为空", trigger: "blur" }
    ],
    targetOneUnit: [
      { required: true, message: "指标1单位不能为空", trigger: "blur" }
    ],
    targetOneStatus: [
      { required: true, message: "指标1状态 1 上浮 2下降不能为空", trigger: "change" }
    ],
    targetOneCompareValue: [
      { required: true, message: "指标1上浮或下降值不能为空", trigger: "blur" }
    ],
    targetTwoName: [
      { required: true, message: "指标2名称不能为空", trigger: "blur" }
    ],
    targetTwoValue: [
      { required: true, message: "指标2值不能为空", trigger: "blur" }
    ],
    targetTwoUnit: [
      { required: true, message: "指标2单位不能为空", trigger: "blur" }
    ],
    targetTwoStatus: [
      { required: true, message: "指标2状态 1 上浮 2下降不能为空", trigger: "change" }
    ],
    targetTwoCompareValue: [
      { required: true, message: "指标2上浮或下降值不能为空", trigger: "blur" }
    ],
    targetThreeName: [
      { required: true, message: "指标3名称不能为空", trigger: "blur" }
    ],
    targetThreeValue: [
      { required: true, message: "指标3值不能为空", trigger: "blur" }
    ],
    targetThreeUnit: [
      { required: true, message: "指标3单位不能为空", trigger: "blur" }
    ],
    targetThreeStatus: [
      { required: true, message: "指标3状态 1 上浮 2下降不能为空", trigger: "change" }
    ],
    targetThreeCompareValue: [
      { required: true, message: "指标3上浮或下降值不能为空", trigger: "blur" }
    ],
    targetFourName: [
      { required: true, message: "指标4名称不能为空", trigger: "blur" }
    ],
    targetFourValue: [
      { required: true, message: "指标4值不能为空", trigger: "blur" }
    ],
    targetFourUnit: [
      { required: true, message: "指标4单位不能为空", trigger: "blur" }
    ],
    targetFourStatus: [
      { required: true, message: "指标4状态 1 上浮 2下降不能为空", trigger: "change" }
    ],
    targetFourCompareValue: [
      { required: true, message: "指标4上浮或下降值不能为空", trigger: "blur" }
    ],
    status: [
      { required: true, message: "启用状态 1启用 2未启用不能为空", trigger: "change" }
    ],
    periodName: [
      { required: true, message: "周期 1 月  2年不能为空", trigger: "blur" }
    ],
    periodValue: [
      { required: true, message: "周期值不能为空", trigger: "blur" }
    ],
    del: [
      { required: true, message: "0未删除   1已删除不能为空", trigger: "blur" }
    ]
  }
});
 
const { queryParams, form, rules } = toRefs(data);
 
/** 查询交通指数列表 */
const getList = async () => {
  loading.value = true;
  const res = await listTrafficIndex(queryParams.value);
  trafficIndexList.value = res.rows;
  total.value = res.total;
  loading.value = false;
}
 
/** 取消按钮 */
const cancel = () => {
  reset();
  dialog.visible = false;
}
 
/** 表单重置 */
const reset = () => {
  form.value = {...initFormData};
  trafficIndexFormRef.value?.resetFields();
}
 
/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
}
 
/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
}
 
/** 多选框选中数据 */
const handleSelectionChange = (selection: TrafficIndexVO[]) => {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
 
/** 新增按钮操作 */
const handleAdd = () => {
  reset();
  dialog.visible = true;
  dialog.title = "添加交通指数";
}
const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab.props.label, activeName)
}
/** 修改按钮操作 */
const handleUpdate = async (row?: TrafficIndexVO) => {
  reset();
  const _id = row?.id || ids.value[0]
  const res = await getTrafficIndex(_id);
  Object.assign(form.value, res.data);
  dialog.visible = true;
  dialog.title = "修改交通指数";
}
 
/** 提交按钮 */
const submitForm = () => {
  trafficIndexFormRef.value?.validate(async (valid: boolean) => {
    if (valid) {
      buttonLoading.value = true;
      if (form.value.id) {
        await updateTrafficIndex(form.value).finally(() =>  buttonLoading.value = false);
      } else {
        await addTrafficIndex(form.value).finally(() =>  buttonLoading.value = false);
      }
      proxy?.$modal.msgSuccess("修改成功");
      dialog.visible = false;
      await getList();
    }
  });
}
 
/** 删除按钮操作 */
const handleDelete = async (row?: TrafficIndexVO) => {
  const _ids = row?.id || ids.value;
  await proxy?.$modal.confirm('是否确认删除交通指数编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
  await delTrafficIndex(_ids);
  proxy?.$modal.msgSuccess("删除成功");
  await getList();
}
 
/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download('rs/trafficIndex/export', {
    ...queryParams.value
  }, `trafficIndex_${new Date().getTime()}.xlsx`)
}
 
onMounted(() => {
  getList();
});
function handleRemove(file:string) {
        console.log(file);
      };
type files = {    //自定义类型
    url: string;
  };
function  handlePictureCardPreview(file:files) {
        dialogImageUrl.value = file.url;
        dialogVisible.value = true;
      };
function handleDownload(file:string) {
        console.log(file);
      };
      
</script>