This commit is contained in:
parent
f5e05ff0f8
commit
2ec044e166
|
|
@ -1,5 +1,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-dialog
|
||||
v-if="visible"
|
||||
title="添加装备/工具"
|
||||
:visible.sync="visible"
|
||||
width="1400px"
|
||||
|
|
@ -139,9 +141,11 @@
|
|||
<!-- 操作按钮 -->
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onHandleConfirm">确定</el-button>
|
||||
<el-button type="primary" @click="openConfirm">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<ConfirmationDialog ref="confirmationDlg" @confirm="onHandleConfirm" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
@ -149,6 +153,7 @@ import { getScrapItemListAPI } from '@/api/EquipmentRetireApply/index.js'
|
|||
// 导入分类树接口(与之前项目保持一致)
|
||||
import { getEquipmentTreeAPI } from '@/api/EquipmentConfig/index.js'
|
||||
import { getTreeSelectApi } from '@/api/toolsManage/index.js'
|
||||
import ConfirmationDialog from '@/views/business/components/ConfirmationDialog'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
|
@ -157,6 +162,7 @@ export default {
|
|||
default: () => []
|
||||
}
|
||||
},
|
||||
components: { ConfirmationDialog },
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
|
|
@ -278,7 +284,7 @@ export default {
|
|||
this.getItemList()
|
||||
},
|
||||
selectable(row) {
|
||||
return !this.existingItems.some(item => item.devId === row.id)
|
||||
return !this.existingItems.some(item => item.id === row.id)
|
||||
},
|
||||
onSelectionChange(selection) {
|
||||
this.selectedItems = selection
|
||||
|
|
@ -289,21 +295,23 @@ export default {
|
|||
// 添加当前页的选中项
|
||||
this.allSelectedItems.push(...selection)
|
||||
},
|
||||
|
||||
onHandleConfirm() {
|
||||
openConfirm() {
|
||||
if (this.selectedItems.length === 0) {
|
||||
this.$message.warning('请选择至少一项')
|
||||
return
|
||||
}
|
||||
|
||||
// 检查申请报废数量是否有效
|
||||
// const invalidItems = this.allSelectedItems.filter(item => !item.scrapQuantity || item.scrapQuantity < 1)
|
||||
const invalidItems = this.selectedItems.filter(item => !item.scrapQuantity || item.scrapQuantity < 1)
|
||||
if (invalidItems.length > 0) {
|
||||
const invalidNames = invalidItems.map(item => item.typeModelName).join('、')
|
||||
this.$message.warning(`以下项目的申请报废数量必须大于0:${invalidNames}`)
|
||||
return
|
||||
}
|
||||
this.$refs.confirmationDlg.openDialog(this.selectedItems)
|
||||
},
|
||||
onHandleConfirm() {
|
||||
|
||||
// 检查申请报废数量是否有效
|
||||
// const invalidItems = this.allSelectedItems.filter(item => !item.scrapQuantity || item.scrapQuantity < 1)
|
||||
|
||||
// 检查是否有重复的keyId
|
||||
// const existingKeyIds = this.existingItems.map(item => item.keyId)
|
||||
|
|
|
|||
|
|
@ -235,8 +235,8 @@ export default {
|
|||
bmFileInfos: item.bmFileInfos || []
|
||||
}))
|
||||
// 去重后添加
|
||||
const existingTypeIds = new Set(this.detailList.map(item => item.devId))
|
||||
const newItems = itemsWithFileInfo.filter(item => !existingTypeIds.has(item.devId))
|
||||
const existingTypeIds = new Set(this.detailList.map(item => item.id))
|
||||
const newItems = itemsWithFileInfo.filter(item => !existingTypeIds.has(item.id))
|
||||
this.detailList.push(...newItems)
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@
|
|||
<el-col style="display: flex; justify-content: flex-end">
|
||||
<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-button type="primary" size="mini" @click="saveAdd">确定添加</el-button>
|
||||
<el-button type="primary" size="mini" @click="confirmAdd">确定添加</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
|
|
@ -316,6 +316,8 @@
|
|||
@pagination="getApplyList"
|
||||
/>
|
||||
</el-dialog>
|
||||
|
||||
<ConfirmationDialog ref="confirmationDlg" @confirm="saveAdd" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
|
@ -329,9 +331,11 @@ import {
|
|||
import { regionData } from 'element-china-area-data'
|
||||
import { getEquipmentTreeAPI } from '@/api/EquipmentConfig/index.js'
|
||||
import { getTreeSelectApi } from '@/api/toolsManage/index.js' // 替换为实际工具接口路径
|
||||
import ConfirmationDialog from '@/views/business/components/ConfirmationDialog'
|
||||
|
||||
export default {
|
||||
name: 'AddEditApply',
|
||||
components: { ConfirmationDialog },
|
||||
data() {
|
||||
return {
|
||||
useTimeRange: [], // 主表单的全局日期范围
|
||||
|
|
@ -864,8 +868,7 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
// 确认添加(将勾选的数据添加到主表格)
|
||||
saveAdd() {
|
||||
async confirmAdd() {
|
||||
if (!this.ids.length) {
|
||||
this.$message.error('请勾选要添加的数据')
|
||||
return
|
||||
|
|
@ -876,7 +879,10 @@ export default {
|
|||
this.$message.error('请为数量管理的设备填写申请数量。')
|
||||
return
|
||||
}
|
||||
|
||||
this.$refs.confirmationDlg.openDialog(this.selectedRow)
|
||||
},
|
||||
// 确认添加(将勾选的数据添加到主表格)
|
||||
async saveAdd() {
|
||||
// 关键修改:读取主表单的日期范围,深拷贝避免引用联动
|
||||
const mainTimeRange = this.queryParams.useTimeRange
|
||||
const defaultTimeRange = mainTimeRange && mainTimeRange.length === 2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
title="确定添加"
|
||||
:visible.sync="visible"
|
||||
width="600px"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div v-loading="loading">
|
||||
<!-- 列表 -->
|
||||
<div style="margin-bottom: 20px">
|
||||
<div style="font-weight: bold; margin-bottom: 10px">已添加(共 {{ selectedRows.length }} 项)</div>
|
||||
<el-table :data="selectedRows" style="width: 100%" max-height="270">
|
||||
<el-table-column prop="typeName" align="center" label="装备名称" show-overflow-tooltip/>
|
||||
<el-table-column prop="num" align="center" label="数量" show-overflow-tooltip>
|
||||
<template slot-scope="{ row }">
|
||||
<span v-if="row.num">{{ row.num }}</span>
|
||||
<span v-else-if="row.repairNum">{{ row.repairNum }}</span>
|
||||
<span v-else-if="row.scrapQuantity">{{ row.scrapQuantity }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="confirm" :loading="loading">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'ConfirmationDialog',
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
loading: false,
|
||||
selectedRows: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openDialog(selectedRows) {
|
||||
console.log('🚀 ~ selectedRows:', selectedRows)
|
||||
this.selectedRows = selectedRows
|
||||
this.visible = true
|
||||
},
|
||||
|
||||
async confirm() {
|
||||
this.visible = false
|
||||
// // 返回正确的promise
|
||||
// return new Promise((resolve, reject) => {
|
||||
// resolve()
|
||||
// })
|
||||
this.$emit('confirm')
|
||||
},
|
||||
|
||||
handleClose() {
|
||||
this.visible = false
|
||||
this.selectedRows = []
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-dialog
|
||||
title="添加申请"
|
||||
:visible.sync="visible"
|
||||
|
|
@ -129,18 +130,22 @@
|
|||
<!-- 底部按钮 -->
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleConfirm">确定添加</el-button>
|
||||
<el-button type="primary" @click="openConfirm">确定添加</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<ConfirmationDialog ref="confirmationDlg" @confirm="handleConfirm" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToBeRepairList } from "@/api/equipmentRepair";
|
||||
import { getEquipmentTreeAPI } from '@/api/EquipmentConfig/index.js'
|
||||
import { getTreeSelectApi } from '@/api/toolsManage/index.js'
|
||||
import ConfirmationDialog from '@/views/business/components/ConfirmationDialog'
|
||||
|
||||
export default {
|
||||
name: 'SelectToolDialog',
|
||||
components: { ConfirmationDialog },
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
|
|
@ -181,6 +186,7 @@ export default {
|
|||
|
||||
externalSelectedRows: [],
|
||||
tableList: [],
|
||||
selectedList: [],
|
||||
selectedMap: new Map(),
|
||||
isRestoring: false // 选中状态还原标记
|
||||
}
|
||||
|
|
@ -425,6 +431,7 @@ export default {
|
|||
|
||||
// 表格选择变化事件
|
||||
handleSelectionChange(selection) {
|
||||
this.selectedList = selection
|
||||
if (this.isRestoring) return
|
||||
// 新增选中项
|
||||
selection.forEach(row => {
|
||||
|
|
@ -440,9 +447,7 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 确定添加按钮事件
|
||||
handleConfirm() {
|
||||
openConfirm() {
|
||||
if (this.selectedMap.size === 0) {
|
||||
return this.$message.warning("请至少选择一条数据")
|
||||
}
|
||||
|
|
@ -458,6 +463,10 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.$refs.confirmationDlg.openDialog(this.selectedList)
|
||||
},
|
||||
// 确定添加按钮事件
|
||||
handleConfirm() {
|
||||
// 触发父组件事件(返回包含devType的选中数据)
|
||||
this.$emit("confirm", [...this.selectedMap.values()])
|
||||
this.selectedMap.clear()
|
||||
|
|
|
|||
Loading…
Reference in New Issue