Newer
Older
KaiFengPC / src / views / spongePerformance / financialperformance / publicsatisfaction / index.vue
@zhangdeliang zhangdeliang on 23 May 13 KB 初始化项目
<template>
  <!-- <>群众满意度 -->
  <div class="publicContainer">
    <!-- 操作栏 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true">
      <el-form-item label="年份" prop="publishTime">
        <el-date-picker value-format="YYYY" v-model="queryParams.examineYear" type="year" placeholder="请选择年份" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="searchData">搜索</el-button>
        <el-button icon="Refresh" @click="resetData">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <el-table :data="tableData" v-loading="tableLoading" :max-height="600">
      <el-table-column type="index" width="55" label="序号" />
      <el-table-column label="调查年度" prop="examineYear" />
      <el-table-column label="满意问卷数" prop="satisfyNum" />
      <el-table-column label="问卷样本数" prop="totalNum" />
      <el-table-column label="满意度%" prop="satisfyPercent" />
      <el-table-column label="较上一年" prop="compareLastYear">
        <template #default="scope">
          <span
            :style="{
              color:
                scope.row.compareLastYear == '-1'
                  ? 'red'
                  : scope.row.compareLastYear == '1'
                  ? 'rgb(16, 142, 233)'
                  : scope.row.compareLastYear == '0'
                  ? 'orange'
                  : scope.row.compareLastYear == ''
                  ? ''
                  : '',
            }"
            >{{
              scope.row.compareLastYear == '-1'
                ? '有所下降'
                : scope.row.compareLastYear == '1'
                ? '有所提升'
                : scope.row.compareLastYear == '0'
                ? '持平'
                : scope.row.compareLastYear == ''
                ? ''
                : ''
            }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="评价结果" prop="reachStandard">
        <template #default="{ row }">
          <span
            :style="{
              color: row.reachStandard == '0' ? 'red' : row.reachStandard == '1' ? 'lime' : '',
            }"
          >
            <el-tag v-if="row.reachStandard === ''" type="warning">未填报</el-tag>
            <el-tag v-else-if="row.reachStandard === 102" type="warning">无法评价</el-tag>
            <el-tag v-else :type="row.reachStandard === 1 ? 'success' : 'error'">{{ row.reachStandard === 1 ? '达标' : '未达标' }}</el-tag>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="佐证材料" prop="fileList" show-overflow-tooltip>
        <template #default="{ row }">
          <p style="color: rgb(16, 142, 233)" @click="handlePreview(item)" v-for="item in row.fileList" :key="item.id" :title="item.name">
            {{ item.name }}
          </p>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" prop="createTime" />
      <el-table-column label="操作" show-overflow-tooltip width="250">
        <template #default="{ row }">
          <el-button link icon="View" type="primary" @click="checkDetail(row)">详情</el-button>
          <el-button type="warning" icon="Edit" @click="handleCount(row)"> 满意度统计 </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getDataList"
    />
    <!-- 添加 修改 查看彈框 -->
    <el-dialog :title="dialogTitle" v-model="showDialog" width="600px" :close-on-click-modal="false">
      <el-form ref="ruleForm" :model="formData" :rules="formRules" label-width="auto" :disabled="isDisab">
        <el-form-item label="问卷样本数:" prop="totalNum">
          <el-input-number
            :min="0"
            v-model="formData.totalNum"
            placeholder="请输入问卷样本数"
            controls-position="right"
            style="width: 100%"
            clearable
            precision="Number"
          />
        </el-form-item>
        <el-form-item label="考核年度:" prop="examineYear">
          <el-date-picker value-format="YYYY" v-model="formData.examineYear" type="year" placeholder="请选择考核年度" style="width: 100%" />
        </el-form-item>
        <el-form-item label="满意问卷数:" prop="satisfyNum">
          <el-input-number
            :min="0"
            v-model="formData.satisfyNum"
            placeholder="请输入满意问卷数"
            controls-position="right"
            style="width: 100%"
            clearable
            precision="Number"
          />
        </el-form-item>
        <el-form-item label="佐证材料:" style="width: 93%">
          <ImageFileUpload v-model:saveFileArr="formData.fileSaveRequestList" :listType="'text'" :refType="'publish_satisfy'" />
        </el-form-item>
        <el-form-item label="满意度,%:" prop="satisfyPercent" v-if="hiddentext">
          <el-input v-model="formData.satisfyPercent" style="width: 100%" clearable :disabled="hiddendisabled" />
        </el-form-item>
        <el-form-item label="上年度满意度,%:" prop="lastYearSatisfyPercent" v-if="hiddentext">
          <el-input v-model="formData.lastYearSatisfyPercent" style="width: 100%" clearable :disabled="hiddendisabled" />
        </el-form-item>
        <el-form-item label="较上一年:" prop="compareLastYear" v-if="hiddentext">
          <div
            :style="{
              color:
                formData.compareLastYear == '-1'
                  ? 'red'
                  : formData.compareLastYear == '1'
                  ? 'rgb(16, 142, 233)'
                  : formData.compareLastYear == '0'
                  ? 'orange'
                  : formData.compareLastYear == ''
                  ? ''
                  : '',
            }"
          >
            {{
              formData.compareLastYear == '-1'
                ? '有所下降'
                : formData.compareLastYear == '1'
                ? '有所提升'
                : formData.compareLastYear == '0'
                ? '持平'
                : formData.compareLastYear == ''
                ? ''
                : ''
            }}
          </div>
        </el-form-item>
        <el-form-item label="是否达标:" prop="reachStandard" v-if="hiddentext">
          <div
            :style="{
              color: formData.reachStandard == '0' ? 'red' : formData.reachStandard == '1' ? 'rgb(16, 142, 233)' : '',
            }"
          >
            {{ formData.reachStandard == '0' ? '不达标' : formData.reachStandard == '1' ? '达标' : '' }}
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm" v-show="!isDisab">保 存</el-button>
          <el-button @click="cancel">关闭</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 满意度统计 -->
    <el-dialog title="满意度统计" v-model="dialogCount" width="1200px" append-to-body>
      <!-- <el-button type="warning" plain icon="Download" @click="handleExport">导出</el-button> -->
      <!-- <el-divider /> -->
      <div class="satisfied">
        <div class="part" v-for="(item, index) in tableDataCount" :key="item.id">
          <p>
            <span>{{ index + 1 }},题目名称:{{ item.problemName }},</span>
            <span>
              题目类型:{{
                item.problemType == 'radio'
                  ? '单选'
                  : item.problemType == 'checkbox'
                  ? '多选'
                  : item.problemType == 'answers'
                  ? '简答题'
                  : '--'
              }}
            </span>
            <span>,本题有效填写人次:{{ item.fillTimes || 0 }}</span>
          </p>
          <el-table :data="item.problemOptionList">
            <el-table-column label="选项名称" prop="optionName" />
            <el-table-column label="问题选项填报次数" prop="optionTimes" />
            <el-table-column label="问题选项填报百分比" prop="percentage" />
          </el-table>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script setup name="publicsatisfaction">
import {
  publicSatisAdd,
  publicSatisDelete,
  publicSatisEdit,
  publicSatispaging,
  performanceYear,
} from '@/api/spongePerformance/financialperformance';
import { quesNaireCount, satisfactionStatisticsByYear } from '@/api/publicService/index';
import { ElMessageBox } from 'element-plus';
import ImageFileUpload from '@/components/ImageFileUpload'; //图片文件上传

const { proxy } = getCurrentInstance();
const dialogCount = ref(false);
const tableDataCount = ref([]);
const tableLoading = ref(true);
const dialogTitle = ref('');
const showDialog = ref(false);
const tableData = ref([]);
const uploadList = ref([]);
const isDisab = ref(false);
const hiddentext = ref(false);
const hiddendisabled = ref(false);
const total = ref(0);
const Dbssz = ref([]);
const AllData = reactive({
  formData: {
    totalNum: '',
    examineYear: '',
    satisfyNum: '',
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  formRules: {
    totalNum: [{ required: true, message: '请输入问卷样本数', trigger: 'blur' }],
    examineYear: [{ required: true, message: '请选择请选择考核年度', trigger: 'blur' }],
    satisfyNum: [{ required: true, message: '请输入满意问卷数', trigger: 'blur' }],
  },
});
function searchData() {
  queryParams.value.pageNum = 1;
  getDataList();
}
//重置
function resetData() {
  queryParams.value.examineYear = '';
  proxy.resetForm('queryRef');
  searchData();
}
/** 表单重置 */
function resetForm() {
  formData.value = {
    totalNum: undefined,
    examineYear: undefined,
    satisfyNum: undefined,
    fileSaveRequestList: [],
  };
  proxy.resetForm('ruleForm');
  uploadList.value = [];
}
const { queryParams, formData, formRules } = toRefs(AllData);
/** 新增按钮操作 */
function addData() {
  resetForm();
  hiddentext.value = false;
  isDisab.value = false;
  showDialog.value = true;
  dialogTitle.value = '新增群众满意度';
}
/** 取消按钮 */
function cancel() {
  showDialog.value = false;
  resetForm();
  getDataList();
}

/** 文件上传 */
function handlePreview(file) {
  console.log(file);
  return ElMessageBox.confirm(`下载此文件: ${file.name}?`).then(
    () => window.open(file.url),
    () => false
  );
}
const DataYaer = async () => {
  performanceYear().then(res => {
    if (res.code == 200) {
      Dbssz.value = res.data;
      let arr = [];
      Dbssz.value.forEach((element, index) => {
        let obj = {};
        obj = { name: element, value: index };
        arr.push(obj);
        Dbssz.value = arr;
        // console.log(obj, arr, 'obj');
        // console.log(Dbssz.value, ' Dbssz.value Dbssz.value');
      });
    }
  });
};

/** 查询列表 */
const getDataList = async () => {
  tableLoading.value = true;
  const res = await publicSatispaging(queryParams.value);
  tableData.value = res.data;
  total.value = res.total;
  tableLoading.value = false;
};
/** 新增弹框 修改弹框 提交按钮 */
async function submitForm() {
  proxy.$refs['ruleForm'].validate(valid => {
    if (valid) {
      uploadList.value.forEach(element => {
        if (element.hasOwnProperty('response')) {
          element.response.data.refType = 'publish_satisfy';
          formData.value.fileSaveRequestList.push(element.response.data);
        } else {
          formData.value.fileSaveRequestList.push(element);
        }
      });
      if (formData.value.id != undefined) {
        publicSatisEdit(formData.value).then(() => {
          proxy.$modal.msgSuccess('修改成功');
          showDialog.value = false;
          getDataList();
        });
      } else {
        console.log(formData.value, 'formData.value');
        publicSatisAdd(formData.value).then(() => {
          proxy.$modal.msgSuccess('新增成功');
          showDialog.value = false;
          getDataList();
        });
      }
    }
  });
}
//表格修改
function editData(row) {
  isDisab.value = false;
  hiddentext.value = true;
  showDialog.value = true;
  hiddendisabled.value = true;
  dialogTitle.value = '修改群众满意度';
  formData.value = { ...row };
  formData.value.examineYear = String(row.examineYear);
  formData.value.fileSaveRequestList = row.fileList;
}
// 表格删除
function deleteData(row) {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await publicSatisDelete(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getDataList();
    })
    .catch(() => {});
}
//详情按钮
function checkDetail(row) {
  dialogTitle.value = '查看群众满意度';
  hiddentext.value = true;
  isDisab.value = true;
  showDialog.value = true;
  formData.value = { ...row };
  formData.value.examineYear = String(row.examineYear);
  formData.value.fileSaveRequestList = row.fileList;
}
// 满意度统计
function handleCount(row) {
  let years = row.examineYear;
  satisfactionStatisticsByYear(years).then(res => {
    tableDataCount.value = res.data.problemConfigList;
    dialogCount.value = true;
  });
}
/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    'system/post/export',
    {
      ...queryParams.value,
    },
    `问卷调查满意度统计 ${new Date().getTime()}.xlsx`
  );
}
onMounted(() => {
  getDataList();
  DataYaer();
});
</script>
<style scoped lang="scss"></style>