This commit is contained in:
jackal 2024-04-18 16:32:16 +08:00
commit 4fdcf91a45
2 changed files with 104 additions and 44 deletions

View File

@ -1,11 +1,12 @@
import request from '@/utils/request'
const maTypeUrl = '/base/type/getMaType' // 物品类型+配件
const addUrl = '/material/maWhole/add' // 添加
const addOrUpdateUrl = '/material/maWhole/addOrUpdate' // 添加
const selectListUrl = '/material/maWhole/selectList' // 查询首页
const selectListByIdUrl = '/material/maWhole/selectListById' // 查询详情
const deleteByIdUrl = '/material/maWhole/deleteById' // 删除
const treeTypeUrl = '/system/select/getDeviceTypeTree' // 设备树
const selectListTreeUrl = '/material/maWhole/selectListTree' // 编辑查询
// 物品类型 选择配件
export function getMaType(query) {
@ -26,9 +27,9 @@ export function getDeviceTypeTree(params = {}){
}
// 新增
export function addMaWhole(data) {
export function addOrUpdateWhole(data) {
return request({
url: addUrl,
url: addOrUpdateUrl,
method: 'post',
data,
})
@ -60,3 +61,12 @@ export function deleteById(data) {
data,
})
}
// 编辑
export function editRequest(data) {
return request({
url: selectListTreeUrl,
method: 'post',
data,
})
}

View File

@ -1,7 +1,7 @@
<template>
<div class="app-container">
<!-- 首页搜索 -->
<el-form :model="formData" ref="formData" size="small" :inline="true" v-show="showSearch">
<el-form :model="formData" ref="formData" size="small" :inline="true" v-show="showSearch" @submit.native.prevent>
<el-form-item label="关键字" prop="keyWord">
<el-input
v-model="formData.keyWord"
@ -26,14 +26,15 @@
</el-row>
<!-- 列表 -->
<el-table :data="houseList" :border="true">
<el-table :data="houseList">
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="typeName" label="机具名称" min-width="280" align="center" />
<el-table-column prop="typeModelName" label="规格型号" min-width="280" align="center" />
<el-table-column prop="totalNum" label="套装所需配件数量" width="200" align="center" />
<el-table-column label="操作" align="center" width="210" fixed="right">
<el-table-column label="操作" align="center" width="310" fixed="right">
<template v-slot="{ row }">
<el-button size="mini" type="primary" icon="el-icon-search" @click="handleDetail(row)">查看明细</el-button>
<el-button type="primary" size="mini" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
@ -49,8 +50,15 @@
<!-- 弹框 -->
<el-dialog :title="title" :visible.sync="open" width="70%" :close-on-click-modal="false">
<!-- 新增 -->
<el-form :model="dialogForm" ref="dialogForm" label-width="100px" :inline="true" size="small">
<!-- 表单 -->
<el-form
:model="dialogForm"
ref="dialogForm"
label-width="100px"
:inline="true"
size="small"
@submit.native.prevent
>
<el-form-item
label="物品类型"
prop="parentId"
@ -64,7 +72,7 @@
filterable
clearable
@change="handleTypeOptions"
style="width: 300px"
style="width: 330px"
v-if="!isDetail"
/>
</el-form-item>
@ -85,7 +93,7 @@
filterable
clearable
@change="handleMountingsOptions"
style="width: 300px"
style="width: 330px"
/>
</el-form-item>
@ -100,7 +108,7 @@
placeholder="请输入关键字"
clearable
maxlength="50"
@keyup.enter.native=""
@keyup.enter.native="handleSearch"
/>
</el-form-item>
<el-form-item v-if="isDetail">
@ -109,7 +117,7 @@
</el-form-item>
</el-form>
<el-table :data="dialogList" border stripe>
<el-table :data="dialogList">
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="typeName" label="类型名称" align="center" />
<el-table-column prop="typeModelName" label="规格型号" align="center" />
@ -146,10 +154,11 @@
<script>
import {
getDeviceTypeTree,
addMaWhole,
addOrUpdateWhole,
searchSelectList,
searchSelectListById,
deleteById,
editRequest,
} from '@/api/store/poleConfig'
export default {
name: 'poleConfig',
@ -173,6 +182,7 @@ export default {
dialogList: [],
selectList: [],
isDetail: false,
isEdit: false,
total: 0,
queryParams: {
pageNum: 1,
@ -184,6 +194,18 @@ export default {
},
created() {
this.getList()
getDeviceTypeTree().then(res => {
// typeOptions
const data = res.data
// this.typeOptions = this.getTree(data)
// this.mountingsOptions = this.getTree(data)
this.typeOptions = this.mountingsOptions = this.getTree(data)
})
// getDeviceTypeTree().then(res => {
// // mountingsOptions
// const data = res.data
// this.mountingsOptions = this.getTree(data)
// })
},
methods: {
//
@ -219,30 +241,22 @@ export default {
handleAdd() {
//
this.open = true
this.title = '新增'
this.isDetail = false
this.isEdit = false
this.dialogForm.parentId = ''
this.dialogForm.mountingsValue = []
this.dialogList = []
this.$nextTick(() => {
setTimeout(() => {
this.$refs.dialogForm.resetFields()
})
getDeviceTypeTree().then(res => {
// typeOptions
const data = res.data
// this.typeOptions = this.getTree(data)
// this.mountingsOptions = this.getTree(data)
this.typeOptions = this.mountingsOptions = this.getTree(data)
})
// getDeviceTypeTree().then(res => {
// // mountingsOptions
// const data = res.data
// this.mountingsOptions = this.getTree(data)
// })
}, 100)
},
//
handleDetail(row) {
this.rowId = row.id
this.open = true
this.isDetail = true
this.title = '抱杆配套明细'
this.title = '详情'
this.dialogForm.keyWord = ''
this.getDetail({ id: row.id })
},
@ -251,6 +265,29 @@ export default {
const res = await searchSelectListById({ id, keyWord })
this.dialogList = res.rows
},
//
handleEdit(row) {
this.rowId = row.id
this.open = true
this.isDetail = false
this.isEdit = true
this.title = '编辑'
this.dialogList = []
this.$nextTick(() => {
this.$refs.dialogForm.resetFields()
})
console.log('🚀 ~ handleEdit ~ row.id:', row.id)
this.queryEdit(row.id)
},
async queryEdit(id) {
const { data } = await editRequest({ id })
this.dialogForm.parentId = data.typeList.fourId
this.dialogForm.mountingsValue = data.list.map(item => {
return [item.firstId, item.secondId, item.threeId, item.fourId]
})
this.dialogList = this.selectList = data.voList
},
//
handleDelete(row) {
//
@ -263,8 +300,8 @@ export default {
//
deleteById({ id: row.id }).then(() => {
this.getList()
this.$message.success('删除成功')
})
this.$message.success('删除成功')
})
.catch(() => {
this.$message.info('取消删除')
@ -276,19 +313,24 @@ export default {
},
//
handleMountingsOptions(val) {
console.log('🚀 ~ handleMountingsOptions ~ val:', val)
this.dialogList = []
this.dialogForm.mountingsValue = val
const selected = this.$refs.mountingsTree.getCheckedNodes()
// level = 2
const filterSel = selected.filter(item => item.level === 4)
this.selectList = filterSel.map(item => {
return {
typeId: item.value,
typeName: item.pathLabels[2],
typeModelName: item.label,
totalNum: 1,
}
})
let selected = []
setTimeout(() => {
selected = this.$refs.mountingsTree.getCheckedNodes()
// level = 4 4
const filterSel = selected.filter(item => item.level === 4)
this.selectList = filterSel.map(item => {
return {
id: item.value,
typeName: item.pathLabels[2],
typeModelName: item.label,
totalNum: 1,
}
})
}, 100)
},
//
addDialogList() {
@ -298,15 +340,14 @@ export default {
this.dialogList = this.selectList
} else {
//
this.$message.warning('请填写完整信息') // w
this.$message.warning('请填写完整信息')
return false
}
})
},
//
handleDeleteDialog(row) {
// row.parentId
this.dialogList = this.dialogList.filter(item => item.typeId !== row.typeId)
this.dialogList = this.dialogList.filter(item => item.id !== row.id)
},
getTree(data) {
return data.map(item => {
@ -330,11 +371,20 @@ export default {
this.$refs.dialogForm.validate(valid => {
if (valid) {
this.isLoading = true
if (!this.dialogList.length) {
this.isLoading = false
this.$message.warning('请点击添加按钮添加数据')
return false
}
const MaWholeSetDto = {
parentId: this.dialogForm.parentId,
wholeList: this.dialogList,
}
addMaWhole(MaWholeSetDto)
if (this.isEdit) {
MaWholeSetDto.id = this.rowId
}
addOrUpdateWhole(MaWholeSetDto)
.then(() => {
this.isLoading = false
this.open = false