From b60dd22d48d089bf8d712617fb6105296bd01301 Mon Sep 17 00:00:00 2001 From: yuejiayang <146344614+YangLei105@users.noreply.github.com> Date: Mon, 12 Aug 2024 20:31:45 +0800 Subject: [PATCH] =?UTF-8?q?2024.8.12=20=E2=91=A0=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=94=B6=E9=9B=86-=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AE=A2=E6=88=B7=E9=80=89=E6=8B=A9=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/eam/eamProject.js | 3 +- src/views/modules/eam/eamProjectInfo.vue | 96 +++++++++++++++++++- src/views/modules/eam/eamProjectPartInfo.vue | 1 - 3 files changed, 96 insertions(+), 4 deletions(-) diff --git a/src/api/eam/eamProject.js b/src/api/eam/eamProject.js index 84f6159..f5ba4de 100644 --- a/src/api/eam/eamProject.js +++ b/src/api/eam/eamProject.js @@ -6,7 +6,8 @@ export const eamProjectInfoEdit= data => createAPI(`/pms/eamProject/eamProjectIn export const eamProjectInfoDelete= data => createAPI(`/pms/eamProject/eamProjectInfoDelete`,'post',data) export const saveFormalPartNo= data => createAPI(`/pms/eamProject/saveFormalPartNo`,'post',data) export const getFinalPartDesc= data => createAPI(`/pms/eamProject/getFinalPartDesc`,'post',data) -export const getTestPartNo= data => createAPI(`/pms/eamProject/getTestPartNo`,'post',data) +export const getCustomerNo= data => createAPI(`/pms/eamProject/getCustomerNo`,'post',data) +export const saveNewCustomer= data => createAPI(`/pms/eamProject/saveNewCustomer`,'post',data) export const eamProjectPartSearch= data => createAPI(`/pms/eamProject/eamProjectPartSearch`,'post',data) export const eamProjectPartInfoSave= data => createAPI(`/pms/eamProject/eamProjectPartInfoSave`,'post',data) export const eamProjectPartInfoEdit= data => createAPI(`/pms/eamProject/eamProjectPartInfoEdit`,'post',data) diff --git a/src/views/modules/eam/eamProjectInfo.vue b/src/views/modules/eam/eamProjectInfo.vue index afbd50a..3185b02 100644 --- a/src/views/modules/eam/eamProjectInfo.vue +++ b/src/views/modules/eam/eamProjectInfo.vue @@ -172,7 +172,10 @@ - 客户编码 + + 客户编码 + (新客户) + @@ -276,6 +279,19 @@ + + + + + + + + + 保存 + 关闭 + + + @@ -711,7 +727,7 @@ import { eamProjectPartInfoDelete, eamProjectPartInfoEdit, eamProjectPartInfoSave, - eamProjectPartSearch + eamProjectPartSearch, getCustomerNo, saveNewCustomer } from "../../../api/eam/eamProject"; import row from "element-ui/packages/row"; import 'moment/locale/zh-cn'; @@ -797,6 +813,7 @@ import {EventBus} from "../../../main"; IPQCFlag:false, FQCFlag:false, MFGlag:false, + newCustomerFlag:false, modalData:{ flag:'', bu: '', @@ -2075,6 +2092,81 @@ import {EventBus} from "../../../main"; } }, + newCustomer () { + this.modalData.customerNo = '' + this.modalData.customerDesc = '' + this.newCustomerFlag = true + }, + + saveNewCustomer () { + this.generateNextCustomerNo().then((customerNo) => { + if (customerNo !== false) { + this.modalData.customerNo = customerNo + let tempData = { + site: this.$store.state.user.site, + customerNo: customerNo, + customerDesc: this.modalData.customerDesc, + createBy: this.$store.state.user.name, + } + saveNewCustomer(tempData).then(({data}) => { + if (data.code === 0) { + this.modalData.customerNo = '' + this.modalData.customerDesc = '' + this.$message.success(data.msg) + this.newCustomerFlag = false + } + }) + } + else { + this.$alert('该客户已存在,请重新输入客户名称!', '提示', { + confirmButtonText: '确定', + type: 'warning' + }) + } + }) + + }, + + generateNextCustomerNo() { + return new Promise((resolve, reject) => { + + getCustomerNo(this.modalData).then(({ data }) => { + if (data.code === 0){ + if (data.data === null || data.data === undefined || data.data === '' || data.data === '0') { + resolve('C0001'); + } else { + const stringData = String(data.data.customerNo); // 显式转换为字符串 + const lastCustomerNo = parseInt(stringData.substring(1)); + const nextCustomerNo = lastCustomerNo + 1; + let customerNo; + + if (nextCustomerNo < 10) { + customerNo = 'C000' + nextCustomerNo; + } else if (nextCustomerNo < 100) { + customerNo = 'C00' + nextCustomerNo; + } else if (nextCustomerNo < 1000) { + customerNo = 'C0' + nextCustomerNo; + } else { + customerNo = 'C' + nextCustomerNo; + } + resolve(customerNo); + } + } + else { + resolve(false); + } + }).catch(error => { + reject('Failed to fetch customerNo: ' + error); + }); + }); + }, + + closeNewCustomer () { + this.modalData.customerNo = '' + this.modalData.customerDesc = '' + this.newCustomerFlag = false + }, + // 校验用户是否收藏 favoriteIsOk () { let userFavorite = { diff --git a/src/views/modules/eam/eamProjectPartInfo.vue b/src/views/modules/eam/eamProjectPartInfo.vue index 733c9de..34308b8 100644 --- a/src/views/modules/eam/eamProjectPartInfo.vue +++ b/src/views/modules/eam/eamProjectPartInfo.vue @@ -695,7 +695,6 @@ import { eamProjectInfoEdit, eamProjectInfoSave, eamProjectInfoSearch, - getTestPartNo, saveFormalPartNo } from "@/api/eam/eamProject.js"; import {getProjectOtherDocument} from "@/api/eam/eamProofing.js";