Browse Source

当项目编码不为空时,需要到erf_exp_apply表查找项目编码=erf_exp_apply的project_no的数据;作为打样单号的下拉框,显示的是erf_exp_apply的apply_no(也就是说试验单其实就是Tracking的打样单);选择某一个打样单后回填打样单号和预计完成时间

master
han\hanst 4 weeks ago
parent
commit
ad375cff4f
  1. 229
      src/views/modules/sampleTracking/projectProofTracking.vue

229
src/views/modules/sampleTracking/projectProofTracking.vue

@ -297,7 +297,7 @@
</el-col>
<el-col :span="6" v-show="isOneKeyCreateFieldVisible('projectNo')">
<el-form-item label="项目编码">
<el-input v-model="oneKeyForm.projectNo" style="width: 100%"></el-input>
<el-input v-model="oneKeyForm.projectNo" style="width: 100%" @blur="handleOneKeyProjectNoBlur"></el-input>
</el-form-item>
</el-col>
<el-col :span="12" v-show="isOneKeyCreateFieldVisible('projectDesc')">
@ -513,7 +513,22 @@
<el-row :gutter="16">
<el-col :span="6" v-show="isOneKeyCreateFieldVisible('proofingNo')">
<el-form-item label="打样单号">
<el-input v-model="oneKeyForm.proofingNo" style="width: 100%"></el-input>
<el-select
v-model="oneKeyForm.proofingNo"
placeholder="请选择打样单号"
clearable
filterable
:loading="oneKeyProofingApplyLoading"
:disabled="isBlankValue(oneKeyForm.projectNo)"
style="width: 100%"
@change="handleOneKeyProofingNoChange">
<el-option
v-for="item in oneKeyProofingApplyOptions"
:key="item.applyNo"
:label="item.applyNo"
:value="item.applyNo"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6" v-show="isOneKeyCreateFieldVisible('proofingStatus')">
@ -642,7 +657,22 @@
<el-row :gutter="16">
<el-col :span="6">
<el-form-item label="打样单号" required>
<el-input v-model="proofDialogData.proofingNo" style="width: 100%" />
<el-select
v-model="proofDialogData.proofingNo"
placeholder="请选择试验单号"
clearable
filterable
:loading="proofDialogApplyLoading"
:disabled="isBlankValue(proofDialogData.projectNo)"
style="width: 100%"
@change="handleProofDialogProofingNoChange">
<el-option
v-for="item in proofDialogApplyOptions"
:key="item.applyNo"
:label="item.applyNo"
:value="item.applyNo"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
@ -842,6 +872,7 @@ import {
updateProofTrackingComments,
updateProofTrackingProcess
} from '@/api/sampleTracking/sampleTracking'
import { searchExpApplyList } from '@/api/erf/erf'
import { getCustomerNo, saveNewCustomer } from '@/api/eam/eamProject.js'
import { getSiteAndBuByUserName } from '@/api/eam/eam.js'
import {
@ -1071,10 +1102,16 @@ export default {
oneKeyDialogMode: 'create',
saveOneKeyLoading: false,
oneKeyForm: {},
oneKeyProofingApplyOptions: [],
oneKeyProofingApplyLoading: false,
oneKeyProofingApplyQueryToken: 0,
proofDialogVisible: false,
proofSaveLoading: false,
proofDialogData: this.getDefaultProofDialogData(),
proofDialogApplyOptions: [],
proofDialogApplyLoading: false,
proofDialogApplyQueryToken: 0,
processDialogVisible: false,
saveProcessLoading: false,
@ -2100,6 +2137,181 @@ export default {
isBlankValue (value) {
return value == null || String(value).trim() === ''
},
normalizeProjectNo (projectNo) {
if (this.isBlankValue(projectNo)) {
return ''
}
return String(projectNo).trim()
},
queryApplyOptionsByProjectNo (projectNo) {
const normalizedProjectNo = this.normalizeProjectNo(projectNo)
if (!normalizedProjectNo) {
return Promise.resolve([])
}
return searchExpApplyList({
projectNo: normalizedProjectNo,
page: 1,
limit: 500
}).then(({ data }) => {
if (!(data && data.code === 0)) {
throw new Error((data && data.msg) || '查询试验单失败')
}
const pageList = (data.page && data.page.list) || []
const matchedProjectNo = normalizedProjectNo.toUpperCase()
const optionMap = {}
const optionRows = []
pageList.forEach(item => {
if (!item || this.isBlankValue(item.applyNo)) {
return
}
const applyStatus = this.isBlankValue(item.status) ? '' : String(item.status).trim()
// tracking 使
if (applyStatus === '草稿' || applyStatus === '已完成') {
return
}
const rowProjectNo = this.normalizeProjectNo(item.projectNo).toUpperCase()
// searchExpApplyList project_no tracking
if (rowProjectNo !== matchedProjectNo) {
return
}
const applyNo = String(item.applyNo).trim()
if (optionMap[applyNo]) {
return
}
optionMap[applyNo] = true
optionRows.push({
applyNo: applyNo,
expectedFinishDate: this.formatDate(item.expectedFinishDate)
})
})
return optionRows
})
},
handleOneKeyProjectNoBlur () {
const projectNo = this.normalizeProjectNo(this.oneKeyForm.projectNo)
if (!projectNo) {
this.oneKeyProofingApplyQueryToken += 1
this.oneKeyProofingApplyLoading = false
this.oneKeyProofingApplyOptions = []
this.oneKeyForm.proofingNo = ''
this.oneKeyForm.requiredDeliveryDate = ''
return
}
this.loadOneKeyProofingApplyOptions(projectNo, { keepCurrentIfMissing: false })
},
handleOneKeyProofingNoChange (proofingNo) {
const selectedNo = this.isBlankValue(proofingNo) ? '' : String(proofingNo).trim()
if (!selectedNo) {
this.oneKeyForm.requiredDeliveryDate = ''
return
}
const matched = this.oneKeyProofingApplyOptions.find(item => item && item.applyNo === selectedNo)
if (!matched) {
return
}
this.oneKeyForm.proofingNo = matched.applyNo
this.oneKeyForm.requiredDeliveryDate = matched.expectedFinishDate || ''
},
loadOneKeyProofingApplyOptions (projectNo, options) {
const queryOptions = options || {}
const normalizedProjectNo = this.normalizeProjectNo(projectNo)
const currentProofingNo = this.isBlankValue(this.oneKeyForm.proofingNo)
? ''
: String(this.oneKeyForm.proofingNo).trim()
const queryToken = this.oneKeyProofingApplyQueryToken + 1
this.oneKeyProofingApplyQueryToken = queryToken
if (!normalizedProjectNo) {
this.oneKeyProofingApplyLoading = false
this.oneKeyProofingApplyOptions = []
return Promise.resolve([])
}
this.oneKeyProofingApplyLoading = true
return this.queryApplyOptionsByProjectNo(normalizedProjectNo).then(optionRows => {
if (queryToken !== this.oneKeyProofingApplyQueryToken) {
return optionRows
}
const nextOptions = optionRows.slice()
const keepCurrentIfMissing = !!queryOptions.keepCurrentIfMissing
if (currentProofingNo) {
const hasCurrent = nextOptions.some(item => item && item.applyNo === currentProofingNo)
if (!hasCurrent && keepCurrentIfMissing) {
// ERF
nextOptions.unshift({
applyNo: currentProofingNo,
expectedFinishDate: this.formatDate(this.oneKeyForm.requiredDeliveryDate)
})
}
if (!hasCurrent && !keepCurrentIfMissing) {
this.oneKeyForm.proofingNo = ''
this.oneKeyForm.requiredDeliveryDate = ''
}
}
this.oneKeyProofingApplyOptions = nextOptions
if (currentProofingNo) {
this.handleOneKeyProofingNoChange(currentProofingNo)
}
return nextOptions
}).catch((e) => {
if (queryToken === this.oneKeyProofingApplyQueryToken) {
this.oneKeyProofingApplyOptions = []
this.$message.error((e && e.message) || '查询试验单异常')
}
return []
}).finally(() => {
if (queryToken === this.oneKeyProofingApplyQueryToken) {
this.oneKeyProofingApplyLoading = false
}
})
},
handleProofDialogProofingNoChange (proofingNo) {
const selectedNo = this.isBlankValue(proofingNo) ? '' : String(proofingNo).trim()
if (!selectedNo) {
this.proofDialogData.requiredDeliveryDate = ''
return
}
const matched = this.proofDialogApplyOptions.find(item => item && item.applyNo === selectedNo)
if (!matched) {
return
}
this.proofDialogData.proofingNo = matched.applyNo
this.proofDialogData.requiredDeliveryDate = matched.expectedFinishDate || ''
},
loadProofDialogApplyOptions (projectNo) {
const normalizedProjectNo = this.normalizeProjectNo(projectNo)
const queryToken = this.proofDialogApplyQueryToken + 1
this.proofDialogApplyQueryToken = queryToken
if (!normalizedProjectNo) {
this.proofDialogApplyLoading = false
this.proofDialogApplyOptions = []
this.proofDialogData.proofingNo = ''
this.proofDialogData.requiredDeliveryDate = ''
return Promise.resolve([])
}
this.proofDialogApplyLoading = true
return this.queryApplyOptionsByProjectNo(normalizedProjectNo).then(optionRows => {
if (queryToken !== this.proofDialogApplyQueryToken) {
return optionRows
}
this.proofDialogApplyOptions = optionRows
const currentProofingNo = this.isBlankValue(this.proofDialogData.proofingNo)
? ''
: String(this.proofDialogData.proofingNo).trim()
if (currentProofingNo) {
this.handleProofDialogProofingNoChange(currentProofingNo)
}
return optionRows
}).catch((e) => {
if (queryToken === this.proofDialogApplyQueryToken) {
this.proofDialogApplyOptions = []
this.$message.error((e && e.message) || '查询试验单异常')
}
return []
}).finally(() => {
if (queryToken === this.proofDialogApplyQueryToken) {
this.proofDialogApplyLoading = false
}
})
},
getBuOptionValue (site, buNo) {
const rawBuNo = buNo == null ? '' : String(buNo).trim()
if (!rawBuNo) {
@ -2276,6 +2488,9 @@ export default {
const dialogMode = mode === 'edit' ? 'edit' : 'create'
this.oneKeyDialogMode = dialogMode
if (dialogMode !== 'edit') {
this.oneKeyProofingApplyQueryToken += 1
this.oneKeyProofingApplyLoading = false
this.oneKeyProofingApplyOptions = []
this.oneKeyForm = this.getEmptyOneKeyForm()
if (this.userBuList.length > 0) {
this.oneKeyForm.buNo = this.userBuList[0].buNo || ''
@ -2331,7 +2546,11 @@ export default {
throw new Error('未找到对应的项目物料信息,无法修改')
}
this.oneKeyForm = this.buildOneKeyEditForm(current, projectRows[0], partRows[0])
this.oneKeyProofingApplyQueryToken += 1
this.oneKeyProofingApplyLoading = false
this.oneKeyProofingApplyOptions = []
this.oneKeyDialogVisible = true
this.loadOneKeyProofingApplyOptions(this.oneKeyForm.projectNo, { keepCurrentIfMissing: true })
}).catch((e) => {
this.$message.error((e && e.message) || '加载项目/物料/打样信息异常')
this.oneKeyDialogMode = 'create'
@ -2392,6 +2611,9 @@ export default {
this.currentRow = current
const projectPartId = this.getTrackingProjectPartId(current) || current.id
const projectCategory = this.getProjectCategoryValue(current)
this.proofDialogApplyQueryToken += 1
this.proofDialogApplyLoading = false
this.proofDialogApplyOptions = []
this.proofDialogData = Object.assign(this.getDefaultProofDialogData(), {
trackingId: null,
site: current.site || this.$store.state.user.site,
@ -2424,6 +2646,7 @@ export default {
this.$message.warning('未获取到项目分类,请手动选择')
}
this.proofDialogVisible = true
this.loadProofDialogApplyOptions(this.proofDialogData.projectNo)
},
validateSyncToNpiRow (row) {
const projectPartId = this.getTrackingProjectPartId(row)

Loading…
Cancel
Save