qq_41295110
2026-02-26 423c1948a631cff298e6348cc55626f5149c111a
pages/MJGL/Sc_MouldRepairSendWork/Sc_MouldRepairSendWorkBill.vue
@@ -12,8 +12,10 @@
                height: containerHeight + 'px',
                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="请输入(或扫描)器具条码" />
@@ -38,6 +40,35 @@
                        </uni-datetime-picker>
                    </view>
                </view>
                <!-- 新增源单类型和故障登记单选择 -->
                <view class="form-item">
                    <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">
@@ -50,34 +81,13 @@
                        <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,15 +95,19 @@
                        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>
                    <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>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </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>
@@ -101,22 +115,21 @@
                        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>
                    <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>
@@ -130,9 +143,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">
@@ -165,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">
@@ -242,8 +270,8 @@
                    </view>
                </view>
            </view>
        </template>
        <!-- 操作按钮 -->
        <view class="buttons" id="buttons">
            <button class="btn-a" size="mini" @tap="submit">提交</button>
@@ -251,7 +279,11 @@
            <button class="btn-a" size="mini" @tap="addNew">新增</button>
            <button class="btn-c" size="mini" @tap="goBack">退出</button>
        </view>
        <!-- <xe-upload ref="XeUpload" :options="uploadOptions" @callback="handleUploadCallback"></xe-upload> -->
        <!-- 新增弹窗组件 -->
        <BillListPopupMouldConkBookBillVue ref="billList" :HBillType="hform.HBillType"
            :HSourceBillType="hform.HMainSourceBillType" :HStockOrgID="hform.HStockOrgID">
        </BillListPopupMouldConkBookBillVue>
    </view>
</template>
@@ -266,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",
@@ -287,6 +328,7 @@
                HRepairList: [],
                hform: {
                    "HBillType": "3843",
                    "HBarCode": "",
                    "HBillNo": "",
                    "HInterID": "0",
@@ -299,20 +341,20 @@
                    "HCycleUnit": "小时",
                    "MouldHName": "",
                    "MouldHModel": "",
                    "HDeptIDName": "",
                    "HDeptID": "0",
                    "HManagerIDName": "",
                    "HManagerID": "0",
                    "HEmpIDName": "",
                    "HEmpID": "0",
                    "HDeptName": getUserInfo()["HDeptName"],
                    "HDeptID": getUserInfo()["HDeptID"],
                    "HEmpName": getUserInfo().HEmpName,
                    "HEmpID": getUserInfo().HEmpID,
                    "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": "内部维修",
@@ -334,9 +376,10 @@
                    "HUpDateDate": "",
                    "HDeleteMan": "",
                    "HDeleteDate": "",
                    HMouldName: "",
                    HMouldSpec: "",
                    HMouldModel: "",
                    "HMouldName": "",
                    "HMouldSpec": "",
                    "HMouldModel": "",
                    "HStockOrgID": uni.getStorageSync("OrganizationID") || "0" // 新增
                },
                HDetailList: [{ // 后端接口提交需要 明细信息
                    "子维修项目": "",
@@ -359,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 {
@@ -396,6 +476,14 @@
            },
            // 提交数据有效性校验
            ValidCheck() {
                // 新增:检查故障登记单
                if (this.hform.HMainSourceBillType != 1 && !this.hform.HMainSourceBillNo) {
                    return {
                        Message: "故障登记单不得为空!",
                        state: false
                    }
                }
                if (this.hform.HMouldID == 0) {
                    return {
                        Message: "未录入器具信息,请先录入器具信息!",
@@ -410,19 +498,19 @@
                }
                if (this.hform.HEmpID == 0) {
                    return {
                        Message: "验收人不得为空!",
                        Message: "维修人不得为空!",
                        state: false
                    }
                }
                if (this.hform.HRepairCheckMainID == 0) {
                    return {
                        Message: "验证项目不得为空!",
                        state: false
                    }
                }
                // if (this.hform.HRepairID == 0) {
                //                 return {
                //       Message: "维修项目不得为空!",
                //                     state: false
                //                 }
                //             }
                if (this.hform.HManagerID == 0) {
                    return {
                        Message: "负责人不得为空!",
                        Message: "主管不得为空!",
                        state: false
                    }
                }
@@ -439,7 +527,6 @@
                    }
                }
                return {
                    Message: "",
                    state: true
@@ -447,7 +534,7 @@
            },
            addNew() {
                uni.redirectTo({
                    url: './Sb_EquipRepairSendWorkBill?operationType=1'
                    url: './Sc_MouldRepairSendWorkBill?operationType=1'
                })
            },
            goBack() {
@@ -459,89 +546,6 @@
                    this.HCheckFileList[index]["HDotCheckResult"] = false
                } else {
                    this.HCheckFileList[index]["HDotCheckResult"] = true
                }
            },
            uploadFile(index) {
                console.log('filePath: ', this.attachmentInfo[index].filePath);
                // 通过临时路径读取文件
                uni.uploadFile({
                    url: CommonUtils.getServerUrl() + "/Sb_EquipDotCheckBill/UploadFile",
                    filePath: this.attachmentInfo[index].filePath,
                    name: 'file',
                    formData: {
                        HBillNo: this.hform.HBillNo,
                        HRemark: "",
                        HUserName: getUserInfo()["Czymc"]
                    },
                    success: (uploadRes) => {
                        CommonUtils.showTips({
                            message: "上传成功"
                        })
                        this.attachmentInfo[index].status = "上传成功"
                    },
                    fail: (err) => {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `上传失败: ${err}`
                        })
                    }
                })
            },
            delFile(index) {
                console.log('attachmentInfo: ', this.attachmentInfo[index]);
                uni.showModal({
                    title: '提示',
                    content: '确认要删除 " ' + this.attachmentInfo[index].fileName + ' " 删除后将不可恢复!',
                    success: (res) => {
                        if (res.confirm) {
                            this.attachmentInfo.splice(index, 1)
                        }
                    },
                })
            },
            handleUploadCallback(res) { // 文件上传回调
                console.log('file: ', res);
                let fileInfo = res.data[0]
                this.attachmentInfo.push({
                    fileName: fileInfo.name,
                    size: fileInfo.size,
                    status: '等待上传',
                    filePath: fileInfo.tempFilePath
                })
            },
            // 上传文件
            fileUpload() {
                this.$refs.XeUpload.upload('file', {});
            },
            //获取班次数据
            async getShiftList() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/Web/GetGy_ShiftsList_Json',
                        data: {
                            Shifts: "",
                        }
                    })
                    let {
                        data,
                        count,
                        Message
                    } = res.data
                    if (count == 1) {
                        this.HShiftsList = data
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: Message
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: err
                    })
                }
            },
            //获取使用部门数据
@@ -579,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,
                        }
                    })
@@ -639,7 +647,7 @@
            },
            toScanCode() {
                MpaasScan.scanCode(cb => {
                    this.hfrom.HBarCode = cb
                    // this.hform.HBarCode = cb
                    this.GetMessageByBarCode(cb)
                })
            },
@@ -651,7 +659,6 @@
                            HBarCode: HBarCode,
                        },
                    })
                    if (!res) {
                        return
@@ -790,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",
@@ -816,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('用户点击取消');
@@ -833,12 +845,53 @@
                        })
                    }
                } 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.enableEdit = false
                        this.showHMainSourceBillType = false
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `获取源单失败: ${Message}`
                        })
                    }
                }
            }
        },
@@ -859,7 +912,18 @@
                // 编辑
            } 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)
            }
@@ -867,6 +931,27 @@
            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)
@@ -883,5 +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;
    }
    .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>