Jelajahi Sumber

feat(repair): 报修人改为搜索选择系统账号避免同名歧义

- 报修人输入框改为弹出选择面板,支持按姓名/账号搜索系统启用账号
- 选中系统账号时同时记录 userId,提交后端以 userId 为准区分同名人员
- 搜索无结果时允许直接按输入姓名填报,后端降级按姓名匹配
- 新增 setDefaultReporter 方法,默认带出当前登录人
- 维修完成页移除"是否停机"字段,停机与否以报修时选择为准
- 工单详情页"开始维修"按钮兼容 assistantStatus 为 NULL 的老工单
dazhaxie 1 Minggu lalu
induk
melakukan
adbc84ec57

+ 99 - 2
pages/middle/middle.vue

@@ -113,8 +113,36 @@
                     <u-input v-model="form.limitHours" type="number" placeholder="请输入要求时间(小时)" />
                 </u-form-item>
                 <u-form-item label="报修人" prop="actualUser" required :label-width="150">
-                    <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
+                    <!-- 报修人默认带出当前登录人,可搜索选择系统账号,避免同名报修人无法区分 -->
+                    <u-input v-model="form.actualUser" disabled @click="openReporterPopup" type="select"
+                        placeholder="请选择报修人" />
                 </u-form-item>
+                <u-popup v-model="reporterPopupShow" 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="reporterPopupShow = false">取消</view>
+                            <view class="main-color-text f-size-32 f-weight-6">选择报修人</view>
+                            <view class="f-size-28" style="visibility: hidden">占位</view>
+                        </view>
+                        <view class="px3 pb2">
+                            <u-search v-model="reporterKeyword" placeholder="搜索姓名或账号" :show-action="false"
+                                :bg-color="'#f4f4f4'"></u-search>
+                        </view>
+                        <scroll-view scroll-y style="max-height: 500rpx" class="px3">
+                            <view class="py2 border-bottom f-size-30" v-for="item in filteredReporterList" :key="item.userId"
+                                @click="chooseReporter(item)">
+                                {{ item.realName }}<text v-if="item.username" class="text-color-6">({{ item.username }})</text>
+                            </view>
+                            <view v-if="!filteredReporterList.length && !reporterKeyword" class="p3 text-color-6 f-size-28">
+                                暂无可选人员
+                            </view>
+                            <!-- 搜索无结果时允许直接按输入的姓名报修(非系统账号) -->
+                            <view v-if="reporterKeyword" class="py2 f-size-30 main-color-text" @click="useReporterKeyword">
+                                直接使用姓名“{{ reporterKeyword }}”
+                            </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>
@@ -152,6 +180,8 @@ export default {
                 level: '',
                 // 传入的
                 sbId: '',
+                // 报修人选中账号的 userId,提交时传后端避免同名歧义
+                userId: '',
                 needStop: null,
                 levelValue: '',
                 source: '',
@@ -172,6 +202,9 @@ export default {
             errorTypeState: false, // 故障类型
             errorTypeList: [],
             limitDateShow: false, // 要求日期
+            reporterPopupShow: false, // 报修人搜索选择弹层
+            reporterKeyword: '', // 报修人搜索关键字
+            reporterList: [], // 报修人候选:全部启用账号
             dateParams: {
                 year: true,
                 month: true,
@@ -248,6 +281,13 @@ export default {
                         message: '请选择故障类型',
                         trigger: ['blur', 'change']
                     }
+                ],
+                actualUser: [
+                    {
+                        required: true,
+                        message: '请选择报修人',
+                        trigger: ['blur', 'change']
+                    }
                 ]
             },
             // #ifdef MP-WEIXIN
@@ -297,7 +337,7 @@ export default {
     onShow() {
         this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
         if (this.userInfo) {
-            this.form.actualUser = this.userInfo.realName
+            this.setDefaultReporter()
         }
         const pages = getCurrentPages()
         const currPage = pages[pages.length - 1]
@@ -398,6 +438,7 @@ export default {
             .getSbPositionTree().then(res => {
                 this.sbPositionData = res.data
             })
+        this.getReporterList()
         // const categoryMap = this.$DictCache.getLabelByValueMapByType(
         //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
         // )
@@ -426,7 +467,60 @@ export default {
     onReady() {
         this.$refs.uForm.setRules(this.rules)
     },
+    computed: {
+        // 报修人候选按姓名/账号本地过滤
+        filteredReporterList() {
+            const kw = (this.reporterKeyword || '').trim().toLowerCase()
+            if (!kw) {
+                return this.reporterList
+            }
+            return this.reporterList.filter(item => {
+                const name = (item.realName || '').toLowerCase()
+                const username = (item.username || '').toLowerCase()
+                return name.indexOf(kw) > -1 || username.indexOf(kw) > -1
+            })
+        }
+    },
     methods: {
+        // 报修人候选列表:全部启用账号,默认带出当前登录人
+        getReporterList() {
+            this.$Http
+                .queryUser({ status: 1 })
+                .then(res => {
+                    this.reporterList = res.data || []
+                    this.setDefaultReporter()
+                })
+        },
+        // 默认报修人=当前登录人(仅未选择时赋值)
+        setDefaultReporter() {
+            if (!this.userInfo) {
+                return
+            }
+            if (!this.form.actualUser) {
+                this.form.actualUser = this.userInfo.realName
+                this.form.userId = this.userInfo.userId
+            }
+        },
+        openReporterPopup() {
+            if (!this.reporterList.length) {
+                uni.showToast({ icon: 'none', title: '暂无可选人员' })
+                return
+            }
+            this.reporterKeyword = ''
+            this.reporterPopupShow = true
+        },
+        // 选中系统账号:同时记录 userId,后端以账号为准不会认错人
+        chooseReporter(item) {
+            this.form.actualUser = item.realName
+            this.form.userId = item.userId
+            this.reporterPopupShow = false
+        },
+        // 按搜索框输入的姓名直接填报:不带 userId,后端降级按姓名匹配
+        useReporterKeyword() {
+            this.form.actualUser = this.reporterKeyword
+            this.form.userId = ''
+            this.reporterPopupShow = false
+        },
         //
         confirm(e) {
             console.log(e)
@@ -494,6 +588,8 @@ export default {
                 sbName: this.form.sbName,
                 sbCph: this.form.sbCph,
                 actualUser: this.form.actualUser,
+                // 报修人选中账号,后端以 userId 为准避免同名歧义
+                userId: this.form.userId || null,
                 category: this.form.category ? Number(this.form.category) : null,
                 level: this.form.levelValue ? Number(this.form.levelValue) : null,
                 repairErrorTypeId: this.form.repairErrorTypeId || null,
@@ -563,6 +659,7 @@ export default {
                 repair: '',
                 remarks: '',
                 actualUser: this.userInfo ? this.userInfo.realName : '',
+                userId: this.userInfo ? this.userInfo.userId : '',
                 content: '',
                 repairErrorTypeId: '',
                 photo: '',

+ 93 - 3
pages/repair-add/repair-add.vue

@@ -114,8 +114,36 @@
                     <u-input v-model="form.limitHours" type="number" placeholder="请输入要求时间(小时)" />
                 </u-form-item>
                 <u-form-item label="报修人" prop="actualUser" required :label-width="150">
-                    <u-input v-model="form.actualUser" :cursor-spacing="cursorSpacing" />
+                    <!-- 报修人默认带出当前登录人,可搜索选择系统账号,避免同名报修人无法区分 -->
+                    <u-input v-model="form.actualUser" disabled @click="openReporterPopup" type="select"
+                        placeholder="请选择报修人" />
                 </u-form-item>
+                <u-popup v-model="reporterPopupShow" 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="reporterPopupShow = false">取消</view>
+                            <view class="main-color-text f-size-32 f-weight-6">选择报修人</view>
+                            <view class="f-size-28" style="visibility: hidden">占位</view>
+                        </view>
+                        <view class="px3 pb2">
+                            <u-search v-model="reporterKeyword" placeholder="搜索姓名或账号" :show-action="false"
+                                :bg-color="'#f4f4f4'"></u-search>
+                        </view>
+                        <scroll-view scroll-y style="max-height: 500rpx" class="px3">
+                            <view class="py2 border-bottom f-size-30" v-for="item in filteredReporterList" :key="item.userId"
+                                @click="chooseReporter(item)">
+                                {{ item.realName }}<text v-if="item.username" class="text-color-6">({{ item.username }})</text>
+                            </view>
+                            <view v-if="!filteredReporterList.length && !reporterKeyword" class="p3 text-color-6 f-size-28">
+                                暂无可选人员
+                            </view>
+                            <!-- 搜索无结果时允许直接按输入的姓名报修(非系统账号) -->
+                            <view v-if="reporterKeyword" class="py2 f-size-30 main-color-text" @click="useReporterKeyword">
+                                直接使用姓名“{{ reporterKeyword }}”
+                            </view>
+                        </scroll-view>
+                    </view>
+                </u-popup>
                 <u-form-item label="通知班长" :label-width="150">
                     <u-input v-model="form.notifyTeamLeaders" disabled @click="openLeaderPopup" type="select"
                         placeholder="请选择通知班长(可多选,非必填)" />
@@ -179,6 +207,8 @@ export default {
                 level: '',
                 // 传入的
                 sbId: '',
+                // 报修人选中账号的 userId,提交时传后端避免同名歧义
+                userId: '',
                 needStop: null,
                 levelValue: '',
                 source: '',
@@ -206,6 +236,9 @@ export default {
             errorTypeState: false, // 故障类型
             errorTypeList: [],
             limitDateShow: false, // 要求日期
+            reporterPopupShow: false, // 报修人搜索选择弹层
+            reporterKeyword: '', // 报修人搜索关键字
+            reporterList: [], // 报修人候选:全部启用账号
             dateParams: {
                 year: true,
                 month: true,
@@ -257,7 +290,7 @@ export default {
                 actualUser: [
                     {
                         required: true,
-                        message: '请填写报修人',
+                        message: '请选择报修人',
                         trigger: ['blur', 'change']
                     }
                 ],
@@ -308,7 +341,7 @@ export default {
     onShow() {
         this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
         if (this.userInfo) {
-            this.form.actualUser = this.userInfo.realName
+            this.setDefaultReporter()
         }
         const pages = getCurrentPages()
         const currPage = pages[pages.length - 1]
@@ -410,6 +443,7 @@ export default {
                 this.sbPositionData = res.data
             })
         this.getTeamLeaders()
+        this.getReporterList()
         // const categoryMap = this.$DictCache.getLabelByValueMapByType(
         //     this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
         // )
@@ -438,7 +472,60 @@ export default {
     onReady() {
         this.$refs.uForm.setRules(this.rules)
     },
+    computed: {
+        // 报修人候选按姓名/账号本地过滤
+        filteredReporterList() {
+            const kw = (this.reporterKeyword || '').trim().toLowerCase()
+            if (!kw) {
+                return this.reporterList
+            }
+            return this.reporterList.filter(item => {
+                const name = (item.realName || '').toLowerCase()
+                const username = (item.username || '').toLowerCase()
+                return name.indexOf(kw) > -1 || username.indexOf(kw) > -1
+            })
+        }
+    },
     methods: {
+        // 报修人候选列表:全部启用账号,默认带出当前登录人
+        getReporterList() {
+            this.$Http
+                .queryUser({ status: 1 })
+                .then(res => {
+                    this.reporterList = res.data || []
+                    this.setDefaultReporter()
+                })
+        },
+        // 默认报修人=当前登录人(仅未选择时赋值)
+        setDefaultReporter() {
+            if (!this.userInfo) {
+                return
+            }
+            if (!this.form.actualUser) {
+                this.form.actualUser = this.userInfo.realName
+                this.form.userId = this.userInfo.userId
+            }
+        },
+        openReporterPopup() {
+            if (!this.reporterList.length) {
+                uni.showToast({ icon: 'none', title: '暂无可选人员' })
+                return
+            }
+            this.reporterKeyword = ''
+            this.reporterPopupShow = true
+        },
+        // 选中系统账号:同时记录 userId,后端以账号为准不会认错人
+        chooseReporter(item) {
+            this.form.actualUser = item.realName
+            this.form.userId = item.userId
+            this.reporterPopupShow = false
+        },
+        // 按搜索框输入的姓名直接填报:不带 userId,后端降级按姓名匹配
+        useReporterKeyword() {
+            this.form.actualUser = this.reporterKeyword
+            this.form.userId = ''
+            this.reporterPopupShow = false
+        },
         // 获取通知班长候选人:默认带出当前用户班组下的班长,找不到则空着
         getTeamLeaders() {
             this.$Http
@@ -551,6 +638,8 @@ export default {
                 actualUser: this.form.actualUser,
                 needStop: this.form.needStop,
                 sbId: this.form.sbId,
+                // 报修人选中账号,后端以 userId 为准避免同名歧义
+                userId: this.form.userId || null,
                 sbName: this.form.sbName,
                 sbCph: this.form.sbCph,
                 category: this.form.category ? Number(this.form.category) : null,
@@ -629,6 +718,7 @@ export default {
                 repair: '',
                 remarks: '',
                 actualUser: this.userInfo ? this.userInfo.realName : '',
+                userId: this.userInfo ? this.userInfo.userId : '',
                 content: '',
                 repairErrorTypeId: '',
                 photo: '',

+ 1 - 41
pages/service-add/service-add.vue

@@ -42,12 +42,6 @@
                     <u-input v-model="category" disabled @click="categoryState = true" type="select" />
                     <m-select v-model="categoryState" :list="categoryMap" @confirm="categorySubmit"></m-select>
                 </u-form-item>
-                <u-form-item label="是否停机" required prop="halt" :label-width="150">
-                    <u-input v-model="form.halt" disabled @click="haltState = true" placeholder="请选择是否停机"
-                        type="select" />
-                    <u-select v-model="haltState" :list="haltList" @confirm="haltSubmit"
-                        :default-value="haltDefaultValue"></u-select>
-                </u-form-item>
                 <u-form-item label="完成时间" prop="repairEndTime" :label-width="150">
                     <u-input v-model="form.repairEndTime" disabled @click="endTimeShow = true" placeholder="请选择完成时间"
                         type="select" />
@@ -81,8 +75,6 @@ export default {
                 category: '',
                 descripitionType: '',
                 no: '',
-                halt: '',
-                needStop: '',
                 userName: '',
                 repairErrorTypeId: '',
                 repairMinutes: '',
@@ -106,8 +98,6 @@ export default {
             badList: [],
             categoryMap: [],
 
-            haltState: false, // 是否停机
-            haltList: [],
             descripitionState: false,
             descripitionList: [],
             action: this.$BaseTool.UserUtil.getUploadUrl(),
@@ -118,16 +108,7 @@ export default {
             imagesList: [],
             detailId: '',
             descripitionMap: {},
-            needStopMap: {},
-            haltDefaultValue: [0],
             rules: {
-                halt: [
-                    {
-                        required: true,
-                        message: '请选择是否停机',
-                        trigger: ['blur', 'change']
-                    }
-                ],
                 category: [
                     {
                         required: true,
@@ -178,17 +159,6 @@ export default {
                 value: key
             });
         }
-        this.needStopMap = this.$DictCache.getLabelByValueMapByType(
-            this.$DictCache.TYPE.YES_NO
-        );
-        for (const key in this.needStopMap) {
-            this.haltList.push({
-                label: this.needStopMap[key],
-                value: key
-            });
-        }
-        this.form.halt = this.haltList[this.haltDefaultValue].label;
-        this.form.needStop = this.haltList[this.haltDefaultValue].value;
         this.initData()
         this.getType()
     },
@@ -209,13 +179,7 @@ export default {
         categorySubmit(data) {
             this.category = data[0].label;
             this.form.category = data[0].value;
-            // 与 PC 端 FinishForm 联动逻辑一致:计划性维修默认停机,其余默认不停机
-            const needStopValue = data[0].value == 1 ? '1' : '0';
-            this.form.needStop = needStopValue;
-            const haltItem = this.haltList.find(item => item.value == needStopValue);
-            if (haltItem) {
-                this.form.halt = haltItem.label;
-            }
+            // 维修完成仅填写维修相关内容,不再处理“是否停机”:停机与否以报修时的选择为准(与 PC 端 FinishForm 一致)
         },
         badSubmit(data) {
             this.form.badType = data[0].label;
@@ -251,10 +215,6 @@ export default {
                 }
             })
         },
-        haltSubmit(data) {
-            this.form.halt = data[0].label;
-            this.form.needStop = data[0].value;
-        },
         // 完成时间
         endTimeSubmit(e) {
             this.form.repairEndTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;

+ 2 - 2
pages/service-detail/service-detail.vue

@@ -185,9 +185,9 @@
             <view class="common btn-plain" v-show="!infoData.fourRepairUser && infoData.repairUserId"
                 @tap="handleDetail">转派
             </view>
-            <!-- 开始维修:与 PC 端一致,assistantStatus === init -->
+            <!-- 开始维修:与 PC 端一致,assistantStatus === init(计时功能上线前老工单为 NULL,视同 init) -->
             <view class="common btn-primary"
-                v-if="infoData.status === 2 && $DictCache.VALUE.REPAIR_ASSISTANT_STATUS.init === infoData.assistantStatus"
+                v-if="infoData.status === 2 && (!infoData.assistantStatus || $DictCache.VALUE.REPAIR_ASSISTANT_STATUS.init === infoData.assistantStatus)"
                 @tap="handleStartRepair">开始维修</view>
             <!-- 暂停维修:与 PC 端一致,assistantStatus === repair -->
             <view class="common btn-plain"