Newer
Older
Nanping_sponge_GCYPG / src / views / preassess / examineManage / index.vue
@liyingjing liyingjing on 25 Oct 2023 7 KB 工程预评估
<template>
  <div class="examineManage">
    <div class="top">
      <el-form ref="ruleForm" :model="form">
        <el-row :gutter="20">
          <el-col :span="5">
            <el-form-item label="使用状态:" prop="status">
              <el-select v-model="form.status" placeholder="请选择使用状态" style="width: 100%">
                <el-option label="全部" value="" />
                <el-option label="启用" value="1" />
                <el-option label="停用" value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <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="13">
            <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"
    >
      <el-table-column type="index" width="55" label="序号" align="center" fixed="left" />
      <el-table-column label="记录名称" prop="recordName" show-overflow-tooltip width="200" fixed="left">
        <template #default="{ row }">
          <span style="color: #409eef">{{ row.recordName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工程类型" align="center" prop="engineeringType" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ engineeringTypeText(row.engineeringType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="考核类型" align="center" prop="assessType" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ assessTypeText(row.assessType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="停用时间" align="center" prop="dwonTime" show-overflow-tooltip />
      <el-table-column label="修改人" align="center" prop="updateNickName" show-overflow-tooltip />
      <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 :type="statusMap.get(row.status).type" v-if="row.status">{{ statusMap.get(row.status).text }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" show-overflow-tooltip width="200" fixed="right">
        <template #default="{ row }">
          <el-button type="primary" link @click="copy(row)">复制</el-button>
          <el-button type="primary" link @click="operateHandle(row, 'view')">查看</el-button>
          <el-button type="primary" link @click="operateHandle(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="30%"
      :before-close="close"
      class="dialog"
    >
      <operate v-if="visible" ref="operateRef" @close="close"/>
      <template #footer v-if="opts.type !== 'view'">
        <div class="dialog-footer">
          <el-button type="primary" @click="submit">保存</el-button>
          <el-button @click="close">取消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import operate from './operate.vue'
import {
  getAssessTargetConfigPage,
  assessTargetConfigCopy,
  assessTargetConfigDel
}
from '@/api/preassess/examineManage.js'
import { optTextMap, statusMap } from '@/utils/map'
import { usePagination } from '@/hooks'
const { proxy } = getCurrentInstance();
// const route = useRoute();
const router = useRouter();
const emit = defineEmits(['toggle'])

const { sponge_engineering_type } = proxy.useDict("sponge_engineering_type")
const engineeringTypeText = (itemType) => {
  const item = sponge_engineering_type.value.find(it => it.value === itemType)
  return item?.label || ''
}
const { assess_type  } = proxy.useDict("assess_type")
const assessTypeText = (itemType) => {
  const item = assess_type.value.find(it => it.value === itemType)
  return item?.label || ''
}

const form = reactive({
  status: '',
  time: []
})

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

const {
  pageNum,
  pageSize,
  tableData,
  total,
  loading,
  getTableList
} = usePagination(getAssessTargetConfigPage, params)
const opts = reactive({
  type: '',
  text: ''
})
const visible = ref(false)

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

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

const openDialog = (type) => {
  visible.value = true
  opts.type = type
  opts.text = optTextMap.get(type)
}
const close = (type) => {
  visible.value = false
  opts.type = ''
  opts.text = ''
  if(type === 'add') search()
}

const submit = () => {
  proxy.$refs.operateRef.submit()
}

const operateHandle = (data, type) => {
  if(data.assessType === 'control') {
    router.push(`/preassess/examine/control/${data.id}?type=${type}&status=${data.status}&name=${data.recordName}&engineeringType=${data.engineeringType}`)
  } else if(data.assessType === 'score'){
    router.push(`/preassess/examine/mark/${data.id}?type=${type}&status=${data.status}&name=${data.recordName}&engineeringType=${data.engineeringType}`)
  }
}

const copy = (row) => {
  proxy.$modal
  .confirm("是否确认复制?")
  .then(async () => {
    const formData = new FormData()
    formData.append('assessTargetId', row.id)
    const res = await assessTargetConfigCopy(formData)
    if(res?.code !== 200) return
    proxy.$modal.msgSuccess('操作成功!')
    getTableList()
  })
  .catch(() => {})
}

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

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

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

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