From def80005702fd12eb17a6e53554d56624c15b04c Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期二, 03 十一月 2026 17:18:59 +0800
Subject: [PATCH] 部分改动
---
src/views/projectManagement/Management/components/formDia.vue | 1493 +++++------------------------------------------------------
1 files changed, 125 insertions(+), 1,368 deletions(-)
diff --git a/src/views/projectManagement/Management/components/formDia.vue b/src/views/projectManagement/Management/components/formDia.vue
index 98722a5..15ebe43 100644
--- a/src/views/projectManagement/Management/components/formDia.vue
+++ b/src/views/projectManagement/Management/components/formDia.vue
@@ -1,1396 +1,153 @@
<template>
- <el-dialog
- v-model="dialogVisible"
- :title="dialogTitle"
- width="95%"
- top="5vh"
- destroy-on-close
- @close="closeDialog"
- >
- <el-form
- ref="formRef"
- :model="form"
- :rules="rules"
- label-position="top"
- label-width="120px"
- :disabled="isView"
- >
- <div class="section">
- <div class="section-header" @click="toggleSection('base')">
- <div class="section-title">
- <span class="section-bar" />
- <span>鍩虹璧勬枡</span>
- </div>
- <el-icon class="toggle-icon">
- <ArrowDown v-if="sectionCollapsed.base" />
- <ArrowUp v-else />
- </el-icon>
- </div>
- <div v-show="!sectionCollapsed.base" class="section-body">
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="鍗曟嵁缂栧彿" prop="billNo">
- <el-input v-model="form.billNo" placeholder="绯荤粺鐢熸垚" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="椤圭洰鍚嶇О" prop="projectName">
- <el-input v-model="form.projectName" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="瀹㈡埛鍚嶇О" prop="customerName">
- <el-select
- v-model="form.customerName"
- placeholder="璇烽�夋嫨瀹㈡埛"
- clearable
- filterable
- :disabled="isFromContract"
- style="width: 100%"
- @change="handleCustomerChange"
- >
- <el-option
- v-for="item in customerOptions"
- :key="item.id ?? item.customerName"
- :label="item.customerName"
- :value="item.customerName"
- />
- </el-select>
- </el-form-item>
- </el-col>
+ <el-dialog v-model="visible" :title="dialogTitle" :width="startProject ? '1100px' : '900px'" destroy-on-close>
+ <el-alert v-if="isBusinessProject" title="璇ラ」鐩敱涓氬姟瀹℃壒鐢熸垚锛屼繚瀛樺悗鍙湪椤圭洰璇︽儏鏌ョ湅鏉ユ簮涓氬姟鍙婂叾闄勪欢銆�" type="info" :closable="false" class="tip" />
+ <el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
+ <el-row v-if="!personnelOnly" :gutter="20">
+ <el-col :span="12"><el-form-item label="椤圭洰鍚嶇О" prop="title"><el-input v-model="form.title" maxlength="200" /></el-form-item></el-col>
+ <el-col :span="12"><el-form-item label="瀹㈡埛鍚嶇О" prop="clientName"><el-select v-model="form.clientName" filterable clearable style="width:100%" @change="syncCustomer"><el-option v-for="item in customers" :key="item.id" :label="item.customerName" :value="item.customerName" /></el-select></el-form-item></el-col>
+ </el-row>
+ <el-row v-if="!personnelOnly" :gutter="20">
+ <el-col :span="12"><el-form-item label="椤圭洰鍒嗙被" prop="projectClassification"><el-tree-select v-model="form.projectClassification" :data="categoryTree" :props="{ label:'categoryName',value:'categoryName',children:'children' }" check-strictly clearable :filterable="false" placeholder="璇烽�夋嫨椤圭洰鍒嗙被" style="width:100%" /></el-form-item></el-col>
+ <el-col :span="12"><el-form-item label="椤圭洰鏉ユ簮"><el-input v-model="form.source" disabled /></el-form-item></el-col>
+ </el-row>
+ <el-row v-if="!personnelOnly" :gutter="20">
+ <el-col :span="12"><el-form-item label="棰勮寮�濮嬫椂闂�" prop="planStartTime"><el-date-picker v-model="form.planStartTime" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
+ <el-col :span="12"><el-form-item label="棰勮缁撴潫鏃堕棿" prop="planEndTime"><el-date-picker v-model="form.planEndTime" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
+ </el-row>
+ <el-row v-if="!personnelOnly" :gutter="20">
+ <el-col :span="12"><el-form-item label="椤圭洰璐熻矗浜�" prop="projectLeaderId"><el-select v-model="form.projectLeaderId" filterable style="width:100%" @change="syncLeader"><el-option v-for="u in users" :key="u.value" :label="u.label" :value="u.value" /></el-select></el-form-item></el-col>
+ <el-col :span="12"><el-form-item label="椤圭洰缁忕悊" prop="projectManagerIds"><el-select v-model="form.projectManagerIds" multiple filterable style="width:100%"><el-option v-for="u in users" :key="u.value" :label="u.label" :value="u.value" /></el-select></el-form-item></el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="24"><el-form-item label="椤圭洰鎵ц浜�" prop="projectExecutorIds"><el-select v-model="form.projectExecutorIds" multiple filterable style="width:100%"><el-option v-for="u in users" :key="u.value" :label="u.label" :value="u.value" /></el-select><div class="field-hint">椤圭洰寮�濮嬪悗浠嶅彲鏂板锛涘凡鏈夐」鐩眹鎶ュ伐浣滃崰姣旂殑鎵ц浜轰笉鑳藉垹闄ゃ��</div></el-form-item></el-col>
+ </el-row>
+ <el-row v-if="!personnelOnly" :gutter="20">
+ <el-col :span="8"><el-form-item label="璺熻繘鍛ㄦ湡" prop="followCycle"><el-select v-model="form.followCycle" style="width:100%"><el-option label="姣忔湀" value="MONTH" /><el-option label="姣忓搴�" value="QUARTER" /><el-option label="姣忓勾" value="YEAR" /></el-select></el-form-item></el-col>
+ <el-col :span="16"><el-form-item label="璺熻繘瑕佹眰" prop="followDetail"><el-input v-model="form.followDetail" maxlength="1000" /></el-form-item></el-col>
+ </el-row>
+ <el-form-item v-if="!personnelOnly" label="椤圭洰澶囨敞"><el-input v-model="form.remark" type="textarea" :rows="3" maxlength="2000" show-word-limit /></el-form-item>
+ <el-form-item v-if="!personnelOnly" label="椤圭洰璧勬枡"><AttachmentUploadFile v-model:file-list="files" :limit="20" /></el-form-item>
+ <template v-if="startProject && !personnelOnly">
+ <el-divider content-position="left">椤圭洰妯″潡缁勬垚锛堝紑濮嬮」鐩墠蹇呭~锛�</el-divider>
+ <el-alert title="妯″潡宸ヤ綔閲忓崰姣斿悎璁″繀椤讳负100%锛涜繖閲屽彧閫夋嫨鎵ц浜猴紝浜哄憳姣旈噸鍦ㄦ瘡娆¤繘搴︽眹鎶ユ椂濉啓銆�" type="info" :closable="false" class="tip" />
+ <div v-for="(module,index) in startModules" :key="module.localKey" class="module-card">
+ <div class="module-card__title"><span>妯″潡 {{ index + 1 }}</span><el-button link type="danger" @click="removeStartModule(index)">鍒犻櫎</el-button></div>
+ <el-row :gutter="16">
+ <el-col :span="8"><el-form-item label="妯″潡鍚嶇О" required><el-input v-model="module.moduleName" maxlength="200" /></el-form-item></el-col>
+ <el-col :span="8"><el-form-item label="棰勮寮�濮�" required><el-date-picker v-model="module.plannedStartDate" type="date" value-format="YYYY-MM-DD" style="width:100%" /></el-form-item></el-col>
+ <el-col :span="8"><el-form-item label="椤圭洰宸ヤ綔閲�" required><el-input-number v-model="module.projectWeight" :min="0" :max="moduleWeightLimit(index)" :precision="2" /><span class="unit">%</span><div class="field-hint">鍏朵粬妯″潡 {{ otherStartModuleWeight(index) }}%锛屽綋鍓嶆渶澶� {{ moduleWeightLimit(index) }}%</div></el-form-item></el-col>
</el-row>
-
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="椤圭洰鍒嗙被" prop="projectClassification">
- <el-select
- v-model="form.projectClassification"
- placeholder="璇烽�夋嫨"
- clearable
- filterable
- allow-create
- default-first-option
- style="width: 100%"
- >
- <el-option
- v-for="c in projectClassificationOptions"
- :key="c"
- :label="c"
- :value="c"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="椤圭洰鏉ユ簮" prop="projectSource">
- <el-select
- v-model="form.projectSource"
- placeholder="璇烽�夋嫨"
- clearable
- filterable
- allow-create
- default-first-option
- style="width: 100%"
- >
- <el-option label="鎵嬪姩娣诲姞" value="鎵嬪姩娣诲姞" />
- <el-option label="涓氬姟瀹℃壒" value="涓氬姟瀹℃壒" />
- <el-option label="鍏朵粬" value="鍏朵粬" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
-
- <el-row v-if="isFromContract" :gutter="20">
- <el-col :span="8">
- <el-form-item label="鍚堝悓閲戦(鍏�)">
- <el-input :model-value="form.projectAmount" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="鍚堝悓鏃ユ湡">
- <el-input :model-value="form.orderDate" disabled />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="10" >
- <el-col :span="24">
- <el-form-item label="闄勪欢" prop="attachmentIds">
- <AttachmentUploadFile
- v-model:file-list="fileList"
- :disabled="isView"
- :limit="10"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row v-if="false" :gutter="20">
- <el-col :span="24">
- <el-form-item label="澶囨敞" prop="remark">
- <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="璇疯緭鍏�" maxlength="100" show-word-limit />
- </el-form-item>
- </el-col>
+ <el-row :gutter="16">
+ <el-col :span="12"><el-form-item label="妯″潡鎵ц浜�" required><el-select v-model="module.memberIds" multiple filterable style="width:100%"><el-option v-for="u in projectExecutorOptions" :key="u.value" :label="u.label" :value="u.value" /></el-select></el-form-item></el-col>
+ <el-col :span="12"><el-form-item label="妯″潡姒傝" required><el-input v-model="module.summary" type="textarea" :rows="2" maxlength="1000" /></el-form-item></el-col>
</el-row>
</div>
- </div>
-
- <div v-if="false" class="section">
- <div class="section-header" @click="toggleSection('team')">
- <div class="section-title">
- <span class="section-bar" />
- <span>椤圭洰鍥㈤槦</span>
- </div>
- <div class="section-actions" @click.stop>
- <el-button v-if="!isView" type="primary" :icon="Plus" @click="addTeamRow">鏂板琛�</el-button>
- <el-icon class="toggle-icon" @click="toggleSection('team')">
- <ArrowDown v-if="sectionCollapsed.team" />
- <ArrowUp v-else />
- </el-icon>
- </div>
- </div>
- <div v-show="!sectionCollapsed.team" class="section-body">
- <PIMTable
- :column="teamColumns"
- :tableData="form.teamList"
- :tableLoading="false"
- :isSelection="false"
- :isShowPagination="false"
- height="220"
- >
- <template #memberId="{ row }">
- <el-select v-model="row.memberId" placeholder="璇烽�夋嫨" filterable clearable style="width: 100%" :disabled="isView">
- <el-option v-for="u in userOptions" :key="u.value" :label="u.label" :value="u.value" />
- </el-select>
- </template>
- <template #roleId="{ row }">
- <el-select v-model="row.roleId" placeholder="璇烽�夋嫨" clearable style="width: 100%" :disabled="isView">
- <el-option v-for="r in roleOptions" :key="r.value" :label="r.label" :value="r.value" />
- </el-select>
- </template>
- <template #enterDate="{ row }">
- <el-date-picker
- v-model="row.enterDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- :disabled="isView"
- />
- </template>
- <template #leaveDate="{ row }">
- <el-date-picker
- v-model="row.leaveDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- :disabled="isView"
- />
- </template>
- <template #phone="{ row }">
- <el-input v-model="row.phone" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #teamRemark="{ row }">
- <el-input v-model="row.remark" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #teamAction="{ row, index }">
- <el-button v-if="!isView" link type="danger" :icon="Delete" @click="removeTeamRow(index)">鍒犻櫎</el-button>
- <span v-else>鈥�</span>
- </template>
- </PIMTable>
- </div>
- </div>
-
- <!-- <div class="section">
- <div class="section-header" @click="toggleSection('phase')">
- <div class="section-title">
- <span class="section-bar" />
- <span>椤圭洰闃舵</span>
- </div>
- <div class="section-actions" @click.stop>
- <el-button v-if="!isView" type="primary" :icon="Plus" @click="addPhaseRow">鏂板琛�</el-button>
- <el-icon class="toggle-icon" @click="toggleSection('phase')">
- <ArrowDown v-if="sectionCollapsed.phase" />
- <ArrowUp v-else />
- </el-icon>
- </div>
- </div>
- <div v-show="!sectionCollapsed.phase" class="section-body">
- <PIMTable
- :column="phaseColumns"
- :tableData="form.phaseList"
- :tableLoading="false"
- :isSelection="false"
- :isShowPagination="false"
- height="240"
- >
- <template #phaseName="{ row }">
- <el-input v-model="row.phaseName" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #phaseDesc="{ row }">
- <el-input v-model="row.description" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #ownerId="{ row }">
- <el-select v-model="row.ownerId" placeholder="璇烽�夋嫨" filterable clearable style="width: 100%" :disabled="isView">
- <el-option v-for="u in userOptions" :key="u.value" :label="u.label" :value="u.value" />
- </el-select>
- </template>
- <template #planDays="{ row }">
- <el-input-number v-model="row.planDays" :min="0" controls-position="right" style="width: 100%" :disabled="isView" />
- </template>
- <template #planStart="{ row }">
- <el-date-picker
- v-model="row.planStartDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- :disabled="isView"
- />
- </template>
- <template #planEnd="{ row }">
- <el-date-picker
- v-model="row.planEndDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- :disabled="isView"
- />
- </template>
- <template #progress="{ row }">
- <el-input-number v-model="row.progress" :min="0" :max="100" controls-position="right" style="width: 100%" :disabled="isView" />
- </template>
- <template #actualStart="{ row }">
- <el-date-picker
- v-model="row.actualStartDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- :disabled="isView"
- />
- </template>
- <template #actualEnd="{ row }">
- <el-date-picker
- v-model="row.actualEndDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- :disabled="isView"
- />
- </template>
- <template #overdueDays="{ row }">
- <el-input-number v-model="row.overdueDays" :min="0" controls-position="right" style="width: 100%" :disabled="isView" />
- </template>
- <template #completion="{ row }">
- <el-input v-model="row.completionRemark" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #phaseAction="{ row, index }">
- <el-button v-if="!isView" link type="danger" :icon="Delete" @click="removePhaseRow(index)">鍒犻櫎</el-button>
- <span v-else>鈥�</span>
- </template>
- </PIMTable>
- </div>
- </div> -->
-
- <div v-if="false" class="section">
- <div class="section-header" @click="toggleSection('address')">
- <div class="section-title">
- <span class="section-bar" />
- <span>鏀惰揣鍦板潃</span>
- </div>
- <div class="section-actions" @click.stop>
- <el-button v-if="!isView" type="primary" :icon="Plus" @click="addAddressRow">鏂板琛�</el-button>
- <el-icon class="toggle-icon" @click="toggleSection('address')">
- <ArrowDown v-if="sectionCollapsed.address" />
- <ArrowUp v-else />
- </el-icon>
- </div>
- </div>
- <div v-show="!sectionCollapsed.address" class="section-body">
- <PIMTable
- :column="addressColumns"
- :tableData="form.addressList"
- :tableLoading="false"
- :isSelection="false"
- :isShowPagination="false"
- height="200"
- >
- <template #receiver="{ row }">
- <el-input v-model="row.receiver" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #receiverPhone="{ row }">
- <el-input v-model="row.phone" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #receiverAddress="{ row }">
- <el-input v-model="row.address" placeholder="璇疯緭鍏�" clearable :disabled="isView" />
- </template>
- <template #addressAction="{ row, index }">
- <el-button v-if="!isView" link type="danger" :icon="Delete" @click="removeAddressRow(index)">鍒犻櫎</el-button>
- <span v-else>鈥�</span>
- </template>
- </PIMTable>
- </div>
- </div>
-
- <div v-if="false" class="section">
- <div class="section-header" @click="toggleSection('contact')">
- <div class="section-title">
- <span class="section-bar" />
- <span>鑱旂郴淇℃伅</span>
- </div>
- <el-icon class="toggle-icon">
- <ArrowDown v-if="sectionCollapsed.contact" />
- <ArrowUp v-else />
- </el-icon>
- </div>
- <div v-show="!sectionCollapsed.contact" class="section-body">
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="鑱旂郴浜哄鍚�" prop="contactName">
- <el-input v-model="form.contactName" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="鎬у埆" prop="contactGender">
- <el-select v-model="form.contactGender" placeholder="璇烽�夋嫨" clearable style="width: 100%">
- <el-option label="鐢�" value="1" />
- <el-option label="濂�" value="2" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="鐢熸棩" prop="contactBirthday">
- <el-date-picker
- v-model="form.contactBirthday"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="閭" prop="contactEmail">
- <el-input v-model="form.contactEmail" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- </el-row>
-
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="閮ㄩ棬" prop="contactDept">
- <el-input v-model="form.contactDept" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="鑱屽姟" prop="contactJob">
- <el-input v-model="form.contactJob" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="鎵嬫満鍙风爜" prop="contactMobile">
- <el-input v-model="form.contactMobile" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="寰俊鍙风爜" prop="contactWechat">
- <el-input v-model="form.contactWechat" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- </el-row>
-
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="QQ" prop="contactQq">
- <el-input v-model="form.contactQq" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="浼佷笟寰俊" prop="contactWorkWechat">
- <el-input v-model="form.contactWorkWechat" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鍦板潃" prop="contactAddress">
- <el-input v-model="form.contactAddress" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- </el-row>
-
- <el-row :gutter="20">
- <el-col :span="24">
- <el-form-item label="澶囨敞" prop="contactRemark">
- <el-input v-model="form.contactRemark" type="textarea" :rows="2" placeholder="璇疯緭鍏�" maxlength="200" show-word-limit />
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- </div>
+ <div class="module-actions"><span>褰撳墠妯″潡宸ヤ綔閲忓悎璁★細{{ startModuleWeight }}%</span><el-button type="primary" plain @click="addStartModule">+ 娣诲姞妯″潡</el-button></div>
+ </template>
</el-form>
-
- <template #footer>
- <div class="dialog-footer">
- <el-button v-if="!isView" type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDialog">{{ isView ? '鍏抽棴' : '鍙栨秷' }}</el-button>
- </div>
- </template>
+ <template #footer><el-button @click="visible=false">鍙栨秷</el-button><el-button type="primary" :loading="saving" @click="submit">{{ personnelOnly ? '淇濆瓨鎵ц浜�' : startProject ? '淇濆瓨骞跺紑濮嬮」鐩�' : '淇濆瓨' }}</el-button></template>
</el-dialog>
-
- <FormDialog
- v-model="productFormVisible"
- :title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'"
- :width="'40%'"
- :operation-type="productOperationType"
- @close="closeProductDia"
- @confirm="submitProduct"
- @cancel="closeProductDia"
- >
- <el-form ref="productFormRef" :model="productForm" label-width="140px" label-position="top" :rules="productRules">
- <el-row :gutter="30">
- <el-col :span="24">
- <el-form-item label="浜у搧澶х被锛�" prop="productCategoryId">
- <el-tree-select
- v-model="productForm.productCategoryId"
- placeholder="璇烽�夋嫨"
- clearable
- check-strictly
- :data="productCategoryOptions"
- :render-after-expand="false"
- style="width: 100%"
- @change="getModels"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="24">
- <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
- <el-select v-model="productForm.productModelId" placeholder="璇烽�夋嫨" clearable filterable @change="getProductModel">
- <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="鍗曚綅锛�" prop="unit">
- <el-input v-model="productForm.unit" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="绋庣巼(%)锛�" prop="taxRate">
- <el-select v-model="productForm.taxRate" placeholder="璇烽�夋嫨" clearable @change="calculateFromTaxRate">
- <el-option
- v-for="dict in tax_rate"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="鍚◣鍗曚环(鍏�)锛�" prop="taxInclusiveUnitPrice">
- <el-input-number
- v-model="productForm.taxInclusiveUnitPrice"
- :step="0.01"
- :min="0"
- :precision="2"
- style="width: 100%"
- placeholder="璇疯緭鍏�"
- clearable
- @change="calculateFromUnitPrice"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鏁伴噺锛�" prop="quantity">
- <el-input-number
- v-model="productForm.quantity"
- :step="0.1"
- :min="0"
- :precision="2"
- style="width: 100%"
- placeholder="璇疯緭鍏�"
- clearable
- @change="calculateFromQuantity"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="鍚◣鎬讳环(鍏�)锛�" prop="taxInclusiveTotalPrice">
- <el-input v-model="productForm.taxInclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable @change="calculateFromTotalPrice" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="涓嶅惈绋庢�讳环(鍏�)锛�" prop="taxExclusiveTotalPrice">
- <el-input v-model="productForm.taxExclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable @change="calculateFromExclusiveTotalPrice" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="鍙戠エ绫诲瀷锛�" prop="invoiceType">
- <el-select v-model="productForm.invoiceType" placeholder="璇烽�夋嫨" clearable>
- <el-option label="澧炴櫘绁�" value="澧炴櫘绁�" />
- <el-option label="澧炰笓绁�" value="澧炰笓绁�" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </FormDialog>
</template>
-<script setup name="ProjectManagementFormDia">
-import { computed, getCurrentInstance, reactive, ref, toRefs } from 'vue'
-import { ArrowDown, ArrowUp, Delete, Plus } from '@element-plus/icons-vue'
+<script setup>
+import { computed, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import AttachmentUploadFile from '@/components/AttachmentUpload/file/index.vue'
-import { listCustomer } from '@/api/basicData/customer.js'
-import PIMTable from '@/components/PIMTable/PIMTable.vue'
-import FormDialog from '@/components/Dialog/FormDialog.vue'
-import { listPlan } from '@/api/projectManagement/projectType'
-import { findRoleListPage } from '@/api/projectManagement/role'
-import { userListAll } from '@/api/publicApi'
import { addProject, getProject, updateProject } from '@/api/projectManagement/project'
-import { modelList, productTreeList } from '@/api/basicData/product'
-import { delProduct as delSalesProduct } from '@/api/salesManagement/salesLedger'
+import { listCustomer } from '@/api/basicData/customer'
+import { deleteProjectModule, getProjectWorkflow, listProjectCategories, saveProjectModule, startProjectWorkflow, updateProjectExecutors } from '@/api/projectManagement/workflow'
+import { userListAll } from '@/api/publicApi'
const emit = defineEmits(['completed'])
-const { proxy } = getCurrentInstance()
-const { bill_status, project_management, plan_status, tax_rate } = proxy.useDict('bill_status', 'project_management', 'plan_status', 'tax_rate')
-
-const dialogVisible = ref(false)
+const visible = ref(false)
+const saving = ref(false)
+const startProject = ref(false)
+const personnelOnly = ref(false)
const operationType = ref('add')
const formRef = ref()
-const fileList = ref([])
-const customerOptions = ref([])
+const customers = ref([])
+const users = ref([])
+const categoryTree = ref([])
+const files = ref([])
+const startModules = ref([])
+const originalModuleIds = ref([])
+const form = reactive({ id:null,no:'',title:'',clientId:null,clientName:'',source:'鎵嬪姩鍒涘缓',sourceBusinessId:null,projectClassification:'',planStartTime:'',planEndTime:'',projectLeaderId:null,projectLeaderName:'',projectManagerIds:[],projectManagerNames:[],projectExecutorIds:[],projectExecutorNames:[],followCycle:'MONTH',followDetail:'',currentPhase:'鏈紑濮�',remark:'' })
+const rules = {
+ title:[{ required:true,message:'璇疯緭鍏ラ」鐩悕绉�',trigger:'blur' }], clientName:[{ required:true,message:'璇烽�夋嫨瀹㈡埛',trigger:'change' }],
+ projectClassification:[{ required:true,message:'璇烽�夋嫨椤圭洰鍒嗙被',trigger:'change' }], planStartTime:[{ required:true,message:'璇烽�夋嫨棰勮寮�濮嬫椂闂�',trigger:'change' }],
+ planEndTime:[{ required:true,message:'璇烽�夋嫨棰勮缁撴潫鏃堕棿',trigger:'change' }], projectLeaderId:[{ required:true,message:'璇烽�夋嫨椤圭洰璐熻矗浜�',trigger:'change' }],
+ projectManagerIds:[{ required:true,type:'array',min:1,message:'璇烽�夋嫨鑷冲皯涓�鍚嶉」鐩粡鐞�',trigger:'change' }], followCycle:[{ required:true,message:'璇烽�夋嫨璺熻繘鍛ㄦ湡',trigger:'change' }],
+ projectExecutorIds:[{ required:true,type:'array',min:1,message:'璇烽�夋嫨鑷冲皯涓�鍚嶉」鐩墽琛屼汉',trigger:'change' }],
+ followDetail:[{ required:true,message:'璇疯緭鍏ヨ窡杩涜姹�',trigger:'blur' }]
+}
+const isBusinessProject = computed(() => !!form.sourceBusinessId || form.source === '涓氬姟鐢熸垚' || form.source === '涓氬姟瀹℃壒')
+const startModuleWeight = computed(() => startModules.value.reduce((sum,module)=>sum+Number(module.projectWeight||0),0).toFixed(2))
+const projectExecutorOptions = computed(() => users.value.filter(user=>form.projectExecutorIds.some(id=>String(id)===String(user.value))))
+const dialogTitle = computed(() => personnelOnly.value ? '璋冩暣椤圭洰鎵ц浜�' : startProject.value ? '濉啓绔嬮」淇℃伅骞跺紑濮嬮」鐩�' : operationType.value === 'add' ? '鎵嬪姩鍒涘缓椤圭洰' : '缂栬緫椤圭洰鍩烘湰鎯呭喌')
-const projectTypeOptions = ref([])
-// 椤圭洰鍒嗙被锛氬厛鍐欐鍑犱釜锛屽悗缁彲鍒囨崲涓哄瓧鍏�
-const projectClassificationOptions = ['鏁板瓧鍖栬浆鍨�', '鏅鸿兘鍒堕��', '绯荤粺闆嗘垚', '鍏朵粬']
-const roleOptions = ref([])
-const userOptions = ref([])
-const productData = ref([])
-const productSelectedRows = ref([])
-const productCategoryOptions = ref([])
-const modelOptions = ref([])
-const productFormVisible = ref(false)
-const productOperationType = ref('add')
-const productFormRef = ref()
-const productIndex = ref(0)
-const isCalculating = ref(false)
-
-const productFormData = reactive({
- productForm: {
- productCategoryId: undefined,
- productCategory: '',
- productModelId: undefined,
- specificationModel: '',
- unit: '',
- quantity: '',
- taxInclusiveUnitPrice: '',
- taxRate: '',
- taxInclusiveTotalPrice: '',
- taxExclusiveTotalPrice: '',
- invoiceType: ''
- },
- productRules: {
- productCategoryId: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
- productModelId: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
- unit: [{ required: true, message: '璇疯緭鍏�', trigger: 'blur' }],
- quantity: [{ required: true, message: '璇疯緭鍏�', trigger: 'blur' }],
- taxInclusiveUnitPrice: [{ required: true, message: '璇疯緭鍏�', trigger: 'blur' }],
- taxRate: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
- taxInclusiveTotalPrice: [{ required: true, message: '璇疯緭鍏�', trigger: 'blur' }],
- taxExclusiveTotalPrice: [{ required: true, message: '璇疯緭鍏�', trigger: 'blur' }],
- invoiceType: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }]
- }
-})
-
-const { productForm, productRules } = toRefs(productFormData)
-
-const data = reactive({
- form: {
- id: undefined,
- clientId: undefined,
- parentProjectId: undefined,
- projectManagementPlanId: undefined,
- managerId: undefined,
- salesmanId: undefined,
- salesmanName: '',
- actualStartDate: '',
- actualEndDate: '',
- departmentId: undefined,
- departmentName: '',
- orderDate: '',
- billNo: '',
- projectName: '',
- customerName: '',
- parentProjectName: '',
- setupDate: todayStr(),
- projectSource: '鎵嬪姩娣诲姞',
- projectClassification: '',
- creatorName: '',
- billStatus: '',
- projectStage: '',
- estimatedDays: 0,
- planStartDate: '',
- planEndDate: '',
- projectManagementPlanId: undefined,
- projectAmount: 0,
- auditStatus: '',
- remark: '',
- attachmentIds: [],
- teamList: [],
- phaseList: [],
- addressList: [],
- contactName: '',
- contactGender: '',
- contactBirthday: '',
- contactEmail: '',
- contactDept: '',
- contactJob: '',
- contactMobile: '',
- contactWechat: '',
- contactQq: '',
- contactWorkWechat: '',
- contactAddress: '',
- contactRemark: ''
- },
- rules: {
- projectName: [{ required: true, message: '璇疯緭鍏ラ」鐩悕绉�', trigger: 'blur' }]
- }
-})
-
-const { form, rules } = toRefs(data)
-
-const sectionCollapsed = reactive({
- base: false,
- product: false,
- team: false,
- phase: false,
- address: false,
- contact: false
-})
-
-const isView = computed(() => operationType.value === 'view')
-// 鍚堝悓鐢熸垚鐨勯」鐩細鏉ユ簮涓轰笟鍔″鎵癸紝鍚堝悓淇℃伅鍙灞曠ず
-const isFromContract = computed(() => operationType.value !== 'add' && form.value.projectSource === '涓氬姟瀹℃壒')
-const dialogTitle = computed(() => {
- if (operationType.value === 'add') return '鏂板椤圭洰'
- if (operationType.value === 'edit') return '缂栬緫椤圭洰'
- return '椤圭洰璇︽儏'
-})
-
-const teamColumns = [
- { label: '濮撳悕', prop: 'memberId', align: 'center', width: 180, dataType: 'slot', slot: 'memberId' },
- { label: '椤圭洰缁勮鑹�', prop: 'roleId', align: 'center', width: 160, dataType: 'slot', slot: 'roleId' },
- { label: '杩涘叆鏃ユ湡', prop: 'enterDate', align: 'center', width: 160, dataType: 'slot', slot: 'enterDate' },
- { label: '绂诲紑鏃ユ湡', prop: 'leaveDate', align: 'center', width: 160, dataType: 'slot', slot: 'leaveDate' },
- { label: '鑱旂郴鏂瑰紡', prop: 'phone', align: 'center', width: 180, dataType: 'slot', slot: 'phone' },
- { label: '澶囨敞', prop: 'remark', align: 'center', dataType: 'slot', slot: 'teamRemark' },
- { label: '鎿嶄綔', prop: 'action', align: 'center', width: 100, dataType: 'slot', slot: 'teamAction', fixed: 'right' }
-]
-
-const phaseColumns = [
- { label: '闃舵鍚嶇О', prop: 'phaseName', align: 'center', width: 160, dataType: 'slot', slot: 'phaseName' },
- { label: '鎻忚堪', prop: 'description', align: 'center', width: 200, dataType: 'slot', slot: 'phaseDesc' },
- { label: '璐熻矗浜�', prop: 'ownerId', align: 'center', width: 160, dataType: 'slot', slot: 'ownerId' },
- { label: '棰勮宸ユ湡(澶�)', prop: 'planDays', align: 'center', width: 140, dataType: 'slot', slot: 'planDays' },
- { label: '璁″垝寮�濮嬫棩鏈�', prop: 'planStartDate', align: 'center', width: 160, dataType: 'slot', slot: 'planStart' },
- { label: '璁″垝缁撴潫鏃ユ湡', prop: 'planEndDate', align: 'center', width: 160, dataType: 'slot', slot: 'planEnd' },
- { label: '杩涘害(%)', prop: 'progress', align: 'center', width: 120, dataType: 'slot', slot: 'progress' },
- { label: '瀹為檯寮�濮嬫棩鏈�', prop: 'actualStartDate', align: 'center', width: 160, dataType: 'slot', slot: 'actualStart' },
- { label: '瀹為檯缁撴潫鏃ユ湡', prop: 'actualEndDate', align: 'center', width: 160, dataType: 'slot', slot: 'actualEnd' },
- { label: '閫炬湡澶╂暟', prop: 'overdueDays', align: 'center', width: 120, dataType: 'slot', slot: 'overdueDays' },
- { label: '瀹屾垚鎯呭喌', prop: 'completionRemark', align: 'center', width: 200, dataType: 'slot', slot: 'completion' },
- { label: '鎿嶄綔', prop: 'action', align: 'center', width: 100, dataType: 'slot', slot: 'phaseAction', fixed: 'right' }
-]
-
-const addressColumns = [
- { label: '鏀惰揣浜�', prop: 'receiver', align: 'center', width: 180, dataType: 'slot', slot: 'receiver' },
- { label: '鑱旂郴鏂瑰紡', prop: 'phone', align: 'center', width: 180, dataType: 'slot', slot: 'receiverPhone' },
- { label: '鏀惰揣鍦板潃', prop: 'address', align: 'center', dataType: 'slot', slot: 'receiverAddress' },
- { label: '鎿嶄綔', prop: 'action', align: 'center', width: 100, dataType: 'slot', slot: 'addressAction', fixed: 'right' }
-]
-
-function toggleSection(key) {
- sectionCollapsed[key] = !sectionCollapsed[key]
+function buildTree(list) { const map=new Map((list||[]).map(x=>[String(x.id),{...x,children:[]}])) ; const roots=[]; map.forEach(node=>{ const parent=map.get(String(node.parentId)); if(parent&&node.parentId) parent.children.push(node); else roots.push(node) }); return roots }
+async function loadOptions() {
+ const [customerRes,userRes,categoryRes] = await Promise.all([listCustomer({ current:-1,size:-1,type:0 }),userListAll(),listProjectCategories()])
+ const customerData=customerRes?.rows||customerRes?.data?.records||customerRes?.data||[]; customers.value=Array.isArray(customerData)?customerData:[]
+ const userData=userRes?.data||userRes?.rows||userRes||[]; users.value=(Array.isArray(userData)?userData:[]).map(u=>({ label:u.nickName||u.userName||u.name,value:u.userId||u.id }))
+ categoryTree.value=buildTree(categoryRes?.data||[])
+}
+function reset() { Object.assign(form,{ id:null,no:'',title:'',clientId:null,clientName:'',source:'鎵嬪姩鍒涘缓',sourceBusinessId:null,projectClassification:'',planStartTime:'',planEndTime:'',projectLeaderId:null,projectLeaderName:'',projectManagerIds:[],projectManagerNames:[],projectExecutorIds:[],projectExecutorNames:[],followCycle:'MONTH',followDetail:'',currentPhase:'鏈紑濮�',remark:'' }); files.value=[];startModules.value=[];originalModuleIds.value=[] }
+function syncCustomer(name) { const item=customers.value.find(x=>x.customerName===name); form.clientId=item?.id||item?.customerId||null }
+function syncLeader(id) { form.projectLeaderName=users.value.find(u=>String(u.value)===String(id))?.label||'' }
+function normalizeFiles(list) { return (list||[]).map(f=>({ id:f.id??f.fileId??f.rawData?.id,name:f.name??f.fileName??f.rawData?.originalFilename,url:f.url??f.fileUrl??f.rawData?.url })).filter(f=>f.id||f.url) }
+function newModule(module={}) { return { localKey:module.id||`${Date.now()}-${Math.random()}`,id:module.id||null,moduleName:module.moduleName||'',plannedStartDate:module.plannedStartDate||'',summary:module.summary||'',projectWeight:Number(module.projectWeight||0),memberIds:(module.members||[]).map(member=>member.userId) } }
+function addStartModule(){startModules.value.push(newModule())}
+function removeStartModule(index){startModules.value.splice(index,1)}
+function otherStartModuleWeight(index){return startModules.value.reduce((sum,module,i)=>sum+(i===index?0:Number(module.projectWeight||0)),0).toFixed(2)}
+function moduleWeightLimit(index){return Math.max(0,100-Number(otherStartModuleWeight(index)))}
+function validateStartModules(){
+ if(!startModules.value.length){ElMessage.warning('椤圭洰寮�濮嬪墠璇疯嚦灏戞坊鍔犱竴涓」鐩ā鍧�');return false}
+ if(startModules.value.some(module=>!module.moduleName||!module.plannedStartDate||!module.summary||!module.memberIds.length)){ElMessage.warning('璇峰畬鏁村~鍐欐瘡涓ā鍧楃殑鍚嶇О銆侀璁″紑濮嬫椂闂淬�佹ā鍧楁瑕佸拰鎵ц浜�');return false}
+ if(Number(startModuleWeight.value)!==100){ElMessage.warning('鎵�鏈夋ā鍧楃殑椤圭洰宸ヤ綔閲忓崰姣斿悎璁″繀椤讳负100%');return false}
+ return true
}
-function todayStr() {
- const d = new Date()
- const pad = n => String(n).padStart(2, '0')
- return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
+async function openDialog(options={}) {
+ reset(); operationType.value=options.operationType||'add'; startProject.value=!!options.startProject; personnelOnly.value=!!options.personnelOnly; await loadOptions()
+ const id=options.row?.id
+ if(id) { const res=await getProject(id); const detail=res?.data?.data??res?.data??res; const info=detail?.info||{}; Object.assign(form,info,{ projectManagerIds:info.projectManagerIds||[],projectManagerNames:info.projectManagerNames||[],projectExecutorIds:info.projectExecutorIds||[],projectExecutorNames:info.projectExecutorNames||[] }); files.value=(info.attachmentList||[]).map(f=>({...f})) }
+ if(startProject.value&&id){const workflow=await getProjectWorkflow(id);const modules=workflow?.data?.modules||[];startModules.value=modules.map(newModule);originalModuleIds.value=modules.map(module=>module.id);if(!startModules.value.length)addStartModule()}
+ visible.value=true
}
-function resetFormData() {
- Object.assign(form.value, {
- id: undefined,
- clientId: undefined,
- parentProjectId: undefined,
- projectManagementPlanId: undefined,
- managerId: undefined,
- salesmanId: undefined,
- salesmanName: '',
- actualStartDate: '',
- actualEndDate: '',
- departmentId: undefined,
- departmentName: '',
- orderDate: '',
- billNo: '',
- projectName: '',
- customerName: '',
- parentProjectName: '',
- setupDate: todayStr(),
- projectSource: '鎵嬪姩娣诲姞',
- projectClassification: '',
- creatorName: '',
- billStatus: '',
- projectStage: '',
- estimatedDays: 0,
- planStartDate: '',
- planEndDate: '',
- projectManagementPlanId: undefined,
- projectAmount: 0,
- auditStatus: '',
- remark: '',
- attachmentIds: [],
- teamList: [],
- phaseList: [],
- addressList: [],
- contactName: '',
- contactGender: '',
- contactBirthday: '',
- contactEmail: '',
- contactDept: '',
- contactJob: '',
- contactMobile: '',
- contactWechat: '',
- contactQq: '',
- contactWorkWechat: '',
- contactAddress: '',
- contactRemark: ''
- })
- fileList.value = []
- productData.value = []
-}
-
-function formattedNumber(row, column, cellValue) {
- const val = Number(cellValue ?? 0)
- return Number.isFinite(val) ? val.toFixed(2) : '0.00'
-}
-
-function summarizeProductTable(param) {
- return proxy.summarizeTable(param, ['taxInclusiveTotalPrice', 'taxExclusiveTotalPrice'])
-}
-
-function productSelected(selection) {
- productSelectedRows.value = selection
-}
-
-function convertIdToValue(data) {
- return (Array.isArray(data) ? data : []).map(item => {
- const { id, children, ...rest } = item
- const newItem = {
- ...rest,
- value: id
- }
- if (children && children.length > 0) {
- newItem.children = convertIdToValue(children)
- }
- return newItem
- })
-}
-
-function findNodeById(nodes, productId) {
- for (let i = 0; i < (nodes || []).length; i++) {
- if (nodes[i].value === productId) {
- return nodes[i].label
- }
- if (nodes[i].children && nodes[i].children.length > 0) {
- const foundNode = findNodeById(nodes[i].children, productId)
- if (foundNode) return foundNode
- }
- }
- return null
-}
-
-function findNodeIdByLabel(nodes, label) {
- if (!label) return null
- for (let i = 0; i < (nodes || []).length; i++) {
- const node = nodes[i]
- if (node.label === label) return node.value
- if (node.children && node.children.length > 0) {
- const found = findNodeIdByLabel(node.children, label)
- if (found !== null && found !== undefined) return found
- }
- }
- return null
-}
-
-function getProductOptions() {
- return productTreeList().then(res => {
- const list = res?.data || res
- productCategoryOptions.value = convertIdToValue(list)
- return productCategoryOptions.value
- })
-}
-
-function getModels(value) {
- const categoryLabel = findNodeById(productCategoryOptions.value, value)
- productForm.value.productCategory = categoryLabel || ''
- modelList({ id: value }).then(res => {
- modelOptions.value = res?.data || res || []
- })
-}
-
-function getProductModel(value) {
- const index = (modelOptions.value || []).findIndex(item => item.id === value)
- if (index !== -1) {
- productForm.value.specificationModel = modelOptions.value[index].model
- productForm.value.unit = modelOptions.value[index].unit
- } else {
- productForm.value.specificationModel = ''
- productForm.value.unit = ''
- }
-}
-
-async function openProductForm(type, row, index) {
- productOperationType.value = type
- productIndex.value = index || 0
- productForm.value = {}
- proxy.resetForm('productFormRef')
-
- if (!productCategoryOptions.value || productCategoryOptions.value.length === 0) {
- await getProductOptions()
- }
-
- if (type === 'edit' && row) {
- productForm.value = { ...row }
- try {
- const categoryId = findNodeIdByLabel(productCategoryOptions.value, productForm.value.productCategory)
- if (categoryId) {
- productForm.value.productCategoryId = categoryId
- const models = await modelList({ id: categoryId })
- modelOptions.value = models?.data || models || []
- const currentModel = (modelOptions.value || []).find(m => m.model === productForm.value.specificationModel)
- if (currentModel) {
- productForm.value.productModelId = currentModel.id
- }
- }
- } catch {}
- } else {
- productForm.value = {
- productCategoryId: undefined,
- productCategory: '',
- productModelId: undefined,
- specificationModel: '',
- unit: '',
- quantity: '',
- taxInclusiveUnitPrice: '',
- taxRate: '',
- taxInclusiveTotalPrice: '',
- taxExclusiveTotalPrice: '',
- invoiceType: ''
- }
- }
-
- productFormVisible.value = true
-}
-
-function closeProductDia() {
- proxy.resetForm('productFormRef')
- productFormVisible.value = false
-}
-
-function submitProduct() {
- productFormRef.value?.validate?.(valid => {
- if (!valid) return
- const payload = { ...productForm.value }
- if (productOperationType.value === 'add') {
- productData.value.push(payload)
- } else {
- productData.value[productIndex.value] = payload
- }
- closeProductDia()
- })
-}
-
-function deleteProduct() {
- if (!productSelectedRows.value || productSelectedRows.value.length === 0) {
- proxy.$modal?.msgWarning?.('璇烽�夋嫨鏁版嵁')
+async function submit() {
+ form.projectExecutorNames=form.projectExecutorIds.map(id=>users.value.find(u=>String(u.value)===String(id))?.label||'').filter(Boolean)
+ if(personnelOnly.value){
+ if(!form.projectExecutorIds.length)return ElMessage.warning('璇疯嚦灏戜繚鐣欎竴鍚嶉」鐩墽琛屼汉')
+ saving.value=true
+ try{await updateProjectExecutors({projectId:form.id,executors:form.projectExecutorIds.map(id=>({userId:id,userName:users.value.find(user=>String(user.value)===String(id))?.label||''}))});ElMessage.success('椤圭洰鎵ц浜哄凡鏇存柊');visible.value=false;emit('completed',{id:form.id})}finally{saving.value=false}
return
}
- const selectedIds = productSelectedRows.value.map(r => r?.id).filter(Boolean)
- if (operationType.value !== 'add' && selectedIds.length > 0) {
- delSalesProduct(selectedIds)
- .then(() => {
- proxy.$modal?.msgSuccess?.('鍒犻櫎鎴愬姛')
- productData.value = productData.value.filter(row => !selectedIds.includes(row?.id))
- productSelectedRows.value = []
- })
- .catch(() => {})
- return
- }
-
- productData.value = productData.value.filter(row => !productSelectedRows.value.includes(row))
- productSelectedRows.value = []
-}
-
-function calculateFromTotalPrice() {
- if (isCalculating.value) return
- const totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice)
- const quantity = parseFloat(productForm.value.quantity)
- if (!totalPrice || !quantity || quantity <= 0) return
- isCalculating.value = true
- productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2)
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(totalPrice, productForm.value.taxRate)
- }
- isCalculating.value = false
-}
-
-function calculateFromExclusiveTotalPrice() {
- if (!productForm.value.taxRate) {
- proxy.$modal?.msgWarning?.('璇峰厛閫夋嫨绋庣巼')
- return
- }
- if (isCalculating.value) return
- const exclusiveTotalPrice = parseFloat(productForm.value.taxExclusiveTotalPrice)
- const quantity = parseFloat(productForm.value.quantity)
- const taxRate = parseFloat(productForm.value.taxRate)
- if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) return
- isCalculating.value = true
- const taxRateDecimal = taxRate / 100
- const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal)
- productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2)
- productForm.value.taxInclusiveUnitPrice = (inclusiveTotalPrice / quantity).toFixed(2)
- isCalculating.value = false
-}
-
-function calculateFromQuantity() {
- if (!productForm.value.taxRate) {
- proxy.$modal?.msgWarning?.('璇峰厛閫夋嫨绋庣巼')
- return
- }
- if (isCalculating.value) return
- const quantity = parseFloat(productForm.value.quantity)
- const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice)
- if (!quantity || quantity <= 0 || !unitPrice) return
- isCalculating.value = true
- productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2)
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(
- productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
- )
- }
- isCalculating.value = false
-}
-
-function calculateFromUnitPrice() {
- if (!productForm.value.taxRate) {
- proxy.$modal?.msgWarning?.('璇峰厛閫夋嫨绋庣巼')
- return
- }
- if (isCalculating.value) return
- const quantity = parseFloat(productForm.value.quantity)
- const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice)
- if (!quantity || quantity <= 0 || !unitPrice) return
- isCalculating.value = true
- productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2)
- if (productForm.value.taxRate) {
- productForm.value.taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(
- productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
- )
- }
- isCalculating.value = false
-}
-
-function calculateFromTaxRate() {
- if (!productForm.value.taxRate) {
- proxy.$modal?.msgWarning?.('璇峰厛閫夋嫨绋庣巼')
- return
- }
- if (isCalculating.value) return
- const inclusiveTotalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice)
- const taxRate = parseFloat(productForm.value.taxRate)
- if (!inclusiveTotalPrice || !taxRate) return
- isCalculating.value = true
- productForm.value.taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(inclusiveTotalPrice, taxRate)
- isCalculating.value = false
-}
-
-async function loadProjectTypeOptions() {
+ await formRef.value?.validate()
+ if(form.planEndTime < form.planStartTime) return ElMessage.warning('棰勮缁撴潫鏃堕棿涓嶈兘鏃╀簬棰勮寮�濮嬫椂闂�')
+ if(startProject.value&&!validateStartModules()) return
+ form.projectManagerNames=form.projectManagerIds.map(id=>users.value.find(u=>String(u.value)===String(id))?.label||'').filter(Boolean)
+ const info={ ...form, currentPhase:startProject.value?'鏈紑濮�':form.currentPhase, establishTime:form.establishTime||new Date().toISOString().slice(0,10), managerId:form.projectLeaderId,managerName:form.projectLeaderName,attachmentIds:normalizeFiles(files.value).map(f=>f.id).filter(Boolean),projectManagementPlanId:null }
+ saving.value=true
try {
- const res = await listPlan({ current: 1, size: 999 })
- const records = res?.data?.records || res?.records || res?.rows || []
- projectTypeOptions.value = records.map(item => ({ label: item.name, value: item.id }))
- // 鏈寚瀹氳鍒掓椂锛岄粯璁や娇鐢ㄢ�滈」鐩敵鎶ュ叚闃舵鈥濊鍒�
- if (!form.value.projectManagementPlanId) {
- const defaultPlan = records.find(item => item.name === '椤圭洰鐢虫姤鍏樁娈�') || records[0]
- if (defaultPlan) form.value.projectManagementPlanId = defaultPlan.id
+ await (form.id?updateProject:addProject)({ info,shippingAddress:null,contractInfo:null,salesLedgerProductList:null })
+ if(startProject.value){
+ for(const module of startModules.value){
+ const members=module.memberIds.map(id=>({userId:id,userName:users.value.find(user=>String(user.value)===String(id))?.label||''}))
+ const res=await saveProjectModule({...module,projectId:form.id,members})
+ module.id=res?.data||module.id
+ }
+ const retainedIds=new Set(startModules.value.map(module=>String(module.id)))
+ for(const id of originalModuleIds.value.filter(id=>!retainedIds.has(String(id)))) await deleteProjectModule(id)
+ await startProjectWorkflow(form.id)
}
- } catch {
- projectTypeOptions.value = []
- }
+ ElMessage.success(startProject.value?'椤圭洰宸插紑濮�':'淇濆瓨鎴愬姛')
+ visible.value=false
+ emit('completed',{ id:form.id,startProject:startProject.value })
+ } finally { saving.value=false }
}
-
-async function loadRoleOptions() {
- try {
- const res = await findRoleListPage({ pageNum: 1, pageSize: 999 })
- const records = res?.data?.records || res?.rows || res?.records || []
- roleOptions.value = records.map(item => ({ label: item.roleName || item.name, value: item.id }))
- } catch {
- roleOptions.value = []
- }
-}
-
-async function loadUserOptions() {
- try {
- const res = await userListAll()
- const list = res?.data || res?.rows || res || []
- userOptions.value = (Array.isArray(list) ? list : []).map(u => ({
- label: u.nickName || u.userName || u.username || u.name,
- value: u.userId || u.id
- }))
- } catch {
- userOptions.value = []
- }
-}
-
-async function loadCustomerOptions() {
- try {
- const res = await listCustomer({ current: -1, size: -1, type: 0 })
- const records = res?.data?.records || res?.data || res?.records || []
- customerOptions.value = Array.isArray(records) ? records : []
- } catch {
- customerOptions.value = []
- }
-}
-
-function handleCustomerChange(customerName) {
- const customer = customerOptions.value.find(item => item.customerName === customerName)
- form.value.clientId = customer?.id ?? null
-}
-
-function addTeamRow() {
- form.value.teamList.push({
- memberId: undefined,
- roleId: undefined,
- enterDate: '',
- leaveDate: '',
- phone: '',
- remark: ''
- })
-}
-
-function removeTeamRow(index) {
- if (index > -1) form.value.teamList.splice(index, 1)
-}
-
-function addPhaseRow() {
- form.value.phaseList.push({
- phaseName: '',
- description: '',
- ownerId: undefined,
- planDays: 0,
- planStartDate: '',
- planEndDate: '',
- progress: 0,
- actualStartDate: '',
- actualEndDate: '',
- overdueDays: 0,
- completionRemark: ''
- })
-}
-
-function removePhaseRow(index) {
- if (index > -1) form.value.phaseList.splice(index, 1)
-}
-
-function addAddressRow() {
- form.value.addressList.push({
- receiver: '',
- phone: '',
- address: ''
- })
-}
-
-function removeAddressRow(index) {
- if (index > -1) form.value.addressList.splice(index, 1)
-}
-
-async function openDialog(payload = {}) {
- operationType.value = payload.operationType || 'add'
- resetFormData()
- await Promise.all([loadProjectTypeOptions(), loadRoleOptions(), loadUserOptions(), loadCustomerOptions(), getProductOptions()])
- if (payload.row?.id) {
- try {
- const res = await getProject(payload.row.id)
- const detail = res?.data?.data ?? res?.data ?? res
- const info = detail?.info || {}
- const shippingAddress = detail?.shippingAddress || {}
- const contractInfo = detail?.contractInfo || {}
-
- const normalizeId = v => {
- if (v === undefined || v === null || v === '') return undefined
- const n = Number(v)
- return Number.isNaN(n) ? v : n
- }
-
- const normalizeDictValue = v => {
- if (v === undefined || v === null || v === '') return ''
- return String(v)
- }
-
- const computeEstimatedDays = (start, end) => {
- if (!start || !end) return 0
- const startTime = new Date(`${start}T00:00:00`).getTime()
- const endTime = new Date(`${end}T00:00:00`).getTime()
- if (!Number.isFinite(startTime) || !Number.isFinite(endTime)) return 0
- if (endTime < startTime) return 0
- return Math.floor((endTime - startTime) / (24 * 60 * 60 * 1000)) + 1
- }
-
- Object.assign(form.value, {
- id: info.id,
- billNo: info.no ?? '',
- projectManagementPlanId: info.projectManagementPlanId ?? '',
- estimatedDays: Number(info.estimatedDays) || computeEstimatedDays(info.planStartTime, info.planEndTime) || 0,
- projectName: info.title ?? '',
- customerName: info.clientName ?? '',
- clientId: info.clientId ?? undefined,
- parentProjectName: info.projectManagementInfoParentName ?? '',
- setupDate: info.establishTime ?? '',
- projectSource: info.source ?? '',
- projectClassification: info.projectClassification ?? '',
- creatorName: info.managerName ?? '',
- billStatus: normalizeDictValue(info.status),
- projectStage: normalizeDictValue(info.stage ?? info.projectStage),
- planStartDate: info.planStartTime ?? '',
- planEndDate: info.planEndTime ?? '',
- projectAmount: info.orderAmount ?? 0,
- orderDate: info.orderDate ?? '',
- auditStatus: normalizeDictValue(info.reviewStatus),
- remark: info.remark ?? '',
- attachmentIds: Array.isArray(info.attachmentIds) ? info.attachmentIds : [],
- teamList: Array.isArray(info.teamList) ? info.teamList.map(t => ({
- memberId: normalizeId(t.userId),
- roleId: normalizeId(t.userRoleId),
- enterDate: t.joinTime,
- leaveDate: t.departTime,
- phone: t.contact,
- remark: t.remark
- })) : [],
- addressList: shippingAddress?.address
- ? [{
- receiver: shippingAddress.consignee,
- phone: shippingAddress.contract,
- address: shippingAddress.address
- }]
- : [],
- contactName: contractInfo.name ?? '',
- contactGender: contractInfo.sex === '鐢�' ? '1' : contractInfo.sex === '濂�' ? '2' : '',
- contactBirthday: contractInfo.birthday ?? '',
- contactDept: contractInfo.department ?? '',
- contactJob: contractInfo.job ?? '',
- contactMobile: contractInfo.phoneNumber ?? '',
- contactEmail: contractInfo.email ?? '',
- contactQq: contractInfo.qq ?? '',
- contactWechat: contractInfo.wx ?? '',
- contactWorkWechat: contractInfo.lineaFissa ?? '',
- contactAddress: contractInfo.origineEtnica ?? '',
- contactRemark: contractInfo.rappresentanteLegale ?? ''
- })
-
- fileList.value = Array.isArray(info.attachmentList)
- ? info.attachmentList.map(a => ({
- id: a.id ?? a.fileId,
- name: a.fileName ?? a.name,
- url: a.url ?? a.fileUrl ?? a.path
- }))
- : []
-
- const rawPhaseList =
- detail?.phaseList ||
- detail?.projectPhaseList ||
- detail?.projectStageList ||
- info?.phaseList ||
- info?.projectPhaseList ||
- []
- form.value.phaseList = Array.isArray(rawPhaseList)
- ? rawPhaseList.map(p => ({
- phaseName: p.phaseName ?? p.name ?? p.title ?? '',
- description: p.description ?? p.workContent ?? p.desc ?? '',
- ownerId: normalizeId(p.ownerId ?? p.leaderId ?? p.userId),
- planDays: Number(p.planDays ?? p.estimatedDuration ?? p.estimatedDays) || 0,
- planStartDate: p.planStartDate ?? p.planStartTime ?? p.startDate ?? '',
- planEndDate: p.planEndDate ?? p.planEndTime ?? p.endDate ?? '',
- progress: Number(p.progress ?? p.schedule) || 0,
- actualStartDate: p.actualStartDate ?? p.actualStartTime ?? '',
- actualEndDate: p.actualEndDate ?? p.actualEndTime ?? '',
- overdueDays: Number(p.overdueDays ?? p.overDays) || 0,
- completionRemark: p.completionRemark ?? p.remark ?? ''
- }))
- : []
-
- productData.value = detail?.salesLedgerProductList || detail?.productData || []
- } catch {}
- }
- if (form.value.teamList.length === 0 && !isView.value) addTeamRow()
- if (form.value.phaseList.length === 0 && !isView.value) addPhaseRow()
- dialogVisible.value = true
-}
-
-function downloadAttachment(att) {
- if (att) {
- try {
- proxy.$download.byUrl(att.url, att.originalFilename);
- return
- } catch (e) {}
- }
- ElMessage.warning('闄勪欢鏆傛棤涓嬭浇鍦板潃')
-}
-function closeDialog() {
- dialogVisible.value = false
-}
-
-async function submitForm() {
- if (isView.value) {
- closeDialog()
- return
- }
- await formRef.value?.validate?.()
- const info = {
- id: form.value.id ?? null,
- no: form.value.billNo,
- title: form.value.projectName,
- clientId: form.value.clientId ?? null,
- clientName: form.value.customerName,
- projectManagementInfoParentId: form.value.parentProjectId ?? null,
- projectManagementPlanId: form.value.projectManagementPlanId ?? null,
- establishTime: form.value.setupDate || todayStr(),
- source: form.value.projectSource,
- projectClassification: form.value.projectClassification,
- managerId: form.value.managerId ?? null,
- managerName: form.value.creatorName,
- salesmanId: form.value.salesmanId ?? null,
- salesmanName: form.value.salesmanName ?? '',
- planStartTime: form.value.planStartDate,
- planEndTime: form.value.planEndDate,
- actualStartTime: form.value.actualStartDate,
- actualEndTime: form.value.actualEndDate,
- status: form.value.billStatus === '' || form.value.billStatus === undefined || form.value.billStatus === null ? null : Number(form.value.billStatus),
- departmentId: form.value.departmentId ?? null,
- departmentName: form.value.departmentName ?? '',
- orderDate: form.value.orderDate,
- orderAmount: form.value.projectAmount,
- reviewStatus: form.value.auditStatus === '' || form.value.auditStatus === undefined || form.value.auditStatus === null ? null : Number(form.value.auditStatus),
- stage: form.value.projectStage === '' || form.value.projectStage === undefined || form.value.projectStage === null ? null : Number(form.value.projectStage),
- remark: form.value.remark,
- attachmentIds: (fileList.value || [])
- .map(f => (f?.id ?? f?.rawData?.id))
- .filter(v => v !== undefined && v !== null && v !== '')
- .map(String)
- }
-
- const payload = {
- info,
- shippingAddress: null,
- contractInfo: null,
- salesLedgerProductList: null
- }
-
- const req = operationType.value === 'edit' ? updateProject : addProject
- const res = await req(payload)
- if (res?.code === 200) {
- ElMessage.success('淇濆瓨鎴愬姛')
- closeDialog()
- emit('completed')
- return
- }
- ElMessage.error(res?.msg || '淇濆瓨澶辫触')
-}
-
defineExpose({ openDialog })
</script>
-<style scoped lang="scss">
-.section {
- border: 1px solid #ebeef5;
- border-radius: 8px;
- margin-bottom: 14px;
- background: #fff;
-}
-
-.section-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 12px 14px;
- cursor: pointer;
-}
-
-.section-title {
- display: flex;
- align-items: center;
- gap: 8px;
- font-weight: 600;
- color: #303133;
-}
-
-.section-bar {
- width: 3px;
- height: 14px;
- background: #002FA7;
- border-radius: 2px;
-}
-
-.section-actions {
- display: flex;
- align-items: center;
- gap: 10px;
-}
-
-.toggle-icon {
- color: #909399;
-}
-
-.section-body {
- padding: 0 14px 14px;
-}
-
-.dialog-footer {
- display: flex;
- justify-content: center;
- gap: 12px;
-}
-.attachment-upload{
-
-}
-</style>
+<style scoped>.tip{margin-bottom:18px}.module-card{padding:14px 14px 2px;margin-bottom:12px;border:1px solid #dcdfe6;border-radius:6px}.module-card__title,.module-actions{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.module-card__title{font-weight:600}.module-actions{color:#606266}.unit{margin-left:6px;color:#606266}.field-hint{width:100%;margin-top:4px;color:#909399;font-size:12px;line-height:18px}</style>
--
Gitblit v1.9.3