376 lines
11 KiB
Vue
376 lines
11 KiB
Vue
|
<!--
|
||
|
* @Author: zhp
|
||
|
* @Date: 2023-12-08 13:46:17
|
||
|
* @LastEditTime: 2023-12-08 16:09:13
|
||
|
* @LastEditors: zhp
|
||
|
* @Description:
|
||
|
-->
|
||
|
<template>
|
||
|
<el-drawer :visible.sync="visible" :show-close="false" :wrapper-closable="false" class="drawer" size="50%">
|
||
|
<small-title slot="title" :no-padding="true">
|
||
|
{{ isdetail ? '详情' : !dataForm.id ? '新增' : '编辑' }}
|
||
|
</small-title>
|
||
|
<div class="content">
|
||
|
<!-- <div class="visual-part"> -->
|
||
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
|
||
|
label-width="100px" label-position="top">
|
||
|
<el-row :gutter="24">
|
||
|
<el-col :span="8">
|
||
|
<el-form-item label="供应商" prop="supplierId">
|
||
|
<el-select v-model="dataForm.supplierId" filterable :disabled="isdetail" style="width: 100%"
|
||
|
placeholder="请选择供应商">
|
||
|
<el-option v-for="dict in supplierList" :key=" dict.id" :label="dict.name" :value="dict.id" />
|
||
|
</el-select>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="8">
|
||
|
<el-form-item label="原料" prop="materialId">
|
||
|
<el-select v-model="dataForm.materialId" filterable :disabled="isdetail" style="width: 100%"
|
||
|
@change="getData" placeholder="请选择原料">
|
||
|
<el-option v-for="dict in materialList" :key=" dict.id" :label="dict.name" :value="dict.id" />
|
||
|
</el-select>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="8">
|
||
|
<el-form-item label="样品编码" prop="sampleCode">
|
||
|
<el-input v-model="dataForm.sampleCode" clearable :disabled="isdetail" placeholder="请输入样品编码" />
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
</el-row>
|
||
|
<el-row :gutter="24">
|
||
|
<el-col :span="8">
|
||
|
<el-form-item label="取样人" prop="samplerId">
|
||
|
<el-select v-model="dataForm.samplerId" filterable :disabled="isdetail" style="width: 100%"
|
||
|
placeholder="请选择取样人">
|
||
|
<el-option v-for="dict in workerList" :key=" dict.id" :label="dict.name" :value="dict.id" />
|
||
|
</el-select>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="8">
|
||
|
<el-form-item label="检测人" prop="checkerId">
|
||
|
<el-select v-model="dataForm.checkerId" filterable :disabled="isdetail" style="width: 100%"
|
||
|
placeholder="请选择检测人">
|
||
|
<el-option v-for="dict in workerList" :key=" dict.id" :label="dict.name" :value="dict.id" />
|
||
|
</el-select>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="8">
|
||
|
<el-form-item label="检测时间" prop="checkTime">
|
||
|
<el-date-picker v-model="dataForm.checkTime" type="datetime" placeholder="选择检测时间">
|
||
|
</el-date-picker>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
</el-row>
|
||
|
</el-form>
|
||
|
<!-- </div> -->
|
||
|
<div class="attr-list" v-if="idAttrShow">
|
||
|
<!-- <small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">
|
||
|
设备物料明细
|
||
|
</small-title>
|
||
|
|
||
|
<div v-if="!isdetail" class="action_btn">
|
||
|
<template>
|
||
|
<span style="display: inline-block;">
|
||
|
<el-button type="text" @click="addNew()" icon="el-icon-plus">新增</el-button>
|
||
|
</span>
|
||
|
</template>
|
||
|
</div>
|
||
|
<base-table :table-props="tableProps" :page="listQuery.pageNo" :limit="listQuery.pageSize"
|
||
|
:table-data="productAttrList">
|
||
|
<method-btn v-if="!isdetail" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
|
||
|
@clickBtn="handleClick" />
|
||
|
</base-table>
|
||
|
<pagination v-show="listQuery.total > 0" :total="listQuery.total" :page.sync="listQuery.pageNo"
|
||
|
:limit.sync="listQuery.pageSize" :page-sizes="[5, 10, 15]" @pagination="getList" /> -->
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="drawer-body__footer">
|
||
|
<el-button style="" @click="goback()">取消</el-button>
|
||
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||
|
</div>
|
||
|
<!-- <attr-add v-if="addOrUpdateVisible" ref="addOrUpdate" :product-id="dataForm.id" @refreshDataList="getList" /> -->
|
||
|
</el-drawer>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
// import basicAdd from '../../core/mixins/basic-add';
|
||
|
import {
|
||
|
getQualityHotMaterial,
|
||
|
updateQualityHotMaterial,
|
||
|
createQualityHotMaterial,
|
||
|
getHotMaterialAllList,
|
||
|
getSupplierList,
|
||
|
getWorkerList,
|
||
|
getMaterialCheckList
|
||
|
} from '@/api/base/qualityHotMaterial';
|
||
|
import SmallTitle from './SmallTitle';
|
||
|
// import { parseTime } from '../../core/mixins/code-filter';
|
||
|
// import attrAdd from './attr-add';
|
||
|
// import {DICT_TYPE, getDictDatas} from "@/utils/dict";
|
||
|
// import { publicFormatter } from '@/utils/dict';
|
||
|
const topBtnConfig = [
|
||
|
{
|
||
|
type: 'add',
|
||
|
btnName: 'btn.add'
|
||
|
}
|
||
|
]
|
||
|
|
||
|
export default {
|
||
|
// mixins: [basicAdd],
|
||
|
components: { SmallTitle },
|
||
|
data() {
|
||
|
return {
|
||
|
// tableBtn,
|
||
|
// tableProps,
|
||
|
// topBtnConfig,
|
||
|
addOrUpdateVisible: false,
|
||
|
urlOptions: {
|
||
|
isGetCode: false,
|
||
|
// codeURL: getCode,
|
||
|
createURL: createQualityHotMaterial,
|
||
|
updateURL: updateQualityHotMaterial,
|
||
|
infoURL: getQualityHotMaterial,
|
||
|
},
|
||
|
listQuery: {
|
||
|
pageSize: 10,
|
||
|
pageNo: 1,
|
||
|
total: 0,
|
||
|
},
|
||
|
materialList: [],
|
||
|
workerList: [],
|
||
|
supplierList:[],
|
||
|
equipmentList:[],
|
||
|
dataForm: {
|
||
|
id: undefined,
|
||
|
materialId:null,
|
||
|
supplierId: null,
|
||
|
sampleCode: null,
|
||
|
samplerId: null,
|
||
|
checkerId: null,
|
||
|
checkTime: null,
|
||
|
appearance: null,
|
||
|
checkResult: null,
|
||
|
materialGrade: null,
|
||
|
},
|
||
|
productAttrList: [],
|
||
|
visible: false,
|
||
|
isdetail: false,
|
||
|
idAttrShow: false,
|
||
|
dataRule: {
|
||
|
// code: [{ required: true, message: "设备物料编码不能为空", trigger: "blur" }],
|
||
|
name: [{ required: true, message: "设备物料名称不能为空", trigger: "blur" }],
|
||
|
equipmentId: [{ required: true, message: "设备名称不能为空", trigger: "change" }],
|
||
|
// : [{ required: true, message: "产品类型不能为空", trigger: "change" }],
|
||
|
// processTime: [{ required: true, message: "产线生产单位用时不能为空", trigger: "blur" }]
|
||
|
}
|
||
|
};
|
||
|
},
|
||
|
mounted() {
|
||
|
},
|
||
|
methods: {
|
||
|
dataFormSubmit() {
|
||
|
this.$refs["dataForm"].validate((valid) => {
|
||
|
if (!valid) {
|
||
|
return false;
|
||
|
}
|
||
|
// 修改的提交
|
||
|
if (this.dataForm.id) {
|
||
|
this.urlOptions.updateURL(this.dataForm).then(response => {
|
||
|
this.$modal.msgSuccess("修改成功");
|
||
|
this.visible = false;
|
||
|
this.$emit("refreshDataList");
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
// 添加的提交
|
||
|
this.urlOptions.createURL(this.dataForm).then(response => {
|
||
|
this.$modal.msgSuccess("新增成功");
|
||
|
this.idAttrShow = true;
|
||
|
this.dataForm.id = res.data
|
||
|
this.$emit("refreshDataList");
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
getData(val) {
|
||
|
console.log(val);
|
||
|
getMaterialCheckList({
|
||
|
materialId:val
|
||
|
}).then((res) => {
|
||
|
console.log(res);
|
||
|
})
|
||
|
},
|
||
|
// clickTopBtn(val) {
|
||
|
// if (val === 'add') {
|
||
|
// this.addNew()
|
||
|
// }
|
||
|
// },
|
||
|
initData() {
|
||
|
this.productAttrList.splice(0);
|
||
|
this.listQuery.total = 0;
|
||
|
},
|
||
|
getDict() {
|
||
|
getHotMaterialAllList().then((res) => {
|
||
|
this.materialList = res.data
|
||
|
})
|
||
|
getWorkerList().then((res) => {
|
||
|
this.workerList = res.data
|
||
|
})
|
||
|
getSupplierList().then(res => {
|
||
|
this.supplierList = res.data
|
||
|
})
|
||
|
},
|
||
|
handleClick(raw) {
|
||
|
if (raw.type === 'delete') {
|
||
|
this.$confirm(
|
||
|
`确定对${
|
||
|
raw.data.materialName
|
||
|
? '[物料名称为' + raw.data.materialName + ']'
|
||
|
: '[序号为' + raw.data.materialName + ']'
|
||
|
}进行删除操作?`,
|
||
|
'提示',
|
||
|
{
|
||
|
confirmButtonText: '确定',
|
||
|
cancelButtonText: '取消',
|
||
|
type: 'warning',
|
||
|
}
|
||
|
)
|
||
|
.then(() => {
|
||
|
deleteProcessEquMaterialBomDet(raw.data.id).then(({ data }) => {
|
||
|
this.$message({
|
||
|
message: '操作成功',
|
||
|
type: 'success',
|
||
|
duration: 1500,
|
||
|
onClose: () => {
|
||
|
this.getList();
|
||
|
},
|
||
|
});
|
||
|
});
|
||
|
})
|
||
|
.catch(() => {});
|
||
|
} else {
|
||
|
this.addNew(raw.data.id);
|
||
|
}
|
||
|
},
|
||
|
getList() {
|
||
|
// 获取产品属性列表
|
||
|
processEquMaterialBomDetPage({
|
||
|
...this.listQuery,
|
||
|
bomId: this.dataForm.id,
|
||
|
}).then((response) => {
|
||
|
this.productAttrList = response.data.list;
|
||
|
this.listQuery.total = response.data.total;
|
||
|
});
|
||
|
},
|
||
|
init(id, isdetail) {
|
||
|
this.initData()
|
||
|
this.getDict()
|
||
|
this.isdetail = isdetail || false;
|
||
|
this.dataForm.id = id || undefined;
|
||
|
this.visible = true;
|
||
|
if (id) {
|
||
|
this.idAttrShow = true
|
||
|
} else {
|
||
|
this.idAttrShow = false
|
||
|
}
|
||
|
|
||
|
this.$nextTick(() => {
|
||
|
this.$refs['dataForm'].resetFields();
|
||
|
|
||
|
if (this.dataForm.id) {
|
||
|
// 获取产品详情
|
||
|
this.urlOptions.infoURL({
|
||
|
bomId: id,
|
||
|
pageNo: 1,
|
||
|
pageSize:10
|
||
|
}).then(response => {
|
||
|
this.dataForm = response.data
|
||
|
this.dataForm.unit = String(this.dataForm.unit)
|
||
|
this.dataForm.materialType = String(this.dataForm.materialType)
|
||
|
this.dataForm.productType = String(this.dataForm.productType)
|
||
|
});
|
||
|
// 获取产品属性列表
|
||
|
this.getList();
|
||
|
} else {
|
||
|
if (this.urlOptions.isGetCode) {
|
||
|
this.getCode()
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
goback() {
|
||
|
this.$emit('refreshDataList');
|
||
|
this.visible = false;
|
||
|
// this.initData();
|
||
|
},
|
||
|
goEdit() {
|
||
|
this.isdetail = false;
|
||
|
},
|
||
|
// 新增 / 修改
|
||
|
addNew(id) {
|
||
|
this.addOrUpdateVisible = true;
|
||
|
this.$nextTick(() => {
|
||
|
this.$refs.addOrUpdate.init(id,this.dataForm.id);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
</script>
|
||
|
<style scoped>
|
||
|
.drawer >>> .el-drawer {
|
||
|
border-radius: 8px 0 0 8px;
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
}
|
||
|
|
||
|
.drawer >>> .el-form-item__label {
|
||
|
padding: 0;
|
||
|
}
|
||
|
|
||
|
.drawer >>> .el-drawer__header {
|
||
|
margin: 0;
|
||
|
padding: 32px 32px 24px;
|
||
|
border-bottom: 1px solid #dcdfe6;
|
||
|
}
|
||
|
.drawer >>> .el-drawer__body {
|
||
|
flex: 1;
|
||
|
height: 1px;
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
}
|
||
|
|
||
|
.drawer >>> .content {
|
||
|
padding: 30px 24px;
|
||
|
flex: 1;
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
/* height: 100%; */
|
||
|
}
|
||
|
|
||
|
.drawer >>> .visual-part {
|
||
|
flex: 1 auto;
|
||
|
max-height: 76vh;
|
||
|
overflow: hidden;
|
||
|
overflow-y: scroll;
|
||
|
padding-right: 10px; /* 调整滚动条样式 */
|
||
|
}
|
||
|
|
||
|
.drawer >>> .el-form,
|
||
|
.drawer >>> .attr-list {
|
||
|
padding: 0 16px;
|
||
|
}
|
||
|
|
||
|
.drawer-body__footer {
|
||
|
display: flex;
|
||
|
justify-content: flex-end;
|
||
|
padding: 18px;
|
||
|
}
|
||
|
.action_btn {
|
||
|
float: right;
|
||
|
margin: -40px 15px;
|
||
|
font-size: 14px;
|
||
|
}
|
||
|
.add {
|
||
|
color: #0b58ff;
|
||
|
}
|
||
|
</style>
|