423 lines
9.8 KiB
Vue
423 lines
9.8 KiB
Vue
<template>
|
|
<el-dialog
|
|
:title="titleMap[mode]"
|
|
v-model="visible"
|
|
:size="1000"
|
|
destroy-on-close
|
|
@closed="$emit('closed')"
|
|
>
|
|
<el-container v-loading="loading">
|
|
<el-main style="padding: 0 20px 20px 20px">
|
|
<el-form
|
|
ref="dialogForm"
|
|
:model="form"
|
|
:rules="rules"
|
|
label-position="right"
|
|
label-width="80px"
|
|
style="padding: 0 10px"
|
|
>
|
|
<el-row>
|
|
<el-col :md="12" :sm="24">
|
|
<el-form-item label="生产类型" prop="mtype">
|
|
<el-select
|
|
v-model="form.mtype"
|
|
placeholder="生产类型"
|
|
clearable
|
|
:disabled="mode == 'edit'"
|
|
style="width: 100%"
|
|
>
|
|
<el-option
|
|
v-for="item in typeOptions"
|
|
:key="item.id"
|
|
:label="item.name"
|
|
:value="item.id"
|
|
></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24" v-if="form.mtype == 20">
|
|
<el-form-item
|
|
label="外协单位"
|
|
prop="supplier"
|
|
v-if="form.mtype == 20"
|
|
>
|
|
<el-select
|
|
v-model="form.supplier"
|
|
placeholder="外协单位"
|
|
clearable
|
|
:disabled="mode == 'edit'"
|
|
style="width: 100%"
|
|
>
|
|
<el-option
|
|
v-for="item in supplierOptions"
|
|
:key="item.id"
|
|
:label="item.name"
|
|
:value="item.id"
|
|
></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24">
|
|
<el-form-item label="工艺路线" prop="route">
|
|
<el-select
|
|
v-model="form.route"
|
|
placeholder="工艺路线"
|
|
clearable
|
|
filterable
|
|
style="width: 100%"
|
|
:disabled="mode == 'edit'"
|
|
>
|
|
<el-option
|
|
v-for="item in routeOptions"
|
|
:key="item.id"
|
|
:label="item.routepack_name"
|
|
:value="item.id"
|
|
>
|
|
<span
|
|
>{{ item.routepack_name }}-{{
|
|
item.process_name
|
|
}}</span
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24">
|
|
<el-form-item label="生产设备">
|
|
<el-select
|
|
v-model="form.equipment"
|
|
placeholder="生产设备"
|
|
clearable
|
|
filterable
|
|
:disabled="mode == 'edit'"
|
|
style="width: 100%"
|
|
>
|
|
<el-option
|
|
v-for="item in options"
|
|
:key="item.id"
|
|
:label="item.label"
|
|
:value="item.id"
|
|
>
|
|
<span style="float:left">{{item.name}}</span>
|
|
<span style="float:right">{{item.number}}</span>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24" v-if="mgroupName=='磨抛一次抛'">
|
|
<el-form-item label="批次序号">
|
|
<el-input-number
|
|
v-model="form.index"
|
|
:min="0"
|
|
:max="99"
|
|
placeholder="第几炉,追加到批次"
|
|
style="width: 100%"
|
|
controls-position="right"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24">
|
|
<el-form-item
|
|
label="开始时间"
|
|
prop="work_start_time"
|
|
>
|
|
<el-date-picker
|
|
:disabled="mode == 'edit'"
|
|
v-model="form.work_start_time"
|
|
type="datetime"
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
style="width: 100%"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :md="12" :sm="24">
|
|
<el-form-item label="结束时间" prop="work_end_time">
|
|
<el-date-picker
|
|
v-model="form.work_end_time"
|
|
type="datetime"
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
style="width: 100%"
|
|
:disabledDate="disabledDateFn"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24" v-if="mgroupName=='黑化'||mgroupName=='退火'">
|
|
<el-form-item label="保温时间" required>
|
|
<el-input-number
|
|
v-model="form.reminder_interval_list[0]"
|
|
:min="0"
|
|
controls-position="right"
|
|
/>(min)
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24" v-if="mgroupName=='黑化'||mgroupName=='退火'">
|
|
<el-form-item label="冷却时间" required>
|
|
<el-input-number
|
|
v-model="form.reminder_interval_list[1]"
|
|
:min="0"
|
|
controls-position="right"
|
|
/>(min)
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24">
|
|
<el-form-item label="操作人">
|
|
<ehsSelect
|
|
v-model="form.handle_user"
|
|
:showName="form.handle_user_name"
|
|
:apiObj="this.$API.system.user.list"
|
|
:params="{ depts: dept }"
|
|
></ehsSelect>
|
|
</el-form-item>
|
|
</el-col>
|
|
<!-- 黑化 -->
|
|
<el-col :md="12" :sm="24" v-if="mgroupName=='黑化'">
|
|
<el-form-item label="检验文件">
|
|
<sc-upload-file
|
|
v-model="fileList"
|
|
:multiple="false"
|
|
:limit="1"
|
|
:accept="['.xlsx', '.xls']"
|
|
@success = "fileUPSuccess"
|
|
>
|
|
<el-button type="primary" icon="el-icon-upload"> </el-button>
|
|
</sc-upload-file>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :md="12" :sm="24">
|
|
<el-form-item label="备注">
|
|
<el-input
|
|
v-model="form.note"
|
|
clearable
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
</el-main>
|
|
<el-footer>
|
|
<el-button type="primary" :loading="isSaveing" @click="submit"
|
|
>保存</el-button
|
|
>
|
|
<el-button @click="visible = false">取消</el-button>
|
|
</el-footer>
|
|
</el-container>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
const defaultForm = {
|
|
mtype: "",
|
|
supplier:'',
|
|
route: "",
|
|
equipment: "",
|
|
handle_user: null,
|
|
work_start_time: "",
|
|
work_end_time:null,
|
|
note:'',
|
|
mgroup:'',
|
|
reminder_interval_list: [0,0],
|
|
};
|
|
|
|
export default {
|
|
props: {
|
|
process: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
mgroupName:{
|
|
type: String,
|
|
default: "",
|
|
},
|
|
mgroup: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
dept: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
},
|
|
computed: {
|
|
title() {
|
|
return this.titleMap[this.mode];
|
|
},
|
|
},
|
|
emits: ["success", "closed"],
|
|
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
mode: "add",
|
|
titleMap: {
|
|
add: "新增日志",
|
|
edit: "编辑日志",
|
|
show: "查看日志",
|
|
},
|
|
test_file:'',
|
|
fileList:[],
|
|
//表单数据
|
|
form: Object.assign({}, defaultForm),
|
|
//验证规则
|
|
rules: {
|
|
supplier: [
|
|
{
|
|
required: true,
|
|
message: "请选择供应商",
|
|
trigger: "blur",
|
|
},
|
|
],
|
|
work_start_time: [
|
|
{
|
|
required: true,
|
|
message: "请选择生产开始时间",
|
|
trigger: "blur",
|
|
},
|
|
],
|
|
route: [
|
|
{
|
|
required: true,
|
|
message: "请选择工艺路线",
|
|
trigger: "blur",
|
|
},
|
|
],
|
|
mtype: [
|
|
{
|
|
required: true,
|
|
message: "请选择生产类型",
|
|
trigger: "blur",
|
|
},
|
|
],
|
|
},
|
|
typeOptions: [
|
|
{ id: 10, name: "自产" },
|
|
{ id: 20, name: "外协" },
|
|
],
|
|
visible: false,
|
|
isSaveing: false,
|
|
options: [],
|
|
routeOptions: [],
|
|
userOptions: [],
|
|
supplierOptions: [],
|
|
setFiltersVisible: false,
|
|
};
|
|
},
|
|
mounted() {
|
|
this.getRoute();
|
|
this.getUser();
|
|
this.getSupplier();
|
|
this.getEquipment();
|
|
|
|
},
|
|
methods: {
|
|
disabledDateFn(time) {
|
|
return time.getTime() > new Date().getTime();
|
|
},
|
|
//获取
|
|
getUser() {
|
|
this.$API.system.user.list.req({ depts: this.dept }).then((res) => {
|
|
this.userOptions = res.results;
|
|
});
|
|
},
|
|
getEquipment() {
|
|
let that = this;
|
|
this.$API.em.equipment.list.req({ page: 0, type: 10,mgroup:that.mgroup}).then((res) => {
|
|
res.forEach((item) => {
|
|
let obj = {};
|
|
Object.assign(obj, item);
|
|
obj.label = item.name+'-'+item.number;
|
|
that.options.push(obj);
|
|
});
|
|
});
|
|
},
|
|
getSupplier() {
|
|
let that = this;
|
|
let obj = {};
|
|
obj.page = 0;
|
|
obj.can_outsource = true;
|
|
that.$API.pum.supplier.list.req(obj).then((res) => {
|
|
that.supplierOptions = res;
|
|
});
|
|
},
|
|
getRoute(id) {
|
|
let that = this;
|
|
that.$API.mtm.route.list
|
|
.req({ process: that.process, page: 0, routepack__state: 30 })
|
|
.then((res) => {
|
|
that.routeOptions = res;
|
|
});
|
|
},
|
|
//显示
|
|
open(mode = "add") {
|
|
this.mode = mode;
|
|
this.visible = true;
|
|
return this;
|
|
},
|
|
//表单注入数据
|
|
setData(data) {
|
|
console.log("data", data);
|
|
Object.assign(this.form, data);
|
|
if(data.test_file!==null){
|
|
this.form.test_file = data.test_file;
|
|
this.fileList = [{name:data.test_file,url:data.test_file}];
|
|
}
|
|
this.getRoute(data.id);
|
|
},
|
|
fileUPSuccess(res) {
|
|
let that = this;
|
|
console.log('res',res);
|
|
this.test_file = res.path;
|
|
},
|
|
//表单提交方法
|
|
submit() {
|
|
let that = this;
|
|
that.$refs.dialogForm.validate(async (valid) => {
|
|
if (valid) {
|
|
that.isSaveing = true;
|
|
that.form.mgroup = that.mgroup;
|
|
if (that.mode === "add") {
|
|
that.$API.wpm.mlog.init.req(that.form).then((res) => {
|
|
that.isSaveing = false;
|
|
that.$emit("success");
|
|
that.visible = false;
|
|
that.$message.success("操作成功");
|
|
}).catch(()=>{
|
|
that.isSaveing = false;
|
|
});
|
|
} else {
|
|
let obj = {};
|
|
obj.work_end_time = that.form.work_end_time;
|
|
obj.handle_user = that.form.handle_user;
|
|
obj.note = that.form.note;
|
|
if(that.mgroupName=='黑化'){
|
|
that.form.test_file = that.test_file;
|
|
}
|
|
that.$API.wpm.mlog.change.req(that.form.id, that.form).then((res) => {
|
|
that.isSaveing = false;
|
|
that.$emit("success");
|
|
that.visible = false;
|
|
that.$message.success("操作成功");
|
|
}).catch(()=>{
|
|
that.isSaveing = false;
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//设置过滤项
|
|
setFilters(filters) {
|
|
this.selectionFilters = filters;
|
|
this.setFiltersVisible = true;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
.form_unit {
|
|
position: absolute;
|
|
right: -25px;
|
|
}
|
|
</style>
|