This commit is contained in:
hayu 2025-11-16 20:34:11 +08:00
parent 7dd27e57eb
commit 58a2fb721b
6 changed files with 133 additions and 96 deletions

View File

@ -18,6 +18,14 @@ export const addRepairData = (data = {}) => {
}) })
} }
export const updateRepairData = (data = {}) => {
return request({
url: '/material-mall/repair/updateRepairData',
method: 'POST',
data: data,
})
}
// 获取维修列表 // 获取维修列表
export const getRepairList = (data) => { export const getRepairList = (data) => {
return request({ return request({

View File

@ -38,7 +38,7 @@
:data="tableList" :data="tableList"
border stripe border stripe
height="550px" height="550px"
:row-key="row => `${row.id}-${row.type}`" :row-key="row => row.keyId"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<el-table-column type="selection" width="50" :reserve-selection="true"/> <el-table-column type="selection" width="50" :reserve-selection="true"/>
@ -95,29 +95,12 @@ export default {
}, },
methods: { methods: {
openDialog(applyId, selectedRows = []) { openDialog(applyId) {
this.applyId = applyId this.applyId = applyId
this.visible = true this.visible = true
this.getList() //
// selectedMap
this.selectedMap.clear()
// selectedMap
selectedRows.forEach(row => {
if (row.keyId) {
this.selectedMap.set(row.keyId, {
...row,
repairNum: row.repairNum || (row.manageMode === '编码管理' ? 1 : 1)
})
}
})
this.getList()
}, },
setFixNumToTableList(row, val) { setFixNumToTableList(row, val) {
const index = this.tableList.findIndex(x => x.keyId === row.keyId) const index = this.tableList.findIndex(x => x.keyId === row.keyId)
if (index !== -1) { if (index !== -1) {
@ -149,21 +132,26 @@ export default {
const rows = res.data || [] const rows = res.data || []
this.tableList = rows.map(item => { this.tableList = rows.map(item => {
const selected = item.keyId ? this.selectedMap.get(item.keyId) : null const key = item.keyId
const selected = this.selectedMap.get(key)
const isCodeManage = item.manageMode === "编码管理" const isCodeManage = item.manageMode === "编码管理"
return { return {
...item, ...item,
keyId: key, // row-key selectedMap key
repairNum: selected ? selected.repairNum : isCodeManage ? 1 : "" repairNum: selected ? selected.repairNum : isCodeManage ? 1 : ""
} }
}) })
// selectedMap tableList keyId // selectedMap tableList keyId
const tableKeys = new Set(this.tableList.map(r => r.keyId)) const tableKeys = new Set(this.tableList.map(r => r.keyId))
Array.from(this.selectedMap.keys()).forEach(key => { Array.from(this.selectedMap.keys()).forEach(key => {
if (!tableKeys.has(key)) this.selectedMap.delete(key) if (!tableKeys.has(key)) this.selectedMap.delete(key)
}) })
this.$nextTick(() => {
if (this.restoreSelection) this.restoreSelection()
})
this.$nextTick(() => this.restoreSelection())
} finally { } finally {
this.loading = false this.loading = false
} }
@ -172,14 +160,12 @@ export default {
restoreSelection() { restoreSelection() {
if (!this.$refs.multipleTable) return if (!this.$refs.multipleTable) return
this.tableList.forEach(row => { this.tableList.forEach(row => {
if (row.keyId && this.selectedMap.has(row.keyId)) { if (this.selectedMap.has(row.keyId)) {
this.$refs.multipleTable.toggleRowSelection(row, true) this.$refs.multipleTable.toggleRowSelection(row, true)
} }
}) })
}, },
handleQuery() { handleQuery() {
this.getList() this.getList()
}, },

View File

@ -63,7 +63,7 @@
:on-success="handleFileSuccess2" :on-success="handleFileSuccess2"
:auto-upload="true" :auto-upload="true"
> >
<el-button size="mini" type="text" @click="beforeFileUpload(scope.row)">上传</el-button> <el-button :disabled="scope.row.status && scope.row.status === '通过'" size="mini" type="text" @click="beforeFileUpload(scope.row)">上传</el-button>
</el-upload> </el-upload>
<el-button <el-button
size="mini" size="mini"
@ -76,10 +76,21 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="routerParams.isEdit" label="状态" align="center" prop="status" width="90">
<template #default="scope">
<el-tag
:type="scope.row.status === '通过' ? 'success' : scope.row.status === '驳回' ? 'danger' : 'warning'"
size="small"
>
{{ scope.row.status }}
</el-tag>
</template>
</el-table-column>
<!-- 操作列 --> <!-- 操作列 -->
<el-table-column label="操作" align="center" width="80px" v-if="!routerParams.isView"> <el-table-column label="操作" align="center" width="80px" v-if="!routerParams.isView">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" style="color: red"> <el-button :disabled="scope.row.status && scope.row.status === '通过'"
size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" style="color: red">
删除 删除
</el-button> </el-button>
</template> </template>
@ -113,7 +124,7 @@
import { getListByApplyIdApi, deleteToolApi, updateToolApplyApi } from '@/api/toolsManage' import { getListByApplyIdApi, deleteToolApi, updateToolApplyApi } from '@/api/toolsManage'
import SelectToolDialog from './SelectToolDialog.vue' import SelectToolDialog from './SelectToolDialog.vue'
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import {addRepairData} from "@/api/equipmentRepair"; import {addRepairData, getRepairDetailsList, updateRepairData} from "@/api/equipmentRepair";
export default { export default {
name: 'AddEditTools', name: 'AddEditTools',
@ -128,7 +139,7 @@ export default {
pageSize: 10, pageSize: 10,
parentTypeName: null, parentTypeName: null,
typeName: null, typeName: null,
manageType: null, manageMode: null,
applyId: null, applyId: null,
}, },
typeList: [ typeList: [
@ -150,12 +161,7 @@ export default {
{ label: '类目', prop: 'groupName' }, { label: '类目', prop: 'groupName' },
{ label: '名称', prop: 'typeName' }, { label: '名称', prop: 'typeName' },
{ label: '规格型号', prop: 'typeModelName' }, { label: '规格型号', prop: 'typeModelName' },
{ { label: '管理模式', prop: 'manageMode' },
label: '管理模式',
prop: 'manageType',
width: '80',
render: (h, { row }) => h('span', {}, row.manageType === '0' ? '数量管理' : '编码管理')
},
{ label: '设备编码', prop: 'code' }, { label: '设备编码', prop: 'code' },
{ label: '维修数量', prop: 'repairNum', width: 80 }, { label: '维修数量', prop: 'repairNum', width: 80 },
{ {
@ -164,18 +170,18 @@ export default {
width: '120', width: '120',
render: (h, { row }) => render: (h, { row }) =>
h('el-select', { h('el-select', {
props: { value: row.isScrap || '' }, props: {
value: row.isScrap || '',
disabled: row.status === '通过' //
},
on: { on: {
input: val => { input: val => {
this.$set(row, 'isScrap', val) this.$set(row, 'isScrap', val)
// === 退/ ===
if (val === '0') { if (val === '0') {
// 退
this.$set(row, 'reasonVal', '') this.$set(row, 'reasonVal', '')
this.$set(row, 'reasonDisabled', true) this.$set(row, 'reasonDisabled', true)
} else { } else {
//
this.$set(row, 'reasonDisabled', false) this.$set(row, 'reasonDisabled', false)
} }
} }
@ -183,7 +189,7 @@ export default {
style: 'width: 90px' style: 'width: 90px'
}, [ }, [
h('el-option', { props: { label: '是', value: '0' } }), h('el-option', { props: { label: '是', value: '0' } }),
h('el-option', { props: { label: '否', value: '1' } }), h('el-option', { props: { label: '否', value: '1' } })
]) ])
}, },
{ {
@ -196,9 +202,12 @@ export default {
type: 'date', type: 'date',
placeholder: '选择日期', placeholder: '选择日期',
format: 'yyyy-MM-dd', format: 'yyyy-MM-dd',
'value-format': 'yyyy-MM-dd' 'value-format': 'yyyy-MM-dd',
disabled: row.status === '通过' //
},
on: {
input: val => this.$set(row, 'repairTime', val)
}, },
on: { input: val => this.$set(row, 'repairTime', val) },
style: 'width: 140px' style: 'width: 140px'
}) })
}, },
@ -210,9 +219,11 @@ export default {
h('el-select', { h('el-select', {
props: { props: {
value: row.reasonVal || '', value: row.reasonVal || '',
disabled: row.reasonDisabled === true // disabled: row.reasonDisabled === true || row.status === '通过' //
},
on: {
input: val => this.$set(row, 'reasonVal', val)
}, },
on: { input: val => this.$set(row, 'reasonVal', val) },
style: 'width: 90px' style: 'width: 90px'
}, [ }, [
h('el-option', { props: { label: '人为', value: '人为' } }), h('el-option', { props: { label: '人为', value: '人为' } }),
@ -225,10 +236,10 @@ export default {
created() { created() {
this.routerParams = this.$route.query this.routerParams = this.$route.query
let title = '新增维修' let title = '新增维修'
if (this.routerParams.isView) title = '查看工具' if (this.routerParams.isView) title = '维修查看'
else if (this.routerParams.isEdit) title = '编辑工具' else if (this.routerParams.isEdit) title = '维修编辑'
this.queryParams.applyId = this.routerParams.applyId || '' this.queryParams.id = this.routerParams.applyId || ''
const obj = Object.assign({}, this.$route, { title }) const obj = Object.assign({}, this.$route, { title })
this.$tab.updatePage(obj) this.$tab.updatePage(obj)
this.getList() this.getList()
@ -253,6 +264,8 @@ export default {
if (!targetRow.bmFileInfos) { if (!targetRow.bmFileInfos) {
this.$set(targetRow, 'bmFileInfos', []) this.$set(targetRow, 'bmFileInfos', [])
} }
//bmFileInfos
targetRow.bmFileInfos=[]
// bmFileInfos // bmFileInfos
targetRow.bmFileInfos.push(obj) targetRow.bmFileInfos.push(obj)
this.$message.success('文件上传成功') this.$message.success('文件上传成功')
@ -287,7 +300,12 @@ export default {
const file = row.bmFileInfos[row.bmFileInfos.length - 1] const file = row.bmFileInfos[row.bmFileInfos.length - 1]
console.log('预览文件:', file) console.log('预览文件:', file)
this.dialogImageUrl = file.fileUrl.replaceAll('#', '%23') this.dialogImageUrl = file.fileUrl.replaceAll('#', '%23')
const parts = file.fileName.split('.') // URL
const urlParts = file.fileUrl.split('/');
const fileNameWithParams = urlParts[urlParts.length - 1];
// URL
const fileName = fileNameWithParams.split('?')[0];
const parts = fileName.split('.')
const extension = parts.pop().toLowerCase() const extension = parts.pop().toLowerCase()
if (['doc', 'docx', 'pdf'].includes(extension)) { if (['doc', 'docx', 'pdf'].includes(extension)) {
const windowName = file.fileName const windowName = file.fileName
@ -304,10 +322,31 @@ export default {
async getList() { async getList() {
this.isLoading = true this.isLoading = true
try { try {
const res = await getListByApplyIdApi({ ...this.queryParams }) const res = await getRepairDetailsList({ ...this.queryParams })
this.tableList = res.rows || [] this.tableList = res.data || []
this.total = res.total || 0
} finally { this.isLoading = false } /** ⭐ 获取列表后同步给弹窗的 selectedMap **/
if (this.$refs.addNum && this.$refs.addNum.selectedMap) {
const dialog = this.$refs.addNum
//
dialog.selectedMap.clear()
// tableList keyId selectedMap
this.tableList.forEach(row => {
dialog.selectedMap.set(row.keyId, row)
})
// tableList
dialog.tableList = [...this.tableList]
// restoreSelection
dialog.$nextTick(() => {
if (dialog.restoreSelection) dialog.restoreSelection()
})
}
this.total = this.tableList.length
} finally {
this.isLoading = false
}
}, },
handleDelete(row) { handleDelete(row) {
this.$confirm('确定删除该条数据?', '提示', { type: 'warning' }).then(() => { this.$confirm('确定删除该条数据?', '提示', { type: 'warning' }).then(() => {
@ -322,7 +361,7 @@ export default {
this.$message.success('删除成功') this.$message.success('删除成功')
}) })
}, },
handleNumDialog() { if (this.$refs.addNum) this.$refs.addNum.openDialog(this.queryParams.applyId, this.tableList) }, handleNumDialog() { if (this.$refs.addNum) this.$refs.addNum.openDialog(this.queryParams.applyId) },
handleAddFromDialog(rows) { handleAddFromDialog(rows) {
if (!rows || rows.length === 0) return if (!rows || rows.length === 0) return
const existingKeys = new Set(this.tableList.map(item => item.keyId)) const existingKeys = new Set(this.tableList.map(item => item.keyId))
@ -359,6 +398,7 @@ export default {
} }
const payload = { const payload = {
changeId:this.routerParams.applyId,
toBeRepairList: this.tableList toBeRepairList: this.tableList
} }
@ -366,7 +406,12 @@ export default {
this.isLoading = true this.isLoading = true
try { try {
const res = await addRepairData(payload) let res;
if (this.routerParams.isEdit){
res = await updateRepairData(payload)
} else {
res = await addRepairData(payload)
}
if (res.code ==200){ if (res.code ==200){
this.$message.success('操作成功!') this.$message.success('操作成功!')
this.$tab.closeOpenPage({ path: './repairList' }) this.$tab.closeOpenPage({ path: './repairList' })

View File

@ -72,18 +72,12 @@
:prop="column.prop" :prop="column.prop"
align="center" align="center"
> >
<!-- &lt;!&ndash; 插槽 &ndash;&gt;-->
<!-- <template v-slot="{ row }" v-if="column.prop == 'status'">-->
<!-- <el-tag v-if="row.status == '0'" type="info">草稿</el-tag>-->
<!-- <el-tag v-if="row.status == '1'" type="warning">审批中</el-tag>-->
<!-- <el-tag v-if="row.status == '2'" type="success">已审批</el-tag>-->
<!-- </template>-->
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<el-button v-if="row.status != '已驳回'" size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button> <el-button size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button>
<el-button v-if="row.status == '驳回'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button> <el-button v-if="row.status == '驳回待处理' || row.status == '全部驳回'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
<el-button v-if="row.status == '驳回'" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)" style="color: red" <el-button v-if="row.status == '待审核' || row.status == '全部驳回'" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)" style="color: red"
>删除</el-button >删除</el-button
> >
</template> </template>
@ -122,9 +116,11 @@ export default {
endTime: null, endTime: null,
}, },
statusList: [ statusList: [
{ label: '待审核', value: '待审核' },
{ label: '审核中', value: '审核中' }, { label: '审核中', value: '审核中' },
{ label: '已审核', value: '已审核' }, { label: '驳回待处理', value: '驳回待处理' },
{ label: '已驳回', value: '已驳回' }, { label: '全部通过', value: '全部通过' },
{ label: '全部驳回', value: '全部驳回' },
], ],
total: 0, // total: 0, //
// //
@ -185,7 +181,7 @@ export default {
}, },
// //
handleEdit(row) { handleEdit(row) {
this.$router.push({ path: '/toolsManage/addTools', query: { applyId: row.id, isEdit: true } }) this.$router.push({ path: './addRepair', query: { applyId: row.id, isEdit: true } })
}, },
// //
handleDelete(row) { handleDelete(row) {

View File

@ -72,7 +72,7 @@
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<el-button size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button> <el-button size="mini" type="text" icon="el-icon-zoom-in" @click="handleView(row)">查看</el-button>
<el-button v-if="row.status == '审核中'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">审核</el-button> <el-button v-if="row.status == '待审核' || row.status == '审核中'" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(row)">审核</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -109,9 +109,11 @@ export default {
endTime: null, endTime: null,
}, },
statusList: [ statusList: [
{ label: '待审核', value: '待审核' },
{ label: '审核中', value: '审核中' }, { label: '审核中', value: '审核中' },
{ label: '已审核', value: '已审核' }, { label: '驳回待处理', value: '驳回待处理' },
{ label: '已驳回', value: '已驳回' }, { label: '全部通过', value: '全部通过' },
{ label: '全部驳回', value: '全部驳回' },
], ],
total: 0, // total: 0, //
// //

View File

@ -188,7 +188,7 @@ export default {
if (res.code == 200) { if (res.code == 200) {
this.$message.success('通过成功!') this.$message.success('通过成功!')
} else { } else {
this.$message.error(res.msg || '通过失败') this.$message.error(res.msg)
} }
} catch (error) { } catch (error) {
this.$message.error('通过失败') this.$message.error('通过失败')