chenhaozhe
2026-01-26 f20a697d4d3b666b2754b6d7057205f3d98503b7
pages/MJGL/Sc_MouldRepairSendWork/Sc_MouldRepairSendWorkBill.vue
@@ -12,6 +12,8 @@
                height: containerHeight + 'px',
                overflow: 'auto'
            }">
            <!-- 原内容保持不变 -->
                <view class="form-item">
                    <view class="title">器具条码:</view>
                    <view :class="enableEdit?'right':'righton'">
@@ -38,46 +40,54 @@
                        </uni-datetime-picker>
                    </view>
                </view>
            <!-- 新增源单类型和故障登记单选择 -->
                <view class="form-item">
                    <view class="title">单据号:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HBillNo" />
               <view class="title">源单类型</view>
               <view class="right" v-show="showHMainSourceBillType">
                  <picker :range="arrayHMainSourceBillType" @change="HMainSourceBillTypeChange">
                     <input disabled name="HMainSourceBillType" v-model="HMainSourceBillType"
                        placeholder="请选择源单类型" />
                     <view class="picker-overlay"></view>
                  </picker>
                    </view>
               <view class="righton" v-show="!showHMainSourceBillType">
                  <input name="HMainSourceBillType" disabled v-model="HMainSourceBillType"
                     placeholder="请选择源单类型" />
                </view>
            </view>
                <view class="form-item">
               <view class="title required">故障登记单</view>
               <view class="right" v-show="hform.HMainSourceBillType != 1">
                  <input type="text" name="HBarCode" v-model="hform.HMainSourceBillNo" />
                    </view>
               <view class="icon-wrapper" v-show="hform.HMainSourceBillType != 1"
                  :disabled="hform.HMainSourceBillType == -1">
                  <uni-icons type="search" size="20" @click="showBillList"></uni-icons>
                </view>
               <view class="righton" v-show="hform.HMainSourceBillType == 1">
                  <input type="text" disabled name="HBarCode" v-model="hform.HMainSourceBillNo" />
                </view>
            </view>
                <view class="form-item">
               <view class="title">单据号:</view>
               <view class="righton">
                  <input disabled v-model="hform.HBillNo" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据日期:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HDate" />
               <view class="title">单据日期:</view>
               <view class="righton">
                  <input disabled v-model="hform.HDate" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">时间单位:</view>
                    <zxz-uni-data-select class="right" :localdata="[
                        {key: '小时', value: '小时'},
                        {key: '天', value: '天'},
                        {key: '月', value: '月'},
                    ]" dataKey="key" dataValue="value" v-model="hform.HCycleUnit">
                    </zxz-uni-data-select>
                </view>
                <view class="form-item">
                    <view class="title required">计划维修工时:</view>
                    <view class="right">
                        <input type="number" v-model="hform.HPlanTimes" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title required">实际维修工时:</view>
                    <view class="right">
                        <input type="number" v-model="hform.HTimes" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title required">维修部门:</view>
                    <zxz-uni-data-select required class="right" :localdata="HDeptList" dataKey="部门名称"
                        dataValue="HItemID" v-model="hform.HDeptID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title required">维修人:</view>
@@ -85,7 +95,6 @@
                        dataValue="HItemID" v-model="hform.HEmpID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title required">维修项目:</view>
@@ -93,7 +102,6 @@
                        dataValue="hitemid" v-model="hform.HRepairID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title required">主管:</view>
@@ -101,7 +109,6 @@
                        dataValue="HItemID" v-model="hform.HManagerID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title">器具名称:</view>
@@ -130,6 +137,27 @@
                overflow: 'auto'
            }">
                <view class="form-item">
               <view class="title">时间单位:</view>
               <zxz-uni-data-select class="right" :localdata="[
                                {key: '小时', value: '小时'},
                                {key: '天', value: '天'},
                                {key: '月', value: '月'},
                            ]" dataKey="key" dataValue="value" v-model="hform.HCycleUnit">
               </zxz-uni-data-select>
            </view>
            <view class="form-item">
               <view class="title">计划维修工时:</view>
               <view class="right">
                  <input type="number" v-model="hform.HPlanTimes" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">实际维修工时:</view>
               <view class="right">
                  <input type="number" v-model="hform.HTimes" />
               </view>
            </view>
            <view class="form-item">
                    <view class="title">供应商:</view>
                    <view class="right">
                        <input v-model="hform.HSupID" placeholder="" />
@@ -242,8 +270,8 @@
                    </view>
                </view>
            </view>
      </template>
        </template>
        <!-- 操作按钮 -->
        <view class="buttons" id="buttons">
            <button class="btn-a" size="mini" @tap="submit">提交</button>
@@ -251,6 +279,11 @@
            <button class="btn-a" size="mini" @tap="addNew">新增</button>
            <button class="btn-c" size="mini" @tap="goBack">退出</button>
        </view>
      <!-- 新增弹窗组件 -->
      <BillListPopupMouldConkBookBillVue ref="billList" :HBillType="hform.HBillType"
         :HSourceBillType="hform.HMainSourceBillType" :HStockOrgID="hform.HStockOrgID">
      </BillListPopupMouldConkBookBillVue>
    </view>
</template>
@@ -265,13 +298,22 @@
    import {
        getUserInfo
    } from "../../../utils/auth";
   // 新增引入组件
   import BillListPopupMouldConkBookBillVue from '../../../components/BillListPopup/BillListPopupMouldConkBookBill.vue';
    export default {
        // 器具维修派工单
        name: 'Sc_MouldRepairSendWorkBill',
      components: {
         BillListPopupMouldConkBookBillVue,
      },
        data() {
            return {
                tabs: 0,
                HMainSourceBillType: "",
            HMainSourceBillType: '模具故障登记单', // 新增
            showHMainSourceBillType: true, // 新增
            arrayHMainSourceBillType: ['模具故障登记单'], // 新增
            arrayHMainSourceBillTypeID: ['3815'], // 新增
                btnTop: 0,
                tabsBottom: 0,
                HModName: "Sc_MouldRepairSendWorkBill",
@@ -305,13 +347,13 @@
                    "HManagerName": getUserInfo().HSecManager,
                    "HManagerID": getUserInfo().HSecManagerID,
                    "HRepairBeginDate": dayjs(new Date()).format('YYYY-MM-DD'),
                    "HMainSourceBillType": "",
                    "HMainSourceInterID": "0",
                    "HMainSourceEntryID": "0",
               "HMainSourceBillType": 3815, // 新增:默认模具故障登记单
               "HMainSourceInterID": "0", // 新增
               "HMainSourceEntryID": "0", // 新增
                    "HPlanTimes": "0",
                    "HTimes": "0",
                    "HRepairEndDate": dayjs(new Date()).format('YYYY-MM-DD'),
                    "HMainSourceBillNo": "",
               "HMainSourceBillNo": "", // 新增
                    "HSupIDName": "",
                    "HSupID": "0",
                    "HRepairType": "内部维修",
@@ -336,6 +378,7 @@
                    HMouldName: "",
                    HMouldSpec: "",
                    HMouldModel: "",
               "HStockOrgID": uni.getStorageSync("OrganizationID") || "0" // 新增
                },
                HDetailList: [{ // 后端接口提交需要 明细信息
                    "子维修项目": "",
@@ -358,6 +401,43 @@
            },
        },
        methods: {
         // 新增:选择源单类型
         HMainSourceBillTypeChange(e) {
            if (e.detail.value == -1 || e.detail.value == NaN) {
               this.HMainSourceBillType = '手工录入'
               this.hform.HMainSourceBillType = -1
               return
            }
            console.log(e.detail.value)
            console.log(e)
            this.HMainSourceBillType = this.arrayHMainSourceBillType[e.detail.value]
            this.hform.HMainSourceBillType = this.arrayHMainSourceBillTypeID[e.detail.value]
            // 缓存当前页面选择
            const pages = getCurrentPages()
            const currentPage = pages[pages.length - 1]
            uni.setStorageSync(`${currentPage.route.split("/").pop()}_HSourceBillTypeCache`, {
               HSourceBillTypeName: this.HMainSourceBillType,
               HSourceBillType: this.hform.HMainSourceBillType
            })
         },
         // 新增:显示单据列表弹窗
         showBillList() {
            this.$refs.billList.showPopup()
         },
         // 新增:读取缓存
         loadCache() {
            const pages = getCurrentPages()
            const currentPage = pages[pages.length - 1]
            let HBillTypeCache = uni.getStorageSync(`${currentPage.route.split("/").pop()}_HSourceBillTypeCache`)
            if (HBillTypeCache) {
               this.HMainSourceBillType = HBillTypeCache.HSourceBillTypeName
               this.hform.HMainSourceBillType = HBillTypeCache.HSourceBillType
            }
         },
            // 维修项目
            async getRepairList() {
                try {
@@ -395,6 +475,14 @@
            },
            // 提交数据有效性校验
            ValidCheck() {
            // 新增:检查故障登记单
            if (this.hform.HMainSourceBillType != 1 && !this.hform.HMainSourceBillNo) {
               return {
                  Message: "故障登记单不得为空!",
                  state: false
               }
            }
                if (this.hform.HMouldID == 0) {
                    return {
                        Message: "未录入器具信息,请先录入器具信息!",
@@ -409,19 +497,19 @@
                }
                if (this.hform.HEmpID == 0) {
                    return {
                        Message: "验收人不得为空!",
                  Message: "维修人不得为空!",
                        state: false
                    }
                }
                if (this.hform.HRepairCheckMainID == 0) {
            if (this.hform.HRepairID == 0) {
                    return {
                        Message: "验证项目不得为空!",
                  Message: "维修项目不得为空!",
                        state: false
                    }
                }
                if (this.hform.HManagerID == 0) {
                    return {
                        Message: "负责人不得为空!",
                  Message: "主管不得为空!",
                        state: false
                    }
                }
@@ -437,7 +525,6 @@
                        state: false
                    }
                }
                return {
                    Message: "",
@@ -555,7 +642,7 @@
            },
            toScanCode() {
                MpaasScan.scanCode(cb => {
                    this.hform.HBarCode = cb
                    // this.hform.HBarCode = cb
                    this.GetMessageByBarCode(cb)
                })
            },
@@ -567,7 +654,6 @@
                            HBarCode: HBarCode,
                        },
                    })
                    if (!res) {
                        return
@@ -732,7 +818,7 @@
                                if (res.confirm) {
                                    console.log('用户点击确定');
                                    uni.redirectTo({
                                        url: './Sb_EquipRepairSendWorkBill?operationType=1'
                              // url: './Sc_MouldRepairSendWorkBill?operationType=1'
                                    })
                                } else if (res.cancel) {
                                    console.log('用户点击取消');
@@ -748,7 +834,6 @@
                            message: "提交单据失败: " + Message
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
@@ -783,7 +868,28 @@
            this.getEmpList()
            this.getCheckProjList()
            this.getRepairList()
         this.loadCache() // 新增:加载缓存
         // 新增:监听单据选择完成事件
         uni.$on('BillSelectComplete', (e) => {
            console.log("接收到的消息: ", e)
            this.hform.HMainSourceInterID = e.HInterID
            this.hform.HMainSourceBillNo = e.HBillNo
            this.hform.HMainSourceEntryID = e.HEntryID
            this.hform.HMouldID = e.HMouldID
            this.hform.HMouldName = e.HMouldName
            this.hform.HMouldSpec = e.HMouldSpec
            this.hform.HMouldModel = e.HMouldModel
            // 如果选择单据时带了条码,也设置条码
            if (e.HBarCode) {
               this.hform.HBarCode = e.HBarCode
            }
            this.$refs.billList.exit()
         })
        },
      onUnload() {
         uni.$off('BillSelectComplete') // 新增:移除事件监听
      },
        onReady() {
            const query = uni.createSelectorQuery().in(this)
            query.select("#buttons")
@@ -799,5 +905,47 @@
</script>
<style lang="scss" scoped>
    @import "@/pages/MJGL/style/MJBillStyle.scss"
   // @import "@/pages/MJGL/style/MJBillStyle.scss";
   .picker-overlay {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 1;
   }
   .icon-wrapper {
      background-color: #3A78FF;
      width: 52rpx;
      height: 52rpx;
      border-radius: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      .uni-icons {
         color: #fff !important;
      }
   }
   .icon-wrapper[disabled] {
      background-color: rgba(228, 228, 228, 1);
      pointer-events: none;
      touch-action: none;
   }
   .required {
      position: relative;
   }
   .required::after {
      content: "*";
      position: relative;
      color: red;
      left: 0;
      top: 0;
      font-size: inherit;
   }
</style>