代码提交

This commit is contained in:
jiang 2025-11-25 15:49:27 +08:00
parent 6dc97fbf5e
commit fc978978cf
1 changed files with 70 additions and 355 deletions

View File

@ -77,7 +77,6 @@
<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="handleDialog">添加</el-button>
<el-button type="primary" @click="submit">确定申请</el-button>
</el-col>
</el-row>
@ -88,16 +87,18 @@
highlight-current-row
border
stripe
:max-height="650"
:max-height="570"
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 label="分类" align="center" prop="devType" :show-overflow-tooltip="true">
<el-table-column label="分类" align="center" prop="devType" :show-overflow-tooltip="true" min-width="55px">
<template slot-scope="scope">
<span v-if="scope.row.devType==1">{{ '装备' }}</span>
<span v-if="scope.row.devType==2">{{ '工具' }}</span>
@ -113,8 +114,17 @@
</template>
</el-table-column>
<el-table-column label="设备编码" align="center" prop="devCode" :show-overflow-tooltip="true" width="140px"/>
<el-table-column label="当前自用" align="center" prop="useNum" :show-overflow-tooltip="true"/>
<el-table-column label="退库数量" align="center" prop="num" :show-overflow-tooltip="true"/>
<el-table-column label="当前自用" align="center" prop="useNum" :show-overflow-tooltip="true" min-width="55px"/>
<el-table-column label="退库数量" align="center" prop="num">
<template slot-scope="scope">
<span v-if="scope.row.manageType==0">{{ scope.row.useNum }}</span>
<el-input-number v-if="scope.row.manageType==1" :disabled="routerParams.isView"
v-model="scope.row.num"
:min="0" :max="scope.row.useNum" :default-value="0" style="width: 120px"
@change="applyNumChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="使用到期日期" align="center" prop="useTime" width="160px">
<template slot-scope="scope">
<el-date-picker
@ -128,7 +138,7 @@
</el-date-picker>
</template>
</el-table-column>
<el-table-column label="是否维修" align="center" prop="isRepair" width="160px">
<el-table-column label="是否维修" align="center" prop="isRepair" min-width="55px">
<template slot-scope="scope">
<el-select
:disabled="!routerParams.isEdit"
@ -143,137 +153,17 @@
</el-table-column>
<el-table-column label="维修数量" align="center" prop="realNum" width="160px">
<template slot-scope="scope">
<el-input
:disabled="scope.row.isRepair =='0' || !routerParams.isEdit"
v-if="scope.row.manageType==1"
v-model.number="scope.row.realNum"
:max="scope.row.num"
:min="0"
step="0.01"
/>
<span v-if="scope.row.manageType==0">{{ scope.row.realNum }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" v-if="!routerParams.isView">
<template slot-scope="{ row }">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)" style="color: red"
>删除
</el-button
>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 添加申请 -->
<el-dialog title="添加申请" :visible.sync="openAdd" width="1200px" append-to-body>
<el-form :model="addQuery" ref="addQuery" size="small" :inline="true" label-width="80px">
<el-form-item label="名称" prop="typeName">
<el-input v-model="addQuery.typeName" maxlength="20" placeholder="请输入名称"/>
</el-form-item>
<el-form-item label="规格型号" prop="typeModelName">
<el-input v-model="addQuery.typeModelName" maxlength="20" placeholder="请输入规格型号"/>
</el-form-item>
<el-form-item label="编码" prop="devCode">
<el-input v-model="addQuery.devCode" maxlength="20" placeholder="请输入编码"/>
</el-form-item>
<!-- 新增分类选择下拉框装备/工具 -->
<el-form-item label="分类" prop="devType">
<el-select
v-model="addQuery.devType"
placeholder="请选择分类"
clearable
style="width: 200px"
>
<el-option label="装备" value="1"/>
<el-option label="工具" value="2"/>
</el-select>
</el-form-item>
<!-- &lt;!&ndash; 新增装备分类下拉框 &ndash;&gt;-->
<!-- <el-form-item label="装备分类" prop="categoryPath">-->
<!-- <el-cascader-->
<!-- v-model="addQuery.categoryPath"-->
<!-- :options="processedTreeData"-->
<!-- :props="cascaderProps"-->
<!-- placeholder="请选择装备分类(最多六级)"-->
<!-- clearable-->
<!-- style="width: 200px"-->
<!-- filterable-->
<!-- popper-class="six-level-cascader"-->
<!-- @change="handleCategoryChange"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- &lt;!&ndash; 新增工具分类下拉框 &ndash;&gt;-->
<!-- <el-form-item label="工具分类" prop="toolCategoryPath">-->
<!-- <el-cascader-->
<!-- v-model="addQuery.toolCategoryPath"-->
<!-- :options="toolTreeData"-->
<!-- :props="toolCascaderProps"-->
<!-- placeholder="请选择工具分类"-->
<!-- clearable-->
<!-- style="width: 200px"-->
<!-- filterable-->
<!-- popper-class="six-level-cascader"-->
<!-- @change="handleToolCategoryChange"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item style="margin-left:990px">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleAddQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetAddQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8" justify="end">
<el-col style="display: flex; justify-content: flex-end">
<el-button type="primary" @click="saveAdd">确定添加</el-button>
</el-col>
</el-row>
<el-table ref="addTable" :data="addList" height="500" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" :selectable="selectable"/>
<el-table-column label="序号" align="center" width="80" type="index">
<template slot-scope="scope">
<span>{{
(addQuery.pageNum - 1) * 10 + scope.$index + 1
}}</span>
</template>
</el-table-column>
<el-table-column label="分类" align="center" prop="devType" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.devType==1">{{ '装备' }}</span>
<span v-if="scope.row.devType==2">{{ '工具' }}</span>
</template>
</el-table-column>
<el-table-column label="类目" align="center" prop="category" :show-overflow-tooltip="true"/>
<el-table-column label="名称" align="center" prop="typeName" :show-overflow-tooltip="true"/>
<el-table-column label="规格型号" align="center" prop="typeModelName" :show-overflow-tooltip="true"/>
<el-table-column label="管理模式" align="center" prop="manageType" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.manageType==0">{{ '编码设备' }}</span>
<span v-if="scope.row.manageType==1">{{ '数量设备' }}</span>
</template>
</el-table-column>
<el-table-column label="设备编码" align="center" prop="devCode" :show-overflow-tooltip="true" width="140px"/>
<el-table-column label="自用数量" align="center" prop="useNum" :show-overflow-tooltip="true"/>
<el-table-column label="退库数量" align="center" prop="num">
<template slot-scope="scope">
<span v-if="scope.row.manageType==0">{{ 1 }}</span>
<el-input-number v-if="scope.row.manageType==1" :disabled="isRowSelected(scope.row)" v-model="scope.row.num"
:min="1" :max="scope.row.useNum" :default-value="1" style="width: 120px"
<el-input-number v-if="scope.row.manageType==1"
:disabled="routerParams.isView || scope.row.isRepair =='0'"
v-model="scope.row.realNum"
:min="0" :max="scope.row.num" :default-value="0" style="width: 120px"
@change="applyNumChange(scope.row)"
/>
</template>
</el-table-column>
</el-table>
<pagination
v-show="addTotal > 0"
:total="addTotal"
:page.sync="addQuery.pageNum"
:limit.sync="addQuery.pageSize"
@pagination="getApplyList"
/>
</el-dialog>
</el-card>
</div>
</template>
@ -392,7 +282,7 @@ export default {
this.queryParams.id = this.routerParams.id || ''
this.getUseProjectList()
if (this.queryParams.status == '0') {
this.queryParams.useUnit = sessionStorage.getItem('deptName') || '';
this.queryParams.useUnit = sessionStorage.getItem('deptName') || ''
}
this.provinceList = regionData
const obj = Object.assign({}, this.$route, { title })
@ -418,17 +308,17 @@ export default {
if (node.children && node.children.length > 0) {
node.children = this.filterTree(node.children)
}
node.label = node.deptName;
node.value = node.deptId;
node.label = node.deptName
node.value = node.deptId
return node
})
.filter(node => node.status !== '1')
},
isChange(row) {
if (row.isRepair == '1') {
row.realNum = row.manageType == 0 ? 1 : row.num;
row.realNum = row.manageType == 0 ? 1 : row.num
} else {
row.realNum = 0;
row.realNum = 0
}
},
// 使
@ -461,6 +351,38 @@ export default {
this.queryParams.proCity = city
this.queryParams.proCounty = county
}
//
const queryParams = {
proCode: value
}
getApplyListApi(queryParams)
.then(response => {
if (response && response.data) {
this.tableList = response.data || []
// 退11
this.tableList.forEach(item => {
item.num = item.manageType === 0 ? 1 : 1
// storageNum使applyNumChange
item.storageNum = item.useNum
item.useTime = this.queryParams.useTime ? new Date(this.queryParams.useTime) : null
item.isRepair = '0'
item.realNum = 0
})
} else {
this.addList = []
this.addTotal = 0
this.$message.warning('获取数据格式异常')
}
})
.catch(error => {
this.addList = []
this.addTotal = 0
this.$message.error(`获取设备列表失败:${error.message || '未知错误'}`)
console.error('分页查询失败:', error)
})
.finally(() => {
this.isLoading = false
})
},
//
@ -527,27 +449,6 @@ export default {
//
})
},
//
handleDialog() {
if (!this.queryParams.proCode) {
this.$message({
type: 'error',
message: '请先选择使用项目'
})
return
}
this.addQuery.pageNum = 1
this.resetAddQuery() //
this.openAdd = true
//
this.$nextTick(() => {
if (this.$refs.addTable) {
this.$refs.addTable.clearSelection()
}
})
},
//
processTreeData(data) {
return Array.isArray(data) ? data : data ? [data] : []
@ -617,121 +518,6 @@ export default {
return processedItem
})
},
//
getApplyList(pagination = {}) {
//
const pageNum = pagination.pageNum || this.addQuery.pageNum
const pageSize = pagination.pageSize || this.addQuery.pageSize
//
this.addQuery.pageNum = pageNum
this.addQuery.pageSize = pageSize
//
const queryParams = {
...this.filterParams,
pageNum,
pageSize
}
this.isLoading = true
getApplyListApi(queryParams)
.then(response => {
if (response && response.data) {
this.addList = response.data.rows || []
this.addTotal = response.data.total || 0
// 退11
this.addList.forEach(item => {
item.num = item.manageType === 0 ? 1 : 1;
// storageNum使applyNumChange
item.storageNum = item.useNum;
})
} else {
this.addList = []
this.addTotal = 0
this.$message.warning('获取数据格式异常')
}
})
.catch(error => {
this.addList = []
this.addTotal = 0
this.$message.error(`获取设备列表失败:${error.message || '未知错误'}`)
console.error('分页查询失败:', error)
})
.finally(() => {
this.isLoading = false
})
},
// devTypeID
handleAddQuery() {
this.addQuery.pageNum = 1 //
const queryParams = { ...this.addQuery }
// 1. devType1=2=
let devType = queryParams.devType || ''
// 2.
let categoryEquipment = ''
if (devType === '1' && queryParams.categoryPath && Array.isArray(queryParams.categoryPath) && queryParams.categoryPath.length > 0) {
categoryEquipment = String(queryParams.categoryPath[queryParams.categoryPath.length - 1])
}
// 3.
let toolTypeId = ''
if (devType === '2' && queryParams.toolCategoryPath && Array.isArray(queryParams.toolCategoryPath) && queryParams.toolCategoryPath.length > 0) {
toolTypeId = String(queryParams.toolCategoryPath[queryParams.toolCategoryPath.length - 1])
}
// devType
this.filterParams = {
typeName: queryParams.typeName,
typeModelName: queryParams.typeModelName,
devCode: queryParams.devCode,
categoryEquipment,
toolTypeId,
devType, //
proCode: queryParams.proCode //
}
//
this.getApplyList({
pageNum: this.addQuery.pageNum,
pageSize: this.addQuery.pageSize
})
},
//
resetAddQuery() {
this.addQuery = {
proCode: this.queryParams.proCode || '', //
typeName: '',
typeModelName: '',
devCode: '',
devType: '', //
categoryPath: [], //
toolCategoryPath: [], //
pageNum: 1,
pageSize: 10
}
//
this.filterParams = {
typeName: '',
typeModelName: '',
devCode: '',
categoryEquipment: '',
toolTypeId: '',
devType: '',
proCode: this.queryParams.proCode || ''
}
//
this.getApplyList({ pageNum: 1, pageSize: this.addQuery.pageSize })
},
handleBack() {
this.$router.go(-1)
},
@ -744,52 +530,16 @@ export default {
// devType
handleSelectionChange(selection) {
this.addTempList = []
this.ids = selection.map(item => item.id)
selection.forEach(item => {
this.addTempList.push({
id: item.id,
typeId: item.typeId,
devType: item.devType, // 1=2=
category: item.category,
typeName: item.typeName,
typeModelName: item.typeModelName,
manageType: item.manageType,
devCode: item.devCode,
useNum: item.useNum,
num: item.manageType == 0 ? 1 : item.num,
useTime: this.queryParams.useTime ? new Date(this.queryParams.useTime) : null,
isRepair: '0',
realNum: 0
})
})
this.single = selection.length != 1
this.multiple = !selection.length
this.ids = selection
},
//
selectable(row) {
// 0
if (!row.useNum || row.useNum <= 0) {
return false
}
//
return !this.tableList.some(item => item.id === row.id && item.typeId === row.typeId)
},
//
isRowSelected(row) {
return this.ids.includes(row.id)
},
//
applyNumChange(row) {
if (row.num > row.storageNum) { //
if (row.num > row.useNum) { //
this.$message({
type: 'error',
message: '退库数量不能大于当前自用数量'
})
row.num = row.storageNum
row.num = row.useNum
} else if (row.num < 1) { // 1
this.$message({
type: 'error',
@ -797,48 +547,14 @@ export default {
})
row.num = 1
}
//
if (row.isRepair === '1') {
row.realNum = row.num;
}
},
//
saveAdd() {
if (!this.ids.length) { //
this.$message({
type: 'error',
message: '请勾选数据'
})
return
}
// 1
const invalidItem = this.addTempList.find(item => item.manageType === 1 && (!item.num || item.num < 1));
if (invalidItem) {
this.$message.error('请为数量管理的设备填写有效的退库数量。');
return;
}
this.addTempList.forEach(item => {
this.tableList.push(item)
})
//
this.addTempList = []
this.ids = []
if(this.$refs.addTable) {
this.$refs.addTable.clearSelection();
}
this.openAdd = false
},
//
async submit() {
this.$refs.queryForm.validate(async(valid) => {
if (valid) {
if (this.tableList.length === 0) {
return this.$message.error('请至少添加一项申请设备');
if (this.ids.length === 0) {
return this.$message.error('请至少选择一项申请设备')
}
this.$confirm('是否确定提交申请?', '提示', {
@ -851,7 +567,7 @@ export default {
//
this.queryParams.type = 1
this.queryParams.leaseType = 0
const tempTableList = this.tableList.map(item => ({
const tempTableList = this.ids.map(item => ({
...item,
category: null // category
}))
@ -860,15 +576,14 @@ export default {
devDetailsList: tempTableList // devType
}
let res;
let res
//
if (!this.routerParams.id) {
res = await addApplyApi(params)
} else if (this.routerParams.isEdit && this.routerParams.id) {
} else if (this.routerParams.id) {
//
res = await editApplyApi(params)
}
if (res.code == 200) {
this.$message({
type: 'success',
@ -876,10 +591,10 @@ export default {
})
this.$router.go(-1)
} else {
this.$message.error(res.msg || '操作失败');
this.$message.error(res.msg || '操作失败')
}
} catch (error) {
this.$message.error('提交申请时发生错误');
this.$message.error('提交申请时发生错误')
console.log('🚀 ~ error:', error)
} finally {
this.isLoading = false