初始化
This commit is contained in:
429
ruoyi-ui/src/views/bas/traycode/index.vue
Normal file
429
ruoyi-ui/src/views/bas/traycode/index.vue
Normal file
@@ -0,0 +1,429 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">-->
|
||||
<!--<!– <el-input-->
|
||||
<!-- v-model="queryParams.formatId"-->
|
||||
<!-- placeholder="请输入格式ID"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter.native="handleQuery"-->
|
||||
<!-- />–>-->
|
||||
<!-- <el-select v-model="queryParams.formatId" placeholder="请选择格式ID">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="item in traycodeFormatList"-->
|
||||
<!-- :key="item.id"-->
|
||||
<!-- :label="item.remarks"-->
|
||||
<!-- :value="item.id"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="条码" prop="trayCode">
|
||||
<el-input
|
||||
v-model="queryParams.trayCode"
|
||||
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="['bas:traycode: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="['bas:traycode: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="['bas:traycode: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="['bas:traycode:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
plain
|
||||
icon="el-icon-printer"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleBatchPrint"
|
||||
v-hasPermi="['bas:traycode:print']"
|
||||
>批量打印</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table ref="table" v-loading="loading" :data="traycodeList" @selection-change="handleSelectionChange" max-height="700">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="left" prop="id" width="120" />
|
||||
<!-- <el-table-column label="格式ID" align="left" prop="formatName" />-->
|
||||
<el-table-column label="条码" align="left" prop="trayCode" />
|
||||
<el-table-column label="Spare Field 1" align="center" prop="spare1" />
|
||||
<el-table-column label="Spare Field 2" align="center" prop="spare2" />
|
||||
<el-table-column label="Spare Field 3" align="center" prop="spare3" />
|
||||
<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="['bas:traycode:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['bas:traycode:remove']"
|
||||
>删除</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-printer"
|
||||
@click="printBarcode(scope.row)"
|
||||
v-hasPermi="['bas:traycode:print']"
|
||||
>打印</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="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<!-- <el-form-item label="格式ID" prop="formatId">
|
||||
<el-select v-model="form.formatId" placeholder="请选择格式ID">
|
||||
<el-option
|
||||
v-for="item in traycodeFormatList"
|
||||
:key="item.id"
|
||||
:label="item.remarks"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>-->
|
||||
<el-form-item label="托盘编码" prop="trayCode">
|
||||
|
||||
<el-input v-model="form.trayCode" placeholder="请输入托盘编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Spare Field 1" prop="spare1">
|
||||
<el-input v-model="form.spare1" placeholder="Enter spare field 1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Spare Field 2" prop="spare2">
|
||||
<el-input v-model="form.spare2" placeholder="Enter spare field 2" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Spare Field 3" prop="spare3">
|
||||
<el-input v-model="form.spare3" placeholder="Enter spare field 3" />
|
||||
</el-form-item>
|
||||
</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>
|
||||
|
||||
|
||||
<!-- 打印模板 -->
|
||||
<vue-easy-print v-show="true" ref="easyPrint2">
|
||||
<div v-for="item in printData" :key="item.id" style="page-break-after:always" class="vue-easy-print">
|
||||
<vue-qr :text='item.trayCode' :size="150" :margin="10" :align-item="center" :correctLevel="2"></vue-qr>
|
||||
<div>
|
||||
<span class="num">{{ item.trayCode }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</vue-easy-print>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listTraycode, getTraycode, delTraycode, addTraycode, updateTraycode } from "@/api/bas/traycode"
|
||||
import { listTraycodeFormat } from "@/api/bas/traycodeFormat"
|
||||
import vueEasyPrint from 'vue-easy-print'
|
||||
import VueQr from 'vue-qr'
|
||||
|
||||
|
||||
export default {
|
||||
name: "Traycode",
|
||||
components: {
|
||||
vueEasyPrint,
|
||||
VueQr
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 设置标题
|
||||
title: this.$t('traycode.title'),
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 条码信息表格数据
|
||||
traycodeList: [],
|
||||
traycodeFormatList: [],
|
||||
printData:[],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
formatId: null,
|
||||
trayCode: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: null
|
||||
},
|
||||
queryTrayCodeFormatParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 99,
|
||||
},
|
||||
// Form parameters
|
||||
form: {},
|
||||
// Form validation
|
||||
rules: {
|
||||
formatId: [
|
||||
{ required: true, message: "请输入格式ID", trigger: "blur" }
|
||||
],
|
||||
trayCode: [
|
||||
{ required: true, message: "请输入托盘编码", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTrayCodeFormatList()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
/** 查询条码信息列表 */
|
||||
getTrayCodeFormatList() {
|
||||
this.loading = true
|
||||
listTraycodeFormat(this.queryTrayCodeFormatParams).then(response => {
|
||||
this.traycodeFormatList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
/** 查询条码信息列表 */
|
||||
getList() {
|
||||
this.loading = true
|
||||
listTraycode(this.queryParams).then(response => {
|
||||
this.traycodeList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
formatId: null,
|
||||
trayCode: null,
|
||||
createTime: null,
|
||||
updateTime: null,
|
||||
spare1: null,
|
||||
spare2: null,
|
||||
spare3: 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.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = "新增托盘编码"
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
const id = row.id || this.ids
|
||||
getTraycode(id).then(response => {
|
||||
this.form = response.data
|
||||
this.open = true
|
||||
this.title = "修改托盘编码"
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateTraycode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addTraycode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("添加成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids
|
||||
this.$modal.confirm('是否确认删除选中的数据项?').then(function() {
|
||||
return delTraycode(ids)
|
||||
}).then(() => {
|
||||
this.getList()
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('bas/traycode/export', {
|
||||
...this.queryParams
|
||||
}, `traycode_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 打印条码 */
|
||||
printBarcode: function (row) {
|
||||
this.printData = [row]
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.easyPrint2.print()
|
||||
}, 100)
|
||||
})
|
||||
},
|
||||
/** 批量打印按钮操作 */
|
||||
handleBatchPrint() {
|
||||
const selection = this.$refs.table.selection;
|
||||
if (selection.length === 0) {
|
||||
this.$modal.msgError("请选择要打印的数据项");
|
||||
return;
|
||||
}
|
||||
this.printData = selection;
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.easyPrint2.print()
|
||||
}, 100)
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
/* 统一表单控件宽度 */
|
||||
.el-select,
|
||||
.el-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 打印样式 */
|
||||
.vue-easy-print {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.num {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
margin-top: 15px;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
|
||||
.vue-qr {
|
||||
display: block;
|
||||
margin: 20px auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
size: A4;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.vue-easy-print {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.num {
|
||||
font-size: 14px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.vue-qr {
|
||||
margin: 10px auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user