Newer
Older
KaiFengPC / src / views / spongePerformance / financialperformance / fundrelease / index.vue
@鲁yixuan 鲁yixuan on 19 Aug 8 KB updata
<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="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" />
      <el-table-column label="发布时间" prop="publishTime" />
      <el-table-column label="修改时间" prop="updateTime" />
      <el-table-column label="修改人" prop="updateBy" />
      <el-table-column label="附件" prop="fileList" show-overflow-tooltip>
        <template #default="{ row }">
          <span
            style="color: rgb(16, 142, 233)"
            @click="handlePreview(item)"
            v-for="item in row.fileList"
            :key="item.id"
            :title="item.name"
          >
            {{ item.name }}
          </span>
        </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-form-item label="资金的协同性:" prop="regulationName">
          <el-input v-model="formData.regulationName" placeholder="请输入资金的协同性" clearable />
        </el-form-item>
        <el-form-item label="发布时间:" prop="publishTime">
          <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: 93%">
          <ImageFileUpload
            v-model:saveFileArr="formData.fileSaveRequestList"
            :listType="'text'"
            :refType="'zjxtx'"
            :fileType="['pdf', 'png', 'jpg', 'jpeg']"
          />
        </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>
  </div>
</template>
<script setup name="fundrelease">
import { ElMessageBox } from 'element-plus';
import { performanceAdd, performanceDelete, performancepaging, performanceEdit } from '@/api/spongePerformance/ManagingPerformance';
import ImageFileUpload from '@/components/ImageFileUpload'; //图片文件上传
import { getToken } from '@/utils/auth';
const { proxy } = getCurrentInstance();
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 uploadList = ref([]);
const AllData = reactive({
  publishTime: '',
  formData: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    examineFileType: '',
    regulationName: '',
    examineType: 'zjxtx',
  },
  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: 'zjxtx',
  };
  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) {
  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>