From 19aff1ac87030b21d2b01cdca5d5604c840ba7c0 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期一, 21 七月 2025 21:36:31 +0800 Subject: [PATCH] 维修工单 --- src/views/system/modules/SelectDeviceDrawer.vue | 117 +++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 78 insertions(+), 39 deletions(-) diff --git a/src/views/system/modules/SelectDeviceDrawer.vue b/src/views/system/modules/SelectDeviceDrawer.vue index 5d49708..911a41a 100644 --- a/src/views/system/modules/SelectDeviceDrawer.vue +++ b/src/views/system/modules/SelectDeviceDrawer.vue @@ -2,7 +2,7 @@ <a-drawer :title="title" :visible="visible" - width="650" + width="500" @ok="handleOk" @close="handleCancel" > @@ -10,10 +10,21 @@ <a-spin :spinning="loading"> <!-- showLine --> <a-form> + <a-form-item> + <a-input-search @search="handleSearch" style="width:100%;" placeholder="妫�绱� 绫诲埆缂栫爜/鍚嶇О" allowClear + v-model="searchInput" @change="handleChange"/> + </a-form-item> <a-form-item label="杞﹂棿灞傜骇锛�"> - <a-tree showLine ref="tree" :expandedKeys.sync="expandedKeys" + <a-tree showLine ref="tree" :expandedKeys.sync="expandedKeys" :autoExpandParent="autoExpandParent" :treeData="treeDataSource" checkable @check="onCheck" v-model="checkedKeys" @expand="onExpand"> + <template slot="title" slot-scope="{ title, parentId, entity, key}"> + <span v-if="title.indexOf(searchValue) > -1">{{ title.substr(0, title.indexOf(searchValue)) }} + <span class="replaceSearch">{{ searchValue }}</span> + {{ title.substr(title.indexOf(searchValue) + searchValue.length) }} + </span> + <span v-else>{{ title }}</span> + </template> </a-tree> </a-form-item> </a-form> @@ -78,11 +89,14 @@ }, data() { return { + searchInput: '', + searchValue: '', cardLoading: false, loading: false, treeDataSource: [], expandedKeys: [], checkedKeys: [], + autoExpandParent: true, url: { getBaseTree: '/mdc/mdcEquipment/queryTreeListByProduction' }, @@ -110,10 +124,9 @@ if (res.success) { this.dataList = [] this.allTreeKeys = [] - this.getTreeDataSouce(res.result) + this.getTreeDataSource(res.result) this.treeDataSource = res.result this.generateList(this.treeDataSource) - console.log('treeDataSource', this.treeDataSource) this.expandedKeys = this.allTreeKeys } else { this.$message.warn(res.message) @@ -140,10 +153,65 @@ } }, - getTreeDataSouce(data) { + handleChange() { + let search = this.searchInput + let expandedKeys = this.dataList + .map(item => { + if (item.title != null) { + if (item.title.indexOf(search) > -1) { + return this.getParentKey(item.key, this.treeDataSource) + } + return null + } + }) + .filter((item, i, self) => item && self.indexOf(item) === i) + Object.assign(this, { + expandedKeys, + searchValue: search, + autoExpandParent: true + }) + }, + + handleSearch(value) { + let search = value + let expandedKeys = this.dataList + .map(item => { + + if (item.title != null) { + if (item.title.indexOf(search) > -1) { + return this.getParentKey(item.key, this.treeDataSource) + } + return null + } + }) + .filter((item, i, self) => item && self.indexOf(item) === i) + Object.assign(this, { + expandedKeys, + searchValue: search, + autoExpandParent: true + }) + }, + + getParentKey(key, tree) { + let parentKey + for (let i = 0; i < tree.length; i++) { + const node = tree[i] + if (node.children) { + if (node.children.some(item => item.key === key)) { + parentKey = node.key + } else if ( + this.getParentKey(key, node.children)) { + parentKey = this.getParentKey(key, node.children) + } + } + } + return parentKey + }, + + getTreeDataSource(data) { data.forEach(item => { if (item.children && item.children.length > 0) { - this.getTreeDataSouce(item.children) + this.getTreeDataSource(item.children) } item.key = item.equipmentId ? item.equipmentId : item.key item.value = item.equipmentId ? item.equipmentId : item.value @@ -176,39 +244,10 @@ } </script> <style lang="less" scoped> - /deep/ .ant-modal { - /*transform-origin: 337px 50px;*/ - } - - .ant-card-body .table-operator { - margin-bottom: 18px; - } - - .ant-table-tbody .ant-table-row td { - padding-top: 15px; - padding-bottom: 15px; - } - - .anty-row-operator button { - margin: 0 5px - } - - .ant-btn-danger { - background-color: #ffffff - } - - .ant-modal-cust-warp { - height: 100% - } - - .ant-modal-cust-warp .ant-modal-body { - height: calc(100% - 110px) !important; - overflow-y: auto - } - - .ant-modal-cust-warp .ant-modal-content { - height: 90% !important; - overflow-y: hidden + .replaceSearch { + color: #40a9ff; + font-weight: bold; + background-color: rgb(204, 204, 204); } .drawer-bottom-button { -- Gitblit v1.9.3