Newer
Older
KaiFengPC / src / views / project / compensation / recordsReward.vue
@鲁yixuan 鲁yixuan on 29 Aug 12 KB updata
<template>
  <div class="completionAcceptance">
    <div class="top">
      <el-form ref="ruleForm" :model="form" v-show="showSearch" inline>
        <el-form-item label="项目名称:" prop="projectName">
          <el-input style="width: 200px" clearable v-model="form.projectName" placeholder="请输入项目名称"></el-input>
        </el-form-item>
        <el-form-item label="项目类型:" prop="projectTypeId">
          <el-select v-model="form.projectTypeId" placeholder="请选择项目类型" style="width: 200px">
            <el-option label="全部" value="" />
            <el-option v-for="dict in projectTypes" :key="dict.id" :label="dict.projectTypeName" :value="dict.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="审核状态:">
          <el-select v-model="tableData.status" placeholder="请选择审核状态" clearable>
            <el-option v-for="dict in dangerous_status" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="申请时间:" prop="registryDate">
          <el-date-picker
            style="width: 200px"
            clearable
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD HH:mm:ss"
            v-model="form.registryDate"
            type="date"
            range-separator="到"
            placeholder="申请时间"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="search"> 搜索</el-button>
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row class="row mb8">
        <el-button type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增验收申请</el-button>
        <right-toolbar v-model:showSearch="showSearch" @queryTable="search" class="rightToolbar"></right-toolbar>
      </el-row>
    </div>
    <el-tabs :model-value="status" class="demo-tabs" @tab-click="handleClick">
      <el-tab-pane label="我的" name="0"></el-tab-pane>
      <el-tab-pane label="待办列表" name="1"></el-tab-pane>
      <el-tab-pane label="已办列表" name="2"></el-tab-pane>
    </el-tabs>
    <div class="table" ref="table_box">
      <el-table :data="tableData" v-loading="loading" :max-height="maxHeight" ref="multipleTableRef">
        <!-- <el-table-column type="selection"  width="55" /> -->
        <el-table-column label="项目编码" prop="projectNo" show-overflow-tooltip />
        <el-table-column label="项目类型" prop="projectTypeName" show-overflow-tooltip> </el-table-column>
        <el-table-column label="项目名称" prop="projectName" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ row.projectName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="申请时间" prop="applicationTime" show-overflow-tooltip />
        <el-table-column label="项目总投资(万元)" prop="totalInvest" show-overflow-tooltip />
        <el-table-column label="中海绵建设投资(万元)" prop="spongeInvest" show-overflow-tooltip />
        <el-table-column label="海绵建设内容(定量填写海绵设施面积、体积等信息)" prop="otherDescription" show-overflow-tooltip />
        <el-table-column label="海绵项目占地面积(㎡)" prop="spongeProjectArea" show-overflow-tooltip> </el-table-column>
        <el-table-column label="年径流量总控制率(%)" prop="annualRunoffTotalControlRate" show-overflow-tooltip> </el-table-column>
        <el-table-column label="年SS总量去除率不低于(%)" prop="turbidityRemovalRate" show-overflow-tooltip> </el-table-column>
        <el-table-column label="申请奖励金额(万元)" prop="bonusAmountApplied" show-overflow-tooltip> </el-table-column>
        <el-table-column label="审核状态" prop="status" show-overflow-tooltip>
          <template #default="{ row }">
            <el-tag v-if="row.fromStatus" class="ml-2" type="danger">驳回</el-tag>
            <el-tag v-else class="ml-2" type="success">{{ statusMap.get(row.status) }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" show-overflow-tooltip :width="curWidth">
          <template #default="{ row }">
            <el-button type="primary" link @click="openDialog(row, 'view')">查看</el-button>
            <el-button type="primary" link @click="openDialog(row, 'audit')" v-show="status === '1' && !row.fromStatus">审核</el-button>
            <el-button
              type="primary"
              link
              @click="openDialog(row, 'edit')"
              v-show="status === '0' || (status === '1' && row.fromStatus)"
              :disabled="(row.status !== 'start' && !row.fromStatus) || userInfo.name !== row.createBy"
              >编辑</el-button
            >
            <el-button type="danger" link @click="del(row)" v-show="status === '0'" :disabled="row.status !== 'start'">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination class="pagination" :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />
    </div>
    <el-dialog v-model="visible" :title="`${opts.text}`" :close-on-click-modal="false" width="70%" :before-close="close" class="dialog">
      <operate
        ref="operateRef"
        :cur-row="curRow"
        :opts="opts"
        :types="projectTypes"
        :company-list="projectCompanyList"
        @close="close"
        v-if="visible && readlShow"
      />
      <div v-if="!readlShow">
        <div v-for="i in ydclList" :key="i.id" class="ydclList">
          <div class="ylxz">
            <div class="WangEditor">
              <span class="documentNamelass white" :title="i.documentName">{{ i.documentName }}</span>
              <WangEditor class="WangEditor_com" :modelValue="i.documentContent"></WangEditor>
            </div>
            <div class="ylxz_btn" v-for="k in i.fileSaveRequestList" :key="k.url">
              <span class="zl white">{{ k.originalName }}</span>
              <span @click="donLoad(k)">预览</span>
              <span @click="ylClick(k)">下载</span>
            </div>
          </div>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="close">取 消</el-button>
          <el-button v-if="!readlShow" @click="readlyClick">已 阅 读</el-button>
          <span v-if="readlShow && opts.type !== 'view'">
            <el-button type="primary" @click="save" v-if="opts.type !== 'audit'">确定</el-button>
            <el-button type="primary" @click="submit" v-if="opts.type !== 'audit'">提 交</el-button>
            <el-button type="primary" @click="handleAudit('false')" v-if="opts.type === 'audit'">驳 回</el-button>
            <el-button type="primary" @click="handleAudit('true')" v-if="opts.type === 'audit'">通 过</el-button>
          </span>
          <el-button v-if="readlShow" @click="returnClick">返回</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { useAdaption } from '@/hooks';
import operate from './recordsRewardComponents/operate.vue';
import { optTextMap } from '@/utils/map';
import { statusMap } from './recordsRewardComponents/map';
import { projectTypeList, getProjectCompanyList } from '@/api/project/projectInformationNew';

import {
  getProjectCompletionAcceptanceMyPage,
  getProjectCompletionAcceptancePage,
  projectCompletionAcceptanceeDel,
  projectBonusNoticeList,
} from '@/api/project/recordsReward';
import useUserStore from '@/store/modules/user';
import WangEditor from '@/components/WangEditor/index.vue'; //富文本编辑器

const userInfo = useUserStore();
const { proxy } = getCurrentInstance();
const { maxHeight, onResize } = useAdaption(proxy, 'table_box');
const { project_operation_pattern, dangerous_status } = proxy.useDict('project_operation_pattern', 'dangerous_status');
const readlShow = ref(false);
const showSearch = ref(true);
const visible = ref(false);
const opts = reactive({
  type: '',
  text: '阅读材料',
});
const curRow = shallowRef({});
const form = reactive({
  projectName: '',
  projectTypeId: '',
  chargeDepartment: '',
  constructUnit: '',
  designUnit: '',
  status: '',
  pageNum: 1,
  pageSize: 10,
  queryScope: '',
});

const status = ref('0');
const curWidth = computed(() => {
  if (status.value === '0') return 170;
  return 120;
});

const projectTypes = ref([]);
const projectCompanyList = ref([]);

const tableData = ref([]);
const total = ref(0);
const loading = ref(false);

const getTableList = async () => {
  loading.value = true;
  if (status.value === '0') {
    const res = await getProjectCompletionAcceptanceMyPage(form);
    loading.value = false;
    if (res?.code === 200) {
      tableData.value = res?.data || [];
      total.value = res?.total || 0;
    }
  } else {
    if (status.value === '1') {
      form.queryScope = 'todo';
    } else {
      form.queryScope = 'done';
    }
    const res = await getProjectCompletionAcceptancePage(form);
    loading.value = false;
    if (res?.code === 200) {
      tableData.value = res?.data || [];
      total.value = res?.total || 0;
    }
  }
};

const getProjectTypeList = async () => {
  const res = await projectTypeList({ status: '0' });
  if (res?.code !== 200) return;
  projectTypes.value = res?.data || [];
};

const getProjectCompanyLists = async () => {
  const res = await getProjectCompanyList();
  if (res?.code !== 200) return;
  projectCompanyList.value = res?.data || [];
};

const openDialog = (data, type) => {
  visible.value = true;
  readlShow.value = false;
  opts.type = type;
  curRow.value = data;
};

const close = () => {
  visible.value = false;
  opts.type = '';
  opts.text = '';
  getTableList();
};

const search = () => {
  form.pageNum = 1;
  getTableList();
};
const resetQuery = () => {
  proxy.$refs.ruleForm.resetFields();
  search();
};

const del = row => {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await projectCompletionAcceptanceeDel(row.id);
      if (res?.code !== 200) return;
      proxy.$modal.msgSuccess('操作成功!');
      getTableList();
    })
    .catch(() => {});
};

const handleClick = tab => {
  status.value = tab.paneName;
  search();
};

const save = () => {
  proxy.$refs.operateRef.submit(1);
};

const submit = () => {
  proxy.$refs.operateRef.submit(2);
};

const handleAudit = result => {
  proxy.$refs.operateRef.handleAudit(result);
};

watch(showSearch, onResize);
//已阅读按钮
function readlyClick() {
  readlShow.value = true;
  opts.text = '新增奖补申请';
}
function returnClick() {
  readlShow.value = false;
  opts.text = '阅读材料';
}
//列表搜索项目奖补须知
const ydclList = ref([]);
async function projectBonusNoticeListM() {
  let { data } = await projectBonusNoticeList();
  ydclList.value = data;
}
//预览
function donLoad(v) {
  console.log(v, 888);
  proxy.$modal.confirm(`下载此文件: ${v.name}?`).then(() => {
    window.open(v.url);
  });
}
function ylClick(v) {
  proxy.$modal.confirm(`下载此文件: ${v.name}?`).then(() => {
    const a = document.createElement('a');
    a.href = v.url;
    a.download = v.name;
    a.style.display = 'none';
    document.body.appendChild(a);
    console.log(a.download);
    a.click(); // 点击下载
    document.body.removeChild(a);
  });
}
onMounted(() => {
  getProjectTypeList();
  getProjectCompanyLists();
  getTableList();
  projectBonusNoticeListM();
});
</script>

<style lang="scss" scoped>
.completionAcceptance {
  color: #fff;
  padding: 20px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  .top,
  .row {
    flex-shrink: 0;
    margin-bottom: 10px;
  }
  .table {
    flex: 1;
    :deep(.pagination) {
      margin-top: 0;
      margin-right: 10px;
      .el-pagination {
        right: 20px;
      }
    }
  }
  :deep(.formItem110) {
    .el-form-item__label {
      width: 110px;
      word-break: keep-all;
      white-space: nowrap;
    }
  }

  :deep(.formItem140) {
    .el-form-item__label {
      width: 140px;
      word-break: keep-all;
      white-space: nowrap;
    }
  }

  :deep(.formItem300) {
    .el-form-item__label {
      width: 300px;
      word-break: keep-all;
      white-space: nowrap;
    }
  }
}

.rightToolbar {
  transform: translateY(40px);
}
.ydclList {
  width: 100%;
  display: flex;
  flex-direction: column;
  // background: red;
}
.ylxz {
  color: #fff;
  .WangEditor {
    display: flex;
    .WangEditor_com {
      flex: 0 0 88%;
      margin-left: 5px;
    }
  }
  .ylxz_btn {
    margin: 10px 100px;
    span {
      display: inline-block;
      width: 60px;
      cursor: pointer;
    }
    .zl {
      color: royalblue;
      width: 300px;
    }
  }
  .documentNamelass {
    text-align: right;
    display: inline-block;
    width: 80px;
  }
  .white {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
}
</style>