feat:修改bug
This commit is contained in:
parent
662ea9a8ec
commit
280546c410
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,3 +25,4 @@ yarn-error.log*
|
||||
*.sln
|
||||
*.sw?
|
||||
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
@ -34,29 +34,25 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="detail-content">
|
||||
<!-- <section class="block-section">
|
||||
<section class="block-section">
|
||||
<div class="section-title">
|
||||
基础信息
|
||||
</div>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<span class="label">模板名称</span>
|
||||
<span class="label">流程主题</span>
|
||||
<span class="value">{{ progressDetail.modelName || '--' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="label">申请人</span>
|
||||
<span class="label">模板名称</span>
|
||||
<span class="value">{{ progressDetail.applicant || '--' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="label">所属部门</span>
|
||||
<span class="value">{{ progressDetail.department || '--' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="label">提交时间</span>
|
||||
<span class="label">版本</span>
|
||||
<span class="value">{{ progressDetail.submitTime || '--' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section> -->
|
||||
</section>
|
||||
|
||||
<section class="block-section">
|
||||
<div class="section-title">
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
v-model="formData.partsName"
|
||||
placeholder="请选择零部件名称"
|
||||
clearable
|
||||
multiple
|
||||
style="width: 100%"
|
||||
:disabled="!formData.subsystem"
|
||||
@change="handlePartsNameChange"
|
||||
@ -57,7 +58,7 @@
|
||||
placeholder="请选择部门"
|
||||
clearable
|
||||
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"
|
||||
>
|
||||
<el-option
|
||||
@ -151,7 +152,7 @@ export default {
|
||||
submitting: false,
|
||||
formData: {
|
||||
subsystem: '',
|
||||
partsName: '', // 零部件名称(仅用于批量修改填写人)
|
||||
partsName: [], // 零部件名称(仅用于批量修改填写人,多选)
|
||||
department: '',
|
||||
currentResponsibleId: '', // 现责任人的ID(用于判断是新增还是修改)
|
||||
currentResponsibleName: '', // 现责任人名称(只读显示)
|
||||
@ -191,7 +192,13 @@ export default {
|
||||
// 如果是批量修改填写人,添加零部件名称验证
|
||||
if (this.dispatchType === 'update_param') {
|
||||
rules.partsName = [
|
||||
{ required: true, message: '请选择零部件名称', trigger: 'change' }
|
||||
{
|
||||
required: true,
|
||||
type: 'array',
|
||||
min: 1,
|
||||
message: '请至少选择一个零部件名称',
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
}
|
||||
return rules
|
||||
@ -218,7 +225,7 @@ export default {
|
||||
// 重置表单数据
|
||||
this.formData = {
|
||||
subsystem: '',
|
||||
partsName: '',
|
||||
partsName: [],
|
||||
department: '',
|
||||
currentResponsibleId: '',
|
||||
currentResponsibleName: '',
|
||||
@ -251,7 +258,7 @@ export default {
|
||||
this.visible = false
|
||||
this.formData = {
|
||||
subsystem: '',
|
||||
partsName: '',
|
||||
partsName: [],
|
||||
department: '',
|
||||
currentResponsibleId: '',
|
||||
currentResponsibleName: '',
|
||||
@ -312,7 +319,7 @@ export default {
|
||||
// 处理子系统选择变化
|
||||
handleSubsystemChange(subsystem) {
|
||||
// 清空零部件名称、部门和现责任人/现填写人
|
||||
this.formData.partsName = ''
|
||||
this.formData.partsName = []
|
||||
this.formData.department = ''
|
||||
this.formData.currentResponsibleId = ''
|
||||
this.formData.currentResponsibleName = ''
|
||||
@ -375,7 +382,8 @@ export default {
|
||||
}
|
||||
},
|
||||
// 处理零部件名称选择变化(仅用于批量修改填写人)
|
||||
handlePartsNameChange(partsName) {
|
||||
handlePartsNameChange(partsNames) {
|
||||
// partsNames 现在是数组
|
||||
// 清空部门、现填写人和新填写人
|
||||
this.formData.department = ''
|
||||
this.formData.currentFillerId = ''
|
||||
@ -386,13 +394,13 @@ export default {
|
||||
this.availableDepartments = []
|
||||
this.userOptions = []
|
||||
// 根据子系统和零部件名称筛选部门列表
|
||||
if (partsName && this.formData.subsystem) {
|
||||
if (partsNames && Array.isArray(partsNames) && partsNames.length > 0 && this.formData.subsystem) {
|
||||
this.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 = []
|
||||
return
|
||||
}
|
||||
@ -405,11 +413,11 @@ export default {
|
||||
const params = currentVersionData[dataPartsName] || []
|
||||
// 遍历该零部件下的所有参数
|
||||
params.forEach((param) => {
|
||||
// 检查参数是否属于选中的子系统和零部件名称
|
||||
// 检查参数是否属于选中的子系统和任意一个选中的零部件名称
|
||||
const paramPartsName = param.partsName || dataPartsName
|
||||
if (
|
||||
param.subsystemName === this.formData.subsystem &&
|
||||
paramPartsName === this.formData.partsName &&
|
||||
this.formData.partsName.includes(paramPartsName) &&
|
||||
param.department
|
||||
) {
|
||||
departmentSet.add(param.department)
|
||||
@ -576,15 +584,15 @@ export default {
|
||||
// 如果是批量修改填写人,不调用接口,直接触发确认事件
|
||||
if (this.dispatchType === 'update_param') {
|
||||
// 验证零部件名称
|
||||
if (!this.formData.partsName) {
|
||||
this.$message.warning('请选择零部件名称')
|
||||
if (!this.formData.partsName || !Array.isArray(this.formData.partsName) || this.formData.partsName.length === 0) {
|
||||
this.$message.warning('请至少选择一个零部件名称')
|
||||
return
|
||||
}
|
||||
// 确保所有必要参数都有值
|
||||
// 如果 userNumber 为空,使用 userId 作为 userNumber(降级处理)
|
||||
const confirmData = {
|
||||
subsystem: this.formData.subsystem,
|
||||
partsName: this.formData.partsName,
|
||||
partsName: this.formData.partsName, // 现在是数组
|
||||
department: this.formData.department,
|
||||
userId: this.formData.userId, // 确保传递userId
|
||||
userNumber: this.formData.userNumber || this.formData.userId, // 如果没有 userNumber,使用 userId
|
||||
|
||||
@ -18,16 +18,35 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div v-if="detail.statusDescription === '审核中'" class="header-right">
|
||||
<el-button size="small" @click="handleReject">
|
||||
退回
|
||||
</el-button>
|
||||
<el-button type="primary" size="small" @click="handleSubmit">
|
||||
<el-button v-if="detail.statusDescription === '审核中'" type="primary" size="small" @click="handleSubmit">
|
||||
提交
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
<div class="section-title">
|
||||
审批内容
|
||||
@ -271,35 +290,32 @@ export default {
|
||||
|
||||
// 使用 activitiRecordDTOS 数据构建审批流程节点
|
||||
if (this.activitiRecordDTOS && this.activitiRecordDTOS.length > 0) {
|
||||
// 如果状态描述是"已通过",则最后一项也是完成状态
|
||||
const isPassed = this.detail && this.detail.statusDescription === '已通过'
|
||||
const isWithdrawn = this.detail && this.detail.statusDescription === '已撤回'
|
||||
const isReject = this.detail && this.detail.statusDescription === '驳回'
|
||||
this.activitiRecordDTOS.forEach((record, index) => {
|
||||
const isLast = index === this.activitiRecordDTOS.length - 1
|
||||
// 最后一项的状态判断:
|
||||
// 1. 如果整体状态是"已撤回"或"驳回",最后一项显示为"驳回"(红色)
|
||||
// 2. 如果整体状态是"已通过",最后一项显示为"通过"
|
||||
// 3. 其他情况,最后一项显示为"审批中"
|
||||
let result = 'PASS'
|
||||
let status = 'PASS'
|
||||
if (isLast) {
|
||||
if (isWithdrawn || isReject) {
|
||||
this.activitiRecordDTOS.forEach((record) => {
|
||||
// 根据每一项的 operate 字段设置状态
|
||||
// REJECT -> 红色(拒绝)
|
||||
// APPROVING -> 黄色(审批中)
|
||||
// PASS -> 绿色(通过)
|
||||
let result = 'APPROVING' // 默认状态为审批中
|
||||
let status = 'APPROVING'
|
||||
|
||||
if (record.operate) {
|
||||
const operate = String(record.operate).toUpperCase()
|
||||
if (operate === 'REJECT') {
|
||||
result = 'REJECT'
|
||||
status = 'REJECT'
|
||||
} else if (isPassed) {
|
||||
result = 'PASS'
|
||||
status = 'PASS'
|
||||
} else {
|
||||
} else if (operate === 'APPROVING') {
|
||||
result = 'APPROVING'
|
||||
status = 'APPROVING'
|
||||
} else if (operate === 'PASS') {
|
||||
result = 'PASS'
|
||||
status = 'PASS'
|
||||
}
|
||||
}
|
||||
|
||||
nodes.push({
|
||||
title: record.node || '审批节点',
|
||||
userName: record.approverPersons || '--',
|
||||
time: record.approvalTime || record.handleTime || record.createTime || '',
|
||||
operateTime: record.approvalTime || record.handleTime || record.createTime || '',
|
||||
result: result,
|
||||
status: status,
|
||||
opinion: record.common || record.comment || record.opinion || null
|
||||
@ -423,7 +439,7 @@ export default {
|
||||
setStatusText(result) {
|
||||
const statusMap = {
|
||||
PASS: '通过',
|
||||
REJECT: '驳回',
|
||||
REJECT: '拒绝',
|
||||
REFUSE: '驳回',
|
||||
APPROVE: '批准',
|
||||
APPROVING: '审批中',
|
||||
|
||||
@ -1452,7 +1452,8 @@ export default {
|
||||
if (this.dispatchType === 'update_param') {
|
||||
const { subsystem, partsName, department, userId, userNumber, username } = change
|
||||
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({
|
||||
type: 'warning',
|
||||
message: '缺少必要参数'
|
||||
@ -1480,11 +1481,12 @@ export default {
|
||||
// 获取参数的零部件名称(优先使用param.partsName,否则使用dataPartsName)
|
||||
const paramPartsName = param.partsName || dataPartsName
|
||||
|
||||
// 检查参数是否匹配子系统、零部件名称和部门
|
||||
// 当 partsName 为 '/' 时,匹配所有子系统为选中子系统且 partsName 为 '/' 的参数
|
||||
// 检查参数是否匹配子系统、零部件名称(数组)和部门
|
||||
// 当 partsName 数组中包含 '/' 时,匹配所有子系统为选中子系统且 partsName 为 '/' 的参数
|
||||
// 当 partsName 数组中包含其他值时,匹配对应的零部件名称
|
||||
if (
|
||||
param.subsystemName === subsystem &&
|
||||
paramPartsName === partsName &&
|
||||
partsName.includes(paramPartsName) &&
|
||||
param.department === department
|
||||
) {
|
||||
// 更新填写人信息
|
||||
|
||||
@ -438,7 +438,9 @@
|
||||
:on-remove="handleImportFileRemove"
|
||||
>
|
||||
<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">
|
||||
仅支持Excel或CSV模板文件
|
||||
</div>
|
||||
@ -730,10 +732,10 @@ export default {
|
||||
pageConfig: this.isMaintainMode
|
||||
? { hidden: true }
|
||||
: {
|
||||
currentPage: this.pagination.currentPage,
|
||||
pageSize: this.pagination.pageSize,
|
||||
total: this.pagination.total
|
||||
}
|
||||
currentPage: this.pagination.currentPage,
|
||||
pageSize: this.pagination.pageSize,
|
||||
total: this.pagination.total
|
||||
}
|
||||
}
|
||||
},
|
||||
paramModalTitle() {
|
||||
@ -1256,6 +1258,22 @@ export default {
|
||||
}
|
||||
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() {
|
||||
// 如果在审批模式下,取消审批而不是返回
|
||||
if (this.isApprovalMode) {
|
||||
@ -1385,7 +1403,7 @@ export default {
|
||||
}
|
||||
return
|
||||
}
|
||||
const templateId = this.internalTemplateId || this.templateId
|
||||
const templateId = this.getDetailTemplateId()
|
||||
if (!templateId) {
|
||||
this.$message.error('缺少模板ID,无法导入')
|
||||
return
|
||||
@ -1451,7 +1469,7 @@ export default {
|
||||
this.importDialogVisible = false
|
||||
},
|
||||
handleDownloadTemplate() {
|
||||
const templateRowId = this.templateId
|
||||
const templateRowId = this.getDetailTemplateId()
|
||||
if (!templateRowId) {
|
||||
console.log('未找到模板ID,无法下载')
|
||||
return
|
||||
@ -1568,10 +1586,9 @@ export default {
|
||||
item.number ||
|
||||
(this.pagination.currentPage - 1) * this.pagination.pageSize + index + 1
|
||||
}
|
||||
// 如果接口返回的 department 字段存在,使用接口返回的值
|
||||
// 否则保持原有逻辑(将 · 替换为 -)
|
||||
// 如果接口返回的 department 字段存在,格式化显示(只显示最后一节)
|
||||
if (item.department) {
|
||||
processedItem.department = item.department.replace(/·/g, '-')
|
||||
processedItem.department = this.formatDepartmentDisplay(item.department)
|
||||
}
|
||||
return processedItem
|
||||
})
|
||||
@ -1679,7 +1696,7 @@ export default {
|
||||
},
|
||||
handleApprovalFormSubmit() {
|
||||
// 获取模板ID
|
||||
const templateRowId = this.internalTemplateId || this.templateId
|
||||
const templateRowId = this.getDetailTemplateId()
|
||||
if (!templateRowId) {
|
||||
this.$message.error('缺少模板ID,无法发起审批')
|
||||
return
|
||||
@ -1923,7 +1940,7 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const templateRowId = this.internalTemplateId || this.templateId
|
||||
const templateRowId = this.getDetailTemplateId()
|
||||
if (!templateRowId) {
|
||||
console.log('缺少模板ID,无法提交')
|
||||
return
|
||||
@ -1957,23 +1974,23 @@ export default {
|
||||
this.isMaintainMode = false
|
||||
this.originalTableData = []
|
||||
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.templateVersion = res.data.version
|
||||
this.templateId = res.data.templateRowId
|
||||
console.log(this.templateId, res.data.templateRowId)
|
||||
if (!this.versionList.some((v) => v.version === res.data.version)) {
|
||||
this.versionList.push({
|
||||
version: res.data.version,
|
||||
status: 'DRAFT',
|
||||
rowId: res.data.templateRowId,
|
||||
id: res.data.templateId
|
||||
rowId: newTemplateId,
|
||||
id: newTemplateId
|
||||
})
|
||||
} else {
|
||||
const versionItem = this.versionList.find((v) => v.version === res.data.version)
|
||||
versionItem.status = 'DRAFT'
|
||||
versionItem.rowId = res.data.templateRowId
|
||||
versionItem.id = res.data.templateId
|
||||
versionItem.rowId = newTemplateId
|
||||
versionItem.id = newTemplateId
|
||||
}
|
||||
this.loadData()
|
||||
})
|
||||
@ -2247,7 +2264,7 @@ export default {
|
||||
loadTemplateInfo() {
|
||||
// 根据模板ID加载模板信息
|
||||
// 这里可以根据实际需求从API获取模板详情
|
||||
const id = this.internalTemplateId || this.templateId
|
||||
const id = this.getDetailTemplateId()
|
||||
if (id) {
|
||||
// TODO: 调用API获取模板详情
|
||||
// this.$request(...).then(res => {
|
||||
@ -2258,7 +2275,7 @@ export default {
|
||||
loadLatestVersion() {
|
||||
// 加载最新版本信息
|
||||
// 如果没有传入版本,尝试从模板信息中获取最新版本
|
||||
const id = this.internalTemplateId || this.templateId
|
||||
const id = this.getDetailTemplateId()
|
||||
if (id && !this.internalTemplateVersion) {
|
||||
// TODO: 调用API获取最新版本
|
||||
// this.$request(...).then(res => {
|
||||
@ -2275,7 +2292,7 @@ export default {
|
||||
},
|
||||
loadAllData() {
|
||||
// 加载所有数据(不分页),用于维护模式
|
||||
const templateId = this.internalTemplateId || this.templateId
|
||||
const templateId = this.getDetailTemplateId()
|
||||
if (!templateId) {
|
||||
this.tableData = []
|
||||
this.$set(this.pagination, 'total', 0)
|
||||
@ -2313,7 +2330,8 @@ export default {
|
||||
return {
|
||||
...item,
|
||||
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
|
||||
@ -2333,11 +2351,23 @@ export default {
|
||||
// 获取版本的唯一标识
|
||||
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) {
|
||||
// 版本切换时,更新内部版本值并重新加载数据
|
||||
this.internalTemplateVersion = versionName
|
||||
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)
|
||||
// 重新加载数据(使用新的版本号)
|
||||
@ -2371,7 +2401,7 @@ export default {
|
||||
}
|
||||
},
|
||||
loadData() {
|
||||
const templateId = this.internalTemplateId || this.templateId
|
||||
const templateId = this.getDetailTemplateId()
|
||||
if (!templateId) {
|
||||
this.tableData = []
|
||||
this.$set(this.pagination, 'total', 0)
|
||||
@ -2412,7 +2442,8 @@ export default {
|
||||
return {
|
||||
...item,
|
||||
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 中获取)
|
||||
|
||||
@ -104,8 +104,8 @@
|
||||
<span v-else-if="row[colConfig.prop] === '已通过'" class="status-tag status-approved"
|
||||
>已通过</span
|
||||
>
|
||||
<span v-else-if="row[colConfig.prop] === '已撤回'" class="status-tag status-withdrawn"
|
||||
>已撤回</span
|
||||
<span v-else-if="row[colConfig.prop] === '已拒绝'" class="status-tag status-withdrawn"
|
||||
>已拒绝</span
|
||||
>
|
||||
<span v-else class="status-tag status-default">{{ row[colConfig.prop] }}</span>
|
||||
</div>
|
||||
@ -508,7 +508,10 @@ export default {
|
||||
// 通过API获取审批详情
|
||||
const flowId = row.flowId || row.id
|
||||
if (!flowId) {
|
||||
this.$message.error('缺少审批ID,无法查看详情')
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '缺少审批ID,无法查看详情'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.showEngineCheck = true
|
||||
@ -566,12 +569,11 @@ export default {
|
||||
this.$request(request)
|
||||
.asyncThen((resp) => {
|
||||
console.log('审批提交成功')
|
||||
|
||||
this.loadData()
|
||||
this.approvalDialogVisible = false
|
||||
this.currentApprovalRow = null
|
||||
this.approvalSubmitting = false
|
||||
// 重新加载数据
|
||||
this.loadData()
|
||||
})
|
||||
.asyncErrorCatch((err) => {
|
||||
console.error('审批提交失败:', err)
|
||||
@ -617,7 +619,7 @@ export default {
|
||||
page: this.pagination.currentPage,
|
||||
size: this.pagination.pageSize,
|
||||
ycOrOth: '竞品',
|
||||
userID: getUserId(),
|
||||
// userID: getUserId(),
|
||||
...this.searchPanelValue
|
||||
},
|
||||
disableSuccessMsg: true
|
||||
@ -774,8 +776,8 @@ export default {
|
||||
}
|
||||
|
||||
&.status-withdrawn {
|
||||
background: #f5f7fa;
|
||||
color: #606266;
|
||||
background: #f56c6c;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
竞品发动机数据
|
||||
</div>
|
||||
<div class="operation">
|
||||
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
|
||||
<el-button class="import-button" @click="handleImport">
|
||||
导入机型
|
||||
</el-button>
|
||||
@ -23,7 +24,7 @@
|
||||
</div>
|
||||
<div class="searched-field">
|
||||
<span class="fielded-label">状态代号</span>
|
||||
<el-input v-model="searchPanelValue.statusCode" placeholder="请输入" />
|
||||
<el-input v-model="searchPanelValue.productNumber" placeholder="请输入" />
|
||||
</div>
|
||||
<div class="searched-field">
|
||||
<span class="fielded-label">板块</span>
|
||||
@ -184,6 +185,7 @@
|
||||
</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
|
||||
<el-button @click="handleImportDialogClose">取消</el-button>
|
||||
<el-button type="primary" :loading="importing" @click="handleImportConfirm">
|
||||
开始导入
|
||||
@ -235,7 +237,8 @@ export default {
|
||||
importDialogVisible: false,
|
||||
importing: false,
|
||||
selectedImportFile: null,
|
||||
importFileList: []
|
||||
importFileList: [],
|
||||
downloadingTemplate: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -512,7 +515,6 @@ export default {
|
||||
.then((resp) => {
|
||||
console.log('导入成功:', resp)
|
||||
loadingInstance.close()
|
||||
|
||||
// 导入成功后刷新列表
|
||||
this.handleImportDialogClose()
|
||||
this.loadData()
|
||||
@ -530,6 +532,89 @@ export default {
|
||||
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() {
|
||||
// 从 selfEnginedata.vue 跳转,设置 ycOrOth 为 "竞品"
|
||||
this.$refs.addEngineModelModal.showModal('竞品')
|
||||
|
||||
@ -898,32 +898,99 @@ export default {
|
||||
this.$request(request)
|
||||
.asyncThen((resp) => {
|
||||
if (resp && resp.data) {
|
||||
// 处理返回的数据,转换为选项格式
|
||||
let result = []
|
||||
if (Array.isArray(resp.data)) {
|
||||
result = resp.data
|
||||
} else if (resp.data.result && Array.isArray(resp.data.result)) {
|
||||
result = resp.data.result
|
||||
} else if (resp.data.data && Array.isArray(resp.data.data)) {
|
||||
result = resp.data.data
|
||||
// 处理返回的数据格式:{ "部门": [], "人员": ["李亚松-yc90117847"] }
|
||||
const responseData = resp.data
|
||||
const deptArray = responseData['部门'] || responseData.department || []
|
||||
const personArray = responseData['人员'] || responseData.person || []
|
||||
|
||||
// 处理人员数组:格式为 ["userName-userId"]
|
||||
if (personArray && personArray.length > 0) {
|
||||
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 {
|
||||
this.personOptions = []
|
||||
this.personConfigFormData.person = []
|
||||
this.personConfigFormData.selectDeptIds = []
|
||||
this.personConfigFormData.department = []
|
||||
}
|
||||
})
|
||||
.asyncErrorCatch((err) => {
|
||||
console.error('加载人员列表失败:', err)
|
||||
this.personOptions = []
|
||||
this.personConfigFormData.person = []
|
||||
this.personConfigFormData.selectDeptIds = []
|
||||
this.personConfigFormData.department = []
|
||||
})
|
||||
this.personConfigDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
@ -1179,6 +1246,33 @@ export default {
|
||||
const path = findNodePath(this.departmentList, deptId)
|
||||
return path ? path.join('-') : ''
|
||||
},
|
||||
// 根据部门id查找部门在树中的ID路径(用于级联选择器)
|
||||
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() {
|
||||
this.$refs.personConfigForm.validate((valid) => {
|
||||
|
||||
@ -153,13 +153,13 @@
|
||||
>查看</a
|
||||
>
|
||||
<span style="width: 6px; display: inline-block"></span>
|
||||
<!-- <a
|
||||
<a
|
||||
v-if="false"
|
||||
href="javascript:void(0)"
|
||||
class="el-link el-link--primary"
|
||||
@click.stop="handleEdit(row)"
|
||||
>修改</a
|
||||
> -->
|
||||
>
|
||||
<span style="width: 6px; display: inline-block"></span>
|
||||
<a
|
||||
v-if="row.status === 'APPROVING'"
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
玉柴发动机数据
|
||||
</div>
|
||||
<div class="operation">
|
||||
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
|
||||
<el-button class="import-button" @click="handleImport">
|
||||
导入机型
|
||||
</el-button>
|
||||
@ -184,7 +185,7 @@
|
||||
</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleDownloadTemplate">下载模板</el-button>
|
||||
|
||||
<el-button @click="handleImportDialogClose">取消</el-button>
|
||||
<el-button type="primary" :loading="importing" @click="handleImportConfirm">
|
||||
开始导入
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user