358 lines
11 KiB
Vue
358 lines
11 KiB
Vue
<template>
|
|
<ContentWrap>
|
|
<!-- 搜索工作栏 -->
|
|
<el-form
|
|
class="-mb-15px"
|
|
:model="queryParams"
|
|
ref="queryFormRef"
|
|
:inline="true"
|
|
label-width="68px"
|
|
>
|
|
<el-form-item label="项目名称" prop="deptId">
|
|
<el-select
|
|
v-model="queryParams.deptId"
|
|
class="!w-240px"
|
|
placeholder="请选择项目名称"
|
|
@keyup.enter="handleQuery"
|
|
>
|
|
<el-option
|
|
v-for="item in deptList"
|
|
:key="item.id"
|
|
:label="item.name"
|
|
:value="item.id"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<!-- <el-form-item label="项目合伙人" prop="ownerUserId">
|
|
<el-input
|
|
v-model="queryParams.ownerUserId"
|
|
placeholder="请输入项目合伙人"
|
|
clearable
|
|
@keyup.enter="handleQuery"
|
|
class="!w-240px"
|
|
/>
|
|
</el-form-item> -->
|
|
<el-form-item label="类型" prop="type">
|
|
<el-select
|
|
v-model="queryParams.type"
|
|
placeholder="请选择类型"
|
|
clearable
|
|
class="!w-240px"
|
|
>
|
|
<el-option
|
|
v-for="dict in getIntDictOptions(DICT_TYPE.CRM_PROJECT_TYPE)"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
|
<el-button
|
|
type="primary"
|
|
plain
|
|
@click="openForm('create')"
|
|
v-hasPermi="['crm:project:create']"
|
|
>
|
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
|
</el-button>
|
|
<el-button
|
|
type="success"
|
|
plain
|
|
@click="handleExport"
|
|
:loading="exportLoading"
|
|
v-hasPermi="['crm:project:export']"
|
|
>
|
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
|
</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</ContentWrap>
|
|
|
|
<!-- 列表 -->
|
|
<ContentWrap>
|
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
<el-table-column align="center" label="项目名称" prop="name" min-width="300">
|
|
<template #default="{ row }">
|
|
<el-link
|
|
v-if="row.id"
|
|
type="primary"
|
|
@click="openProjectDetail(row.id)"
|
|
:underline="false"
|
|
>
|
|
{{ row.name }}
|
|
</el-link>
|
|
<span v-else>{{ row.name }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="项目总投资额(万元)" align="center" prop="totalInvestment" width="180"/>
|
|
<el-table-column label="枪数" align="center" prop="estimatedPiles" />
|
|
<el-table-column label="单枪成本(万元)" align="center" min-width="120">
|
|
<template #default="{ row }">
|
|
<span>{{ calculateCostPerPile(row) }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" label="类型" prop="type" width="160">
|
|
<template #default="scope">
|
|
<dict-tag :type="DICT_TYPE.CRM_PROJECT_TYPE" :value="scope.row.type" />
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column align="center" label="供电模式" prop="type" width="160">
|
|
<template #default="scope">
|
|
<dict-tag :type="DICT_TYPE.CRM_PROJECT_POWER_SUPPLY_TYPE" :value="scope.row.powerSupplyType" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" label="状态" prop="projectStatus" width="160">
|
|
<template #default="scope">
|
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.projectStatus" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="操作" fixed="right" align="center" min-width="180px">
|
|
<template #default="scope">
|
|
<!-- <el-button
|
|
link
|
|
type="warning"
|
|
@click="openConfigDialog(scope.row.id)"
|
|
v-hasPermi="['crm:project:update']"
|
|
>
|
|
配置
|
|
</el-button> -->
|
|
<el-button
|
|
link
|
|
type="primary"
|
|
@click="openForm('update', scope.row.id)"
|
|
v-hasPermi="['crm:project:update']"
|
|
>
|
|
编辑
|
|
</el-button>
|
|
<el-button
|
|
link
|
|
type="danger"
|
|
@click="handleDelete(scope.row.id)"
|
|
v-hasPermi="['crm:project:delete']"
|
|
>
|
|
删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<!-- 分页 -->
|
|
<Pagination
|
|
:total="total"
|
|
v-model:page="queryParams.pageNo"
|
|
v-model:limit="queryParams.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
</ContentWrap>
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
<ProjectForm ref="formRef" @success="getList" />
|
|
|
|
<!-- 配置表单弹窗 -->
|
|
<!-- <Dialog
|
|
v-model="configDialogVisible"
|
|
title="巡检配置"
|
|
width="40%"
|
|
>
|
|
<ProjectInspectConfigForm ref="configFormRef" />
|
|
<template #footer>
|
|
<el-button type="primary" @click="handleConfigSubmit" :loading="configSubmitting">
|
|
提交
|
|
</el-button>
|
|
<el-button @click="configDialogVisible = false">取消</el-button>
|
|
</template>
|
|
</Dialog> -->
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { dateFormatter } from '@/utils/formatTime'
|
|
import download from '@/utils/download'
|
|
import * as ProjectApi from '@/api/crm/project'
|
|
import * as DeptApi from '@/api/system/dept'
|
|
import ProjectForm from './ProjectForm.vue'
|
|
import ProjectInspectConfigForm from './component/ProjectInspectConfigForm.vue'
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
|
/** CRM 项目信息 列表 */
|
|
defineOptions({ name: 'CrmProject' })
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
const { t } = useI18n() // 国际化
|
|
|
|
const loading = ref(true) // 列表的加载中
|
|
const list = ref<ProjectApi.ProjectVO[]>([]) // 列表的数据
|
|
const total = ref(0) // 列表的总页数
|
|
const queryParams = reactive({
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
deptId: undefined,
|
|
siteId: undefined,
|
|
ownerUserId: undefined,
|
|
type: undefined,
|
|
projectStatus: undefined,
|
|
estimatedPiles: undefined,
|
|
createTime: [],
|
|
})
|
|
const queryFormRef = ref() // 搜索的表单
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
const deptList = ref<DeptApi.DeptVO[]>([])
|
|
|
|
// // 配置表单相关
|
|
// const configDialogVisible = ref(false) // 配置弹窗是否显示
|
|
// const configFormRef = ref() // 配置表单引用
|
|
// const currentProjectId = ref<number>() // 当前操作的项目ID
|
|
// const configSubmitting = ref(false) // 配置提交中
|
|
|
|
/** 查询列表 */
|
|
const getList = async () => {
|
|
loading.value = true
|
|
try {
|
|
const data = await ProjectApi.getProjectPage(queryParams)
|
|
list.value = data.list
|
|
total.value = data.total
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
/** 打开场地详情 */
|
|
const { push } = useRouter()
|
|
const openSiteDetail = (id: number) => {
|
|
push({ name: 'CrmStationSiteDetail', params: { id } })
|
|
}
|
|
|
|
/** 打开项目详情 */
|
|
const openProjectDetail = (id: number) => {
|
|
push({ name: 'CrmProjectDetail', params: { id: String(id) } })
|
|
}
|
|
/** 搜索按钮操作 */
|
|
const handleQuery = () => {
|
|
queryParams.pageNo = 1
|
|
getList()
|
|
}
|
|
|
|
/** 重置按钮操作 */
|
|
const resetQuery = () => {
|
|
queryFormRef.value.resetFields()
|
|
handleQuery()
|
|
}
|
|
|
|
/** 添加/修改操作 */
|
|
const formRef = ref()
|
|
const openForm = (type: string, id?: number) => {
|
|
formRef.value.open(type, id)
|
|
}
|
|
|
|
/** 删除按钮操作 */
|
|
const handleDelete = async (id: number) => {
|
|
try {
|
|
// 删除的二次确认
|
|
await message.delConfirm()
|
|
// 发起删除
|
|
await ProjectApi.deleteProject(id)
|
|
message.success(t('common.delSuccess'))
|
|
// 刷新列表
|
|
await getList()
|
|
} catch {}
|
|
}
|
|
|
|
/** 导出按钮操作 */
|
|
const handleExport = async () => {
|
|
try {
|
|
// 导出的二次确认
|
|
await message.exportConfirm()
|
|
// 发起导出
|
|
exportLoading.value = true
|
|
const data = await ProjectApi.exportProject(queryParams)
|
|
download.excel(data, 'CRM 项目信息.xls')
|
|
} catch {
|
|
} finally {
|
|
exportLoading.value = false
|
|
}
|
|
}
|
|
|
|
const calculateCostPerPile = (row) => {
|
|
// 检查枪数是否有效(非空、非零、数字类型)
|
|
if (!row.estimatedPiles || isNaN(row.estimatedPiles) || row.estimatedPiles <= 0) {
|
|
return ''; // 无效值返回空字符串
|
|
}
|
|
|
|
// 检查总投资额是否有效
|
|
if (!row.totalInvestment || isNaN(row.totalInvestment)) {
|
|
return ''; // 无效值返回空字符串
|
|
}
|
|
|
|
// 计算并保留两位小数
|
|
const cost = (row.totalInvestment / row.estimatedPiles).toFixed(2);
|
|
return parseFloat(cost); // 转为数字类型避免显示多余的0
|
|
};
|
|
|
|
// /** 打开配置弹窗 */
|
|
// const openConfigDialog = async (projectId: number) => {
|
|
// currentProjectId.value = projectId
|
|
// configDialogVisible.value = true
|
|
// // 加载配置数据
|
|
// await nextTick()
|
|
// configFormRef.value?.open(projectId)
|
|
// }
|
|
|
|
// /** 处理配置提交 */
|
|
// const handleConfigSubmit = async () => {
|
|
// try {
|
|
// // 从配置表单获取数据
|
|
// const formData = configFormRef.value?.formData || {}
|
|
|
|
// // 验证启用的配置项
|
|
// const enabledKeys = Object.keys(formData).filter(key => formData[key]?.enabled)
|
|
|
|
// for (const key of enabledKeys) {
|
|
// if (!formData[key]?.responsiblePersonId) {
|
|
// message.error(`${key}的责任人不能为空`)
|
|
// return
|
|
// }
|
|
// if (!formData[key]?.cycle) {
|
|
// message.error(`${key}的巡检周期不能为空`)
|
|
// return
|
|
// }
|
|
// }
|
|
|
|
// // 构建提交数据
|
|
// const submitData: any = {}
|
|
// enabledKeys.forEach(key => {
|
|
// submitData[key] = {
|
|
// enabled: formData[key].enabled,
|
|
// management: formData[key].management,
|
|
// contact: formData[key].contact,
|
|
// phone: formData[key].phone,
|
|
// responsiblePersonId: formData[key].responsiblePersonId,
|
|
// cycle: formData[key].cycle,
|
|
// remark: formData[key].remark
|
|
// }
|
|
// })
|
|
|
|
// configSubmitting.value = true
|
|
// // TODO: 这里可以调用API保存配置数据
|
|
// // await ProjectApi.saveInspectConfig(currentProjectId.value, submitData)
|
|
// message.success('配置保存成功')
|
|
// configDialogVisible.value = false
|
|
// } catch (error) {
|
|
// console.error('配置保存失败:', error)
|
|
// message.error('配置保存失败')
|
|
// } finally {
|
|
// configSubmitting.value = false
|
|
// }
|
|
// }
|
|
|
|
/** 初始化 **/
|
|
onMounted(async () => {
|
|
await getList()
|
|
// 加载部门列表
|
|
deptList.value = await DeptApi.querySimpleDeptList(3)
|
|
})
|
|
</script>
|