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

View File

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