Newer
Older
KaiFengPC / src / views / publicService / publicmind.vue
@鲁yixuan 鲁yixuan on 5 Jul 3 KB update
<template>
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="公众意见" prop="opinion" style="width: 300px">
        <el-input v-model="queryParams.opinion" placeholder="请输入" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="年份" style="width: 200px">
        <el-date-picker
          type="year"
          v-model="queryParams.publishTime"
          value-format="YYYY"
          placeholder="请选择年"
          style="width: 100%"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button type="success" icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 按钮区域 -->
    <el-row :gutter="10" class="mb8">
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table v-loading="tableLoading" :data="tableData" max-height="650">
      <el-table-column label="用户头像" prop="headImg">
        <template #default="scope">
          <el-image :src="scope.row.headImg" style="width: 100px; height: 100px; border-radius: 50px"></el-image>
        </template>
      </el-table-column>
      <el-table-column label="用户昵称" prop="wechatName" />
      <el-table-column label="日期" prop="publishTime" />
      <el-table-column label="上传图片" prop="filelist">
        <template #default="scope">
          <el-image style="width: 60px; height: 60px; margin: 5px" v-for="i in scope.row.filelist" :src="i.url" :preview-src-list="[i.url]">
          </el-image>
        </template>
      </el-table-column>
      <el-table-column label="公众意见" prop="opinion" width="650" />
    </el-table>
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getDataList"
    />
  </div>
</template>

<script setup name="公众意见">
import { peopleOpinionPage, specialNavAdd, specialNavDel, specialNavDetail, specialNavEdit } from '@/api/publicService/index';
import ImageFileUpload from '@/components/ImageFileUpload/index.vue'; //图片文件上传
import defaultImg from '@/assets/images/login/user.png';

const { proxy } = getCurrentInstance();

const tableData = ref([]);
const tableLoading = ref(true);
const total = ref(0);
const showSearch = ref(true);

const allData = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    opinion: undefined,
    publishTime: ref(proxy.moment(new Date()).format('YYYY')),
  },
});
const { queryParams } = toRefs(allData);

/** 获取查询数据列表 */
function getDataList() {
  tableLoading.value = true;
  peopleOpinionPage(queryParams.value).then(response => {
    tableData.value = response.data;
    total.value = response.total;
    tableLoading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getDataList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  queryParams.value.publishTime = ref(proxy.moment(new Date()).format('YYYY'));
  handleQuery();
}

onMounted(() => {
  getDataList();
});
</script>