Newer
Older
KaiFengPC / src / views / spongePerformance / ManagingPerformance / completionstatus / 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="handleQuery"
          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="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</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="handleAdd" v-hasPermi="['system:post:add']">新增</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table :data="dataList" v-loading="loading" :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 }">
          <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="200">
        <template #default="{ row }">
          <el-button link icon="View" type="primary" @click="handleView(row, 'view')">详情</el-button>
          <el-button link icon="Edit" type="warning" @click="handleUpdate(row, 'edit')">修改</el-button>
          <el-button type="danger" link @click="handleDelete(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="getList"
    />
    <!-- 添加 修改 查看彈框 -->
    <el-dialog :title="title" v-model="open" width="600px" :close-on-click-modal="false">
      <el-form ref="ruleForm" :model="form" :rules="rules" label-width="auto" :disabled="isDisab" class="publicForm">
        <el-row>
          <el-form-item label="立法及长效机制:" prop="regulationName" style="width: 100%">
            <el-input v-model="form.regulationName" placeholder="请输入立法及长效机制" clearable />
          </el-form-item>
          <el-form-item label="类型:" prop="examineFileType" style="width: 100%">
            <el-select clearable v-model="form.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" style="width: 100%">
            <el-date-picker
              style="width: 100%"
              clearable
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
              v-model="form.publishTime"
              type="date"
              placeholder="请选择发布时间"
            />
          </el-form-item>
          <el-form-item label="附件:" style="width: 100%" prop="fileList">
            <ImageFileUpload v-model:saveFileArr="form.fileSaveRequestList" :listType="'text'" :fileType="['*']" :refType="'lfjcxjz'" />
          </el-form-item>
          <el-form-item label="附件说明:" prop="descCripion" style="width: 100%">
            <el-input type="textarea" v-model="form.descCripion" placeholder="请输入附件说明" clearable />
          </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="completionstatus">
import ImageFileUpload from '@/components/ImageFileUpload/index.vue'; //图片文件上传
import { ElMessageBox } from 'element-plus';
import {
  performanceUserId,
  performanceAdd,
  performanceDelete,
  performancedetails,
  performancepaging,
  performanceEdit,
  FileSystemList,
} from '@/api/spongePerformance/ManagingPerformance';

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 open = ref(false);
const showSearch = ref(true);
const loading = ref(true);
const total = ref(0);
const title = ref('');
const dataList = ref([]);
const fileList1 = ref([]);
const AllData = reactive({
  publishTime: '',
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    examineFileType: '',
    regulationName: '',
    examineType: 'lfjcxjz',
    beginTime: undefined,
    endTime: undefined,
  },
  rules: {
    regulationName: [{ required: true, message: '请输入立法及长效机制', trigger: 'blur' }],
    examineFileType: [{ required: true, message: '请选择类型', trigger: 'blur' }],
    publishTime: [{ required: true, message: '请选择发布时间', trigger: 'blur' }],
  },
});
const { queryParams, form, rules } = toRefs(AllData);

/** 表单重置 */
function reset() {
  form.value = {
    regulationName: undefined,
    examineFileType: undefined,
    publishTime: undefined,
    fileSaveRequestList: [],
    examineType: 'lfjcxjz',
  };
  proxy.resetForm('ruleForm');
  fileList1.value = [];
}
/** 新增按钮操作 */
function handleAdd() {
  reset();
  isDisab.value = false;
  open.value = true;
  title.value = '新增立法及长效机制';
}
//搜索
function handleQuery() {
  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;
  getList();
}
//重置
function resetQuery() {
  AllData.publishTime = [];
  proxy.resetForm('queryRef');
  // queryParams.value = { pageNum: 1, pageSize: 10 };
  handleQuery();
}
const uploadHeader = ref({
  Authorization: 'Bearer ' + getToken(),
});
/** 文件上传 */
function handlePreview(file) {
  console.log(file);
  return ElMessageBox.confirm(`下载此文件: ${file.name}?`).then(
    () => window.open(file.url),
    () => false
  );
}

/** 搜索列表 */
const getList = async () => {
  loading.value = true;
  if (AllData.publishTime) {
    queryParams.value.beginTime = AllData.publishTime[0];
    queryParams.value.endTime = AllData.publishTime[1];
  }
  const res = await performancepaging(queryParams.value);
  dataList.value = res.data;
  total.value = res.total;
  loading.value = false;
};
/** 新增弹框 修改弹框 提交按钮 */
async function submitForm() {
  proxy.$refs['ruleForm'].validate(valid => {
    if (valid) {
      // form.value.examineType='lfjcxjz'
      if (form.value.id != undefined) {
        performanceEdit(form.value).then(() => {
          console.log(form.value, 'form.value');
          proxy.$modal.msgSuccess('修改成功');
          open.value = false;
          getList();
        });
      } else {
        performanceAdd(form.value).then(() => {
          proxy.$modal.msgSuccess('新增成功');
          open.value = false;
          getList();
        });
      }
    }
  });
}
//表格修改
function handleUpdate(row) {
  isDisab.value = false;
  open.value = true;
  title.value = '修改立法及长效机制';
  form.value = { ...row };
  form.value.fileSaveRequestList = [];
  form.value.fileSaveRequestList = row.fileList;
}
// 表格删除
function handleDelete(row) {
  console.log(111);
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await performanceDelete(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getList();
    })
    .catch(() => {});
}
//详情按钮
function handleView(row) {
  title.value = '查看立法及长效机制';
  isDisab.value = true;
  open.value = true;
  form.value = { ...row };
  fileList1.value = [];
  form.value.fileSaveRequestList = row.fileList;
  // 获取文件列表
  FileSystemList({
    refId: row.id,
    refType: 'lfjcxjz',
  }).then(response => {
    console.log(response.data, 'response.data');
    response.data.forEach(element => {
      fileList1.value.push(element);
    });
  });
}
/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
  getList();
}
getList();
</script>
<style scoped lang="scss"></style>