feat:修改bug

This commit is contained in:
大黑 2025-12-23 17:09:02 +08:00
parent 662ea9a8ec
commit 280546c410
17 changed files with 1677 additions and 1009 deletions

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ yarn-error.log*
*.sln *.sln
*.sw? *.sw?
node_modules.zip node_modules.zip
apaas-custom-mydemo.zip

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,29 +34,25 @@
</div> </div>
</div> </div>
<div class="detail-content"> <div class="detail-content">
<!-- <section class="block-section"> <section class="block-section">
<div class="section-title"> <div class="section-title">
基础信息 基础信息
</div> </div>
<div class="info-grid"> <div class="info-grid">
<div class="info-item"> <div class="info-item">
<span class="label">模板名称</span> <span class="label">流程主题</span>
<span class="value">{{ progressDetail.modelName || '--' }}</span> <span class="value">{{ progressDetail.modelName || '--' }}</span>
</div> </div>
<div class="info-item"> <div class="info-item">
<span class="label">申请人</span> <span class="label">模板名称</span>
<span class="value">{{ progressDetail.applicant || '--' }}</span> <span class="value">{{ progressDetail.applicant || '--' }}</span>
</div> </div>
<div class="info-item"> <div class="info-item">
<span class="label">所属部门</span> <span class="label">版本</span>
<span class="value">{{ progressDetail.department || '--' }}</span>
</div>
<div class="info-item">
<span class="label">提交时间</span>
<span class="value">{{ progressDetail.submitTime || '--' }}</span> <span class="value">{{ progressDetail.submitTime || '--' }}</span>
</div> </div>
</div> </div>
</section> --> </section>
<section class="block-section"> <section class="block-section">
<div class="section-title"> <div class="section-title">

View File

@ -39,6 +39,7 @@
v-model="formData.partsName" v-model="formData.partsName"
placeholder="请选择零部件名称" placeholder="请选择零部件名称"
clearable clearable
multiple
style="width: 100%" style="width: 100%"
:disabled="!formData.subsystem" :disabled="!formData.subsystem"
@change="handlePartsNameChange" @change="handlePartsNameChange"
@ -57,7 +58,7 @@
placeholder="请选择部门" placeholder="请选择部门"
clearable clearable
style="width: 100%" style="width: 100%"
:disabled="dispatchType === 'update_param' ? (!formData.subsystem || !formData.partsName) : !formData.subsystem" :disabled="dispatchType === 'update_param' ? (!formData.subsystem || !formData.partsName || !Array.isArray(formData.partsName) || formData.partsName.length === 0) : !formData.subsystem"
@change="handleDepartmentChange" @change="handleDepartmentChange"
> >
<el-option <el-option
@ -151,7 +152,7 @@ export default {
submitting: false, submitting: false,
formData: { formData: {
subsystem: '', subsystem: '',
partsName: '', // partsName: [], //
department: '', department: '',
currentResponsibleId: '', // ID currentResponsibleId: '', // ID
currentResponsibleName: '', // currentResponsibleName: '', //
@ -191,7 +192,13 @@ export default {
// //
if (this.dispatchType === 'update_param') { if (this.dispatchType === 'update_param') {
rules.partsName = [ rules.partsName = [
{ required: true, message: '请选择零部件名称', trigger: 'change' } {
required: true,
type: 'array',
min: 1,
message: '请至少选择一个零部件名称',
trigger: 'change'
}
] ]
} }
return rules return rules
@ -218,7 +225,7 @@ export default {
// //
this.formData = { this.formData = {
subsystem: '', subsystem: '',
partsName: '', partsName: [],
department: '', department: '',
currentResponsibleId: '', currentResponsibleId: '',
currentResponsibleName: '', currentResponsibleName: '',
@ -251,7 +258,7 @@ export default {
this.visible = false this.visible = false
this.formData = { this.formData = {
subsystem: '', subsystem: '',
partsName: '', partsName: [],
department: '', department: '',
currentResponsibleId: '', currentResponsibleId: '',
currentResponsibleName: '', currentResponsibleName: '',
@ -312,7 +319,7 @@ export default {
// //
handleSubsystemChange(subsystem) { handleSubsystemChange(subsystem) {
// / // /
this.formData.partsName = '' this.formData.partsName = []
this.formData.department = '' this.formData.department = ''
this.formData.currentResponsibleId = '' this.formData.currentResponsibleId = ''
this.formData.currentResponsibleName = '' this.formData.currentResponsibleName = ''
@ -375,7 +382,8 @@ export default {
} }
}, },
// //
handlePartsNameChange(partsName) { handlePartsNameChange(partsNames) {
// partsNames
// //
this.formData.department = '' this.formData.department = ''
this.formData.currentFillerId = '' this.formData.currentFillerId = ''
@ -386,13 +394,13 @@ export default {
this.availableDepartments = [] this.availableDepartments = []
this.userOptions = [] this.userOptions = []
// //
if (partsName && this.formData.subsystem) { if (partsNames && Array.isArray(partsNames) && partsNames.length > 0 && this.formData.subsystem) {
this.filterDepartmentsByPartsName() this.filterDepartmentsByPartsName()
} }
}, },
// //
filterDepartmentsByPartsName() { filterDepartmentsByPartsName() {
if (!this.formData.subsystem || !this.formData.partsName) { if (!this.formData.subsystem || !this.formData.partsName || !Array.isArray(this.formData.partsName) || this.formData.partsName.length === 0) {
this.availableDepartments = [] this.availableDepartments = []
return return
} }
@ -405,11 +413,11 @@ export default {
const params = currentVersionData[dataPartsName] || [] const params = currentVersionData[dataPartsName] || []
// //
params.forEach((param) => { params.forEach((param) => {
// //
const paramPartsName = param.partsName || dataPartsName const paramPartsName = param.partsName || dataPartsName
if ( if (
param.subsystemName === this.formData.subsystem && param.subsystemName === this.formData.subsystem &&
paramPartsName === this.formData.partsName && this.formData.partsName.includes(paramPartsName) &&
param.department param.department
) { ) {
departmentSet.add(param.department) departmentSet.add(param.department)
@ -576,15 +584,15 @@ export default {
// //
if (this.dispatchType === 'update_param') { if (this.dispatchType === 'update_param') {
// //
if (!this.formData.partsName) { if (!this.formData.partsName || !Array.isArray(this.formData.partsName) || this.formData.partsName.length === 0) {
this.$message.warning('请选择零部件名称') this.$message.warning('请至少选择一个零部件名称')
return return
} }
// //
// userNumber 使 userId userNumber // userNumber 使 userId userNumber
const confirmData = { const confirmData = {
subsystem: this.formData.subsystem, subsystem: this.formData.subsystem,
partsName: this.formData.partsName, partsName: this.formData.partsName, //
department: this.formData.department, department: this.formData.department,
userId: this.formData.userId, // userId userId: this.formData.userId, // userId
userNumber: this.formData.userNumber || this.formData.userId, // userNumber使 userId userNumber: this.formData.userNumber || this.formData.userId, // userNumber使 userId

View File

@ -18,16 +18,35 @@
</div> </div>
</div> </div>
</div> </div>
<div class="header-right"> <div v-if="detail.statusDescription === '审核中'" class="header-right">
<el-button size="small" @click="handleReject"> <el-button size="small" @click="handleReject">
退回 退回
</el-button> </el-button>
<el-button type="primary" size="small" @click="handleSubmit"> <el-button v-if="detail.statusDescription === '审核中'" type="primary" size="small" @click="handleSubmit">
提交 提交
</el-button> </el-button>
</div> </div>
</div> </div>
<div class="detail-content"> <div class="detail-content">
<section class="block-section">
<div class="section-title">
基础信息
</div>
<div class="info-grid">
<div class="info-item">
<span class="label">流程主题</span>
<span class="value">{{ progressDetail.modelName || '--' }}</span>
</div>
<div class="info-item">
<span class="label">机型名称</span>
<span class="value">{{ progressDetail.applicant || '--' }}</span>
</div>
<div class="info-item">
<span class="label">版本</span>
<span class="value">{{ progressDetail.submitTime || '--' }}</span>
</div>
</div>
</section>
<section class="block-section"> <section class="block-section">
<div class="section-title"> <div class="section-title">
审批内容 审批内容
@ -271,35 +290,32 @@ export default {
// 使 activitiRecordDTOS // 使 activitiRecordDTOS
if (this.activitiRecordDTOS && this.activitiRecordDTOS.length > 0) { if (this.activitiRecordDTOS && this.activitiRecordDTOS.length > 0) {
// "" this.activitiRecordDTOS.forEach((record) => {
const isPassed = this.detail && this.detail.statusDescription === '已通过' // operate
const isWithdrawn = this.detail && this.detail.statusDescription === '已撤回' // REJECT ->
const isReject = this.detail && this.detail.statusDescription === '驳回' // APPROVING ->
this.activitiRecordDTOS.forEach((record, index) => { // PASS -> 绿
const isLast = index === this.activitiRecordDTOS.length - 1 let result = 'APPROVING' //
// let status = 'APPROVING'
// 1. """"""
// 2. """" if (record.operate) {
// 3. "" const operate = String(record.operate).toUpperCase()
let result = 'PASS' if (operate === 'REJECT') {
let status = 'PASS'
if (isLast) {
if (isWithdrawn || isReject) {
result = 'REJECT' result = 'REJECT'
status = 'REJECT' status = 'REJECT'
} else if (isPassed) { } else if (operate === 'APPROVING') {
result = 'PASS'
status = 'PASS'
} else {
result = 'APPROVING' result = 'APPROVING'
status = 'APPROVING' status = 'APPROVING'
} else if (operate === 'PASS') {
result = 'PASS'
status = 'PASS'
} }
} }
nodes.push({ nodes.push({
title: record.node || '审批节点', title: record.node || '审批节点',
userName: record.approverPersons || '--', userName: record.approverPersons || '--',
time: record.approvalTime || record.handleTime || record.createTime || '', operateTime: record.approvalTime || record.handleTime || record.createTime || '',
result: result, result: result,
status: status, status: status,
opinion: record.common || record.comment || record.opinion || null opinion: record.common || record.comment || record.opinion || null
@ -423,7 +439,7 @@ export default {
setStatusText(result) { setStatusText(result) {
const statusMap = { const statusMap = {
PASS: '通过', PASS: '通过',
REJECT: '驳回', REJECT: '拒绝',
REFUSE: '驳回', REFUSE: '驳回',
APPROVE: '批准', APPROVE: '批准',
APPROVING: '审批中', APPROVING: '审批中',

View File

@ -1452,7 +1452,8 @@ export default {
if (this.dispatchType === 'update_param') { if (this.dispatchType === 'update_param') {
const { subsystem, partsName, department, userId, userNumber, username } = change const { subsystem, partsName, department, userId, userNumber, username } = change
console.log(change, 'change', subsystem, partsName, department, userId, userNumber, username) console.log(change, 'change', subsystem, partsName, department, userId, userNumber, username)
if (!subsystem || !partsName || !department || !userId) { // partsName
if (!subsystem || !partsName || !Array.isArray(partsName) || partsName.length === 0 || !department || !userId) {
this.$message({ this.$message({
type: 'warning', type: 'warning',
message: '缺少必要参数' message: '缺少必要参数'
@ -1480,11 +1481,12 @@ export default {
// 使param.partsName使dataPartsName // 使param.partsName使dataPartsName
const paramPartsName = param.partsName || dataPartsName const paramPartsName = param.partsName || dataPartsName
// //
// partsName '/' partsName '/' // partsName '/' partsName '/'
// partsName
if ( if (
param.subsystemName === subsystem && param.subsystemName === subsystem &&
paramPartsName === partsName && partsName.includes(paramPartsName) &&
param.department === department param.department === department
) { ) {
// //

View File

@ -438,7 +438,9 @@
:on-remove="handleImportFileRemove" :on-remove="handleImportFileRemove"
> >
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text"> 将文件拖到此处<em>点击上传</em> </div> <div class="el-upload__text">
将文件拖到此处<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip"> <div slot="tip" class="el-upload__tip">
仅支持Excel或CSV模板文件 仅支持Excel或CSV模板文件
</div> </div>
@ -730,10 +732,10 @@ export default {
pageConfig: this.isMaintainMode pageConfig: this.isMaintainMode
? { hidden: true } ? { hidden: true }
: { : {
currentPage: this.pagination.currentPage, currentPage: this.pagination.currentPage,
pageSize: this.pagination.pageSize, pageSize: this.pagination.pageSize,
total: this.pagination.total total: this.pagination.total
} }
} }
}, },
paramModalTitle() { paramModalTitle() {
@ -1256,6 +1258,22 @@ export default {
} }
return findPath(this.departmentList, departmentId) || '' return findPath(this.departmentList, departmentId) || ''
}, },
//
formatDepartmentDisplay(department) {
if (!department) {
return '平台部'
}
// · -
const normalizedDept = department.replace(/·/g, '-')
// -
const parts = normalizedDept.split('-').filter(part => part.trim() !== '')
//
if (parts.length > 0) {
return parts[parts.length - 1]
}
//
return normalizedDept
},
handleBack() { handleBack() {
// //
if (this.isApprovalMode) { if (this.isApprovalMode) {
@ -1385,7 +1403,7 @@ export default {
} }
return return
} }
const templateId = this.internalTemplateId || this.templateId const templateId = this.getDetailTemplateId()
if (!templateId) { if (!templateId) {
this.$message.error('缺少模板ID无法导入') this.$message.error('缺少模板ID无法导入')
return return
@ -1451,7 +1469,7 @@ export default {
this.importDialogVisible = false this.importDialogVisible = false
}, },
handleDownloadTemplate() { handleDownloadTemplate() {
const templateRowId = this.templateId const templateRowId = this.getDetailTemplateId()
if (!templateRowId) { if (!templateRowId) {
console.log('未找到模板ID无法下载') console.log('未找到模板ID无法下载')
return return
@ -1568,10 +1586,9 @@ export default {
item.number || item.number ||
(this.pagination.currentPage - 1) * this.pagination.pageSize + index + 1 (this.pagination.currentPage - 1) * this.pagination.pageSize + index + 1
} }
// department 使 // department
// · -
if (item.department) { if (item.department) {
processedItem.department = item.department.replace(/·/g, '-') processedItem.department = this.formatDepartmentDisplay(item.department)
} }
return processedItem return processedItem
}) })
@ -1679,7 +1696,7 @@ export default {
}, },
handleApprovalFormSubmit() { handleApprovalFormSubmit() {
// ID // ID
const templateRowId = this.internalTemplateId || this.templateId const templateRowId = this.getDetailTemplateId()
if (!templateRowId) { if (!templateRowId) {
this.$message.error('缺少模板ID无法发起审批') this.$message.error('缺少模板ID无法发起审批')
return return
@ -1923,7 +1940,7 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
const templateRowId = this.internalTemplateId || this.templateId const templateRowId = this.getDetailTemplateId()
if (!templateRowId) { if (!templateRowId) {
console.log('缺少模板ID无法提交') console.log('缺少模板ID无法提交')
return return
@ -1957,23 +1974,23 @@ export default {
this.isMaintainMode = false this.isMaintainMode = false
this.originalTableData = [] this.originalTableData = []
this.submitting = false this.submitting = false
this.internalTemplateId = res.data.templateRowId const newTemplateId = res.data && (res.data.templateId || res.data.templateRowId)
this.setDetailTemplateId(newTemplateId)
this.internalTemplateVersion = res.data.version this.internalTemplateVersion = res.data.version
this.templateVersion = res.data.version this.templateVersion = res.data.version
this.templateId = res.data.templateRowId
console.log(this.templateId, res.data.templateRowId) console.log(this.templateId, res.data.templateRowId)
if (!this.versionList.some((v) => v.version === res.data.version)) { if (!this.versionList.some((v) => v.version === res.data.version)) {
this.versionList.push({ this.versionList.push({
version: res.data.version, version: res.data.version,
status: 'DRAFT', status: 'DRAFT',
rowId: res.data.templateRowId, rowId: newTemplateId,
id: res.data.templateId id: newTemplateId
}) })
} else { } else {
const versionItem = this.versionList.find((v) => v.version === res.data.version) const versionItem = this.versionList.find((v) => v.version === res.data.version)
versionItem.status = 'DRAFT' versionItem.status = 'DRAFT'
versionItem.rowId = res.data.templateRowId versionItem.rowId = newTemplateId
versionItem.id = res.data.templateId versionItem.id = newTemplateId
} }
this.loadData() this.loadData()
}) })
@ -2247,7 +2264,7 @@ export default {
loadTemplateInfo() { loadTemplateInfo() {
// ID // ID
// API // API
const id = this.internalTemplateId || this.templateId const id = this.getDetailTemplateId()
if (id) { if (id) {
// TODO: API // TODO: API
// this.$request(...).then(res => { // this.$request(...).then(res => {
@ -2258,7 +2275,7 @@ export default {
loadLatestVersion() { loadLatestVersion() {
// //
// //
const id = this.internalTemplateId || this.templateId const id = this.getDetailTemplateId()
if (id && !this.internalTemplateVersion) { if (id && !this.internalTemplateVersion) {
// TODO: API // TODO: API
// this.$request(...).then(res => { // this.$request(...).then(res => {
@ -2275,7 +2292,7 @@ export default {
}, },
loadAllData() { loadAllData() {
// //
const templateId = this.internalTemplateId || this.templateId const templateId = this.getDetailTemplateId()
if (!templateId) { if (!templateId) {
this.tableData = [] this.tableData = []
this.$set(this.pagination, 'total', 0) this.$set(this.pagination, 'total', 0)
@ -2313,7 +2330,8 @@ export default {
return { return {
...item, ...item,
parameterType: item.parameterType || item.type || '', parameterType: item.parameterType || item.type || '',
number: item.number || index + 1 number: item.number || index + 1,
department: item.department ? this.formatDepartmentDisplay(item.department) : (item.department || '')
} }
}) })
// 使 Vue.set 使 totalNumber // 使 Vue.set 使 totalNumber
@ -2333,11 +2351,23 @@ export default {
// //
return version.version || version.name || version.rowId || '' return version.version || version.name || version.rowId || ''
}, },
// 使 templateId
getDetailTemplateId() {
return this.internalTemplateId || this.templateId || ''
},
// 使 templateId使
setDetailTemplateId(newTemplateId) {
if (!newTemplateId) return
this.internalTemplateId = newTemplateId
this.templateId = newTemplateId
},
handleVersionChange(versionName) { handleVersionChange(versionName) {
// //
this.internalTemplateVersion = versionName this.internalTemplateVersion = versionName
this.changeId = this.versionList.find((v) => v.version === versionName)?.id || '' this.changeId = this.versionList.find((v) => v.version === versionName)?.id || ''
this.internalTemplateId = this.versionList.find((v) => v.version === versionName)?.rowId || '' const versionItem = this.versionList.find((v) => v.version === versionName)
const newTemplateId = (versionItem && (versionItem.id || versionItem.rowId)) || ''
this.setDetailTemplateId(newTemplateId)
// //
this.$set(this.pagination, 'currentPage', 1) this.$set(this.pagination, 'currentPage', 1)
// 使 // 使
@ -2371,7 +2401,7 @@ export default {
} }
}, },
loadData() { loadData() {
const templateId = this.internalTemplateId || this.templateId const templateId = this.getDetailTemplateId()
if (!templateId) { if (!templateId) {
this.tableData = [] this.tableData = []
this.$set(this.pagination, 'total', 0) this.$set(this.pagination, 'total', 0)
@ -2412,7 +2442,8 @@ export default {
return { return {
...item, ...item,
parameterType: item.parameterType || item.type || '', parameterType: item.parameterType || item.type || '',
number: item.number || startIndex + index + 1 number: item.number || startIndex + index + 1,
department: item.department ? this.formatDepartmentDisplay(item.department) : (item.department || '')
} }
}) })
// resp.data result // resp.data result

View File

@ -104,8 +104,8 @@
<span v-else-if="row[colConfig.prop] === '已通过'" class="status-tag status-approved" <span v-else-if="row[colConfig.prop] === '已通过'" class="status-tag status-approved"
>已通过</span >已通过</span
> >
<span v-else-if="row[colConfig.prop] === '撤回'" class="status-tag status-withdrawn" <span v-else-if="row[colConfig.prop] === '拒绝'" class="status-tag status-withdrawn"
>撤回</span >拒绝</span
> >
<span v-else class="status-tag status-default">{{ row[colConfig.prop] }}</span> <span v-else class="status-tag status-default">{{ row[colConfig.prop] }}</span>
</div> </div>
@ -508,7 +508,10 @@ export default {
// API // API
const flowId = row.flowId || row.id const flowId = row.flowId || row.id
if (!flowId) { if (!flowId) {
this.$message.error('缺少审批ID无法查看详情') this.$message({
type: 'error',
message: '缺少审批ID无法查看详情'
})
return return
} }
this.showEngineCheck = true this.showEngineCheck = true
@ -566,12 +569,11 @@ export default {
this.$request(request) this.$request(request)
.asyncThen((resp) => { .asyncThen((resp) => {
console.log('审批提交成功') console.log('审批提交成功')
this.loadData()
this.approvalDialogVisible = false this.approvalDialogVisible = false
this.currentApprovalRow = null this.currentApprovalRow = null
this.approvalSubmitting = false this.approvalSubmitting = false
// //
this.loadData()
}) })
.asyncErrorCatch((err) => { .asyncErrorCatch((err) => {
console.error('审批提交失败:', err) console.error('审批提交失败:', err)
@ -617,7 +619,7 @@ export default {
page: this.pagination.currentPage, page: this.pagination.currentPage,
size: this.pagination.pageSize, size: this.pagination.pageSize,
ycOrOth: '竞品', ycOrOth: '竞品',
userID: getUserId(), // userID: getUserId(),
...this.searchPanelValue ...this.searchPanelValue
}, },
disableSuccessMsg: true disableSuccessMsg: true
@ -774,8 +776,8 @@ export default {
} }
&.status-withdrawn { &.status-withdrawn {
background: #f5f7fa; background: #f56c6c;
color: #606266; color: white;
} }
} }
} }

View File

@ -6,6 +6,7 @@
竞品发动机数据 竞品发动机数据
</div> </div>
<div class="operation"> <div class="operation">
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
<el-button class="import-button" @click="handleImport"> <el-button class="import-button" @click="handleImport">
导入机型 导入机型
</el-button> </el-button>
@ -23,7 +24,7 @@
</div> </div>
<div class="searched-field"> <div class="searched-field">
<span class="fielded-label">状态代号</span> <span class="fielded-label">状态代号</span>
<el-input v-model="searchPanelValue.statusCode" placeholder="请输入" /> <el-input v-model="searchPanelValue.productNumber" placeholder="请输入" />
</div> </div>
<div class="searched-field"> <div class="searched-field">
<span class="fielded-label">板块</span> <span class="fielded-label">板块</span>
@ -184,6 +185,7 @@
</div> </div>
</el-upload> </el-upload>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="handleImportDialogClose">取消</el-button> <el-button @click="handleImportDialogClose">取消</el-button>
<el-button type="primary" :loading="importing" @click="handleImportConfirm"> <el-button type="primary" :loading="importing" @click="handleImportConfirm">
开始导入 开始导入
@ -235,7 +237,8 @@ export default {
importDialogVisible: false, importDialogVisible: false,
importing: false, importing: false,
selectedImportFile: null, selectedImportFile: null,
importFileList: [] importFileList: [],
downloadingTemplate: false
} }
}, },
computed: { computed: {
@ -512,7 +515,6 @@ export default {
.then((resp) => { .then((resp) => {
console.log('导入成功:', resp) console.log('导入成功:', resp)
loadingInstance.close() loadingInstance.close()
// //
this.handleImportDialogClose() this.handleImportDialogClose()
this.loadData() this.loadData()
@ -530,6 +532,89 @@ export default {
this.importing = false this.importing = false
}) })
}, },
handleDownloadTemplate() {
if (this.downloadingTemplate) {
return
}
const { url, method = 'get', headers = {} } = api.DOWNLOAD_ENGINE_DEMO || {}
const requestConfig = {
url,
method,
params: {},
responseType: 'blob',
headers
}
if (!requestConfig.url) {
console.log('未配置下载地址')
return
}
if ((requestConfig.method || '').toLowerCase() === 'post') {
requestConfig.data = requestConfig.params
delete requestConfig.params
}
const defaultFilename = '机型导入模板.xlsx'
this.downloadingTemplate = true
this.$axios(requestConfig)
.then((response) => {
const blobData = response.data
if (!blobData) {
console.log('下载失败,文件内容为空')
return
}
const contentType =
response.headers &&
(response.headers['content-type'] || response.headers['Content-Type'])
if (contentType && contentType.includes('application/json')) {
try {
const reader = new FileReader()
reader.onload = () => {
console.log(`下载失败: ${reader.result}`)
}
reader.readAsText(blobData)
} catch (err) {
console.error('解析下载失败响应异常:', err)
}
return
}
const disposition =
response.headers &&
(response.headers['content-disposition'] || response.headers['Content-Disposition'])
let filename = defaultFilename
if (disposition) {
const filenameMatch = /filename\*=UTF-8''([^;]+)|filename="?([^";]+)"?/i.exec(
disposition
)
const matchedName = filenameMatch ? filenameMatch[1] || filenameMatch[2] : ''
if (matchedName) {
try {
filename = decodeURIComponent(matchedName)
} catch (err) {
filename = matchedName
}
}
}
const downloadUrl = window.URL.createObjectURL(blobData)
const link = document.createElement('a')
link.href = downloadUrl
link.download = filename
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(downloadUrl)
this.$message({
type: 'success',
message: '下载成功'
})
console.log('下载开始,请查看浏览器下载列表')
})
.catch((err) => {
console.error('下载失败:', err)
this.$message.error('下载失败,请稍后重试')
})
.finally(() => {
this.downloadingTemplate = false
})
},
handleAdd() { handleAdd() {
// selfEnginedata.vue ycOrOth "" // selfEnginedata.vue ycOrOth ""
this.$refs.addEngineModelModal.showModal('竞品') this.$refs.addEngineModelModal.showModal('竞品')

View File

@ -898,32 +898,99 @@ export default {
this.$request(request) this.$request(request)
.asyncThen((resp) => { .asyncThen((resp) => {
if (resp && resp.data) { if (resp && resp.data) {
// // { "": [], "": ["-yc90117847"] }
let result = [] const responseData = resp.data
if (Array.isArray(resp.data)) { const deptArray = responseData['部门'] || responseData.department || []
result = resp.data const personArray = responseData['人员'] || responseData.person || []
} else if (resp.data.result && Array.isArray(resp.data.result)) {
result = resp.data.result // ["userName-userId"]
} else if (resp.data.data && Array.isArray(resp.data.data)) { if (personArray && personArray.length > 0) {
result = resp.data.data const personOptions = []
const personUserNumbers = []
personArray.forEach((personStr) => {
if (typeof personStr === 'string' && personStr.includes('-')) {
// userName-userId
const parts = personStr.split('-')
if (parts.length >= 2) {
// userId userName
const userId = parts[parts.length - 1]
const userName = parts.slice(0, -1).join('-')
personOptions.push({
userId: userId,
username: userName,
userNumber: userId // userNumber 使 userId
})
personUserNumbers.push(userId)
}
}
})
this.personOptions = personOptions
this.personConfigFormData.person = personUserNumbers
//
this.personConfigFormData.configType = 'person'
} else {
this.personOptions = []
this.personConfigFormData.person = []
}
// ["deptName-deptId"]
if (deptArray && deptArray.length > 0) {
const deptIds = []
const deptPaths = []
deptArray.forEach((deptStr) => {
if (typeof deptStr === 'string' && deptStr.includes('-')) {
// deptName-deptId
const parts = deptStr.split('-')
if (parts.length >= 2) {
// deptId deptName
const deptId = parts[parts.length - 1]
// deptName
// const deptName = parts.slice(0, -1).join('-')
//
const deptPath = this.findDepartmentPath(deptId)
if (deptPath && deptPath.length > 0) {
deptPaths.push(deptPath)
deptIds.push(deptId)
} else {
// 使 deptId
deptIds.push(deptId)
//
deptPaths.push([deptId])
}
}
}
})
if (deptIds.length > 0) {
this.personConfigFormData.selectDeptIds = deptIds
this.personConfigFormData.department = deptPaths
//
if (!personArray || personArray.length === 0) {
this.personConfigFormData.configType = 'department'
}
}
} else {
this.personConfigFormData.selectDeptIds = []
this.personConfigFormData.department = []
} }
// {userId: user.userId, username: user.username, userNumber: user.userNumber}
this.personOptions = result.map((user) => ({
userId: user.userId || user.id,
username: user.username || user.name,
userNumber: user.userNumber || user.userId || user.id
}))
// userNumber
this.personConfigFormData.person = this.personOptions.map(opt => opt.userNumber)
} else { } else {
this.personOptions = [] this.personOptions = []
this.personConfigFormData.person = [] this.personConfigFormData.person = []
this.personConfigFormData.selectDeptIds = []
this.personConfigFormData.department = []
} }
}) })
.asyncErrorCatch((err) => { .asyncErrorCatch((err) => {
console.error('加载人员列表失败:', err) console.error('加载人员列表失败:', err)
this.personOptions = [] this.personOptions = []
this.personConfigFormData.person = [] this.personConfigFormData.person = []
this.personConfigFormData.selectDeptIds = []
this.personConfigFormData.department = []
}) })
this.personConfigDialogVisible = true this.personConfigDialogVisible = true
this.$nextTick(() => { this.$nextTick(() => {
@ -1179,6 +1246,33 @@ export default {
const path = findNodePath(this.departmentList, deptId) const path = findNodePath(this.departmentList, deptId)
return path ? path.join('-') : '' return path ? path.join('-') : ''
}, },
// idID
findDepartmentPath(deptId) {
if (!deptId || !this.departmentList || this.departmentList.length === 0) {
return null
}
// ID
const findNodeIdPath = (nodes, targetId, path = []) => {
for (const node of nodes) {
const currentPath = [...path, node.id]
if (node.id === targetId) {
return currentPath
}
if (node.children && node.children.length > 0) {
const found = findNodeIdPath(node.children, targetId, currentPath)
if (found) {
return found
}
}
}
return null
}
return findNodeIdPath(this.departmentList, deptId)
},
// //
handlePersonConfigSubmit() { handlePersonConfigSubmit() {
this.$refs.personConfigForm.validate((valid) => { this.$refs.personConfigForm.validate((valid) => {

View File

@ -153,13 +153,13 @@
>查看</a >查看</a
> >
<span style="width: 6px; display: inline-block"></span> <span style="width: 6px; display: inline-block"></span>
<!-- <a <a
v-if="false" v-if="false"
href="javascript:void(0)" href="javascript:void(0)"
class="el-link el-link--primary" class="el-link el-link--primary"
@click.stop="handleEdit(row)" @click.stop="handleEdit(row)"
>修改</a >修改</a
> --> >
<span style="width: 6px; display: inline-block"></span> <span style="width: 6px; display: inline-block"></span>
<a <a
v-if="row.status === 'APPROVING'" v-if="row.status === 'APPROVING'"

View File

@ -6,6 +6,7 @@
玉柴发动机数据 玉柴发动机数据
</div> </div>
<div class="operation"> <div class="operation">
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
<el-button class="import-button" @click="handleImport"> <el-button class="import-button" @click="handleImport">
导入机型 导入机型
</el-button> </el-button>
@ -184,7 +185,7 @@
</div> </div>
</el-upload> </el-upload>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="handleDownloadTemplate">下载模板</el-button>
<el-button @click="handleImportDialogClose">取消</el-button> <el-button @click="handleImportDialogClose">取消</el-button>
<el-button type="primary" :loading="importing" @click="handleImportConfirm"> <el-button type="primary" :loading="importing" @click="handleImportConfirm">
开始导入 开始导入