Merge pull request 'fix : 费用分摊同项目同人不能多次分摊判断' (#692) from dd into master

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/692
This commit is contained in:
2024-08-11 14:39:20 +00:00

View File

@@ -2,13 +2,13 @@
<div v-loading="loading">
<el-form :model="formData" ref="form" class="query-form" :rules="rules">
<el-row>
<el-col :span="12">
<el-col :span="6" style="padding-left: 0">
<el-form-item label="分摊名称" prop="shareName">
<el-input v-model="formData.shareName" placeholder="请输入分摊名称" clearable>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="6">
<el-form-item label="分摊月份" prop="apportionmentMonth">
<el-date-picker
v-model="formData.apportionmentMonth"
@@ -24,7 +24,7 @@
<el-table-column prop="projectId" label="项目名称" min-width="230">
<template #default="scope">
<el-form-item prop="time" :rules="scope.row.projectId?'1':rules.projectId">
<el-select v-model="scope.row.projectId" placeholder="请选择项目名称" clearable filterable remote>
<el-select v-model="scope.row.projectId" placeholder="请选择项目名称" clearable filterable>
<el-option
v-for="item in nameOptions"
:key="item.value"
@@ -98,18 +98,19 @@
</el-table-column>
<el-table-column prop="oper" label="操作" min-width="130">
<template #default="scope">
<el-button type="primary" @click="handleCopy(scope.row)" link style="font-size: 18px">复制</el-button>
<el-button type="primary" @click="handleDelete(scope.$index)" link style="font-size: 18px">删除</el-button>
<el-button type="primary" @click="handleCopy(scope.row)" link style="font-size: 16px">复制</el-button>
<el-button type="primary" @click="handleDelete(scope.$index)" link style="font-size: 16px">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
</el-form>
<user-picker :multiple="false" ref="userPicker" title="请选择研发人员" v-model:value="userList" @ok="selected"
<user-picker :multiple="false" ref="userPicker" title="请选择研发人员" v-model:value="userList"
@ok="selectedResearchPersonnel"
:setNullToSelectList="true" :isResearch="true"/>
<div style="width:100%;text-align: center;padding: 10px">
<el-button type="primary" @click="handleAdd" link style="font-size: 18px">添加一行</el-button>
<el-button type="primary" @click="handleAdd" link style="font-size: 16px">添加一行</el-button>
</div>
<div class="approval-record">
<div class="approval-title">
@@ -120,11 +121,12 @@
<div class="base-title">流程图</div>
<el-switch
v-model="changeDiagram"
style="--el-switch-on-color:#BEA266 ; --el-switch-off-color:#cecdcd"
style="--el-switch-on-color:#BEA266 ; --el-switch-off-color:#cecdcd;margin-top: 1px"
/>
</div>
</div>
<el-empty :image-size="100" description="暂无审批记录" v-if="processDiagramViewer&& !opentionData?.operationList&&!changeDiagram"/>
<el-empty :image-size="100" description="暂无审批记录"
v-if="processDiagramViewer&& !opentionData?.operationList&&!changeDiagram"/>
<div class="process">
<operation-render
v-if="processDiagramViewer&& opentionData?.operationList && opentionData?.operationList.length > 0&&!changeDiagram"
@@ -209,7 +211,8 @@ const researchOptions = ref([])
const showPersonnelPicker = (row, index) => {
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: '提示',