This commit is contained in:
parent
809f413386
commit
ce1618bb85
|
|
@ -328,6 +328,8 @@ export default {
|
|||
let start = new Date()
|
||||
start.setMonth(start.getMonth() - 1)
|
||||
this.queryParams.time = [this.format(start), this.format(end)]
|
||||
// 设置默认状态为第一个选项(未完成)
|
||||
this.queryParams.taskStatus = '1'
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@
|
|||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import PageHeaderApply from "@/components/pageHeaderApply";
|
||||
import Home from "./component/homeApply.vue"; // 主列表
|
||||
import AddTools from "./component/addToolsApply.vue"; // 发布
|
||||
import QueryTools from "./component/queryToolsApply.vue"; // 查询机具
|
||||
import QueryTools from "./component/queryToolsApply.vue"; // 查询机具
|
||||
export default {
|
||||
name: "LeasePublish",
|
||||
components: {
|
||||
|
|
@ -85,4 +85,4 @@ export default {
|
|||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -121,7 +121,18 @@
|
|||
:popper-class="'type-select-dropdown'"
|
||||
:popper-append-to-body="false"
|
||||
@visible-change="handleVisibleChange"
|
||||
@focus="handleSelectFocus"
|
||||
:loading="typeInitialLoading"
|
||||
loading-text="加载中..."
|
||||
>
|
||||
<el-option
|
||||
v-if="!typeDataLoaded && !typeInitialLoading"
|
||||
key="loading-placeholder"
|
||||
label="点击加载类型规格数据..."
|
||||
value=""
|
||||
disabled
|
||||
>
|
||||
</el-option>
|
||||
<el-option
|
||||
v-for="item in filteredOptions"
|
||||
:key="item.typeId"
|
||||
|
|
@ -472,6 +483,12 @@ export default {
|
|||
keepSelectOpen: false, // 控制下拉框是否保持打开
|
||||
isSearching: false, // 添加搜索状态标记
|
||||
|
||||
// 懒加载相关状态
|
||||
typeDataLoaded: false, // 类型数据是否已加载
|
||||
typeLoadingTimer: null, // 延迟加载定时器
|
||||
typeInitialLoading: false, // 初始加载状态
|
||||
hasInitialized: false, // 是否已初始化
|
||||
|
||||
//是否是分包商
|
||||
isFileFbs:false,
|
||||
urlTemp: '',
|
||||
|
|
@ -507,14 +524,14 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
this.projectInfoList();//单位工程下拉选
|
||||
this.equipmentType();//机具类型下拉选
|
||||
// this.equipmentType();//机具类型下拉选 - 改为懒加载
|
||||
this.getStandardConfigListFn() // 获取标准配置
|
||||
if (this.isEdit) {
|
||||
console.log("isEdit", this.isEdit);
|
||||
this.taskId = this.editTaskId;
|
||||
this.id = this.editId;
|
||||
this.getTaskInfo();
|
||||
this.equipmentType();
|
||||
// this.equipmentType(); - 在getTaskInfo中按需加载
|
||||
}
|
||||
// this.projectInfoList();
|
||||
// this.equipmentType();
|
||||
|
|
@ -597,20 +614,67 @@ export default {
|
|||
// this.$set(item, 'supplierId', supplierId)
|
||||
// })
|
||||
// },
|
||||
/** 机具类型 */
|
||||
equipmentType() {
|
||||
equipmentTypeTree().then((response) => {
|
||||
this.equipmentTypeList = response.data;
|
||||
// 处理并扁平化所有类型数据
|
||||
this.flattenTypeOptions = this.processTypeData(response.data);
|
||||
// 初始显示所有选项
|
||||
this.filteredOptions = [...this.flattenTypeOptions];
|
||||
/** 机具类型 - 懒加载版本 */
|
||||
async equipmentType(forceLoad = false) {
|
||||
// 如果数据已加载且不是强制加载,直接返回
|
||||
if (this.typeDataLoaded && !forceLoad) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 反显选中数据
|
||||
if (this.equipmentList.length > 0) {
|
||||
this.deviceType = this.equipmentList.map(item => item.typeId);
|
||||
try {
|
||||
this.typeInitialLoading = true;
|
||||
const response = await equipmentTypeTree();
|
||||
|
||||
// 使用 requestIdleCallback 在空闲时处理数据,避免阻塞主线程
|
||||
if (window.requestIdleCallback) {
|
||||
window.requestIdleCallback(() => {
|
||||
this.processEquipmentTypeData(response.data);
|
||||
});
|
||||
} else {
|
||||
// 降级方案:使用 setTimeout
|
||||
setTimeout(() => {
|
||||
this.processEquipmentTypeData(response.data);
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('加载机具类型数据失败:', error);
|
||||
this.$message.error('加载机具类型数据失败');
|
||||
} finally {
|
||||
this.typeInitialLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 处理机具类型数据
|
||||
processEquipmentTypeData(data) {
|
||||
this.equipmentTypeList = data;
|
||||
// 处理并扁平化所有类型数据
|
||||
this.flattenTypeOptions = this.processTypeData(data);
|
||||
// 初始显示所有选项
|
||||
this.filteredOptions = [...this.flattenTypeOptions];
|
||||
this.typeDataLoaded = true;
|
||||
|
||||
// 反显选中数据
|
||||
if (this.equipmentList.length > 0) {
|
||||
this.deviceType = this.equipmentList.map(item => item.typeId);
|
||||
}
|
||||
},
|
||||
|
||||
// 延迟加载类型数据
|
||||
lazyLoadTypeData() {
|
||||
// 清除之前的定时器
|
||||
if (this.typeLoadingTimer) {
|
||||
clearTimeout(this.typeLoadingTimer);
|
||||
}
|
||||
|
||||
// 如果数据已加载,直接返回
|
||||
if (this.typeDataLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置延迟加载
|
||||
this.typeLoadingTimer = setTimeout(() => {
|
||||
this.equipmentType();
|
||||
}, 300); // 300ms 延迟
|
||||
},
|
||||
// 获取标准配置
|
||||
async getStandardConfigListFn() {
|
||||
|
|
@ -688,6 +752,12 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
// 确保数据已加载
|
||||
if (!this.typeDataLoaded) {
|
||||
this.lazyLoadTypeData();
|
||||
return;
|
||||
}
|
||||
|
||||
const lowercaseQuery = query.toLowerCase();
|
||||
this.filteredOptions = this.flattenTypeOptions.filter(item =>
|
||||
item.searchKey.includes(lowercaseQuery) ||
|
||||
|
|
@ -698,6 +768,13 @@ export default {
|
|||
handleTypeChange(val) {
|
||||
if (!val || val.length === 0) return;
|
||||
|
||||
// 确保数据已加载
|
||||
if (!this.typeDataLoaded) {
|
||||
this.$message.warning('类型数据正在加载中,请稍后再试');
|
||||
this.tempDeviceType = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取新选中的项
|
||||
const lastSelected = val[val.length - 1];
|
||||
const typeData = this.flattenTypeOptions.find(item => item.typeId === lastSelected);
|
||||
|
|
@ -750,6 +827,11 @@ export default {
|
|||
}
|
||||
// this.loading = false;
|
||||
});
|
||||
|
||||
// 如果有设备列表,需要加载类型数据来正确显示
|
||||
if (this.equipmentList.length > 0) {
|
||||
await this.equipmentType(true); // 强制加载
|
||||
}
|
||||
// await this.projectInfoList();
|
||||
},
|
||||
checkNum(row) {
|
||||
|
|
@ -1144,7 +1226,7 @@ export default {
|
|||
downloadFile({fileName: file.name, fileData: file.raw, fileType: 'application/vnd.ms-excel;charset=utf-8'})
|
||||
} else if (file.status === 'success') {
|
||||
|
||||
downloadFileData({fileName: file.name, fileUrl: file.url})
|
||||
downloadFileData({ fileName: file.name,fileUrl:file.url })
|
||||
// downloadFileData({ fileName: file.name,fileUrl:file.url })
|
||||
}
|
||||
},
|
||||
|
|
@ -1159,6 +1241,11 @@ export default {
|
|||
|
||||
// 处理下拉框可见性变化
|
||||
handleVisibleChange(visible) {
|
||||
if (visible) {
|
||||
// 下拉框打开时触发懒加载
|
||||
this.lazyLoadTypeData();
|
||||
}
|
||||
|
||||
if (!visible && this.keepSelectOpen && !this.isSearching) {
|
||||
// 只有在非搜索状态下才重新打开下拉框
|
||||
this.$nextTick(() => {
|
||||
|
|
@ -1190,6 +1277,13 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
// 处理下拉框获得焦点
|
||||
handleSelectFocus() {
|
||||
this.isSearching = false;
|
||||
// 触发懒加载
|
||||
this.lazyLoadTypeData();
|
||||
},
|
||||
|
||||
// 高亮搜索处理
|
||||
handleHighlightSearch() {
|
||||
this.isSearching = true;
|
||||
|
|
@ -1201,6 +1295,12 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
// 确保数据已加载
|
||||
if (!this.typeDataLoaded) {
|
||||
this.lazyLoadTypeData();
|
||||
return;
|
||||
}
|
||||
|
||||
// 找到所有匹配项
|
||||
this.matchedOptions = this.filteredOptions.filter(item =>
|
||||
item.fullPath.toLowerCase().includes(this.searchKeyword.toLowerCase())
|
||||
|
|
@ -1230,6 +1330,12 @@ export default {
|
|||
beforeDestroy() {
|
||||
this.keepSelectOpen = false;
|
||||
this.isSearching = false;
|
||||
|
||||
// 清理定时器
|
||||
if (this.typeLoadingTimer) {
|
||||
clearTimeout(this.typeLoadingTimer);
|
||||
this.typeLoadingTimer = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -1281,22 +1387,18 @@ export default {
|
|||
color: #000;
|
||||
}
|
||||
|
||||
::v-deep .el-input-group__append {
|
||||
padding: 0;
|
||||
.el-button {
|
||||
padding: 0 10px;
|
||||
border: none;
|
||||
height: 100%;
|
||||
&:first-child {
|
||||
border-right: 1px solid #dcdfe6;
|
||||
}
|
||||
&[disabled] {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
}
|
||||
::v-deep .el-select-dropdown__item.is-disabled {
|
||||
color: #409eff;
|
||||
cursor: pointer;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.type-select-dropdown {
|
||||
::v-deep .el-select .el-input.is-focus .el-input__inner {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
::v-deep .type-select-dropdown {
|
||||
.el-select-dropdown__wrap {
|
||||
max-height: 400px !important;
|
||||
}
|
||||
|
|
@ -1310,7 +1412,7 @@ export default {
|
|||
}
|
||||
|
||||
|
||||
.el-input-group__append {
|
||||
::v-deep .el-input-group__append {
|
||||
padding: 0;
|
||||
.el-button {
|
||||
padding: 0 10px;
|
||||
|
|
|
|||
|
|
@ -528,10 +528,23 @@ export default {
|
|||
start.setMonth(start.getMonth() - 1)
|
||||
this.queryParams.time = [this.format(start), this.format(end)]
|
||||
// this.getStatusList();
|
||||
this.getList()
|
||||
// 不在这里直接调用getList,等字典数据加载完成后再调用
|
||||
// this.getTypeList()
|
||||
},
|
||||
methods: {
|
||||
// 字典数据加载完成后的回调
|
||||
onDictReady(dict) {
|
||||
// 获取lease_task_status的所有选项
|
||||
const validOptions = dict.type.lease_task_status || []
|
||||
|
||||
// 如果有有效选项,设置第一个为默认值
|
||||
if (validOptions.length > 0) {
|
||||
this.queryParams.taskStatus = validOptions[0].value
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
this.getList()
|
||||
},
|
||||
// getTypeList() {
|
||||
// getTypeList({ level: '3' }).then((response) => {
|
||||
// this.typesList = response.data
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@
|
|||
<el-button icon="el-icon-refresh" size="mini" @click="resetQueryOutView">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="getListOutInfo" width="600px" height="450">
|
||||
<el-table v-loading="loadingView" :data="getListOutInfo" width="600px" height="450">
|
||||
<el-table-column label="类型名称" align="center" prop="maTypeName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="规格型号" align="center" prop="typeName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="计量单位" align="center" prop="unitName" :show-overflow-tooltip="true" />
|
||||
|
|
@ -686,6 +686,7 @@ export default {
|
|||
// 遮罩层
|
||||
loading: true,
|
||||
loadingTwo: false,
|
||||
loadingView: false, // 查看弹窗的加载状态
|
||||
//查看的显示
|
||||
showOutView: false,
|
||||
//出库的显示
|
||||
|
|
@ -783,9 +784,22 @@ export default {
|
|||
let start = new Date()
|
||||
start.setMonth(start.getMonth() - 1)
|
||||
this.queryParams.time = [this.format(start), this.format(end)]
|
||||
this.getList()
|
||||
// 不在这里直接调用getList,等字典数据加载完成后再调用
|
||||
},
|
||||
methods: {
|
||||
// 字典数据加载完成后的回调
|
||||
onDictReady(dict) {
|
||||
// 获取过滤后的状态选项(排除值为1和2的选项)
|
||||
const validOptions = dict.type.lease_task_status.filter(item => item.value != 1 && item.value != 2)
|
||||
|
||||
// 如果有有效选项,设置第一个为默认值
|
||||
if (validOptions.length > 0) {
|
||||
this.queryParams.taskStatus = validOptions[0].value
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
this.getList()
|
||||
},
|
||||
format(date) {
|
||||
const y = date.getFullYear()
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||
|
|
@ -859,9 +873,12 @@ export default {
|
|||
this.queryOutView.keyWord = ''
|
||||
this.showOutView = true
|
||||
this.queryOutView.id = row.id
|
||||
this.loadingView = true // 开启加载动画
|
||||
outInfoList(id, { keyWord: this.queryOutView.keyWord, publishTask }).then(response => {
|
||||
this.getListOutInfo = response.data.leaseApplyDetailsList
|
||||
// this.loading = false;
|
||||
this.loadingView = false // 关闭加载动画
|
||||
}).catch(() => {
|
||||
this.loadingView = false // 请求失败时也要关闭加载动画
|
||||
})
|
||||
},
|
||||
//查看
|
||||
|
|
@ -874,13 +891,15 @@ export default {
|
|||
this.getListView()
|
||||
},
|
||||
getListView() {
|
||||
this.loadingView = true // 开启加载动画
|
||||
outInfoList(this.queryOutView.id, {
|
||||
keyWord: this.queryOutView.keyWord,
|
||||
publishTask: this.publishTask
|
||||
}).then(response => {
|
||||
this.getListOutInfo = response.data.leaseApplyDetailsList
|
||||
// this.dialogTotal = response.
|
||||
// this.loading = false;
|
||||
this.loadingView = false // 关闭加载动画
|
||||
}).catch(() => {
|
||||
this.loadingView = false // 请求失败时也要关闭加载动画
|
||||
})
|
||||
},
|
||||
/** 出库查询列表 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue