461 lines
12 KiB
Vue
461 lines
12 KiB
Vue
<template>
|
|
<el-drawer
|
|
v-model="visible"
|
|
title="成品检验"
|
|
:size="'90%'"
|
|
destroy-on-close
|
|
@closed="$emit('closed')"
|
|
>
|
|
<div style="padding: 8px">
|
|
<div>
|
|
<el-card style="width: 100%" header="基本信息" shadow="hover">
|
|
<el-descriptions>
|
|
<el-descriptions-item label="物料">{{
|
|
workObj.material_name
|
|
}}</el-descriptions-item>
|
|
<el-descriptions-item label="批次号">{{
|
|
workObj.batch
|
|
}}</el-descriptions-item>
|
|
<el-descriptions-item label="日期">{{
|
|
workObj.test_date
|
|
}}</el-descriptions-item>
|
|
<el-descriptions-item label="总数">{{
|
|
workObj.count
|
|
}}</el-descriptions-item>
|
|
<el-descriptions-item label="合格数">{{
|
|
workObj.count_ok
|
|
}}</el-descriptions-item>
|
|
<el-descriptions-item label="不合格数">{{
|
|
workObj.count_notok
|
|
}}</el-descriptions-item>
|
|
<el-descriptions-item label="抽检数">{{
|
|
workObj.count_sampling
|
|
}}</el-descriptions-item>
|
|
<el-descriptions-item label="配棒管批次号" v-if=" workObj.mb_&&workObj.mb_.assemb">
|
|
<span v-for="item in workObj.mb_.assemb" :key="item.id">{{item.batch}}; </span>
|
|
</el-descriptions-item>
|
|
</el-descriptions>
|
|
<el-button
|
|
type="primary" @click="table_edit(workObj)">编辑</el-button>
|
|
</el-card>
|
|
</div>
|
|
<div style="height: 8px"></div>
|
|
<div>
|
|
<el-card style="width: 100%" header="检验记录" shadow="hover">
|
|
<sc-form-table
|
|
ref="formTable"
|
|
v-model="formTableData"
|
|
:addTemplate="addTemplate"
|
|
placeholder="暂无数据"
|
|
>
|
|
<el-table-column
|
|
prop="val"
|
|
label="抽检编号"
|
|
min-width="180"
|
|
>
|
|
<template #default="scope">
|
|
<!-- <span v-if="scope.row.id">{{ scope.row.test_numer }}</span> -->
|
|
<el-input
|
|
:disabled="!scope.row.isEdit"
|
|
v-model="scope.row.test_numer"
|
|
placeholder="抽检编号"
|
|
></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="检验记录" align="center">
|
|
<template
|
|
v-for="(item0, $index) in ftestitems"
|
|
:key="item0.id"
|
|
>
|
|
<el-table-column
|
|
prop="test_val_json"
|
|
:label="item0.name"
|
|
min-width="130"
|
|
>
|
|
{{ftestitems[$index].field_type}}
|
|
<!-- 小数 -->
|
|
<template v-if="ftestitems[$index].field_type == 'input-number'" #default="scope">
|
|
|
|
<el-input-number
|
|
v-model="scope.row.ftestitems[$index].test_val_json"
|
|
:disabled="!scope.row.isEdit"
|
|
:min="0"
|
|
:precision="2"
|
|
style="width: 100%"
|
|
controls-position="right"
|
|
>
|
|
</el-input-number>
|
|
</template>
|
|
<!-- 整数 -->
|
|
<template v-else-if="ftestitems[$index].field_type == 'input-int'" #default="scope">
|
|
<el-input-number
|
|
v-model="scope.row.ftestitems[$index].test_val_json"
|
|
:precision="0"
|
|
:disabled="!scope.row.isEdit"
|
|
:min="0"
|
|
style="width: 100%"
|
|
controls-position="right"
|
|
>
|
|
</el-input-number>
|
|
</template>
|
|
<!-- 文本 -->
|
|
<template v-else-if="ftestitems[$index].field_type == 'input-text'" #default="scope">
|
|
<el-input
|
|
v-model="scope.row.ftestitems[$index].test_val_json"
|
|
:disabled="!scope.row.isEdit"
|
|
>
|
|
</el-input>
|
|
</template>
|
|
<!-- 单选 -->
|
|
<template v-else-if="ftestitems[$index].field_type == 'select-text'" #default="scope">
|
|
<el-select
|
|
v-model="scope.row.ftestitems[$index].test_val_json"
|
|
clearable
|
|
:disabled="!scope.row.isEdit"
|
|
style="width: 100%"
|
|
>
|
|
<el-option
|
|
v-for="item in ftestitems[$index].choices"
|
|
:key="item"
|
|
:label="item"
|
|
:value="item"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
<!-- 多选 -->
|
|
<template v-else-if="ftestitems[$index].field_type == 'selects-text'" #default="scope">
|
|
<el-select
|
|
v-model="scope.row.ftestitems[$index].test_val_json"
|
|
clearable
|
|
multiple
|
|
:disabled="!scope.row.isEdit"
|
|
style="width: 100%"
|
|
>
|
|
<el-option
|
|
v-for="item in ftestitems[$index].choices"
|
|
:key="item"
|
|
:label="item"
|
|
:value="item"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
label="合格判定"
|
|
min-width="90"
|
|
>
|
|
<template #default="scope">
|
|
<el-select
|
|
v-model="scope.row.is_ok"
|
|
placeholder="是否合格"
|
|
clearable
|
|
:disabled="!scope.row.isEdit"
|
|
style="width: 100%"
|
|
>
|
|
<el-option label="是" :value="true" />
|
|
<el-option label="否" :value="false" />
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
prop="test_user"
|
|
label="检验人"
|
|
width="160"
|
|
>
|
|
<template #default="scope">
|
|
<xtSelect
|
|
:apiObj="apiUserObj"
|
|
:params="apiUserParams"
|
|
v-model="scope.row.test_user"
|
|
v-model:label="scope.row.test_user_name"
|
|
:edit="scope.row.isEdit"
|
|
style="width: 100%"
|
|
>
|
|
<el-table-column label="账号" prop="username"></el-table-column>
|
|
<el-table-column label="名称" prop="name"></el-table-column>
|
|
</xtSelect>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="val" label="备注">
|
|
<template #default="scope">
|
|
<el-input
|
|
:disabled="!scope.row.isEdit"
|
|
v-model="scope.row.note"
|
|
placeholder="备注"
|
|
></el-input>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
prop="open"
|
|
label="操作"
|
|
fixed="right"
|
|
width="90"
|
|
align="center"
|
|
>
|
|
<template #default="scope">
|
|
<el-link
|
|
type="primary"
|
|
v-if="scope.row.isEdit"
|
|
@click="saveCheck(scope.row)"
|
|
>保存</el-link
|
|
>
|
|
<el-link
|
|
type="primary"
|
|
v-else
|
|
@click="editCheck(scope.row)"
|
|
>编辑</el-link
|
|
>
|
|
<el-link
|
|
type="danger"
|
|
@click="delCheck(scope.row, scope.$index)"
|
|
style="margin-left: 2px"
|
|
>删除</el-link
|
|
>
|
|
</template>
|
|
</el-table-column>
|
|
</sc-form-table>
|
|
</el-card>
|
|
</div>
|
|
</div>
|
|
</el-drawer>
|
|
<save-dialog
|
|
v-if="dialog.save"
|
|
ref="saveDialog"
|
|
:mioId="mioId"
|
|
:belongDeptId="belongDeptId"
|
|
:belongDeptName="mioObj.belong_dept_name"
|
|
:mioObj="mioObj"
|
|
:cate="cate"
|
|
@success="handleSaveSuccess"
|
|
@closed="dialog.save = false"
|
|
>
|
|
</save-dialog>
|
|
<save-work-dialog
|
|
v-if="dialog.worksave"
|
|
ref="saveWorkDialog"
|
|
@success="handleWorkSaveSuccess"
|
|
@closed="dialog.worksave = false"
|
|
></save-work-dialog>
|
|
</template>
|
|
<script>
|
|
import saveDialog from "./product_check.vue";
|
|
import saveWorkDialog from "./product_form.vue";
|
|
export default {
|
|
name: "mioitem",
|
|
emits: ["success", "closed"],
|
|
props: {
|
|
ftestWork: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
materialCate: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
},
|
|
components: {
|
|
saveDialog,saveWorkDialog
|
|
},
|
|
data() {
|
|
return {
|
|
apiUserObj: this.$API.system.user.list,
|
|
apiUserParams: {posts__code__contains: "check"},
|
|
addTemplate: {
|
|
ftestitems: [{ test_val_json: "", check_val: "", testitem: "" ,choices:[],field_type:'',name:''}],
|
|
test_date: "", //work获取
|
|
test_numer: "",
|
|
is_ok: true,
|
|
test_user: "",
|
|
ftest_work: "", //work获取
|
|
isEdit: true,
|
|
type: "prod",
|
|
},
|
|
ftestitems: [],
|
|
dialog: {
|
|
worksave: false,
|
|
save: false,
|
|
},
|
|
apiObj: null,
|
|
params: {},
|
|
formTableData: [],
|
|
userList: [],
|
|
workObj: {},
|
|
visible: false,
|
|
};
|
|
},
|
|
watch: {
|
|
formTableData(newValue, oldValue) {
|
|
console.log("值发生了变化:", newValue);
|
|
this.testNumberChange();
|
|
},
|
|
},
|
|
mounted() {
|
|
let that = this;
|
|
that.addTemplate.ftest_work = that.ftestWork;
|
|
that.$API.qm.ftestwork.item.req(that.ftestWork).then((res) => {
|
|
that.workObj = res;
|
|
that.addTemplate.test_date = res.test_date;
|
|
that.getCheckList(that.ftestWork);
|
|
});
|
|
|
|
let tags = that.materialCate;
|
|
that.getTestItem(tags, that.ftestWork);
|
|
},
|
|
methods: {
|
|
open() {
|
|
this.visible = true;
|
|
},
|
|
//获取检验项目
|
|
getTestItem(tags, ftestWork) {
|
|
//tags__contains:首件/成品/性能 mcate_tags__contains:棒/管/套/
|
|
let that = this;
|
|
that.$API.qm.getTestItem
|
|
.get({ tags__contains: 'prod',mcate_tags__contains:tags, page: 0})
|
|
.then((res) => {
|
|
let arr = res;
|
|
that.ftestitems = res;
|
|
console.log('res',res)
|
|
let ftestitems = [];
|
|
arr.forEach((item) => {
|
|
let obj = {};
|
|
obj.test_val_json = null;
|
|
obj.testitem = item.id;
|
|
obj.field_type = item.field_type;
|
|
ftestitems.push(obj);
|
|
});
|
|
that.addTemplate.ftestitems = ftestitems;
|
|
console.log('addTemplate.ftestitems',that.addTemplate.ftestitems)
|
|
|
|
});
|
|
},
|
|
table_edit(row) {
|
|
this.dialog.worksave = true;
|
|
this.$nextTick(() => {
|
|
this.$refs.saveWorkDialog.open("edit").setData(row);
|
|
});
|
|
},
|
|
//表格数据
|
|
getCheckList(ftestwork) {
|
|
let that = this;
|
|
that.formTableData = [];
|
|
this.$API.qm.ftest.list
|
|
.req({ page: 0, type: "prod", ftest_work: ftestwork })
|
|
.then((res) => {
|
|
if (res.length > 0) {
|
|
that.addTemplate.test_numer = that.workObj.batch + "_" + (res.length + 1);
|
|
res.forEach((item) => {
|
|
let obj = {};
|
|
obj = item;
|
|
obj.isEdit = false;
|
|
that.formTableData.push(obj);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
testNumberChange() {
|
|
console.log('this.formTableData',this.formTableData)
|
|
this.addTemplate.test_numer =
|
|
this.workObj.batch + "_" + (this.formTableData.length + 1);
|
|
},
|
|
editCheck(row) {
|
|
this.formTableData.forEach((item, index) => {
|
|
if (item.id == row.id) {
|
|
this.formTableData[index].isEdit = true;
|
|
}
|
|
});
|
|
},
|
|
//删除
|
|
delCheck(row, index) {
|
|
if (row.id == undefined) {
|
|
this.formTableData.splice(index, 1);
|
|
return
|
|
}
|
|
let that = this;
|
|
that.$confirm(`确定删除吗?`, "提示", {
|
|
type: "warning",
|
|
})
|
|
.then(() => {
|
|
that.$API.qm.ftest.delete
|
|
.req(row.id)
|
|
.then((res) => {
|
|
that.$message.success("删除成功");
|
|
that.getCheckList(that.ftestWork);
|
|
this.getFtestWork();
|
|
return res;
|
|
})
|
|
.catch((err) => {
|
|
return err;
|
|
});
|
|
})
|
|
.catch(() => {});
|
|
},
|
|
getFtestWork() {
|
|
let that = this;
|
|
that.$API.qm.ftestwork.item.req(that.ftestWork).then((res) => {
|
|
that.workObj = res;
|
|
});
|
|
},
|
|
saveCheck(row) {
|
|
let that = this;
|
|
let index = this.formTableData.findIndex(
|
|
(item) => item.id == row.id
|
|
);
|
|
|
|
if (row.id && row.id !== "") {
|
|
that.$API.qm.ftest.update
|
|
.req(row.id, row)
|
|
.then((res) => {
|
|
that.formTableData[index].isEdit = false;
|
|
that.$message.success("操作成功");
|
|
this.getFtestWork();
|
|
})
|
|
.catch((err) => {
|
|
return err;
|
|
});
|
|
} else {
|
|
that.$API.qm.ftest.create
|
|
.req(row)
|
|
.then((res) => {
|
|
that.formTableData[index].isEdit = false;
|
|
that.$message.success("操作成功");
|
|
that.getCheckList(that.ftestWork);
|
|
this.getFtestWork();
|
|
})
|
|
.catch((err) => {
|
|
return err;
|
|
});
|
|
}
|
|
},
|
|
//本地更新数据
|
|
handleSaveSuccess(data, mode) {
|
|
this.$refs.table.refresh();
|
|
},
|
|
handleWorkSaveSuccess(){
|
|
let that = this;
|
|
that.$API.qm.ftestwork.item.req(that.ftestWork).then((res) => {
|
|
that.workObj = res;
|
|
});
|
|
},
|
|
handleCheckSuccess() {
|
|
this.$refs.table.refresh();
|
|
},
|
|
handleQuery() {
|
|
this.$refs.table.queryData(this.query);
|
|
},
|
|
resetQuery() {
|
|
this.query = {};
|
|
},
|
|
mioSubmit() {
|
|
this.$API.inm.mio.submit.req(this.mioObj.id).then((res) => {
|
|
this.$message.success("提交成功");
|
|
this.mioObj = res;
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|