Newer
Older
Nanping_sponge_JXKH / src / views / financialperformance / publicsatisfaction / publicsatisfaction.vue
<template>
  <!-- <>群众满意度 -->
  <div class="app-container">
    <!-- 操作栏 -->
    <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-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Plus" @click="addData">新增</el-button>
      </el-col>
    </el-row>
    <!-- 表格 -->
    <el-table :data="tableData" v-loading="tableLoading" stripe :max-height="600" border>
      <el-table-column type="index" width="55" label="序号" fixed="left" />
      <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" fixed="right">
        <template #default="{ row }">
          <el-button link icon="View" type="primary" @click="checkDetail(row)">详情</el-button>
          <el-button link icon="Edit" type="warning" @click="editData(row)">修改</el-button>
          <el-button link icon="Delete" type="danger" @click="deleteData(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="70%" :close-on-click-modal="false">
      <el-form ref="ruleForm" :model="formData" :rules="formRules" label-width="auto" :disabled="isDisab">
        <el-row>
          <el-form-item label="问卷样本数:" prop="totalNum" style="width: 45%">
            <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" style="width: 45%">
            <!-- <el-select clearable v-model="formData.examineYear" class="m-2" placeholder="请选择" size="mini">
              <el-option v-for="item in Dbssz" :key="item.value" :label="item.name" :value="item.name" />
            </el-select> -->
            <el-date-picker value-format="YYYY" v-model="formData.examineYear" type="year" placeholder="请选择考核年度" />
          </el-form-item>
          <el-form-item label="满意问卷数:" prop="satisfyNum" style="width: 45%">
            <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" style="width: 45%" v-if="hiddentext">
            <el-input v-model="formData.satisfyPercent" style="width: 100%" clearable :disabled="hiddendisabled" />
          </el-form-item>
          <el-form-item label="上年度满意度,%:" prop="lastYearSatisfyPercent" style="width: 45%" v-if="hiddentext">
            <el-input v-model="formData.lastYearSatisfyPercent" style="width: 100%" clearable :disabled="hiddendisabled" />
          </el-form-item>
          <el-form-item label="较上一年:" prop="compareLastYear" style="width: 45%" 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" style="width: 45%" 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-row>
      </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>
  </div>
</template>
<script setup name="publicsatisfaction">
import {
  publicSatisList,
  publicSatisAdd,
  publicSatisDelete,
  publicSatisEdit,
  publicSatispaging,
  performanceYear,
} from '@/api/financialperformance';
import { getToken } from '@/utils/auth';
import { ElMessageBox } from 'element-plus';
import ImageFileUpload from '@/components/ImageFileUpload'; //图片文件上传

const { proxy } = getCurrentInstance();
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();
}
const uploadHeader = ref({
  Authorization: 'Bearer ' + getToken(),
});
/** 文件上传 */
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.fileSaveRequestList = row.fileList;

}
onMounted(() => {
  getDataList();
  DataYaer();
});
</script>
<style scoped lang="scss"></style>