Newer
Older
KaiFengPC / src / views / preassess / targetManage / index.vue
@zhangdeliang zhangdeliang on 23 May 8 KB 初始化项目
<template>
  <div class="targetManage">
    <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="3">
            <el-form-item label="建设类型:" prop="buildCategory">
              <el-select v-model="form.buildCategory" placeholder="建设类型" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option v-for="dict in build_category" :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="7">
            <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>
        <!-- <upload class="mr10" :upload-config="uploadConfig" @success="uploadSuccess">
          <el-button type="primary" plain icon="Upload">导入</el-button>
        </upload>
        <el-button type="primary" plain icon="Download" @click="downloadTemplate">下载模板</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="annualRunoffTotalControlRate" show-overflow-tooltip width="100" />
      <el-table-column label="设计降雨量mm" prop="designRainfall" show-overflow-tooltip width="130">
        <template #header>
          <span>设计降雨量mm</span>
          <popover :width="600">
            <div class="box">
              <div class="img" style="width: 426px; height: 270px">
                <img :src="u400" alt="" />
              </div>
              <p class="description">根据目标年径流总量控制率跟设计降雨关系曲线,由年径流总量控制率推算设计降雨</p>
            </div>
          </popover>
        </template>
      </el-table-column>
      <el-table-column label="年径流污染控制率%,≥" prop="annualRunoffPollutionControlRate" show-overflow-tooltip width="100" />
      <el-table-column label="硬质地面率%,<" prop="hardGroundRate" show-overflow-tooltip width="100" />
      <el-table-column label="工程类型" prop="engineeringType" show-overflow-tooltip width="100">
        <template #default="{ row }">
          {{ findText('sponge_engineering_type', row.engineeringType) }}
        </template>
      </el-table-column>
      <el-table-column label="建设分区" prop="drainagePartition" show-overflow-tooltip>
        <template #default="{ row }">
          {{ findText('drainage_partition', row.drainagePartition) }}
        </template>
      </el-table-column>
      <el-table-column label="建设类型" prop="buildCategory" show-overflow-tooltip>
        <template #default="{ row }">
          {{ findText('build_category', row.buildCategory) }}
        </template>
      </el-table-column>
      <el-table-column label="建设单位" prop="constructionUnit" show-overflow-tooltip width="240" />
      <el-table-column label="责任人" prop="dutyPerson" show-overflow-tooltip />
      <el-table-column label="修改日期" prop="updateTime" show-overflow-tooltip width="160" />
      <el-table-column label="操作" show-overflow-tooltip width="158">
        <template #default="{ row }">
          <el-button type="primary" link @click="openDialog(row, 'view')">查看</el-button>
          <el-button type="primary" link @click="openDialog(row, 'edit')">修改</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" />
    <el-dialog v-model="visible" :title="`${opts.text}项目工程目标`" :close-on-click-modal="false" width="50%" :before-close="close">
      <dialogForm v-if="visible" ref="dialogFormRef" :id="row.id || ''" :opts="opts.type" @close="close"></dialogForm>
      <template #footer v-if="opts.type !== 'view'">
        <div class="dialog-footer">
          <el-button type="primary" @click="handleOk">保存</el-button>
          <el-button @click="close">取消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import dialogForm from './dialogForm.vue';
import { ref, reactive, onMounted } from 'vue';
import { optTextMap } from '@/utils/map';
import { usePagination } from '@/hooks';
import { getProjectBuildTargetConfigPage, projectBuildTargetConfigInfoDel } from '@/api/preassess/targetManage';
import u400 from '@/assets/images/preassess/u400.png';
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: '',
  buildCategory: '',
  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(getProjectBuildTargetConfigPage, params);

const uploadConfig = reactive({
  url: '/prod-api/a/b',
});
const visible = ref(false);
const row = ref({});
const opts = reactive({
  type: '',
  text: '',
});

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

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

const uploadSuccess = () => {
  console.log('上传成功');
};

const downloadTemplate = () => {};

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

const close = type => {
  proxy.$refs.dialogFormRef.restForm();
  visible.value = false;
  opts.type = '';
  opts.text = '';
  row.value = {};
  if (type === 'add') search();
  else if (type === 'edit') getTableList();
};

const handleOk = () => {
  proxy.$refs.dialogFormRef.submit();
};

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

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

<style lang="scss" scoped>
.targetManage {
  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);
      }
    }
  }
}
.box {
  display: flex;
  padding: 10px;
  .img {
    flex-shrink: 0;
    img {
      width: 100%;
      height: 100%;
    }
  }
  p {
    padding-left: 10px;
    text-indent: 2em;
  }
}
</style>