From fe25b9d9dc98187a0b885631bc39dfd5daa15163 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 20 十一月 2025 17:26:04 +0800
Subject: [PATCH] 工位改为默认查询所有状态
---
src/views/mdc/MYTree.vue | 94 +++++++++++++++++++++++++++++++++++------------
1 files changed, 70 insertions(+), 24 deletions(-)
diff --git a/src/views/mdc/MYTree.vue b/src/views/mdc/MYTree.vue
index 4e70583..24993bc 100644
--- a/src/views/mdc/MYTree.vue
+++ b/src/views/mdc/MYTree.vue
@@ -1,17 +1,30 @@
<!--
* @Date: 2024-04-18 19:53:35
- * @LastEditors: Sneed
- * @LastEditTime: 2024-05-26 15:49:11
- * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/MYTree.vue
+ * @LastEditors: 鏉庡枂(寮�鍙戠粍) lzhe@yxqiche.com
+ * @LastEditTime: 2025-03-27 14:47:57
+ * @FilePath: /cps-web/src/views/mdc/MYTree.vue
-->
<template>
- <el-tree ref="treeRef" v-bind="$attrs" :show-checkbox="showCheckbox" :current-node-key="currentNodeKey"
- node-key="id" :props="defalutProps" :data="data" @check-change="checkChange" @node-click="handleNodeClick"
- highlight-current default-expand-all :expand-on-click-node="false" :render-content="renderContent"></el-tree>
+ <el-input v-model="word" style="max-width: 600px" placeholder="" @change="search" class="input-with-select">
+ <template #append>
+ <el-button :icon="ElementPlusIconsVue.Search" />
+ </template>
+ </el-input>
+ <el-switch v-model="showType" active-text="鍒楄〃" inactive-text="鏍戠姸" @change="switchFn" />
+ <el-tree v-show="!showType" :expand-on-click-node="false" ref="treeRef" v-bind="$attrs"
+ :show-checkbox="showCheckbox" :current-node-key="currentNodeKey" node-key="id" :props="defalutProps"
+ :data="data" @check-change="checkChange" @node-click="handleNodeClick" highlight-current default-expand-all
+ :render-content="renderContent"></el-tree>
+ <el-table v-show="showType" :data="tableData" @selection-change="handleSelectionChange" highlight-current-row
+ :current-row-key="currentNodeKey" row-key="id" @row-click="rowClick">
+ <el-table-column v-if="showCheckbox" type="selection" :selectable="selectable" width="55" />
+ <el-table-column prop="title" label="宸ヤ綅鍚嶇О" />
+ </el-table>
</template>
<script>
import pmsPng from '@/assets/pms.png'
+import * as ElementPlusIconsVue from '@element-plus/icons-vue'
export default {
props: {
showCheckbox: {
@@ -27,17 +40,25 @@
default: () => {
return {}
}
+ },
+ isSelectId: { //榛樿閫変腑
+ type: String,
+ default: ""
}
},
data() {
return {
+ ElementPlusIconsVue,
+ word: '',
+ showType: false, // 鏄剧ず绫诲瀷
+ tableData: [],
pmsPng,
firstWorkKey: '',
- currentNodeKey: [],
+ currentNodeKey: '',
defalutProps: {
label: 'title',
children: 'children',
- disabled: 'disabled',
+ disabled: this.showCheckbox ? '' : 'disabled',
class: (data, node) => {
return this.value.includes(data.id) ? 'active' : ''
},
@@ -57,17 +78,38 @@
this.$emit('update:modelValue', value)
}
},
- created() {
+ mounted() {
this.getList()
+ let key = this.$route.path
+ if (localStorage.getItem(key) === '1') {
+ this.showType = true
+ }
+ console.log(this.$route, '>>>>>>')
},
methods: {
- renderContent(h, { data,node }) {
+ search() {
+ this.getList()
+ },
+ switchFn(val) {
+ console.log(this.$route, val, '>>>>>>')
+ localStorage.setItem(this.$route.path, val ? '1' : '0')
+ },
+ handleSelectionChange(selection) {
+ if (this.getAll) {
+ return this.value = selection
+ }
+ this.value = selection.map(v => v.id)
+ },
+ rowClick(row) {
+ this.currentNodeKey = row.id
+ },
+ renderContent(h, { data, node }) {
let img = data.groupTag == 'fms_beltline'
return h('a', {
class: {
- disabled: this.props.disabled ? this.props.disabled(data,node) : data.disabled
+ disabled: this.props.disabled ? this.props.disabled(data, node) : data.disabled
},
- disabled: this.props.disabled ? this.props.disabled(data,node) : data.disabled
+ disabled: this.props.disabled ? this.props.disabled(data, node) : data.disabled
},
img ? h('img', {
src: pmsPng
@@ -75,24 +117,26 @@
data.title)
},
getList() {
- this.$HTTP.post('/api/blade-cps/group/groupWorkstation/type', {
+ this.$HTTP.post('/api/smis/group/groupWorkstation/type', {
groupCategory: 1,
groupType: "group_workstation"
}).then(({ code, data }) => {
if (code === 200) {
- this.data = this.formatData(data)
+ this.tableData = data.filter(v => v.isWorkstation && v.title.indexOf(this.word) > -1)
+ this.data = this.formatData(data.filter(v => !v.isWorkstation || (v.isWorkstation && v.title.indexOf(this.word) > -1)))
this.$nextTick(() => {
- this.currentNodeKey = this.firstWorkKey
- this.$emit('loaded', this.firstWorkKey)
+ this.setCurrentKey(data)
+ this.$emit('loaded', this.currentNodeKey)
this.$emit('request', data)
})
}
})
},
- setCurrentKey(v) {
- if (this.firstWorkKey) return
- if (v.isWorkstation) {
- this.firstWorkKey = v.id
+ setCurrentKey(data) {
+ if(this.isSelectId) {
+ this.currentNodeKey = this.isSelectId;
+ }else {
+ this.currentNodeKey = data.find(v => v.isWorkstation && v.title.indexOf(this.word) > -1).id;
}
},
formatData(data, current) {
@@ -103,7 +147,7 @@
v.children = this.formatData(data, v).sort((a, b) => {
return b.sort - a.sort
})
- this.setCurrentKey(v)
+ // this.setCurrentKey(v)
return v
})
} else {
@@ -113,7 +157,7 @@
item.children = this.formatData(data, item).sort((a, b) => {
return b.sort - a.sort
})
- this.setCurrentKey(item)
+ // this.setCurrentKey(item)
return item
})
return res
@@ -129,6 +173,7 @@
},
checkChange(data, data1, data2) {
+ console.log('>>>>>>>')
if (this.getAll) {
return this.value = this.$refs.treeRef.getCheckedNodes().filter(v => v.isWorkstation)
}
@@ -139,9 +184,10 @@
</script>
<style lang="scss">
-.active .el-tree-node__content {
- background: var(--el-color-primary) !important;
+.is-current>.el-tree-node__content {
+ // background: var(--el-color-primary) !important;
}
+
a.disabled {
color: #ccc;
}
--
Gitblit v1.9.3