<template>
|
<view>
|
<view class="form">
|
<view class="form-item">
|
<view class="title">{{ $t("MouldUpperBill.HBarCode") == "MouldUpperBill.HBarCode" ? "条码" : $t("MouldUpperBill.HBarCode") }}</view>
|
<view class="right" style="width: 350rpx;">
|
<input type="text" :focus="HBarCodeFocus" v-model="hform.HBarCode"
|
:placeholder="$t('MouldUpperBill.HBarCode_Placeholder') == 'MouldUpperBill.HBarCode_Placeholder' ? '请扫描(或输入)条码' : $t('MouldUpperBill.HBarCode_Placeholder')"
|
@confirm="getHBarCodeData(hform.HBarCode)" />
|
</view>
|
<uni-icons type="scan"
|
style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
|
size="20" @click="toScanCode"></uni-icons>
|
</view>
|
<view class="tabs">
|
<view :class="tabs == 0 ? 'on':''" @tap="() => { tabs = 0; reFocusBarCode(); }">
|
{{ $t("MouldUpperBill.tabBillInfo") == "MouldUpperBill.tabBillInfo" ? "单据信息" : $t("MouldUpperBill.tabBillInfo") }}
|
</view>
|
<view :class="tabs == 1 ? 'on':''" @tap="() => { tabs = 1; reFocusBarCode(); }">
|
{{ $t("MouldUpperBill.tabMouldInfo") == "MouldUpperBill.tabMouldInfo" ? "模具信息" : $t("MouldUpperBill.tabMouldInfo") }}
|
</view>
|
<view :class="tabs == 2 ? 'on':''" @tap="() => { tabs = 2; reFocusBarCode(); }">
|
{{ $t("MouldUpperBill.tabMakerInfo") == "MouldUpperBill.tabMakerInfo" ? "制单信息" : $t("MouldUpperBill.tabMakerInfo") }}
|
</view>
|
</view>
|
|
<!-- 单据信息 -->
|
<view v-if="tabs == 0">
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HBillNo") == "Gy.HBillNo" ? "单据号:" : $t("Gy.HBillNo") }}</view>
|
<view class="righton">
|
<input name="HBillNo" disabled v-model="hform.HBillNo" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HDate") == "Gy.HDate" ? "单据日期:" : $t("Gy.HDate") }}</view>
|
<view class="right">
|
<picker mode="date" v-model="hform.HDate" @change="HDateChange">
|
<input disabled v-model="hform.HDate" :placeholder="$t('Gy.HDate_Placeholder') == 'Gy.HDate_Placeholder' ? '请选择日期' : $t('Gy.HDate_Placeholder')" />
|
</picker>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>{{ $t("Gy.HDeptName") == "Gy.HDeptName" ? "使用部门:" : $t("Gy.HDeptName") }}</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHDeptName" :placeholder="$t('Gy.HDeptName_Placeholder') == 'Gy.HDeptName_Placeholder' ? '请选择部门' : $t('Gy.HDeptName_Placeholder')" v-model="hform.HDeptName" @input="HDeptNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>{{ $t("MouldUpperBill.HEmpName") == "MouldUpperBill.HEmpName" ? "操作员:" : $t("MouldUpperBill.HEmpName") }}</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHEmpName" :placeholder="$t('MouldUpperBill.HEmpName_Placeholder') == 'MouldUpperBill.HEmpName_Placeholder' ? '请选择操作员' : $t('MouldUpperBill.HEmpName_Placeholder')" v-model="hform.HEmpName" @input="HEmpNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>{{ $t("MouldUpperBill.HManagerName") == "MouldUpperBill.HManagerName" ? "负责人:" : $t("MouldUpperBill.HManagerName") }}</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHEmpName" :placeholder="$t('MouldUpperBill.HManagerName_Placeholder') == 'MouldUpperBill.HManagerName_Placeholder' ? '请选择负责人' : $t('MouldUpperBill.HManagerName_Placeholder')" v-model="hform.HMangerName" @input="HManagerNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title"><text>*</text>{{ $t("MouldUpperBill.HSourceName") == "MouldUpperBill.HSourceName" ? "生产资源:" : $t("MouldUpperBill.HSourceName") }}</view>
|
<view class="right">
|
<uni-combox :candidates="arrayHSourceName" :placeholder="$t('MouldUpperBill.HSourceName_Placeholder') == 'MouldUpperBill.HSourceName_Placeholder' ? '请选择生产资源' : $t('MouldUpperBill.HSourceName_Placeholder')" v-model="hform.HSourceName" @input="HSourceNameChange"></uni-combox>
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("MouldUpperBill.HScanDate") == "MouldUpperBill.HScanDate" ? "上模时间:" : $t("MouldUpperBill.HScanDate") }}</view>
|
<view class="righton">
|
<input name="HScanDate" disabled v-model="hform.HScanDate" :placeholder="$t('Gy.HDate_Placeholder') == 'Gy.HDate_Placeholder' ? '请选择' : $t('Gy.HDate_Placeholder')" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("MouldUpperBill.HICMOBillNo") == "MouldUpperBill.HICMOBillNo" ? "生产订单:" : $t("MouldUpperBill.HICMOBillNo") }}</view>
|
<view class="righton">
|
<input name="HICMOBillNo" disabled v-model="hform.HICMOBillNo" />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("MouldUpperBill.HProcExchBillNo") == "MouldUpperBill.HProcExchBillNo" ? "流转卡:" : $t("MouldUpperBill.HProcExchBillNo") }}</view>
|
<view class="righton">
|
<input disabled v-model="hform.HProcExchBillNo" />
|
</view>
|
</view>
|
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HRemark") == "Gy.HRemark" ? "备注:" : $t("Gy.HRemark") }}</view>
|
<view class="right">
|
<textarea name="HRemark" v-model="hform.HRemark" auto-height :placeholder="$t('Gy.HRemark_Placeholder') == 'Gy.HRemark_Placeholder' ? '请输入备注' : $t('Gy.HRemark_Placeholder')"></textarea>
|
</view>
|
</view>
|
|
</view>
|
<!-- 模具信息 -->
|
<view v-if="tabs == 1">
|
<view class="card-list" :style="{height: `${listTableHeight}px`, overflow: 'auto'}">
|
<!-- 卡片列表 -->
|
<view v-for="(item, index) in listData" :key="index" class="card-item">
|
<uni-card style="margin: 10rpx 0;">
|
<view class="card-content">
|
<view class="card-row">
|
<text class="label">{{ $t("MouldUpperBill.table_SerialNo") == "MouldUpperBill.table_SerialNo" ? "序号:" : $t("MouldUpperBill.table_SerialNo") }}</text>
|
<text class="value">{{ index + 1 }}</text>
|
</view>
|
<view class="card-row">
|
<text class="label">{{ $t("MouldUpperBill.table_MouldCode") == "MouldUpperBill.table_MouldCode" ? "器具编码:" : $t("MouldUpperBill.table_MouldCode") }}</text>
|
<text class="value">{{ item.器具编码 }}</text>
|
</view>
|
<view class="card-row">
|
<text class="label">{{ $t("MouldUpperBill.table_MouldName") == "MouldUpperBill.table_MouldName" ? "器具名称:" : $t("MouldUpperBill.table_MouldName") }}</text>
|
<text class="value">{{ item.器具名称 }}</text>
|
</view>
|
<view class="card-row">
|
<text class="label">{{ $t("MouldUpperBill.table_MouldModel") == "MouldUpperBill.table_MouldModel" ? "器具型号:" : $t("MouldUpperBill.table_MouldModel") }}</text>
|
<text class="value">{{ item.器具型号 }}</text>
|
</view>
|
<view class="card-row">
|
<text class="label">{{ $t("Gy.HBarCode") == "Gy.HBarCode" ? "器具条码:" : $t("Gy.HBarCode") }}</text>
|
<text class="value">{{ item.器具条码 }}</text>
|
</view>
|
<view class="card-row">
|
<text class="label">{{ $t("Gy.HQty") == "Gy.HQty" ? "器具数量:" : $t("Gy.HQty") }}</text>
|
<text class="value">{{ item.器具数量 }}</text>
|
</view>
|
</view>
|
</uni-card>
|
</view>
|
|
<view class="over" v-if="listData.length == 0">{{ $t("MouldUpperBill.noMouldData") == "MouldUpperBill.noMouldData" ? "暂无模具数据" : $t("MouldUpperBill.noMouldData") }}</view>
|
</view>
|
</view>
|
|
<view v-if="tabs == 2">
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HMaker") == "Gy.HMaker" ? "制单人:" : $t("Gy.HMaker") }}</view>
|
<view class="righton">
|
<input v-model="hform.HMaker" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HMakeDate") == "Gy.HMakeDate" ? "制单日期:" : $t("Gy.HMakeDate") }}</view>
|
<view class="righton">
|
<input v-if="hform.HMakeDate" v-model="hform.HMakeDate.substr(0,10)" disabled />
|
<input v-else v-model="hform.HMakeDate" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HUpDater") == "Gy.HUpDater" ? "修改人:" : $t("Gy.HUpDater") }}</view>
|
<view class="righton">
|
<input v-model="hform.HUpDater" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HUpDateDate") == "Gy.HUpDateDate" ? "修改日期:" : $t("Gy.HUpDateDate") }}</view>
|
<view class="righton">
|
<input v-if="hform.HUpDateDate" v-model="hform.HUpDateDate.substr(0,10)" disabled />
|
<input v-else v-model="hform.HUpDateDate" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HChecker") == "Gy.HChecker" ? "审核人:" : $t("Gy.HChecker") }}</view>
|
<view class="righton">
|
<input v-model="hform.HChecker" disabled />
|
</view>
|
</view>
|
<view class="form-item">
|
<view class="title">{{ $t("Gy.HCheckDate") == "Gy.HCheckDate" ? "审核日期:" : $t("Gy.HCheckDate") }}</view>
|
<view class="righton">
|
<input v-if="hform.HCheckDate" v-model="hform.HCheckDate.substr(0,10)" disabled />
|
<input v-else v-model="hform.HCheckDate" disabled />
|
</view>
|
</view>
|
|
</view>
|
|
<view class="bottom-btn">
|
<button v-if="btnType == 1 && !isEdit" class="btn-a" size="mini" @tap="submit">{{ $t("MouldUpperBill.submit") == "MouldUpperBill.submit" ? "提交" : $t("MouldUpperBill.submit") }}</button>
|
<button v-if="btnType != 1 && !isEdit" class="btn-a" size="mini" @tap="ifEdit">{{ $t("MouldUpperBill.modify") == "MouldUpperBill.modify" ? "修改" : $t("MouldUpperBill.modify") }}</button>
|
<button v-if="btnType != 1 && isEdit" class="btn-a" size="mini" @tap="submit">{{ $t("MouldUpperBill.submit") == "MouldUpperBill.submit" ? "提交" : $t("MouldUpperBill.submit") }}</button>
|
<button class="btn-c" size="mini" @tap="goBack">{{ $t("MouldUpperBill.goBack") == "MouldUpperBill.goBack" ? "退出" : $t("MouldUpperBill.goBack") }}</button>
|
</view>
|
</view>
|
|
</view>
|
</template>
|
<script>
|
import getDateTime from '@/utils/getdateTime.js';
|
import {
|
getUserInfo
|
} from "@/utils/auth.js";
|
export default {
|
data() {
|
return {
|
// 计算列表高度
|
bottomBtnTop: 0,
|
listTableTop: 0,
|
tabs: 0,
|
|
userInfo: getUserInfo(),
|
serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
|
linterid: '',
|
HBillNo: '',
|
btnType: 1, //1新增,3修改
|
showmore: false,
|
HBarCodeFocus: false,
|
|
arrayHDeptName: [], //部门
|
HDeptNameList: [],
|
arrayHEmpName: [], //发现人/负责人
|
HEmpNameList: [],
|
arrayHSourceName: [], //生产资源
|
HSourceNameList: [],
|
|
|
isEdit: false,
|
listOption: [], // 列表选项
|
listData: [], // 表格数据
|
selectedRows: [], // 表格选中的数据
|
|
hform: {
|
HInterID: '',
|
HBillNo: '',
|
HDate: getDateTime.dateTimeStr('y-m-d'),
|
HBarCode: '',
|
HDeptName: uni.getStorageSync('HDeptName'),
|
HDeptID: uni.getStorageSync('HDeptID'),
|
HEmpName: uni.getStorageSync('HEmpName'),
|
HEmpID: uni.getStorageSync('HEmpID'),
|
HMangerName: uni.getStorageSync('HMangerName'),
|
HMangerID: uni.getStorageSync('HMangerID'),
|
|
|
HSourceName: '',
|
HSourceID: '0',
|
HQty: '0',
|
HScanDate: getDateTime.dateTimeStr('y-m-d h:i:s'),
|
HMaterID: '0',
|
HICMOBillNo: '',
|
HICMOInterID: '0',
|
HICMOEntryID: '0',
|
HProcExchBillNo: '',
|
HProcExchInterID: '0',
|
HProcExchEntryID: '0',
|
HOrgID: uni.getStorageSync('OrganizationID'),
|
|
HMaker: '',
|
HMakeDate: '',
|
HUpDater: '',
|
HUpDateDate: '',
|
HChecker: '',
|
HCheckDate: '',
|
HCloseMan: '',
|
HCloseDate: '',
|
HDeleteMan: '',
|
HDeleteDate: '',
|
|
eventType: 'Add'
|
}
|
}
|
},
|
onLoad(e) {
|
|
uni.setNavigationBarTitle({
|
title: this.$t("MouldUpperBill.title") == 'MouldUpperBill.title' ? '上模单' : this.$t("MouldUpperBill.title")
|
})
|
this.HBarCodeFocus = true
|
this.getHDeptList()
|
this.getHEmpList()
|
this.getHSourceList()
|
this.hform.HMaker = uni.getStorageSync('HUserName')
|
console.log(e, this.userInfo)
|
if (e.linterid) {
|
this.btnType = 3
|
this.linterid = e.linterid
|
this.HBillNo = e.HBillNo
|
this.getEditData(e.linterid, e.HBillNo)
|
this.getMouldDetailData(e.linterid, e.HBillNo);
|
} else {
|
this.getNewData()
|
}
|
this.tabs = 0
|
},
|
// ==================== 计算属性 ====================
|
computed: {
|
// 计算表格高度
|
listTableHeight: {
|
get() {
|
return this.bottomBtnTop - this.listTableTop - 10
|
}
|
}
|
},
|
methods: {
|
//扫码
|
toScanCode() {
|
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
|
mpaasScanModule.mpaasScan({
|
'hideAlbum': true,
|
'timeoutInterval': '10', //超时时间
|
'timeoutText': this.$t('MouldUpperBill.scanTimeoutText') == 'MouldUpperBill.scanTimeoutText' ? '未识别到二维码' : this.$t('MouldUpperBill.scanTimeoutText') //超时提醒
|
}, (ret) => {
|
console.log(ret.resp_result)
|
this.hform.HBarCode = ret.resp_result
|
this.getHBarCodeData(ret.resp_result)
|
})
|
},
|
//光标
|
async refreshBarCodeState() {
|
this.HBarCodeFocus = false
|
await this.$nextTick(() => {
|
this.HBarCodeFocus = true
|
this.hform.HBarCode = ""
|
})
|
},
|
// 添加一个重新聚焦的方法
|
reFocusBarCode() {
|
this.HBarCodeFocus = false;
|
this.$nextTick(() => {
|
this.HBarCodeFocus = true;
|
});
|
},
|
//日期
|
HDateChange(e) {
|
console.log(e.detail.value)
|
this.hform.HDate = e.detail.value
|
},
|
getHBarCodeData(HBarCode) {
|
if (uni.getStorageSync('Organization') == "杭州斯莫尔磁性材料有限公司") {
|
if (!this.hform.HSourceName) {
|
uni.showToast({
|
title: this.$t('MouldUpperBill.selectSourceFirst') == 'MouldUpperBill.selectSourceFirst' ? '请先选择或扫描生产资源' : this.$t('MouldUpperBill.selectSourceFirst'),
|
icon: 'none'
|
});
|
return;
|
}
|
}
|
var HBillType = "";
|
var barNo = "";
|
if (HBarCode.length < 22) {
|
if (HBarCode.substr(0, 4) === "GXLX") {
|
HBillType = "3772";
|
} else if (HBarCode.substr(0, 2) === "WP") {
|
HBillType = "3710";
|
} else if (HBarCode.substr(0, 4) === "SCRW") {
|
HBillType = "3710";
|
}
|
}
|
|
if (HBarCode.length > 22) {
|
barNo = HBarCode.substr(0, 22);
|
switch (barNo) {
|
case "https://qr61.cn/omM1Cj":
|
HBillType = "3899";
|
break;
|
case "https://qr61.cn/oAhaGh":
|
HBillType = "3308";
|
break;
|
case "https://www.aliwork.com":
|
HBillType = "3308";
|
break;
|
}
|
}
|
uni.request({
|
url: this.serverUrl + '/Sc_MouldUpperBill/txtHBarCode_KeyDown',
|
data: {
|
HBarCode: this.hform.HBarCode,
|
HSourceID: this.hform.HSourceID,
|
UserID: uni.getStorageSync('Czybm'),
|
HBillType: HBillType
|
},
|
success: (res) => {
|
if (res.data.code == 1) {
|
var data = res.data.data[0];
|
var num = data.Num;
|
switch (num) {
|
//生产资源
|
case 1:
|
this.hform.HSourceID = data.HItemID;
|
this.hform.HSourceName = data.HName;
|
this.refreshBarCodeState();
|
break;
|
//生产订单
|
case 2:
|
this.hform.HICMOBillNo = data.单据号;
|
this.hform.HICMOInterID = data.hmainid;
|
this.hform.HICMOEntryID = data.HEntryID;
|
this.hform.HMaterID = data.HMaterID;
|
this.refreshBarCodeState();
|
if (uni.getStorageSync('OrganizationID') == "100007" && uni.getStorageSync(
|
'Organization') == "事业一处") {
|
//获取器具清单
|
this.GetMaterialMouldList();
|
}
|
break;
|
//模具
|
case 3:
|
if (!this.hform.HICMOBillNo && !this.hform.HProcExchBillNo) {
|
uni.showToast({
|
title: this.$t('MouldUpperBill.scanWorkOrderFirst') == 'MouldUpperBill.scanWorkOrderFirst' ? '请先扫描生产工单' : this.$t('MouldUpperBill.scanWorkOrderFirst'),
|
icon: 'none'
|
});
|
return;
|
}
|
// 根据组织条件决定是否进行校验
|
const isSpecialOrg = uni.getStorageSync('OrganizationID') == "100007" &&
|
uni.getStorageSync('Organization') == "事业一处";
|
|
if (isSpecialOrg) {
|
// 特殊组织:需要调用模具档案检查
|
this.getMould_FC().then(isValid => {
|
if (isValid) {
|
this.handleMouldData(data);
|
} else {
|
// 校验不通过,清空条码但不添加数据
|
this.refreshBarCodeState();
|
}
|
}).catch(error => {
|
console.log('校验失败:', error);
|
this.refreshBarCodeState();
|
});
|
} else {
|
// 其他组织:直接处理模具数据
|
this.handleMouldData(data);
|
}
|
break;
|
//流转卡
|
case 4:
|
this.hform.HProcExchBillNo = data.单据号;
|
this.hform.HProcExchInterID = data.hmainid;
|
this.hform.HProcExchEntryID = data.HEntryID;
|
this.hform.HICMOBillNo = data.任务单号;
|
this.hform.HICMOInterID = data.hicmointerid;
|
this.hform.HICMOEntryID = data.HICMOEntryID;
|
this.hform.HMaterID = data.HMaterID;
|
this.hform.HSourceID = data.HSourceID;
|
this.hform.HSourceName = data.HSourceName;
|
this.refreshBarCodeState();
|
if (uni.getStorageSync('OrganizationID') == "100007" && uni.getStorageSync(
|
'Organization') == "事业一处") {
|
//获取器具清单
|
this.GetMaterialMouldList();
|
}
|
break;
|
default:
|
uni.showToast({
|
title: this.$t('MouldUpperBill.unknownType') == 'MouldUpperBill.unknownType' ? '未知的返回类型' : this.$t('MouldUpperBill.unknownType'),
|
icon: 'none',
|
});
|
break;
|
}
|
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.requestFailed') == 'MouldUpperBill.requestFailed' ? '接口请求失败' : this.$t('MouldUpperBill.requestFailed'),
|
icon: 'none'
|
})
|
},
|
});
|
},
|
handleMouldData(data) {
|
this.tabs = 1;
|
// 检查模具是否已存在于表格中
|
const existingIndex = this.listData.findIndex(item =>
|
item.HMouldID === data.hmainid
|
);
|
|
const isSpecialOrg = uni.getStorageSync('OrganizationID') == "100007" &&
|
uni.getStorageSync('Organization') == "事业一处";
|
|
if (isSpecialOrg) {
|
// 特殊组织:检查物料器具清单
|
if (existingIndex === -1) {
|
// 如果不存在,说明不在当前物料的检具清单中
|
uni.showToast({
|
title: this.$t('MouldUpperBill.mouldNotInList') == 'MouldUpperBill.mouldNotInList' ? '当前检具不在当前物料的检具清单中' : this.$t('MouldUpperBill.mouldNotInList'),
|
icon: 'none',
|
duration: 1500
|
});
|
this.refreshBarCodeState();
|
} else {
|
// 如果已存在,检查器具数量
|
if (this.listData[existingIndex].器具数量 === 0) {
|
// 器具数量为0,更新条码并将数量变为1
|
this.listData[existingIndex].器具条码 = this.hform.HBarCode;
|
this.listData[existingIndex].器具数量 = 1;
|
uni.showToast({
|
title: this.$t('MouldUpperBill.scanSuccess') == 'MouldUpperBill.scanSuccess' ? '扫描成功' : this.$t('MouldUpperBill.scanSuccess'),
|
icon: 'success',
|
duration: 1500
|
});
|
this.refreshBarCodeState();
|
} else {
|
// 器具数量已为1,提示不允许重复扫描
|
uni.showToast({
|
title: this.$t('MouldUpperBill.mouldAlreadyScanned') == 'MouldUpperBill.mouldAlreadyScanned' ? '该模具已扫描,不允许重复扫描' : this.$t('MouldUpperBill.mouldAlreadyScanned'),
|
icon: 'none',
|
duration: 1500
|
});
|
this.refreshBarCodeState();
|
}
|
}
|
} else {
|
// 其他组织:直接处理
|
if (existingIndex === -1) {
|
// 如果不存在,添加到表格
|
const newRow = {
|
index: this.listData.length + 1,
|
HMouldID: data.hmainid,
|
器具编码: data.模具编号,
|
器具名称: data.模具名称,
|
器具型号: data.模具型号,
|
器具条码: this.hform.HBarCode,
|
器具数量: 1,
|
checked: false // 默认不选中
|
};
|
this.listData.push(newRow);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.scanSuccess') == 'MouldUpperBill.scanSuccess' ? '扫描成功' : this.$t('MouldUpperBill.scanSuccess'),
|
icon: 'success',
|
duration: 1500
|
});
|
this.refreshBarCodeState();
|
} else {
|
// 如果已存在,提示用户
|
uni.showToast({
|
title: this.$t('MouldUpperBill.mouldAlreadyScanned') == 'MouldUpperBill.mouldAlreadyScanned' ? '该模具已扫描' : this.$t('MouldUpperBill.mouldAlreadyScanned'),
|
icon: 'none',
|
duration: 1500
|
});
|
this.refreshBarCodeState();
|
}
|
}
|
},
|
//获取使用部门数据
|
getHDeptList() {
|
uni.request({
|
url: this.serverUrl + '/PublicPageMethod/DeptList',
|
data: {
|
sWhere: "where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + uni.getStorageSync(
|
'OrganizationID') + ""
|
},
|
success: (res) => {
|
if (res.data.count == 1) {
|
this.HDeptNameList = res.data.data
|
for (var i = 0; i < res.data.data.length; i++) {
|
this.arrayHDeptName[i] = res.data.data[i].HName
|
}
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.requestFailed') == 'MouldUpperBill.requestFailed' ? '接口请求失败' : this.$t('MouldUpperBill.requestFailed'),
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//选择使用部门
|
HDeptNameChange(e) {
|
for (var i = 0; i < this.HDeptNameList.length; i++) {
|
if (this.HDeptNameList[i].HName == e) {
|
this.hform.HDeptID = this.HDeptNameList[i].HItemID
|
}
|
}
|
},
|
//操作员、负责人
|
getHEmpList() {
|
uni.request({
|
url: this.serverUrl + '/Web/GetEmployeeList_Json',
|
data: {
|
Employee: '',
|
HGroupID: 0,
|
HDeptID: getUserInfo()["HDeptID"] || -1
|
},
|
success: (res) => {
|
if (res.data.count == 1) {
|
this.HEmpNameList = res.data.data
|
for (var i = 0; i < res.data.data.length; i++) {
|
this.arrayHEmpName[i] = res.data.data[i].HName
|
}
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.requestFailed') == 'MouldUpperBill.requestFailed' ? '接口请求失败' : this.$t('MouldUpperBill.requestFailed'),
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//选择操作员
|
HEmpNameChange(e) {
|
for (var i = 0; i < this.HEmpNameList.length; i++) {
|
if (this.HEmpNameList[i].HName == e) {
|
this.hform.HEmpID = this.HEmpNameList[i].HItemID
|
}
|
}
|
},
|
//选择负责人
|
HManagerNameChange(e) {
|
for (var i = 0; i < this.HEmpNameList.length; i++) {
|
if (this.HEmpNameList[i].HName == e) {
|
this.hform.HMangerID = this.HEmpNameList[i].HItemID
|
}
|
}
|
},
|
//生产资源
|
getHSourceList() {
|
uni.request({
|
url: this.serverUrl + '/api/newBill/getSourceList',
|
data: {
|
sWhere: " and HUSEORGID = " + uni.getStorageSync('OrganizationID') + ""
|
},
|
success: (res) => {
|
if (res.data.code == 1) {
|
this.HSourceNameList = res.data.data.Gy_Source
|
for (var i = 0; i < res.data.data.Gy_Source.length; i++) {
|
this.arrayHSourceName[i] = res.data.data.Gy_Source[i].生产资源
|
}
|
this.$forceUpdate();
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.requestFailed') == 'MouldUpperBill.requestFailed' ? '接口请求失败' : this.$t('MouldUpperBill.requestFailed'),
|
icon: 'none'
|
})
|
},
|
});
|
},
|
//选择生产资源
|
HSourceNameChange(e) {
|
for (var i = 0; i < this.HSourceNameList.length; i++) {
|
if (this.HSourceNameList[i].生产资源 == e) {
|
this.hform.HSourceID = this.HSourceNameList[i].HItemID
|
}
|
}
|
},
|
ifEdit() {
|
this.isEdit = true
|
this.hform.eventType = 'Modify'
|
},
|
//编辑回显
|
getEditData(linterid, HBillNo) {
|
//主表
|
var sWhere = " and hmainid='" + linterid + "'";
|
uni.request({
|
url: this.serverUrl + '/Sc_MouldUpperBill/Sc_MouldUpperBillList',
|
data: {
|
sWhere: sWhere,
|
user: uni.getStorageSync('HUserName')
|
},
|
success: (res) => {
|
console.log(1, res.data.data[0]);
|
if (res.data.code == 1) {
|
var data = res.data.data[0]
|
this.btnType = 3
|
this.hform.HInterID = data.hmainid
|
this.hform.HBillNo = data.单据号
|
this.hform.HBarCode = data.条形码
|
this.hform.HDeptID = data.HDeptID
|
this.hform.HDeptName = data.部门
|
this.hform.HEmpID = data.HEmpID
|
this.hform.HEmpName = data.操作员
|
this.hform.HMangerID = data.HMangerID
|
this.hform.HMangerName = data.负责人
|
this.hform.HRemark = data.表头备注
|
this.hform.HDate = data.日期.substr(0, 10)
|
|
this.hform.HSourceID = data.HSourceID,
|
this.hform.HSourceName = data.生产资源,
|
this.hform.HQty = data.数量,
|
this.hform.HScanDate = data.上模扫码时间,
|
this.hform.HICMOBillNo = data.HICMOBillNo,
|
this.hform.HICMOInterID = data.HICMOInterID,
|
this.hform.HICMOEntryID = data.HICMOEntryID,
|
this.hform.HProcExchBillNo = data.HProcExchBillNo,
|
this.hform.HProcExchInterID = data.HProcExchInterID,
|
this.hform.HProcExchEntryID = data.HProcExchEntryID,
|
this.hform.HOrgID = data.HOrgID,
|
|
this.hform.HMaker = data.制单人
|
this.hform.HMakeDate = data.制单日期
|
this.hform.HUpDater = data.修改人
|
this.hform.HUpDateDate = data.修改日期
|
this.hform.HChecker = data.审核人
|
this.hform.HCheckDate = data.审核日期
|
this.hform.HDeleteMan = data.作废人
|
this.hform.HDeleteDate = data.作废日期
|
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.requestFailed') == 'MouldUpperBill.requestFailed' ? '接口请求失败' : this.$t('MouldUpperBill.requestFailed'),
|
icon: 'none'
|
})
|
},
|
});
|
},
|
// 编辑获取模具明细的方法
|
getMouldDetailData(linterid) {
|
var sWhere = " and hmainid='" + linterid + "'";
|
uni.request({
|
url: this.serverUrl + '/Sc_MouldUpperBill/Sc_MouldUpperBillList',
|
data: {
|
sWhere: sWhere,
|
user: uni.getStorageSync('HUserName')
|
},
|
success: (res) => {
|
if (res.data.code == 1 && res.data.data && res.data.data.length > 0) {
|
this.listData = [];
|
|
res.data.data.forEach((item, index) => {
|
this.listData.push({
|
index: index + 1,
|
HMouldID: item.HMouldID,
|
器具编码: item.模具编码 || item.HMouldNumber,
|
器具名称: item.模具名称 || item.HMouldName,
|
器具型号: item.模具规格 || item.HMouldModel,
|
器具条码: item.条形码 || item.HBarCode,
|
器具数量: item.数量 || item.HBarCode
|
});
|
});
|
|
this.selectedRows = [...this.listData];
|
}
|
},
|
fail: (res) => {
|
console.log('获取模具明细失败:', res);
|
}
|
});
|
},
|
// 提供工单的物料自动带出对应的产品器具清单
|
GetMaterialMouldList() {
|
var sWhere = " and HMaterID='" + this.hform.HMaterID + "'";
|
uni.request({
|
url: this.serverUrl + '/Sc_MouldUpperBill/GetMaterialMouldList',
|
data: {
|
sWhere: sWhere,
|
user: uni.getStorageSync('HUserName')
|
},
|
success: (res) => {
|
if (res.data.code == 1 && res.data.data && res.data.data.length > 0) {
|
this.listData = [];
|
this.tabs = 1;
|
res.data.data.forEach((item, index) => {
|
this.listData.push({
|
index: index + 1,
|
HMouldID: item.HMouldID,
|
器具编码: item.模具编号 || item.HMouldNumber,
|
器具名称: item.模具名称 || item.HMouldName,
|
器具型号: item.模具型号 || item.HMouldModel,
|
器具条码: item.条形码 || item.HBarCode,
|
器具数量: 0
|
});
|
});
|
|
this.selectedRows = [...this.listData];
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log('获取模具明细失败:', res);
|
}
|
});
|
},
|
// 条码扫描时候判断是否是存在模具档案 并且是否存在产品器具清单
|
getMould_FC() {
|
return new Promise((resolve, reject) => {
|
uni.request({
|
url: this.serverUrl + '/Sc_MouldUpperBill/GetBarCode_FC',
|
data: {
|
HBarCode: this.hform.HBarCode,
|
HMaterID: this.hform.HMaterID
|
},
|
success: (res) => {
|
if (res.data.code == 1) {
|
// 校验通过
|
resolve(true);
|
} else {
|
// 校验不通过,显示错误信息
|
uni.showToast({
|
title: res.data.Message || this.$t('MouldUpperBill.mouldCheckFailed') == 'MouldUpperBill.mouldCheckFailed' ? '模具档案校验失败' : this.$t('MouldUpperBill.mouldCheckFailed'),
|
icon: 'none'
|
});
|
resolve(false);
|
}
|
},
|
fail: (res) => {
|
console.log('获取模具条码失败:', res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.checkNetworkFailed') == 'MouldUpperBill.checkNetworkFailed' ? '校验失败,请检查网络' : this.$t('MouldUpperBill.checkNetworkFailed'),
|
icon: 'none'
|
});
|
resolve(false);
|
}
|
});
|
});
|
},
|
//新增
|
getNewData() {
|
uni.request({
|
url: this.serverUrl + '/Web/GetMAXNum',
|
data: {
|
HBillType: '3846'
|
},
|
success: (res) => {
|
console.log(res.data)
|
if (res.data.count == 1) {
|
this.hform.HInterID = res.data.data[0].HInterID
|
this.hform.HBillNo = res.data.data[0].HBillNo
|
this.hform.HMakeDate = getDateTime.dateTimeStr('y-m-d')
|
this.btnType = 1
|
} else {
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.requestFailed') == 'MouldUpperBill.requestFailed' ? '接口请求失败' : this.$t('MouldUpperBill.requestFailed'),
|
icon: 'none'
|
})
|
},
|
});
|
},
|
submit() {
|
if (uni.getStorageSync('Organization') == "杭州斯莫尔磁性材料有限公司") {
|
if (!this.hform.HSourceName) {
|
uni.showToast({
|
title: this.$t('MouldUpperBill.selectSourceFirst') == 'MouldUpperBill.selectSourceFirst' ? '请先选择生产资源' : this.$t('MouldUpperBill.selectSourceFirst'),
|
icon: 'none'
|
});
|
return;
|
}
|
}
|
if (this.listData.length === 0) {
|
uni.showToast({
|
title: this.$t('MouldUpperBill.addAtLeastOneMould') == 'MouldUpperBill.addAtLeastOneMould' ? '请至少添加一个模具' : this.$t('MouldUpperBill.addAtLeastOneMould'),
|
icon: 'none'
|
})
|
}
|
// 如果是事业一处组织,校验器具数量
|
if (uni.getStorageSync('OrganizationID') === "100007" && uni.getStorageSync('Organization') === "事业一处") {
|
const zeroQtyItem = this.listData.find(item => {
|
// 考虑0、null、undefined等异常情况
|
const qty = Number(item.器具数量) || 0;
|
return qty <= 0;
|
});
|
|
if (zeroQtyItem) {
|
// 找到第一个数量异常项的位置(索引+1)
|
const index = this.listData.indexOf(zeroQtyItem) + 1;
|
const code = zeroQtyItem.器具编码 || this.$t('MouldUpperBill.unknownCode') == 'MouldUpperBill.unknownCode' ? '未知编码' : this.$t('MouldUpperBill.unknownCode');
|
uni.showToast({
|
title: this.$t('MouldUpperBill.qtyZeroError') == 'MouldUpperBill.qtyZeroError' ? '第{index}行【{code}】器具数量为0,请检查' : this.$t('MouldUpperBill.qtyZeroError').replace('{index}', index).replace('{code}', code),
|
icon: 'none',
|
duration: 3000
|
});
|
return;
|
}
|
}
|
if (!this.hform.HEmpName) {
|
uni.showToast({
|
title: this.$t('MouldUpperBill.selectOperator') == 'MouldUpperBill.selectOperator' ? '请选择操作员' : this.$t('MouldUpperBill.selectOperator'),
|
icon: 'none'
|
})
|
} else if (!this.hform.HMangerName) {
|
uni.showToast({
|
title: this.$t('MouldUpperBill.selectManager') == 'MouldUpperBill.selectManager' ? '请选择负责人' : this.$t('MouldUpperBill.selectManager'),
|
icon: 'none'
|
})
|
} else if (!this.hform.HDeptName) {
|
uni.showToast({
|
title: this.$t('MouldUpperBill.selectDept') == 'MouldUpperBill.selectDept' ? '请选择部门' : this.$t('MouldUpperBill.selectDept'),
|
icon: 'none'
|
})
|
} else {
|
uni.showLoading({
|
title: this.$t('MouldUpperBill.pleaseWait') == 'MouldUpperBill.pleaseWait' ? '请稍候' : this.$t('MouldUpperBill.pleaseWait')
|
})
|
// ========== 第一步:构建主表数据 ==========
|
const mainData = {
|
HBillNo: this.hform.HBillNo,
|
HInterID: this.hform.HInterID,
|
HDate: this.hform.HDate,
|
|
// 扫码信息
|
HBarCode: this.hform.HBarCode,
|
|
// 部门信息
|
HDeptName: this.hform.HDeptName,
|
HDeptID: this.hform.HDeptID,
|
|
// 人员信息
|
HEmpName: this.hform.HEmpName,
|
HEmpID: this.hform.HEmpID,
|
HMangerName: this.hform.HMangerName,
|
HMangerID: this.hform.HMangerID,
|
|
// 其他信息
|
HRemark: this.hform.HRemark || "",
|
HOrgID: this.hform.HOrgID,
|
|
// 系统字段
|
HMaker: this.hform.HMaker || uni.getStorageSync('HUserName'),
|
hupdater: this.hform.HUpDater || uni.getStorageSync('HUserName'),
|
hchecker: this.hform.HChecker || "",
|
HMakeDate: this.hform.HMakeDate || getDateTime.dateTimeStr('y-m-d'),
|
hupdatedate: this.hform.HUpDateDate || getDateTime.dateTimeStr('y-m-d'),
|
hcheckdate: this.hform.HCheckDate || "",
|
hdeleteman: this.hform.HDeleteMan || "",
|
hdeletedate: this.hform.HDeleteDate || "",
|
};
|
|
// ========== 第二步:构建明细数据 ==========
|
const detailData = this.listData.map((item, index) => ({
|
HMouldID: item.HMouldID,
|
HMouldNumber: item.器具编码,
|
HMouldName: item.器具名称,
|
HMouldModel: item.器具型号,
|
HBarCode: item.器具条码,
|
HQty: 1, // 每个模具数量默认为1
|
|
// 从hform中复用的生产信息
|
HSourceID: this.hform.HSourceID,
|
HSourceName: this.hform.HSourceName,
|
HICMOInterID: this.hform.HICMOInterID || "0",
|
HICMOEntryID: this.hform.HICMOEntryID || "0",
|
HICMOBillNo: this.hform.HICMOBillNo || "",
|
|
LAY_TABLE_INDEX: index // 从0开始的索引
|
}));
|
|
// ========== 第三步:拼接完整数据 ==========
|
const submitStr = JSON.stringify(mainData) + ";" + JSON.stringify(detailData) + ";" + this.btnType +
|
";" + uni.getStorageSync('HUserName');
|
|
|
console.log(submitStr);
|
uni.request({
|
url: this.serverUrl + '/Sc_MouldUpperBill/AddSc_MouldUpperBill_APP',
|
method: 'POST',
|
dataType: "json",
|
data: {
|
sMainSub: submitStr
|
},
|
success: (res) => {
|
console.log(1, res);
|
uni.hideLoading()
|
if (res.data.count == 1) {
|
let pages = getCurrentPages();
|
let prePage = pages[pages.length - 2];
|
|
uni.showModal({
|
title: this.$t('MouldUpperBill.confirmTitle') == 'MouldUpperBill.confirmTitle' ? '提示' : this.$t('MouldUpperBill.confirmTitle'),
|
content: res.data.Message + (this.$t('MouldUpperBill.continueAdd') == 'MouldUpperBill.continueAdd' ? '。是否继续新增?' : this.$t('MouldUpperBill.continueAdd')),
|
success: (res) => {
|
if (res.confirm) {
|
console.log("用户点击确定");
|
uni.redirectTo({
|
url: "/pages/shangmudan/MouldUpperBill",
|
});
|
} else if (res.cancel) {
|
console.log("用户点击取消");
|
setTimeout(() => {
|
uni.navigateBack();
|
}, 50)
|
}
|
},
|
});
|
}
|
uni.showToast({
|
title: res.data.Message,
|
icon: 'none'
|
})
|
},
|
fail: (res) => {
|
console.log(res);
|
uni.showToast({
|
title: this.$t('MouldUpperBill.requestFailed') == 'MouldUpperBill.requestFailed' ? '接口请求失败' : this.$t('MouldUpperBill.requestFailed'),
|
icon: 'none'
|
})
|
},
|
});
|
}
|
},
|
goBack() {
|
uni.showModal({
|
title: this.$t('MouldUpperBill.confirmTitle') == 'MouldUpperBill.confirmTitle' ? '提示' : this.$t('MouldUpperBill.confirmTitle'),
|
content: this.$t('MouldUpperBill.exitConfirm') == 'MouldUpperBill.exitConfirm' ? '确认要退出当前页面吗?' : this.$t('MouldUpperBill.exitConfirm'),
|
success: (res) => {
|
if (res.confirm) {
|
console.log('用户点击确定');
|
uni.navigateBack()
|
} else if (res.cancel) {
|
console.log('用户点击取消');
|
}
|
}
|
});
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
/* 样式保持不变 */
|
.form {
|
width: 668rpx;
|
margin: 20rpx auto;
|
padding-bottom: 240rpx;
|
}
|
|
.tab_area {
|
width: 100%;
|
height: 50rpx;
|
}
|
|
.other {
|
margin-top: 8rpx;
|
text-align: center;
|
font-size: 28rpx;
|
padding: 4rpx 18rpx;
|
color: #1890FF;
|
}
|
|
.form-item {
|
display: flex;
|
align-items: center;
|
font-size: 30rpx;
|
padding: 6rpx 0;
|
|
.title {
|
width: 208rpx;
|
|
text {
|
color: red;
|
font-weight: bold;
|
}
|
}
|
|
.right {
|
width: 450rpx;
|
border-radius: 22rpx;
|
border: 1px solid #acacac;
|
}
|
|
.righton {
|
width: 450rpx;
|
border-radius: 22rpx;
|
border: 1px solid #e4e4e4;
|
background-color: #e4e4e4;
|
}
|
|
input {
|
width: 100%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
|
textarea {
|
width: 98%;
|
padding: 8rpx 20rpx;
|
font-size: 30rpx;
|
}
|
|
}
|
|
.bottom-btn {
|
width: 100%;
|
// height: 120rpx;
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
background-color: #fff;
|
box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
|
padding: 30rpx 40rpx 40rpx 40rpx;
|
|
button {
|
border-radius: 50rpx;
|
width: 180rpx;
|
height: 66rpx;
|
line-height: 66rpx;
|
font-size: 28rpx;
|
}
|
|
.btn-a {
|
background-color: #3A78FF;
|
color: #fff;
|
}
|
|
.btn-b {
|
background-color: #41a863;
|
color: #fff;
|
}
|
|
.btn-c {
|
background-color: #FFA500;
|
color: #fff;
|
position: absolute;
|
right: 120rpx;
|
}
|
|
.btn-d {
|
background-color: #ff8901;
|
color: #fff;
|
}
|
}
|
|
.tabs {
|
width: 100%;
|
display: flex;
|
border-bottom: 1px solid #ddd;
|
margin: 20rpx 0;
|
|
view {
|
width: 25%;
|
font-size: 30rpx;
|
color: #555;
|
text-align: center;
|
padding: 16rpx 0;
|
}
|
|
.on {
|
color: #3a78ff;
|
font-weight: bold;
|
border-bottom: 3px solid #3a78ff;
|
}
|
}
|
</style>
|