From 12ff398d25cacaef245f87e0cad2fbb002a1100b Mon Sep 17 00:00:00 2001 From: monkeyhouyi Date: Wed, 30 Oct 2024 15:19:53 +0800 Subject: [PATCH] 优化 --- src/main.js | 16 ++-------------- src/utils/loadmore.js | 10 ++++++++++ src/views/DisposalSuggestions/index.vue | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------- src/views/baseCaseHandling/Form.vue | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- src/views/baseCaseHandling/index.vue | 12 +++++++++--- src/views/baseInspectionReport/Form.vue | 37 ++++++++++++++++++++++++++++++------- src/views/baseInspectionReport/index.vue | 5 +++-- src/views/baseListHazardousSamples/index.vue | 27 ++++++++++++++++++++++++++- 8 files changed, 178 insertions(+), 41 deletions(-) create mode 100644 src/utils/loadmore.js diff --git a/src/main.js b/src/main.js index 980ed2c..630e9e5 100644 --- a/src/main.js +++ b/src/main.js @@ -19,6 +19,7 @@ import store from './store' import './permission' import moment from "moment"; import i18n from './lang' // internationalization +import selectLoadMore from '@/utils/loadmore.js'; Vue.config.productionTip = false @@ -44,20 +45,7 @@ Object.keys(filters).forEach(key => { }) Vue.config.productionTip = false - -Vue.directive('loadMore', { - bind(el, binding) { - // 获取element-ui定义好的scroll盒子 - const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap') - SELECTWRAP_DOM.addEventListener('scroll', function () { - - const CONDITION = this.scrollHeight - this.scrollTop <= this.clientHeight - if (CONDITION) { - binding.value() - } - }) - } -}) +Vue.directive('selectLoadMore', selectLoadMore) Vue.directive('removeAriaHidden', { bind(el, binding) { let ariaEls = el.querySelectorAll('.el-radio__original'); diff --git a/src/utils/loadmore.js b/src/utils/loadmore.js new file mode 100644 index 0000000..e30aa6d --- /dev/null +++ b/src/utils/loadmore.js @@ -0,0 +1,10 @@ +export default { + bind(el, binding) { + const selectDom = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap') + selectDom.addEventListener('scroll', () => { + if (selectDom.scrollHeight - selectDom.scrollTop <= selectDom.clientHeight + 20) { + binding.value() + } + }) + } +}; \ No newline at end of file diff --git a/src/views/DisposalSuggestions/index.vue b/src/views/DisposalSuggestions/index.vue index f06ea42..dcadd8c 100644 --- a/src/views/DisposalSuggestions/index.vue +++ b/src/views/DisposalSuggestions/index.vue @@ -68,6 +68,21 @@ 导出 + 导出处理模板 + +
+ 批量上报 +
+
@@ -79,7 +94,7 @@ - + @@ -216,13 +231,19 @@ export default { }); this.sourceOptions = data; }, + getTime() { + if(!this.query.creatorTime) return; + return { + startTime: this.query.creatorTime[0] || '', + endTime: this.query.creatorTime[1] || '', + } + }, initData() { this.listLoading = true; let _query = { ...this.listQuery, ...this.query, - startTime: this.query.creatorTime[0] || '', - endTime: this.query.creatorTime[1] || '', + ...this.getTime() }; let query = {}; for (let key in _query) { @@ -344,16 +365,33 @@ export default { link.click(); }); }, - uploadSuccess(response, file, fileList) { - this.$message({ - showClose: true, - message: response.msg, - type: response.code == 200 ? 'success' : 'error', - close: () => { - response.code == 200 && this.initData(); - } + exportMakeDemo() { + let obj = { + url: '/Extend/BaseInspectionReport/Actions/GenerateImportTemplateBatchReport', + method: "GET", + responseType: 'blob', + }; + request(obj).then((res) => { + const blob = new Blob([res], {type: 'application/json'}); + const url = window.URL.createObjectURL(blob); + let link = document.createElement('a'); + link.style.display = 'none'; + link.href = url; + link.download = '处理表单模板.xlsx'; + link.click(); }); }, + uploadSuccess(response, file, fileList) { + if(response.code == 200) { + this.$message({ + message: response.msg, + type: 'success' + }); + } else { + this.$message.error(response.msg); + } + response.code == 200 && this.initData(); + }, uploadError() { console.log('erroe'); }, diff --git a/src/views/baseCaseHandling/Form.vue b/src/views/baseCaseHandling/Form.vue index edf0b08..e8a172a 100644 --- a/src/views/baseCaseHandling/Form.vue +++ b/src/views/baseCaseHandling/Form.vue @@ -45,11 +45,15 @@ style="width: 100%" @blur.native.capture="selectCompanyBlur" @visible-change="visibleNameCompanyChange" - :disabled="formType != 0" @change="(val) => companyChange(val, 'change')" + :disabled="formType != 0" + v-selectLoadMore="moreCompanyList" + :loading="name_loading" + :teleported="false" + :filter-method="filterMethod" > - + @@ -432,6 +438,9 @@ export default { btnLoading: false, companyOptions: [], platformTypeOptions: [], + company_currentPage: 20, + name_loading: false, + system_currentPage: 20, }; }, computed: { @@ -463,6 +472,23 @@ export default { this.companyOptions = data; }) }, + moreCompanyList() { + if(this.company_currentPage > this.companyOptions.length) return; + this.company_currentPage += 10; + }, + async filterMethod(val) { + this.company_currentPage = 20; + this.name_loading = true + let companyRes = await request({ + url: `/Extend/basecomapnyinfo/GetNoPagingList`, + method: "GET", + params: { + companyName: val + } + }); + this.companyOptions = companyRes.data; + this.name_loading = false; + }, // 获取系统列表 getSystemSelect(companyId) { this.system_loading = true; @@ -475,6 +501,26 @@ export default { this.system_loading = false; }) }, + moreSystemList() { + if(this.system_currentPage > this.systemOption.length) return; + this.system_currentPage += 10; + }, + async filterMethod_system(val) { + this.system_currentPage = 0; + this.system_loading = true; + this.systemOption.filter.includes + request({ + url: "/Extend/basesysteminfo/GetNoPagingList", + method: "get", + params: { + companyId: this.dataForm.registeredEntity, + systemName: val, + } + }).then(({data}) => { + this.systemOption = data; + this.system_loading = false; + }) + }, selectBlur(e) { let value = e.target.value; if(!value) return; diff --git a/src/views/baseCaseHandling/index.vue b/src/views/baseCaseHandling/index.vue index c2db541..55a1e32 100644 --- a/src/views/baseCaseHandling/index.vue +++ b/src/views/baseCaseHandling/index.vue @@ -183,7 +183,7 @@ export default { }, }, created() { - this.initSystemOptions(); + // this.initSystemOptions(); this.initSystemTypeList(); this.initAreaTypeList(); this.initStateTypeOption(); @@ -203,13 +203,19 @@ export default { this.listQuery.sidx = !order ? "" : prop; this.initData(); }, + getTime() { + if(!this.query.registrationTime) return; + return { + startTime: this.query.registrationTime[0] || '', + endTime: this.query.registrationTime[1] || '', + } + }, initData() { this.listLoading = true; let _query = { ...this.listQuery, ...this.query, - startTime: this.query.registrationTime[0] || '', - endTime: this.query.registrationTime[1] || '', + ...this.getTime() }; let query = {}; for (let key in _query) { diff --git a/src/views/baseInspectionReport/Form.vue b/src/views/baseInspectionReport/Form.vue index 0e812ec..fdace34 100644 --- a/src/views/baseInspectionReport/Form.vue +++ b/src/views/baseInspectionReport/Form.vue @@ -45,8 +45,12 @@ @visible-change="visibleNameCompanyChange" @change="(val) => companyChange(val, 'change')" :disabled='!!this.dataForm.id' + v-selectLoadMore="initCompanyList" + :loading="name_loading" + :teleported="false" + :filter-method="filterMethod" > - + @@ -62,9 +66,11 @@ @blur.native.capture="selectBlur" @visible-change="visibleNameChange" @change="(val) => platformNameChange(val, 'change')" - :loading="name_loading" + v-selectLoadMore="moreSystemList" + :teleported="false" + :loading="system_loading" :disabled="!!this.dataForm.id || !dataForm.company"> - + @@ -364,6 +370,10 @@ export default { companyOptions: [], btnLoading: false, areaOptions: [], + company_currentPage: 20, + system_loading: false, + system_currentPage: 20, + system_loading: false, }; }, computed: { @@ -402,12 +412,21 @@ export default { // this.name_loading = false; }, async initCompanyList() { - request({ + if(this.company_currentPage > this.companyOptions.length) return; + this.company_currentPage += 10; + }, + async filterMethod(val) { + this.company_currentPage = 20; + this.name_loading = true + let companyRes = await request({ url: `/Extend/basecomapnyinfo/GetNoPagingList`, method: "GET", - }).then(({data}) => { - this.companyOptions = data; - }) + params: { + companyName: val + } + }); + this.companyOptions = companyRes.data; + this.name_loading = false; }, selectBlur(e) { let value = e.target.value; @@ -474,6 +493,10 @@ export default { this.name_loading = false; }) }, + moreSystemList() { + if(this.system_currentPage > this.nameOptions.length) return; + this.system_currentPage += 10; + }, async getplatformTypeOptions() { let list = this.$store.state.meta.system; !list && (list = await this.$store.dispatch("getTypeListByCode", "system")); diff --git a/src/views/baseInspectionReport/index.vue b/src/views/baseInspectionReport/index.vue index aa01f84..d7ae019 100644 --- a/src/views/baseInspectionReport/index.vue +++ b/src/views/baseInspectionReport/index.vue @@ -59,6 +59,7 @@
导出 + @@ -229,7 +230,7 @@ let obj = {} if(type) { obj = { - url: '/Extend/BaseInspectionReport/Actions/GenerateImportTemplate', + url: type == 'demo' ? '/Extend/BaseInspectionReport/Actions/GenerateImportTemplate' : '/Extend/BaseInspectionReport/Actions/GenerateImportTemplateBatchReport', method: "GET", responseType: 'blob', } @@ -262,7 +263,7 @@ let link = document.createElement('a'); link.style.display = 'none'; link.href = url; - link.download = '线索录入模板.xlsx'; + link.download = type == 'demo' ? '线索录入模板.xlsx' : '处理表单模板.xlsx'; link.click(); } else { if(res.code != 200) return; diff --git a/src/views/baseListHazardousSamples/index.vue b/src/views/baseListHazardousSamples/index.vue index 80fabe7..a18c5e6 100644 --- a/src/views/baseListHazardousSamples/index.vue +++ b/src/views/baseListHazardousSamples/index.vue @@ -42,9 +42,14 @@ v-model="query.company" placeholder="请选择运营主体" clearable + filterable + v-selectLoadMore="moreCompanyList" + :loading="name_loading" + :teleported="false" + :filter-method="filterMethod" > { this.companyOptions = data; + this.name_loading = false; + }) + }, + moreCompanyList() { + if(this.company_currentPage > this.companyOptions.length) return + this.company_currentPage += 10; + }, + filterMethod(val) { + this.company_currentPage = 20; + this.name_loading = true; + request({ + url: `/Extend/basecomapnyinfo/GetNoPagingList`, + method: "GET", + params: { companyName: val } + }).then(({data}) => { + this.companyOptions = data; + this.name_loading = false; }) }, initData() { -- libgit2 0.21.4