机具类型管理增加树节点增删改查操作,选择高亮,新购增加线下采购单编号字段等需求完善

This commit is contained in:
BianLzhaoMin 2024-09-23 16:37:34 +08:00
parent 107134bb82
commit d25638b07b
6 changed files with 351 additions and 47 deletions

View File

@ -614,4 +614,11 @@ export default {
width: 60px !important; width: 60px !important;
margin-bottom: 10px; margin-bottom: 10px;
} }
::v-deep
.el-tree--highlight-current
.el-tree-node.is-current
> .el-tree-node__content {
background-color: #8decf1;
}
</style> </style>

View File

@ -625,4 +625,10 @@ export default {
width: 60px !important; width: 60px !important;
margin-bottom: 10px; margin-bottom: 10px;
} }
::v-deep
.el-tree--highlight-current
.el-tree-node.is-current
> .el-tree-node__content {
background-color: #8decf1;
}
</style> </style>

View File

@ -3,7 +3,7 @@
<div class="app-container" id="toolsType"> <div class="app-container" id="toolsType">
<el-row :gutter="20"> <el-row :gutter="20">
<!--树数据--> <!--树数据-->
<el-col :span="4" :xs="24"> <el-col :span="5" :xs="24">
<div class="head-container"> <div class="head-container">
<el-input <el-input
v-model="typeName" v-model="typeName"
@ -27,11 +27,58 @@
default-expand-all default-expand-all
highlight-current highlight-current
@node-click="handleNodeClick" @node-click="handleNodeClick"
/> >
<span
class="custom-tree-node"
slot-scope="{ node, data }"
@mousemove="onMousemove(data)"
@mouseleave="onMouseleave()"
>
<span
v-if="
isMousemoveId === data.id &&
node.label.length > 5
"
>{{ node.label.slice(0, 3) + '...' }}</span
>
<span v-else>{{ node.label }}</span>
<span
class="btn-items"
v-if="isMousemoveId === data.id"
>
<el-button
type="text"
size="mini"
icon="el-icon-plus"
@click.stop="() => appendTreeNode(data)"
>
</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-edit-outline"
style="color: #67c23a"
v-if="data.id !== 0"
@click.stop="() => editTreeNode(data)"
>
</el-button>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
style="color: #f56c6c"
v-if="data.id !== 0"
@click.stop="() => removeTreeNode(data)"
>
</el-button>
</span>
</span>
</el-tree>
</div> </div>
</el-col> </el-col>
<!--用户数据--> <!--用户数据-->
<el-col :span="20" :xs="24"> <el-col :span="19" :xs="24">
<el-form <el-form
:model="queryParams" :model="queryParams"
ref="queryForm" ref="queryForm"
@ -68,7 +115,7 @@
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <!-- <el-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
plain plain
@ -78,7 +125,7 @@
v-hasPermi="['machinery:type:add']" v-hasPermi="['machinery:type:add']"
>新增</el-button >新增</el-button
> >
</el-col> </el-col> -->
<!-- <el-col :span="1.5"> <!-- <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
@ -265,13 +312,13 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- <pagination <pagination
v-show="total>0" v-show="total > 0"
:total="total" :total="total"
:page.sync="queryParams.pageNum" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/>--> />
</el-col> </el-col>
</el-row> </el-row>
@ -292,7 +339,7 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="所属上级" prop="parentId"> <el-form-item label="所属上级" prop="parentId">
<treeselect <!-- <treeselect
v-model="form.parentId" v-model="form.parentId"
:options="treeOptions" :options="treeOptions"
:show-count="true" :show-count="true"
@ -301,7 +348,9 @@
noResultsText="没有搜索结果" noResultsText="没有搜索结果"
placeholder="请选择所属上级分类" placeholder="请选择所属上级分类"
@select="treeChange" @select="treeChange"
/> /> -->
<el-input v-model="form.label" disabled />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -581,6 +630,53 @@
<el-button @click="cancelConfig"> </el-button> <el-button @click="cancelConfig"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 新增弹框 -->
<el-dialog
:title="addTitle"
:visible.sync="addTitleVisible"
width="50%"
append-to-body
:close-on-click-modal="false"
>
<el-form
label-width="80px"
:model="addFormParams"
:rules="addFormParamsRules"
ref="addFormParamsRef"
>
<el-row :gutter="24">
<el-col :span="12" v-if="addTitle === '新增'">
<el-form-item label="所属上级">
<el-input
style="width: 100%"
disabled
v-model="addFormParams.label"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="名称" prop="typeName">
<el-input
style="width: 100%"
v-model="addFormParams.typeName"
/>
</el-form-item>
</el-col>
</el-row>
<el-row style="text-align: right">
<el-form-item>
<el-button size="small" type="primary" @click="onSubmit"
> </el-button
>
<el-button size="small" @click="onCancel"
> </el-button
>
</el-form-item>
</el-row>
</el-form>
</el-dialog>
</div> </div>
</template> </template>
@ -664,9 +760,10 @@ export default {
// //
queryParams: { queryParams: {
// pageNum: 1, pageNum: 1,
// pageSize: 10, pageSize: 10,
typeName: undefined, typeName: undefined,
level: 0,
// phonenumber: undefined, // phonenumber: undefined,
// status: undefined, // status: undefined,
// typeId: undefined // typeId: undefined
@ -763,6 +860,26 @@ export default {
// {required: true, message: "", trigger: "blur"} // {required: true, message: "", trigger: "blur"}
// ], // ],
}, },
/* 新增弹框等数据源定义 */
addTitleVisible: false,
addTitle: '', //
addFormParams: {
label: '',
typeName: '',
companyId: 101,
},
addFormParamsRules: {
typeName: [
{
required: true,
message: '名称不能为空',
trigger: 'blur',
},
],
},
isMousemoveId: null,
} }
}, },
watch: { watch: {
@ -799,7 +916,14 @@ export default {
/** 查询新增页面-上级类型下拉树结构 */ /** 查询新增页面-上级类型下拉树结构 */
getTreeData() { getTreeData() {
getMaTypeList().then((response) => { getMaTypeList().then((response) => {
this.treeOptions = response.data this.treeOptions = [
{
label: '机具类型',
id: 0,
children: response.data,
level: 0,
},
]
}) })
}, },
/** 查询资产属性下拉 */ /** 查询资产属性下拉 */
@ -812,8 +936,8 @@ export default {
getList() { getList() {
this.loading = true this.loading = true
getListByMaType(this.queryParams).then((response) => { getListByMaType(this.queryParams).then((response) => {
this.typeList = response.data this.typeList = response.data.rows
// this.total = response.total; this.total = response.data.total
this.loading = false this.loading = false
}) })
}, },
@ -825,6 +949,7 @@ export default {
// - // -
handleNodeClick(data) { handleNodeClick(data) {
this.queryParams.typeId = data.id this.queryParams.typeId = data.id
this.queryParams.level = data.level
this.handleQuery() this.handleQuery()
}, },
// //
@ -839,6 +964,7 @@ export default {
photoName: '', photoName: '',
documentUrl: '', documentUrl: '',
documentName: '', documentName: '',
parentId: '',
} }
this.imageUrl = '' this.imageUrl = ''
this.fileList = [] this.fileList = []
@ -855,6 +981,9 @@ export default {
this.dateRange = [] this.dateRange = []
this.resetForm('queryForm') this.resetForm('queryForm')
this.queryParams.typeId = undefined this.queryParams.typeId = undefined
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.queryParams.level = 0
this.$refs.tree.setCurrentKey(null) this.$refs.tree.setCurrentKey(null)
this.handleQuery() this.handleQuery()
}, },
@ -893,6 +1022,11 @@ export default {
} }
this.imageUrl = this.form.photoUrl this.imageUrl = this.form.photoUrl
console.log(row, '---')
this.getParentName(this.treeOptions, row.parentId)
// console.log(this.form, '--')
this.open = true this.open = true
this.title = '修改' this.title = '修改'
}) })
@ -930,8 +1064,9 @@ export default {
return delMaType(typeIds) return delMaType(typeIds)
}) })
.then(() => { .then(() => {
this.getList()
this.$modal.msgSuccess('删除成功') this.$modal.msgSuccess('删除成功')
this.getList()
this.getTreeData()
}) })
.catch(() => {}) .catch(() => {})
}, },
@ -1050,6 +1185,102 @@ export default {
this.form.companyId = val.companyId this.form.companyId = val.companyId
}, },
/* 树节点增加 */
appendTreeNode(data) {
if (data.level === 3) {
this.reset()
Object.assign(this.form, data)
this.form.parentId = data.id
this.open = true
this.title = '新增'
} else {
Object.assign(this.addFormParams, data)
this.addFormParams.typeName = ''
this.addTitle = '新增'
this.addTitleVisible = true
}
},
/* 树节点删除 */
removeTreeNode(data) {
// this.$message.success('--')
console.log(data, '删除时的数据源--')
this.$modal
.confirm('是否确认删除数据项?')
.then(function () {
return delMaType(data.id)
})
.then(() => {
this.$modal.msgSuccess('删除成功')
this.getTreeData()
})
.catch(() => {})
},
/* 树节点修改 */
editTreeNode(data) {
console.log(data, '修改')
Object.assign(this.addFormParams, data)
this.addTitle = '修改'
this.addFormParams.typeName = data.label
this.addTitleVisible = true
},
/* 确定 */
onSubmit() {
const { id, typeName } = this.addFormParams
const addParams = {
parentId: id,
typeName,
}
const editParams = {
typeId: id,
typeName,
}
this.$refs['addFormParamsRef'].validate(async (valid) => {
if (valid) {
if (this.addTitle === '新增') {
const res = await addMaType(addParams)
if (res.code === 200) {
this.$message.success('新增成功!')
this.addTitleVisible = false
this.getTreeData()
}
} else {
const res = await updateMaType(editParams)
if (res.code === 200) {
this.$message.success('修改成功!')
this.addTitleVisible = false
this.getTreeData()
}
}
}
})
},
/* 取消 */
onCancel() {
this.addTitleVisible = false
},
getParentName(list, id) {
try {
list.forEach((e) => {
if (e.id == id) {
this.form.label = e.label
throw new Error()
} else {
if (e.children && e.children.length > 0) {
this.getParentName(e.children, id)
}
}
})
} catch (error) {}
},
onMousemove(data) {
this.isMousemoveId = data.id
},
onMouseleave() {
this.isMousemoveId = null
},
}, },
} }
</script> </script>
@ -1058,4 +1289,43 @@ export default {
width: 60px !important; width: 60px !important;
margin-bottom: 10px; margin-bottom: 10px;
} }
::v-deep .btn-items .el-button + .el-button {
margin-left: 6px;
}
.btn-items {
margin-left: 4px;
.el-button--text {
font-size: 16px;
}
}
::v-deep .el-tree .el-tree-node__expand-icon.expanded {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
::v-deep .el-tree .el-icon-caret-right:before {
content: '\e783';
font-size: 16px;
}
::v-deep
.el-tree
.el-tree-node__expand-icon.expanded.el-icon-caret-right:before {
content: '\e781';
font-size: 16px;
color: #1890ff;
}
::v-deep .el-tree-node__content > .el-tree-node__expand-icon {
color: #1890ff !important;
}
::v-deep .el-tree-node__expand-icon.is-leaf {
color: transparent !important;
}
::v-deep
.el-tree--highlight-current
.el-tree-node.is-current
> .el-tree-node__content {
background-color: #8decf1;
}
</style> </style>

View File

@ -1,29 +1,14 @@
<template> <template>
<!-- 新增工机具 --> <!-- 新增工机具 -->
<div> <div>
<el-form <!-- <el-form -->
:model="queryParams" <!-- :model="queryParams" -->
ref="queryForm" <!-- ref="queryForm" -->
size="small" <!-- size="small" -->
:inline="true" <!-- :inline="true" -->
label-width="100px" <!-- label-width="100px" -->
> <!-- > -->
<el-form-item label="规格型号" prop="equipmentId"> <!-- <el-form-item label="出厂日期">
<treeselect
v-model="queryParams.equipmentId"
default-expand-all
:options="equipmentTypeList"
placeholder="请选择规格型号"
@select="select"
:disable-branch-nodes="true"
style="width: 240px"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
/>
</el-form-item>
<el-form-item label="出厂日期">
<el-date-picker <el-date-picker
v-model="queryParams.productionTime" v-model="queryParams.productionTime"
style="width: 240px" style="width: 240px"
@ -49,16 +34,37 @@
:value="item.supplierId" :value="item.supplierId"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item> -->
</el-form> <!-- </el-form> -->
<el-form <el-form
:model="maForm" :model="maForm"
ref="maForm" ref="maForm"
:rules="rules" :rules="rules"
size="small" size="small"
:inline="true" :inline="true"
label-width="100px" label-width="120px"
> >
<el-form-item label="线下采购单编号" prop="purchaseNumber">
<el-input
placeholder="请输入线下采购单编号"
style="width: 240px"
v-model="maForm.purchaseNumber"
/>
</el-form-item>
<el-form-item label="规格型号" prop="equipmentId">
<treeselect
v-model="queryParams.equipmentId"
default-expand-all
:options="equipmentTypeList"
placeholder="请选择规格型号"
@select="select"
:disable-branch-nodes="true"
style="width: 240px"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
/>
</el-form-item>
<el-form-item label="采购日期" prop="purchaseTime"> <el-form-item label="采购日期" prop="purchaseTime">
<el-date-picker <el-date-picker
v-model="maForm.purchaseTime" v-model="maForm.purchaseTime"
@ -343,6 +349,7 @@ export default {
arrivalTime: '', arrivalTime: '',
purchaser: '', purchaser: '',
remark: '', remark: '',
purchaseNumber: '',
}, },
// //
form: {}, form: {},
@ -352,6 +359,13 @@ export default {
}, },
// //
rules: { rules: {
purchaseNumber: [
{
required: true,
message: '请输入线下采购单编号',
trigger: 'blur',
},
],
purchaseTime: [ purchaseTime: [
{ {
required: true, required: true,
@ -503,6 +517,7 @@ export default {
this.maForm.arrivalTime = response.data.arrivalTime this.maForm.arrivalTime = response.data.arrivalTime
this.maForm.purchaser = response.data.purchaser this.maForm.purchaser = response.data.purchaser
this.maForm.remark = response.data.remark this.maForm.remark = response.data.remark
this.maForm.purchaseNumber = response.data.purchaseNumber
this.equipmentList = response.data.checkDetailsList this.equipmentList = response.data.checkDetailsList
// this.loading = false; // this.loading = false;
}) })

View File

@ -109,6 +109,12 @@
indexContinuation(queryParams.pageNum, queryParams.pageSize) indexContinuation(queryParams.pageNum, queryParams.pageSize)
" "
/> />
<el-table-column
align="center"
label="线下采购单编号"
prop="purchaseNumber"
:show-overflow-tooltip="true"
/>
<el-table-column <el-table-column
label="采购单号" label="采购单号"
align="center" align="center"

View File

@ -42,7 +42,7 @@ module.exports = {
// target: `https://test-cc.zhgkxt.com`,//线上环境-南网 // target: `https://test-cc.zhgkxt.com`,//线上环境-南网
// target: `https://z.csgmall.com.cn`, // target: `https://z.csgmall.com.cn`,
target: `http://192.168.2.1:39080`, //超 target: `http://192.168.2.127:39080`, //超
// target: `http://10.40.92.81:8080`, //韩/ // target: `http://10.40.92.81:8080`, //韩/
// target: `http://192.168.2.75:39080`, //旭/ // target: `http://192.168.2.75:39080`, //旭/
// target: `http://192.168.2.17:39080`, //帅 // target: `http://192.168.2.17:39080`, //帅