You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

789 lines
27 KiB
Vue

<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
icon="el-icon-plus"
plain
size="mini"
type="primary"
@click="handleAddProductBarcode"
v-if="addProductBarcodeBtnVisible"
>新增成品码
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
icon="el-icon-plus"
plain
size="mini"
type="primary"
@click="handleInternalAdd"
v-if="addInternalBtnVisible"
>新增对内原材料条码
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-printer"
size="mini"
@click="handlePrintBarcodes"
:disabled="batchPrintBtnDisabled"
>打印
</el-button>
</el-col>
<!--right-toolbar :columns="columns" :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar-->
</el-row>
<el-table v-loading="loading" :data="barcodeList" @selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" width="55"/>
<el-table-column v-if="columns[0].visible" align="center" label="主键标识" prop="barcodeId"/>
<el-table-column v-if="columns[4].visible" align="center" label="条码类型" prop="barcodeType">
<template slot-scope="scope">
<dict-tag :options="dict.type.barcode_type" :value="scope.row.barcodeType"/>
</template>
</el-table-column>
<el-table-column v-if="columns[17].visible" align="center" label="派工单号" prop="planCode" width="110"/>
<el-table-column v-if="columns[18].visible" align="center" label="明细编号" prop="planDetailCode" width="110"/>
<el-table-column v-if="columns[20].visible" align="center" label="销售订单编号" prop="saleorderCode" width="110"/>
<el-table-column v-if="columns[13].visible" align="center" label="采购订单号" prop="poNo" width="100"/>
<el-table-column v-if="columns[29].visible" align="center" label="条码类型" prop="barcodeType" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.barcode_type" :value="scope.row.barcodeType"/>
</template>
</el-table-column>
<el-table-column v-if="columns[5].visible" align="center" label="条码内容" prop="barcodeInfo" width="100"/>
<el-table-column v-if="columns[8].visible" align="center" label="物料编码" prop="materialCode" width="100"/>
<el-table-column v-if="columns[30].visible" align="center" label="物料名称" prop="materialName" width="100"/>
<el-table-column v-if="columns[31].visible" align="center" label="物料规格" prop="materialSpec" width="100"/>
<el-table-column label="打印标识" align="center" prop="printFlag">
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_print_flag" :value="scope.row.printFlag"/>
</template>
</el-table-column>
<el-table-column v-if="columns[14].visible" align="center" label="生产日期" prop="productionDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.productionDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column v-if="columns[16].visible" align="center" label="最晚出库日期" prop="lastOutstockDate"
width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.lastOutstockDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column v-if="columns[19].visible" align="center" label="销售订单ID" prop="saleOrderId"/>
<el-table-column v-if="columns[21].visible" align="center" label="项目号" prop="projectNo"/>
<el-table-column v-if="columns[23].visible" align="center" label="备注" prop="remark"/>
<el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作">
<template slot-scope="scope">
<el-button
icon="el-icon-plus"
plain
size="mini"
type="primary"
@click="handleAddBindBarcode(scope.row.barcodeInfo)"
v-if="scope.row.barcodeType!==BARCODE_TYPE.BIND_BARCODE && addBindBarcodeBtnVisible"
>配对码
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-refresh"
@click="regenerateBarcode(scope.row)"
v-if="scope.row.printFlag ==='1'"
>重新生成
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-printer"
@click="handlePrintBarcodes(scope.row)"
v-if="scope.row.printFlag ==='0'"
>打印
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:limit.sync="queryParams.pageSize"
:page.sync="queryParams.pageNum"
:total="total"
@pagination="getList"
/>
<!-- 添加或修改条码信息对话框 -->
<el-dialog :title="title" :visible.sync="addProductBarcodeOpen" append-to-body width="500px">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="派工单号" prop="planCode">
<el-input v-model="form.planCode" :disabled="true">
</el-input>
</el-form-item>
<el-form-item label="生产明细编号" prop="planDetailCode">
<el-input v-model="form.planDetailCode" :disabled="true">
</el-input>
</el-form-item>
<el-form-item label="绑定柜体码" prop="bindBarcode"
v-if="this.form.barcodeType === this.BARCODE_TYPE.BIND_BARCODE">
<el-input v-model="form.bindBarcode" :disabled="true">
</el-input>
</el-form-item>
<el-form-item label="配对码数量" prop="barcodeAmount"
v-if="this.form.barcodeType === this.BARCODE_TYPE.BIND_BARCODE">
<el-input-number v-model="form.barcodeAmount" :min="1" :max="1000">
</el-input-number>
</el-form-item>
<el-form-item label="生产日期" prop="productionDate">
<el-date-picker v-model="form.productionDate"
clearable
placeholder="请选择生产日期"
type="date"
value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
<el-form-item label="最晚出库日期" prop="lastOutstockDate">
<el-date-picker v-model="form.lastOutstockDate"
clearable
placeholder="请选择最晚出库日期"
type="date"
value-format="yyyy-MM-dd">
</el-date-picker>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入内容" type="textarea"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" :loading="submitLoading" @click="submitForm">确 定</el-button>
<el-button @click="cancelProductBarcode">取 消</el-button>
</div>
</el-dialog>
<!-- 添加或修改对内生产的原材料条码信息对话框 -->
<el-dialog :title="internalTitle" :visible.sync="internalOpen" width="500px" append-to-body>
<el-form ref="internalForm" :model="internalForm" :rules="internalRules" label-width="100px">
<el-form-item label="成品条码" prop="productBarcode">
<el-input v-model="internalForm.productBarcode" placeholder="请输入或扫描成品条码" class="input-with-select"
@blur="selectProductBarcodeInfoByBarcodeInfo">
<el-button slot="append" icon="el-icon-full-screen"></el-button>
</el-input>
</el-form-item>
<el-form-item label="物料ID" prop="materialId" v-if="false">
<el-input v-model="internalForm.materialId" placeholder="请输入物料ID"/>
</el-form-item>
<el-form-item label="物料编码" prop="materialCode">
<el-input v-model="internalForm.materialCode" disabled/>
</el-form-item>
<el-form-item label="物料名称" prop="materialName">
<el-input v-model="internalForm.materialName" :disabled="true"/>
</el-form-item>
<el-form-item label="物料规格" prop="materialSpec">
<el-input v-model="internalForm.materialSpec" :disabled="true"/>
</el-form-item>
<el-form-item label="生产日期" prop="productionDate">
<el-date-picker clearable
v-model="internalForm.productionDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择生产日期">
</el-date-picker>
</el-form-item>
<el-form-item label="最晚出库日期" prop="lastOutstockDate">
<el-date-picker clearable
v-model="internalForm.lastOutstockDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择最晚出库日期">
</el-date-picker>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="internalForm.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitInternalForm">确 定</el-button>
<el-button @click="cancelInternal"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listProductBarcode,
addProductBarcode,
printProductBarcodes,
selectProductBarcodeInfoByBarcodeInfo,
addInternalBarcode, regenerateBarcode
} from "@/api/board/barcode";
export default {
name: "Barcode",
dicts: ['bind_status', 'active_flag', 'barcode_type', 'mes_print_flag'],
data() {
return {
// 遮罩层
loading: true,
// 保存遮罩层
submitLoading:false,
// 选中数组
ids: [],
barcodeInfos: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 条码信息表格数据
barcodeList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
addBtnTitle: '新增条码',
addProductBarcodeOpen: false,
internalTitle: "添加对内原材料条码信息",
internalOpen: false,
// 对内条码表单参数
internalForm: {},
// 表单校验
internalRules: {
materialCode: [
{required: true, message: "物料编码不能为空", trigger: "blur"}
],
},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
printTime: null,
printPerson: null,
batchFlag: null,
barcodeType: '3',
barcodeInfo: null,
batchCode: null,
palletInfoCode: null,
materialId: null,
manufacturerId: null,
amount: null,
machineName: null,
printNumber: null,
poNo: null,
productionDate: null,
acceptedDate: null,
lastOutstockDate: null,
planCode: null,
planDetailCode: null,
saleOrderId: null,
saleorderCode: null,
projectNo: null,
serialNumber: null,
bindStatus: null,
bindBy: null,
bindTime: null,
updateBy: null,
updateTime: null,
singleFlag: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
orderCode: [
{required: true, message: "工单编号不能为空", trigger: "blur"}
],
batchFlag: [
{required: true, message: "批次标识不能为空", trigger: "change"}
],
barcodeType: [
{required: true, message: "条码类型不能为空", trigger: "change"}
],
bindBarcode: [
{required: true, message: "请先领取柜体", trigger: "change"}
],
barcodeAmount: [
{required: true, message: "请输入配对码数量", trigger: "change"}
],
materialId: [
{required: true, message: "物料ID不能为空", trigger: "blur"}
],
},
columns: [
{key: 0, label: `主键标识`, visible: false},
{key: 1, label: `打印时间`, visible: true},
{key: 2, label: `打印人`, visible: true},
{key: 3, label: `批次标识`, visible: true},
{key: 4, label: `条码类型`, visible: false},
{key: 5, label: `条码内容`, visible: true},
{key: 6, label: `批次代码`, visible: true},
{key: 7, label: `托盘RFID代码`, visible: true},
{key: 8, label: `物料名称`, visible: true},
{key: 9, label: `供应商ID`, visible: false},
{key: 10, label: `数量`, visible: true},
{key: 11, label: `打印机台名称`, visible: true},
{key: 12, label: `打印次数`, visible: true},
{key: 13, label: `采购订单号`, visible: false},
{key: 14, label: `生产日期`, visible: true},
{key: 15, label: `接受日期`, visible: true},
{key: 16, label: `最晚出库日期`, visible: true},
{key: 17, label: `派工单号`, visible: false},
{key: 18, label: `明细编号`, visible: true},
{key: 19, label: `销售订单ID`, visible: false},
{key: 20, label: `销售订单编号`, visible: true},
{key: 21, label: `项目号`, visible: false},
{key: 22, label: `流水号`, visible: false},
{key: 23, label: `备注`, visible: true},
{key: 24, label: `绑定状态`, visible: true},
{key: 25, label: `绑定托盘的人`, visible: true},
{key: 26, label: `绑定托盘时间`, visible: true},
{key: 27, label: `更新人`, visible: false},
{key: 28, label: `更新时间`, visible: false},
{key: 29, label: `条码类型`, visible: true},
{key: 30, label: `物料编码`, visible: true},
{key: 31, label: `物料规格`, visible: true},
],
addBindBarcodeBtnVisible: false,
batchPrintBtnDisabled: false,
addProductBarcodeBtnVisible: false,
addInternalBtnVisible: false,
barcodeTypeParam: "",
BARCODE_TYPE: {
RAW: '1',//原材料
PRODUCT: '3',//成品
BIND_BARCODE: '4',//配对码
},
BARCODE_TYPE_PARAM: {
PRODUCT:'3',//成品
PRODUCT_BARCODE: '4',//成品配对码
SPLIT_BIND_BARCODE: '5', //拆分配对码
},
SINGLE_FLAG: {
YES: '1',//是
INTERNAL: "2",//对内
}
};
},
mounted() {
this.getData();
this.getList();
},
props: {
defineData: {
type: Object,
default: {}
}
},
// watch: {
// 'form.batchFlag': function (newVal, oldVal) {
// // 在 form.batchFlag 变化时执行
// if (newVal === '1') {
// this.amountVisible = true;
// } else if (newVal === '0') {
// this.amountVisible = false;
// }
// },
// },
methods: {
getData() {
if (this.defineData.barcodeType) {
let barcodeType = this.defineData.barcodeType ? this.defineData.barcodeType : this.BARCODE_TYPE.PRODUCT;
let bindBarcode = this.defineData.bindBarcode ? this.defineData.bindBarcode : '';
this.barcodeTypeParam = barcodeType;
this.queryParams.planCode = this.defineData.planCode;
this.queryParams.planDetailCode = this.defineData.planDetailCode;
if (barcodeType === this.BARCODE_TYPE_PARAM.PRODUCT_BARCODE) {//成品配对码
this.queryParams.barcodeType = this.BARCODE_TYPE.PRODUCT;
this.queryParams.bindOrFlag = "1";
// this.queryParams.barcodeTypeStr = this.BARCODE_TYPE.PRODUCT + "," + this.BARCODE_TYPE.BIND_BARCODE;
} else if (barcodeType === this.BARCODE_TYPE_PARAM.SPLIT_BIND_BARCODE) {//拆分原材料配对码
this.queryParams.barcodeType = this.BARCODE_TYPE.RAW ;
this.queryParams.bindOrFlag = "1";
// this.queryParams.barcodeTypeStr = this.BARCODE_TYPE.RAW + "," + this.BARCODE_TYPE.BIND_BARCODE;
// this.queryParams.bindOrFlag = "1";
}
this.form = {
planId: this.defineData.planId,
planCode: this.defineData.planCode,
planDetailCode: this.defineData.planDetailCode,
singleFlag:this.defineData.singleFlag,
saleOrderId:this.defineData.saleOrderId,
batchFlag: '0',
bindBarcode: bindBarcode,
barcodeType: "",
amount: 1,
}
} else if (this.defineData.singleFlag && this.defineData.singleFlag === this.SINGLE_FLAG.INTERNAL) {
//4楼到5楼的原材料条码也要更换成新的plancode和plandetailcode
this.internalForm = {
planId: this.defineData.planId,
planCode: this.defineData.planCode,
planDetailCode: this.defineData.planDetailCode,
saleOrderId:this.defineData.saleOrderId,
batchFlag: '0',
amount: 1,
}
this.queryParams.planCode = this.defineData.planCode;
this.queryParams.planDetailCode = this.defineData.planDetailCode;
this.queryParams.singleFlag = this.SINGLE_FLAG.INTERNAL;
this.queryParams.barcodeType = this.BARCODE_TYPE.RAW;
}
},
/** 查询条码信息列表 */
getList() {
this.loading = true;
listProductBarcode(this.queryParams).then(response => {
this.barcodeList = response.rows;
this.total = response.total;
if (this.total && this.total > 0) {
if (this.queryParams.singleFlag) {
this.addProductBarcodeBtnVisible = false;
this.addBindBarcodeBtnVisible = false;
this.addInternalBtnVisible = false;
} else {
this.addInternalBtnVisible = false;
this.addProductBarcodeBtnVisible = false;
if(this.barcodeTypeParam === this.BARCODE_TYPE_PARAM.PRODUCT){
this.addBindBarcodeBtnVisible = false;
}else{
this.addBindBarcodeBtnVisible = true;
}
if (this.total === 1 && this.barcodeTypeParam === this.BARCODE_TYPE_PARAM.SPLIT_BIND_BARCODE) {
this.handleAddBindBarcode(this.form.bindBarcode);
}
}
} else {
if (this.queryParams.singleFlag) {
this.addProductBarcodeBtnVisible = false;
this.addBindBarcodeBtnVisible = false;
this.addInternalBtnVisible = true;
this.handleInternalAdd();
} else {
this.addInternalBtnVisible = false;
this.addProductBarcodeBtnVisible = true;
this.addProductBarcodeOpen = true;
this.handleAddProductBarcode();
}
}
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
barcodeId: null,
printTime: null,
printPerson: null,
batchFlag: '0',
barcodeType: '3',
barcodeInfo: null,
batchCode: null,
palletInfoCode: null,
materialId: null,
manufacturerId: null,
amount: 1,
machineName: null,
printNumber: null,
poNo: null,
productionDate: null,
acceptedDate: null,
lastOutstockDate: null,
planCode: null,
planDetailCode: null,
saleOrderId: null,
saleorderCode: null,
projectNo: null,
serialNumber: null,
remark: null,
bindStatus: null,
bindBy: null,
bindTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.barcodeId)
this.barcodeInfos = selection.map(item => item.barcodeInfo)
this.single = selection.length !== 1
this.multiple = !selection.length
},
handleSelection(selection) {
this.ids = selection.map(item => item.barcodeId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
// handleAdd() {
// this.reset();
// if (this.defineData?.planCode) {
// this.getData()
// }
// this.open = true;
// this.title = "添加配对条码信息";
// },
/** 新增配对码按钮操作 */
handleAddBindBarcode(barcodeInfo) {
this.reset();
if (this.defineData?.planCode) {
this.getData()
this.form.barcodeType = this.BARCODE_TYPE.BIND_BARCODE;
}
this.form.bindBarcode = barcodeInfo;
this.addProductBarcodeOpen = true;
this.title = "添加配对条码信息";
},
handleAddProductBarcode() {
this.reset();
if (this.defineData?.planCode) {
this.getData()
this.form.barcodeType = this.BARCODE_TYPE.PRODUCT;
}
this.addProductBarcodeOpen = true;
},
// 取消按钮
cancelProductBarcode() {
this.addProductBarcodeOpen = false;
this.reset();
},
/** 打印条码按钮操作 */
handlePrintBarcodes(row) {
const barcodeIds = row.barcodeId || this.ids;
if (barcodeIds == null || barcodeIds == '') {
this.$modal.msgWarning("请选择要打印的物料条码");
return;
}
if (row.printFlag) {
row.printFlag = '1';
} else {
this.batchPrintBtnDisabled = true;
}
printProductBarcodes(barcodeIds).then(response => {
this.$modal.msgSuccess("打印条码成功");
this.getList();
this.batchPrintBtnDisabled = false;
}).catch(() => {
this.batchPrintBtnDisabled = false;
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.submitLoading = true;
addProductBarcode(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.addProductBarcodeOpen = false;
this.getList();
}).finally(e =>{
this.submitLoading = false;
});
}
});
},
// 表单重置
resetInternal() {
this.internalForm = {
barcodeId: null,
printTime: null,
printPerson: null,
batchFlag: null,
barcodeType: '1',
barcodeInfo: null,
batchCode: null,
palletInfoCode: null,
materialId: null,
manufacturerId: null,
amount: null,
barcodeAmount: null,
machineName: null,
printNumber: null,
poNo: null,
productionDate: null,
acceptedDate: null,
lastOutstockDate: null,
planCode: null,
planDetailCode: null,
saleOrderId: null,
saleorderCode: null,
projectNo: null,
serialNumber: null,
remark: null,
bindStatus: null,
bindBy: null,
bindTime: null,
updateBy: null,
updateTime: null
};
this.resetForm("internalForm");
},
/** 内部生产原材料条码新增按钮操作 */
handleInternalAdd() {
this.resetInternal();
if (this.defineData?.planCode) {
this.getData()
this.internalForm.barcodeType = this.BARCODE_TYPE.RAW;
}
this.internalOpen = true;
},
selectProductBarcodeInfoByBarcodeInfo() {
if (this.internalForm.productBarcode == null || this.internalForm.productBarcode === '') {
return;
}
selectProductBarcodeInfoByBarcodeInfo(this.internalForm.productBarcode).then(response => {
if (response.data == null) {
this.resetInternal();
if (this.defineData?.planCode) {
this.getData()
this.internalForm.barcodeType = this.BARCODE_TYPE.RAW;
}
this.$modal.msgError("成品信息不存在");
return;
}
if(response.data.saleOrderId !== this.internalForm.saleOrderId){
this.resetInternal();
if (this.defineData?.planCode) {
this.getData()
this.internalForm.barcodeType = this.BARCODE_TYPE.RAW;
}
this.$modal.msgError("销售订单不一致");
return;
}
this.$set(this.internalForm, "materialId", response.data.materialId);
this.$set(this.internalForm, "materialCode", response.data.materialCode);
this.$set(this.internalForm, "materialName", response.data.materialName);
this.$set(this.internalForm, "materialSpec", response.data.materialSpec);
this.$set(this.internalForm, "productionDate", response.data.productionDate);
this.$set(this.internalForm, "saleOrderId", response.data.saleOrderId);
this.$set(this.internalForm, "saleorderCode", response.data.saleorderCode);
this.$set(this.internalForm, "safeFlag", response.data.safeFlag);
}).catch(error => {
this.resetInternal();
if (this.defineData?.planCode) {
this.getData()
this.internalForm.barcodeType = this.BARCODE_TYPE.RAW;
}
});
},
/** 提交按钮 */
submitInternalForm() {
this.$refs["internalForm"].validate(valid => {
if (valid) {
addInternalBarcode(this.internalForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.internalOpen = false;
this.getList();
});
}
});
},
// 取消按钮
cancelInternal() {
this.internalOpen = false;
this.resetInternal();
},
//对于已打印的条码可重新生成条码,之前的作废
regenerateBarcode(row) {
const barcodeId = row.barcodeId;
const barcodeInfo = row.barcodeInfo;
const barcodeType = row.barcodeType;
this.$modal.confirm('重新生成后之前的条码将会作废,是否确认重新生成条码内容为"' + barcodeInfo + '"的数据项?').then(function () {
return regenerateBarcode({
"barcodeId": barcodeId,
"barcodeInfo": barcodeInfo,
"barcodeType": barcodeType
});
}).then(() => {
this.getList();
this.$modal.msgSuccess("重新生成成功");
}).catch(() => {
});
},
}
};
</script>