优化维修页面表格复选框问题

This commit is contained in:
BianLzhaoMin 2024-07-22 13:28:25 +08:00
parent 8027d196b2
commit f7ee959421
6 changed files with 407 additions and 396 deletions

View File

@ -366,6 +366,11 @@
width="55"
align="center"
v-if="repairTitle === '维修'"
:selectable="
(row) => {
return row.status == 1
}
"
/>
<el-table-column
label="类型名称"

View File

@ -1,218 +1,217 @@
<template>
<el-select
class="user-select-tree"
v-model="textStr"
:placeholder="placeholder"
ref="select"
:filterable="true"
:remote="true"
:remote-method="remoteMethod"
:clearable="clearable"
@clear="clearSelect"
@visible-change="visibleChange"
:popper-append-to-body="false"
style="width: 100%"
>
<el-option
v-model="value"
style="
height: 100%;
max-height: 200px;
overflow-y: auto;
padding: 0;
background-color: #ffffff;
"
<el-select
class="user-select-tree"
v-model="textStr"
:placeholder="placeholder"
ref="select"
:filterable="true"
:clearable="clearable"
@clear="clearSelect"
@visible-change="visibleChange"
:popper-append-to-body="false"
style="width: 100%"
>
<el-tree
:data="treeList"
:props="treeProps"
:filter-node-method="filterNode"
:current-node-key="currentKey"
highlight-current
default-expand-all
:node-key="nodeKey"
ref="selectTree"
:check-strictly="true"
@node-click="handleTreeClick"
>
<span
slot-scope="{ data }"
:title="data[treeProps.label]"
class="ellipsis"
<el-option
v-model="value"
style="
height: 100%;
max-height: 200px;
overflow-y: auto;
padding: 0;
background-color: #ffffff;
"
>
{{ data[treeProps.label] }}
</span>
</el-tree>
</el-option>
</el-select>
<el-tree
:data="treeList"
:props="treeProps"
:filter-node-method="filterNode"
:current-node-key="currentKey"
highlight-current
default-expand-all
:node-key="nodeKey"
ref="selectTree"
:check-strictly="true"
@node-click="handleTreeClick"
>
<span
slot-scope="{ data }"
:title="data[treeProps.label]"
class="ellipsis"
>
{{ data[treeProps.label] }}
</span>
</el-tree>
</el-option>
</el-select>
</template>
<script>
export default {
name: 'index',
props: {
treeList: {
type: Array
}, //
treeProps: Object, //
nodeKey: String, //
defaultSelect: {
//
type: Boolean,
default: true
name: 'index',
props: {
treeList: {
type: Array,
}, //
treeProps: Object, //
nodeKey: String, //
defaultSelect: {
//
type: Boolean,
default: true,
},
defaultData: {
type: Object,
default: null,
},
clearable: { type: Boolean, default: false },
placeholder: { type: String, default: '请选择' },
},
defaultData: {
type: Object,
default: null
},
clearable: { type: Boolean, default: false },
placeholder: { type: String, default: '请选择' }
},
data() {
return {
textStr: '',
value: '',
filterText: '',
currentKey: '',
highlightNode: -1
}
},
watch: {
// clearable(val) {
// console.log('val-----', val);
// },
clearable: {
handler: function(val,old) {
},
// obj.name
immediate: true
},
filterText(val) {
this.$refs.selectTree.filter(val)
},
defaultData(val) {
if (this.highlightNode === -1) {
this.setEdit(val)
}
},
treeList(val) {
if (val.length > 0) {
this.$nextTick(() => {
if (this.defaultSelect) {
this.value = val[0][this.treeProps.children][0][this.nodeKey]
this.textStr =
val[0][this.treeProps.children][0][this.treeProps.label]
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$emit('handleNodeClick', this.value)
}
})
}
}
},
methods: {
setEdit(obj) {
if (obj.name !== '' && obj.value !== '') {
this.value = obj.value
this.textStr = obj.name
this.$nextTick(() => {
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
})
}
},
visibleChange() {
this.filterText = ''
},
filterNode(value, data) {
if (!value) return true
return data[this.treeProps.label].indexOf(value) !== -1
},
remoteMethod(query) {
setTimeout(() => {
this.filterText = query
}, 100)
},
//
handleTreeClick(data, checked) {
this.filterText = ''
if (checked) {
// //
if (
data[this.treeProps.children] !== undefined &&
data[this.treeProps.children].length !== 0
) {
this.$refs.selectTree.setCurrentKey(this.highlightNode)
} else {
this.value = data[this.nodeKey]
this.textStr = data[this.treeProps.label]
this.$forceUpdate()
this.currentKey = this.value
this.highlightNode = data[this.nodeKey]
this.$emit('handleNodeClick', this.value)
this.$refs.selectTree.setCheckedKeys([this.highlightNode])
this.$refs.select.blur()
data() {
return {
textStr: '',
value: '',
filterText: '',
currentKey: '',
highlightNode: -1,
}
}
},
clearFun() {
this.value = null
this.textStr = null
this.currentKey = undefined
this.highlightNode = undefined
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$refs.select.clearSingleSelect()
// this.value = ''
// this.textStr = ''
// this.currentKey = undefined
// this.highlightNode = undefined
// this.$refs.selectTree.setCurrentKey(this.highlightNode)
watch: {
// clearable(val) {
// console.log('val-----', val);
// },
clearable: {
handler: function (val, old) {},
// obj.name
immediate: true,
},
filterText(val) {
this.$refs.selectTree.filter(val)
},
defaultData(val) {
if (this.highlightNode === -1) {
this.setEdit(val)
}
},
treeList(val) {
if (val.length > 0) {
this.$nextTick(() => {
if (this.defaultSelect) {
this.value =
val[0][this.treeProps.children][0][this.nodeKey]
this.textStr =
val[0][this.treeProps.children][0][
this.treeProps.label
]
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$emit('handleNodeClick', this.value)
}
})
}
},
},
methods: {
setEdit(obj) {
if (obj.name !== '' && obj.value !== '') {
this.value = obj.value
this.textStr = obj.name
this.$nextTick(() => {
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
})
}
},
visibleChange() {
this.filterText = ''
},
filterNode(value, data) {
if (!value) return true
return data[this.treeProps.label].indexOf(value) !== -1
},
remoteMethod(query) {
setTimeout(() => {
this.filterText = query
}, 100)
},
//
handleTreeClick(data, checked) {
this.filterText = ''
if (checked) {
// //
if (
data[this.treeProps.children] !== undefined &&
data[this.treeProps.children].length !== 0
) {
this.$refs.selectTree.setCurrentKey(this.highlightNode)
} else {
this.value = data[this.nodeKey]
this.textStr = data[this.treeProps.label]
this.$forceUpdate()
this.currentKey = this.value
this.highlightNode = data[this.nodeKey]
this.$emit('handleNodeClick', this.value)
this.$refs.selectTree.setCheckedKeys([this.highlightNode])
this.$refs.select.blur()
}
}
},
clearFun() {
this.value = null
this.textStr = null
this.currentKey = undefined
this.highlightNode = undefined
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$refs.select.clearSingleSelect()
// this.value = ''
// this.textStr = ''
// this.currentKey = undefined
// this.highlightNode = undefined
// this.$refs.selectTree.setCurrentKey(this.highlightNode)
},
clearSelect() {
this.value = ''
this.textStr = ''
this.$refs.selectTree.setCurrentKey()
this.$emit('handleNodeClick', '')
},
},
clearSelect() {
this.value = ''
this.textStr = ''
this.$refs.selectTree.setCurrentKey()
this.$emit('handleNodeClick', '')
}
}
}
</script>
<style scoped lang="scss">
.user-select-tree {
::v-deep {
.el-icon-::before {
content: '\ea1b';
font-family: 'icomoon' !important;
display: inline-block;
-webkit-transform: scale(0.83);
font-size: 10px;
//width: 100%;
//height: 100%;
color: #666666;
pointer-events: none;
}
// ::v-deep {
// .el-icon-::before {
// content: '\ea1b';
// font-family: 'icomoon' !important;
// display: inline-block;
// -webkit-transform: scale(0.83);
// font-size: 10px;
// //width: 100%;
// //height: 100%;
// color: #666666;
// pointer-events: none;
// }
.el-input.is-focus {
.el-icon- {
transform: rotate(0deg);
}
}
// .el-input.is-focus {
// .el-icon- {
// transform: rotate(0deg);
// }
// }
.el-input__inner {
height: 36px;
line-height: 36px;
}
// .el-input__inner {
// height: 36px;
// line-height: 36px;
// }
.el-input__icon {
line-height: 36px;
}
// .el-input__icon {
// line-height: 36px;
// }
.el-tree-node__content {
height: 32px;
}
}
// .el-tree-node__content {
// height: 32px;
// }
// }
}
</style>

View File

@ -377,6 +377,11 @@
type="selection"
width="55"
align="center"
:selectable="
(row) => {
return row.status == 1
}
"
v-if="repairTitle === '维修'"
/>
<el-table-column

View File

@ -1,218 +1,217 @@
<template>
<el-select
class="user-select-tree"
v-model="textStr"
:placeholder="placeholder"
ref="select"
:filterable="true"
:remote="true"
:remote-method="remoteMethod"
:clearable="clearable"
@clear="clearSelect"
@visible-change="visibleChange"
:popper-append-to-body="false"
style="width: 100%"
>
<el-option
v-model="value"
style="
height: 100%;
max-height: 200px;
overflow-y: auto;
padding: 0;
background-color: #ffffff;
"
<el-select
class="user-select-tree"
v-model="textStr"
:placeholder="placeholder"
ref="select"
:filterable="true"
:clearable="clearable"
@clear="clearSelect"
@visible-change="visibleChange"
:popper-append-to-body="false"
style="width: 100%"
>
<el-tree
:data="treeList"
:props="treeProps"
:filter-node-method="filterNode"
:current-node-key="currentKey"
highlight-current
default-expand-all
:node-key="nodeKey"
ref="selectTree"
:check-strictly="true"
@node-click="handleTreeClick"
>
<span
slot-scope="{ data }"
:title="data[treeProps.label]"
class="ellipsis"
<el-option
v-model="value"
style="
height: 100%;
max-height: 200px;
overflow-y: auto;
padding: 0;
background-color: #ffffff;
"
>
{{ data[treeProps.label] }}
</span>
</el-tree>
</el-option>
</el-select>
<el-tree
:data="treeList"
:props="treeProps"
:filter-node-method="filterNode"
:current-node-key="currentKey"
highlight-current
default-expand-all
:node-key="nodeKey"
ref="selectTree"
:check-strictly="true"
@node-click="handleTreeClick"
>
<span
slot-scope="{ data }"
:title="data[treeProps.label]"
class="ellipsis"
>
{{ data[treeProps.label] }}
</span>
</el-tree>
</el-option>
</el-select>
</template>
<script>
export default {
name: 'index',
props: {
treeList: {
type: Array
}, //
treeProps: Object, //
nodeKey: String, //
defaultSelect: {
//
type: Boolean,
default: true
name: 'index',
props: {
treeList: {
type: Array,
}, //
treeProps: Object, //
nodeKey: String, //
defaultSelect: {
//
type: Boolean,
default: true,
},
defaultData: {
type: Object,
default: null,
},
clearable: { type: Boolean, default: false },
placeholder: { type: String, default: '请选择' },
},
defaultData: {
type: Object,
default: null
},
clearable: { type: Boolean, default: false },
placeholder: { type: String, default: '请选择' }
},
data() {
return {
textStr: '',
value: '',
filterText: '',
currentKey: '',
highlightNode: -1
}
},
watch: {
// clearable(val) {
// console.log('val-----', val);
// },
clearable: {
handler: function(val,old) {
},
// obj.name
immediate: true
},
filterText(val) {
this.$refs.selectTree.filter(val)
},
defaultData(val) {
if (this.highlightNode === -1) {
this.setEdit(val)
}
},
treeList(val) {
if (val.length > 0) {
this.$nextTick(() => {
if (this.defaultSelect) {
this.value = val[0][this.treeProps.children][0][this.nodeKey]
this.textStr =
val[0][this.treeProps.children][0][this.treeProps.label]
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$emit('handleNodeClick', this.value)
}
})
}
}
},
methods: {
setEdit(obj) {
if (obj.name !== '' && obj.value !== '') {
this.value = obj.value
this.textStr = obj.name
this.$nextTick(() => {
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
})
}
},
visibleChange() {
this.filterText = ''
},
filterNode(value, data) {
if (!value) return true
return data[this.treeProps.label].indexOf(value) !== -1
},
remoteMethod(query) {
setTimeout(() => {
this.filterText = query
}, 100)
},
//
handleTreeClick(data, checked) {
this.filterText = ''
if (checked) {
// //
if (
data[this.treeProps.children] !== undefined &&
data[this.treeProps.children].length !== 0
) {
this.$refs.selectTree.setCurrentKey(this.highlightNode)
} else {
this.value = data[this.nodeKey]
this.textStr = data[this.treeProps.label]
this.$forceUpdate()
this.currentKey = this.value
this.highlightNode = data[this.nodeKey]
this.$emit('handleNodeClick', this.value)
this.$refs.selectTree.setCheckedKeys([this.highlightNode])
this.$refs.select.blur()
data() {
return {
textStr: '',
value: '',
filterText: '',
currentKey: '',
highlightNode: -1,
}
}
},
clearFun() {
this.value = null
this.textStr = null
this.currentKey = undefined
this.highlightNode = undefined
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$refs.select.clearSingleSelect()
// this.value = ''
// this.textStr = ''
// this.currentKey = undefined
// this.highlightNode = undefined
// this.$refs.selectTree.setCurrentKey(this.highlightNode)
watch: {
// clearable(val) {
// console.log('val-----', val);
// },
clearable: {
handler: function (val, old) {},
// obj.name
immediate: true,
},
filterText(val) {
this.$refs.selectTree.filter(val)
},
defaultData(val) {
if (this.highlightNode === -1) {
this.setEdit(val)
}
},
treeList(val) {
if (val.length > 0) {
this.$nextTick(() => {
if (this.defaultSelect) {
this.value =
val[0][this.treeProps.children][0][this.nodeKey]
this.textStr =
val[0][this.treeProps.children][0][
this.treeProps.label
]
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$emit('handleNodeClick', this.value)
}
})
}
},
},
methods: {
setEdit(obj) {
if (obj.name !== '' && obj.value !== '') {
this.value = obj.value
this.textStr = obj.name
this.$nextTick(() => {
this.highlightNode = this.value
this.currentKey = this.value
this.$refs.selectTree.setCurrentKey(this.highlightNode)
})
}
},
visibleChange() {
this.filterText = ''
},
filterNode(value, data) {
if (!value) return true
return data[this.treeProps.label].indexOf(value) !== -1
},
remoteMethod(query) {
setTimeout(() => {
this.filterText = query
}, 100)
},
//
handleTreeClick(data, checked) {
this.filterText = ''
if (checked) {
// //
if (
data[this.treeProps.children] !== undefined &&
data[this.treeProps.children].length !== 0
) {
this.$refs.selectTree.setCurrentKey(this.highlightNode)
} else {
this.value = data[this.nodeKey]
this.textStr = data[this.treeProps.label]
this.$forceUpdate()
this.currentKey = this.value
this.highlightNode = data[this.nodeKey]
this.$emit('handleNodeClick', this.value)
this.$refs.selectTree.setCheckedKeys([this.highlightNode])
this.$refs.select.blur()
}
}
},
clearFun() {
this.value = null
this.textStr = null
this.currentKey = undefined
this.highlightNode = undefined
this.$refs.selectTree.setCurrentKey(this.highlightNode)
this.$refs.select.clearSingleSelect()
// this.value = ''
// this.textStr = ''
// this.currentKey = undefined
// this.highlightNode = undefined
// this.$refs.selectTree.setCurrentKey(this.highlightNode)
},
clearSelect() {
this.value = ''
this.textStr = ''
this.$refs.selectTree.setCurrentKey()
this.$emit('handleNodeClick', '')
},
},
clearSelect() {
this.value = ''
this.textStr = ''
this.$refs.selectTree.setCurrentKey()
this.$emit('handleNodeClick', '')
}
}
}
</script>
<style scoped lang="scss">
.user-select-tree {
::v-deep {
.el-icon-::before {
content: '\ea1b';
font-family: 'icomoon' !important;
display: inline-block;
-webkit-transform: scale(0.83);
font-size: 10px;
//width: 100%;
//height: 100%;
color: #666666;
pointer-events: none;
}
// ::v-deep {
// .el-icon-::before {
// content: '\ea1b';
// font-family: 'icomoon' !important;
// display: inline-block;
// -webkit-transform: scale(0.83);
// font-size: 10px;
// //width: 100%;
// //height: 100%;
// color: #666666;
// pointer-events: none;
// }
.el-input.is-focus {
.el-icon- {
transform: rotate(0deg);
}
}
// .el-input.is-focus {
// .el-icon- {
// transform: rotate(0deg);
// }
// }
.el-input__inner {
height: 36px;
line-height: 36px;
}
// .el-input__inner {
// height: 36px;
// line-height: 36px;
// }
.el-input__icon {
line-height: 36px;
}
// .el-input__icon {
// line-height: 36px;
// }
.el-tree-node__content {
height: 32px;
}
}
// .el-tree-node__content {
// height: 32px;
// }
// }
}
</style>

View File

@ -5,7 +5,10 @@
<el-table-column align="center" label="文件名称" prop="name" />
<el-table-column align="center" label="操作">
<template slot-scope="{ row }">
<a :href="`${filePreviewUrl}${row.url}`" target="_blank"
<a
:href="`${filePreviewUrl}${row.url}`"
target="_blank"
:download="row.name"
>查看</a
>
</template>

View File

@ -43,7 +43,7 @@ module.exports = {
// target: `https://test-cc.zhgkxt.com`,//线上环境-南网
// target: `https://z.csgmall.com.cn`,
target: `http://192.168.2.167:28080`, //超
target: `http://192.168.2.134:28080`, //超
// target: `http://10.40.92.81:28080`, //韩/
// target: `http://10.40.92.74:8080`,//旭/
// target: `http://192.168.2.248:28080`, //帅