From 678ee0578bcdd780ec1fc8528379cc96b583b655 Mon Sep 17 00:00:00 2001 From: hflllll Date: Tue, 2 Sep 2025 15:51:30 +0800 Subject: [PATCH] 'save' --- api/modules/config.js | 19 +++++- api/modules/exhibit.js | 4 +- pages/index/home.vue | 49 ++++++++----- pages/index/maintain.vue | 4 +- stores/index.js | 46 +++++++++++-- subPages/home/RAArecord.vue | 129 +++++++++++++++++++++-------------- subPages/home/maintainanceSubmit.vue | 8 +-- subPages/home/repairSubmit.vue | 16 +++-- subPages/repair/maintainSubmit.vue | 14 +++- 9 files changed, 199 insertions(+), 90 deletions(-) diff --git a/api/modules/config.js b/api/modules/config.js index f3158df..46ebab7 100644 --- a/api/modules/config.js +++ b/api/modules/config.js @@ -22,5 +22,22 @@ export default { url: '/config/queryCategoryList', method: 'GET' }) - } + }, + + // 获取故障情况列表 + async queryMalfunctionDescList(data) { + return http({ + url: '/config/queryMalfunctionDescList', + method: 'GET', + data + }) + }, + + // 获取人员情况 + async queryUserList() { + return http({ + url: '/userInfo/queryUserList', + method: 'GET' + }) + }, } \ No newline at end of file diff --git a/api/modules/exhibit.js b/api/modules/exhibit.js index 5af8ef2..6797280 100644 --- a/api/modules/exhibit.js +++ b/api/modules/exhibit.js @@ -89,5 +89,7 @@ export default { showLoading: true, needToken: true }) - } + }, + + } diff --git a/pages/index/home.vue b/pages/index/home.vue index f8c8dab..3a122c8 100644 --- a/pages/index/home.vue +++ b/pages/index/home.vue @@ -15,18 +15,18 @@ - 展品分类 + {{ selectedCategory.label ||'展品分类' }} - - + --> + @@ -52,7 +52,7 @@ 展品类型 - {{ item.type }} + {{ item.categoryId_dictText }} 下次保养日期 @@ -111,16 +111,17 @@ export default { return { mixinListApi: 'exhibit.queryShowpieceList', searchValue: '', - categoryShow: false, - selectedCategory: '', - columns: [ - [ - '全部', - '文字内容', - '互动设备', - '展示设备' - ] - ] + selectedCategory: { + label: '', + value: '' + }, + + } + }, + computed: { + // 从状态管理工具中拿分类大数组 + columns() { + return this.$store.state.categoryList } }, methods: { @@ -130,18 +131,32 @@ export default { this.getList(true) }, mixinSetParams() { + const params = { } + if (this.selectedCategory.value) { + params.categoryId = this.selectedCategory.value + } return { - title: this.searchValue + title: this.searchValue, + ...params } }, openPicker() { this.$refs.picker.open() + }, onCategoryConfirm(e) { - this.selectedCategory = e.label + this.selectedCategory = e.value[1] console.log('选择分类:', e) + this.initPage() + this.getList(true) // TODO: 根据分类筛选展品 }, + onCategoryChange(e) { + const { columnIndex , index} = e + if (columnIndex === 0) { + this.$refs.picker.setColumnValues(1, this.columns[1][index]) + } + }, copyId(id) { uni.setClipboardData({ data: id, diff --git a/pages/index/maintain.vue b/pages/index/maintain.vue index d682290..973f046 100644 --- a/pages/index/maintain.vue +++ b/pages/index/maintain.vue @@ -52,13 +52,13 @@ 展品位置 - {{ item.position }} + {{ item.showpiece.position }} 报修人 - {{ item.reporterName }} + {{ item.malfunctionName_dictText }} 报修日期 diff --git a/stores/index.js b/stores/index.js index 3bedfcd..7fda6a4 100644 --- a/stores/index.js +++ b/stores/index.js @@ -9,11 +9,47 @@ const store = new Vuex.Store({ // 存放状态 configList: [], departmentList: [], + categoryList: [] }, mutations: { - // 分类列表 + // 构造用于uv-picker的树状结构数组 setCategoryList(state, data) { - state.categoryList = data + // 将返回的平面数组data 根据pid和hasChild组装成两个数组,其一为pid为0的父级一维数组,其二为pid不为0的子级二维数组,其中pid相同的排一起 不同的分为不同子数组,并且按顺序排序,比如第一个为[中国,美国] 第二个按顺序为[[上海,福建],[纽约,华盛顿]] + + // 分离父级和子级数据 + const parentCategories = data.filter(item => item.pid === 0 || item.pid === '0') + const childCategories = data.filter(item => item.pid !== 0 && item.pid !== '0') + + // 构建父级一维数组 + const parentArray = parentCategories.map((item) => { + return { + label: item.name || item.title || item.categoryName, + value: item.id + } + }) + + // 构建子级二维数组 + const childArray = [] + parentCategories.forEach(parent => { + const children = childCategories + .filter(child => child.pid === parent.id) + .map(child => { + return { + label: child.name || child.title || child.categoryName, + value: child.id + } + }) + childArray.push(children.length > 0 ? children : [{ + label: '全部', + value: 0 + }]) + }) + console.log('父数组','子数组',parentArray, childArray); + + // 组装最终结果 + state.categoryList = [parentArray, childArray] + console.log('最终数组', state.categoryList); + }, setConfigList(state, data) { state.configList = data @@ -22,6 +58,7 @@ const store = new Vuex.Store({ state.departmentList = data }, + // }, actions: { // 查询配置列表 @@ -37,7 +74,6 @@ const store = new Vuex.Store({ return acc }, {}) commit('setConfigList', config) - }, // 查询部门列表 async getDepartment({ commit }) { @@ -62,15 +98,13 @@ const store = new Vuex.Store({ await Promise.all([ dispatch('getConfig'), dispatch('getDepartment'), - // dispatch('getCategory'), + dispatch('getCategory'), ]) console.log('所有配置数据初始化完成') } catch (error) { console.error('配置数据初始化失败:', error) } }, - - } }) diff --git a/subPages/home/RAArecord.vue b/subPages/home/RAArecord.vue index 93f4cfd..1677ed6 100644 --- a/subPages/home/RAArecord.vue +++ b/subPages/home/RAArecord.vue @@ -29,20 +29,28 @@ - {{ selectedPerson || '人员' }} + {{ selectedPerson.label || '人员' }} - + > --> + + + @@ -86,11 +95,11 @@ - + 上传图片 - + @@ -124,7 +133,7 @@ - + - + 保养后状态 - + {{ record.afterStatus }} - + - + 是否产生费用 {{ record.hasCost }} - - + 产生费用 {{ record.totalCost }} - + 费用名称 数量 金额 - + {{ item.name }} {{ item.quantity }} {{ item.amount }} @@ -191,18 +200,18 @@ @@ -210,35 +219,35 @@ - {{ record.isCollapsed ? '查看全部' : '收起' }} - {{ record.isCollapsed ? '▼' : '▲' }} + {{ collapsedStates[index] ? '查看全部' : '收起' }} + {{ collapsedStates[index] ? '▼' : '▲' }} @@ -256,6 +265,7 @@ export default { mixinListApi: 'exhibit.queryRepairList', activeMainTab: 'repair', // 当前激活的主Tab activeFilter: 0, // 当前激活的筛选器 + collapsedStates: [], // 控制每个记录项的展开/收起状态 filterOptions: [ { name: '时间' }, { name: '人员' } @@ -265,9 +275,7 @@ export default { timeColumns: [ ['今天', '昨天', '本周', '本月', '上月', '自定义'] ], - personColumns: [ - ['张三', '李四', '王五', '赵六', '钱七', '孙八'] - ], + personColumns: [ ], // 维修记录数据 repairData: [ { @@ -284,7 +292,6 @@ export default { ], isResolved: '是', remark: '文字内容', - isCollapsed: true // 控制收起状态 }, { repairPerson: '李华', @@ -299,8 +306,7 @@ export default { { name: '达玛树脂', quantity: '1', amount: '200.00' } ], isResolved: '是', - remark: '文字内容', - isCollapsed: true // 控制收起状态 + remark: '文字内容' }, ], // 保养记录数据 @@ -320,8 +326,7 @@ export default { ], attachmentInfo: '附件信息', maintainRemark: '文字内容', - attachmentImage: '/static/商城_商品2.png', - isCollapsed: true // 控制收起状态 + attachmentImage: '/static/商城_商品2.png' }, { maintainPerson: '李华', @@ -338,16 +343,12 @@ export default { ], attachmentInfo: '附件信息', maintainRemark: '文字内容', - attachmentImage: '/static/商城_商品2.png', - isCollapsed: true // 控制收起状态 + attachmentImage: '/static/商城_商品2.png' } ] } }, computed: { - // list() { - // return this.activeMainTab === 'repair' ? this.repairData : this.maintainData - // }, contentText() { const tabText = this.activeMainTab === 'repair' ? '维修' : '保养' const filterText = this.filterOptions[this.activeFilter].name @@ -364,18 +365,37 @@ export default { }, methods: { mixinSetParams() { + const params = { } + if (this.activeMainTab === 'repair' && this.selectedTime) { + params.repairDate = this.selectedTime + } else if (this.activeMainTab === 'maintain' && this.selectedTime) { + params.maintainDate = this.selectedTime + } + if (this.selectedPerson) { + params.id = this.selectedPerson.id + } return { - showpieceId: this.showpieceId + showpieceId: this.showpieceId, + ...params } }, - switchMainTab(tab) { + async switchMainTab(tab) { this.activeMainTab = tab + this.mixinListApi = this.activeMainTab === 'repair' ? 'exhibit.queryRepairList' : 'exhibit.queryMaintenanceList' + this.onFilterChange() + this.initPage() + await this.getList(true) + this.initCollapsedStates() }, - onFilterChange(index) { - this.activeFilter = index + initCollapsedStates() { + this.collapsedStates = new Array(this.list.length).fill(true) + }, + onFilterChange() { + // this.activeFilter = index // 切换筛选器时清空选择 this.selectedTime = '' this.selectedPerson = '' + }, showTimePicker() { this.$refs.timePicker.open() @@ -383,9 +403,11 @@ export default { showPersonPicker() { this.$refs.personPicker.open() }, - onTimeConfirm(value) { - this.selectedTime = value.value[0] - console.log('选择的时间:', value) + onTimeConfirm(e) { + const date = new Date(e.value) + this.selectedTime = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}` + this.initPage() + this.getList(true) }, onTimeCancel() { console.log('取消选择时间') @@ -393,22 +415,25 @@ export default { onPersonConfirm(value) { this.selectedPerson = value.value[0] console.log('选择的人员:', value) + this.initPage() + this.getList(true) }, onPersonCancel() { console.log('取消选择人员') }, toggleCollapse(index) { - if (this.activeMainTab === 'repair') { - this.repairData[index].isCollapsed = !this.repairData[index].isCollapsed - console.log('收起/展开费用详情', this.repairData[index].isCollapsed) - } else { - this.maintainData[index].isCollapsed = !this.maintainData[index].isCollapsed - console.log('收起/展开费用详情', this.maintainData[index].isCollapsed) - } + this.$set(this.collapsedStates, index, !this.collapsedStates[index]) + console.log('收起/展开费用详情', this.collapsedStates[index]) } }, - onLoad(args){{ + async onLoad(args){{ this.showpieceId = args.id + this.initCollapsedStates() + const userRes = await this.$api.config.queryUserList() + this.personColumns = [[...userRes.result.records.map(item => ({ + label: item.nickName, + id: item.id + }))]] }} } diff --git a/subPages/home/maintainanceSubmit.vue b/subPages/home/maintainanceSubmit.vue index 2cc75ba..df7997d 100644 --- a/subPages/home/maintainanceSubmit.vue +++ b/subPages/home/maintainanceSubmit.vue @@ -210,7 +210,7 @@ 下次保养日期 - {{ nextMaintenanceDate || '请选择' }} + {{ malfunctionDate || '请选择' }} @@ -276,7 +276,7 @@ export default { costList: [], remarkText: '', remarkImage: [], - nextMaintenanceDate: '', + malfunctionDate: '', remark: '', showpieceId: '', submiting: false @@ -312,7 +312,7 @@ export default { confirmNextDate(e) { // uv-datetime-picker返回的是时间戳,需要转换为日期格式 const date = new Date(e.value) - this.nextMaintenanceDate = date.getFullYear() + '-' + + this.malfunctionDate = date.getFullYear() + '-' + String(date.getMonth() + 1).padStart(2, '0') + '-' + String(date.getDate()).padStart(2, '0') }, @@ -478,7 +478,7 @@ export default { amount: this.amount, remarkText: this.remarkText, remarkImage: this.remarkImage?.join(',') || '', - nextMaintenanceDate: this.nextMaintenanceDate, + malfunctionDate: this.malfunctionDate, remark: this.remark, showpieceId: this.showpieceId } diff --git a/subPages/home/repairSubmit.vue b/subPages/home/repairSubmit.vue index b21e56d..4f6a7ac 100644 --- a/subPages/home/repairSubmit.vue +++ b/subPages/home/repairSubmit.vue @@ -37,7 +37,7 @@ 故障情况 - {{ malfunctionStatus.label || '请选择' }} + {{ malfunctionStatus || '请选择' }} @@ -294,7 +294,6 @@ export default { isAffectExperience: '0', remark: '', showpieceId: '', - // 频率选项 frequencyOptions: [ @@ -453,8 +452,7 @@ export default { showpieceId: this.showpieceId, malfunctionDate: this.malfunctionDate, urgency: this.urgency.value, - malfunctionStatus: this.malfunctionStatus.id, - malfunctionDesc: this.malfunctionDesc, + malfunctionDesc: this.malfunctionStatus + this.malfunctionDesc, malfunctionImage: this.malfunctionImage.join(','), firstDate: this.firstDate, frequency: this.frequency, @@ -479,8 +477,16 @@ export default { } } }, - onLoad(args) { + async onLoad(args) { this.showpieceId = args.id + try { + const listRes = await this.$api.config.queryMalfunctionDescList() + if (listRes.code === 200) { + this.faultColumns = [[...listRes.result.records.map(item => item.malfunction)]] + } + } catch (error) { + uni.showToast({ title: error.message, icon: 'none' }) + } } } diff --git a/subPages/repair/maintainSubmit.vue b/subPages/repair/maintainSubmit.vue index c69ba33..51675ae 100644 --- a/subPages/repair/maintainSubmit.vue +++ b/subPages/repair/maintainSubmit.vue @@ -345,7 +345,7 @@ 备注 - +