Sfoglia il codice sorgente

feat(maintain): 优化保养完成流程并新增设备详情信息展示

- 在设备详情页新增上次保养完成时间字段展示
- 优化设备位置信息获取逻辑,优先使用positionName,兼容cph字段
- 保养完成页面新增"完成并报修"功能按钮
- 重构保养完成提交方法,支持不同类型的完成操作跳转
- 优化保养列表页面卡片标题显示格式
- 修复保养详情页面传递设备ID参数问题
- 新增报修申请页面班长通知选择功能
- 集成班长候选人员查询接口并实现多选逻辑
- 优化服务页面初始化状态配置
dazhaxie 1 settimana fa
parent
commit
dc317b1295

+ 14 - 0
api/upms/user.js

@@ -28,6 +28,20 @@ export function queryUser (parameter) {
 }
 
 /**
+ * 报修通知班长候选人:全部班长 + 当前用户班组下的班长(默认勾选)
+ * 返回 { leaders: [], defaultIds: [] }
+ */
+export function queryRepairTeamLeaders () {
+    return http({
+        url: '/upms/users/team-leaders',
+        method: 'get',
+        headers: {
+            'Content-Type': 'application/json;charset=UTF-8'
+        }
+    })
+}
+
+/**
  * fetch single func
  * parameter: { }
  * @param parameter

+ 3 - 1
pages/equipment-detail/equipment-detail.vue

@@ -31,7 +31,9 @@
                 <!--                <equipment-line title="财务编码" :content="infoData.financingNo"/>-->
                 <equipment-line title="设备类型" :content="infoData.typeName" />
                 <equipment-line title="规格型号" :content="infoData.model" />
-                <equipment-line title="使用位置" :content="infoData.cph" />
+                <!-- 使用位置优先取设备位置树名称(positionName),cph 仅在报修回写后才有值,兜底兼容老数据 -->
+                <equipment-line title="使用位置" :content="infoData.positionName ? infoData.positionName : (infoData.cph ? infoData.cph : '')" />
+                <equipment-line title="上次保养完成时间" :content="infoData.lastMaintainFinishTime ? infoData.lastMaintainFinishTime : '暂无'" />
             </view>
 
             <!-- <view class="mt-3">

+ 1 - 1
pages/maintain-detail/maintain-detail.vue

@@ -216,7 +216,7 @@ export default {
     },
     handleFinish() {
       uni.navigateTo({
-        url: `/pages/maintain/finish?id=${this.infoData.id}&standardId=${this.infoData.standardId}`
+        url: `/pages/maintain/finish?id=${this.infoData.id}&standardId=${this.infoData.standardId}&sbId=${this.infoData.sbId}`
       })
     },
     handleRepair() {

+ 32 - 6
pages/maintain/finish.vue

@@ -61,8 +61,9 @@
           </view>
         </view>
       </view>
-      <view class="p-fixed d-flex j-around a-center footer">
-        <view class="main-color-bg text-color-white common" @tap="handleSubmit">提交</view>
+      <view class="p-fixed d-flex a-center footer">
+        <view class="finish-action-btn finish-action-btn-danger" @tap="handleSubmit(1)">完成并报修</view>
+        <view class="finish-action-btn finish-action-btn-primary" @tap="handleSubmit()">完成</view>
       </view>
     </view>
     <u-toast ref="uToast" />
@@ -111,7 +112,7 @@ export default {
     this.$refs.uForm.setRules(this.rules)
   },
   methods: {
-    handleSubmit() {
+    handleSubmit(type) {
       this.$refs.uForm.validate(valid => {
         if (valid) {
           let isReturn = false
@@ -137,10 +138,18 @@ export default {
             this.$refs.uToast.show({
               title: '操作成功'
             })
-            uni.navigateBack({
-              delta: 1
-            })
             this.$Http.timerStop({ referenceId: this.form.id, finalAccumulatedTime: this.displayTime })
+            if (type === 1) {
+              // 完成并报修:直接进入该设备的报修填写页(与 PC 端“完成并报修”一致)
+              uni.redirectTo({
+                url: '/pages/repair-add/repair-add?detailId=' + this.form.sbId
+              })
+            } else {
+              // 仅完成:返回保养详情页
+              uni.navigateBack({
+                delta: 1
+              })
+            }
           })
         }
       })
@@ -165,6 +174,23 @@ export default {
     background-color: #0082ff;
     color: #fff;
   }
+
+  .finish-action-btn {
+    flex: 1;
+    margin: 0 20rpx;
+    padding: 15rpx 0;
+    text-align: center;
+    border-radius: 30rpx;
+    color: #fff;
+  }
+
+  .finish-action-btn-danger {
+    background-color: #fa3534;
+  }
+
+  .finish-action-btn-primary {
+    background-color: #0082ff;
+  }
 }
 
 .select {

+ 2 - 6
pages/maintain/maintain.vue

@@ -6,15 +6,11 @@
         <view class="mx3 my2 p3 bg-color-white box p-relative" v-for="(item, index) in listData" :key="item.id"
           @click="handleDetail(item.id)" @longpress="showMask(item.id, $event)">
           <common-mask :item="item" :maskId="maskId" @hide="maskId = 0" @del="handleDel(item.id)" />
+          <!-- 卡片标题仅显示设备名称(设备编号),右侧状态角标 -->
           <view class="d-flex j-between border-bottom pb-2 a-center">
-            <view class="text-color-b f-size-26 text-overflow">{{ item.sbNo }} ({{ item.sbName }})</view>
+            <view class="text-color-3 f-size-32 f-weight-bold text-overflow">{{ item.sbName }} ({{ item.sbNo }})</view>
             <my-badge :text="statusMap[item.status]" :status="dict[item.status]" />
           </view>
-          <view class="mt-2 d-flex j-between">
-            <view class="text-color-3 f-size-32 f-weight-bold">{{
-              item.requirementList ? item.requirementList.map(i => i.stdName).join('、') : ''
-            }}</view>
-          </view>
           <view class="f-size-26 text-color-6 f-weight-4 mt-2">计划执行日期:{{
             item.startTime
           }}

+ 90 - 2
pages/repair-add/repair-add.vue

@@ -116,6 +116,31 @@
                 <u-form-item label="报修人" prop="actualUser" required :label-width="150">
                     <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
                 </u-form-item>
+                <u-form-item label="通知班长" :label-width="150">
+                    <u-input v-model="form.notifyTeamLeaders" disabled @click="openLeaderPopup" type="select"
+                        placeholder="请选择通知班长(可多选,非必填)" />
+                </u-form-item>
+                <u-popup v-model="leaderPopupShow" mode="bottom" border-radius="20">
+                    <view class="bg-color-white">
+                        <view class="d-flex j-between a-center p3">
+                            <view class="text-color-6 f-size-28" @click="cancelLeaderSelect">取消</view>
+                            <view class="main-color-text f-size-32 f-weight-6">通知班长(可多选)</view>
+                            <view class="main-color-text f-size-28" @click="confirmLeaderSelect">确定</view>
+                        </view>
+                        <scroll-view scroll-y style="max-height: 500rpx" class="px3">
+                            <u-checkbox-group shape="square">
+                                <view class="py2" v-for="(leader, index) in teamLeaderList" :key="leader.userId">
+                                    <u-checkbox v-model="teamLeaderList[index].checked" :name="leader.userId">
+                                        {{ leader.realName }}
+                                    </u-checkbox>
+                                </view>
+                            </u-checkbox-group>
+                            <view v-if="!teamLeaderList.length" class="p3 text-color-6 f-size-28">
+                                暂无具有班长身份的人员
+                            </view>
+                        </scroll-view>
+                    </view>
+                </u-popup>
                 <u-form-item label="故障描述" prop="content" required :label-width="150">
                     <u-input v-model="form.content" :cursor-spacing="cursorSpacing" />
                 </u-form-item>
@@ -158,8 +183,14 @@ export default {
                 levelValue: '',
                 source: '',
                 limitDate: '',
-                limitHours: ''
+                limitHours: '',
+                // 通知班长:仅展示已选班长姓名,提交用 selectedLeaderIds
+                notifyTeamLeaders: ''
             },
+            teamLeaderList: [], // 全部具有班长身份的人,带 checked 勾选状态
+            defaultLeaderIds: [], // 当前用户班组下的班长,默认勾选
+            selectedLeaderIds: [], // 已选班长用户id
+            leaderPopupShow: false, // 通知班长多选弹层
             category: '',
             badState: false,
             badList: [],
@@ -378,6 +409,7 @@ export default {
             .getSbPositionTree().then(res => {
                 this.sbPositionData = res.data
             })
+        this.getTeamLeaders()
         // const categoryMap = this.$DictCache.getLabelByValueMapByType(
         //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
         // )
@@ -407,6 +439,56 @@ export default {
         this.$refs.uForm.setRules(this.rules)
     },
     methods: {
+        // 获取通知班长候选人:默认带出当前用户班组下的班长,找不到则空着
+        getTeamLeaders() {
+            this.$Http
+                .queryRepairTeamLeaders()
+                .then(res => {
+                    const data = res.data || {}
+                    const defaultIds = data.defaultIds || []
+                    // 每项附加 checked 勾选状态,默认勾选本班组班长
+                    this.teamLeaderList = (data.leaders || []).map(item => ({
+                        ...item,
+                        checked: defaultIds.indexOf(item.userId) > -1
+                    }))
+                    this.defaultLeaderIds = defaultIds
+                    this.selectedLeaderIds = defaultIds.slice()
+                    this.syncLeaderDisplay()
+                })
+        },
+        // 已选班长id同步到表单展示姓名
+        syncLeaderDisplay() {
+            const names = this.teamLeaderList
+                .filter(item => this.selectedLeaderIds.indexOf(item.userId) > -1)
+                .map(item => item.realName)
+            this.form.notifyTeamLeaders = names.join('、')
+        },
+        // 用已选id刷新弹层勾选状态
+        resetLeaderChecked() {
+            this.teamLeaderList.forEach((item, index) => {
+                this.$set(this.teamLeaderList[index], 'checked', this.selectedLeaderIds.indexOf(item.userId) > -1)
+            })
+        },
+        openLeaderPopup() {
+            if (!this.teamLeaderList.length) {
+                uni.showToast({ icon: 'none', title: '暂无具有班长身份的人员' })
+                return
+            }
+            this.resetLeaderChecked()
+            this.leaderPopupShow = true
+        },
+        confirmLeaderSelect() {
+            this.selectedLeaderIds = this.teamLeaderList
+                .filter(item => item.checked)
+                .map(item => item.userId)
+            this.syncLeaderDisplay()
+            this.leaderPopupShow = false
+        },
+        cancelLeaderSelect() {
+            // 取消:丢弃弹层内未确认的勾选
+            this.resetLeaderChecked()
+            this.leaderPopupShow = false
+        },
         //
         confirm(e) {
             console.log(e)
@@ -475,6 +557,8 @@ export default {
                 limitHours: this.form.limitHours || null,
                 // 与 PC 端 BaseForm 一致:提交当前登录人部门
                 deptId: this.userInfo ? this.userInfo.deptId : null,
+                // 通知班长:选中班长的用户id,逗号分隔,与 PC 端保持一致
+                notifyTeamLeaders: this.selectedLeaderIds.join(','),
                 applicationFileList: this.imagesList
             }
             // this.form.photo = a.join(',');
@@ -519,11 +603,15 @@ export default {
                 levelValue: '',
                 source: '',
                 limitDate: '',
-                limitHours: ''
+                limitHours: '',
+                notifyTeamLeaders: ''
             }
             this.category = ''
             this.imagesList = []
             this.fileList = []
+            // 通知班长恢复默认本班组班长
+            this.selectedLeaderIds = this.defaultLeaderIds.slice()
+            this.syncLeaderDisplay()
         },
         // 紧急等级
         levelSubmit(data) {

+ 2 - 2
pages/service/service.vue

@@ -68,13 +68,13 @@ export default {
         return {
             list: [
             ],
-            current: 2,
+            current: 0,
             // 加载更多
             status: 'loadmore',
             page: 1,
             limit: 10,
             sbId: '',
-            type: 2,
+            type: 0,
             filter: -1,
             loadMore: true,
             listData: [],