584 lines
14 KiB
Vue
584 lines
14 KiB
Vue
<template>
|
|
<el-dialog
|
|
:title="titleMap[mode]"
|
|
v-model="visible"
|
|
destroy-on-close
|
|
style="width: 80%;"
|
|
@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" v-if="mgroupMtype == 20">
|
|
<el-form-item
|
|
label="外协单位"
|
|
prop="supplier"
|
|
>
|
|
<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" v-if="mlogtype!=='rework'">
|
|
<el-form-item label="工艺步骤">
|
|
<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.name"
|
|
:value="item.id"
|
|
>
|
|
<span>[{{ item.routepack_name }}]{{ item.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.team"
|
|
placeholder="班组"
|
|
:disabled="mode == 'edit'"
|
|
style="width: 100%"
|
|
>
|
|
<el-option
|
|
v-for="item in teamOptions"
|
|
: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="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" v-if="mode == 'edit'">
|
|
<el-form-item label="结束时间" prop="work_end_time">
|
|
<el-date-picker
|
|
v-model="form.work_end_time"
|
|
type="datetime"
|
|
:disabledDate="disabledDateFn"
|
|
value-format="YYYY-MM-DD HH:mm:ss"
|
|
style="width: 100%"
|
|
/>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :md="12" :sm="24" v-if="route_code=='chaoxi'||route_code=='chaoxi2'||route_code=='chaoxi3'">
|
|
<el-form-item label="操作人">
|
|
<el-select
|
|
v-model="form.handle_users"
|
|
placeholder="操作人"
|
|
clearable
|
|
filterable
|
|
multiple
|
|
:disabled="mode == 'edit'"
|
|
style="width: 100%"
|
|
@change="handleUsersChange"
|
|
>
|
|
<el-option
|
|
v-for="item in userOptions"
|
|
: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-else>
|
|
<el-form-item label="操作人">
|
|
<el-select
|
|
v-model="form.handle_user"
|
|
placeholder="操作人"
|
|
:disabled="mode == 'edit'"
|
|
style="width: 100%"
|
|
filterable
|
|
>
|
|
<el-option
|
|
v-for="item in userOptions"
|
|
: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="生产设备">
|
|
<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="检验文件">
|
|
<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-row>
|
|
<el-row>
|
|
<el-col :md="8" :sm="12" :xs="24" v-for="item in testitems" :key="item.id">
|
|
<el-form-item :label="item.name">
|
|
<el-input-number
|
|
v-if="item.field_type=='input-number'"
|
|
v-model="item.value"
|
|
:min="0"
|
|
class="width-100"
|
|
controls-position="right"
|
|
>
|
|
</el-input-number>
|
|
<el-input-number
|
|
v-if="item.field_type=='input-int'"
|
|
v-model="item.value"
|
|
:min="0"
|
|
class="width-100"
|
|
controls-position="right"
|
|
>
|
|
</el-input-number>
|
|
<el-input
|
|
v-if="item.field_type=='input-text'"
|
|
v-model="item.value"
|
|
class="width-100"
|
|
>
|
|
</el-input>
|
|
<el-select
|
|
v-if="item.field_type=='select-text'"
|
|
v-model="item.value"
|
|
clearable
|
|
class="width-100"
|
|
>
|
|
<el-option
|
|
v-for="item0 in item.choices"
|
|
:key="item0"
|
|
:label="item0"
|
|
:value="item0"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
<el-select
|
|
v-if="item.field_type=='selects-text'"
|
|
v-model="item.value"
|
|
clearable
|
|
multiple
|
|
class="width-100"
|
|
>
|
|
<el-option
|
|
v-for="item1 in item.choices"
|
|
:key="item1"
|
|
:label="item1"
|
|
:value="item1"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<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: '',
|
|
handle_users:[],
|
|
work_start_time: "",
|
|
work_end_time:null,
|
|
note:'',
|
|
mgroup:'',
|
|
handle_user_name:"",
|
|
reminder_interval_list: [0,0],
|
|
};
|
|
|
|
export default {
|
|
props: {
|
|
process: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
mgroupName:{
|
|
type: String,
|
|
default: "",
|
|
},
|
|
mgroup: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
dept: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
mgroupMtype:{
|
|
type: String,
|
|
default: "",
|
|
}
|
|
},
|
|
computed: {
|
|
title() {
|
|
return this.titleMap[this.mode];
|
|
},
|
|
},
|
|
emits: ["success", "closed"],
|
|
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
mode: "add",
|
|
titleMap: {
|
|
add: "新增日志",
|
|
edit: "编辑日志",
|
|
show: "查看日志",
|
|
},
|
|
route_code:"",
|
|
test_file:'',
|
|
fileList:[],
|
|
testitems:[],
|
|
//表单数据
|
|
form: Object.assign({}, defaultForm),
|
|
//验证规则
|
|
rules: {
|
|
supplier: [
|
|
{
|
|
required: true,
|
|
message: "请选择供应商",
|
|
trigger: "blur",
|
|
},
|
|
],
|
|
work_start_time: [
|
|
{
|
|
required: true,
|
|
message: "请选择生产开始时间",
|
|
trigger: "blur",
|
|
},
|
|
],
|
|
work_end_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: "外协" },
|
|
],
|
|
mlogtype:"",
|
|
codeText:"",
|
|
is_fix:false,
|
|
visible: false,
|
|
isSaveing: false,
|
|
options: [],
|
|
teamOptions:[],
|
|
routeOptions: [],
|
|
userOptions: [],
|
|
supplierOptions: [],
|
|
setFiltersVisible: false,
|
|
};
|
|
},
|
|
mounted() {
|
|
let that = this;
|
|
that.route_code = that.$route.path.split("/")[2];
|
|
this.getUser();
|
|
this.getRoute();
|
|
this.getTeam();
|
|
this.getSupplier();
|
|
this.getEquipment();
|
|
this.gettestitem();
|
|
let date = new Date();
|
|
this.form.work_start_time = this.form.work_end_time = this.$TOOL.dateFormat(date);
|
|
|
|
},
|
|
methods: {
|
|
getTeam() {
|
|
let that = this;
|
|
let form = {};
|
|
form.page = 0;
|
|
form.belong_dept = this.dept;
|
|
that.$API.mtm.team.list.req(form).then((res) => {
|
|
that.teamOptions = res;
|
|
});
|
|
},
|
|
teamChange(){
|
|
let that = this;
|
|
that.$API.mtm.teammember.list.req({team:that.form.team,page:0}).then((res) => {
|
|
that.userOptions = res;
|
|
});
|
|
},
|
|
//获取操作项
|
|
gettestitem(){
|
|
let that = this;
|
|
that.$API.qm.testitem.list.req({ process: that.process,type:20 }).then((res) => {
|
|
res.results.forEach((item) => {
|
|
let obj = {};
|
|
Object.assign(obj, item);
|
|
obj.value = '';
|
|
that.testitems.push(obj);
|
|
})
|
|
});
|
|
},
|
|
disabledDateFn(time) {
|
|
return time.getTime() > new Date().getTime();
|
|
},
|
|
// //获取
|
|
getUser() {
|
|
let that = this;
|
|
let userInfo = that.$TOOL.data.get("USER_INFO");
|
|
this.$API.system.user.list.req({ depts: that.dept, page: 0 }).then((res) => {
|
|
that.userOptions = res;
|
|
let arr = res.filter(item=>{
|
|
return item.id==userInfo.id;
|
|
})
|
|
if(arr.length>0){
|
|
that.form.handle_user = userInfo.id;
|
|
}else{
|
|
let obj = {};
|
|
obj.id = userInfo.id;
|
|
obj.name = userInfo.name;
|
|
that.userOptions.push(obj)
|
|
that.form.handle_user = userInfo.id;
|
|
}
|
|
});
|
|
},
|
|
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;
|
|
if(res.length==1){
|
|
that.form.route = res[0].id;
|
|
}
|
|
});
|
|
},
|
|
//显示
|
|
open(mode = "add",text) {
|
|
this.mode = mode;
|
|
if(text=='rework'){
|
|
this.mlogtype = 'rework';
|
|
this.form.mtype=10;
|
|
this.form.is_fix=true;
|
|
}else{
|
|
this.codeText = text;
|
|
}
|
|
|
|
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;
|
|
},
|
|
handleUsersChange(){
|
|
this.form.handle_user = this.form.handle_users.length>0?this.form.handle_users[0]:null;
|
|
console.log('handleUsersChange',this.form.handle_users)
|
|
},
|
|
//表单提交方法
|
|
submit() {
|
|
let that = this;
|
|
that.$refs.dialogForm.validate(async (valid) => {
|
|
if (valid) {
|
|
that.isSaveing = true;
|
|
that.form.mgroup = that.mgroup;
|
|
if(that.form.is_fix){
|
|
that.form.route = null;
|
|
}
|
|
if (that.mode === "add") {
|
|
if(that.mgroupName=='黑化'||that.mgroupName=='退火'){
|
|
let times = 0,reminder_interval_list=[];
|
|
that.testitems.forEach(item=>{
|
|
if(item.name=='退火时间'||item.name=='黑化时间'||item.name=='冷却时间'){
|
|
times = times + item.value;
|
|
reminder_interval_list.push(item.value);
|
|
}
|
|
})
|
|
let time_diff = times*60*1000;
|
|
let start_times = new Date(that.form.work_start_time).getTime();
|
|
let end_time = start_times + time_diff;
|
|
let work_end_time = new Date(end_time);
|
|
that.form.reminder_interval_list = reminder_interval_list;
|
|
that.form.work_end_time = that.$TOOL.dateFormat(work_end_time);
|
|
}
|
|
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>
|