Files
FT501-WMS/ruoyi-ui/src/views/bas/container/index.vue

412 lines
15 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" :label-width="$t('bas_ContainerManagement.lblWidthSearch')">
<!-- 容器编号 -->
<el-form-item :label="$t('bas_ContainerManagement.containerId')" prop="containerId">
<el-input
v-model="queryParams.containerId"
:placeholder="$t('bas_ContainerManagement.placeholderContainerId')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- 点位名称 -->
<el-form-item :label="$t('bas_ContainerManagement.portName')" prop="portName">
<el-select v-model="queryParams.portName" :placeholder="$t('bas_ContainerManagement.placeholderPortName')" clearable>
<el-option
v-for="(item, index) in portNameOptions"
:key="index"
:label="item"
:value="item"
></el-option>
</el-select>
</el-form-item>
<!-- 物料种类 -->
<!-- <el-form-item :label="$t('bas_ContainerManagement.productTypeQuantity')" prop="productTypeQuantity">-->
<!-- <el-input-->
<!-- v-model="queryParams.productTypeQuantity"-->
<!-- :placeholder="$t('bas_ContainerManagement.placeholderProductTypeQuantity')"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- 操作人 -->
<!-- <el-form-item :label="$t('bas_ContainerManagement.operationMan')" prop="operationMan">-->
<!-- <el-input-->
<!-- v-model="queryParams.operationMan"-->
<!-- :placeholder="$t('bas_ContainerManagement.placeholderOperationMan')"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<!-- 【搜索】按钮 -->
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('bas_ContainerManagement.btnSearch') }}</el-button>
<!-- 【重置】按钮 -->
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('bas_ContainerManagement.btnReset') }}</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:container:add']"
>{{ $t('bas_ContainerManagement.btnAddOrBinding') }}</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:container:edit']"
>{{ $t('bas_ContainerManagement.btnEdit') }}</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:container:remove']"
>{{ $t('bas_ContainerManagement.btnDeleteOrUnbinding') }}</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="containerList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!-- 容器编号 -->
<el-table-column :label="$t('bas_ContainerManagement.containerId')" align="left" prop="containerId" />
<!-- 点位名称 -->
<el-table-column :label="$t('bas_ContainerManagement.portName')" align="left" prop="portName" />
<!-- 容器状态 -->
<el-table-column :label="$t('bas_ContainerManagement.status')" align="left" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.stock_status" :value="scope.row.status"/>
</template>
</el-table-column>
<!-- 物料种类 -->
<el-table-column :label="$t('bas_ContainerManagement.productTypeQuantity')" align="right" prop="productTypeQuantity" />
<!-- 容量 -->
<el-table-column :label="$t('bas_ContainerManagement.capacity')" align="right" prop="capacity" />
<!-- 创建时间 -->
<el-table-column :label="$t('bas_ContainerManagement.createTime')" align="left" prop="createTime" />
<!-- 状态更新时间 -->
<el-table-column :label="$t('bas_ContainerManagement.updateTime')" align="left" prop="updateTime" />
<!-- 删除时间 -->
<el-table-column :label="$t('bas_ContainerManagement.operationMan')" align="left" prop="operationMan" />
<!-- 操作 -->
<el-table-column :label="$t('bas_ContainerManagement.operation')" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!-- 【详情】按钮 -->
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleDetails(scope.row)"
v-hasPermi="['bas:container:edit']"
>{{ $t('bas_ContainerManagement.btnDetails') }}</el-button>
<!-- 【修改】按钮 -->
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['bas:container:edit']"
>{{ $t('bas_ContainerManagement.btnEdit') }}</el-button>
<!-- 【删除】按钮 -->
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['bas:container:remove']"
>{{ $t('bas_ContainerManagement.btnDeleteOrUnbinding') }}</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="$t('bas_ContainerManagement.lblWidthDialog')">
<!-- 容器编号 -->
<el-form-item :label="$t('bas_ContainerManagement.containerId')" prop="containerId">
<el-input v-model="form.containerId" :placeholder="$t('bas_ContainerManagement.placeholderContainerId')" :disabled="!containerIdIsEnabled"/>
</el-form-item>
<!-- 点位名称 -->
<el-form-item :label="$t('bas_ContainerManagement.portName')" prop="portName">
<el-select v-model="form.portName" :placeholder="$t('bas_ContainerManagement.placeholderPortName')" clearable>
<el-option
v-for="(item, index) in portNameOptions"
:key="index"
:label="item"
:value="item"
></el-option>
</el-select>
</el-form-item>
<!-- 状态 -->
<el-form-item :label="$t('bas_ContainerManagement.status')" prop="status">
<el-select v-model="form.status" :placeholder="$t('bas_ContainerManagement.placeholderStatus')" clearable>
<el-option
v-for="status in dict.type.stock_status.slice(0, 2)"
:key="status.value"
:label="status.label"
:value="status.value">
</el-option>
</el-select>
</el-form-item>
<!-- 操作人字段已移除,由后台自动获取当前登录用户 -->
</el-form>
<div slot="footer" class="dialog-footer">
<!-- 【确定】按钮 -->
<el-button type="primary" @click="submitForm">{{ $t('bas_ContainerManagement.btnConfirm') }}</el-button>
<!-- 【取消】按钮 -->
<el-button @click="cancel">{{ $t('bas_ContainerManagement.btnCancel') }}</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listContainer, getContainer, delContainer, addContainer, updateContainer, getPortNames } from "@/api/bas/container"
import { get } from "sortablejs"
export default {
name: "Container",
dicts: ['stock_status'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 容器管理表格数据
containerList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 是否显示详细弹出层
openView: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
containerId: null,
portName: null,
status: null,
productTypeQuantity: null,
updateTime: null,
operationMan: null,
},
portNameOptions: [],
// statusOptions: ['空', '有货'],
// 表单参数
form: {},
// 表单校验
rules: {
containerId: [
{ required: true, message: this.$t('bas_ContainerManagement.containerIdRequired'), trigger: "blur" } // 容器编号不能为空
],
portName: [
{ required: true, message: this.$t('bas_ContainerManagement.portNameRequired'), trigger: "blur" } // 点位名称不能为空
],
status: [
{ required: true, message: this.$t('bas_ContainerManagement.statusRequired'), trigger: "blur" } // 容器状态不能为空
]
},
// 弹出框容器编号是否可编辑
containerIdIsEnabled: true,
}
},
created() {
this.getList()
// this.getPortNames()
},
methods: {
/** 查询容器管理列表 */
getList() {
this.loading = true
listContainer(this.queryParams).then(response => {
this.containerList = response.rows
this.total = response.total
this.loading = false
})
//@@@
getPortNames().then(res => {
if (res.code === 200) {
// this.portNameOptions = res.data || [];
this.portNameOptions = Array.isArray(res.data) ? [...res.data] : [];
// console.log(this.portNameOptions);
} else {
// 获取点位名称失败
this.$message.error(this.$t('bas_ContainerManagement.textErrorForGetPortName'));
}
})
.catch(error => {
// 请求异常
this.$message.error(this.$t('bas_ContainerManagement.textErrorForRequestException'));
console.error(error);
});
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
containerId: null,
portName: null,
status: null,
productTypeQuantity: null,
capacity: null,
createTime: null,
updateTime: null,
operationMan: 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.containerId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.containerIdIsEnabled = true
this.open = true
// 标题:添加容器管理
this.title = this.$t('bas_ContainerManagement.addContainerItem')
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const containerId = row.containerId || this.ids
getContainer(containerId).then(response => {
this.form = response.data
this.containerIdIsEnabled = false
this.open = true
// 标题:修改容器管理
this.title = this.$t('bas_ContainerManagement.editContainerItem')
})
},
/** 详情按钮操作 */
handleDetails(row){
const containerId = row.containerId
// this.$router.push("/bas/containerDetails/index/" + containerId)
this.$router.push({
name: 'ContainerDetails',
params: { containerId: containerId }
})
// console.log(containerId)
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
// 标题:修改容器管理
if (this.title === this.$t('bas_ContainerManagement.editContainerItem')) {
// 移除操作人字段,由后台自动获取当前登录用户
delete this.form.operationMan;
updateContainer(this.form).then(response => {
// 提示信息:修改成功
this.$modal.msgSuccess(this.$t('bas_ContainerManagement.editSuccessInfo'))
this.open = false
this.getList()
})
} else {
//@@@
this.form.productTypeQuantity = '3';
this.form.capacity = 10;
// 移除操作人字段,由后台自动获取当前登录用户
delete this.form.operationMan;
addContainer(this.form).then(response => {
// 提示信息:新增成功
this.$modal.msgSuccess(this.$t('bas_ContainerManagement.addSuccessInfo'))
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const containerIds = row.containerId || this.ids
// 提示信息:是否确认删除容器编号为" + containerIds + "的数据项?
this.$modal.confirm(this.$t('bas_ContainerManagement.textDeleteConfirm1') + containerIds + this.$t('bas_ContainerManagement.textDeleteConfirm2')).then(function() {
return delContainer(containerIds)
}).then(() => {
this.getList()
// 提示信息:删除成功
this.$modal.msgSuccess(this.$t('bas_ContainerManagement.deleteSuccessInfo'))
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() {
this.download('bas/container/export', {
...this.queryParams
}, `container_${new Date().getTime()}.xlsx`)
}
}
}
</script>
<style scoped>
/* 统一表单控件宽度 */
.el-select,
.el-input {
width: 100%;
}
</style>