检验任务不良类型修改

yangwl
shaoyong 6 months ago
parent a463c17a04
commit 9d2636329e

@ -0,0 +1,22 @@
import request from '@/utils/request'
export function getDefectValue(belongToDetail) {
return request({
url: '/quality/qcCheckTaskDefect/getDefectValue/' + belongToDetail,
method: 'get',
});
}
export function commitDefectValue(data) {
return request({
url: '/quality/qcCheckTaskDefect/commitDefectValue',
method: 'post',
data: data
});
}
export function updateDefectValue(data) {
return request({
url: '/quality/qcCheckTaskDefect/updateDefectValue',
method: 'put',
data: data
});
}

@ -40,14 +40,13 @@
</el-table-column>
<el-table-column label="不良类型" align="left" prop="defectCode" width="120">
<template slot-scope="scope">
<el-select v-model="scope.row.defectCode" placeholder="检验结果" clearable>
<el-option
v-for="(item,index) in defectList"
:key="index"
:label="item.defectSubclass"
:value="item.defectCode"
/>
</el-select>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleDefectType(scope.row)"
v-hasPermi="['quality:qcIncome:edit']"
>不良数量</el-button>
</template>
</el-table-column>
<el-table-column label="不良数量" align="left" prop="defectQuality" width="120">
@ -113,11 +112,32 @@
</el-form-item>
</el-form>
</el-dialog>
<el-dialog title="不良类型" :visible.sync="defectOpen" width="600px" append-to-body>
<el-form :model="defectForm" ref="defectForm" label-width="100px" class="demo-dynamic">
<el-form-item
v-for="(item, index) in defectForm.defectItems"
:label="item.defectSubclass"
:key="index"
:prop="`defectItems.${index}.noOkQuality`"
:rules="{
required: true, message: '不良类型不能为空', trigger: 'blur'
}"
>
<el-input type="number" v-model="item.noOkQuality" placeholder="请输入不良数量" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitDefectForm('defectForm')"></el-button>
<el-button @click="resetDefectForm('defectForm')"></el-button>
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<script>
import { getCkeckProjectList,changeCheckDetailStatus,commitActualValue,commitCheckResult,getDefectList} from "@/api/quality/income";
import { getDefectValue, commitDefectValue, updateDefectValue} from "@/api/quality/checkTaskDefect";
export default {
name: "itemSelectUser",
dicts: ["check_result","qc_rule_prop"],
@ -162,8 +182,28 @@ export default {
valueOpen: false,
//id
recordId:'',
typeCode:'',//
defectList:[]//
//belongTo
belongTo:'',
//
typeCode:'',
//
defectOpen: false,
updateFlag: false,
//
defectList:[],
defectForm: {
defectItems: [
{defectSubclass: '',
defectCode: '',
noOkQuality: 0,
belongToDetail: '',
belongTo: ''
}
]
},
};
},
created() {
@ -174,6 +214,11 @@ export default {
getDefect(){
getDefectList(this.typeCode).then(response => {
this.defectList = response;
this.defectForm.defectItems = this.defectList.map(item => ({
defectSubclass: item.defectSubclass,
defectCode: item.defectCode,
noOkQuality: 0
}));
});
},
@ -281,6 +326,28 @@ export default {
this.valueOpen = true;
this.recordId = row.recordId;
},
/** 不良类型弹窗 */
handleDefectType(row) {
this.defectForm.defectItems.forEach(item => {
item.belongToDetail = row.recordId;
item.belongTo = row.belongTo;
});
getDefectValue(row.recordId).then(response => {
let values = response.rows;
if(values.length > 0){
this.defectForm.defectItems = values.map(item => ({
//qc_check_task_defectrecordId
recordId: item.recordId,
defectSubclass: item.defectSubclass,
defectCode: item.defectCode,
noOkQuality: item.noOkQuality,
}));
this.updateFlag = true;
}
this.defectOpen = true;
});
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
@ -312,6 +379,51 @@ export default {
value: '',
key: Date.now()
});
},
submitDefectForm() {
this.$refs.defectForm.validate((valid) => {
// 使 defectForm.defectItems
const formData = this.defectForm.defectItems;
if (valid) {
//
if(!this.updateFlag) {
commitDefectValue(formData).then(response => {
if(response.code === 200) {
this.$modal.msgSuccess("提交成功");
}else {
this.$modal.msgError(response.msg);
}
this.defectForm.defectItems = [];
this.defectOpen = false;
this.getDefect();
});
}else {
console.log(formData);
updateDefectValue(formData).then(response => {
if(response.code === 200) {
this.$modal.msgSuccess("修改成功");
}else {
this.$modal.msgError(response.msg);
}
this.defectForm.defectItems = [];
this.defectOpen = false;
this.getDefect();
});
}
} else {
//
console.log('error submit!!');
return false;
}
});
},
resetDefectForm() {
this.$refs.defectForm.resetFields();
// defectForm.defectItems noOkQuality
this.defectForm.defectItems.forEach(item => (item.noOkQuality = 0));
}
}
};

Loading…
Cancel
Save