Browse Source

描述模糊搜索

ecss-tx
han\hanst 2 weeks ago
parent
commit
eafd0f9e89
  1. 77
      src/views/modules/sampleTracking/projectProofTracking.vue

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

@ -500,15 +500,15 @@
v-model.trim="oneKeyForm.projectNo" v-model.trim="oneKeyForm.projectNo"
:fetch-suggestions="queryOneKeyProjectSuggestions" :fetch-suggestions="queryOneKeyProjectSuggestions"
:trigger-on-focus="true" :trigger-on-focus="true"
placeholder="手工输入或按BU选择NPI项目"
placeholder="输入项目描述模糊搜索"
style="width: 100%" style="width: 100%"
@select="handleOneKeyProjectSelect" @select="handleOneKeyProjectSelect"
@blur="handleOneKeyProjectNoBlur"> @blur="handleOneKeyProjectNoBlur">
<template slot-scope="{ item }"> <template slot-scope="{ item }">
<div class="one-key-suggest-main">{{ item.value }}</div>
<div class="one-key-suggest-sub"> <div class="one-key-suggest-sub">
{{ item.projectDesc || '-' }} | {{ item.customerDesc || '-' }}
{{ item.value }} | {{ item.customerDesc || '-' }}
</div> </div>
<div class="one-key-suggest-main">{{ item.projectDesc || item.value }}</div>
</template> </template>
</el-autocomplete> </el-autocomplete>
</el-form-item> </el-form-item>
@ -595,13 +595,13 @@
v-model.trim="oneKeyForm.testPartNo" v-model.trim="oneKeyForm.testPartNo"
:fetch-suggestions="queryOneKeyPartSuggestions" :fetch-suggestions="queryOneKeyPartSuggestions"
:trigger-on-focus="true" :trigger-on-focus="true"
placeholder="手工输入或按项目编码选择料号"
placeholder="输入物料描述模糊搜索"
style="width: 100%" style="width: 100%"
@select="handleOneKeyPartSelect" @select="handleOneKeyPartSelect"
@blur="handleOneKeyPartNoBlur"> @blur="handleOneKeyPartNoBlur">
<template slot-scope="{ item }"> <template slot-scope="{ item }">
<div class="one-key-suggest-main">{{ item.value }}</div>
<div class="one-key-suggest-sub">{{ item.partDesc || '-' }}</div>
<div class="one-key-suggest-sub">{{ item.value }}</div>
<div class="one-key-suggest-main">{{ item.partDesc || item.value }}</div>
</template> </template>
</el-autocomplete> </el-autocomplete>
</el-form-item> </el-form-item>
@ -1598,6 +1598,7 @@ export default {
oneKeyProjectQueryToken: 0, oneKeyProjectQueryToken: 0,
oneKeyPartQueryToken: 0, oneKeyPartQueryToken: 0,
oneKeyProjectNoSnapshot: '', oneKeyProjectNoSnapshot: '',
oneKeyPartNoSnapshot: '',
oneKeyProjectRoleBaseline: {}, oneKeyProjectRoleBaseline: {},
proofDialogVisible: false, proofDialogVisible: false,
@ -4279,6 +4280,7 @@ export default {
this.oneKeyForm.partDesc = '' this.oneKeyForm.partDesc = ''
this.oneKeyForm.partType = '' this.oneKeyForm.partType = ''
this.oneKeyForm.dry_wet_type = '' this.oneKeyForm.dry_wet_type = ''
this.oneKeyPartNoSnapshot = ''
return return
} }
if (previousProjectNo.toUpperCase() !== projectNo.toUpperCase()) { if (previousProjectNo.toUpperCase() !== projectNo.toUpperCase()) {
@ -4287,6 +4289,7 @@ export default {
this.oneKeyForm.partDesc = '' this.oneKeyForm.partDesc = ''
this.oneKeyForm.partType = '' this.oneKeyForm.partType = ''
this.oneKeyForm.dry_wet_type = '' this.oneKeyForm.dry_wet_type = ''
this.oneKeyPartNoSnapshot = ''
} }
this.oneKeyProjectNoSnapshot = projectNo this.oneKeyProjectNoSnapshot = projectNo
this.loadOneKeyProofingApplyOptions(projectNo, { keepCurrentIfMissing: false }) this.loadOneKeyProofingApplyOptions(projectNo, { keepCurrentIfMissing: false })
@ -4533,18 +4536,39 @@ export default {
return leftKey.localeCompare(rightKey) return leftKey.localeCompare(rightKey)
}) })
}, },
queryOneKeyProjectOptions (projectNoKeyword) {
getOneKeyDescSearchKeyword (queryString, selectedSnapshotCode) {
const keyword = this.isBlankValue(queryString) ? '' : String(queryString).trim()
if (!keyword) {
return ''
}
const snapshotCode = this.isBlankValue(selectedSnapshotCode) ? '' : String(selectedSnapshotCode).trim()
// v-model
if (snapshotCode && keyword.toUpperCase() === snapshotCode.toUpperCase()) {
return ''
}
return keyword
},
matchOneKeyDescKeyword (sourceText, keyword) {
if (this.isBlankValue(keyword)) {
return true
}
if (this.isBlankValue(sourceText)) {
return false
}
return String(sourceText).toUpperCase().indexOf(String(keyword).trim().toUpperCase()) > -1
},
queryOneKeyProjectOptions (projectDescKeyword) {
const buContext = this.getOneKeyBuQueryContext() const buContext = this.getOneKeyBuQueryContext()
if (!buContext) { if (!buContext) {
return Promise.resolve([]) return Promise.resolve([])
} }
const queryKeyword = this.isBlankValue(projectNoKeyword) ? '' : String(projectNoKeyword).trim()
const queryKeyword = this.isBlankValue(projectDescKeyword) ? '' : String(projectDescKeyword).trim()
const inData = { const inData = {
site: buContext.site, site: buContext.site,
userName: this.$store.state.user.name, userName: this.$store.state.user.name,
buDesc: buContext.buDesc, buDesc: buContext.buDesc,
projectNo: queryKeyword,
projectDesc: '',
projectNo: '',
projectDesc: queryKeyword,
customerNo: '', customerNo: '',
customerDesc: '', customerDesc: '',
projectCategory: '', projectCategory: '',
@ -4565,7 +4589,6 @@ export default {
const sourceRows = (data.page && data.page.list) || [] const sourceRows = (data.page && data.page.list) || []
const targetBuNo = buContext.normalizedBuNo.toUpperCase() const targetBuNo = buContext.normalizedBuNo.toUpperCase()
const targetBuDesc = this.isBlankValue(buContext.buDesc) ? '' : String(buContext.buDesc).trim().toUpperCase() const targetBuDesc = this.isBlankValue(buContext.buDesc) ? '' : String(buContext.buDesc).trim().toUpperCase()
const normalizedKeyword = queryKeyword.toUpperCase()
const filteredRows = sourceRows.filter(item => { const filteredRows = sourceRows.filter(item => {
if (!item || this.isBlankValue(item.projectNo)) { if (!item || this.isBlankValue(item.projectNo)) {
return false return false
@ -4577,31 +4600,29 @@ export default {
if (hasRowBuInfo && !matchedBu) { if (hasRowBuInfo && !matchedBu) {
return false return false
} }
if (!normalizedKeyword) {
return true
}
return String(item.projectNo).toUpperCase().indexOf(normalizedKeyword) > -1
return this.matchOneKeyDescKeyword(item.projectDesc, queryKeyword)
|| this.matchOneKeyDescKeyword(item.projectName, queryKeyword)
}) })
return this.sortRowsByDateDesc(filteredRows, ['createDate', 'projectCreationDate', 'updateDate']) return this.sortRowsByDateDesc(filteredRows, ['createDate', 'projectCreationDate', 'updateDate'])
}).catch(() => { }).catch(() => {
return [] return []
}) })
}, },
queryOneKeyPartOptions (projectNo, partNoKeyword) {
queryOneKeyPartOptions (projectNo, partDescKeyword) {
const normalizedProjectNo = this.normalizeProjectNo(projectNo) const normalizedProjectNo = this.normalizeProjectNo(projectNo)
if (!normalizedProjectNo) { if (!normalizedProjectNo) {
return Promise.resolve([]) return Promise.resolve([])
} }
const buContext = this.getOneKeyBuQueryContext() const buContext = this.getOneKeyBuQueryContext()
const queryKeyword = this.isBlankValue(partNoKeyword) ? '' : String(partNoKeyword).trim()
const queryKeyword = this.isBlankValue(partDescKeyword) ? '' : String(partDescKeyword).trim()
const inData = { const inData = {
site: buContext ? buContext.site : this.$store.state.user.site, site: buContext ? buContext.site : this.$store.state.user.site,
userName: this.$store.state.user.name, userName: this.$store.state.user.name,
buDesc: buContext ? buContext.buDesc : '', buDesc: buContext ? buContext.buDesc : '',
projectNo: normalizedProjectNo, projectNo: normalizedProjectNo,
projectDesc: '', projectDesc: '',
testPartNo: queryKeyword,
partDesc: '',
testPartNo: '',
partDesc: queryKeyword,
customerNo: '', customerNo: '',
customerDesc: '', customerDesc: '',
projectCategory: '', projectCategory: '',
@ -4625,17 +4646,13 @@ export default {
} }
const sourceRows = (data.page && data.page.list) || [] const sourceRows = (data.page && data.page.list) || []
const targetProjectNo = normalizedProjectNo.toUpperCase() const targetProjectNo = normalizedProjectNo.toUpperCase()
const normalizedKeyword = queryKeyword.toUpperCase()
const filteredRows = sourceRows.filter(item => { const filteredRows = sourceRows.filter(item => {
const rowPartNo = item && item.testPartNo ? String(item.testPartNo).trim() : '' const rowPartNo = item && item.testPartNo ? String(item.testPartNo).trim() : ''
const rowProjectNo = this.normalizeProjectNo(item && item.projectNo ? item.projectNo : '').toUpperCase() const rowProjectNo = this.normalizeProjectNo(item && item.projectNo ? item.projectNo : '').toUpperCase()
if (!rowPartNo || rowProjectNo !== targetProjectNo) { if (!rowPartNo || rowProjectNo !== targetProjectNo) {
return false return false
} }
if (!normalizedKeyword) {
return true
}
return rowPartNo.toUpperCase().indexOf(normalizedKeyword) > -1
return this.matchOneKeyDescKeyword(item.partDesc, queryKeyword)
}) })
return this.sortRowsByDateDesc(filteredRows, ['createDate', 'updateDate', 'buildDate']) return this.sortRowsByDateDesc(filteredRows, ['createDate', 'updateDate', 'buildDate'])
}).catch(() => { }).catch(() => {
@ -4645,7 +4662,8 @@ export default {
queryOneKeyProjectSuggestions (queryString, callback) { queryOneKeyProjectSuggestions (queryString, callback) {
const queryToken = this.oneKeyProjectQueryToken + 1 const queryToken = this.oneKeyProjectQueryToken + 1
this.oneKeyProjectQueryToken = queryToken this.oneKeyProjectQueryToken = queryToken
this.queryOneKeyProjectOptions(queryString).then(rows => {
const descKeyword = this.getOneKeyDescSearchKeyword(queryString, this.oneKeyProjectNoSnapshot)
this.queryOneKeyProjectOptions(descKeyword).then(rows => {
if (queryToken !== this.oneKeyProjectQueryToken) { if (queryToken !== this.oneKeyProjectQueryToken) {
return return
} }
@ -4670,14 +4688,15 @@ export default {
}) })
}, },
queryOneKeyPartSuggestions (queryString, callback) { queryOneKeyPartSuggestions (queryString, callback) {
const projectNo = this.normalizeProjectNo(this.oneKeyForm.projectNo)
const projectNo = this.normalizeProjectNo(this.oneKeyProjectNoSnapshot)
if (!projectNo) { if (!projectNo) {
callback([]) callback([])
return return
} }
const queryToken = this.oneKeyPartQueryToken + 1 const queryToken = this.oneKeyPartQueryToken + 1
this.oneKeyPartQueryToken = queryToken this.oneKeyPartQueryToken = queryToken
this.queryOneKeyPartOptions(projectNo, queryString).then(rows => {
const descKeyword = this.getOneKeyDescSearchKeyword(queryString, this.oneKeyPartNoSnapshot)
this.queryOneKeyPartOptions(projectNo, descKeyword).then(rows => {
if (queryToken !== this.oneKeyPartQueryToken) { if (queryToken !== this.oneKeyPartQueryToken) {
return return
} }
@ -4772,6 +4791,7 @@ export default {
this.oneKeyForm.partDesc = '' this.oneKeyForm.partDesc = ''
this.oneKeyForm.partType = '' this.oneKeyForm.partType = ''
this.oneKeyForm.dry_wet_type = '' this.oneKeyForm.dry_wet_type = ''
this.oneKeyPartNoSnapshot = ''
} }
this.loadOneKeyProofingApplyOptions(projectNo, { keepCurrentIfMissing: false }) this.loadOneKeyProofingApplyOptions(projectNo, { keepCurrentIfMissing: false })
}, },
@ -4782,6 +4802,7 @@ export default {
return return
} }
this.oneKeyForm.testPartNo = partNo this.oneKeyForm.testPartNo = partNo
this.oneKeyPartNoSnapshot = partNo
if (!this.isBlankValue(selectedPart.partDesc)) { if (!this.isBlankValue(selectedPart.partDesc)) {
this.oneKeyForm.partDesc = String(selectedPart.partDesc).trim() this.oneKeyForm.partDesc = String(selectedPart.partDesc).trim()
} }
@ -4992,6 +5013,7 @@ export default {
this.oneKeyProjectQueryToken += 1 this.oneKeyProjectQueryToken += 1
this.oneKeyPartQueryToken += 1 this.oneKeyPartQueryToken += 1
this.oneKeyProjectNoSnapshot = '' this.oneKeyProjectNoSnapshot = ''
this.oneKeyPartNoSnapshot = ''
this.oneKeyProjectRoleBaseline = {} this.oneKeyProjectRoleBaseline = {}
this.oneKeyForm = this.getEmptyOneKeyForm() this.oneKeyForm = this.getEmptyOneKeyForm()
const selectedSearchBuNo = this.getSelectedSearchBuNo() const selectedSearchBuNo = this.getSelectedSearchBuNo()
@ -5055,6 +5077,7 @@ export default {
this.oneKeyForm = this.buildOneKeyEditForm(current, projectRows[0], partRows[0]) this.oneKeyForm = this.buildOneKeyEditForm(current, projectRows[0], partRows[0])
this.snapshotOneKeyProjectRoles(projectRows[0]) this.snapshotOneKeyProjectRoles(projectRows[0])
this.oneKeyProjectNoSnapshot = this.normalizeProjectNo(this.oneKeyForm.projectNo) this.oneKeyProjectNoSnapshot = this.normalizeProjectNo(this.oneKeyForm.projectNo)
this.oneKeyPartNoSnapshot = this.isBlankValue(this.oneKeyForm.testPartNo) ? '' : String(this.oneKeyForm.testPartNo).trim()
this.oneKeyProofingApplyQueryToken += 1 this.oneKeyProofingApplyQueryToken += 1
this.oneKeyProofingApplyLoading = false this.oneKeyProofingApplyLoading = false
this.oneKeyProofingApplyOptions = [] this.oneKeyProofingApplyOptions = []

Loading…
Cancel
Save