This commit is contained in:
hayu 2025-11-15 23:38:08 +08:00
parent 2a7b932a72
commit 2136e199fe
7 changed files with 1434 additions and 0 deletions

View File

@ -0,0 +1,46 @@
import request from '@/utils/request'
// 获取待修工具和装备列表
export const getToBeRepairList = (data) => {
return request({
url: '/material-mall/repair/getToBeRepairList',
method: 'GET',
params: data,
})
}
//提交申请
export const addRepairData = (data = {}) => {
return request({
url: '/material-mall/repair/addRepairData',
method: 'POST',
data: data,
})
}
// 获取维修列表
export const getRepairList = (data) => {
return request({
url: '/material-mall/repair/getRepairList',
method: 'GET',
params: data,
})
}
// 获取维修详情列表
export const getRepairDetailsList = (data) => {
return request({
url: '/material-mall/repair/getRepairDetailsList',
method: 'GET',
params: data,
})
}
// 维修列表删除
export const deleteRepairList = (data) => {
return request({
url: '/material-mall/repair/deleteRepairList',
method: 'POST',
data: data,
})
}

View File

@ -0,0 +1,226 @@
<template>
<el-dialog
title="选择编码工具"
:visible.sync="visible"
width="70%"
@close="handleClose"
>
<!-- 查询条件 -->
<el-form :model="queryParams" inline size="small" label-width="80px">
<el-form-item label="名称">
<el-input v-model="queryParams.typeName" placeholder="输入内容"
clearable style="width: 200px"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="规格型号">
<el-input v-model="queryParams.typeModelName" placeholder="输入内容"
clearable style="width: 200px"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="编码">
<el-input v-model="queryParams.code" placeholder="输入内容"
clearable style="width: 200px"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">查询</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 表格 -->
<el-table
ref="multipleTable"
v-loading="loading"
:data="tableList"
border stripe
height="550px"
:row-key="row => `${row.id}-${row.type}`"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="50" :reserve-selection="true"/>
<el-table-column align="center" label="序号" type="index" width="60"/>
<el-table-column align="center" label="分类" prop="type" width="110"/>
<el-table-column align="center" label="类目" prop="groupName"/>
<el-table-column align="center" label="名称" prop="typeName"/>
<el-table-column align="center" label="规格型号" prop="typeModelName"/>
<el-table-column align="center" label="管理模式" prop="manageMode" width="110"/>
<el-table-column align="center" label="设备编码" prop="code" width="150"/>
<el-table-column align="center" label="在修数量" prop="tobeRepairNum" width="100"/>
<el-table-column align="center" label="维修数量" width="120">
<template v-slot="{ row }">
<el-input
v-model="row.repairNum"
size="mini"
placeholder="输入数量"
@input="handleFixNumInput($event, row)"
@blur="handleFixNumBlur($event, row)"
/>
</template>
</el-table-column>
</el-table>
<!-- 底部按钮 -->
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="handleConfirm">确定添加</el-button>
</span>
</el-dialog>
</template>
<script>
import { getToBeRepairList } from "@/api/equipmentRepair";
export default {
name: 'SelectToolDialog',
data() {
return {
visible: false,
loading: false,
applyId: null,
queryParams: {
typeModelName: null,
typeName: null,
code: null,
},
tableList: [],
// selectedMap key `${id}-${type}`
selectedMap: new Map(),
}
},
methods: {
openDialog(applyId, selectedRows = []) {
this.applyId = applyId
this.visible = true
// 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) {
const index = this.tableList.findIndex(x => x.keyId === row.keyId)
if (index !== -1) {
this.$set(this.tableList[index], "repairNum", val)
}
},
handleFixNumInput(val, row) {
if (row.manageMode === "编码管理") val = 1
this.setFixNumToTableList(row, val)
if (row.keyId && this.selectedMap.has(row.keyId)) this.selectedMap.get(row.keyId).repairNum = val
},
handleFixNumBlur(val, row) {
let num = Number(val)
if (!val || isNaN(num) || num <= 0) num = row.repairNum || 1
if (num > row.tobeRepairNum) {
num = row.tobeRepairNum
this.$message.warning("维修数量不能大于在修数量")
}
this.setFixNumToTableList(row, num)
if (row.keyId && this.selectedMap.has(row.keyId)) this.selectedMap.get(row.keyId).repairNum = num
},
async getList() {
this.loading = true
try {
const res = await getToBeRepairList({ ...this.queryParams })
const rows = res.data || []
this.tableList = rows.map(item => {
const selected = item.keyId ? this.selectedMap.get(item.keyId) : null
const isCodeManage = item.manageMode === "编码管理"
return {
...item,
repairNum: selected ? selected.repairNum : isCodeManage ? 1 : ""
}
})
// selectedMap tableList keyId
const tableKeys = new Set(this.tableList.map(r => r.keyId))
Array.from(this.selectedMap.keys()).forEach(key => {
if (!tableKeys.has(key)) this.selectedMap.delete(key)
})
this.$nextTick(() => this.restoreSelection())
} finally {
this.loading = false
}
},
restoreSelection() {
if (!this.$refs.multipleTable) return
this.tableList.forEach(row => {
if (row.keyId && this.selectedMap.has(row.keyId)) {
this.$refs.multipleTable.toggleRowSelection(row, true)
}
})
},
handleQuery() {
this.getList()
},
resetQuery() {
this.queryParams = {typeModelName: null, typeName: null, code: null}
this.getList()
},
handleSelectionChange(selection) {
selection.forEach(row => {
if (row.keyId && !this.selectedMap.has(row.keyId)) {
this.selectedMap.set(row.keyId, { ...row })
}
})
this.tableList.forEach(row => {
if (row.keyId && !selection.some(s => s.keyId === row.keyId)) {
this.selectedMap.delete(row.keyId)
}
})
},
handleConfirm() {
if (this.selectedMap.size === 0) return this.$message.warning("请至少选择一条数据")
for (let item of this.selectedMap.values()) {
if (item.manageMode !== "编码管理") {
const num = Number(item.repairNum)
if (!num || num <= 0) return this.$message.warning(`维修数量必须大于 0${item.typeName}`)
if (num > item.tobeRepairNum) return this.$message.warning(`维修数量不能大于在修数量(${item.typeName}`)
}
}
this.$emit("confirm", [...this.selectedMap.values()])
this.visible = false
},
handleClose() {
this.selectedMap.clear()
}
}
}
</script>

View File

@ -0,0 +1,382 @@
<template>
<div class="app-container">
<!-- 列表 -->
<el-card>
<el-row class="mb8" :gutter="10" justify="end">
<el-col :span="4">
<span style="font-size: 20px; font-weight: 800">申请列表</span>
</el-col>
<el-col v-if="!routerParams.isView" :span="20" style="display: flex; justify-content: flex-end">
<el-button type="primary" @click="handleNumDialog">添加</el-button>
<el-button type="primary" @click="submit">确认申请</el-button>
</el-col>
</el-row>
<el-table
v-loading="isLoading"
:data="tableList"
highlight-current-row
border
stripe
:max-height="650"
style="width: 100%"
>
<!-- 序号列 -->
<el-table-column
type="index"
width="55"
label="序号"
align="center"
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<!-- 动态列 -->
<el-table-column
v-for="(column, index) in tableColumns"
:key="index"
:label="column.label"
:prop="column.prop"
:width="column.width"
:min-width="column.minWidth"
align="center"
show-overflow-tooltip
>
<template slot-scope="scope">
<span v-if="!column.render">{{ scope.row[column.prop] }}</span>
<component
v-else
:is="{ render: (h) => column.render(h, { row: scope.row }) }"
/>
</template>
</el-table-column>
<el-table-column label="附件" align="center" width="90" :show-overflow-tooltip="true">
<template slot-scope="scope">
<div style="display: flex; align-items: center; justify-content: space-between">
<el-upload
ref="upload"
:limit="3"
:headers="upload.headers"
:action="upload.url"
:show-file-list="false"
accept=".png, .jpg, .jpeg, .pdf, .doc, .docx"
:on-success="handleFileSuccess2"
:auto-upload="true"
>
<el-button size="mini" type="text" @click="beforeFileUpload(scope.row)">上传</el-button>
</el-upload>
<el-button
size="mini"
type="text"
@click="picturePreview(scope.row)"
v-if="scope.row.bmFileInfos && scope.row.bmFileInfos.length > 0"
>
查看
</el-button>
</div>
</template>
</el-table-column>
<!-- 操作列 -->
<el-table-column label="操作" align="center" width="80px" v-if="!routerParams.isView">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" style="color: red">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-card>
<!-- 插入选择工具的弹窗 -->
<SelectToolDialog ref="addNum" @confirm="handleAddFromDialog" />
<!-- 图片查看弹窗 -->
<el-dialog :visible.sync="dialogVisible" width="500px" height="500px">
<img width="100%" height="500px" :src="dialogImageUrl" />
</el-dialog>
</div>
</template>
<script>
import { getListByApplyIdApi, deleteToolApi, updateToolApplyApi } from '@/api/toolsManage'
import SelectToolDialog from './SelectToolDialog.vue'
import { getToken } from "@/utils/auth";
import {addRepairData} from "@/api/equipmentRepair";
export default {
name: 'AddEditTools',
components: { SelectToolDialog },
data() {
return {
routerParams: {},
isLoading: false,
showSearch: true,
queryParams: {
pageNum: 1,
pageSize: 10,
parentTypeName: null,
typeName: null,
manageType: null,
applyId: null,
},
typeList: [
{ label: '数量管理', value: '0' },
{ label: '编码管理', value: '1' },
],
upload: {
headers: { Authorization: 'Bearer ' + getToken() },
url: process.env.VUE_APP_BASE_API + '/file/upload'
},
currentRowId: null,
dialogImageUrl: '',
dialogVisible: false,
tempMaCodeList: [],
total: 0,
tableList: [],
tableColumns: [
{ label: '分类', prop: 'type', width: 75 },
{ label: '类目', prop: 'groupName' },
{ label: '名称', prop: 'typeName' },
{ label: '规格型号', prop: 'typeModelName' },
{
label: '管理模式',
prop: 'manageType',
width: '80',
render: (h, { row }) => h('span', {}, row.manageType === '0' ? '数量管理' : '编码管理')
},
{ label: '设备编码', prop: 'code' },
{ label: '维修数量', prop: 'repairNum', width: 80 },
{
label: '维修是否合格',
prop: 'isScrap',
width: '120',
render: (h, { row }) =>
h('el-select', {
props: { value: row.isScrap || '' },
on: {
input: val => {
this.$set(row, 'isScrap', val)
// === 退/ ===
if (val === '0') {
// 退
this.$set(row, 'reasonVal', '')
this.$set(row, 'reasonDisabled', true)
} else {
//
this.$set(row, 'reasonDisabled', false)
}
}
},
style: 'width: 90px'
}, [
h('el-option', { props: { label: '是', value: '0' } }),
h('el-option', { props: { label: '否', value: '1' } }),
])
},
{
label: '维修日期',
prop: 'repairTime',
width: '180',
render: (h, { row }) => h('el-date-picker', {
props: {
value: row.repairTime,
type: 'date',
placeholder: '选择日期',
format: 'yyyy-MM-dd',
'value-format': 'yyyy-MM-dd'
},
on: { input: val => this.$set(row, 'repairTime', val) },
style: 'width: 140px'
})
},
{
label: '退役原因',
prop: 'reasonVal',
width: '120',
render: (h, { row }) =>
h('el-select', {
props: {
value: row.reasonVal || '',
disabled: row.reasonDisabled === true //
},
on: { input: val => this.$set(row, 'reasonVal', val) },
style: 'width: 90px'
}, [
h('el-option', { props: { label: '人为', value: '人为' } }),
h('el-option', { props: { label: '自然', value: '自然' } })
])
},
]
}
},
created() {
this.routerParams = this.$route.query
let title = '新增维修'
if (this.routerParams.isView) title = '查看工具'
else if (this.routerParams.isEdit) title = '编辑工具'
this.queryParams.applyId = this.routerParams.applyId || ''
const obj = Object.assign({}, this.$route, { title })
this.$tab.updatePage(obj)
this.getList()
},
methods: {
// -
//
handleFileSuccess2(response, file, fileList) {
console.log('文件上传成功', response)
if (response.code === 200) {
let obj = {
fileName: response.data.name,
fileUrl: response.data.url
}
// ID
if (this.currentRowId !== null) {
//
const targetRow = this.tableList.find(item => item.keyId === this.currentRowId)
if (targetRow) {
// bmFileInfos
if (!targetRow.bmFileInfos) {
this.$set(targetRow, 'bmFileInfos', [])
}
// bmFileInfos
targetRow.bmFileInfos.push(obj)
this.$message.success('文件上传成功')
//
this.$forceUpdate()
} else {
this.$message.warning('未找到对应的行数据')
}
// currentRowId
this.currentRowId = null
} else {
this.$message.warning('未找到对应的行数据')
}
} else {
this.$message.error('文件上传失败:' + response.msg)
}
},
// ID
beforeFileUpload(row) {
this.currentRowId = row.keyId
console.log('记录当前行ID:', row.keyId)
},
//
picturePreview(row) {
console.log('预览行数据:', row)
console.log('预览附件:', row.bmFileInfos)
if (row.bmFileInfos && row.bmFileInfos.length > 0) {
//
const file = row.bmFileInfos[row.bmFileInfos.length - 1]
console.log('预览文件:', file)
this.dialogImageUrl = file.fileUrl.replaceAll('#', '%23')
const parts = file.fileName.split('.')
const extension = parts.pop().toLowerCase()
if (['doc', 'docx', 'pdf'].includes(extension)) {
const windowName = file.fileName
window.open(file.fileUrl, windowName)
} else {
this.dialogVisible = true
}
} else {
this.$message.warning('该行没有附件')
}
},
handleQuery() { this.queryParams.pageNum = 1; this.getList() },
handleReset() { this.queryParams.pageNum = 1; this.queryParams.pageSize = 10; this.$refs.queryForm.resetFields(); this.getList() },
async getList() {
this.isLoading = true
try {
const res = await getListByApplyIdApi({ ...this.queryParams })
this.tableList = res.rows || []
this.total = res.total || 0
} finally { this.isLoading = false }
},
handleDelete(row) {
this.$confirm('确定删除该条数据?', '提示', { type: 'warning' }).then(() => {
this.tableList = this.tableList.filter(item => item.keyId !== row.keyId)
if (this.$refs.addNum) {
const dialog = this.$refs.addNum
dialog.selectedMap.delete(row.keyId)
dialog.tableList = dialog.tableList.filter(item => item.keyId !== row.keyId)
dialog.$nextTick(() => dialog.restoreSelection())
}
this.total = this.tableList.length
this.$message.success('删除成功')
})
},
handleNumDialog() { if (this.$refs.addNum) this.$refs.addNum.openDialog(this.queryParams.applyId, this.tableList) },
handleAddFromDialog(rows) {
if (!rows || rows.length === 0) return
const existingKeys = new Set(this.tableList.map(item => item.keyId))
const newRows = rows.filter(item => !existingKeys.has(item.keyId))
newRows.forEach(item => {
if (item.manageMode === '编码管理') item.repairNum = 1
else if (!item.repairNum) item.repairNum = 1
if (this.$refs.addNum && this.$refs.addNum.selectedMap) this.$refs.addNum.selectedMap.set(item.keyId, item)
})
this.tableList = [...this.tableList, ...newRows]
this.total = this.tableList.length
},
submit() {
this.$confirm('是否确定提交申请?', '提示', { type: 'warning' }).then(async () => {
//
for (const row of this.tableList) {
if (!row.repairNum || row.repairNum === 0) {
return this.$message.warning(`${row.typeName}】维修数量不能为空或为0`)
}
if (!row.isScrap) {
return this.$message.warning(`${row.typeName}】请选择维修是否合格`)
}
if (!row.repairTime) {
return this.$message.warning(`${row.typeName}】请选择维修日期`)
}
// 退
if (row.isScrap === '1' && !row.reasonVal) {
return this.$message.warning(`${row.typeName}】请选择退役原因`)
}
}
const payload = {
toBeRepairList: this.tableList
}
console.log("提交内容:", payload)
this.isLoading = true
try {
const res = await addRepairData(payload)
if (res.code ==200){
this.$message.success('操作成功!')
this.$tab.closeOpenPage({ path: './repairList' })
} else {
this.$message.error(res.msg || '申请失败')
}
} catch (error) {
this.$message.error('申请失败')
}finally {
this.isLoading = false
}
})
},
}
}
</script>

View File

@ -0,0 +1,217 @@
<template>
<!-- 基础页面 -->
<div class="app-container">
<el-card v-show="showSearch" style="margin-bottom: 20px">
<el-form :model="queryParams" ref="queryForm" size="small" inline @submit.native.prevent>
<el-form-item label="任务状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="请选择审批状态"
clearable
filterable
style="width: 240px"
>
<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<!-- 日期范围 -->
<el-form-item label="申请日期">
<el-date-picker
v-model="timeRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
unlink-panels
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
style="width: 240px"
/>
</el-form-item>
<!-- 表单按钮 -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card>
<el-row :gutter="10" class="mb8" justify="end">
<el-col :span="4">
<span style="font-size: 20px; font-weight: 800">维修申请列表</span>
</el-col>
<el-col :span="24" style="display: flex; justify-content: flex-end">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建申请</el-button>
</el-col>
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" /> -->
</el-row>
<el-table
v-loading="isLoading"
:data="tableList"
highlight-current-row
border
stripe
:max-height="650"
style="width: 100%"
>
<el-table-column
type="index"
width="55"
label="序号"
align="center"
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<el-table-column
v-for="(column, index) in tableColumns"
show-overflow-tooltip
:key="index"
:label="column.label"
:prop="column.prop"
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 label="操作" align="center">
<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 v-if="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
>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-card>
</div>
</template>
<script>
import { getToolApplyListApi, deleteToolApplyApi } from '@/api/toolsManage'
import {deleteRepairList, getRepairList} from "@/api/equipmentRepair";
export default {
name: 'ApplicantList',
data() {
return {
isLoading: false,
showSearch: true,
timeRange: [],
queryParams: {
pageNum: 1,
pageSize: 10,
status: null,
createBy: null,
startTime: null,
endTime: null,
},
statusList: [
{ label: '审批中', value: '0' },
{ label: '已通过', value: '1' },
{ label: '已驳回', value: '2' },
],
total: 0, //
//
tableColumns: [
{ label: '维修单号', prop: 'code' },
{ label: '维修装备数', prop: 'equipmentNum' },
{ label: '维修工具数', prop: 'toolNum' },
{ label: '任务状态', prop: 'status' },
{ label: '申请人', prop: 'createUser' },
{ label: '申请时间', prop: 'createTime' },
],
//
tableList: [],
}
},
created() {
this.getList()
},
methods: {
//
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
//
handleReset() {
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.timeRange = []
this.$refs.queryForm.resetFields()
this.getList()
},
//
async getList() {
console.log('列表-查询', this.queryParams)
this.isLoading = true
this.queryParams.startTime = this.timeRange && this.timeRange[0] ? this.timeRange[0] : null
this.queryParams.endTime = this.timeRange && this.timeRange[1] ? this.timeRange[1] : null
try {
const params = { ...this.queryParams }
const res = await getRepairList(params)
this.tableList = res.data.rows || []
this.total = res.data.total || 0
} catch (error) {
this.tableList = []
this.total = 0
} finally {
this.isLoading = false
}
},
//
handleAdd() {
this.$router.push({ path: './addRepair' })
},
//
handleView(row) {
this.$router.push({ path: './repairView', query: { applyId: row.id, isView: true } })
},
//
handleEdit(row) {
this.$router.push({ path: '/toolsManage/addTools', query: { applyId: row.id, isEdit: true } })
},
//
handleDelete(row) {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
this.isLoading = true
try {
await deleteRepairList({ id: row.id })
//
this.$message({
type: 'success',
message: '删除成功!',
})
this.getList()
} catch (error) {
console.log('🚀 ~ error:', error)
} finally {
this.isLoading = false
}
})
},
},
}
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,166 @@
<template>
<div class="app-container">
<!-- 列表 -->
<el-card>
<el-row class="mb8" :gutter="10" justify="end">
<el-col :span="4">
<span style="font-size: 20px; font-weight: 800">申请列表</span>
</el-col>
</el-row>
<el-table
v-loading="isLoading"
:data="tableList"
highlight-current-row
border
stripe
:max-height="650"
style="width: 100%"
>
<!-- 序号列 -->
<el-table-column
type="index"
width="55"
label="序号"
align="center"
/>
<!-- 动态列 -->
<el-table-column
v-for="(column, index) in tableColumns"
:key="index"
:label="column.label"
:prop="column.prop"
:width="column.width"
:min-width="column.minWidth"
align="center"
show-overflow-tooltip
>
<template slot-scope="scope">
<span v-if="!column.render">{{ scope.row[column.prop] }}</span>
<component
v-else
:is="{ render: (h) => column.render(h, { row: scope.row }) }"
/>
</template>
</el-table-column>
<!-- 附件列 -->
<el-table-column label="附件" align="center" width="90">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="picturePreview(scope.row)"
v-if="scope.row.url"
>
查看
</el-button>
<span v-else></span>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 图片查看弹窗 -->
<el-dialog :visible.sync="dialogVisible" width="500px" height="500px">
<img width="100%" height="500px" :src="dialogImageUrl" />
</el-dialog>
</div>
</template>
<script>
import { getRepairDetailsList } from "@/api/equipmentRepair";
export default {
name: 'ViewRepairListNoPagination',
data() {
return {
routerParams: {},
isLoading: false,
queryParams: {
parentTypeName: null,
typeName: null,
manageType: null,
applyId: null,
id: null
},
dialogImageUrl: '',
dialogVisible: false,
tableList: [],
tableColumns: [
{ label: '分类', prop: 'type', width: 75 },
{ label: '类目', prop: 'groupName' },
{ label: '名称', prop: 'typeName' },
{ label: '规格型号', prop: 'typeModelName' },
{
label: '管理模式',
prop: 'manageType',
width: '80',
render: (h, { row }) => h('span', {}, row.manageType === '0' ? '数量管理' : '编码管理')
},
{ label: '设备编码', prop: 'code' },
{ label: '维修数量', prop: 'repairNum', width: 80 },
{
label: '维修是否合格',
prop: 'isScrap',
width: '120',
render: (h, { row }) => h('span', {}, row.isScrap === '0' ? '是' : '否')
},
{
label: '维修日期',
prop: 'repairTime',
width: '150',
render: (h, { row }) => h('span', {}, row.repairTime || '-')
},
{
label: '退役原因',
prop: 'reasonVal',
width: '120',
render: (h, { row }) => h('span', {}, row.reasonVal || '-')
},
]
}
},
created() {
this.routerParams = this.$route.query
const title = this.routerParams.isView ? '维修查看' : '列表查看'
this.queryParams.id = this.routerParams.applyId || ''
this.$tab.updatePage(Object.assign({}, this.$route, { title }))
this.getList()
},
methods: {
async getList() {
this.isLoading = true
try {
const res = await getRepairDetailsList({ ...this.queryParams })
this.tableList = res.data || []
} finally {
this.isLoading = false
}
},
//
picturePreview(row) {
if (row.url) {
this.dialogImageUrl = row.url.replaceAll('#', '%23')
// URL
const urlParts = row.url.split('/');
const fileNameWithParams = urlParts[urlParts.length - 1];
// URL
const fileName = fileNameWithParams.split('?')[0];
const parts = fileName.split('.')
const extension = parts.pop().toLowerCase()
if (['doc', 'docx', 'pdf'].includes(extension)) {
window.open(row.url, fileName)
} else {
this.dialogVisible = true
}
} else {
this.$message.warning('该行没有附件')
}
},
}
}
</script>

View File

@ -0,0 +1,200 @@
<template>
<!-- 基础页面 -->
<div class="app-container">
<el-card v-show="showSearch" style="margin-bottom: 20px">
<el-form :model="queryParams" ref="queryForm" size="small" inline @submit.native.prevent>
<el-form-item label="任务状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="请选择审批状态"
clearable
filterable
style="width: 240px"
>
<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<!-- 日期范围 -->
<el-form-item label="申请日期">
<el-date-picker
v-model="timeRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
clearable
unlink-panels
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
style="width: 240px"
/>
</el-form-item>
<!-- 表单按钮 -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card>
<el-row :gutter="10" class="mb8" justify="end">
<el-col :span="4">
<span style="font-size: 20px; font-weight: 800">维修审核列表</span>
</el-col>
</el-row>
<el-table
v-loading="isLoading"
:data="tableList"
highlight-current-row
border
stripe
:max-height="650"
style="width: 100%"
>
<el-table-column
type="index"
width="55"
label="序号"
align="center"
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
/>
<el-table-column
v-for="(column, index) in tableColumns"
show-overflow-tooltip
:key="index"
:label="column.label"
:prop="column.prop"
align="center"
>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="{ row }">
<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>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-card>
</div>
</template>
<script>
import { getToolApplyListApi, deleteToolApplyApi } from '@/api/toolsManage'
import {deleteRepairList, getRepairList} from "@/api/equipmentRepair";
export default {
name: 'ApplicantList',
data() {
return {
isLoading: false,
showSearch: true,
timeRange: [],
queryParams: {
pageNum: 1,
pageSize: 10,
status: null,
createBy: null,
startTime: null,
endTime: null,
},
statusList: [
{ label: '审批中', value: '0' },
{ label: '已通过', value: '1' },
{ label: '已驳回', value: '2' },
],
total: 0, //
//
tableColumns: [
{ label: '维修单号', prop: 'code' },
{ label: '维修装备数', prop: 'equipmentNum' },
{ label: '维修工具数', prop: 'toolNum' },
{ label: '任务状态', prop: 'status' },
{ label: '申请人', prop: 'createUser' },
{ label: '申请时间', prop: 'createTime' },
],
//
tableList: [],
}
},
created() {
this.getList()
},
methods: {
//
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
//
handleReset() {
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.timeRange = []
this.$refs.queryForm.resetFields()
this.getList()
},
//
async getList() {
console.log('列表-查询', this.queryParams)
this.isLoading = true
this.queryParams.startTime = this.timeRange && this.timeRange[0] ? this.timeRange[0] : null
this.queryParams.endTime = this.timeRange && this.timeRange[1] ? this.timeRange[1] : null
try {
const params = { ...this.queryParams }
const res = await getRepairList(params)
this.tableList = res.data.rows || []
this.total = res.data.total || 0
} catch (error) {
this.tableList = []
this.total = 0
} finally {
this.isLoading = false
}
},
//
handleView(row) {
this.$router.push({ path: './repairView', query: { applyId: row.id, isView: true } })
},
//
handleEdit(row) {
this.$router.push({ path: './repairDetailsAudit', query: { applyId: row.id, isEdit: true } })
},
//
handleDelete(row) {
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
this.isLoading = true
try {
await deleteRepairList({ id: row.id })
//
this.$message({
type: 'success',
message: '删除成功!',
})
this.getList()
} catch (error) {
console.log('🚀 ~ error:', error)
} finally {
this.isLoading = false
}
})
},
},
}
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,197 @@
<template>
<div class="app-container">
<!-- 列表 -->
<el-card>
<el-row class="mb8" :gutter="10" justify="end">
<el-col :span="4">
<span style="font-size: 20px; font-weight: 800">申请列表</span>
</el-col>
<el-col v-if="!routerParams.isView" :span="20" style="display: flex; justify-content: flex-end">
<el-button type="primary" @click="handleApprove">通过</el-button>
<el-button type="danger" @click="handleReject">驳回</el-button>
</el-col>
</el-row>
<el-table
v-loading="isLoading"
:data="tableList"
highlight-current-row
border
stripe
:max-height="650"
style="width: 100%"
@selection-change="handleSelectionChange"
>
<!-- 复选框列 -->
<el-table-column
type="selection"
width="55"
align="center"
/>
<!-- 序号列 -->
<el-table-column
type="index"
width="55"
label="序号"
align="center"
/>
<!-- 动态列 -->
<el-table-column
v-for="(column, index) in tableColumns"
:key="index"
:label="column.label"
:prop="column.prop"
:width="column.width"
:min-width="column.minWidth"
align="center"
show-overflow-tooltip
>
<template slot-scope="scope">
<span v-if="!column.render">{{ scope.row[column.prop] }}</span>
<component
v-else
:is="{ render: (h) => column.render(h, { row: scope.row }) }"
/>
</template>
</el-table-column>
<!-- 附件列 -->
<el-table-column label="附件" align="center" width="90">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="picturePreview(scope.row)"
v-if="scope.row.url"
>
查看
</el-button>
<span v-else></span>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 图片查看弹窗 -->
<el-dialog :visible.sync="dialogVisible" width="500px" height="500px">
<img width="100%" height="500px" :src="dialogImageUrl" />
</el-dialog>
</div>
</template>
<script>
import { getRepairDetailsList } from "@/api/equipmentRepair";
export default {
name: 'ViewRepairListNoPagination',
data() {
return {
routerParams: {},
isLoading: false,
queryParams: {
parentTypeName: null,
typeName: null,
manageType: null,
applyId: null,
id: null
},
dialogImageUrl: '',
dialogVisible: false,
tableList: [],
selectedRows: [], //
tableColumns: [
{ label: '分类', prop: 'type', width: 75 },
{ label: '类目', prop: 'groupName' },
{ label: '名称', prop: 'typeName' },
{ label: '规格型号', prop: 'typeModelName' },
{
label: '管理模式',
prop: 'manageType',
width: '80',
render: (h, { row }) => h('span', {}, row.manageType === '0' ? '数量管理' : '编码管理')
},
{ label: '设备编码', prop: 'code' },
{ label: '维修数量', prop: 'repairNum', width: 80 },
{
label: '维修是否合格',
prop: 'isScrap',
width: '120',
render: (h, { row }) => h('span', {}, row.isScrap === '0' ? '是' : '否')
},
{
label: '维修日期',
prop: 'repairTime',
width: '150',
render: (h, { row }) => h('span', {}, row.repairTime || '-')
},
{
label: '退役原因',
prop: 'reasonVal',
width: '120',
render: (h, { row }) => h('span', {}, row.reasonVal || '-')
},
]
}
},
created() {
this.routerParams = this.$route.query
const title = this.routerParams.isView ? '维修查看' : '列表查看'
this.queryParams.id = this.routerParams.applyId || ''
this.$tab.updatePage(Object.assign({}, this.$route, { title }))
this.getList()
},
methods: {
async getList() {
this.isLoading = true
try {
const res = await getRepairDetailsList({ ...this.queryParams })
this.tableList = res.data || []
} finally {
this.isLoading = false
}
},
handleSelectionChange(val) {
this.selectedRows = val
},
handleApprove() {
if (this.selectedRows.length === 0) {
this.$message.warning('请至少选择一条数据')
return
}
// TODO:
console.log('通过的行:', this.selectedRows)
this.$message.success('已通过选中数据')
},
handleReject() {
if (this.selectedRows.length === 0) {
this.$message.warning('请至少选择一条数据')
return
}
// TODO:
console.log('驳回的行:', this.selectedRows)
this.$message.error('已驳回选中数据')
},
//
picturePreview(row) {
if (row.url) {
this.dialogImageUrl = row.url.replaceAll('#', '%23')
const urlParts = row.url.split('/');
const fileNameWithParams = urlParts[urlParts.length - 1];
const fileName = fileNameWithParams.split('?')[0];
const parts = fileName.split('.')
const extension = parts.pop().toLowerCase()
if (['doc', 'docx', 'pdf'].includes(extension)) {
window.open(row.url, fileName)
} else {
this.dialogVisible = true
}
} else {
this.$message.warning('该行没有附件')
}
},
}
}
</script>