From 00fb4a73928140455fe001e665a7f0a08fc49500 Mon Sep 17 00:00:00 2001 From: lilu Date: Tue, 14 Mar 2023 17:34:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B0=E8=B4=A6=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/getters.js | 1 + src/store/modules/user.js | 13 ++- .../detail/modules/operationArea.vue | 1 - .../detail/modules/rightContent.vue | 1 - src/views/main/BookingLedger/list/index.vue | 95 +++++-------------- 5 files changed, 39 insertions(+), 72 deletions(-) diff --git a/src/store/getters.js b/src/store/getters.js index ac48d03..90effe3 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -17,6 +17,7 @@ const getters = { multiTab: state => state.app.multiTab, lang: state => state.i18n.lang, bookingList: state => state.user.bookingList, + bookingGridOptions: state => state.user.bookingGridOptions, needSavePages: state => state.user.needSavePages, hasbookingDetail: state => state.user.hasbookingDetail } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 9417b38..e25eb79 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -20,7 +20,8 @@ const user = { roles: [], info: {}, notices: [], // 接收的通知公告 - bookingList: {}, // 订舱台账列表 + bookingList: {}, // 订舱台账列表 (全部列表对象) + bookingGridOptions: {}, // 订舱台账列表 needSavePages: {}, // 需要保存的页面 hasbookingDetail: false // 订舱详情是否销毁 }, @@ -76,6 +77,9 @@ const user = { SET_BOOKINGLIST: (state, list) => { state.bookingList = list }, + SET_BOOKINGGRIDOPTIONS: (state, obj) => { + state.bookingGridOptions = obj + }, SET_NEEDSAVEPAGES: (state, list) => { state.needSavePages = list }, @@ -270,6 +274,13 @@ const user = { }) }, + setBookingGridOptions({ commit }, obj) { + return new Promise(resolve => { + commit('SET_BOOKINGGRIDOPTIONS', obj) + resolve() + }) + }, + // 设置需要保存页面 setNeedSavePages({ commit }, obj) { return new Promise(resolve => { diff --git a/src/views/main/BookingLedger/detail/modules/operationArea.vue b/src/views/main/BookingLedger/detail/modules/operationArea.vue index c8f22ae..9c9c8b5 100644 --- a/src/views/main/BookingLedger/detail/modules/operationArea.vue +++ b/src/views/main/BookingLedger/detail/modules/operationArea.vue @@ -397,7 +397,6 @@ has-feedback >
- ???? { - console.log('== 进入路由 - beforeRouteEnter ==', vm.formRes) - vm.createdInit() - vm.onresize() + console.log('== 进入路由 - beforeRouteEnter ==', vm.bookingGridOptions) + if (Object.keys(vm.gridOptions).length > 0) { + vm.gridOptions = { ...vm.gridOptions, ...vm.bookingGridOptions } + } + // vm.createdInit() + // vm.onresize() }) }, created() { - // this.createdInit() + this.createdInit() }, mounted() { - // this.onresize() + this.onresize() }, methods: { + ...mapActions(['setBookingList', 'setBookingGridOptions']), createdInit () { this.showColumns = JSON.parse(JSON.stringify(initData.columns)) this.formAllData = JSON.parse(JSON.stringify(initData.condAllData)) @@ -719,7 +727,6 @@ export default { } }) }, - ...mapActions(['setBookingList']), FnCopy(data) { const el = document.createElement('input') el.setAttribute('value', data) @@ -869,7 +876,7 @@ export default { }) console.log('== 获取到form, 准备获取列表 ==', isReset, this.formRes) if (!isReset) { - this.getList(this.formRes) + this.getList(this.formRes, true) } const len = this.formData.length % 4 if (this.formData.length === 4 || this.formData.length > 4) { @@ -911,7 +918,6 @@ export default { setPageSize (data) { if (data && JSON.parse(data.configJson)) { this.gridOptions.pagerConfig.pageSize = JSON.parse(data.configJson).pageSize - this.getList(this.formRes) this.$forceUpdate() } }, @@ -919,59 +925,7 @@ export default { // 获取表单设置内容 getFormData(isReset = false) { DjyUserConfigGet({ type: 'booking_list_cond' }).then(res => { - if (res.data && JSON.parse(res.data.configJson).length) { - const arr = JSON.parse(res.data.configJson) - const nowData = [] - const moreData = [] - arr.map((item, index) => { - this.formAllData.map((fitem, findex) => { - if (fitem.label === item) { - nowData.push(fitem) - } - }) - }) - this.formAllData.map((item, index) => { - if (!arr.includes(item.label)) { - moreData.push(item) - } - }) - this.formData = nowData - this.formMoreData = moreData - } else { - const nowData = this.formData.map((item, index) => { - return item.label - }) - const moreData = [] - this.formAllData.map((item, index) => { - if (!nowData.includes(item.label)) { - moreData.push(item) - } - }) - this.formMoreData = moreData - } - this.formData.map((item, index) => { - this.$set(this.formRes, item.label, this.formRes[item.label] || '') - // select 船公司 等获取下拉列表 - if (item.type === 'select') { - if (['NOBILL', 'CARGOID'].includes(item.label)) { - item.dataList = item.data - setTimeout(() => { - this.$refs[`fromlabel-${item.label}`][0].$data.dataList = item.data - }, 300) - } - } - }) - console.log('== 获取到form, 准备获取列表 ==', isReset, this.formRes) - if (!isReset) { - this.getList(this.formRes) - } - const len = this.formData.length % 4 - if (this.formData.length === 4 || this.formData.length > 4) { - this.formBtnCol = 8 - } else { - this.formBtnCol = 24 - len * 4 - } - this.$forceUpdate() + this.setFormData(res.data) }) }, emnuSelectApi(type) { @@ -1174,7 +1128,7 @@ export default { editColumns(row) { this.$router.push({ name: 'BookingDetail', query: { id: row.id, type: row.carrierid, mblno: row.mblno } }) }, - getList(queryParam = {}) { + getList(queryParam = {}, isInit = false) { this.$set(this.gridOptions, 'loading', true) const { currentPage, pageSize } = this.gridOptions.pagerConfig const query = { @@ -1201,8 +1155,14 @@ export default { } BookingOrderPage(query) .then(res => { + if (isInit) { this.getList(this.formRes) } if (res.success) { + let newBookingList = {} + if (query.PageNo !== 1) { + newBookingList = this.bookingList + } const _data = res.data.items.map((item, index) => { + this.$set(newBookingList, item.id, item) item.index = (currentPage - 1) * pageSize + index const bookstatus = [ { staCode: 'sta_cangdan', isChecked: false }, @@ -1229,11 +1189,8 @@ export default { this.$set(this.gridOptions, 'data', [..._data]) this.$set(this.gridOptions.pagerConfig, 'total', res.data.totalCount) this.$set(this.gridOptions, 'loading', false) - const bookingList = {} - this.gridOptions.data.map(($item, $index) => { - this.$set(bookingList, $item.id, $item) - }) - this.setBookingList(bookingList) + this.setBookingList(newBookingList) + console.log(this.gridOptions.data.length, Object.keys(newBookingList).length, this.gridOptions.data, newBookingList) this.$forceUpdate() } else { this.$set(this.gridOptions, 'data', [...[]])