|
@@ -98,7 +98,7 @@
|
|
|
>
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
<!-- <el-table-column label="ID" align="center" prop="id" width="80" /> -->
|
|
|
- <el-table-column label="产品名称" align="center" prop="productName" />
|
|
|
+ <el-table-column label="产品名称" align="center" prop="productName" width="120" />
|
|
|
<el-table-column
|
|
|
label="屠宰时间"
|
|
|
align="center"
|
|
@@ -109,31 +109,33 @@
|
|
|
<span>{{ parseTime(scope.row.produceTime) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="吊钩号" align="center" prop="hookNo" />
|
|
|
- <el-table-column label="血码" align="center" prop="slaughterCode" />
|
|
|
- <el-table-column label="检疫证号" align="center" prop="animalCertNo" />
|
|
|
- <el-table-column label="供应商" align="center" prop="supplierName" />
|
|
|
- <el-table-column label="肉商" align="center" prop="purchaserName" />
|
|
|
- <el-table-column label="吊钩类型" align="center" prop="hookName">
|
|
|
+ <el-table-column label="吊钩号" align="center" prop="hookNo" width="120" />
|
|
|
+ <el-table-column label="血码" align="center" prop="slaughterCode" width="120" />
|
|
|
+ <el-table-column label="检疫证号" align="center" prop="animalCertNo" width="150" />
|
|
|
+ <el-table-column label="供应商" align="center" prop="supplierName" width="120" />
|
|
|
+ <el-table-column label="肉商" align="center" prop="purchaserName" width="120" />
|
|
|
+ <el-table-column label="吊钩类型" align="center" prop="hookName" width="120">
|
|
|
<template slot-scope="scope">
|
|
|
<span>{{ showValue(scope.row.hookName) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="吊钩扣重(kg)" align="center" prop="hookWeight">
|
|
|
+ <el-table-column label="吊钩扣重(kg)" align="center" prop="hookWeight" width="120">
|
|
|
<template slot-scope="scope">
|
|
|
<span>{{ showValue(scope.row.hookWeight) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="干损重量(kg)" align="center" prop="dryLossWeight">
|
|
|
+ <el-table-column label="干损重量(kg)" align="center" prop="dryLossWeight" width="120">
|
|
|
<template slot-scope="scope">
|
|
|
<span>{{ showValue(scope.row.dryLossWeight) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="宰后重量(kg)" align="center" prop="finalWeight">
|
|
|
+ <el-table-column label="宰后重量(kg)" align="center" prop="finalWeight" width="120">
|
|
|
<template slot-scope="scope">
|
|
|
<span>{{ showValue(scope.row.finalWeight) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column label="识别器" align="center" prop="deviceName" width="160">
|
|
|
+ </el-table-column>
|
|
|
<el-table-column
|
|
|
label="操作"
|
|
|
fixed="right"
|
|
@@ -215,7 +217,7 @@
|
|
|
</el-row>
|
|
|
</el-dialog>
|
|
|
<!-- 添加或修改白条生产记录对话框 -->
|
|
|
- <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
|
|
+ <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @close="closeDialog">
|
|
|
<el-form
|
|
|
ref="form"
|
|
|
:model="form"
|
|
@@ -224,8 +226,21 @@
|
|
|
label-width="120px"
|
|
|
>
|
|
|
<el-row :gutter="20">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="称重产线" prop="deviceSerial" v-if="!this.form.id">
|
|
|
+ <el-radio-group v-model="deviceSerial" @input="selectLine">
|
|
|
+ <el-radio
|
|
|
+ v-for="(item, i) in NFIDReaders"
|
|
|
+ :key="i"
|
|
|
+ :label="item.deviceSerial"
|
|
|
+ border
|
|
|
+ >{{ item.deviceName }}</el-radio
|
|
|
+ >
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="产品名称" prop="productName" v-if="form.id">
|
|
|
+ <el-form-item label="产品名称" prop="productName">
|
|
|
<el-input
|
|
|
v-model="form.productName"
|
|
|
placeholder="请输入产品名称"
|
|
@@ -235,7 +250,7 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="生产时间" prop="produceTime" v-if="form.id">
|
|
|
+ <el-form-item label="生产时间" prop="produceTime">
|
|
|
<el-date-picker
|
|
|
clearable
|
|
|
v-model="form.produceTime"
|
|
@@ -243,7 +258,7 @@
|
|
|
format="yyyy-MM-dd HH:mm:ss"
|
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
placeholder="请选择生产时间"
|
|
|
- style="width: 240px;"
|
|
|
+ style="width: 240px"
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
@@ -254,19 +269,20 @@
|
|
|
<el-input
|
|
|
v-model="form.hookNo"
|
|
|
placeholder="请输入吊钩号"
|
|
|
- @blur="fillInput"
|
|
|
+
|
|
|
+ class="large-input"
|
|
|
style="width: 630px"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="血码" prop="slaughterCode" v-if="form.id">
|
|
|
+ <el-form-item label="血码" prop="slaughterCode">
|
|
|
<el-select
|
|
|
v-model="form.slaughterCode"
|
|
|
filterable
|
|
|
placeholder="请选择血码"
|
|
|
@change="getDistribute()"
|
|
|
- style="width: 240px;"
|
|
|
+ style="width: 240px"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in slaughterRelationOptions"
|
|
@@ -278,27 +294,51 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="检疫证号" prop="animalCertNo" v-if="form.id">
|
|
|
- <el-input v-model="form.animalCertNo" placeholder="" style="width: 240px;" disabled />
|
|
|
+ <el-form-item label="检疫证号" prop="animalCertNo">
|
|
|
+ <el-input
|
|
|
+ v-model="form.animalCertNo"
|
|
|
+ placeholder=""
|
|
|
+ style="width: 240px"
|
|
|
+ disabled
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="肉商" prop="purchaserName" v-if="form.id">
|
|
|
- <el-input v-model="form.purchaserName" placeholder="" style="width: 240px;" disabled />
|
|
|
+ <el-form-item label="肉商" prop="purchaserName">
|
|
|
+ <el-input
|
|
|
+ v-model="form.purchaserName"
|
|
|
+ placeholder=""
|
|
|
+ style="width: 240px"
|
|
|
+ disabled
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="供应商" prop="supplierName" v-if="form.id">
|
|
|
- <el-input v-model="form.supplierName" placeholder="" style="width: 240px;" disabled />
|
|
|
+ <el-form-item label="供应商" prop="supplierName">
|
|
|
+ <el-input
|
|
|
+ v-model="form.supplierName"
|
|
|
+ placeholder=""
|
|
|
+ style="width: 240px"
|
|
|
+ disabled
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row :gutter="20">
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="吊钩类型" prop="hookName" v-if="form.id">
|
|
|
- <el-select
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="吊钩类型" prop="hookName">
|
|
|
+ <el-radio-group v-model="form.hookName" @input="getHookType">
|
|
|
+ <el-radio
|
|
|
+ v-for="(item, i) in hookOptions"
|
|
|
+ :key="i"
|
|
|
+ :label="item.hookName"
|
|
|
+ border
|
|
|
+ >{{ item.hookName }}</el-radio
|
|
|
+ >
|
|
|
+ </el-radio-group>
|
|
|
+ <!-- <el-select
|
|
|
v-model="form.hookName"
|
|
|
filterable
|
|
|
placeholder="请选择吊钩类型"
|
|
@@ -311,11 +351,11 @@
|
|
|
:label="item.hookName"
|
|
|
:value="item.hookName"
|
|
|
></el-option>
|
|
|
- </el-select>
|
|
|
+ </el-select> -->
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="吊钩扣重(kg)" prop="hookWeight" v-if="form.id">
|
|
|
+ <el-form-item label="吊钩扣重(kg)" prop="hookWeight">
|
|
|
<el-input
|
|
|
v-model="form.hookWeight"
|
|
|
placeholder="请输入吊钩扣重"
|
|
@@ -325,6 +365,18 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="干损重量(kg)" prop="dryLossWeight">
|
|
|
+ <el-input
|
|
|
+ v-model="form.dryLossWeight"
|
|
|
+ disabled
|
|
|
+ style="width: 240px"
|
|
|
+ />
|
|
|
+ <span style="color: #f00; margin-left: 20px"
|
|
|
+ >【当前干损比为:{{ this.dryLossRatio }}%】</span
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
|
|
|
<SerialInput
|
|
@@ -332,27 +384,21 @@
|
|
|
:type="1"
|
|
|
ref="SerialInputRef"
|
|
|
:disabled="isView"
|
|
|
- v-if="form.id"
|
|
|
@confirm="confirmWeight"
|
|
|
/>
|
|
|
|
|
|
- <el-form-item label="干损重量(kg)" prop="dryLossWeight" v-if="form.id">
|
|
|
+ <el-form-item label="宰后重量(kg)" prop="finalWeight">
|
|
|
<el-input
|
|
|
- v-model="form.dryLossWeight"
|
|
|
- disabled
|
|
|
+ v-model="form.finalWeight"
|
|
|
+ class="large-input"
|
|
|
style="width: 240px"
|
|
|
+ disabled
|
|
|
/>
|
|
|
- <span style="color: #f00; margin-left: 20px"
|
|
|
- >【当前干损比为:{{ this.dryLossRatio }}%】</span
|
|
|
- >
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="宰后重量(kg)" prop="finalWeight" v-if="form.id">
|
|
|
- <el-input v-model="form.finalWeight" style="width: 240px" disabled />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <div slot="footer" class="dialog-footer" v-if="!isView">
|
|
|
- <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
- <el-button @click="cancel">取 消</el-button>
|
|
|
+ <div slot="footer" class="dialog-footer" v-show="!isView">
|
|
|
+ <el-button type="primary" size="large" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button size="large" @click="cancel">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
@@ -366,12 +412,16 @@ import {
|
|
|
addPorkSideProduce,
|
|
|
updatePorkSideProduce,
|
|
|
} from "@/api/app/porkSideProduce";
|
|
|
-import { getHookBindDetail,cleanBind } from "@/api/app/hookBind";
|
|
|
+import { listAllNFIDReader } from "@/api/app/NFIDReader";
|
|
|
+import { unsubscribeRead } from "@/api/app/nfidReadRecord";
|
|
|
+import { getHookBindDetail, cleanBind } from "@/api/app/hookBind";
|
|
|
import { getValidDistributeBatch } from "@/api/app/distributeBatch";
|
|
|
import { getAllHook } from "@/api/app/hook";
|
|
|
import { getAllSlaughterRelation } from "@/api/app/slaughterRelation";
|
|
|
import { getNowRatio } from "@/api/app/dryLossRatio";
|
|
|
import SerialInput from "@/components/weightSerial/index.vue";
|
|
|
+import { getRandomString } from "@/utils/str";
|
|
|
+import { isEmpty } from "@/utils/validate";
|
|
|
export default {
|
|
|
name: "PorkSideProduce",
|
|
|
components: {
|
|
@@ -394,6 +444,10 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
return {
|
|
|
+ //SSE
|
|
|
+ emitter:null,
|
|
|
+ clientId:"",
|
|
|
+ deviceSerial:null,
|
|
|
//串口信息
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
@@ -411,6 +465,7 @@ export default {
|
|
|
porkSideProduceList: [],
|
|
|
hookOptions: [],
|
|
|
slaughterRelationOptions: [],
|
|
|
+ NFIDReaders: [],
|
|
|
distributeList: [],
|
|
|
dryLossRatio: 0,
|
|
|
regexRule:
|
|
@@ -474,8 +529,91 @@ export default {
|
|
|
created() {
|
|
|
this.getList();
|
|
|
this.getHookOptions();
|
|
|
+ this.getAllNFIDReader();
|
|
|
+ this.getSlaughterRelationOptions();
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // 监听全局键盘事件
|
|
|
+ document.addEventListener("keydown", this.handleGlobalKeyDown);
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ // 组件销毁时移除监听
|
|
|
+ document.removeEventListener("keydown", this.handleGlobalKeyDown);
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleGlobalKeyDown(event) {
|
|
|
+ if (event.key === "Enter") {
|
|
|
+ event.preventDefault(); // 阻止默认行为
|
|
|
+ if(this.open && !this.isView){
|
|
|
+ //弹窗已打开,并且是新增或修改的操作
|
|
|
+ this.$refs.SerialInputRef.stopReader().then(()=>{
|
|
|
+ this.submitForm();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ //选择识别的产线
|
|
|
+ selectLine(){
|
|
|
+ this.unSubNFIDRecord();
|
|
|
+ this.subNFIDRecord();
|
|
|
+ },
|
|
|
+ //订阅识别记录
|
|
|
+ subNFIDRecord(){
|
|
|
+ console.log("订阅识别记录")
|
|
|
+ if(isEmpty(this.clientId)){
|
|
|
+ this.clientId = getRandomString(12);
|
|
|
+ }
|
|
|
+
|
|
|
+ let url = process.env.VUE_APP_BASE_API + "/app/NFIDReadRecord/subscribe/"+this.deviceSerial+"/"+this.clientId;
|
|
|
+ this.emitter = new EventSource(url);
|
|
|
+
|
|
|
+ this.emitter.onmessage = (event) => {
|
|
|
+ console.log(event.data);
|
|
|
+ };
|
|
|
+
|
|
|
+ this.emitter.addEventListener(this.deviceSerial, (event) => {
|
|
|
+ console.log(`[自定义事件] ${event.data}`);
|
|
|
+ const data = JSON.parse(event.data);
|
|
|
+ // this.form.produceTime = data.produceTime;
|
|
|
+ this.form.deviceSerial = data.deviceSerial;
|
|
|
+ this.form.hookNo = data.hookNo;
|
|
|
+ this.form.slaughterCode = data.slaughterCode;
|
|
|
+ this.form.entranceBatchId = data.entranceBatchId;
|
|
|
+ this.form.distributeBatchId = data.distributeBatchId;
|
|
|
+ this.form.supplierName = data.supplierName;
|
|
|
+ this.form.purchaserName = data.purchaserName;
|
|
|
+ this.form.animalCertNo = data.animalCertNo;
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ this.emitter.onerror = (error) => {
|
|
|
+ console.error("SSE 错误:", error);
|
|
|
+ };
|
|
|
+ },
|
|
|
+ //取消订阅
|
|
|
+ unSubNFIDRecord(){
|
|
|
+ console.log("取消订阅")
|
|
|
+ if (this.emitter) {
|
|
|
+ this.emitter.close();
|
|
|
+ this.emitter = null;
|
|
|
+ unsubscribeRead(this.deviceSerial,this.clientId )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ closeDialog(){
|
|
|
+ this.unSubNFIDRecord();
|
|
|
+ this.deviceSerial = null;
|
|
|
+ this.clientId = null;
|
|
|
+ },
|
|
|
+ //获取全部白条产线
|
|
|
+ getAllNFIDReader() {
|
|
|
+ let param = {
|
|
|
+ deviceSpot: "weight",
|
|
|
+ };
|
|
|
+ listAllNFIDReader(param).then((response) => {
|
|
|
+ this.NFIDReaders = response.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
//空值显示 -
|
|
|
showValue(value) {
|
|
|
return value != null ? value : "-";
|
|
@@ -494,20 +632,28 @@ export default {
|
|
|
this.form.scaleWeight = val;
|
|
|
this.caclutateWeight();
|
|
|
},
|
|
|
+ //首次需要选择默认产线
|
|
|
+ setDefaultDevice() {
|
|
|
+ if(isEmpty(this.form.deviceSerial)){
|
|
|
+ this.$set(this.form, "deviceSerial", this.NFIDReaders && this.NFIDReaders.length > 0
|
|
|
+ ? this.NFIDReaders[0].deviceSerial
|
|
|
+ : null,);
|
|
|
+ }
|
|
|
+ },
|
|
|
//设置默认吊钩
|
|
|
- setDefaultHook(){
|
|
|
- this.hookOptions.forEach((item)=>{
|
|
|
- if(item.defaultFlag){
|
|
|
- console.log(item)
|
|
|
- this.$set(this.form, "hookName", item.hookName);
|
|
|
- this.$set(this.form, "hookWeight", item.hookWeight);
|
|
|
- this.caclutateWeight();
|
|
|
- }
|
|
|
- })
|
|
|
+ setDefaultHook() {
|
|
|
+ this.hookOptions.forEach((item) => {
|
|
|
+ if (item.defaultFlag) {
|
|
|
+ console.log(item);
|
|
|
+ this.$set(this.form, "hookName", item.hookName);
|
|
|
+ this.$set(this.form, "hookWeight", item.hookWeight);
|
|
|
+ this.caclutateWeight();
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
//计算数量
|
|
|
caclutateWeight() {
|
|
|
- console.log("计算数量")
|
|
|
+ console.log("计算数量");
|
|
|
let finalWeight =
|
|
|
this.form.scaleWeight - this.form.hookWeight > 0
|
|
|
? this.form.scaleWeight - this.form.hookWeight
|
|
@@ -597,14 +743,12 @@ export default {
|
|
|
getSlaughterRelationOptions() {
|
|
|
getAllSlaughterRelation({}).then((response) => {
|
|
|
this.slaughterRelationOptions = response.data;
|
|
|
-
|
|
|
});
|
|
|
},
|
|
|
/** 查询吊钩清单 */
|
|
|
getHookOptions() {
|
|
|
getAllHook().then((response) => {
|
|
|
this.hookOptions = response.data;
|
|
|
-
|
|
|
});
|
|
|
},
|
|
|
/** 查询白条生产记录列表 */
|
|
@@ -626,7 +770,8 @@ export default {
|
|
|
this.form = {
|
|
|
id: null,
|
|
|
productName: "白条",
|
|
|
- produceTime: null,
|
|
|
+ produceTime: this.parseTime(new Date()),
|
|
|
+ deviceSerial:null,
|
|
|
hookNo: null,
|
|
|
slaughterCode: null,
|
|
|
supplierName: null,
|
|
@@ -641,7 +786,8 @@ export default {
|
|
|
finalWeight: null,
|
|
|
};
|
|
|
this.resetForm("form");
|
|
|
- this.setDefaultHook()
|
|
|
+ this.setDefaultHook();
|
|
|
+ //this.setDefaultDevice();
|
|
|
this.getRatio();
|
|
|
},
|
|
|
/** 搜索按钮操作 */
|
|
@@ -670,8 +816,6 @@ export default {
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
|
this.reset();
|
|
|
-
|
|
|
- this.getSlaughterRelationOptions();
|
|
|
const id = row.id || this.ids;
|
|
|
getPorkSideProduce(id).then((response) => {
|
|
|
this.form = response.data;
|
|
@@ -679,7 +823,7 @@ export default {
|
|
|
this.isView = false;
|
|
|
this.title = "修改白条生产记录";
|
|
|
//是否需要设置默认吊钩
|
|
|
- if(this.form.hookName == null && this.form.hookWeight==null){
|
|
|
+ if (this.form.hookName == null && this.form.hookWeight == null) {
|
|
|
this.setDefaultHook();
|
|
|
}
|
|
|
});
|
|
@@ -712,7 +856,10 @@ export default {
|
|
|
} else {
|
|
|
addPorkSideProduce(this.form).then((response) => {
|
|
|
this.$modal.msgSuccess("新增成功");
|
|
|
- this.open = false;
|
|
|
+ this.reset();
|
|
|
+ //重新启动串口重量数据
|
|
|
+ this.$refs.SerialInputRef.startReader();
|
|
|
+ //this.open = false;
|
|
|
this.getList();
|
|
|
});
|
|
|
}
|
|
@@ -734,10 +881,9 @@ export default {
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
//清除吊钩绑定关系
|
|
|
- handleCleanBind(){
|
|
|
+ handleCleanBind() {
|
|
|
cleanBind().then((response) => {
|
|
|
- this.$modal.msgSuccess("清除成功");
|
|
|
-
|
|
|
+ this.$modal.msgSuccess("清除成功");
|
|
|
});
|
|
|
},
|
|
|
/** 导出按钮操作 */
|
|
@@ -753,3 +899,14 @@ export default {
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
+<style>
|
|
|
+/* 样式保持不变 */
|
|
|
+.large-input {
|
|
|
+ font-size: 32px;
|
|
|
+ width: 300px;
|
|
|
+}
|
|
|
+.large-input > .el-input__inner {
|
|
|
+ height: 60px;
|
|
|
+ line-height: 60px;
|
|
|
+}
|
|
|
+</style>
|