Newer
Older
KaiFengPC / src / views / project / ProjectProcessAdministration / constructionPermitsa / conPermitsa.vue
@鲁yixuan 鲁yixuan on 7 Jun 12 KB update
<template>
  <div class="constructionPermits">
    <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="spongeLandType">
              <el-select v-model="form.spongeLandType" placeholder="请选择用地类型" style="width: 100%">
                <el-option label="全部" value=""></el-option>
                <el-option v-for="dict in sponge_land_type" :key="dict.value" :label="dict.label" :value="dict.value" />
              </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="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="buildStatus">
              <el-select v-model="form.buildStatus" placeholder="请选择建设状态" style="width: 100%">
                <el-option label="全部" value=""></el-option>
                <el-option v-for="dict in build_status" :key="dict.value" :label="dict.label" :value="dict.value" />
              </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="projectInquiry" />
                <el-option label="人工审核" value="manualReview" />
                <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>
      <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>
    <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="projectArea" show-overflow-tooltip />
        <el-table-column label="用地类型" prop="spongeLandType" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ findText('sponge_land_type', row.spongeLandType) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="绿地率" prop="greenRate" show-overflow-tooltip />
        <el-table-column label="建设单位" prop="chargeDepartment" show-overflow-tooltip />
        <el-table-column label="年径流总量控制率" prop="annualRunoffTotalControlRate" show-overflow-tooltip />
        <el-table-column label="年径流污染去除率" prop="annualRunoffPollutionControlRate" show-overflow-tooltip />
        <el-table-column label="硬化地面率" prop="hardGroundRate" show-overflow-tooltip />
        <el-table-column label="建设状态" prop="buildStatus" show-overflow-tooltip>
          <template #default="{ row }">
            <span>{{ findText('build_status', row.buildStatus) }}</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="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="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"
        :project-content-type="project_content_type"
        :cur-status="status"
        @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, computed, shallowRef } from 'vue';
import { useAdaption, useDicts } from '@/hooks';
import operate from './operate.vue';
import { optTextMap } from '@/utils/map';
import { statusMap } from './map';
import { getConstructionPermitsMyPage, getConstructionPermitsPage, projectConstructionPermitsDel } from '@/api/project/constructionPermits';
import { projectTypeList } from '@/api/project/projectInformationNew';
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: '',
  spongeLandType: '',
  chargeDepartment: '',
  projectTypeId: '',
  buildStatus: '',
  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 tableData = ref([]);
const total = ref(0);
const loading = ref(false);
const getTableList = async () => {
  loading.value = true;
  if (status.value === '0') {
    const res = await getConstructionPermitsMyPage(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 getConstructionPermitsPage(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 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 projectConstructionPermitsDel(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(() => {
  getTableList();
  getProjectTypeList();
});
</script>

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

.rightToolbar {
  transform: translateY(40px);
}
</style>