wangyi
2026-03-03 fbe87c8d043cb038d384df7721bc071676a0c24c
pages/MJGL/Sc_MouldRepairSendWork/Sc_MouldRepairSendWorkBill.vue
@@ -13,9 +13,9 @@
                overflow: 'auto'
            }">
            <!-- 原内容保持不变 -->
                <!-- 原内容保持不变 -->
                <view class="form-item">
                    <view class="title">器具条码:</view>
                    <view class="title">模具条码:</view>
                    <view :class="enableEdit?'right':'righton'">
                        <input v-model="hform.HBarCode" :disabled="!enableEdit"
                            @confirm="GetMessageByBarCode(hform.HBarCode)" placeholder="请输入(或扫描)器具条码" />
@@ -40,45 +40,45 @@
                        </uni-datetime-picker>
                    </view>
                </view>
            <!-- 新增源单类型和故障登记单选择 -->
                <!-- 新增源单类型和故障登记单选择 -->
                <view class="form-item">
               <view class="title">源单类型</view>
               <view class="right" v-show="showHMainSourceBillType">
                  <picker :range="arrayHMainSourceBillType" @change="HMainSourceBillTypeChange">
                    <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>
                            <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 class="righton" v-show="!showHMainSourceBillType">
                        <input name="HMainSourceBillType" disabled v-model="HMainSourceBillType"
                            placeholder="请选择源单类型" />
                    </view>
                </view>
                <view class="form-item">
               <view class="title">单据日期:</view>
               <view class="righton">
                  <input disabled v-model="hform.HDate" />
                    <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>
                </view>
@@ -97,11 +97,17 @@
                    </zxz-uni-data-select>
                </view>
                <view class="form-item">
                    <view class="title required">维修项目:</view>
                    <zxz-uni-data-select required class="right" :localdata="HRepairList" dataKey="维修项目"
                        dataValue="hitemid" v-model="hform.HRepairID">
                    <view class="title">维修项目:</view>
                    <zxz-uni-data-select class="right" :localdata="HRepairList" dataKey="维修项目" dataValue="hitemid"
                        v-model="hform.HRepairID">
                    </zxz-uni-data-select>
                </view>
                <view class="form-item">
                    <view class="title">维修内容:</view>
                    <view class="right">
                        <textarea v-model="hform.HRepairContent" placeholder="请输入维修内容" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title required">主管:</view>
@@ -111,19 +117,19 @@
                    </zxz-uni-data-select>
                </view>
                <view class="form-item">
                    <view class="title">器具名称:</view>
                    <view class="title">模具名称:</view>
                    <view class="righton">
                        <input v-model="hform.HMouldName" disabled />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">器具规格:</view>
                    <view class="title">模具规格:</view>
                    <view class="righton">
                        <input v-model="hform.HMouldModel" disabled />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">器具型号:</view>
                    <view class="title">模具型号:</view>
                    <view class="righton">
                        <input v-model="hform.HMouldSpec" disabled />
                    </view>
@@ -137,27 +143,27 @@
                overflow: 'auto'
            }">
                <view class="form-item">
               <view class="title">时间单位:</view>
               <zxz-uni-data-select class="right" :localdata="[
                    <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">
                    </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.HSupIDName" placeholder="" />
@@ -193,12 +199,6 @@
                    <view class="title">维修费用:</view>
                    <view class="right">
                        <input type="number" v-model="HDetailList[0].HMoney" placeholder="" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">维修内容:</view>
                    <view class="right">
                        <textarea v-model="hform.HRepairContent" placeholder="请输入维修内容" />
                    </view>
                </view>
                <view class="form-item">
@@ -270,7 +270,7 @@
                    </view>
                </view>
            </view>
      </template>
        </template>
        <!-- 操作按钮 -->
        <view class="buttons" id="buttons">
@@ -280,10 +280,10 @@
            <button class="btn-c" size="mini" @tap="goBack">退出</button>
        </view>
      <!-- 新增弹窗组件 -->
      <BillListPopupMouldConkBookBillVue ref="billList" :HBillType="hform.HBillType"
         :HSourceBillType="hform.HMainSourceBillType" :HStockOrgID="hform.HStockOrgID">
      </BillListPopupMouldConkBookBillVue>
        <!-- 新增弹窗组件 -->
        <BillListPopupMouldConkBookBillVue ref="billList" :HBillType="hform.HBillType"
            :HSourceBillType="hform.HMainSourceBillType" :HStockOrgID="hform.HStockOrgID">
        </BillListPopupMouldConkBookBillVue>
    </view>
</template>
@@ -298,22 +298,22 @@
    import {
        getUserInfo
    } from "../../../utils/auth";
   // 新增引入组件
   import BillListPopupMouldConkBookBillVue from '../../../components/BillListPopup/BillListPopupMouldConkBookBill.vue';
    // 新增引入组件
    import BillListPopupMouldConkBookBillVue from '../../../components/BillListPopup/BillListPopupMouldConkBookBill.vue';
    export default {
        // 器具维修派工单
        name: 'Sc_MouldRepairSendWorkBill',
      components: {
         BillListPopupMouldConkBookBillVue,
      },
        components: {
            BillListPopupMouldConkBookBillVue,
        },
        data() {
            return {
                tabs: 0,
            HMainSourceBillType: '模具故障登记单', // 新增
            showHMainSourceBillType: true, // 新增
            arrayHMainSourceBillType: ['模具故障登记单'], // 新增
            arrayHMainSourceBillTypeID: ['3815'], // 新增
                HMainSourceBillType: '模具故障登记单', // 新增
                showHMainSourceBillType: true, // 新增
                arrayHMainSourceBillType: ['模具故障登记单'], // 新增
                arrayHMainSourceBillTypeID: ['3815'], // 新增
                btnTop: 0,
                tabsBottom: 0,
                HModName: "Sc_MouldRepairSendWorkBill",
@@ -328,7 +328,7 @@
                HRepairList: [],
                hform: {
               "HBillType":"3843",
                    "HBillType": "3843",
                    "HBarCode": "",
                    "HBillNo": "",
                    "HInterID": "0",
@@ -348,13 +348,13 @@
                    "HManagerName": getUserInfo().HSecManager,
                    "HManagerID": getUserInfo().HSecManagerID,
                    "HRepairBeginDate": dayjs(new Date()).format('YYYY-MM-DD'),
               "HMainSourceBillType": 3815, // 新增:默认模具故障登记单
               "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": "内部维修",
@@ -379,7 +379,7 @@
                    "HMouldName": "",
                    "HMouldSpec": "",
                    "HMouldModel": "",
               "HStockOrgID": uni.getStorageSync("OrganizationID") || "0" // 新增
                    "HStockOrgID": uni.getStorageSync("OrganizationID") || "0" // 新增
                },
                HDetailList: [{ // 后端接口提交需要 明细信息
                    "子维修项目": "",
@@ -402,42 +402,42 @@
            },
        },
        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]
            // 新增:选择源单类型
            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
            })
         },
                // 缓存当前页面选择
                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()
         },
            // 新增:显示单据列表弹窗
            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
            }
         },
            // 新增:读取缓存
            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() {
@@ -476,13 +476,13 @@
            },
            // 提交数据有效性校验
            ValidCheck() {
            // 新增:检查故障登记单
            if (this.hform.HMainSourceBillType != 1 && !this.hform.HMainSourceBillNo) {
               return {
                  Message: "故障登记单不得为空!",
                  state: false
               }
            }
                // 新增:检查故障登记单
                if (this.hform.HMainSourceBillType != 1 && !this.hform.HMainSourceBillNo) {
                    return {
                        Message: "故障登记单不得为空!",
                        state: false
                    }
                }
                if (this.hform.HMouldID == 0) {
                    return {
@@ -498,19 +498,19 @@
                }
                if (this.hform.HEmpID == 0) {
                    return {
                  Message: "维修人不得为空!",
                        Message: "维修人不得为空!",
                        state: false
                    }
                }
            if (this.hform.HRepairID == 0) {
                    return {
                  Message: "维修项目不得为空!",
                        state: false
                    }
                }
                // if (this.hform.HRepairID == 0) {
                //                 return {
                //       Message: "维修项目不得为空!",
                //                     state: false
                //                 }
                //             }
                if (this.hform.HManagerID == 0) {
                    return {
                  Message: "主管不得为空!",
                        Message: "主管不得为空!",
                        state: false
                    }
                }
@@ -583,8 +583,8 @@
            // 获取职员数据
            async getEmpList() {
                try {
                    let sWhere=  " where 1=1 "
                    if(this.hform.HDeptName && uni.getStorageSync("Organization") == '宁波市华舟包装有限公司'){
                    let sWhere = " where 1=1 "
                    if (this.hform.HDeptName && uni.getStorageSync("Organization") == '宁波市华舟包装有限公司') {
                        sWhere += ` and HDeptName = '${this.hform.HDeptName}'`
                    }
                    let res = await CommonUtils.doRequest2Async({
@@ -798,7 +798,7 @@
                    this.HDetailList[0].HRepairID = this.hform.HRepairID
                    let sSubStr = JSON.stringify(this.HDetailList);
                    let oprType = this.operationType
                    if(oprType == 4) {
                    if (oprType == 4) {
                        // 下推的操作类型也视为新增
                        oprType = 1
                    }
@@ -828,7 +828,7 @@
                                if (res.confirm) {
                                    console.log('用户点击确定');
                                    uni.redirectTo({
                              // url: './Sc_MouldRepairSendWorkBill?operationType=1'
                                        // url: './Sc_MouldRepairSendWorkBill?operationType=1'
                                    })
                                } else if (res.cancel) {
                                    console.log('用户点击取消');
@@ -854,18 +854,23 @@
            },
            async getSourceBillInfo(HSourceBillType, HInterID, HBillNo) {
                // 下推单据类型为设备故障登记单
                if(HSourceBillType == 3815) {
                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 {
                        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 = '器具故障登记单'
@@ -878,12 +883,10 @@
                        this.hform.HMouldName = data1.产品模具
                        this.hform.HMouldModel = data1.产品模具型号
                        this.hform.HMouldSpec = data1.产品模具规格
                        this.hform.HRepairContent = data1.故障原因
                        this.enableEdit = false
                        this.showHMainSourceBillType = false
                    }
                    else {
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `获取源单失败: ${Message}`
@@ -910,7 +913,11 @@
            } else if (this.operationType == 4) {
                // 下推
                let {HSourceBillType, HInterID, HBillNo} = e
                let {
                    HSourceBillType,
                    HInterID,
                    HBillNo
                } = e
                // 下推
                // this.enableEdit = false;
                // this.enableSourceBillEdit = false;
@@ -924,28 +931,28 @@
            this.getEmpList()
            this.getCheckProjList()
            this.getRepairList()
         this.loadCache() // 新增:加载缓存
            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()
         })
            // 新增:监听单据选择完成事件
            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') // 新增:移除事件监听
      },
        onUnload() {
            uni.$off('BillSelectComplete') // 新增:移除事件监听
        },
        onReady() {
            const query = uni.createSelectorQuery().in(this)
            query.select("#buttons")
@@ -961,47 +968,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;
   }
    .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;
    .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;
      }
   }
        .uni-icons {
            color: #fff !important;
        }
    }
   .icon-wrapper[disabled] {
      background-color: rgba(228, 228, 228, 1);
      pointer-events: none;
      touch-action: none;
   }
    .icon-wrapper[disabled] {
        background-color: rgba(228, 228, 228, 1);
        pointer-events: none;
        touch-action: none;
    }
   .required {
      position: relative;
   }
    .required {
        position: relative;
    }
   .required::after {
      content: "*";
      position: relative;
      color: red;
      left: 0;
      top: 0;
      font-size: inherit;
   }
    .required::after {
        content: "*";
        position: relative;
        color: red;
        left: 0;
        top: 0;
        font-size: inherit;
    }
</style>