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.

505 lines
16 KiB
Vue

<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="库区编码" prop="areaCode">
<el-input
v-model="queryParams.areaCode"
placeholder="请输入库区编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="仓库编码" prop="whCode">
<el-input
v-model="queryParams.whCode"
placeholder="请输入仓库编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['wms:area:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['wms:area:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['wms:area:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['wms:area:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="areaList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!-- 序号 -->
<el-table-column
type="index"
width="90"
align="center"
:index="indexMethod"
label="序号">
</el-table-column>
<el-table-column label="库区编码" align="center" prop="areaCode" />
<el-table-column label="库区描述" align="center" prop="areaDesc" />
<el-table-column label="仓库编码" align="center" prop="whCode" />
<el-table-column label="创建人" align="center" prop="createBy" />
<el-table-column label="创建时间" align="center" prop="createTime" />
<el-table-column prop="activeFlag" label="是否启用" align="center">
<template slot-scope="scope">
{{ scope.row.activeFlag == 1 ? "是" : "否" }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['wms:area:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['wms:area:remove']"
>删除</el-button>
<el-button
size="mini"
type="text"
@click="showPrint(scope.row)"
>打印</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<el-dialog :title="printTitle" :visible.sync="printOpen" width="500px" append-to-body>
<div class="center-content" id="printFrom" style="display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; margin: 0 auto;">
<canvas ref="qrCanvas" width="200" height="200" style="width: 200px; height: 200px;"></canvas>
<ul class="no-bullets"style="list-style-type: none; padding: 0;">
<li class="material-info" style="font-size: 24px;">库区:{{printData.areaCode}}</li>
</ul>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handlePrint(printData)">确 定</el-button>
</div>
</el-dialog>
<!-- 添加或修改库区对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px" >
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-form-item label="库区编码" prop="areaCode" style="width:450px">
<el-input v-model="form.areaCode" placeholder="请输入库区编码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="库区描述" prop="areaDesc" style="width:450px">
<el-input v-model="form.areaDesc" placeholder="请输入库区描述(名称)" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-form-item label="区域编码" prop="regionCode" style="width:450px">
<el-input v-model="form.regionCode" placeholder="请输入区域编码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="仓库编码" prop="whCode" style="width:450px">
<el-input v-model="form.whCode" placeholder="请输入仓库编码" />
</el-form-item>
</el-col>
</el-row>
<!--
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-form-item label="入库过渡库位" prop="instockTranLoc">
<el-input v-model="form.instockTranLoc" placeholder="请输入入库过渡库位" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="出库过渡库位" prop="outstockTranLoc">
<el-input v-model="form.outstockTranLoc" placeholder="请输入出库过渡库位" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-form-item label="拣货过渡库位" prop="pickTranLoc">
<el-input v-model="form.pickTranLoc" placeholder="请输入拣货过渡库位" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="默认异常储位" prop="exSignLocNo">
<el-input v-model="form.exSignLocNo" placeholder="请输入默认异常储位" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="默认隔离储位" prop="frozenLocNo">
<el-input v-model="form.frozenLocNo" placeholder="请输入默认隔离储位" />
</el-form-item>
<el-form-item label="库区基点" prop="areaPoint">
<el-input v-model="form.areaPoint" placeholder="请输入库区基点" />
</el-form-item>
<el-form-item label="是否使用托盘" prop="useTray">
<el-input v-model="form.useTray" placeholder="请输入是否使用托盘(1-是 0-否)" />
</el-form-item>
<el-form-item label="是否托盘混载" prop="trayMix">
<el-input v-model="form.trayMix" placeholder="请输入是否托盘混载(1-是 0-否)" />
</el-form-item>
<el-form-item label="入库策略" prop="instorageStrategy">
<el-input v-model="form.instorageStrategy" placeholder="请输入入库策略" />
</el-form-item>
<el-form-item label="出库策略" prop="outstorageStrategy">
<el-input v-model="form.outstorageStrategy" placeholder="请输入出库策略" />
</el-form-item>
<el-form-item label="是否强制出库" prop="forceOutstorage">
<el-input v-model="form.forceOutstorage" placeholder="请输入是否强制出库" />
</el-form-item>
<el-form-item label="是否判断库位允许拣货" prop="locPickFlag">
<el-input v-model="form.locPickFlag" placeholder="请输入是否判断库位允许拣货" />
</el-form-item>
<el-form-item label="手持提单时的默认分配规则" prop="allocationRule">
<el-input v-model="form.allocationRule" placeholder="请输入手持提单时的默认分配规则" />
</el-form-item>
<el-form-item label="优先级" prop="priority">
<el-input v-model="form.priority" placeholder="请输入优先级" />
</el-form-item>
<el-form-item label="库区标志" prop="userDefined1">
<el-input v-model="form.userDefined1" placeholder="请输入库区标志(0-普通库区 1-立体库内机库区 2-立体库外机库区" />
</el-form-item> -->
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-form-item label="是否启用" prop="activeFlag">
<el-select v-model="form.activeFlag" placeholder="请选择是否启用" @change="$forceUpdate()" clearable style="width:350px">
<el-option v-for="item in options" :key="item.activeFlag" :label="item.label" :value="item.activeFlag"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="工厂编码" prop="factoryCode" style="width:450px">
<el-input v-model="form.factoryCode" placeholder="请输入工厂编码" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listArea, getArea, delArea, addArea, updateArea } from "@/api/wms/area";
import QRCode from "qrcode";
export default {
name: "Area",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
//打印弹出层标题
printTitle:"",
//是否显示打印弹出层
printOpen: false,
// 打印
printData: {
areaCode: null,
printable: 'printFrom',
ignore: ['no-print'],
workCenter: "暂无数据",
SAPNo: null,
manufacture: null,
auditor: null,
printDate: null,
factory: null,
productDate: null,
workTable: [],
},
// 总条数
total: 0,
// 库区表格数据
areaList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
areaCode: null,
areaDesc: null,
regionCode: null,
whCode: null,
instockTranLoc: null,
outstockTranLoc: null,
pickTranLoc: null,
exSignLocNo: null,
frozenLocNo: null,
sapSendSpot: null,
areaPoint: null,
useTray: null,
trayMix: null,
instorageStrategy: null,
outstorageStrategy: null,
forceOutstorage: null,
locPickFlag: null,
allocationRule: null,
gatherLocType: null,
priority: null,
userDefined1: null,
userDefined2: null,
userDefined3: null,
activeFlag: null,
factoryCode: null
},
options: [{
activeFlag: "1",
label: '是'
}, {
activeFlag: "0",
label: '否'
}],
// 表单参数
form: {},
// 表单校验
rules: {
whCode: [
{ required: true, message: "仓库编码不能为空", trigger: "blur" }
],
areaCode: [
{ required: true, message: "库区编码不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
// 生成表头序号
indexMethod(index){
return index+1 ;
},
/** 查询库区列表 */
getList() {
this.loading = true;
listArea(this.queryParams).then(response => {
this.areaList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
showPrint(row) {
console.log(row.areaCode)
//const storageId = row.storageId || this.ids;
this.printData.areaCode = row.areaCode;
this.printOpen = true;
// 使用 Vue 的 nextTick 来确保 DOM 已经更新
this.$nextTick(() => {
const canvas = this.$refs.qrCanvas;
const options = {
width: 200, // 设定二维码的宽度
height: 200 // 设定二维码的高度
};
QRCode.toCanvas(canvas,row.areaCode, options, error => {
if (error) console.error(error);
});
});
},
// 表单重置
reset() {
this.form = {
areaId: null,
areaCode: null,
areaDesc: null,
regionCode: null,
whCode: null,
instockTranLoc: null,
outstockTranLoc: null,
pickTranLoc: null,
exSignLocNo: null,
frozenLocNo: null,
sapSendSpot: null,
areaPoint: null,
useTray: null,
trayMix: null,
instorageStrategy: null,
outstorageStrategy: null,
forceOutstorage: null,
locPickFlag: null,
allocationRule: null,
gatherLocType: null,
priority: null,
userDefined1: null,
userDefined2: null,
userDefined3: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
activeFlag: null,
remark: null,
factoryCode: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
handlePrint(params) {
console.log(params)
printJS({
printable: params.printable || 'printFrom', // 标签元素id
type: params.type || 'html',
maxWidth: 1500, // 最大宽度
font_size: "",// 设置字体大小
header: params.header, // '表单',
targetStyles: ['*'],
style: '@page {margin:0 10mm};', // 可选-打印时去掉眉页眉尾
ignoreElements: params.ignore || [], // ['no-print']
properties: params.properties || null
})
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.areaId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加库区";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const areaId = row.areaId || this.ids
getArea(areaId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改库区";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.areaId != null) {
updateArea(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addArea(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const areaIds = row.areaId || this.ids;
this.$modal.confirm('是否确认删除库区编号为"' + areaIds + '"的数据项?').then(function() {
return delArea(areaIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('wms/area/export', {
...this.queryParams
}, `area_${new Date().getTime()}.xlsx`)
}
}
};
</script>