Browse Source

2026-07-29

Lab:
1、申请部门设置为数据字典取值,固定取site = 41;
2、【删除】需要用户有权限 且 (申请人一致 或者 是超级管理员);
master
fengyuan_yang 11 hours ago
parent
commit
e64347d57a
  1. 153
      src/views/modules/lab/labRecord.vue

153
src/views/modules/lab/labRecord.vue

@ -74,7 +74,11 @@
<span>{{ normalizeDateOnly(scope.row.applicationDate) }}</span> <span>{{ normalizeDateOnly(scope.row.applicationDate) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="applyDepartment" header-align="center" align="center" label="申请部门" width="150"></el-table-column>
<el-table-column prop="applyDepartment" header-align="center" align="center" label="申请部门" width="150">
<template slot-scope="scope">
<span>{{ resolveLabApplyDepartmentDisplay(scope.row.applyDepartment) }}</span>
</template>
</el-table-column>
<el-table-column prop="requestedDate" header-align="center" align="center" label="需求日期" width="120"> <el-table-column prop="requestedDate" header-align="center" align="center" label="需求日期" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ normalizeDateOnly(scope.row.requestedDate) }}</span> <span>{{ normalizeDateOnly(scope.row.requestedDate) }}</span>
@ -168,7 +172,15 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="申请部门/Apply Department"> <el-form-item label="申请部门/Apply Department">
<el-input v-model="modalData.applyDepartment" :disabled="isLabFieldDisabled('applyDepartment')" style="width: 225px"></el-input>
<dict-data-select
v-model="modalData.applyDepartment"
clearable
:disabled="isLabFieldDisabled('applyDepartment')"
style="width: 225px"
dict-type="lab_apply_department"
site="41"
@change="handleApplyDepartmentChange">
</dict-data-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -667,7 +679,7 @@
<el-input :value="currentDetail.site || ''" disabled style="width: 135px"></el-input> <el-input :value="currentDetail.site || ''" disabled style="width: 135px"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="申请部门/Apply Department"> <el-form-item label="申请部门/Apply Department">
<el-input :value="currentDetail.applyDepartment || ''" disabled style="width: 225px"></el-input>
<el-input :value="resolveLabApplyDepartmentDisplay(currentDetail.applyDepartment)" disabled style="width: 225px"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -1025,6 +1037,9 @@ export default {
operatorId: '', operatorId: '',
operatorName: '' operatorName: ''
}, },
labApplyDepartmentDictRows: [],
labApplyDepartmentValueLabelMap: {},
labApplyDepartmentLabelValueMap: {},
labTestLabDictRows: [], labTestLabDictRows: [],
labTestLabValueLabelMap: {}, labTestLabValueLabelMap: {},
labTestLabLabelValueMap: {}, labTestLabLabelValueMap: {},
@ -1043,6 +1058,7 @@ export default {
this.getButtonAuthData() this.getButtonAuthData()
this.checkSuperAdmin() this.checkSuperAdmin()
this.loadSiteOptions() this.loadSiteOptions()
this.loadLabApplyDepartmentDictOptions()
this.loadLabTestLabDictOptions() this.loadLabTestLabDictOptions()
}, },
mounted () { mounted () {
@ -1150,6 +1166,7 @@ export default {
applicantName: '', applicantName: '',
applicationDate: '', applicationDate: '',
applyDepartment: '', applyDepartment: '',
applyDepartmentLabel: '',
requestedDate: '', requestedDate: '',
customerId: '', customerId: '',
customerName: '', customerName: '',
@ -1223,10 +1240,114 @@ export default {
this.nodeOptions = [] this.nodeOptions = []
}) })
}, },
getLabTestLabDictSite () {
// Keep consistent with current Test Lab dict source configuration.
getLabFixedDictSite () {
// Keep consistent with current Lab fixed dictionary source configuration.
return '41' return '41'
}, },
getLabApplyDepartmentDictSite () {
return this.getLabFixedDictSite()
},
buildLabApplyDepartmentDictMaps (rows) {
const valueLabelMap = {}
const labelValueMap = {}
;(rows || []).forEach(item => {
const value = String((item && item.dictValue) || '').trim()
const label = String((item && item.dictLabel) || '').trim()
const status = String((item && item.status) || '').trim().toUpperCase()
if (!value || !label || status === 'N') {
return
}
valueLabelMap[value] = label
if (!labelValueMap[label]) {
labelValueMap[label] = value
}
})
this.labApplyDepartmentValueLabelMap = valueLabelMap
this.labApplyDepartmentLabelValueMap = labelValueMap
},
loadLabApplyDepartmentDictOptions (forceRefresh = false) {
if (!forceRefresh && this.labApplyDepartmentDictRows && this.labApplyDepartmentDictRows.length > 0) {
return Promise.resolve(this.labApplyDepartmentDictRows)
}
const params = {
site: this.getLabApplyDepartmentDictSite(),
dictType: 'lab_apply_department'
}
return selectDictDataList(params).then(({ data }) => {
if (data && data.code === 0 && Array.isArray(data.rows)) {
this.labApplyDepartmentDictRows = data.rows
this.buildLabApplyDepartmentDictMaps(data.rows)
} else {
this.labApplyDepartmentDictRows = []
this.labApplyDepartmentValueLabelMap = {}
this.labApplyDepartmentLabelValueMap = {}
}
return this.labApplyDepartmentDictRows
}).catch(() => {
this.labApplyDepartmentDictRows = []
this.labApplyDepartmentValueLabelMap = {}
this.labApplyDepartmentLabelValueMap = {}
return []
})
},
resolveLabApplyDepartmentPair (rawValue) {
const rawText = String(rawValue || '').trim()
if (!rawText) {
return {
key: '',
label: ''
}
}
const labelByValue = this.labApplyDepartmentValueLabelMap[rawText]
if (labelByValue) {
return {
key: rawText,
label: labelByValue
}
}
const valueByLabel = this.labApplyDepartmentLabelValueMap[rawText]
if (valueByLabel) {
return {
key: valueByLabel,
label: rawText
}
}
return {
key: rawText,
label: rawText
}
},
applyLabApplyDepartmentPairToModalData (rawValue) {
if (!this.modalData) {
return
}
const pair = this.resolveLabApplyDepartmentPair(rawValue)
this.$set(this.modalData, 'applyDepartment', pair.key)
this.$set(this.modalData, 'applyDepartmentLabel', pair.label)
},
resolveLabApplyDepartmentValueForSubmit (source) {
const sourceValue = String((source && source.applyDepartment) || '').trim()
if (!sourceValue) {
return ''
}
const pair = this.resolveLabApplyDepartmentPair(sourceValue)
return String(pair.key || sourceValue).trim()
},
resolveLabApplyDepartmentDisplay (rawValue) {
const pair = this.resolveLabApplyDepartmentPair(rawValue)
return String(pair.label || pair.key || '').trim()
},
handleApplyDepartmentChange (value) {
if (!this.modalData || this.showModalFlag || this.isLabFieldDisabled('applyDepartment')) {
return
}
const pair = this.resolveLabApplyDepartmentPair(value || '')
this.$set(this.modalData, 'applyDepartment', pair.key)
this.$set(this.modalData, 'applyDepartmentLabel', pair.label)
},
getLabTestLabDictSite () {
return this.getLabFixedDictSite()
},
buildLabTestLabDictMaps (rows) { buildLabTestLabDictMaps (rows) {
const valueLabelMap = {} const valueLabelMap = {}
const labelValueMap = {} const labelValueMap = {}
@ -2185,7 +2306,7 @@ export default {
checkSuperAdmin () { checkSuperAdmin () {
checkSuperAdmin().then(({data}) => { checkSuperAdmin().then(({data}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.superAdmin = !!data.flag
this.superAdmin = !!(data.superAdmin !== undefined ? data.superAdmin : data.flag)
} }
}) })
}, },
@ -2598,10 +2719,15 @@ export default {
this.$set(this.modalData, 'csProcessControl', 'N') this.$set(this.modalData, 'csProcessControl', 'N')
this.$set(this.modalData, 'testerName', this.modalData.testerName || this.modalData.tester || '') this.$set(this.modalData, 'testerName', this.modalData.testerName || this.modalData.tester || '')
this.$set(this.modalData, 'labApproverName', this.modalData.labApproverName || this.modalData.labApprover || '') this.$set(this.modalData, 'labApproverName', this.modalData.labApproverName || this.modalData.labApprover || '')
this.loadLabTestLabDictOptions().then(() => {
Promise.all([
this.loadLabApplyDepartmentDictOptions(),
this.loadLabTestLabDictOptions()
]).then(() => {
this.applyLabApplyDepartmentPairToModalData(this.modalData.applyDepartment)
this.applyLabTestLabPairToModalData(this.modalData.testLab) this.applyLabTestLabPairToModalData(this.modalData.testLab)
this.loadTesterOptions() this.loadTesterOptions()
}).catch(() => { }).catch(() => {
this.applyLabApplyDepartmentPairToModalData(this.modalData.applyDepartment)
this.applyLabTestLabPairToModalData(this.modalData.testLab) this.applyLabTestLabPairToModalData(this.modalData.testLab)
this.loadTesterOptions() this.loadTesterOptions()
}) })
@ -2641,6 +2767,8 @@ export default {
this.$set(this.modalData, 'testerCodeList', []) this.$set(this.modalData, 'testerCodeList', [])
this.$set(this.modalData, 'testerList', []) this.$set(this.modalData, 'testerList', [])
this.$set(this.modalData, 'testerName', '') this.$set(this.modalData, 'testerName', '')
this.$set(this.modalData, 'applyDepartment', '')
this.$set(this.modalData, 'applyDepartmentLabel', '')
this.$set(this.modalData, 'testLab', '') this.$set(this.modalData, 'testLab', '')
this.$set(this.modalData, 'testLabLabel', '') this.$set(this.modalData, 'testLabLabel', '')
this.$set(this.modalData, 'labApproverCodeList', []) this.$set(this.modalData, 'labApproverCodeList', [])
@ -2694,6 +2822,7 @@ export default {
fields.forEach(field => { fields.forEach(field => {
payload[field] = source[field] payload[field] = source[field]
}) })
payload.applyDepartment = this.resolveLabApplyDepartmentValueForSubmit(source)
payload.testLab = this.resolveLabTestLabLabelForSubmit(source) payload.testLab = this.resolveLabTestLabLabelForSubmit(source)
return payload return payload
}, },
@ -2836,6 +2965,16 @@ export default {
this.$message.warning('仅草稿状态的单据允许删除,当前勾选包含非草稿单据:' + previewText + suffix) this.$message.warning('仅草稿状态的单据允许删除,当前勾选包含非草稿单据:' + previewText + suffix)
return return
} }
const currentUserName = String((this.$store.state.user && this.$store.state.user.name) || this.createBy2 || '').trim()
const unauthorizedRows = this.superAdmin
? []
: selectedRows.filter(item => String((item && item.applicant) || '').trim() !== currentUserName)
if (unauthorizedRows.length) {
const previewText = unauthorizedRows.slice(0, 3).map(item => item.referenceNo).join('、')
const suffix = unauthorizedRows.length > 3 ? (' 等' + unauthorizedRows.length + '条') : ''
this.$message.warning('删除仅允许申请人本人或超级管理员操作,当前勾选包含不可删除单据:' + previewText + suffix)
return
}
this.$confirm('确认删除选中的' + selectedRows.length + '条Lab单据?删除后会同步删除属性和附件数据。', '提示', { this.$confirm('确认删除选中的' + selectedRows.length + '条Lab单据?删除后会同步删除属性和附件数据。', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',

Loading…
Cancel
Save