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.

240 lines
6.2 KiB
Vue

<template>
<el-dialog title="设备选择"
v-if="showFlag"
:visible.sync="showFlag"
:modal= false
width="1100px"
center
>
<el-table v-loading="loading" :data="prepareDetailList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="ID" align="center" prop="recordId" />
<el-table-column label="备料主ID" align="center" prop="prepareId" />
<el-table-column label="物料编号" align="center" prop="materialCode" />
<el-table-column label="物料名称" align="center" prop="materailName" />
<el-table-column label="规格型号" align="center" prop="materailSpc" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="生产数量" align="center" prop="quantity" />
<el-table-column label="工单生产日期" align="center" prop="productDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.productDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="班次" align="center" prop="shiftId" />
<el-table-column label="单据状态" align="center" prop="status" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="产品类型" align="center" prop="prodType" />
<el-table-column label="${comment}" align="center" prop="factoryCode" />
<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="['mes:prepareDetail:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['mes:prepareDetail:remove']"
>删除</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>
</template>
<script>
import { listPrepareDetail, getPrepareDetail, delPrepareDetail, addPrepareDetail, updatePrepareDetail } from "@/api/mes/prepareDetail";
export default {
name: "PrepareDetail",
data() {
return {
showFlag:false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// mes备料单明细表格数据
prepareDetailList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
prepareId: null,
materialCode: null,
materailName: null,
materailSpc: null,
unit: null,
quantity: null,
productDate: null,
shiftId: null,
status: null,
attr1: null,
attr2: null,
attr3: null,
attr4: null,
prodType: null,
factoryCode: null
},
// 表单参数
form: {},
// 表单校验
rules: {
prepareId: [
{ required: true, message: "备料主ID不能为空", trigger: "blur" }
],
materialCode: [
{ required: true, message: "物料编号不能为空", trigger: "blur" }
],
materailName: [
{ required: true, message: "物料名称不能为空", trigger: "blur" }
],
unit: [
{ required: true, message: "单位不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询mes备料单明细列表 */
getList() {
this.loading = true;
listPrepareDetail(this.queryParams).then(response => {
this.prepareDetailList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
recordId: null,
prepareId: null,
materialCode: null,
materailName: null,
materailSpc: null,
unit: null,
quantity: null,
productDate: null,
shiftId: null,
status: null,
remark: null,
attr1: null,
attr2: null,
attr3: null,
attr4: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
prodType: null,
factoryCode: 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.recordId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加mes备料单明细";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const recordId = row.recordId || this.ids
getPrepareDetail(recordId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改mes备料单明细";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.recordId != null) {
updatePrepareDetail(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addPrepareDetail(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const recordIds = row.recordId || this.ids;
this.$modal.confirm('是否确认删除mes备料单明细编号为"' + recordIds + '"的数据项?').then(function() {
return delPrepareDetail(recordIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('mes/prepareDetail/export', {
...this.queryParams
}, `prepareDetail_${new Date().getTime()}.xlsx`)
}
}
};
</script>