Browse Source

fix:[模板管理]去重

lkf
15881625488@163.com 2 months ago
parent
commit
a00ad0bb30
3 changed files with 21 additions and 2 deletions
  1. +17
    -0
      src/utils/calUnitTools.js
  2. +2
    -1
      src/utils/index.js
  3. +2
    -1
      src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue

+ 17
- 0
src/utils/calUnitTools.js View File

@ -80,3 +80,20 @@ export function multiplyDecimals(a, b) {
result = result.replace(/\.?0+$/, '') || '0' result = result.replace(/\.?0+$/, '') || '0'
return (isNegative ? '-' : '') + result return (isNegative ? '-' : '') + result
} }
//模板物资去重
export function uniqeResource(oldList,newList) {
for(var i=0;i<newList.length;i++){
let _index= _.findIndex(oldList,function(item){
return item.bh==newList[i].bh&&(item.type==newList[i].type||item.elnType==newList[i].type)
})
if(_index>-1){
const { total, unit }=addTj([oldList[_index].syl,newList[i].syl],[oldList[_index].syldw,newList[i].syldw])
oldList[_index].syl=total
oldList[_index].syldw=unit
}else{
oldList.push(newList[i])
}
}
return oldList;
}

+ 2
- 1
src/utils/index.js View File

@ -422,4 +422,5 @@ export const getExpireDate = (startDate, effectivePeriod, effectivePeriodUnit) =
export function getuuid() { export function getuuid() {
return Math.random().toString(36).substring(2) + return Math.random().toString(36).substring(2) +
Date.now().toString(36); Date.now().toString(36);
}
}

+ 2
- 1
src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue View File

@ -39,6 +39,7 @@ import templateMixin from "../../mixins/templateMixin";
import CustomTable from '@/components/Template/CustomTable.vue'; import CustomTable from '@/components/Template/CustomTable.vue';
import { getLatestSn } from '@/api/template'; import { getLatestSn } from '@/api/template';
import { EventBus } from "@/utils/eventBus"; import { EventBus } from "@/utils/eventBus";
import { uniqeResource } from "@/utils/calUnitTools";
export default { export default {
name: "Sp001", name: "Sp001",
@ -309,7 +310,7 @@ export default {
} }
//使 //使
const stepResource = this.$refs.stepRef.getStepResource() const stepResource = this.$refs.stepRef.getStepResource()
this.resourceTmp = tmpResource.concat(stepResource.sjResource||[])
this.resourceTmp =uniqeResource(tmpResource,stepResource.sjResource||[])
this.yqResourceTmp = stepResource.yqResource||[] this.yqResourceTmp = stepResource.yqResource||[]
return content; return content;
} }

Loading…
Cancel
Save