From 3e3d738362996a22f364551f9298732f9d8ec351 Mon Sep 17 00:00:00 2001
From: odjbin <1042039504@qq.com>
Date: Sun, 11 Aug 2024 22:38:15 +0800
Subject: [PATCH] =?UTF-8?q?fix=20:=20=E8=B4=B9=E7=94=A8=E5=88=86=E6=91=8A?=
=?UTF-8?q?=E5=90=8C=E9=A1=B9=E7=9B=AE=E5=90=8C=E4=BA=BA=E4=B8=8D=E8=83=BD?=
=?UTF-8?q?=E5=A4=9A=E6=AC=A1=E5=88=86=E6=91=8A=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/expense-management/share/add.vue | 87 +++++++++++++++++-----
1 file changed, 69 insertions(+), 18 deletions(-)
diff --git a/src/views/expense-management/share/add.vue b/src/views/expense-management/share/add.vue
index ea84d99..787ea38 100644
--- a/src/views/expense-management/share/add.vue
+++ b/src/views/expense-management/share/add.vue
@@ -2,13 +2,13 @@
-
+
-
+
-
+
- 复制
- 删除
+ 复制
+ 删除
-
- 添加一行
+ 添加一行
@@ -120,11 +121,12 @@
流程图
-
+
{
currentRow.value = row
currentIndex.value = index
- if (row.companyName) {
+ console.log('row',row)
+ if (row.companyName&&row.researchPersonnelId) {
let userObj = {
id: row.researchPersonnelId,
name: row.researchPersonnel,
@@ -224,7 +227,7 @@ const showPersonnelPicker = (row, index) => {
userPicker.value.showUserPicker()
})
}
-const selected = (select) => {
+const selectedResearchPersonnel = (select) => {
if (!select || select.length === 0) {
return
}
@@ -236,7 +239,54 @@ const selected = (select) => {
item.accountType = select[0].accountType
}
})
- userList.value = select
+ //以下是为" 同一项目下,同一人不能分摊多次 "
+ const projectIdArray = formData.value.tableData.map(item => item.projectId)
+ const researchPersonnelIdArray = formData.value.tableData.map(item => item.researchPersonnelId)
+ const projectNumObj = getSelectProjectAndResearchPersonnelNum(projectIdArray)
+ const researchPersonnelNumObj = getSelectProjectAndResearchPersonnelNum(researchPersonnelIdArray)
+ let repeatProjectName=''
+ for (let projectIdKey in projectNumObj) {
+ // console.log('projectNumObjKey', projectIdKey, projectNumObj[projectIdKey])
+ if(projectNumObj[projectIdKey]>1){
+ // console.log('getProjectName(projectIdKey)',getProjectName(projectIdKey))
+ repeatProjectName=getProjectName(projectIdKey)
+ }
+ }
+ for (let researchPersonnelIdKey in researchPersonnelNumObj) {
+ // console.log('researchPersonnelIdKey', researchPersonnelIdKey, researchPersonnelNumObj[researchPersonnelIdKey])
+ if(researchPersonnelNumObj[researchPersonnelIdKey]>1&&repeatProjectName){
+ ElNotification({
+ title: '警告',
+ message: `${repeatProjectName} 项目下,同一个研发人员不能分摊多次!`,
+ type: 'warning',
+ })
+ formData.value.tableData.forEach((item,index)=>{
+ if (index === currentIndex.value) {
+ item.researchPersonnelId = ''
+ item.researchPersonnel = ''
+ item.companyName = ''
+ item.accountType = ''
+ }
+ })
+ }else{
+
+ userList.value = select
+ }
+ }
+
+}
+/**
+ * 获取一个项目/研发人员的选择次数
+ * @param projectIdArray
+ * @returns {{}}
+ */
+const getSelectProjectAndResearchPersonnelNum = (projectIdArray) => {
+ const obj = {};
+ for (let i = 0, l = projectIdArray.length; i < l; i++) {
+ const item = projectIdArray[i];
+ obj[item] = (obj[item] + 1) || 1;
+ }
+ return obj;
}
const getResearchOptions = async () => {
const res = await getResearchUser()
@@ -249,7 +299,7 @@ const getProjectOptions = async () => {
const getProjectName = (id) => {
let label = ''
nameOptions.value.forEach(item => {
- if (item.value === id) {
+ if (item.value == id) {
label = item.label
}
})
@@ -276,10 +326,10 @@ const handleCopy = (row) => {
let copyObj = {
projectId: row.projectId,
projectName: '',
- accountType: row.accountType,
- companyName: row.companyName,
- researchPersonnelId: row.researchPersonnelId,
- researchPersonnel: row.researchPersonnel,
+ // accountType: row.accountType,
+ // companyName: row.companyName,
+ // researchPersonnelId: row.researchPersonnelId,
+ // researchPersonnel: row.researchPersonnel,
wagesPayable: row.wagesPayable,
performance: row.performance,
reserveFund: row.reserveFund,
@@ -294,6 +344,7 @@ const handleDelete = (index) => {
formData.value.tableData.splice(index, 1)
}
const handleSubmit = (instance) => {
+ console.log('tableData', formData.value.tableData)
if (!instance) return
instance.validate(async (valid) => {
if (!valid) {
@@ -326,7 +377,7 @@ const handleSubmit = (instance) => {
usrAllocations: formData.value.tableData,
deploymentId: processInstanceData.value.deploymentId,
}
- // console.log('params', params, formData.value.tableData)
+ console.log('params', params, formData.value.tableData)
const {code, msg} = await addAllocation(params)
ElNotification({
title: '提示',