Newer
Older
KaiFengPC / src / views / spongePerformance / ManagingPerformance / performanceappraisal / index.vue
@zhangdeliang zhangdeliang 22 days ago 9 KB update
<template>
  <!-- 绩效考核制度 -->
  <div class="publicContainer">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="名称:" prop="regulationName">
        <el-input
          v-model="queryParams.regulationName"
          placeholder="请输入关键字"
          clearable
          @keyup.enter="searchData"
          style="width: 240px"
        />
      </el-form-item>
      <el-form-item label="类型:" prop="examineFileType">
        <el-select clearable v-model="queryParams.examineFileType" class="m-2" placeholder="请选择" size="mini">
          <el-option v-for="item in examine_file_type" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>

      <el-form-item label="发布时间" prop="publishTime">
        <el-date-picker
          style="width: 240px"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD"
          v-model="AllData.publishTime"
          type="daterange"
          unlink-panels
          range-separator="至"
          start-placeholder="开始时间"
          end-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" v-hasPermi="['system:post:add']">新增</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table :data="tableData" v-loading="tableLoading" :max-height="600">
      <el-table-column type="index" width="55" label="序号" />
      <el-table-column label="绩效考核制度" prop="regulationName" show-overflow-tooltip />
      <el-table-column label="类型" prop="examineFileType" width="80">
        <template #default="{ row }">
          <dict-tag :options="examine_file_type" :value="row.examineFileType" />
        </template>
      </el-table-column>
      <el-table-column label="发布时间" prop="publishTime" width="110" />
      <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="操作" show-overflow-tooltip width="250">
        <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="600px" :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="regulationName" style="width: 100%">
            <el-input v-model="formData.regulationName" placeholder="请输入绩效考核制度" clearable />
          </el-form-item>
          <el-form-item label="类型:" prop="examineFileType" style="width: 100%">
            <el-select clearable v-model="formData.examineFileType" placeholder="请选择" size="mini" style="width: 100%">
              <el-option v-for="item in examine_file_type" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="发布时间:" prop="publishTime" style="width: 100%">
            <el-date-picker
              style="width: 100%"
              clearable
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
              v-model="formData.publishTime"
              type="date"
              placeholder="请选择发布时间"
            />
          </el-form-item>
          <el-form-item label="附件:" style="width: 100%">
            <ImageFileUpload
              v-model:saveFileArr="formData.fileSaveRequestList"
              :listType="'text'"
              :refType="'default'"
              :fileType="['pdf', 'png', 'jpg', 'jpeg']"
            />
          </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="performanceappraisal">
import { ElMessageBox } from 'element-plus';
import {
  performanceUserId,
  performanceAdd,
  performanceDelete,
  performancepaging,
  performanceEdit,
  FileSystemList,
  performancedetails,
} from '@/api/spongePerformance/ManagingPerformance';
import ImageFileUpload from '@/components/ImageFileUpload'; //图片文件上传
import { getToken } from '@/utils/auth';
const { proxy } = getCurrentInstance();
const { examine_file_type, examine_type } = proxy.useDict('examine_file_type', 'examine_type');
const isDisab = ref(false);
const showDialog = ref(false);
const showSearch = ref(true);
const tableLoading = ref(true);
const total = ref(0);
const dialogTitle = ref('');
const tableData = ref([]);
const AllData = reactive({
  publishTime: '',
  formData: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    examineFileType: '',
    regulationName: '',
    examineType: 'default',
  },
  formRules: {
    regulationName: [{ required: true, message: '请输入规划管控制度', trigger: 'blur' }],
    publishTime: [{ required: true, message: '请选择发布时间', trigger: 'blur' }],
  },
});
const { queryParams, formData, formRules } = toRefs(AllData);

/** 表单重置 */
function resetForm() {
  formData.value = {
    regulationName: undefined,
    examineFileType: undefined,
    publishTime: undefined,
    fileSaveRequestList: [],
    examineType: 'default',
  };
  proxy.resetForm('ruleForm');
}
/** 新增按钮操作 */
function addData() {
  resetForm();
  isDisab.value = false;
  showDialog.value = true;
  dialogTitle.value = '新增绩效考核制度';
}
//搜索
function searchData() {
  if (AllData.publishTime) {
    queryParams.value.beginTime = AllData.publishTime[0];
    queryParams.value.endTime = AllData.publishTime[1];
  } else {
    queryParams.value.beginTime = '';
    queryParams.value.endTime = '';
  }
  queryParams.value.pageNum = 1;
  getDataList();
}
//重置
function resetData() {
  AllData.publishTime = [];
  proxy.resetForm('queryRef');
  searchData();
}
const uploadHeader = ref({
  Authorization: 'Bearer ' + getToken(),
});
/** 文件上传 */
function handlePreview(file) {
  console.log(file);
  return ElMessageBox.confirm(`下载此文件: ${file.name}?`).then(
    () => window.open(file.url),
    () => false
  );
}

/** 搜索列表 */
const getDataList = async () => {
  tableLoading.value = true;
  /** 搜索列表 */
  tableLoading.value = true;
  if (AllData.publishTime) {
    queryParams.value.beginTime = AllData.publishTime[0];
    queryParams.value.endTime = AllData.publishTime[1];
  }
  const res = await performancepaging(queryParams.value);
  tableData.value = res.data;
  total.value = res.total;
  tableLoading.value = false;
};
/** 新增弹框 修改弹框 提交按钮 */
async function submitForm() {
  proxy.$refs['ruleForm'].validate(valid => {
    if (valid) {
      if (formData.value.id != undefined) {
        performanceEdit(formData.value).then(() => {
          console.log(formData.value, 'formData.value');
          proxy.$modal.msgSuccess('修改成功');
          showDialog.value = false;
          getDataList();
        });
      } else {
        performanceAdd(formData.value).then(() => {
          proxy.$modal.msgSuccess('新增成功');
          showDialog.value = false;
          getDataList();
        });
      }
    }
  });
}
//表格修改
function editData(row) {
  isDisab.value = false;
  showDialog.value = true;
  dialogTitle.value = '修改绩效考核制度';
  formData.value = { ...row };
  formData.value.fileSaveRequestList = row.fileList;
}
// 表格删除
function deleteData(row) {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await performanceDelete(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getDataList();
    })
    .catch(() => {});
}
//详情按钮
function checkDetail(row) {
  console.log(row, 33);
  dialogTitle.value = '查看绩效考核制度';
  isDisab.value = true;
  showDialog.value = true;
  formData.value = { ...row };
  formData.value.fileSaveRequestList = row.fileList;
}

/** 取消按钮 */
function cancel() {
  showDialog.value = false;
  resetForm();
  getDataList();
}
onMounted(() => {
  getDataList();
});
</script>
<style scoped lang="scss"></style>