chenhaozhe
2026-02-05 c141b01c990146b4ef41c17a69ad3066d721a91c
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,9 +137,30 @@
                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="" />
                        <input v-model="hform.HSupIDName" placeholder="" />
                    </view>
                </view>
                <view class="form-item">
@@ -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",
@@ -286,6 +328,7 @@
                HRepairList: [],
                hform: {
               "HBillType":"3843",
                    "HBarCode": "",
                    "HBillNo": "",
                    "HInterID": "0",
@@ -305,13 +348,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": "内部维修",
@@ -333,9 +376,10 @@
                    "HUpDateDate": "",
                    "HDeleteMan": "",
                    "HDeleteDate": "",
                    HMouldName: "",
                    HMouldSpec: "",
                    HMouldModel: "",
                    "HMouldName": "",
                    "HMouldSpec": "",
                    "HMouldModel": "",
               "HStockOrgID": uni.getStorageSync("OrganizationID") || "0" // 新增
                },
                HDetailList: [{ // 后端接口提交需要 明细信息
                    "子维修项目": "",
@@ -358,6 +402,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 +476,14 @@
            },
            // 提交数据有效性校验
            ValidCheck() {
            // 新增:检查故障登记单
            if (this.hform.HMainSourceBillType != 1 && !this.hform.HMainSourceBillNo) {
               return {
                  Message: "故障登记单不得为空!",
                  state: false
               }
            }
                if (this.hform.HMouldID == 0) {
                    return {
                        Message: "未录入器具信息,请先录入器具信息!",
@@ -409,19 +498,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 +526,6 @@
                        state: false
                    }
                }
                return {
                    Message: "",
@@ -495,10 +583,14 @@
            // 获取职员数据
            async getEmpList() {
                try {
                    let sWhere=  " where 1=1 "
                    if(this.hform.HDeptName && uni.getStorageSync("Organization") == '宁波市华舟包装有限公司'){
                        sWhere += ` and HDeptName = '${this.hform.HDeptName}'`
                    }
                    let res = await CommonUtils.doRequest2Async({
                        url: '/PublicPageMethod/UserList',
                        data: {
                            sWhere: " where 1=1",
                            sWhere: sWhere,
                        }
                    })
@@ -555,7 +647,7 @@
            },
            toScanCode() {
                MpaasScan.scanCode(cb => {
                    this.hform.HBarCode = cb
                    // this.hform.HBarCode = cb
                    this.GetMessageByBarCode(cb)
                })
            },
@@ -567,7 +659,6 @@
                            HBarCode: HBarCode,
                        },
                    })
                    if (!res) {
                        return
@@ -706,7 +797,12 @@
                    this.HDetailList[0].HManagerID = this.hform.HManagerID
                    this.HDetailList[0].HRepairID = this.hform.HRepairID
                    let sSubStr = JSON.stringify(this.HDetailList);
                    let sMainSub = oMain + ';' + sSubStr + `;${this.operationType}` + ';' + getUserInfo()[
                    let oprType = this.operationType
                    if(oprType == 4) {
                        // 下推的操作类型也视为新增
                        oprType = 1
                    }
                    let sMainSub = oMain + ';' + sSubStr + `;${oprType}` + ';' + getUserInfo()[
                        'Czymc'];
                    let res = await CommonUtils.doRequest2Sync({
                        url: "/Sc_MouldRepairSendWorkBill/AddBill",
@@ -732,7 +828,7 @@
                                if (res.confirm) {
                                    console.log('用户点击确定');
                                    uni.redirectTo({
                                        url: './Sb_EquipRepairSendWorkBill?operationType=1'
                              // url: './Sc_MouldRepairSendWorkBill?operationType=1'
                                    })
                                } else if (res.cancel) {
                                    console.log('用户点击取消');
@@ -749,12 +845,50 @@
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: "温馨提示",
                        message: "提交单据失败: " + err
                    })
                }
            },
            async getSourceBillInfo(HSourceBillType, HInterID, HBillNo) {
                // 下推单据类型为设备故障登记单
                if(HSourceBillType == 3815) {
                    let res = await CommonUtils.doRequest2Async({
                        url: "/Sc_MouldConkBookBill/Sb_MouldConkBookBillListCheckDetai",
                        data: {
                            HID: HInterID
                        }
                    })
                    let {data,code, count, Message} = res.data
                    console.log('data: ',data);
                    if(code == 1) {
                        console.log('data: ',data.h_v_Sc_MouldConkBookBillList_Edit);
                        let data1 = data.h_v_Sc_MouldConkBookBillList_Edit[0]
                        this.hform.HMainSourceBillType = HSourceBillType
                        this.HMainSourceBillType = '器具故障登记单'
                        this.hform.HMainSourceBillNo = data1.单据号
                        this.hform.HMainSourceInterID = data1.hmainid
                        this.hform.HMainSourceEntryID = data1.hsubid
                        this.hform.HMouldID = data1.HMouldID
                        this.hform.HManagerName = data1.负责人
                        this.hform.HManagerID = data1.HManagerID
                        this.hform.HMouldName = data1.产品模具
                        this.hform.HMouldModel = data1.产品模具型号
                        this.hform.HMouldSpec = data1.产品模具规格
                        this.hform.HRepairContent = data1.故障原因
                        this.enableEdit = false
                        this.showHMainSourceBillType = false
                    }
                    else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `获取源单失败: ${Message}`
                        })
                    }
                }
            }
        },
@@ -775,7 +909,14 @@
                // 编辑
            } else if (this.operationType == 4) {
                // 浏览
                // 下推
                let {HSourceBillType, HInterID, HBillNo} = e
                // 下推
                // this.enableEdit = false;
                // this.enableSourceBillEdit = false;
                // this.showHMainSourceBillType = false;
                this.getMaxNum()
                this.getSourceBillInfo(HSourceBillType, HInterID, HBillNo)
            }
@@ -783,7 +924,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 +961,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>