From 5df6d6cd93ed5655065652a008189d1630fbfeab Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 29 十月 2026 16:34:34 +0800
Subject: [PATCH] change
---
src/views/projectManagement/Management/components/formDia.vue | 342 +++++++++++++++++++-------------------------------------
1 files changed, 116 insertions(+), 226 deletions(-)
diff --git a/src/views/projectManagement/Management/components/formDia.vue b/src/views/projectManagement/Management/components/formDia.vue
index 0db3efe..98722a5 100644
--- a/src/views/projectManagement/Management/components/formDia.vue
+++ b/src/views/projectManagement/Management/components/formDia.vue
@@ -40,123 +40,90 @@
</el-col>
<el-col :span="6">
<el-form-item label="瀹㈡埛鍚嶇О" prop="customerName">
- <el-input v-model="form.customerName" placeholder="璇疯緭鍏�" clearable />
+ <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-row>
<el-row :gutter="20">
<el-col :span="6">
- <el-form-item label="绔嬮」鏃ユ湡" prop="setupDate">
- <el-date-picker
- v-model="form.setupDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
+ <el-form-item label="椤圭洰鍒嗙被" prop="projectClassification">
+ <el-select
+ v-model="form.projectClassification"
placeholder="璇烽�夋嫨"
- style="width: 100%"
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-input v-model="form.projectSource" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="绔嬮」浜�" prop="creatorName">
- <el-input v-model="form.creatorName" placeholder="璇疯緭鍏�" clearable />
+ <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 :gutter="20">
- <el-col :span="6">
- <el-form-item label="棰勮宸ユ湡(澶�)" prop="estimatedDays">
- <el-input-number v-model="form.estimatedDays" :min="0" controls-position="right" style="width: 100%" />
+ <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="6">
- <el-form-item label="璁″垝寮�濮嬫棩鏈�" prop="planStartDate">
- <el-date-picker
- v-model="form.planStartDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- />
+ <el-col :span="8">
+ <el-form-item label="鍚堝悓鏃ユ湡">
+ <el-input :model-value="form.orderDate" disabled />
</el-form-item>
</el-col>
- <el-col :span="6">
- <el-form-item label="璁″垝瀹屾垚鏃ユ湡" prop="planEndDate">
- <el-date-picker
- v-model="form.planEndDate"
- type="date"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- placeholder="璇烽�夋嫨"
- style="width: 100%"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
-
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="椤圭洰绫诲瀷" prop="projectManagementPlanId">
- <el-select v-model="form.projectManagementPlanId" placeholder="璇烽�夋嫨" clearable style="width: 100%">
- <el-option v-for="opt in projectTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="椤圭洰閲戦" prop="projectAmount">
- <el-input-number v-model="form.projectAmount" :min="0" controls-position="right" style="width: 100%" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="瀹℃牳鐘舵��" prop="auditStatus">
- <el-select v-model="form.auditStatus" placeholder="璇烽�夋嫨" clearable style="width: 100%">
- <el-option v-for="d in project_management" :key="d.value" :label="d.label" :value="d.value" />
- </el-select>
- </el-form-item>
- </el-col>
-
</el-row>
<el-row :gutter="10" >
<el-col :span="24">
- <el-upload
- v-model:file-list="fileList"
- :action="upload.url"
- :headers="upload.headers"
- multiple
- :disabled="isView"
- :before-upload="beforeUpload"
- :on-success="handleUploadSuccess"
- :on-error="handleUploadError"
- name="files"
- :on-remove="handleRemove"
- >
- <el-button type="primary" :disabled="isView">涓婁紶鏂囦欢</el-button>
- </el-upload>
- <div v-if="existingAttachments.length > 0" class="attachment-list">
- <div
- v-for="(att, idx) in existingAttachments"
- :key="att.id || att.url || idx"
- class="attachment-item"
- >
- <el-icon><Document /></el-icon>
- <span class="attachment-name">{{ att.name || att.fileName || att.url || '闄勪欢' }}</span>
- <el-button link type="primary" size="small" @click="downloadAttachment(att)">涓嬭浇</el-button>
- </div>
- </div>
+ <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 :gutter="20">
+ <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 />
@@ -166,49 +133,7 @@
</div>
</div>
- <div class="section">
- <div class="section-header" @click="toggleSection('product')">
- <div class="section-title">
- <span class="section-bar" />
- <span>浜у搧淇℃伅</span>
- </div>
- <div class="section-actions" @click.stop>
- <el-button v-if="!isView" type="primary" @click="openProductForm('add')">娣诲姞</el-button>
- <el-button v-if="!isView" plain type="danger" @click="deleteProduct">鍒犻櫎</el-button>
- <el-icon class="toggle-icon" @click="toggleSection('product')">
- <ArrowDown v-if="sectionCollapsed.product" />
- <ArrowUp v-else />
- </el-icon>
- </div>
- </div>
- <div v-show="!sectionCollapsed.product" class="section-body">
- <el-table
- :data="productData"
- border
- show-summary
- :summary-method="summarizeProductTable"
- @selection-change="productSelected"
- >
- <el-table-column v-if="!isView" align="center" type="selection" width="55" />
- <el-table-column align="center" label="搴忓彿" type="index" width="60" />
- <el-table-column label="浜у搧澶х被" prop="productCategory" />
- <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
- <el-table-column label="鍗曚綅" prop="unit" />
- <el-table-column label="鏁伴噺" prop="quantity" />
- <el-table-column label="绋庣巼(%)" prop="taxRate" />
- <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" />
- <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
- <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
- <el-table-column v-if="!isView" fixed="right" label="鎿嶄綔" min-width="60" align="center">
- <template #default="scope">
- <el-button link type="primary" size="small" @click="openProductForm('edit', scope.row, scope.$index)">缂栬緫</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
-
- <div class="section">
+ <div v-if="false" class="section">
<div class="section-header" @click="toggleSection('team')">
<div class="section-title">
<span class="section-bar" />
@@ -381,7 +306,7 @@
</div>
</div> -->
- <div class="section">
+ <div v-if="false" class="section">
<div class="section-header" @click="toggleSection('address')">
<div class="section-title">
<span class="section-bar" />
@@ -421,7 +346,7 @@
</div>
</div>
- <div class="section">
+ <div v-if="false" class="section">
<div class="section-header" @click="toggleSection('contact')">
<div class="section-title">
<span class="section-bar" />
@@ -639,9 +564,10 @@
<script setup name="ProjectManagementFormDia">
import { computed, getCurrentInstance, reactive, ref, toRefs } from 'vue'
-import { ArrowDown, ArrowUp, Delete, Plus, Document } from '@element-plus/icons-vue'
+import { ArrowDown, ArrowUp, Delete, Plus } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
-import { getToken } from '@/utils/auth'
+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'
@@ -659,13 +585,11 @@
const operationType = ref('add')
const formRef = ref()
const fileList = ref([])
-const existingAttachments = ref([])
-const upload = reactive({
- url: import.meta.env.VITE_APP_BASE_API + '/basic/customer-follow/upload',
- headers: { Authorization: 'Bearer ' + getToken() }
-})
+const customerOptions = ref([])
const projectTypeOptions = ref([])
+// 椤圭洰鍒嗙被锛氬厛鍐欐鍑犱釜锛屽悗缁彲鍒囨崲涓哄瓧鍏�
+const projectClassificationOptions = ['鏁板瓧鍖栬浆鍨�', '鏅鸿兘鍒堕��', '绯荤粺闆嗘垚', '鍏朵粬']
const roleOptions = ref([])
const userOptions = ref([])
const productData = ref([])
@@ -725,8 +649,9 @@
projectName: '',
customerName: '',
parentProjectName: '',
- setupDate: '',
- projectSource: '',
+ setupDate: todayStr(),
+ projectSource: '鎵嬪姩娣诲姞',
+ projectClassification: '',
creatorName: '',
billStatus: '',
projectStage: '',
@@ -771,6 +696,8 @@
})
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 '缂栬緫椤圭洰'
@@ -813,6 +740,12 @@
sectionCollapsed[key] = !sectionCollapsed[key]
}
+function todayStr() {
+ const d = new Date()
+ const pad = n => String(n).padStart(2, '0')
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
+}
+
function resetFormData() {
Object.assign(form.value, {
id: undefined,
@@ -831,8 +764,9 @@
projectName: '',
customerName: '',
parentProjectName: '',
- setupDate: '',
- projectSource: '',
+ setupDate: todayStr(),
+ projectSource: '鎵嬪姩娣诲姞',
+ projectClassification: '',
creatorName: '',
billStatus: '',
projectStage: '',
@@ -1116,6 +1050,11 @@
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
+ }
} catch {
projectTypeOptions.value = []
}
@@ -1142,6 +1081,21 @@
} 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() {
@@ -1191,41 +1145,10 @@
if (index > -1) form.value.addressList.splice(index, 1)
}
-function beforeUpload() {
- if (isView.value) return false
- proxy.$modal?.loading?.('姝e湪涓婁紶鏂囦欢锛岃绋嶅��...')
- return true
-}
-
-function handleUploadError() {
- proxy.$modal?.closeLoading?.()
- ElMessage.error('涓婁紶鏂囦欢澶辫触')
-}
-
-function handleUploadSuccess(res, file) {
- console.log(res, file)
- proxy.$modal?.closeLoading?.()
- if (res?.code !== 200) {
- ElMessage.error(res?.msg || '涓婁紶澶辫触')
- return
- }
- const attachmentId = res?.data?.[0]?.id ?? ""
- if (!attachmentId) return
- form.value.attachmentIds.push(attachmentId)
- console.log(form.value.attachmentIds)
- ElMessage.success('涓婁紶鎴愬姛')
-}
-
-function handleRemove(file) {
- const attachmentId = file?.attachmentId
- if (!attachmentId) return
- form.value.attachmentIds = (form.value.attachmentIds || []).filter(id => id !== attachmentId)
-}
-
async function openDialog(payload = {}) {
operationType.value = payload.operationType || 'add'
resetFormData()
- await Promise.all([loadProjectTypeOptions(), loadRoleOptions(), loadUserOptions(), getProductOptions()])
+ await Promise.all([loadProjectTypeOptions(), loadRoleOptions(), loadUserOptions(), loadCustomerOptions(), getProductOptions()])
if (payload.row?.id) {
try {
const res = await getProject(payload.row.id)
@@ -1261,15 +1184,18 @@
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 : [],
@@ -1302,7 +1228,7 @@
contactRemark: contractInfo.rappresentanteLegale ?? ''
})
- existingAttachments.value = Array.isArray(info.attachmentList)
+ fileList.value = Array.isArray(info.attachmentList)
? info.attachmentList.map(a => ({
id: a.id ?? a.fileId,
name: a.fileName ?? a.name,
@@ -1360,45 +1286,6 @@
return
}
await formRef.value?.validate?.()
- if (!productData.value || productData.value.length === 0) {
- proxy.$modal?.msgWarning?.('璇锋坊鍔犱骇鍝佷俊鎭�')
- return
- }
- const findLabel = (list, value) => (list || []).find(i => String(i.value) === String(value))?.label
- const teamList = (form.value.teamList || []).map(t => ({
- userId: t.memberId,
- userName: findLabel(userOptions.value, t.memberId),
- userRoleId: t.roleId,
- userRoleName: findLabel(roleOptions.value, t.roleId),
- joinTime: t.enterDate,
- departTime: t.leaveDate,
- contact: t.phone,
- remark: t.remark
- }))
-
- const shippingRow = (form.value.addressList || [])[0] || {}
- const shippingAddress = {
- id: undefined,
- consignee: shippingRow.receiver,
- contract: shippingRow.phone,
- address: shippingRow.address
- }
-
- const contractInfo = {
- id: undefined,
- name: form.value.contactName,
- sex: form.value.contactGender === '1' ? '鐢�' : form.value.contactGender === '2' ? '濂�' : '',
- birthday: form.value.contactBirthday,
- department: form.value.contactDept,
- job: form.value.contactJob,
- phoneNumber: form.value.contactMobile,
- email: form.value.contactEmail,
- qq: form.value.contactQq,
- lineaFissa: form.value.contactWorkWechat,
- wx: form.value.contactWechat,
- origineEtnica: form.value.contactAddress,
- rappresentanteLegale: form.value.contactRemark
- }
const info = {
id: form.value.id ?? null,
no: form.value.billNo,
@@ -1407,8 +1294,9 @@
clientName: form.value.customerName,
projectManagementInfoParentId: form.value.parentProjectId ?? null,
projectManagementPlanId: form.value.projectManagementPlanId ?? null,
- establishTime: form.value.setupDate,
+ 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,
@@ -1425,15 +1313,17 @@
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: Array.isArray(form.value.attachmentIds) ? form.value.attachmentIds : [],
- teamList
+ attachmentIds: (fileList.value || [])
+ .map(f => (f?.id ?? f?.rawData?.id))
+ .filter(v => v !== undefined && v !== null && v !== '')
+ .map(String)
}
const payload = {
info,
- shippingAddress,
- contractInfo,
- salesLedgerProductList: productData.value
+ shippingAddress: null,
+ contractInfo: null,
+ salesLedgerProductList: null
}
const req = operationType.value === 'edit' ? updateProject : addProject
--
Gitblit v1.9.3