| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- <template>
- <el-dialog
- v-dialogDrag
- title="货位"
- :visible.sync="viewOpen"
- width="1200px"
- append-to-body
- @open="dialogOpen"
- @close="dialogClose"
- >
- <!-- 搜索工作栏 -->
- <el-form
- v-show="showSearch"
- ref="queryForm"
- :model="queryParams"
- size="small"
- label-width="68px"
- >
- <el-row :gutter="20">
- <el-col :span="5">
- <el-form-item label="货位编码" prop="locationCode">
- <el-input
- v-model="queryParams.locationCode"
- placeholder="请输入仓库货位编码"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="库存单位" prop="storageUnit">
- <el-select
- v-model="queryParams.storageUnit"
- placeholder="请选择库存单位"
- clearable
- size="small"
- >
- <el-option
- v-for="dict in getDictDatas(DICT_TYPE.MES_UNIT)"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="库位容量" prop="storageQty">
- <el-input
- v-model="queryParams.storageQty"
- placeholder="请输入库位容量"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="可放物料" prop="materials">
- <el-input
- v-model="queryParams.materials"
- placeholder="请输入可放物料"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-button
- type="primary"
- icon="el-icon-search"
- size="small"
- @click="handleQuery"
- >搜索</el-button
- >
- <el-button icon="el-icon-refresh" size="small" @click="resetQuery"
- >重置</el-button
- >
- </el-col>
- </el-row>
- </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"
- >新增</el-button
- >
- </el-col>
- <el-col :span="1.5">
- <el-button
- v-hasPermi="['wms:stock-location:export']"
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- :loading="exportLoading"
- @click="handleExport"
- >导出</el-button
- >
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-printer"
- size="mini"
- :loading="exportLoading"
- @click="handlePrint"
- >标签打印</el-button
- >
- </el-col>
- <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
- </el-row>
- <!-- 列表 -->
- <el-table
- v-loading="loading"
- :data="list"
- border
- size="mini"
- @selection-change="tableSelected"
- @select="select"
- @select-all="selectAll"
- >
- <el-table-column
- type="selection"
- width="55"
- fixed="left"
- align="center"
- />
- <el-table-column
- label="货位编码"
- width="120"
- show-overflow-tooltip
- align="center"
- prop="locationCode"
- />
- <el-table-column
- label="货位名称"
- align="center"
- prop="name"
- width="160"
- show-overflow-tooltip
- />
- <el-table-column label="库存单位" align="center" prop="storageUnit">
- <template slot-scope="scope">
- <dict-tag :type="DICT_TYPE.MES_UNIT" :value="scope.row.storageUnit" />
- </template>
- </el-table-column>
- <el-table-column label="库位容量" align="center" prop="storageQty" />
- <el-table-column
- label="货架号"
- align="center"
- prop="shelfNo"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="层号"
- align="center"
- prop="storey"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="位置编码"
- align="center"
- prop="position"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column label="备注" align="center" prop="remark" />
- <el-table-column
- label="可放物料"
- align="center"
- prop="materials"
- width="150"
- >
- <template slot-scope="{ row }">
- <el-tag
- v-for="item in row.materialsName"
- :key="item.code"
- type="primary"
- size="mini"
- >{{ item.name }}</el-tag
- >
- </template>
- </el-table-column>
- <el-table-column
- label="创建时间"
- align="center"
- prop="createTime"
- width="180"
- >
- <template slot-scope="scope">
- <span>{{ parseTime(scope.row.createTime) }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- align="center"
- width="120"
- fixed="right"
- class-name="small-padding fixed-width"
- >
- <template slot-scope="scope">
- <el-button
- v-hasPermi="['wms:stock-location:update']"
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="handleUpdate(scope.row)"
- >修改</el-button
- >
- <el-button
- v-hasPermi="['wms:stock-location:delete']"
- size="mini"
- type="text"
- class="text-danger"
- icon="el-icon-delete"
- @click="handleDelete(scope.row)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页组件 -->
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.pageNo"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 对话框(添加 / 修改) -->
- <el-dialog
- v-dialogDrag
- :title="title"
- :visible.sync="open"
- width="500px"
- append-to-body
- @open="updateOpen"
- @close="dialogCloseWithUpdate"
- >
- <el-form ref="form" :model="form" :rules="rules" label-width="96px">
- <el-form-item label="区域名称" prop="wmsStockAreaId">
- <el-input
- v-model="names"
- placeholder="请输入对应仓库区域"
- clearable
- disabled
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="货位编码" prop="locationCode">
- <el-input
- v-model="form.locationCode"
- placeholder="仓库货位编码自动生成"
- disabled
- />
- </el-form-item>
- <el-form-item label="货架号" prop="shelfNo">
- <!-- <el-input
- v-model="form.shelfNo"
- oninput="value=value.replace(/[^A-Z]/g, '')"
- placeholder="请输入A-Z的货架号"
- @change="shelfNoChange"
- /> -->
- <DictSelect
- v-model="form.shelfNo"
- placeholder="请选择货架号"
- dict-type="WMS_SHELVES_CODE"
- @change="shelfNoChange"
- />
- </el-form-item>
- <el-form-item label="层" prop="storey">
- <!-- <el-input
- v-model="form.storey"
- oninput="value=value.replace(/^\D*(\d*(?:.\d)?).*$/g, '$1')"
- placeholder="请输入层"
- @change="storeyChange"
- /> -->
- <DictSelect
- v-model="form.storey"
- placeholder="请选择层号"
- dict-type="WMS_LEVEL_CODE"
- @change="storeyChange"
- />
- </el-form-item>
- <el-form-item label="位置" prop="position">
- <!-- <el-input
- v-model="form.position"
- oninput="value=value.replace(/^\D*(\d*(?:.\d)?).*$/g, '$1')"
- placeholder="请输入位置"
- @change="positionChange"
- /> -->
- <DictSelect
- v-model="form.position"
- placeholder="请选择位置"
- dict-type="WMS_LOCATION_CODE"
- @change="positionChange"
- />
- </el-form-item>
- <el-form-item label="货位名称" prop="name">
- <el-input v-model="form.name" placeholder="请输入仓库货位名称" />
- </el-form-item>
- <el-form-item label="库存单位" prop="storageUnit">
- <el-select
- v-model="form.storageUnit"
- placeholder="请选择库存单位"
- clearable
- size="small"
- >
- <el-option
- v-for="dict in getDictDatas(DICT_TYPE.MES_UNIT)"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="库位容量" prop="storageQty">
- <el-input
- v-model="form.storageQty"
- placeholder="请输入库位容量"
- oninput="value=value.replace(/^\D*(\d*(?:.\d{0,7})?).*$/g, '$1')"
- />
- </el-form-item>
- <el-form-item label="可放物料编码" prop="materials">
- <MaterialSelect
- ref="materialsSelect"
- v-model="form.materials"
- multiple
- filterable
- placeholder="请选择可放物料"
- @change="change"
- />
- </el-form-item>
- <el-form-item
- v-if="selectedMaterialList.length > 0"
- label="可放物料名称"
- prop="materialsName"
- >
- <!-- <MaterialSelect
- v-model="form.materialsName"
- multiple
- filterable
- placeholder="请选择可放物理"
- /> -->
- <!-- <el-input v-model="form.materialsName" placeholder="请输入可放物料" /> -->
- <div class="material-wrapper">
- <el-tag
- v-for="item in selectedMaterialList"
- :key="item.code"
- type="primary"
- size="small"
- class="material-wrapper-item"
- >{{ item.name }}</el-tag
- >
- </div>
- </el-form-item>
- <el-form-item label="备注" prop="remark">
- <el-input
- v-model="form.remark"
- :autosize="{ minRows: 4, maxRows: 6 }"
- type="textarea"
- maxlength="200"
- show-word-limit
- placeholder="请输入备注"
- />
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="cancel">取消</el-button>
- <el-button type="primary" @click="submitForm">确定</el-button>
- </div>
- </el-dialog>
- <!-- 标签打印 -->
- <IssuePrinit ref="issuePrint" />
- </el-dialog>
- </template>
- <script>
- import {
- createStockLocation,
- updateStockLocation,
- deleteStockLocation,
- getStockLocation,
- getStockLocationPage,
- exportStockLocationExcel,
- } from "@/api/wms/base/stockLocation";
- import MaterialSelect from "./MaterialSelect.vue";
- const AccessTokenKey = "ACCESS_TOKEN";
- import IssuePrinit from "../../output/productionIssue/issueDetails/IssuePrinit.vue";
- export default {
- name: "StockLocation",
- components: {
- MaterialSelect,
- IssuePrinit,
- },
- props: {
- id: {
- type: [String, Number],
- default: "",
- },
- code: {
- type: String,
- default: "",
- },
- names: {
- type: String,
- default: "",
- },
- },
- data() {
- return {
- // 遮罩层
- loading: true,
- editDisable: false,
- // 导出遮罩层
- exportLoading: false,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // WMS 仓库 仓库货位列表
- list: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- viewOpen: false,
- // 打印参数
- tokens: "",
- baseUrl: "",
- reportId: "",
- // 查询参数
- queryParams: {
- pageNo: 1,
- pageSize: 10,
- wmsStockAreaId: null,
- locationCode: null,
- storageUnit: null,
- storageQty: null,
- remark: null,
- materials: null,
- createTime: [],
- },
- // 表单参数
- form: {},
- selectedMaterialList: [],
- selectedMaterialListCopied: [],
- currentRows: [],
- // 表单校验
- rules: {
- name: [
- {
- required: true,
- message: "对应仓库区域表ID不能为空",
- trigger: "blur",
- },
- ],
- // locationCode: [{ required: true, message: '仓库货位编码不能为空', trigger: 'blur' }],
- storageUnit: [
- { required: true, message: "库存单位不能为空", trigger: "blur" },
- ],
- storageQty: [
- { required: true, message: "库位容量不能为空", trigger: "blur" },
- ],
- },
- };
- },
- methods: {
- /** 查询列表 */
- getList() {
- this.loading = true;
- // 执行查询
- getStockLocationPage(this.queryParams)
- .then((response) => {
- this.list = response.data.list.map((i) => {
- const { materialsName } = i;
- if (materialsName) {
- i.materialsName = JSON.parse(materialsName);
- } else {
- i.materialsName = [];
- }
- return i;
- });
- this.total = response.data.total;
- })
- .finally(() => {
- this.loading = false;
- });
- },
- /** 取消按钮 */
- cancel() {
- this.open = false;
- this.reset();
- },
- /** 表单重置 */
- reset() {
- this.form = {
- id: undefined,
- wmsStockAreaId: undefined,
- locationCode: undefined,
- storageUnit: undefined,
- storageQty: undefined,
- remark: undefined,
- materials: undefined,
- };
- this.resetForm("form");
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNo = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm("queryForm");
- this.handleQuery();
- },
- /** 新增按钮操作 */
- handleAdd() {
- this.reset();
- this.open = true;
- this.title = "添加WMS 仓库 仓库货位";
- this.form.wmsStockAreaId = this.id;
- // this.form.locationCode = this.code
- this.form.names = this.names;
- this.editDisable = false;
- },
- updateOpen() {
- this.$nextTick(() => {
- this.$refs.materialsSelect.copiedOptions = this.selectedMaterialList;
- });
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.reset();
- const id = row.id;
- this.editDisable = true;
- getStockLocation(id).then((response) => {
- const { data = {} } = response;
- data.materials = data.materials ? data.materials.split(",") : [];
- this.selectedMaterialList = data.materialsName
- ? JSON.parse(data.materialsName)
- : [];
- this.form = data;
- this.open = true;
- this.title = "修改WMS 仓库 仓库货位";
- });
- },
- // 计算货位
- positionChange(v) {
- const { shelfNo, storey } = this.form;
- if (!shelfNo || !storey) {
- this.form.locationCode = undefined;
- return;
- }
- this.form.locationCode =
- this.names + "-" + shelfNo + "-" + storey + "-" + v;
- },
- shelfNoChange(v) {
- const { position, storey } = this.form;
- if (!position || !storey) {
- this.form.locationCode = undefined;
- return;
- }
- this.form.locationCode =
- this.names + "-" + v + "-" + storey + "-" + position;
- },
- // 根据层计算货位
- storeyChange(v) {
- const { shelfNo, position } = this.form;
- if (!position || !shelfNo) {
- this.form.locationCode = undefined;
- return;
- }
- this.form.locationCode =
- this.names + "-" + shelfNo + "-" + v + "-" + position;
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate((valid) => {
- if (!valid) {
- return;
- }
- // 修改的提交
- // this.form.materials = this.form.materials.join(',')
- const params = JSON.parse(JSON.stringify(this.form));
- params.materials = params.materials ? params.materials.join(",") : "";
- params.materialsName = JSON.stringify(
- this.selectedMaterialList.map((i) => {
- const { name, code } = i;
- return { name, code };
- })
- );
- if (params.id != null) {
- updateStockLocation(params).then((response) => {
- this.$modal.msgSuccess("修改成功");
- this.open = false;
- this.getList();
- this.selectedMaterialList = [];
- });
- return;
- }
- // 添加的提交
- params.wmsStockAreaId = this.queryParams.wmsStockAreaId;
- createStockLocation(params).then((response) => {
- this.$modal.msgSuccess("新增成功");
- this.open = false;
- this.getList();
- this.selectedMaterialList = [];
- });
- });
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const { id } = row;
- this.$modal
- .confirm('是否确认删除WMS 仓库 仓库货位编号为"' + id + '"的数据项?')
- .then(function () {
- return deleteStockLocation(id);
- })
- .then(() => {
- this.getList();
- this.$modal.msgSuccess("删除成功");
- })
- .catch(() => {});
- },
- /** 导出按钮操作 */
- handleExport() {
- // 处理查询参数
- const params = { ...this.queryParams };
- params.pageNo = undefined;
- params.pageSize = undefined;
- this.$modal
- .confirm("是否确认导出所有WMS 仓库 仓库货位数据项?")
- .then(() => {
- this.exportLoading = true;
- return exportStockLocationExcel(params);
- })
- .then((response) => {
- this.$download.excel(response, "WMS 仓库 仓库货位.xls");
- this.exportLoading = false;
- })
- .catch(() => {});
- },
- dialogOpen() {
- this.getList();
- this.tokens = localStorage.getItem(AccessTokenKey);
- this.baseUrl = process.env.VUE_APP_REPORT_API;
- this.reportId = this.$route.meta.reportId;
- },
- dialogClose() {
- this.list = [];
- },
- change(list) {
- this.selectedMaterialList = list;
- // const index = this.selectedMaterialList.findIndex(item => !(v.includes(item.code)))
- // if (index > -1) {
- // this.selectedMaterialList.splice(index, 1)
- // }
- },
- // 表格选中
- tableSelected(val) {
- this.currentRows = val;
- const list = this.currentRows.map((item) => item.deliveryOrderNo);
- this.ids = list.join(",");
- },
- select(selection, row) {
- if (selection.length > 1) {
- const del_row = selection.shift();
- this.$refs.multipleTable.toggleRowSelection(del_row, false);
- }
- },
- selectAll(selection) {
- if (selection.length > 1) {
- selection.length = 1;
- }
- },
- dialogCloseWithUpdate() {
- this.selectedMaterialList = [];
- },
- handlePrint() {
- if (this.currentRows.length <= 0) {
- this.$modal.msgWarning("请先选择你要打印的数据!");
- return;
- }
- console.log(this.currentRows);
- const { id } = this.currentRows[0];
- const src = `${this.baseUrl}/jmreport/view/${this.reportId}?token=${this.tokens}&id=${id}`;
- this.$refs.issuePrint.title = "单据打印";
- this.$refs.issuePrint.dialogVisible = true;
- this.$refs.issuePrint.src = src;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .material-wrapper {
- .material-wrapper-item + .material-wrapper-item {
- margin-left: 5px;
- }
- }
- </style>
|