1003 lines
29 KiB
Vue
1003 lines
29 KiB
Vue
<template>
|
||
<el-drawer
|
||
:title="headTitle[mode]"
|
||
v-model="visible"
|
||
:size="'90%'"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
@closed="$emit('closed')"
|
||
>
|
||
<el-container>
|
||
<el-header v-if="descriptionVisible">
|
||
<div style="display: flex;align-items: center;justify-content: space-between;width: 100%;">
|
||
<div>检验人:{{setForm.test_user_name}}</div>
|
||
<div>检验设备:{{setForm.equipment_name}}</div>
|
||
<div>缺陷项:
|
||
<span v-for="(item1,index1) in defectlists" :key="item1.id">{{ item1.defect_name }}
|
||
<span v-if="index1 < defectlists.length-1">、</span>
|
||
</span>
|
||
</div>
|
||
<div>检测项:
|
||
<span v-for="(item2,index2) in testitemlists" :key="item2.id">{{ item2.testitem_name }}
|
||
<span v-if="index2 < testitemlists.length-1">、</span>
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</el-header>
|
||
<el-main id="mlogbwMain">
|
||
<el-button type="primary" v-if="!isSubmit&&process_type=='20'&&mode=='outs'" @click="check_start" style="position: absolute;top: 20px;left: 150px;">检验</el-button>
|
||
<el-button type="primary" v-if="multipleSet" @click="check_set" style="position: absolute;top: 20px;left: 210px;">批量操作</el-button>
|
||
<el-input v-if="multipleSet" v-model="wprInputText" @change="wprinputChange" style="width:200px;position: absolute;top: 20px;left: 308px;">批量操作</el-input>
|
||
<sc-form-table
|
||
hideDelete
|
||
id="mlogbwlist"
|
||
:tableHeight="tableHeight"
|
||
v-model="mlogbwlist"
|
||
:addTemplate="addTemplate"
|
||
placeholder="暂无数据"
|
||
:hideAdd="hideAdd"
|
||
>
|
||
<el-table-column prop="number" label="物料编号" fixed min-width="120px">
|
||
<template #default="scope">
|
||
<span v-if="!scope.row.isEdit&&mode == 'outs'">{{ scope.row.number }}</span>
|
||
<el-input v-if="scope.row.isEdit&&mode == 'outs'" v-model="scope.row.number" placeholder="物料编号"></el-input>
|
||
<el-select
|
||
v-if="scope.row.isEdit&&mode == 'ins'&&route_code!=='niuzhuan'"
|
||
v-model="scope.row.wpr"
|
||
placeholder="动态成品"
|
||
clearable
|
||
style="width: 100%"
|
||
@change="optionChange(scope.row)"
|
||
>
|
||
<el-option
|
||
v-for="item in options"
|
||
:key="item.id"
|
||
:label="item.number"
|
||
:value="item.id"
|
||
>
|
||
</el-option>
|
||
</el-select>
|
||
<span v-if="!scope.row.isEdit&&mode == 'ins'">{{ scope.row.number }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="生产设备" min-width="80px" v-if="mode == 'ins'&&route_code=='niuzhuan'">
|
||
<template #default="scope">
|
||
<el-select
|
||
v-model="scope.row.equip"
|
||
placeholder="生产设备"
|
||
clearable
|
||
filterable
|
||
:disabled="!scope.row.isEdit"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="item in optionsEq"
|
||
:key="item.id"
|
||
:label="item.name"
|
||
:value="item.id"
|
||
>
|
||
<span style="float:left">{{item.name}}</span>
|
||
<span style="float:right">{{item.number}}</span>
|
||
</el-option>
|
||
</el-select>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="开始时间" min-width="80px" v-if="mode == 'ins'&&route_code=='niuzhuan'">
|
||
<template #default="scope">
|
||
<el-date-picker
|
||
:disabled="!scope.row.isEdit"
|
||
v-model="scope.row.work_start_time"
|
||
type="datetime"
|
||
value-format="YYYY-MM-DD HH:mm:ss"
|
||
style="width: 100%;"
|
||
popper-append-to-body
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="结束时间" min-width="80px" v-if="mode == 'ins'&&route_code=='niuzhuan'">
|
||
<template #default="scope">
|
||
<el-date-picker
|
||
v-model="scope.row.work_end_time"
|
||
type="datetime"
|
||
value-format="YYYY-MM-DD HH:mm:ss"
|
||
style="width: 100%;"
|
||
:disabled="!scope.row.isEdit"
|
||
popper-append-to-body
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<el-table-column prop="note" :label="item.testitem_name" v-for="item in qct_testitems" :key="item.id" width="150px">
|
||
<template #default="scope">
|
||
<el-input-number
|
||
v-if="item.testitem_field_type=='input-number'"
|
||
v-model="scope.row[item.testitem_name]"
|
||
:disabled="!scope.row.isEdit||!item.canEdit"
|
||
class="width-100"
|
||
controls-position="right"
|
||
@change="defectCountSun(scope.row)"
|
||
>
|
||
</el-input-number>
|
||
<el-input-number
|
||
v-if="item.testitem_field_type=='input-int'"
|
||
v-model="scope.row[item.testitem_name]"
|
||
:min="0"
|
||
:disabled="!scope.row.isEdit||!item.canEdit"
|
||
class="width-100"
|
||
controls-position="right"
|
||
@change="defectCountSun(scope.row)"
|
||
>
|
||
</el-input-number>
|
||
<el-input
|
||
v-if="item.testitem_field_type=='input-text'"
|
||
v-model="scope.row[item.testitem_name]"
|
||
class="width-100"
|
||
:disabled="!scope.row.isEdit||!item.canEdit"
|
||
@change="defectCountSun(scope.row)"
|
||
>
|
||
</el-input>
|
||
<el-select
|
||
v-if="item.testitem_field_type=='select-text'"
|
||
v-model="scope.row[item.testitem_name]"
|
||
clearable
|
||
class="width-100"
|
||
:disabled="!scope.row.isEdit||!item.canEdit"
|
||
@change="defectCountSun(scope.row)"
|
||
>
|
||
<el-option
|
||
v-for="item0 in item.testitem_choices"
|
||
:key="item0"
|
||
:label="item0"
|
||
:value="item0"
|
||
>
|
||
</el-option>
|
||
</el-select>
|
||
<el-select
|
||
v-if="item.testitem_field_type=='selects-text'"
|
||
v-model="scope.row[item.testitem_name]"
|
||
clearable
|
||
multiple
|
||
class="width-100"
|
||
:disabled="!scope.row.isEdit||!item.canEdit"
|
||
@change="defectCountSun(scope.row)"
|
||
>
|
||
<el-option
|
||
v-for="item1 in item.testitem_choices"
|
||
:key="item1"
|
||
:label="item1"
|
||
:value="item1"
|
||
>
|
||
</el-option>
|
||
</el-select>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="note" :label="item.defect_name" v-for="item in qct_defects" :key="item.id" width="120px">
|
||
<template #default="scope">
|
||
<el-switch
|
||
:disabled="!scope.row.isEdit||!item.canEdit"
|
||
v-model="scope.row[item.defect_name]"
|
||
style="--el-switch-on-color: red"
|
||
@change="switchChange(scope.row, item)"
|
||
></el-switch>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="note" label="备注" width="80px">
|
||
<template #default="scope">
|
||
<span v-if="!scope.row.isEdit">{{ scope.row.note }}</span>
|
||
<el-input v-else v-model="scope.row.note" placeholder="备注"></el-input>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="90" align="center" fixed="right" v-if="!isSubmit">
|
||
<template #default="scope">
|
||
<el-link
|
||
v-if="scope.row.isEdit"
|
||
type="primary"
|
||
size="small"
|
||
@click="formTableSave(scope.row)"
|
||
>保存</el-link
|
||
>
|
||
<el-link
|
||
v-if="scope.row.isEdit"
|
||
type="danger"
|
||
size="small"
|
||
style="margin-left: 5px;"
|
||
@click="formTableCancel(scope.row)"
|
||
>取消</el-link
|
||
>
|
||
<el-link
|
||
v-if="!scope.row.isEdit&&(mode=='outs'||route_code=='niuzhuan')"
|
||
type="primary"
|
||
size="small"
|
||
@click="formTableEdit(scope.row)"
|
||
>编辑</el-link
|
||
>
|
||
<el-link
|
||
v-if="!scope.row.isEdit"
|
||
type="danger"
|
||
size="small"
|
||
style="margin-left: 5px;"
|
||
@click="formTableDel(scope.row.id)"
|
||
>删除</el-link
|
||
>
|
||
</template>
|
||
</el-table-column>
|
||
</sc-form-table>
|
||
</el-main>
|
||
</el-container>
|
||
<el-dialog
|
||
title="检验"
|
||
v-model="checkVisible"
|
||
destroy-on-close
|
||
>
|
||
<el-container>
|
||
<el-main>
|
||
<el-form
|
||
ref="dialogForm"
|
||
:model="form"
|
||
:rules="rules"
|
||
label-width="80px"
|
||
>
|
||
<el-row>
|
||
<el-col :md="12" :sm="12" :xs="24">
|
||
<el-form-item label="操作人" prop="test_user">
|
||
<ehsSelect
|
||
v-model="form.test_user"
|
||
:showName="test_user_name"
|
||
:apiObj="this.$API.system.user.list"
|
||
:params="{ depts: dept }"
|
||
style="width: 100%"
|
||
@change="userChange"
|
||
></ehsSelect>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="12" :xs="24">
|
||
<el-form-item label="设备">
|
||
<el-select
|
||
v-model="form.equipment"
|
||
placeholder="设备"
|
||
clearable
|
||
filterable
|
||
style="width: 100%"
|
||
@change="equipmentChange"
|
||
>
|
||
<el-option
|
||
v-for="item in equipmentOptions"
|
||
:key="item.id"
|
||
:label="item.name"
|
||
: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="12" :xs="24">
|
||
<el-form-item label="检测项">
|
||
<el-select
|
||
v-model="form.testitemids"
|
||
placeholder="检测项"
|
||
clearable
|
||
filterable
|
||
multiple
|
||
style="width: 100%"
|
||
@change="testitemidsChange"
|
||
>
|
||
<el-option
|
||
v-for="item in qct_testitems"
|
||
:key="item.testitem"
|
||
:label="item.testitem_name"
|
||
:value="item.testitem"
|
||
>
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :md="12" :sm="12" :xs="24">
|
||
<el-form-item label="缺陷项">
|
||
<el-select
|
||
v-model="form.defectids"
|
||
placeholder="缺陷项"
|
||
clearable
|
||
filterable
|
||
multiple
|
||
style="width: 100%"
|
||
@change="defectidsChange"
|
||
>
|
||
<el-option
|
||
v-for="item in qct_defects"
|
||
:key="item.defect"
|
||
:label="item.defect_name"
|
||
:value="item.defect"
|
||
>
|
||
</el-option>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
<el-footer>
|
||
<el-button type="primary" :loading="isSaveing" @click.stop="checkSetting" save>确定</el-button>
|
||
<el-button @click="saveCancel">取消</el-button>
|
||
</el-footer>
|
||
</el-main>
|
||
</el-container>
|
||
</el-dialog>
|
||
<el-dialog
|
||
title="批量检验"
|
||
v-model="setVisible"
|
||
destroy-on-close
|
||
style="height:100%;width:80%"
|
||
>
|
||
<el-container>
|
||
<el-main>
|
||
<el-form
|
||
ref="dialogForm"
|
||
:model="form"
|
||
:rules="rules"
|
||
label-width="150px"
|
||
>
|
||
<el-row>
|
||
<el-col v-for="item2 in defectlists" :key="item2.id" :span="12">
|
||
<el-form-item :label="item2.defect_name">
|
||
<el-switch v-model="item2.value"></el-switch>
|
||
<!-- <el-input v-model="item2.value"></el-input> -->
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col>
|
||
<!-- 扫描物料的number 根据number对比list里的物料-->
|
||
<el-form-item label="检测物料" label-width="70px">
|
||
<el-input v-model="wprNumber" @change="wprChange(wprNumber)"></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
<el-row>
|
||
<el-table :data="selectWpr" border>
|
||
<el-table-column prop="number" label="物料编号"></el-table-column>
|
||
<el-table-column v-for="item2 in defectlists" :key="item2.id" :label="item2.defect_name">
|
||
{{ item2.value }}
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="90" align="center" fixed="right">
|
||
<template #default="scope">
|
||
<el-link type="danger" size="small" @click="selectWprDel(scope.row)">删除</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</el-row>
|
||
<el-footer>
|
||
<el-button type="primary" :loading="isSaveing" @click.stop="saveSetting" save>保存</el-button>
|
||
<el-button @click="saveCancel">取消</el-button>
|
||
</el-footer>
|
||
</el-main>
|
||
</el-container>
|
||
</el-dialog>
|
||
</el-drawer>
|
||
</template>
|
||
<script>
|
||
export default {
|
||
props: {
|
||
mlogb: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
wm: {
|
||
type: String,
|
||
default: "",
|
||
},
|
||
handle_user:{
|
||
type: String,
|
||
default: "",
|
||
},
|
||
handle_date:{
|
||
type: String,
|
||
default: "",
|
||
},
|
||
batchNumber:{
|
||
type: String,
|
||
default: "",
|
||
},
|
||
mgroup:{
|
||
type: String,
|
||
default: "",
|
||
},
|
||
mgroupName:{
|
||
type:String,
|
||
default:"",
|
||
},
|
||
dept:{
|
||
type:String,
|
||
default:"",
|
||
},
|
||
isSubmit:{
|
||
type: Boolean,
|
||
default: false,
|
||
},
|
||
},
|
||
// components: {
|
||
// checkDrawer
|
||
// },
|
||
emits: ["success", "closed"],
|
||
data() {
|
||
return {
|
||
loading: false,
|
||
headTitle:{
|
||
ins:'输入物料详情',
|
||
outs:'输出物料详情',
|
||
},
|
||
mode:'ins',
|
||
//表单数据
|
||
form: {
|
||
test_user:"",
|
||
equipment:"",
|
||
cd_req_addr:"",//请求数据接口地址
|
||
equipment_name:"",
|
||
testitemids : [],
|
||
defectids : [],
|
||
},
|
||
test_user_name:"",
|
||
qct:"",
|
||
values:"",
|
||
wprNumber:"",
|
||
route_code:"",
|
||
wprInputText:"",
|
||
params: {mlogb:'',page:0},
|
||
hideAdd: true,
|
||
visible: false,
|
||
setVisible:false,
|
||
multipleSet:false,
|
||
checkVisible:false,
|
||
descriptionVisible:false,
|
||
options:[],
|
||
qct_defects:[],
|
||
qct_testitems:[],
|
||
mlogbwlist:[],
|
||
equipmentOptions:[],
|
||
process_type:"",
|
||
addTemplate:{
|
||
mlogb: "",
|
||
number: "",
|
||
note: "",
|
||
isEdit: true,
|
||
},
|
||
setForm:{
|
||
test_user:"",
|
||
equipment:"",
|
||
equipment_name:"",
|
||
testitemids : [],
|
||
defectids : [],
|
||
},
|
||
rules: {
|
||
test_user: [{ required: true, message: "请选择操作人" }],
|
||
equipment:[{ required: true, message: "请选择设备" }],
|
||
|
||
},
|
||
optionsEq:[],
|
||
defectlists:[],
|
||
testitemlists:[],
|
||
qct_defects_origin:[],
|
||
selectWpr:[],
|
||
tableHeight:500,
|
||
apiObjPrint:this.$API.cm.labelmat.fromWm,
|
||
printer_name:localStorage.getItem("printer_name")
|
||
};
|
||
},
|
||
mounted() {
|
||
let that = this;
|
||
this.route_code = this.$route.path.split("/")[2];
|
||
if(this.route_code=='niuzhuan'){
|
||
this.getEquipment4();
|
||
}
|
||
that.hideAdd = that.isSubmit;
|
||
if(that.mgroupName!=='排板'){
|
||
that.addTemplate.number = that.batchNumber;
|
||
}
|
||
that.params.mlogb = that.addTemplate.mlogb = that.mlogb;
|
||
that.currentDate = this.$TOOL.dateFormat2(new Date());
|
||
// console.log(that.currentDate);
|
||
},
|
||
methods: {
|
||
open(mode = "ins",qct = '') {
|
||
let that = this;
|
||
this.mode = mode;
|
||
if(that.mode == 'ins'){//输入
|
||
that.getOptions();
|
||
this.qct = ""
|
||
}else{
|
||
this.qct = qct;
|
||
}
|
||
that.$API.mtm.mgroup.item.req(that.mgroup).then((res) => {
|
||
that.process_type=res.process_type;
|
||
if(that.mode == 'outs'&&qct!==''&&qct!==null){//输出
|
||
that.getdefects();
|
||
}else{
|
||
that.getList();
|
||
}
|
||
})
|
||
this.visible = true;
|
||
setTimeout(() => {
|
||
this.tableHeight = document.getElementById('mlogbwMain').clientHeight-20;
|
||
},500)
|
||
},
|
||
getEquipment4() {
|
||
let that = this;
|
||
that.$API.em.equipment.list.req({page:0,cate__code:"4"}).then((res) => {
|
||
that.optionsEq = res;
|
||
})
|
||
},
|
||
getEquipments(){
|
||
let that = this;
|
||
that.$API.em.equipment.list.req({page:0,cate__code:"6"}).then((res) => {
|
||
that.equipmentOptions = res;
|
||
})
|
||
},
|
||
getdefects(){
|
||
let that = this;
|
||
if(that.qct!==''){
|
||
that.$API.qm.qct.item.req(that.qct).then((res) => {
|
||
that.qct_defects = [];
|
||
res.qct_defects.forEach((item) => {
|
||
that.addTemplate[item.defect_name] = false;
|
||
let obj = Object.assign({}, item);
|
||
obj.canEdit = that.process_type=='20'?false:true;
|
||
that.qct_defects.push(obj);
|
||
})
|
||
that.qct_defects_origin = that.qct_defects;
|
||
that.qct_testitems = [];
|
||
res.qct_testitems.forEach((item2) => {
|
||
let obj2 = Object.assign({}, item2);
|
||
obj2.value = '';
|
||
obj2.canEdit = that.process_type=='20'?false:true;
|
||
|
||
obj2.addto_wpr = item2.addto_wpr;
|
||
if(item2.testitem_field_type=='input-number'||item2.testitem_field_type=='input-int'){
|
||
obj2.value = null;
|
||
that.addTemplate[item2.testitem_name] = null;
|
||
}
|
||
if(item2.testitem_field_type=='select-text'||item2.testitem_field_type=='selects-text'){
|
||
let str = obj2.testitem_choices.replace(/'/g, '"');
|
||
let arr = JSON.parse(str);
|
||
obj2.testitem_choices = arr;
|
||
that.addTemplate[item2.testitem_name] = null;
|
||
}
|
||
that.qct_testitems.push(obj2);
|
||
})
|
||
that.qct_testitems_origin = that.qct_testitems;
|
||
that.getList();
|
||
})
|
||
}else{
|
||
that.getList();
|
||
}
|
||
},
|
||
getOptions(){
|
||
let that = this;
|
||
that.$API.wpm.wpr.list.req({wm:that.wm,page:0}).then((res) => {
|
||
that.options = res;
|
||
})
|
||
},
|
||
optionChange(row){
|
||
let that = this;
|
||
that.options.forEach((item) => {
|
||
if(item.id == row.wpr){
|
||
let index = that.mlogbwlist.indexOf(row);
|
||
that.mlogbwlist[index].number = item.number;
|
||
}
|
||
})
|
||
},
|
||
getList(){
|
||
let that = this;
|
||
that.$API.wpm.mlogbw.list.req(that.params).then((res) => {
|
||
that.mlogbwlist = [];
|
||
if(res.length>0){
|
||
res.forEach((item) => {
|
||
let obj = {};
|
||
obj = Object.assign({},item);
|
||
obj.isEdit = false;
|
||
if(that.qct!=''){
|
||
if(item.ftest!=null){
|
||
if(item.ftest.ftestdefects!==undefined&&item.ftest.ftestdefects!==''&&item.ftest.ftestdefects!==null&&item.ftest.ftestdefects.length>0){
|
||
item.ftest.ftestdefects.forEach((item1) => {
|
||
obj[item1.defect_name] = item1.has;
|
||
})
|
||
}
|
||
if(item.ftest.ftestitems!==undefined&&item.ftest.ftestitems!==''&&item.ftest.ftestitems!==null&&item.ftest.ftestitems.length>0){
|
||
item.ftest.ftestitems.forEach((item2) => {
|
||
obj[item2.testitem_name] = item2.test_val_json;
|
||
})
|
||
}
|
||
}else{
|
||
that.qct_defects.forEach((item1) => {
|
||
obj[item1.defect_name] = false;
|
||
})
|
||
that.qct_testitems.forEach((item2) => {
|
||
obj[item2.testitem_name] = null;
|
||
// if(item2.testitem_field_type=='input-number'||item.testitem_field_type=='input-int'){
|
||
// obj[item2.testitem_name] = null;
|
||
// }else{
|
||
// obj[item2.testitem_name] = "";
|
||
// }
|
||
})
|
||
}
|
||
}
|
||
that.mlogbwlist.push(obj);
|
||
})
|
||
}
|
||
})
|
||
},
|
||
//添加
|
||
formTableSave(row) {
|
||
let that = this;
|
||
let obj = {};
|
||
obj.number = row.number;
|
||
obj.mlogb = row.mlogb;
|
||
obj.wpr = row.wpr;
|
||
obj.note = row.note;
|
||
//qct不为空,有检验表
|
||
if(that.qct!==''){
|
||
that.qct_defects_origin.forEach(item => {
|
||
if(item.rule_expression!==''&&item.rule_expression!==undefined&&item.rule_expression!==null){
|
||
let str = item.rule_expression.replace(/`/g, '');
|
||
str = str.replace(/\${(.*?)}/g, 'row.\$1')
|
||
let judge = eval(str);
|
||
row[item.defect_name] = judge;
|
||
}
|
||
});
|
||
//检验表已经填过
|
||
if(row.ftest!==null&&row.ftest!==undefined&&row.ftest!==''){
|
||
console.log('已填过');
|
||
obj.ftest =row.ftest;
|
||
obj.ftest.ftestdefects.forEach((item) => {
|
||
item.has = row[item.defect_name];
|
||
})
|
||
row.ftest.ftestitems.forEach((item1) => {
|
||
item1.test_val_json = row[item1.testitem_name];
|
||
})
|
||
}else{//检验表未填过
|
||
console.log('未填过');
|
||
obj.ftest = {};
|
||
obj.ftest.ftestitems = [];
|
||
obj.ftest.ftestdefects = [];
|
||
obj.ftest.qct = that.qct;
|
||
obj.ftest.test_date = that.handle_date!=null?that.handle_date:that.currentDate;
|
||
obj.ftest.test_user = that.handle_user;
|
||
that.qct_defects_origin.forEach((item) => {
|
||
let itemObj = {};
|
||
itemObj.defect = item.defect;
|
||
itemObj.test_user = that.handle_user;
|
||
itemObj.has = row[item.defect_name]?row[item.defect_name]:false;
|
||
obj.ftest.ftestdefects.push(itemObj);
|
||
})
|
||
that.qct_testitems.forEach((item1) => {
|
||
let itemObj1 = {};
|
||
itemObj1.testitem = item1.testitem;
|
||
itemObj1.test_user = that.handle_user;
|
||
itemObj1.addto_wpr = item1.addto_wpr;
|
||
itemObj1.test_val_json = row[item1.testitem_name];
|
||
obj.ftest.ftestitems.push(itemObj1);
|
||
})
|
||
}
|
||
}
|
||
// console.log('obj',obj);
|
||
if(that.mode == 'ins'&&that.route_code=='niuzhuan'){
|
||
obj.equip = row.equip;
|
||
obj.work_start_time = row.work_start_time;
|
||
obj.work_end_time = row.work_end_time;
|
||
}
|
||
if(row.id!==''&&row.id!==undefined&&row.id!==null){
|
||
obj.id = row.id;
|
||
that.$API.wpm.mlogbw.update.req(row.id,obj).then((res) => {
|
||
that.$message.success("保存成功");
|
||
that.getList();
|
||
return res;
|
||
}).catch((err) => {
|
||
return err;
|
||
});
|
||
}else{
|
||
that.$API.wpm.mlogbw.create.req(obj).then((res) => {
|
||
that.$message.success("添加成功");
|
||
that.getList();
|
||
return res;
|
||
}).catch((err) => {
|
||
return err;
|
||
});
|
||
}
|
||
},
|
||
formTableCancel(row){
|
||
this.mlogbwlist.forEach((item, index) => {
|
||
if (item.id == row.id) {
|
||
this.mlogbwlist[index].isEdit = false;
|
||
}
|
||
});
|
||
},
|
||
formTableEdit(row) {
|
||
this.mlogbwlist.forEach((item, index) => {
|
||
if (item.id == row.id) {
|
||
// console.log('row',row);
|
||
this.mlogbwlist[index].isEdit = true;
|
||
}
|
||
});
|
||
},
|
||
//删除
|
||
formTableDel(id) {
|
||
let that = this;
|
||
that.$confirm(`确定删除吗?`, "提示", {
|
||
type: "warning",
|
||
}).then(() => {
|
||
that.$API.wpm.mlogbw.delete.req(id).then((res) => {
|
||
that.getList();
|
||
that.$message.success("删除成功");
|
||
}).catch((err) => {
|
||
return err;
|
||
});
|
||
}).catch(() => {});
|
||
},
|
||
switchChange(row,item){
|
||
let that = this;
|
||
let index = that.mlogbwlist.indexOf(row);
|
||
that.mlogbwlist[index][item.defect_name] = row[item.defect_name];
|
||
},
|
||
//表单提交方法
|
||
mlogbwSubmit() {
|
||
let that = this;
|
||
},
|
||
//表单提交方法
|
||
mlogbSubmit() {
|
||
let that = this;
|
||
that.$API.wpm.mlogb.submit.req(that.mlogb).then((res) => {
|
||
that.isSaveing = false;
|
||
that.visible = false;
|
||
that.$message.success("操作成功");
|
||
});
|
||
},
|
||
defectCountSun(row){
|
||
let that = this;
|
||
let index = that.mlogbwlist.indexOf(row);
|
||
that.qct_defects_origin.forEach(item => {
|
||
// console.log('item.rule_expression',item.rule_expression);
|
||
if(item.rule_expression!==''&&item.rule_expression!==undefined&&item.rule_expression!==null){
|
||
let str = item.rule_expression.replace(/`/g, '');
|
||
str = str.replace(/\${(.*?)}/g, 'row.\$1')
|
||
let judge = eval(str);
|
||
that.mlogbwlist[index][item.defect_name] = judge;
|
||
}else{
|
||
that.mlogbwlist[index][item.defect_name] = false;
|
||
}
|
||
});
|
||
},
|
||
//设置过滤项
|
||
setFilters(filters) {
|
||
this.selectionFilters = filters;
|
||
this.setFiltersVisible = true;
|
||
},
|
||
handlePrint(){
|
||
let that = this;
|
||
that.printVisible = true;
|
||
},
|
||
//打印物料标签
|
||
printMaterial(row){
|
||
let that = this;
|
||
that.apiObj.req({tid:row.id}).then((res) => {
|
||
let code = res.code_label;
|
||
let str = [
|
||
"SIZE 40 mm,70 mm",
|
||
"GAP 7 mm,7 mm",
|
||
"CLS",
|
||
"REFERENCE 0,0",
|
||
'QRCODE 30,400,H,5,A,0,"' +code +'"',
|
||
"WINTEXT 200,550,28,90,0,0,Simhei," + res.material_name,
|
||
"WINTEXT 240,550,28,90,0,0,Simhei," + res.batch,
|
||
"PRINT 1",
|
||
];
|
||
let obj = {};
|
||
obj.printer_commands = str;
|
||
obj.printer_name = that.printer_name;
|
||
that.$API.wpm.prints.req(obj).then((response) => {
|
||
that.$message.success("打印成功");
|
||
});
|
||
})
|
||
},
|
||
userChange(val){
|
||
let that = this;
|
||
this.$API.system.user.item.req(val).then((res) => {
|
||
that.setForm.test_user_name = res.name;
|
||
})
|
||
},
|
||
equipmentChange(){
|
||
let that = this;
|
||
that.equipmentOptions.forEach(item => {
|
||
if(item.id == that.form.equipment){
|
||
that.form.equipment_name = item.name;
|
||
that.form.cd_req_addr=item.cd_req_addr;
|
||
}
|
||
});
|
||
},
|
||
testitemidsChange(){
|
||
let that = this;
|
||
that.testitemlists = [];
|
||
that.qct_testitems.forEach(item => {
|
||
if(that.form.testitemids.indexOf(item.testitem) > -1){
|
||
item.canEdit = true;
|
||
item.value=null;
|
||
that.testitemlists.push(item);
|
||
}
|
||
});
|
||
},
|
||
defectidsChange(){
|
||
let that = this;
|
||
that.defectlists = [];
|
||
that.qct_defects.forEach(item => {
|
||
if(that.form.defectids.indexOf(item.defect) > -1){
|
||
item.canEdit = true;
|
||
item.value=null;
|
||
that.defectlists.push(item);
|
||
}
|
||
})
|
||
},
|
||
check_start(){
|
||
this.checkVisible=true;
|
||
this.getEquipments();
|
||
},
|
||
checkSetting(){
|
||
let that = this;
|
||
this.$refs.dialogForm.validate((valid) => {
|
||
if (valid) {
|
||
Object.assign(that.setForm,that.form);
|
||
that.mlogbwlist.forEach(item => {
|
||
if(item.ftest!==null){
|
||
item.ftest.ftestdefects.forEach(defect => {
|
||
if(that.setForm.defectids.indexOf(defect.defect) > -1){
|
||
defect.test_user = that.setForm.test_user;
|
||
}
|
||
})
|
||
item.ftest.ftestitems.forEach(testitem => {
|
||
if(that.setForm.testitemids.indexOf(testitem.testitem) > -1){
|
||
testitem.test_user = that.setForm.test_user;
|
||
testitem.test_equip = that.setForm.equipment;
|
||
}
|
||
})
|
||
}else{
|
||
let ftest = {};
|
||
ftest.ftestitems = [];
|
||
ftest.ftestdefects = [];
|
||
ftest.qct = that.qct;
|
||
ftest.test_date =that.handle_date!=null?that.handle_date:that.currentDate;
|
||
ftest.test_user = that.handle_user;
|
||
that.qct_defects.forEach((item0) => {
|
||
let itemObj = {};
|
||
itemObj.defect = item0.defect;
|
||
itemObj.has = false;
|
||
if(that.setForm.defectids.indexOf(item0.defect) > -1){
|
||
itemObj.test_user = that.setForm.test_user;
|
||
}else{
|
||
itemObj.test_user = that.handle_user;
|
||
}
|
||
ftest.ftestdefects.push(itemObj);
|
||
})
|
||
that.qct_testitems.forEach((item1) => {
|
||
let itemObj1 = {};
|
||
itemObj1.testitem = item1.testitem;
|
||
itemObj1.addto_wpr = item1.addto_wpr;
|
||
itemObj1.test_val_json = "";
|
||
if(that.setForm.testitemids.indexOf(item1.testitem) > -1){
|
||
itemObj1.test_user = that.setForm.test_user;
|
||
itemObj1.test_equip = that.setForm.equipment;
|
||
}else{
|
||
itemObj1.test_user = that.handle_user;
|
||
}
|
||
ftest.ftestitems.push(itemObj1);
|
||
})
|
||
item.ftest = ftest;
|
||
}
|
||
});
|
||
that.$API.wpm.mlogbw.update.req("bulk",that.mlogbwlist).then((res) => {
|
||
this.form = {};
|
||
that.checkVisible = false;
|
||
this.multipleSet = true;
|
||
that.descriptionVisible = true;
|
||
that.qct_defects = [];
|
||
that.qct_defects = that.defectlists;
|
||
that.qct_testitems = [];
|
||
that.qct_testitems = that.testitemlists;
|
||
that.tableHeight = document.getElementById('mlogbwMain').clientHeight-80;
|
||
that.getList();
|
||
}).catch((err) => {
|
||
return err;
|
||
});
|
||
}
|
||
});
|
||
},
|
||
saveCancel(){
|
||
this.form = {};
|
||
this.form.test_user = "";
|
||
this.form.equipment = "";
|
||
this.form.testitemids = [];
|
||
this.form.defectids = [];
|
||
this.checkVisible = false;
|
||
},
|
||
check_set(){
|
||
this.setVisible=true;
|
||
},
|
||
//扫描物料将这一行放到第一行并编辑这一行
|
||
wprinputChange(){
|
||
let that = this;
|
||
that.mlogbwlist.forEach((item,index) => {
|
||
if(item.number == that.wprInputText){
|
||
let obj = Object.assign({},item);
|
||
obj.isEdit = true;
|
||
that.mlogbwlist.splice(index,1);
|
||
that.wprInputText = "";
|
||
that.mlogbwlist.unshift(obj);
|
||
if(that.setForm.cd_req_addr!==null){
|
||
//执行cd_req_addr,获取检测设备的数据
|
||
that.$API.em.cd.req({method:that.setForm.cd_req_addr}).then((res) => {
|
||
//例:res:[{"ZValue": "-0.18", "machineId": "testMachine","XValue": "-127.5831","YValue": "-12.5523"}]
|
||
//遍历检测项,查看是否有cd_expr
|
||
that.qct_testitems.forEach(item0 => {
|
||
if(item0.testitem_cd_expr!=null){
|
||
that.mlogbwlist[0][item0.testitem_name]= eval(item0.testitem_cd_expr);
|
||
}
|
||
})
|
||
|
||
}).catch((err) => {
|
||
return err;
|
||
});
|
||
}
|
||
}
|
||
})
|
||
},
|
||
wprChange(wprNumber){
|
||
let that = this;
|
||
that.mlogbwlist.forEach(item => {
|
||
if(item.number == wprNumber){
|
||
that.selectWpr.push(item);
|
||
that.wprNumber = "";
|
||
}
|
||
});
|
||
},
|
||
selectWprDel(row){
|
||
let that = this;
|
||
that.selectWpr.forEach((item,index) => {
|
||
if(item.number == row.number){
|
||
that.selectWpr.splice(index,1);
|
||
}
|
||
});
|
||
},
|
||
saveSetting(){
|
||
let that = this;
|
||
this.$refs.dialogForm.validate((valid) => {
|
||
if (valid) {
|
||
that.selectWpr.forEach(item => {
|
||
item.ftest.ftestdefects.forEach(defect => {
|
||
let defectindex = that.setForm.defectids.indexOf(defect.defect);
|
||
if(defectindex > -1){
|
||
defect.has = that.defectlists[defectindex].value;
|
||
}
|
||
})
|
||
item.ftest.ftestitems.forEach(testitem => {
|
||
let testitemindex = that.setForm.testitemids.indexOf(testitem.testitem);
|
||
if( testitemindex > -1){
|
||
testitem.test_val_json = that.testitemlists[testitemindex].value;
|
||
}
|
||
})
|
||
});
|
||
that.$API.wpm.mlogbw.update.req("bulk",that.selectWpr).then((res) => {
|
||
that.setVisible = false;
|
||
// that.descriptionVisible = false;
|
||
// that.setForm = {};
|
||
that.getList();
|
||
}).catch((err) => {
|
||
return err;
|
||
});
|
||
}
|
||
});
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
.width-100{
|
||
width: 100%;
|
||
}
|
||
</style>
|