Merge branch 'anhui-mall-ui-test' of http://192.168.0.75:3000/bonus/bonus-ui into anhui-mall-ui-test

This commit is contained in:
zzyuan 2025-12-12 16:47:50 +08:00
commit f1b97845d9
4 changed files with 2979 additions and 2136 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,585 +1,460 @@
<template>
<!-- 类型管理 -->
<div class="app-container" id="toolsType">
<el-row :gutter="20">
<!--树数据-->
<el-col :span="5" :xs="24">
<div class="head-container">
<el-input
v-model="typeName"
placeholder="请输入类型名称"
clearable
maxlength="50"
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
</el-col>
<el-col :span="19" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="关键字" prop="keyWord">
<el-input
v-model="queryParams.keyWord"
placeholder="请输入关键字"
clearable
style="width: 240px"
@keyup.enter.native="getList"
/>
</el-form-item>
<!-- 类型管理 -->
<div class="app-container" id="toolsType">
<el-row :gutter="10" class="main-content">
<el-col :span="5">
<el-card>
<el-input
clearable
size="small"
maxlength="50"
v-model="typeName"
prefix-icon="el-icon-search"
placeholder="请输入类型名称"
style="margin-bottom: 20px"
/>
<el-tree
ref="tree"
node-key="id"
highlight-current
:data="treeOptions"
:expand-on-click-node="false"
@node-click="handleNodeClick"
:filter-node-method="filterNode"
:default-expanded-keys="defaultExpandedKeys"
:props="{ children: 'children', label: 'label' }"
>
<div
class="custom-tree-node"
slot-scope="{ node, data }"
@mousemove="onMousemove(data)"
@mouseleave="onMouseleave()"
>
<span v-if="isMousemoveId === data.id && node.label.length > 10">
{{ node.label.slice(0, 10) + '...' }}
</span>
<span v-else>{{ node.label }}</span>
</div>
</el-tree>
</el-card>
</el-col>
<el-col :span="5">
<el-card>
<el-input
clearable
size="small"
maxlength="50"
v-model="typeName_1"
prefix-icon="el-icon-search"
placeholder="请输入类型名称"
style="margin-bottom: 20px"
/>
<el-tree
ref="tree_1"
node-key="id"
highlight-current
:data="treeOptions2"
:expand-on-click-node="false"
:filter-node-method="filterNode_1"
@node-click="handleNodeClick"
:default-expanded-keys="defaultExpandedKeys2"
:props="{ children: 'children', label: 'label' }"
>
<div class="custom-tree-node" slot-scope="{ node, data }">
<span v-if="isMousemoveId === data.id && node.label.length > 10">{{
node.label.slice(0, 10) + '...'
}}</span>
<span v-else>{{ node.label }}</span>
</div>
</el-tree>
</el-card>
</el-col>
<el-col :span="14">
<el-card class="table-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="关键字" prop="keyWord">
<el-input
clearable
style="width: 240px"
placeholder="请输入关键字"
v-model="queryParams.keyWord"
@keyup.enter.native="getList"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getList">查询 </el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置 </el-button>
</el-form-item>
</el-form>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getList">
查询
</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置 </el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-edit" size="mini" @click="onBatchEditPrice"
>批量修改租赁价
</el-button>
</el-col>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-edit" size="mini" @click="onBatchEditPrice">
批量修改租赁价
</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="typeList" border @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column
label="专业"
align="center"
key="equipCategory"
prop="equipCategory"
show-overflow-tooltip
/>
<el-table-column label="主工序" align="center" key="major" prop="major" show-overflow-tooltip />
<el-table-column label="子工序" align="center" prop="mainProcedure" show-overflow-tooltip />
<el-table-column label="装备类目" align="center" prop="subProcedure" show-overflow-tooltip />
<el-table-column label="装备名称" align="center" prop="typeName" show-overflow-tooltip />
<el-table-column label="租赁价" align="center" prop="leasePrice" show-overflow-tooltip />
</el-table>
<pagination
:total="total"
@pagination="getList"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
/>
</el-card>
</el-col>
</el-row>
</el-col>
</el-row>
<el-row :gutter="20" style="height: 93%">
<!--树数据-->
<el-col :span="5" :xs="24" style="height: 100%">
<div class="head-container" style="height: 100%">
<el-tree
style="overflow-y: auto"
:data="treeOptions"
:props="{ children: 'children', label: 'label' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
:default-expanded-keys="defaultExpandedKeys"
highlight-current
@node-click="handleNodeClick"
>
<div
class="custom-tree-node"
slot-scope="{ node, data }"
@mousemove="onMousemove(data)"
@mouseleave="onMouseleave()"
>
<span v-if="isMousemoveId === data.id && node.label.length > 10">{{
node.label.slice(0, 10) + '...'
}}</span>
<span v-else>{{ node.label }}</span>
</div>
</el-tree>
<el-tree
style="height: 100%"
:data="treeOptions2"
:props="{ children: 'children', label: 'label' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree2"
node-key="id"
:default-expanded-keys="defaultExpandedKeys2"
highlight-current
@node-click="handleNodeClick"
>
<div
class="custom-tree-node"
slot-scope="{ node, data }"
@mousemove="onMousemove(data)"
@mouseleave="onMouseleave()"
>
<span v-if="isMousemoveId === data.id && node.label.length > 10">{{
node.label.slice(0, 10) + '...'
}}</span>
<span v-else>{{ node.label }}</span>
</div>
</el-tree>
</div>
</el-col>
<el-col :span="18" style="height: 100%">
<el-table v-if="typeList.length > 0" v-loading="loading" :data="typeList" border height="546" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="专业" align="center" key="equipCategory" prop="equipCategory" show-overflow-tooltip />
<el-table-column label="主工序" align="center" key="major" prop="major" show-overflow-tooltip />
<el-table-column
label="子工序"
align="center"
key="mainProcedure"
prop="mainProcedure"
show-overflow-tooltip
/>
<el-table-column
label="装备类目"
align="center"
key="subProcedure"
prop="subProcedure"
show-overflow-tooltip
/>
<el-table-column label="装备名称" align="center" key="typeName" prop="typeName" show-overflow-tooltip />
<el-table-column label="租赁价" align="center" prop="leasePrice" show-overflow-tooltip />
</el-table>
<el-table v-if="typeList2.length > 0" v-loading="loading" :data="typeList2" border height="546" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="工具专业" align="center" key="fourthParentName" prop="fourthParentName" show-overflow-tooltip />
<el-table-column label="施工类型" align="center" key="greatGrandparentName" prop="greatGrandparentName" show-overflow-tooltip />
<el-table-column
label="工具类型"
align="center"
key="grandparentTypeName"
prop="grandparentTypeName"
show-overflow-tooltip
/>
<el-table-column label="工具名称" align="center" key="parentTypeName" prop="parentTypeName" show-overflow-tooltip />
<el-table-column label="规格型号" align="center" key="typeName" prop="typeName" show-overflow-tooltip />
<el-table-column label="租赁价" align="center" prop="leasePrice" show-overflow-tooltip />
</el-table>
<pagination
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<AddNode
:visible.sync="addOpen"
:parentNode="addParentNode"
:showIsStateGrid="showIsStateGrid"
@refresh="refresh"
/>
<EditNode
:visible.sync="editOpen"
:parentNode="editParentNode"
:showIsStateGrid="showIsStateGrid"
@refresh="refresh"
/>
<AddChildNode :visible.sync="addChildOpen" :parentNode="addChildNode" @refresh="refresh" />
<EditChildNode :visible.sync="editChildOpen" :parentNode="editChildNode" @refresh="refresh" />
<!-- 修改价格弹框 -->
<el-dialog
title="修改共享价"
:visible.sync="editLeasePriceVisible"
v-if="editLeasePriceVisible"
width="30%"
append-to-body
:close-on-click-modal="false"
>
<el-form :inline="true" :model="editPriceForm" ref="editPriceFormRef" :rules="editPriceFormRules">
<el-form-item label="修改后租赁价" prop="leasePrice">
<el-input v-model="editPriceForm.leasePrice" />
</el-form-item>
<el-row style="text-align: right">
<el-form-item>
<el-button size="small" @click="onEditCancel"> </el-button>
<el-button size="small" type="primary" @click="onEditSubmit"> </el-button>
</el-form-item>
</el-row>
</el-form>
</el-dialog>
</div>
<!-- 修改价格弹框 -->
<el-dialog
title="修改共享价"
:visible.sync="editLeasePriceVisible"
v-if="editLeasePriceVisible"
width="30%"
append-to-body
:close-on-click-modal="false"
>
<el-form :inline="true" :model="editPriceForm" ref="editPriceFormRef" :rules="editPriceFormRules">
<el-form-item label="修改后租赁价" prop="leasePrice">
<el-input v-model="editPriceForm.leasePrice" />
</el-form-item>
<el-row style="text-align: right">
<el-form-item>
<el-button size="small" @click="onEditCancel"> </el-button>
<el-button size="small" type="primary" @click="onEditSubmit"> </el-button>
</el-form-item>
</el-row>
</el-form>
</el-dialog>
</div>
</template>
<script>
import { getMaTypeList, delMaType, getList, updateLeasePriceApi } from '@/api/lessor/equipType'
import { getMaTypeList, getList, updateLeasePriceApi } from '@/api/lessor/equipType'
import { getTreeSelect, getListTool, updateLeasePriceTool } from '@/api/ma/base'
import AddNode from '@/views/lessor/equipment/equipType/child/addNode.vue'
import EditNode from '@/views/lessor/equipment/equipType/child/editNode.vue'
import AddChildNode from '@/views/lessor/equipment/equipType/child/addChildNode.vue'
import EditChildNode from '@/views/lessor/equipment/equipType/child/editChildNode.vue'
export default {
name: 'ToolsType',
components: { AddNode, EditNode, AddChildNode, EditChildNode },
data() {
return {
editPriceForm: {
leasePrice: '',
},
editLeasePriceVisible: false,
name: 'priceManagement',
//
total: 0,
//
typeList: undefined,
typeList2: [],
//
loading: true,
typeName: undefined,
treeOptions: undefined,
treeOptions2: undefined,
addOpen: false,
addParentNode: {},
editOpen: false,
editParentNode: {},
data() {
return {
editPriceForm: {
leasePrice: '',
},
editLeasePriceVisible: false,
addChildOpen: false,
addChildNode: {},
editChildOpen: false,
editChildNode: {},
isMousemoveId: null,
addFormParams: {
label: '',
typeName: '',
companyId: 101,
},
queryParams: {
pageNum: 1,
pageSize: 10,
keyWord: undefined,
level: 1,
},
addFormParamsRules: {
typeName: [
{
required: true,
message: '名称不能为空',
trigger: 'blur',
},
],
},
editPriceFormRules: {
leasePrice: [
{
required: true,
message: '请输入修改后共享价格',
trigger: 'blur',
},
{
pattern: /^(0(\.\d{0,2})?|([1-9]\d*)(\.\d{0,2})?)$/,
message: '请输入正确的费用金额,最多两位小数点',
trigger: 'blur',
},
],
},
addTitleVisible: false,
addTitle: '',
showIsStateGrid: null,
ids: [],
defaultExpandedKeys: [],
defaultExpandedKeys2: [],
isTool: false,
}
},
watch: {
typeName(val) {
this.$refs.tree.filter(val)
},
},
created() {
this.getTreeData()
this.getList()
},
methods: {
collectExpandKeys(nodes, currentLevel = 1, maxLevel = 2) {
let keys = []
//
total: 0,
//
typeList: undefined,
typeList2: [],
//
loading: true,
typeName: undefined,
typeName_1: '',
treeOptions: undefined,
treeOptions2: undefined,
isMousemoveId: null,
nodes.forEach((node) => {
if (currentLevel <= maxLevel) {
keys.push(node.id)
queryParams: {
pageNum: 1,
pageSize: 10,
keyWord: undefined,
level: 1,
},
editPriceFormRules: {
leasePrice: [
{
required: true,
message: '请输入修改后共享价格',
trigger: 'blur',
},
{
pattern: /^(0(\.\d{0,2})?|([1-9]\d*)(\.\d{0,2})?)$/,
message: '请输入正确的费用金额,最多两位小数点',
trigger: 'blur',
},
],
},
ids: [],
defaultExpandedKeys: [],
defaultExpandedKeys2: [],
isTool: false,
}
if (node.children && node.children.length) {
keys = keys.concat(this.collectExpandKeys(node.children, currentLevel + 1, maxLevel))
}
})
return keys
},
getList() {
this.loading = true
this.typeList = []
this.typeList2 = []
if (this.isTool) {
const params = {
typeId: this.queryParams.typeId,
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
}
getListTool(params).then((res) => {
this.typeList2 = res.rows
this.total = res.total
this.loading = false
})
} else {
getList(this.queryParams).then((response) => {
this.typeList = response.data.rows
this.total = response.data.total
this.loading = false
})
}
},
async getTreeData() {
const response = await getMaTypeList()
const res = await getTreeSelect()
// level == 7
const filterTree = (nodes) => {
return nodes
.filter((node) => node.level !== 7) // level=7
.map((node) => ({
...node,
children: node.children ? filterTree(node.children) : [],
}))
}
const filterTree2 = (nodes) => {
return nodes
.filter((node) => node.level !== 7) // level=7
.map((node) => ({
...node,
id: node.typeId,
label: node.typeName,
isTool: true,
children: node.children ? filterTree2(node.children) : [],
}))
}
this.treeOptions = [
{
label: '机具类型',
id: 0,
children: filterTree(response.data),
level: 0,
watch: {
typeName(val) {
this.$refs.tree.filter(val)
},
]
this.treeOptions2 = [
{
label: '工具类型',
id: 0,
children: filterTree2(res.data),
level: 0,
typeName_1(val) {
this.$refs.tree_1.filter(val)
},
]
this.defaultExpandedKeys = this.collectExpandKeys(this.treeOptions)
this.defaultExpandedKeys2 = this.collectExpandKeys(this.treeOptions2)
this.$nextTick(() => {
this.$refs.tree && this.$refs.tree.setCurrentKey(null)
this.$refs.tree2 && this.$refs.tree2.setCurrentKey(null)
})
},
created() {
this.getTreeData()
this.getList()
},
methods: {
collectExpandKeys(nodes, currentLevel = 1, maxLevel = 2) {
let keys = []
console.log('🚀 ~ this.treeOptions2:', this.treeOptions2)
},
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
nodes.forEach((node) => {
if (currentLevel <= maxLevel) {
keys.push(node.id)
}
if (node.children && node.children.length) {
keys = keys.concat(this.collectExpandKeys(node.children, currentLevel + 1, maxLevel))
}
})
handleNodeClick(data) {
console.log('节点点击', data)
this.isTool = data.isTool
console.log('🚀 ~ this.isTool:', this.isTool)
this.queryParams.typeId = data.id
this.queryParams.level = data.level
this.queryParams.typeName = data.label
this.getList()
},
return keys
},
resetQuery() {
this.dateRange = []
this.resetForm('queryForm')
this.queryParams.typeId = undefined
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.queryParams.level = 1
this.$refs.tree.setCurrentKey(null)
this.getList()
},
appendTreeNode(data) {
this.showIsStateGrid = data.level == 4
if (data.level == 6) {
const path = this.getParentNames(this.treeOptions, data.id)
data.major = path[1]
data.mainProcedure = path[2]
this.addChildOpen = true
this.addChildNode = data
} else {
this.addOpen = true
this.addParentNode = data
}
},
editTreeNode(data) {
console.log('🚀 ~ editTreeNode ~ data.level:', data)
this.showIsStateGrid = data.level == 5
if (data.level == 7) {
const path = this.getParentNames(this.treeOptions, data.parentId)
data.major = path[1]
data.mainProcedure = path[2]
this.editChildOpen = true
this.editChildNode = data
console.log(data)
} else {
this.editOpen = true
this.editParentNode = data
}
},
removeTreeNode(data) {
this.$modal
.confirm('是否确认删除数据项?')
.then(() => delMaType(data.id || data.typeId))
.then(() => {
this.$modal.msgSuccess('删除成功')
this.getTreeData()
this.getList()
})
.catch(() => {})
},
onMousemove(data) {
this.isMousemoveId = data.id
},
onMouseleave() {
this.isMousemoveId = null
},
refresh() {
this.getTreeData()
this.getList()
},
/**
* 根据节点ID查找完整父级路径名称
* @param {Array} treeData 树形数据
* @param {number} nodeId 要查找的节点ID
* @returns {Array} 从根节点到目标节点的名称路径数组
*/
getParentNames(treeData, nodeId) {
const path = []
function findNode(nodes, targetId) {
for (const node of nodes) {
//
if (node.id === targetId) {
path.unshift(node.label) //
return true
}
//
if (node.children && node.children.length > 0) {
if (findNode(node.children, targetId)) {
path.unshift(node.label) //
return true
getList() {
this.loading = true
this.typeList = []
this.typeList2 = []
if (this.isTool) {
const params = {
typeId: this.queryParams.typeId,
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
}
getListTool(params).then((res) => {
this.typeList2 = res.rows
this.total = res.total
this.loading = false
})
} else {
getList(this.queryParams).then((response) => {
this.typeList = response.data.rows
this.total = response.data.total
this.loading = false
})
}
},
async getTreeData() {
const response = await getMaTypeList()
const res = await getTreeSelect()
// level == 7
const filterTree = (nodes) => {
return nodes
.filter((node) => node.level !== 7) // level=7
.map((node) => ({
...node,
children: node.children ? filterTree(node.children) : [],
}))
}
const filterTree2 = (nodes) => {
return nodes
.filter((node) => node.level !== 7) // level=7
.map((node) => ({
...node,
id: node.typeId,
label: node.typeName,
isTool: true,
children: node.children ? filterTree2(node.children) : [],
}))
}
}
}
return false
}
findNode(treeData, nodeId)
console.log(path)
return path
},
//
onBatchEditPrice() {
this.$message.closeAll()
if (this.ids.length < 1) {
this.$message.error('请勾选改价的设备')
return
}
this.editPriceForm.leasePrice = ''
// this.batchEdit = true
this.editLeasePriceVisible = true
},
this.treeOptions = [
{
label: '机具类型',
id: 0,
children: filterTree(response.data),
level: 0,
},
]
this.treeOptions2 = [
{
label: '工具类型',
id: 0,
children: filterTree2(res.data),
level: 0,
},
]
this.defaultExpandedKeys = this.collectExpandKeys(this.treeOptions)
this.defaultExpandedKeys2 = this.collectExpandKeys(this.treeOptions2)
this.$nextTick(() => {
this.$refs.tree && this.$refs.tree.setCurrentKey(null)
this.$refs.tree2 && this.$refs.tree2.setCurrentKey(null)
})
//
handleSelectionChange(val) {
console.log(val)
this.ids = val
},
onEditCancel() {
this.editLeasePriceVisible = false
this.$refs.editPriceFormRef.resetFields()
},
handleUpdateLeasePrice(row) {
this.editPriceForm.leasePrice = ''
// this.batchEdit = false
// this.editTypeIds = []
// this.editTypeIds.push(row.typeId)
this.editLeasePriceVisible = true
},
onEditSubmit() {
this.$refs.editPriceFormRef.validate(async (valid) => {
if (valid) {
const params = {
typeIds: this.ids.map((e) => e.typeId),
leasePrice: this.editPriceForm.leasePrice * 1,
}
let res = null
if (this.isTool) {
res = await updateLeasePriceTool(params)
} else {
res = await updateLeasePriceApi(params)
}
if (res.code === 200) {
this.$message.success('修改成功')
this.editLeasePriceVisible = false
console.log('🚀 ~ this.treeOptions2:', this.treeOptions2)
},
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
filterNode_1(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
handleNodeClick(data) {
this.isTool = data.isTool
this.queryParams.typeId = data.id
this.queryParams.level = data.level
this.queryParams.typeName = data.label
this.getList()
}
}
})
},
resetQuery() {
this.dateRange = []
this.resetForm('queryForm')
this.queryParams.typeId = undefined
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.queryParams.level = 1
this.$refs.tree.setCurrentKey(null)
this.getList()
},
refresh() {
this.getTreeData()
this.getList()
},
//
onBatchEditPrice() {
this.$message.closeAll()
if (this.ids.length < 1) {
this.$message.error('请勾选改价的设备')
return
}
this.editPriceForm.leasePrice = ''
// this.batchEdit = true
this.editLeasePriceVisible = true
},
//
handleSelectionChange(val) {
this.ids = val
},
onEditCancel() {
this.editLeasePriceVisible = false
this.$refs.editPriceFormRef.resetFields()
},
onEditSubmit() {
this.$refs.editPriceFormRef.validate(async (valid) => {
if (valid) {
const params = {
typeIds: this.ids.map((e) => e.typeId),
leasePrice: this.editPriceForm.leasePrice * 1,
}
let res = null
if (this.isTool) {
res = await updateLeasePriceTool(params)
} else {
res = await updateLeasePriceApi(params)
}
if (res.code === 200) {
this.$message.success('修改成功')
this.editLeasePriceVisible = false
this.getList()
}
}
})
},
},
},
}
</script>
<style lang="scss" scoped>
::v-deep.el-table .fixed-width .el-button--mini {
width: 60px !important;
margin-bottom: 10px;
width: 60px !important;
margin-bottom: 10px;
}
::v-deep .btn-items .el-button + .el-button {
margin-left: 10px;
margin-left: 10px;
}
.btn-items {
margin-left: 4px;
margin-left: 4px;
.el-button--text {
font-size: 16px;
}
.el-button--text {
font-size: 16px;
}
}
::v-deep .el-tree .el-tree-node__expand-icon.expanded {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
::v-deep .el-tree .el-icon-caret-right:before {
content: '\e783';
font-size: 16px;
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;
content: '\e781';
font-size: 16px;
color: #1890ff;
}
::v-deep .el-tree-node__content > .el-tree-node__expand-icon {
color: #1890ff !important;
color: #1890ff !important;
}
::v-deep .el-tree-node__expand-icon.is-leaf {
color: transparent !important;
color: transparent !important;
}
::v-deep .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
background-color: #8decf1;
background-color: #8decf1;
}
::v-deep .el-tree {
height: 300px;
overflow-y: scroll; /* 必须保留scroll而不是auto */
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE/Edge */
overflow-y: scroll; /* 必须保留scroll而不是auto */
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE/Edge */
}
::v-deep .el-tree::-webkit-scrollbar {
display: none; /* Chrome/Safari/Opera */
display: none; /* Chrome/Safari/Opera */
}
.main-content {
height: 100%;
.el-col {
height: 100%;
.el-card {
height: 100%;
}
}
}
::v-deep .el-card__body {
padding: 10px;
}
.table-container {
overflow: auto;
}
</style>

View File

@ -0,0 +1,635 @@
<template>
<!-- 类型管理 -->
<div class="app-container" id="toolsType">
<el-row :gutter="20">
<!--树数据-->
<el-col :span="5" :xs="24">
<div class="head-container">
<el-input
v-model="typeName"
placeholder="请输入类型名称"
clearable
maxlength="50"
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
</el-col>
<el-col :span="19" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="关键字" prop="keyWord">
<el-input
v-model="queryParams.keyWord"
placeholder="请输入关键字"
clearable
style="width: 240px"
@keyup.enter.native="getList"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getList">查询 </el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置 </el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-edit" size="mini" @click="onBatchEditPrice"
>批量修改租赁价
</el-button>
</el-col>
</el-row>
</el-col>
</el-row>
<el-row :gutter="20" style="height: 93%">
<!--树数据-->
<el-col :span="5" :xs="24" style="height: 100%">
<div class="head-container" style="height: 100%">
<el-tree
style="overflow-y: auto"
:data="treeOptions"
:props="{ children: 'children', label: 'label' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
:default-expanded-keys="defaultExpandedKeys"
highlight-current
@node-click="handleNodeClick"
>
<div
class="custom-tree-node"
slot-scope="{ node, data }"
@mousemove="onMousemove(data)"
@mouseleave="onMouseleave()"
>
<span v-if="isMousemoveId === data.id && node.label.length > 10">{{
node.label.slice(0, 10) + '...'
}}</span>
<span v-else>{{ node.label }}</span>
</div>
</el-tree>
<el-tree
style="height: 100%"
:data="treeOptions2"
:props="{ children: 'children', label: 'label' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree2"
node-key="id"
:default-expanded-keys="defaultExpandedKeys2"
highlight-current
@node-click="handleNodeClick"
>
<div
class="custom-tree-node"
slot-scope="{ node, data }"
@mousemove="onMousemove(data)"
@mouseleave="onMouseleave()"
>
<span v-if="isMousemoveId === data.id && node.label.length > 10">{{
node.label.slice(0, 10) + '...'
}}</span>
<span v-else>{{ node.label }}</span>
</div>
</el-tree>
</div>
</el-col>
<el-col :span="18" style="height: 100%">
<el-table
v-if="typeList.length > 0"
v-loading="loading"
:data="typeList"
border
height="546"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="50" align="center" />
<el-table-column
label="专业"
align="center"
key="equipCategory"
prop="equipCategory"
show-overflow-tooltip
/>
<el-table-column label="主工序" align="center" key="major" prop="major" show-overflow-tooltip />
<el-table-column
label="子工序"
align="center"
key="mainProcedure"
prop="mainProcedure"
show-overflow-tooltip
/>
<el-table-column
label="装备类目"
align="center"
key="subProcedure"
prop="subProcedure"
show-overflow-tooltip
/>
<el-table-column
label="装备名称"
align="center"
key="typeName"
prop="typeName"
show-overflow-tooltip
/>
<el-table-column label="租赁价" align="center" prop="leasePrice" show-overflow-tooltip />
</el-table>
<el-table
v-if="typeList2.length > 0"
v-loading="loading"
:data="typeList2"
border
height="546"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="50" align="center" />
<el-table-column
label="工具专业"
align="center"
key="fourthParentName"
prop="fourthParentName"
show-overflow-tooltip
/>
<el-table-column
label="施工类型"
align="center"
key="greatGrandparentName"
prop="greatGrandparentName"
show-overflow-tooltip
/>
<el-table-column
label="工具类型"
align="center"
key="grandparentTypeName"
prop="grandparentTypeName"
show-overflow-tooltip
/>
<el-table-column
label="工具名称"
align="center"
key="parentTypeName"
prop="parentTypeName"
show-overflow-tooltip
/>
<el-table-column
label="规格型号"
align="center"
key="typeName"
prop="typeName"
show-overflow-tooltip
/>
<el-table-column label="租赁价" align="center" prop="leasePrice" show-overflow-tooltip />
</el-table>
<pagination
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<AddNode
:visible.sync="addOpen"
:parentNode="addParentNode"
:showIsStateGrid="showIsStateGrid"
@refresh="refresh"
/>
<EditNode
:visible.sync="editOpen"
:parentNode="editParentNode"
:showIsStateGrid="showIsStateGrid"
@refresh="refresh"
/>
<AddChildNode :visible.sync="addChildOpen" :parentNode="addChildNode" @refresh="refresh" />
<EditChildNode :visible.sync="editChildOpen" :parentNode="editChildNode" @refresh="refresh" />
<!-- 修改价格弹框 -->
<el-dialog
title="修改共享价"
:visible.sync="editLeasePriceVisible"
v-if="editLeasePriceVisible"
width="30%"
append-to-body
:close-on-click-modal="false"
>
<el-form :inline="true" :model="editPriceForm" ref="editPriceFormRef" :rules="editPriceFormRules">
<el-form-item label="修改后租赁价" prop="leasePrice">
<el-input v-model="editPriceForm.leasePrice" />
</el-form-item>
<el-row style="text-align: right">
<el-form-item>
<el-button size="small" @click="onEditCancel"> </el-button>
<el-button size="small" type="primary" @click="onEditSubmit"> </el-button>
</el-form-item>
</el-row>
</el-form>
</el-dialog>
</div>
</template>
<script>
import { getMaTypeList, delMaType, getList, updateLeasePriceApi } from '@/api/lessor/equipType'
import { getTreeSelect, getListTool, updateLeasePriceTool } from '@/api/ma/base'
import AddNode from '@/views/lessor/equipment/equipType/child/addNode.vue'
import EditNode from '@/views/lessor/equipment/equipType/child/editNode.vue'
import AddChildNode from '@/views/lessor/equipment/equipType/child/addChildNode.vue'
import EditChildNode from '@/views/lessor/equipment/equipType/child/editChildNode.vue'
export default {
name: 'ToolsType',
components: { AddNode, EditNode, AddChildNode, EditChildNode },
data() {
return {
editPriceForm: {
leasePrice: '',
},
editLeasePriceVisible: false,
//
total: 0,
//
typeList: undefined,
typeList2: [],
//
loading: true,
typeName: undefined,
treeOptions: undefined,
treeOptions2: undefined,
addOpen: false,
addParentNode: {},
editOpen: false,
editParentNode: {},
addChildOpen: false,
addChildNode: {},
editChildOpen: false,
editChildNode: {},
isMousemoveId: null,
addFormParams: {
label: '',
typeName: '',
companyId: 101,
},
queryParams: {
pageNum: 1,
pageSize: 10,
keyWord: undefined,
level: 1,
},
addFormParamsRules: {
typeName: [
{
required: true,
message: '名称不能为空',
trigger: 'blur',
},
],
},
editPriceFormRules: {
leasePrice: [
{
required: true,
message: '请输入修改后共享价格',
trigger: 'blur',
},
{
pattern: /^(0(\.\d{0,2})?|([1-9]\d*)(\.\d{0,2})?)$/,
message: '请输入正确的费用金额,最多两位小数点',
trigger: 'blur',
},
],
},
addTitleVisible: false,
addTitle: '',
showIsStateGrid: null,
ids: [],
defaultExpandedKeys: [],
defaultExpandedKeys2: [],
isTool: false,
}
},
watch: {
typeName(val) {
this.$refs.tree.filter(val)
},
},
created() {
this.getTreeData()
this.getList()
},
methods: {
collectExpandKeys(nodes, currentLevel = 1, maxLevel = 2) {
let keys = []
nodes.forEach((node) => {
if (currentLevel <= maxLevel) {
keys.push(node.id)
}
if (node.children && node.children.length) {
keys = keys.concat(this.collectExpandKeys(node.children, currentLevel + 1, maxLevel))
}
})
return keys
},
getList() {
this.loading = true
this.typeList = []
this.typeList2 = []
if (this.isTool) {
const params = {
typeId: this.queryParams.typeId,
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
}
getListTool(params).then((res) => {
this.typeList2 = res.rows
this.total = res.total
this.loading = false
})
} else {
getList(this.queryParams).then((response) => {
this.typeList = response.data.rows
this.total = response.data.total
this.loading = false
})
}
},
async getTreeData() {
const response = await getMaTypeList()
const res = await getTreeSelect()
// level == 7
const filterTree = (nodes) => {
return nodes
.filter((node) => node.level !== 7) // level=7
.map((node) => ({
...node,
children: node.children ? filterTree(node.children) : [],
}))
}
const filterTree2 = (nodes) => {
return nodes
.filter((node) => node.level !== 7) // level=7
.map((node) => ({
...node,
id: node.typeId,
label: node.typeName,
isTool: true,
children: node.children ? filterTree2(node.children) : [],
}))
}
this.treeOptions = [
{
label: '机具类型',
id: 0,
children: filterTree(response.data),
level: 0,
},
]
this.treeOptions2 = [
{
label: '工具类型',
id: 0,
children: filterTree2(res.data),
level: 0,
},
]
this.defaultExpandedKeys = this.collectExpandKeys(this.treeOptions)
this.defaultExpandedKeys2 = this.collectExpandKeys(this.treeOptions2)
this.$nextTick(() => {
this.$refs.tree && this.$refs.tree.setCurrentKey(null)
this.$refs.tree2 && this.$refs.tree2.setCurrentKey(null)
})
console.log('🚀 ~ this.treeOptions2:', this.treeOptions2)
},
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
handleNodeClick(data) {
console.log('节点点击', data)
this.isTool = data.isTool
console.log('🚀 ~ this.isTool:', this.isTool)
this.queryParams.typeId = data.id
this.queryParams.level = data.level
this.queryParams.typeName = data.label
this.getList()
},
resetQuery() {
this.dateRange = []
this.resetForm('queryForm')
this.queryParams.typeId = undefined
this.queryParams.pageNum = 1
this.queryParams.pageSize = 10
this.queryParams.level = 1
this.$refs.tree.setCurrentKey(null)
this.getList()
},
appendTreeNode(data) {
this.showIsStateGrid = data.level == 4
if (data.level == 6) {
const path = this.getParentNames(this.treeOptions, data.id)
data.major = path[1]
data.mainProcedure = path[2]
this.addChildOpen = true
this.addChildNode = data
} else {
this.addOpen = true
this.addParentNode = data
}
},
editTreeNode(data) {
console.log('🚀 ~ editTreeNode ~ data.level:', data)
this.showIsStateGrid = data.level == 5
if (data.level == 7) {
const path = this.getParentNames(this.treeOptions, data.parentId)
data.major = path[1]
data.mainProcedure = path[2]
this.editChildOpen = true
this.editChildNode = data
console.log(data)
} else {
this.editOpen = true
this.editParentNode = data
}
},
removeTreeNode(data) {
this.$modal
.confirm('是否确认删除数据项?')
.then(() => delMaType(data.id || data.typeId))
.then(() => {
this.$modal.msgSuccess('删除成功')
this.getTreeData()
this.getList()
})
.catch(() => {})
},
onMousemove(data) {
this.isMousemoveId = data.id
},
onMouseleave() {
this.isMousemoveId = null
},
refresh() {
this.getTreeData()
this.getList()
},
/**
* 根据节点ID查找完整父级路径名称
* @param {Array} treeData 树形数据
* @param {number} nodeId 要查找的节点ID
* @returns {Array} 从根节点到目标节点的名称路径数组
*/
getParentNames(treeData, nodeId) {
const path = []
function findNode(nodes, targetId) {
for (const node of nodes) {
//
if (node.id === targetId) {
path.unshift(node.label) //
return true
}
//
if (node.children && node.children.length > 0) {
if (findNode(node.children, targetId)) {
path.unshift(node.label) //
return true
}
}
}
return false
}
findNode(treeData, nodeId)
console.log(path)
return path
},
//
onBatchEditPrice() {
this.$message.closeAll()
if (this.ids.length < 1) {
this.$message.error('请勾选改价的设备')
return
}
this.editPriceForm.leasePrice = ''
// this.batchEdit = true
this.editLeasePriceVisible = true
},
//
handleSelectionChange(val) {
console.log(val)
this.ids = val
},
onEditCancel() {
this.editLeasePriceVisible = false
this.$refs.editPriceFormRef.resetFields()
},
handleUpdateLeasePrice(row) {
this.editPriceForm.leasePrice = ''
// this.batchEdit = false
// this.editTypeIds = []
// this.editTypeIds.push(row.typeId)
this.editLeasePriceVisible = true
},
onEditSubmit() {
this.$refs.editPriceFormRef.validate(async (valid) => {
if (valid) {
const params = {
typeIds: this.ids.map((e) => e.typeId),
leasePrice: this.editPriceForm.leasePrice * 1,
}
let res = null
if (this.isTool) {
res = await updateLeasePriceTool(params)
} else {
res = await updateLeasePriceApi(params)
}
if (res.code === 200) {
this.$message.success('修改成功')
this.editLeasePriceVisible = false
this.getList()
}
}
})
},
},
}
</script>
<style lang="scss" scoped>
::v-deep.el-table .fixed-width .el-button--mini {
width: 60px !important;
margin-bottom: 10px;
}
::v-deep .btn-items .el-button + .el-button {
margin-left: 10px;
}
.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;
}
::v-deep .el-tree {
height: 300px;
overflow-y: scroll; /* 必须保留scroll而不是auto */
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE/Edge */
}
::v-deep .el-tree::-webkit-scrollbar {
display: none; /* Chrome/Safari/Opera */
}
</style>