fix:光芯日志输出物料编辑

This commit is contained in:
shijing 2025-01-10 10:43:08 +08:00
parent 4765754890
commit f1c363ed23
1 changed files with 13 additions and 239 deletions

View File

@ -26,109 +26,17 @@
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="实际生产数">
<el-form-item label="生产数" prop="count_real">
<el-input-number
v-model="form.count_real"
:min="0"
class="width-100"
controls-position="right"
@change="countChanges"
/>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="合格数量">
<el-input-number
v-model="form.count_ok"
:min="0"
class="width-100"
controls-position="right"
/>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="不合格数量">
<el-input-number
v-model="form.count_notok"
:min="0"
class="width-100"
@change="countChanges"
controls-position="right"
/>
</el-form-item>
</el-col>
</el-row>
<el-divider></el-divider>
<el-row>
<el-col :md="12" :sm="24" v-for="item in qct_testitems" :key="item.id">
<el-form-item :label="item.testitem_name">
<el-input-number
v-if="item.testitem_field_type=='input-number'"
v-model="form[item.testitem_name]"
:min="0"
class="width-100"
controls-position="right"
@change="defectCountSun"
>
</el-input-number>
<el-input-number
v-if="item.testitem_field_type=='input-int'"
v-model="form[item.testitem_name]"
:min="0"
class="width-100"
controls-position="right"
@change="defectCountSun"
>
</el-input-number>
<el-input
v-if="item.testitem_field_type=='input-text'"
v-model="form[item.testitem_name]"
class="width-100"
@change="defectCountSun"
>
</el-input>
<el-select
v-if="item.testitem_field_type=='select-text'"
v-model="form[item.testitem_name]"
clearable
class="width-100"
@change="defectCountSun"
>
<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="form[item.testitem_name]"
clearable
multiple
class="width-100"
@change="defectCountSun"
>
<el-option
v-for="item1 in item.testitem_choices"
:key="item1"
:label="item1"
:value="item1"
>
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24" v-for="item in qct_defects" :key="item.id">
<el-form-item :label="item.defect_name">
<span v-if="form['defect-'+item.defect_name]"></span>
<span v-else></span>
<span v-if="item.note!==null&&item.note!==''" style="font-size: 12px; color: #a9a7a7;">({{ item.note }})</span>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-main>
<el-footer>
@ -156,32 +64,7 @@ export default {
batch: null,
count_real: 0,
count_ok: 0,
count_notok: 0,
count_n_hs: 0,
count_n_qp: 0,
count_n_swen: 0,
count_n_bb: 0,
count_n_xbb:0,
count_n_md: 0,
count_n_xh: 0,
count_n_ps: 0,
count_n_qt: 0,
count_n_wm: 0,
count_n_zq:0
},
notokOptions:[
{name:"划伤",value:'count_n_hs'},
{name:"气泡",value:'count_n_qp'},
{name:"水纹",value:'count_n_swen'},
{name:"崩边",value:'count_n_bb'},
{name:"小崩边",value:'count_n_xbb'},
{name:"麻点",value:'count_n_md'},
{name:"划伤",value:'count_n_xh'},
{name:"破损",value:'count_n_ps'},
{name:"其他",value:'count_n_qt'},
{name:"雾面",value:'count_n_wm'},
{name:"棕圈",value:'count_n_zq'},
],
//
rules: {
batch: [
@ -191,108 +74,28 @@ export default {
trigger: "blur",
},
],
count_use: [
count_real: [
{
required: true,
message: "请填写领用数量",
message: "请填写生产数量",
trigger: "blur",
},
],
},
options: [],
qct_defects:[],
qct_testitems:[],
count_notok_json:[],
materialOptions: [],
visible: false,
isSaveing: false,
batchDisabled: false,
};
},
mounted() {
if (this.form.batch != null) {
this.batchDisabled = true;
}
console.log(this.material);
this.getQctDetail();
},
methods: {
open(data) {
this.visible = true;
Object.assign(this.form, data);
this.mgroupName = data.mgroup_name;
console.log(this.form);
},
//
getQctDetail(){
let that = this;
that.$API.qm.qct.list.req({ qctmat__material: that.material,page:0 }).then((res) => {
if(res.length>0){
that.qctId = res[0].id;
that.$API.qm.qct.item.req(that.qctId).then((res0) => {
//testitemdefectitem
that.qct_defects = [];
that.qct_testitems = [];
if(res0.qct_defects.length>0){
res0.qct_defects.forEach((item1) => {
let obj = Object.assign({}, item1);
obj.value = '';
that.qct_defects.push(obj);
})
}else{
that.qct_defects = [];
}
if(res0.qct_testitems.length>0){
res0.qct_testitems.forEach((item2) => {
let obj2 = Object.assign({}, item2);
obj2.value = '';
if(obj2.testitem_field_type=='select-text'||obj2.testitem_field_type=='selects-text'){
let str = obj2.testitem_choices.replace(/'/g, '"');
let arr = JSON.parse(str);
obj2.testitem_choices = arr;
}
that.qct_testitems.push(obj2);
})
}else{
that.qct_testitems = [];
}
that.defectCountSun();
})
}
});
},
defectCountSun(){
let that = this;
that.qct_defects.forEach(item => {
let str = item.rule_expression.replace(/`/g, '');
str = str.replace(/\${(.*?)}/g, 'this.form.\$1')
let judge = eval(str);
that.form['defect-'+item.defect_name] = judge;
});
},
notok_add(){
this.count_notok_json.push({notok:'qt',count:null,floor:null,count_sampling:null});
},
notok_del(index){
this.count_notok_json.splice(index, 1)
},
countChange() {
this.form.count_notok =
this.form.count_n_hs +
this.form.count_n_qp +
this.form.count_n_swen +
this.form.count_n_bb +
this.form.count_n_xbb +
this.form.count_n_md +
this.form.count_n_xh +
this.form.count_n_ps +
this.form.count_n_zq +
this.form.count_n_qt +
this.form.count_n_wm;
this.form.count_ok = this.form.count_real - this.form.count_notok;
},
countChanges(){
this.form.count_ok = this.form.count_real - this.form.count_notok;
this.form.count_ok = this.form.count_real;
},
//
submit() {
@ -301,44 +104,15 @@ export default {
if (valid) {
that.isSaveing = true;
that.form.mlog = that.mlog;
let sum = 0;
if(that.mgroupName=='黑化'||that.mgroupName=='退火'){
let total = 0;
that.count_notok_json.forEach(item => {
total+=item.count;
});
this.form.count_notok = total;
this.form.count_notok_json = this.count_notok_json;
}else{
this.form.count_notok =
this.form.count_n_hs +
this.form.count_n_qp +
this.form.count_n_swen +
this.form.count_n_bb +
this.form.count_n_xbb +
this.form.count_n_md +
this.form.count_n_xh +
this.form.count_n_ps +
this.form.count_n_zq +
this.form.count_n_qt +
this.form.count_n_wm;
}
sum = this.form.count_ok + this.form.count_notok;
if (sum - this.form.count_real == 0) {
that.$API.wpm.mlogb.updateOut
.req(that.form.id, that.form)
.then((res) => {
that.isSaveing = false;
that.$emit("success");
that.visible = false;
that.$message.success("操作成功");
})
.catch((err) => {
that.isSaveing = false;
});
} else {
this.$message.error("使用数量与合格数不合格数数量不对等");
}
that.form.count_ok = that.form.count_real;
that.$API.wpm.mlogb.updateOut.req(that.form.id, that.form).then((res) => {
that.isSaveing = false;
that.$emit("success");
that.visible = false;
that.$message.success("操作成功");
}).catch((err) => {
that.isSaveing = false;
});
}
});
},