检验任务不良类型修改

master
shaoyong 8 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
});
}

@ -173,4 +173,4 @@ export function getCkeckProjectXJList(query) {
method: 'get', method: 'get',
params: query params: query
}); });
} }

@ -40,14 +40,13 @@
</el-table-column> </el-table-column>
<el-table-column label="不良类型" align="left" prop="defectCode" width="120"> <el-table-column label="不良类型" align="left" prop="defectCode" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.defectCode" placeholder="检验结果" clearable> <el-button
<el-option size="mini"
v-for="(item,index) in defectList" type="text"
:key="index" icon="el-icon-edit"
:label="item.defectSubclass" @click="handleDefectType(scope.row)"
:value="item.defectCode" v-hasPermi="['quality:qcIncome:edit']"
/> >不良数量</el-button>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="不良数量" align="left" prop="defectQuality" width="120"> <el-table-column label="不良数量" align="left" prop="defectQuality" width="120">
@ -113,11 +112,32 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-dialog> </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> </div>
</template> </template>
<script> <script>
import { getCkeckProjectList,changeCheckDetailStatus,commitActualValue,commitCheckResult,getDefectList } from "@/api/quality/income"; import { getCkeckProjectList,changeCheckDetailStatus,commitActualValue,commitCheckResult,getDefectList} from "@/api/quality/income";
import { getDefectValue, commitDefectValue, updateDefectValue} from "@/api/quality/checkTaskDefect";
export default { export default {
name: "itemSelectUser", name: "itemSelectUser",
dicts: ["check_result","qc_rule_prop"], dicts: ["check_result","qc_rule_prop"],
@ -162,8 +182,28 @@ export default {
valueOpen: false, valueOpen: false,
//id //id
recordId:'', recordId:'',
typeCode:'',// //belongTo
defectList:[]// belongTo:'',
//
typeCode:'',
//
defectOpen: false,
updateFlag: false,
//
defectList:[],
defectForm: {
defectItems: [
{defectSubclass: '',
defectCode: '',
noOkQuality: 0,
belongToDetail: '',
belongTo: ''
}
]
},
}; };
}, },
created() { created() {
@ -174,6 +214,11 @@ export default {
getDefect(){ getDefect(){
getDefectList(this.typeCode).then(response => { getDefectList(this.typeCode).then(response => {
this.defectList = response; this.defectList = response;
this.defectForm.defectItems = this.defectList.map(item => ({
defectSubclass: item.defectSubclass,
defectCode: item.defectCode,
noOkQuality: 0
}));
}); });
}, },
@ -227,13 +272,13 @@ export default {
}, },
getAllRowData() { getAllRowData() {
const rowArray = this.$refs.myTable.data; const rowArray = this.$refs.myTable.data;
this.rowData = rowArray.map(obj => { this.rowData = rowArray.map(obj => {
const found = this.defectList.find(subObj => subObj.defectCode === obj.defectCode); const found = this.defectList.find(subObj => subObj.defectCode === obj.defectCode);
if (found) { if (found) {
return { ...obj, defectSubclass: found.defectSubclass }; return { ...obj, defectSubclass: found.defectSubclass };
} else { } else {
return obj; return obj;
} }
}); });
}, },
@ -281,6 +326,28 @@ export default {
this.valueOpen = true; this.valueOpen = true;
this.recordId = row.recordId; 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) { submitForm(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
@ -312,6 +379,51 @@ export default {
value: '', value: '',
key: Date.now() 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