Newer
Older
KaiFengPC / src / views / preassess / calculate / index.vue
@zhangdeliang zhangdeliang on 23 May 9 KB 初始化项目
<template>
  <div class="calculate">
    <div class="top">
      <el-form ref="ruleForm" :model="form">
        <el-row :gutter="20">
          <el-col :span="5">
            <el-form-item label="建设工程:" prop="projectName">
              <el-input v-model="form.projectName" placeholder="建设工程" style="width: 100%" /> </el-form-item
          ></el-col>
          <el-col :span="4">
            <el-form-item label="建设分区:" prop="drainagePartition">
              <el-select v-model="form.drainagePartition" placeholder="建设分区" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option v-for="dict in drainage_partition" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="工程类型:" prop="engineeringType">
              <el-select v-model="form.engineeringType" placeholder="工程类型" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option v-for="dict in sponge_engineering_type" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="修改时间:" prop="time">
              <el-date-picker
                v-model="form.time"
                type="daterange"
                range-separator="~"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                style="width: 100%"
              />
            </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>
      <el-row class="mb8">
        <el-button class="mr10" type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增</el-button>
      </el-row>
    </div>
    <el-table :data="tableData" v-loading="loading" :max-height="600">
      <el-table-column type="index" width="55" label="序号" />
      <el-table-column label="建设工程" prop="projectName" show-overflow-tooltip width="200">
        <template #default="{ row }">
          <span style="color: #409eef">{{ row.projectName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建人单位" prop="createDeptName" show-overflow-tooltip width="240" />
      <el-table-column label="年径流总量控制率%,≥" prop="targetAnnualRunoffTotalControlRate" show-overflow-tooltip width="100" />
      <el-table-column label="年径流污染控制率%,≥" prop="targetAnnualRunoffPollutionControlRate" show-overflow-tooltip width="100" />
      <el-table-column label="目标硬质地面率%,<" prop="targetHardGroundRate" show-overflow-tooltip width="100" />
      <el-table-column label="目标调蓄量m³" prop="targetStorageCapacity" show-overflow-tooltip width="140">
        <template #header>
          <span>目标调蓄量m³</span>
          <popover>
            <span style="font-weight: 700">说明</span>
            <br />
            <span>0.01*设计降雨量*面积加和*综合径流系数</span>
          </popover>
        </template>
      </el-table-column>
      <el-table-column label="设施调蓄量m³" prop="facilityStorageCapacity" show-overflow-tooltip width="110" />
      <el-table-column label="调蓄量是否达标" prop="storageCapacityStandards" show-overflow-tooltip width="100">
        <template #default="{ row }">
          <el-tag v-if="standardMap.get(row.storageCapacityStandards)?.text" :type="standardMap.get(row.storageCapacityStandards)?.type">{{
            standardMap.get(row.storageCapacityStandards)?.text
          }}</el-tag>
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column label="污染控制率%" prop="pollutionRemovalRate" show-overflow-tooltip width="110" />
      <el-table-column label="污染去除率是否达标" prop="pollutionRemovalStandards" show-overflow-tooltip width="100">
        <template #default="{ row }">
          <el-tag
            v-if="standardMap.get(row.pollutionRemovalStandards)?.text"
            :type="standardMap.get(row.pollutionRemovalStandards)?.type"
            >{{ standardMap.get(row.pollutionRemovalStandards)?.text }}</el-tag
          >
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column label="硬质地面率%" prop="hardGroundRate" show-overflow-tooltip width="110" />
      <el-table-column label="硬质地面率是否达标" prop="hardGroundStandards" show-overflow-tooltip width="100">
        <template #default="{ row }">
          <el-tag v-if="standardMap.get(row.hardGroundStandards)?.text" :type="standardMap.get(row.hardGroundStandards)?.type">{{
            standardMap.get(row.hardGroundStandards)?.text
          }}</el-tag>
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column label="工程类型" prop="engineeringType" width="100">
        <template #default="{ row }">
          <span>{{ findText('sponge_engineering_type', row.engineeringType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="建设分区" prop="drainagePartition" show-overflow-tooltip width="100">
        <template #default="{ row }">
          <span>{{ findText('drainage_partition', row.drainagePartition) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="建设类型" prop="buildCategory" show-overflow-tooltip width="80">
        <template #default="{ row }">
          <span>{{ findText('build_category', row.buildCategory) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="建设单位" prop="constructionUnit" show-overflow-tooltip width="240" />
      <el-table-column label="责任人" prop="dutyPerson" show-overflow-tooltip width="100" />
      <el-table-column label="修改日期" prop="updateTime" show-overflow-tooltip width="160" />
      <el-table-column label="状态" prop="status" width="100">
        <template #default="{ row }">
          <el-tag v-if="statusMap.get(row.status)?.text" :type="statusMap.get(row.status)?.type">{{
            statusMap.get(row.status)?.text
          }}</el-tag>
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column label="操作" show-overflow-tooltip width="158" fixed="right">
        <template #default="{ row }">
          <el-button type="primary" link @click="openDialog(row, 'view')">查看</el-button>
          <el-button type="primary" link @click="openDialog(row, 'edit')" :disabled="row.status === '2'">修改</el-button>
          <el-button type="danger" link @click="del(row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />
    <operate
      ref="operateRef"
      :id="row.id || ''"
      :status="row.status"
      :opts="opts"
      @close="close"
      v-model="isShowDialog"
      v-if="isShowDialog"
    ></operate>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue';
import operate from './operate.vue';
import { optTextMap } from '@/utils/map';
import { usePagination } from '@/hooks';
import { getFacilitiesStandardCalcPage, facilitiesStandardCalcDel } from '@/api/preassess/calculate';
import { standardMap, statusMap } from './map';
import popover from '@/components/popover';
const { proxy } = getCurrentInstance();

const { build_category } = proxy.useDict('build_category');
const { drainage_partition } = proxy.useDict('drainage_partition');
const { sponge_engineering_type } = proxy.useDict('sponge_engineering_type');
const dicts = {
  build_category,
  drainage_partition,
  sponge_engineering_type,
};
const findText = (prop, type) => {
  const item = dicts[prop].value.find(it => it.value === type);
  return item?.label || '';
};
const form = reactive({
  projectName: '',
  drainagePartition: '',
  engineeringType: '',
  time: [],
});

const params = computed(() => {
  const args = JSON.parse(JSON.stringify(form));
  const { time } = args;
  delete args.time;
  return {
    ...args,
    updateStartTime: time[0] || '',
    updateEndTime: time[1] || '',
  };
});

const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(getFacilitiesStandardCalcPage, params);
const row = ref({});
const opts = reactive({
  type: '',
  text: '',
});

const isShowDialog = ref(false);

const search = () => {
  pageNum.value = 1;
  getTableList();
};

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

const openDialog = (data, type) => {
  isShowDialog.value = true;
  opts.type = type;
  opts.text = optTextMap.get(type);
  row.value = data;
};

const close = type => {
  opts.type = '';
  opts.text = '';
  row.value = {};
  if (type === 'add') {
    search();
  } else if (type === 'edit') {
    getTableList();
  }
};

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

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

<style lang="scss" scoped>
.calculate {
  padding: 20px;
  height: 90vh;
  overflow-y: hidden;
  .top {
    margin-bottom: 15px;
  }
}

:deep(.el-table) {
  .el-table__header {
    .cell {
      .el-tooltip__trigger.el-icon {
        margin-top: 0 !important;
        transform: translateY(2px);
      }
    }
  }
}
</style>