幻雨堂
2024-02-27 9e68d44b460ed5897ded1ee3c07e0840c6c24160
交通指数
3个文件已添加
940 ■■■■■ 已修改文件
src/api/ti/trafficIndex/index.ts 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/ti/trafficIndex/types.ts 401 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/ti/trafficIndex/index.vue 476 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/ti/trafficIndex/index.ts
New file
@@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TrafficIndexVO, TrafficIndexForm, TrafficIndexQuery } from '@/api/ti/trafficIndex/types';
/**
 * 查询交通指数列表
 * @param query
 * @returns {*}
 */
export const listTrafficIndex = (query?: TrafficIndexQuery): AxiosPromise<TrafficIndexVO[]> => {
  return request({
    url: '/rs/trafficIndex/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询交通指数详细
 * @param id
 */
export const getTrafficIndex = (id: string | number): AxiosPromise<TrafficIndexVO> => {
  return request({
    url: '/rs/trafficIndex/' + id,
    method: 'get'
  });
};
/**
 * 新增交通指数
 * @param data
 */
export const addTrafficIndex = (data: TrafficIndexForm) => {
  return request({
    url: '/rs/trafficIndex',
    method: 'post',
    data: data
  });
};
/**
 * 修改交通指数
 * @param data
 */
export const updateTrafficIndex = (data: TrafficIndexForm) => {
  return request({
    url: '/rs/trafficIndex',
    method: 'put',
    data: data
  });
};
/**
 * 删除交通指数
 * @param id
 */
export const delTrafficIndex = (id: string | number | Array<string | number>) => {
  return request({
    url: '/rs/trafficIndex/' + id,
    method: 'delete'
  });
};
src/api/ti/trafficIndex/types.ts
New file
@@ -0,0 +1,401 @@
export interface TrafficIndexVO {
  /**
   * 主键id
   */
  id: string | number;
  /**
   * 模块名称
   */
  modeName: string;
  /**
   * 指标1名称
   */
  targetOneName: string;
  /**
   * 指标1值
   */
  targetOneValue: number;
  /**
   * 指标1单位
   */
  targetOneUnit: string;
  /**
   * 指标1状态 1 上浮 2下降
   */
  targetOneStatus: number;
  /**
   * 指标1上浮或下降值
   */
  targetOneCompareValue: number;
  /**
   * 指标2名称
   */
  targetTwoName: string;
  /**
   * 指标2值
   */
  targetTwoValue: number;
  /**
   * 指标2单位
   */
  targetTwoUnit: string;
  /**
   * 指标2状态 1 上浮 2下降
   */
  targetTwoStatus: number;
  /**
   * 指标2上浮或下降值
   */
  targetTwoCompareValue: number;
  /**
   * 指标3名称
   */
  targetThreeName: string;
  /**
   * 指标3值
   */
  targetThreeValue: number;
  /**
   * 指标3单位
   */
  targetThreeUnit: string;
  /**
   * 指标3状态 1 上浮 2下降
   */
  targetThreeStatus: number;
  /**
   * 指标3上浮或下降值
   */
  targetThreeCompareValue: number;
  /**
   * 指标4名称
   */
  targetFourName: string;
  /**
   * 指标4值
   */
  targetFourValue: number;
  /**
   * 指标4单位
   */
  targetFourUnit: string;
  /**
   * 指标4状态 1 上浮 2下降
   */
  targetFourStatus: number;
  /**
   * 指标4上浮或下降值
   */
  targetFourCompareValue: number;
  /**
   * 启用状态 1启用 2未启用
   */
  status: number;
  /**
   * 周期 1 月  2年
   */
  periodName: string;
  /**
   * 周期值
   */
  periodValue: number;
  /**
   * 0未删除   1已删除
   */
  del: number;
}
export interface TrafficIndexForm extends BaseEntity {
  /**
   * 主键id
   */
  id?: string | number;
  /**
   * 模块名称
   */
  modeName?: string;
  /**
   * 指标1名称
   */
  targetOneName?: string;
  /**
   * 指标1值
   */
  targetOneValue?: number;
  /**
   * 指标1单位
   */
  targetOneUnit?: string;
  /**
   * 指标1状态 1 上浮 2下降
   */
  targetOneStatus?: number;
  /**
   * 指标1上浮或下降值
   */
  targetOneCompareValue?: number;
  /**
   * 指标2名称
   */
  targetTwoName?: string;
  /**
   * 指标2值
   */
  targetTwoValue?: number;
  /**
   * 指标2单位
   */
  targetTwoUnit?: string;
  /**
   * 指标2状态 1 上浮 2下降
   */
  targetTwoStatus?: number;
  /**
   * 指标2上浮或下降值
   */
  targetTwoCompareValue?: number;
  /**
   * 指标3名称
   */
  targetThreeName?: string;
  /**
   * 指标3值
   */
  targetThreeValue?: number;
  /**
   * 指标3单位
   */
  targetThreeUnit?: string;
  /**
   * 指标3状态 1 上浮 2下降
   */
  targetThreeStatus?: number;
  /**
   * 指标3上浮或下降值
   */
  targetThreeCompareValue?: number;
  /**
   * 指标4名称
   */
  targetFourName?: string;
  /**
   * 指标4值
   */
  targetFourValue?: number;
  /**
   * 指标4单位
   */
  targetFourUnit?: string;
  /**
   * 指标4状态 1 上浮 2下降
   */
  targetFourStatus?: number;
  /**
   * 指标4上浮或下降值
   */
  targetFourCompareValue?: number;
  /**
   * 启用状态 1启用 2未启用
   */
  status?: number;
  /**
   * 周期 1 月  2年
   */
  periodName?: string;
  /**
   * 周期值
   */
  periodValue?: number;
  /**
   * 0未删除   1已删除
   */
  del?: number;
}
export interface TrafficIndexQuery extends PageQuery {
  /**
   * 模块名称
   */
  modeName?: string;
  /**
   * 指标1名称
   */
  targetOneName?: string;
  /**
   * 指标1值
   */
  targetOneValue?: number;
  /**
   * 指标1单位
   */
  targetOneUnit?: string;
  /**
   * 指标1状态 1 上浮 2下降
   */
  targetOneStatus?: number;
  /**
   * 指标1上浮或下降值
   */
  targetOneCompareValue?: number;
  /**
   * 指标2名称
   */
  targetTwoName?: string;
  /**
   * 指标2值
   */
  targetTwoValue?: number;
  /**
   * 指标2单位
   */
  targetTwoUnit?: string;
  /**
   * 指标2状态 1 上浮 2下降
   */
  targetTwoStatus?: number;
  /**
   * 指标2上浮或下降值
   */
  targetTwoCompareValue?: number;
  /**
   * 指标3名称
   */
  targetThreeName?: string;
  /**
   * 指标3值
   */
  targetThreeValue?: number;
  /**
   * 指标3单位
   */
  targetThreeUnit?: string;
  /**
   * 指标3状态 1 上浮 2下降
   */
  targetThreeStatus?: number;
  /**
   * 指标3上浮或下降值
   */
  targetThreeCompareValue?: number;
  /**
   * 指标4名称
   */
  targetFourName?: string;
  /**
   * 指标4值
   */
  targetFourValue?: number;
  /**
   * 指标4单位
   */
  targetFourUnit?: string;
  /**
   * 指标4状态 1 上浮 2下降
   */
  targetFourStatus?: number;
  /**
   * 指标4上浮或下降值
   */
  targetFourCompareValue?: number;
  /**
   * 启用状态 1启用 2未启用
   */
  status?: number;
  /**
   * 周期 1 月  2年
   */
  periodName?: string;
  /**
   * 周期值
   */
  periodValue?: number;
  /**
   * 0未删除   1已删除
   */
  del?: number;
    /**
     * 日期范围参数
     */
    params?: any;
}
src/views/ti/trafficIndex/index.vue
New file
@@ -0,0 +1,476 @@
<template>
  <div class="p-2">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div class="search" v-show="showSearch">
        <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
          <el-form-item label="模块名称" prop="modeName">
            <el-input v-model="queryParams.modeName" placeholder="请输入模块名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标1名称" prop="targetOneName">
            <el-input v-model="queryParams.targetOneName" placeholder="请输入指标1名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标1值" prop="targetOneValue">
            <el-input v-model="queryParams.targetOneValue" placeholder="请输入指标1值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标1单位" prop="targetOneUnit">
            <el-input v-model="queryParams.targetOneUnit" placeholder="请输入指标1单位" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标1上浮或下降值" prop="targetOneCompareValue">
            <el-input v-model="queryParams.targetOneCompareValue" placeholder="请输入指标1上浮或下降值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标2名称" prop="targetTwoName">
            <el-input v-model="queryParams.targetTwoName" placeholder="请输入指标2名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标2值" prop="targetTwoValue">
            <el-input v-model="queryParams.targetTwoValue" placeholder="请输入指标2值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标2单位" prop="targetTwoUnit">
            <el-input v-model="queryParams.targetTwoUnit" placeholder="请输入指标2单位" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标2上浮或下降值" prop="targetTwoCompareValue">
            <el-input v-model="queryParams.targetTwoCompareValue" placeholder="请输入指标2上浮或下降值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标3名称" prop="targetThreeName">
            <el-input v-model="queryParams.targetThreeName" placeholder="请输入指标3名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标3值" prop="targetThreeValue">
            <el-input v-model="queryParams.targetThreeValue" placeholder="请输入指标3值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标3单位" prop="targetThreeUnit">
            <el-input v-model="queryParams.targetThreeUnit" placeholder="请输入指标3单位" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标3上浮或下降值" prop="targetThreeCompareValue">
            <el-input v-model="queryParams.targetThreeCompareValue" placeholder="请输入指标3上浮或下降值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标4名称" prop="targetFourName">
            <el-input v-model="queryParams.targetFourName" placeholder="请输入指标4名称" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标4值" prop="targetFourValue">
            <el-input v-model="queryParams.targetFourValue" placeholder="请输入指标4值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标4单位" prop="targetFourUnit">
            <el-input v-model="queryParams.targetFourUnit" placeholder="请输入指标4单位" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="指标4上浮或下降值" prop="targetFourCompareValue">
            <el-input v-model="queryParams.targetFourCompareValue" placeholder="请输入指标4上浮或下降值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="周期 1 月  2年" prop="periodName">
            <el-input v-model="queryParams.periodName" placeholder="请输入周期 1 月  2年" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="周期值" prop="periodValue">
            <el-input v-model="queryParams.periodValue" placeholder="请输入周期值" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="0未删除   1已删除" prop="del">
            <el-input v-model="queryParams.del" placeholder="请输入0未删除   1已删除" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </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="主键id" align="center" prop="id" v-if="true" />
        <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>
    <!-- 添加或修改交通指数对话框 -->
    <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';
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 queryFormRef = ref<ElFormInstance>();
const trafficIndexFormRef = ref<ElFormInstance>();
const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});
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 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();
});
</script>