Newer
Older
KaiFengPC / src / views / project / processControl / completionAcceptance / index.vue
@zhangdeliang zhangdeliang on 22 Oct 13 KB update
<template>
  <div class="completionAcceptance">
    <div class="top">
      <el-form ref="ruleForm" :model="form" v-show="showSearch">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="项目名称:" prop="projectName">
              <el-input v-model="form.projectName" placeholder="请输入项目名称" style="width: 100%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目类型:" prop="projectTypeId">
              <el-select v-model="form.projectTypeId" placeholder="请选择项目类型" style="width: 100%">
                <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-col>
          <el-col :span="6">
            <el-form-item label="建设单位:" prop="chargeDepartment">
              <el-input v-model="form.chargeDepartment" placeholder="请输入建设单位" style="width: 100%"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="施工单位:" prop="constructUnit">
              <el-select v-model="form.constructUnit" placeholder="请选择施工单位" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option v-for="dict in projectCompanyList" :key="dict.id" :label="dict.unitName" :value="dict.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设计单位:" prop="designUnit">
              <el-select v-model="form.designUnit" placeholder="请选择设计单位" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option v-for="dict in projectCompanyList" :key="dict.id" :label="dict.unitName" :value="dict.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="审核状态:" prop="status">
              <el-select v-model="form.status" placeholder="请选择审核状态" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option label="开始" value="start" />
                <el-option label="验收审查" value="acceptanceReview" />
                <el-option label="驳回" value="submit" />
                <el-option label="结束" value="end" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <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-col>
        </el-row>
      </el-form>
    </div>
    <el-row class="row">
      <!-- 角色:建设单位(buildUnit)可提交验收申请,海绵中心(spongeCenter) 审核 -->
      <!-- <el-button
        type="primary"
        plain
        icon="Plus"
        @click="openDialog({}, 'add')"
        v-if="userInfo.roles.includes('admin') || userInfo.roles.includes('buildUnit')"
      >
        新增验收申请
      </el-button> -->
      <el-button type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增验收申请</el-button>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="resetQuery" class="rightToolbar"></right-toolbar>
    </el-row>
    <!-- <el-tabs :model-value="status" class="demo-tabs" @tab-click="handleClick">
      <el-tab-pane label="我的" name="0" v-if="userInfo.roles.includes('admin') || userInfo.roles.includes('buildUnit')"></el-tab-pane>
      <el-tab-pane
        label="待办列表"
        name="1"
        v-if="userInfo.roles.includes('admin') || userInfo.roles.includes('spongeCenter')"
      ></el-tab-pane>
      <el-tab-pane
        label="已办列表"
        name="2"
        v-if="userInfo.roles.includes('admin') || userInfo.roles.includes('spongeCenter')"
      ></el-tab-pane>
    </el-tabs> -->
    <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" stripe :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="projectTypeId" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectTypes.find(it => it.id === row.projectTypeId)?.projectTypeName || '' }}</span>
          </template>
        </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="applyTime" show-overflow-tooltip />
        <el-table-column label="联系人" prop="chargeUser" show-overflow-tooltip />
        <el-table-column label="联系方式" prop="phone" show-overflow-tooltip />
        <el-table-column label="建设单位" prop="chargeDepartment" show-overflow-tooltip />
        <el-table-column label="设计单位" prop="designUnit" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectCompanyList.find(it => it.id === row.designUnit)?.unitName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="施工单位" prop="constructUnit" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectCompanyList.find(it => it.id === row.constructUnit)?.unitName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="监理单位" prop="supervisorUnit" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ projectCompanyList.find(it => it.id === row.supervisorUnit)?.unitName }}</span>
          </template>
        </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="240">
          <template #default="{ row }">
            <el-button icon="View" type="primary" link @click="openDialog(row, 'view')">详情</el-button>
            <el-button type="warning" icon="Edit" link @click="openDialog(row, 'audit')" v-show="status === '1' && !row.fromStatus">
              审核
            </el-button>

            <el-button
              icon="Edit"
              type="warning"
              link
              @click="openDialog(row, 'edit')"
              v-show="status === '0' || (status === '1' && row.fromStatus)"
              :disabled="(row.status !== 'start' && !row.fromStatus) || userInfo.name !== row.createBy"
              :title="userInfo.name !== row.createBy ? '抄送人员不可操作' : ''"
            >
              修改
            </el-button>
            <el-button
              type="danger"
              icon="Delete"
              link
              @click="del(row)"
              v-show="status === '0'"
              :disabled="row.status !== 'start' || userInfo.name !== row.createBy"
              :title="userInfo.name !== row.createBy ? '抄送人员不可操作' : ''"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination class="pagination" :total="total" v-model:page="form.pageNum" v-model:limit="form.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"
      />
      <template #footer v-if="opts.type !== 'view'">
        <div class="dialog-footer">
          <el-button @click="close">取 消</el-button>
          <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>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, watch, onMounted, shallowRef } from 'vue';
import { useAdaption } from '@/hooks';
import operate from './operate.vue';
import { optTextMap } from '@/utils/map';
import { statusMap } from './map';
import { projectTypeList, getProjectCompanyList } from '@/api/project/projectInformationNew';
import {
  getProjectCompletionAcceptanceMyPage,
  getProjectCompletionAcceptancePage,
  projectCompletionAcceptanceeDel,
} from '@/api/project/completionAcceptance';
import useUserStore from '@/store/modules/user';
const userInfo = useUserStore();
const { proxy } = getCurrentInstance();
// const { build_status, sponge_land_type, project_content_type, findText } = useDicts(proxy)
const { maxHeight, onResize } = useAdaption(proxy, 'table_box');
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(null);
if (userInfo.roles.includes('spongeCenter')) {
  status.value = '1';
} else {
  status.value = '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;
  opts.type = type;
  opts.text = optTextMap.get(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);

onMounted(() => {
  getProjectTypeList();
  getProjectCompanyLists();
  getTableList();
});
</script>

<style lang="scss" scoped>
.completionAcceptance {
  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);
}
</style>