Newer
Older
Nanping_sponge_GCYPG / src / views / preassess / evaluation / index.vue
@liyingjing liyingjing on 25 Oct 2023 9 KB 工程预评估
<template>
  <div class="evaluation">
    <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="assessmentGrade">
              <el-select v-model="form.assessmentGrade" placeholder="请选择评估等级" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option label="一星级" :value="1" />
                <el-option label="二星级" :value="2" />
                <el-option label="三星级" :value="3" />
                <el-option label="不予评分" :value="0" />
                <el-option label="不达标" :value="-1" />
              </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"
      stripe
      :max-height="600"
      element-loading-text="数据加载中..."
    >
      <el-table-column type="index" width="55" label="序号" align="center" fixed="left" />
      <el-table-column label="建设工程" prop="projectName" show-overflow-tooltip width="200" fixed="left">
        <template #default="{ row }">
          <span style="color: #409eef">{{ row.projectName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工程类型" align="center" prop="engineeringType" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ findText('sponge_engineering_type', row.engineeringType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="建设分区" align="center" prop="drainagePartition" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ findText('drainage_partition', row.drainagePartition) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="建设类型" align="center" prop="buildCategory" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ findText('build_category', row.buildCategory) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="控制项" align="center" prop="controlItemStandard" show-overflow-tooltip>
        <template #default="{ row }">
          <el-tag
            v-if="standardMap.get(row.controlItemStandard)?.text"
            :type="standardMap.get(row.controlItemStandard)?.type"
          >{{ standardMap.get(row.controlItemStandard)?.text }}</el-tag>
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column label="得分项" align="center" prop="scoreItem" show-overflow-tooltip />
      <el-table-column label="评估等级" prop="assessmentGrade" width="160">
        <template #default="{ row }">
          <div class="grade" v-if="levelMap.get(row.assessmentGrade)?.text">
            <el-tag
              class="tag"
              :type="levelMap.get(row.assessmentGrade)?.type"
            >{{ row.assessmentGrade === 0 ? '--' : levelMap.get(row.assessmentGrade)?.text }}</el-tag>
            <div class="starList" v-if="row.assessmentGrade > 0">
              <el-icon
                v-for="item in row.assessmentGrade"
                class="starFilled"
              ><Star /></el-icon>
            </div>
            <el-icon
              v-else
              class="remove"
            ><RemoveFilled /></el-icon>
          </div>
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column label="建设单位" align="center" prop="constructionUnit" show-overflow-tooltip width="240" />
      <el-table-column label="责任人" align="center" prop="dutyPerson" show-overflow-tooltip width="100" />
      <el-table-column label="修改日期" align="center" prop="updateTime" show-overflow-tooltip width="160" />
      <el-table-column label="状态" align="center" prop="status" show-overflow-tooltip fixed="right">
        <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="操作" align="center" 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')">修改</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 || ''"
      :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 { standardMap, levelMap, statusMap } from './map'
import { usePagination } from '@/hooks'
import {
  getProjectPreEvaluatePage,
  projectPreEvaluateDel
} from '@/api/preassess/evaluation'
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: '',
  assessmentGrade: '',
  engineeringType: '',
  time: []
})

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

const {
  pageNum,
  pageSize,
  tableData,
  total,
  loading,
  getTableList
} = usePagination(getProjectPreEvaluatePage, 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 = (data) => {
  opts.type = ''
  opts.text = ''
  row.value = {}
  if(!data.isSubmit) return
  if(data.type === 'add') {
    search()
  } else if(data.type === 'edit') {
    getTableList()
  }
}

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

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

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

  .grade {
    display: flex;
    align-items: center;
    line-height: 1;
    .tag {
      min-width: 56px;
    }
    .starList {
      margin-left: 30px;
      .starFilled {
        color: #F7BA2A;
        font-size: 20px;
      }
    }
    .remove {
      margin-left: 30px;
      color: #F56C6C;
      font-size: 20px;
    }
  }
}

::v-deep(.dialog) {
  .el-dialog__body {
    padding-bottom: 20px !important;
  }
  .el-dialog__footer {
    padding-top: 0 !important;
  }
}
</style>