123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 |
- <template>
- <view class='container'>
- <view class="content">
- <view>
- <text class='title'>选择批次号</text>
- <view class="batchNo uni-row">
- <view :class="{'batchNo-item':true, 'uni-row': true}" v-for="(item,index) in batchNoList"
- :key='index'>
- <!-- ,'batchNoCheck':batchNoCheck === item -->
- <!-- @click="handleCheckBatchNo(item)" -->
- {{item.lotCode}}
- </view>
- </view>
- <view class="inpAndScan uni-row">
- <uni-easyinput v-if="batchNoList.length > 0" class="inp" suffixIcon="checkmarkempty"
- v-model="inpValue" placeholder="可手动修正批次" @iconClick="iconClick"></uni-easyinput>
- <view v-if="batchNoList.length > 0" class="scanLotCode" @click="handleConfirmLotCode">
- <text>扫码修正批次</text>
- </view>
- </view>
- </view>
- <view class='middle'>
- <view class='segment'></view>
- <uni-icons type="link" size="30" style="margin: 10rpx; transform: rotate(135deg);"></uni-icons>
- <view class='segment'></view>
- </view>
- <!-- <view>
- <text class='title'>扫码绑定载具</text>
- <view class="vehicleList uni-row">
- <view class="vehicleNo uni-row" v-for="(item,index) in vehicleList">
- <text>{{item.carrierCode}}</text>
- <text @click="handleDelVehicleNo(index)">×</text>
- </view>
- </view>
- <view>
- <button style='background-color: rgba(0, 226, 166,1);
- color: white;margin: 20rpx auto;
- width: 80%;' @click='handleScanCode'>扫码</button>
- </view>
- </view>
- <view class='middle'>
- <view class='segment'></view>
- <uni-icons type="paperclip" size="30" style="margin: 10rpx;"></uni-icons>
- <view class='segment'></view>
- </view> -->
- <view>
- <text class='title' style="margin-bottom: 50rpx;">基础信息</text>
- <view class="uni-row info">
- <label for="HeatNo">炉号:</label>
- <select id="incomingInfo" class="uni-input data-select" v-model="basicInfo.heatNo">
- <option class="data-select-options" v-for="(item,index) in range">{{item.text}}</option>
- </select>
- <!-- <input id="HeatNo" class="uni-input" v-model="basicInfo.heatNo" placeholder="请填写" /> -->
- <!-- <text id="HeatNo" class="uni-input">{{basicInfo.heatNo}}</text> -->
- </view>
- <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
- <view class="uni-row info">
- <label for="manufacturer">厂家:</label>
- <!-- <input id="manufacturer" class="uni-input" v-model="basicInfo.manufacturer" placeholder="请填写" /> -->
- <text id="manufacturer" class="uni-input">{{basicInfo.manufacturer}}</text>
- </view>
- <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
- <view class="uni-row info">
- <label for="incomingInfo">来料日期:</label>
- <!-- <input id="incomingInfo" class="uni-input" v-model="basicInfo.incomingInfo" placeholder="请填写" /> -->
- <text id="incomingInfo" class="uni-input">{{basicInfo.incomingInfo}}</text>
- </view>
- <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
- <view class="uni-row info">
- <label for="incomingInfo">材质:</label>
- <!-- <input id="incomingInfo" class="uni-input" v-model="basicInfo.incomingInfo" placeholder="请填写" /> -->
- <text id="incomingInfo" class="uni-input">{{basicInfo.materia}}</text>
- </view>
- <view class='segment' style="width: 90%;margin: 20rpx auto;"></view>
- </view>
- </view>
- <view class='bottom uni-row'>
- <button class='add' type=primary @click='handleAdd'>添加</button>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad,
- onReady
- } from '@dcloudio/uni-app'
- import {
- getLotList
- } from "@/api/business/lot.js"
- import {
- saveDayWork
- } from '@/api/business/dayWork.js'
- import {
- store
- } from '@/store/index.js'
- import {
- getCarrierById,
- checkCarrier
- } from '@/api/business/carrier.js'
- import { getFurnaceNoInfo } from '@/api/p2/furnaceNoInfo.js'
- const batchNoCheck = ref(null) // 批次号是否选中
- const batchNoList = ref([]) // 批次号列表
- const vehicleList = ref([])
- const basicInfo = ref({ // 基础信息对象
- heatNo: 'cs222',
- manufacturer: 'DMS',
- incomingInfo: 'L123456',
- materia: 'dx1111'
- })
- const dayWork = ref({})
- const curPlan = ref({})
- const range = ref([{
- value: 0,
- text: "LNO001"
- },
- {
- value: 1,
- text: "LNO002"
- },
- {
- value: 2,
- text: "LNO003"
- },
- ])
- const emit = defineEmits(['batchReporting-addBatch']);
- const inpValue = ref('')
- const lotList = ref([])
- onLoad(() => {
- // 处理特殊字符JSON解析失败报错
- curPlan.value = store.planDetails;
- dayWork.value = {
- productionPlanDetailId: curPlan.value.id,
- productionPlanId: curPlan.value.productionDetailId,
- technologicalProcessId: curPlan.value.technologicalProcessId,
- deptId: store.curDeptDetails.deptId
- }
- init();
- })
- function init() {
- let obj = {}
- obj.productionPlanDetailId = store.planDetails.id;
- getLotList(obj).then(res => {
- console.log(res)
- lotList.value = res.rows;
- if (res.rows.length > 0) {
- batchNoList.value = [res.rows[0]];
- dayWork.value.lotId = batchNoList.value[0].id;
- dayWork.value.lotCode = batchNoList.value[0].lotCode;
- } else {
- batchNoList.value = res.rows;
- }
- })
- getFurnaceNoInfo({
- productionPlanNo: store.planDetails.productionPlanNo,
- lineNumber: store.planDetails.lineNumber
- }).then(res => {
- console.log(res)
- })
- }
- // function handleCheckBatchNo(item) {
- // batchNoCheck.value = item;
- // dayWork.value.lotId = item.id;
- // }
- // function handleDelVehicleNo(index) {
- // vehicleList.value.splice(index, 1);
- // }
- // function handleValidate() {
- // if (batchNoCheck.value && vehicleList.value) {
- // return true;
- // } else {
- // return false;
- // }
- // }
- function iconClick() {
- checkLotCode(inpValue.value);
- }
- function checkLotCode(lotCode) {
- if (lotList.value.some(item => item.lotCode == lotCode)) {
- for (let i = 0; i < lotList.value.length; i++) {
- if (lotList.value[i].lotCode == lotCode) {
- batchNoList.value = [lotList.value[i]];
- dayWork.value.lotId = lotList.value[i].id;
- dayWork.value.lotCode = lotList.value[i].lotCode;
- uni.showToast({
- icon: "none",
- title: "该批次号可用",
- duration: 2000
- })
- return true;
- }
- }
- } else {
- uni.showToast({
- icon: "none",
- title: "该批次号已被使用或不属于该产品",
- duration: 2000
- })
- return false;
- }
- }
- function handleConfirmLotCode() {
- // 引入原生插件
- const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
- // 调用插件的 mpaasScan 方法
- mpaasScanModule.mpaasScan({
- // 扫码识别类型,参数可多选,qrCode、barCode,
- // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
- scanType: ["qrCode", "barCode"],
- // 是否隐藏相册,默认false不隐藏
- hideAlbum: false,
- },
- (ret) => {
- console.log(ret);
- // uni.showModal({
- // title: "扫码结果",
- // // 返回值中,有三个参数 resp_code、resp_message、resp_result
- // // resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
- // // resp_message 表示返回结果信息
- // // resp_result 表示扫码结果,只有成功才会有返回
- // content: JSON.stringify(ret),
- // showCancel: false,
- // confirmText: "确定",
- // });
- if (ret.resp_result) {
- checkLotCode(ret.resp_result);
- } else {
- uni.showToast({
- icon: "none",
- title: "条形码可能损坏,请重新扫码或手动修正批次号",
- duration: 2000
- })
- }
- }
- );
- }
- // function handleScanCode() {
- // uni.scanCode({
- // scanType: ['qrCode'],
- // onlyFromCamera: true, // 只允许相机扫码
- // autoZoom: false,
- // success: function(res) {
- // let vehicleObj = JSON.parse(res.result);
- // if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
- // uni.showToast({
- // icon: "error",
- // title: "请扫载具码",
- // duration: 1000
- // })
- // return;
- // }
- // for (let i = 0; i < vehicleList.value.length; i++) {
- // if (vehicleList.value[i].carrierId == vehicleObj.carrierId) {
- // uni.showToast({
- // icon: "error",
- // title: "载具已存在",
- // duration: 1000
- // })
- // return;
- // }
- // }
- // checkCarrier(vehicleObj.carrierId).then(response => {
- // if (response.code == 200) {
- // vehicleList.value.push(vehicleObj);
- // } else {
- // uni.showToast({
- // icon: 'none',
- // title: response.msg
- // })
- // return;
- // }
- // })
- // }
- // });
- // }
- function handleAdd() {
- // dayWork.value.dayworkCarriers = vehicleList.value;
- console.log(dayWork.value)
- // console.log(batchNoCheck.value)
- // console.log(vehicleList.value)
- if (checkLotCode(dayWork.value.lotCode)) {
- saveDayWork(dayWork.value).then(res => {
- console.log(res)
- if (res.code === 200) {
- uni.showToast({
- icon: 'success',
- title: '添加成功',
- duration: 2000
- });
- uni.$emit('batchReporting-addBatch');
- uni.$emit('dayworkItemUpdate');
- uni.navigateBack({
- url: '/pages/batchReporting/index'
- })
- } else {
- uni.showToast({
- icon: 'error',
- title: res.msg,
- duration: 2000
- });
- }
- })
- }else{
- uni.showToast({
- icon: "none",
- title: "该批次号已被使用或不属于该产品",
- duration: 2000
- })
- }
- }
- </script>
- <style lang="scss">
- .container {
- height: 90%;
- background-color: #f5f5f5;
- padding-bottom: 112rpx;
- }
- .bottom {
- background-color: white;
- width: 100%;
- position: fixed;
- bottom: 0;
- align-items: center;
- background-color: #ffffff;
- padding: 16rpx 0;
- .add {
- margin: 0 auto;
- width: 80%;
- height: 80rpx;
- }
- }
- .content {
- position: relative;
- width: auto;
- background-color: rgba(255, 255, 255, 1);
- margin: 32rpx;
- padding-bottom: 50rpx;
- padding-top: 20rpx;
- border-radius: 12rpx;
- .title {
- width: auto;
- font-size: 36rpx;
- font-weight: bold;
- text-align: center;
- }
- }
- .inpAndScan {
- justify-content: space-between;
- width: calc(88% + 20rpx);
- margin: 0 auto;
- .inp {
- width: 52%;
- margin: 10rpx;
- height: 74rpx;
- }
- .scanLotCode {
- border-radius: 6rpx;
- border: 1rpx solid rgba(22, 132, 252, 1);
- height: 60rpx;
- margin: 10rpx;
- height: 72rpx;
- width: 36%;
- text-align: center;
- line-height: 72rpx;
- background-color: rgba(22, 132, 252, 1);
- color: white;
- }
- }
- .batchNo {
- // justify-content: flex-start;
- // flex-wrap: wrap;
- // width: auto;
- // height: 320rpx;
- // overflow: auto;
- // padding-left: calc(100% - 88% - 4rpx - 40rpx);
- // margin-bottom: 40rpx;
- // border-radius: 6rpx;
- justify-content: center;
- .batchNo-item {
- justify-content: center;
- align-items: center;
- width: 88%;
- margin: 10rpx;
- height: 72rpx;
- border: 1px solid rgba(213, 213, 213, 1);
- border-radius: 6rpx;
- }
- .batchNoCheck {
- color: #FFF;
- border: 1rpx solid rgba(22, 132, 252, 1);
- background-color: rgba(22, 132, 252, 1);
- }
- }
- .vehicleList {
- justify-content: flex-start;
- flex-wrap: wrap;
- width: auto;
- height: 120rpx;
- overflow: auto;
- padding: 0 80rpx;
- .vehicleNo {
- padding: 0 10rpx;
- margin: 10rpx;
- justify-content: space-between;
- align-items: center;
- width: 230rpx;
- height: 60rpx;
- border: 1px solid rgba(213, 213, 213, 1);
- border-radius: 6rpx;
- }
- }
- .middle {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center
- }
- .segment {
- width: 280rpx;
- background-color: rgba(213, 213, 213, 1);
- border: 1rpx solid rgba(213, 213, 213, 1);
- }
- .info {
- width: 100%;
- justify-content: space-around;
- align-items: center;
- label {
- flex: 1;
- text-combine-upright: all;
- margin: 0 30rpx;
- }
- text {
- flex: 3;
- // width: 80%;
- }
- .data-select {
- flex: 3;
- width: 80%;
- height: 60rpx;
- margin-right: 40rpx;
- border-radius: 18rpx;
- background-color: #FFF;
- .data-select-options {
- width: 200rpx;
- }
- }
- }
- </style>
|