factory_web/src/views/inm/mioitem_check.vue

1600 lines
43 KiB
Vue

<template>
<el-dialog
title="检验"
v-model="visible"
:size="1200"
destroy-on-close
@closed="$emit('closed')"
>
<el-container v-loading="loading">
<el-main style="padding: 0">
<el-form
ref="dialogForm"
:model="form"
:rules="rules"
label-width="140px"
>
<!-- 半成品 -->
<el-row
v-if="
(type == 'do_in' && cate == 'halfgood') ||
type == 'other_in'
"
>
<el-col :md="12" :sm="24">
<el-form-item label="检验日期" prop="test_date">
<el-date-picker
v-model="form.test_date"
type="date"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="检验人" prop="test_user">
<el-select
v-model="form.test_user"
placeholder="检验人"
clearable
style="width: 100%"
>
<el-option
v-for="item in userList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</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"
style="width: 100%"
disabled
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="炸纹">
<el-input-number
v-model="form.count_n_zw"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="条纹">
<el-input-number
v-model="form.count_n_tw"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="气泡">
<el-input-number
v-model="form.count_n_qp"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="弯曲">
<el-input-number
v-model="form.count_n_wq"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="断裂">
<el-input-number
v-model="form.count_n_dl"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="偏壁">
<el-input-number
v-model="form.count_n_pb"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="大小头">
<el-input-number
v-model="form.count_n_dxt"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="结石">
<el-input-number
v-model="form.count_n_js"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="气线">
<el-input-number
v-model="form.count_n_qx"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="划伤">
<el-input-number
v-model="form.count_n_hs"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="杂质">
<el-input-number
v-model="form.count_n_zz"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="颜色青">
<el-input-number
v-model="form.count_n_ysq"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="扁">
<el-input-number
v-model="form.count_n_b"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="其他">
<el-input-number
v-model="form.count_n_qt"
@change="countNotOkSun"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="备注">
<el-input v-model="form.test_note"> </el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 成品 -->
<el-row v-if="type == 'do_in' && cate == 'good'">
<el-col :md="12" :sm="24">
<el-form-item label="批次号:">
{{ objitem.batch }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="总数:">
{{ objitem.count }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="检验日期" prop="test_date">
<el-date-picker
v-model="form.test_date"
type="date"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="抽检数">
<el-input-number
v-model="form.count"
:min="0"
style="width: 100%"
@change="countChange"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="划伤">
<el-input-number
v-model="form.count_n_hs"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="划伤"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="挫伤">
<el-input-number
v-model="form.count_n_cs"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="挫伤"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="杂质">
<el-input-number
v-model="form.count_n_zz"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="杂质"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="条纹">
<el-input-number
v-model="form.count_n_tw"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="条纹"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="锥度大">
<el-input-number
v-model="form.count_n_zdd"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="锥度大"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="短">
<el-input-number
v-model="form.count_n_d"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="短"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="炸纹">
<el-input-number
v-model="form.count_n_zw"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="炸纹"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<!-- 棒 -->
<el-col :md="12" :sm="24">
<el-form-item label="断裂">
<el-input-number
v-model="form.count_n_dl"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="断裂"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="气泡">
<el-input-number
v-model="form.count_n_qp"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="气泡"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="不亮">
<el-input-number
v-model="form.count_n_bl"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="不亮"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="横纹">
<el-input-number
v-model="form.count_n_hw"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="横纹"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="有皮">
<el-input-number
v-model="form.count_n_yp"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="有皮"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="爆皮">
<el-input-number
v-model="form.count_n_bp"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="爆皮"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="色差">
<el-input-number
v-model="form.count_n_sc"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="色差"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<!-- 管 -->
<el-col :md="12" :sm="24">
<el-form-item label="气线">
<el-input-number
v-model="form.count_n_qx"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="气线"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="结石">
<el-input-number
v-model="form.count_n_js"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="结石"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="椭圆度大">
<el-input-number
v-model="form.count_n_tydd"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="椭圆度大"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="水雾">
<el-input-number
v-model="form.count_n_sw"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="水雾"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="壁厚偏差大">
<el-input-number
v-model="form.count_n_bhpcd"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="壁厚偏差大"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="弯">
<el-input-number
v-model="form.count_n_wq"
controls-position="right"
:min="0"
:step="1"
:step-strictly="true"
style="width: 100%"
placeholder="弯"
@change="countNotOkSun"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="合计">
<el-input-number
v-model="form.count_notok"
controls-position="right"
style="width: 100%"
placeholder="合计"
disabled
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="备注">
<el-input
v-model="form.test_note"
tyle="width:100%"
placeholder="备注"
></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 入厂检验 -->
<el-row v-if="type == 'pur_in'&&project_code=='gx'">
<el-col :md="12" :sm="24">
<el-form-item label="产品名称:" label-width="100">
{{ objitem.material_name }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="入厂批次号:" label-width="100">
{{ objitem.batch }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="批次号" required label-width="100">
<el-input v-model="form.batch"> </el-input>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="接收总数" required label-width="100">
<el-input-number
v-model="form.count"
:min="0"
style="width: 100%"
controls-position="right"
@change="gxPurInCountChange"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="合格数" label-width="100">
<el-input-number
v-model="form.count_ok"
disabled
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="不合格数量" label-width="100">
<el-input
v-model="form.count_notok"
disabled
style="width: 100%"
placeholder="不合格数量"
/>
</el-form-item>
</el-col>
<el-col>异常项:</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="直径" label-width="100">
<el-input-number
v-model="form.count_n_zw"
:min="0"
style="width: 100%"
controls-position="right"
@change="nqtChange"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="长度" label-width="100">
<el-input-number
v-model="form.count_n_dl"
:min="0"
style="width: 100%"
controls-position="right"
@change="nqtChange"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="崩面" label-width="100">
<el-input-number
v-model="form.count_n_b"
:min="0"
style="width: 100%"
controls-position="right"
@change="nqtChange"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="亮面" label-width="100">
<el-input-number
v-model="form.count_n_zz"
:min="0"
style="width: 100%"
controls-position="right"
@change="nqtChange"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="检验日期" prop="test_date" label-width="100">
<el-date-picker
v-model="form.test_date"
type="date"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="检验员" prop="test_user" label-width="100">
<el-select
v-model="form.test_user"
placeholder="检验员"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="item in userList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="备注" label-width="100">
<el-input v-model="form.test_note"> </el-input>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="type == 'pur_in'&&project_code!='gx'">
<el-col :md="12" :sm="24">
<el-form-item label="产品名称:">
{{ objitem.material_name }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="入厂批次号:">
{{ objitem.batch }}
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item v-if="project_code === 'gz'" label="总袋(桶)数">
<el-input-number
v-model="form.count_bag"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="抽样数量">
<el-input
disabled
v-model="form.count_sampling"
placeholder="抽样数量"
/>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="检验日期" prop="test_date">
<el-date-picker
v-model="form.test_date"
type="date"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="检验员" prop="test_user">
<el-select
v-model="form.test_user"
placeholder="检验员"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="item in userList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="检验合格" prop="is_testok">
<el-select
v-model="form.is_testok"
placeholder="检验合格"
clearable
style="width: 100%"
>
<el-option label="是" :value="true" />
<el-option label="否" :value="false" />
</el-select>
</el-form-item>
</el-col>
<!-- 光子 -->
<el-col :md="12" :sm="24" v-if="project_code == 'gz'">
<el-form-item label="抽样计算总重量/Kg">
<el-input-number
v-model="form.count_bag_weight_all"
:min="0"
style="width: 100%"
controls-position="right"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="备注">
<el-input v-model="form.test_note"> </el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 光子 -->
<el-row v-if="project_code == 'gz'">
<el-col>
<el-form-item label="称重记录/Kg">
<el-button
type="primary"
icon="el-icon-plus"
@click="addWeight"
></el-button>
</el-form-item>
</el-col>
<el-col
:md="12"
:sm="24"
v-for="(item, ind) in weight_kgs"
:key="item"
style="position: relative"
>
<el-form-item :label-width="50">
<el-input-number
v-model="item.value"
:min="0"
style="width: 90%"
controls-position="right"
@change="countSun"
/>
</el-form-item>
<el-button
@click="delWeight(ind)"
type="danger"
icon="el-icon-delete"
circle
style="position: absolute; right: -10px; top: 0"
/>
</el-col>
</el-row>
</el-form>
</el-main>
<el-footer v-if="mode == 'add'">
<el-button type="primary" :loading="isSaveing" @click="submit"
>提交</el-button
>
<el-button @click="visible = false">取消</el-button>
</el-footer>
</el-container>
</el-dialog>
<el-drawer
v-model="visibleDrawer"
title="检验"
:size="'90%'"
destroy-on-close
@closed="$emit('closed')"
>
<el-container v-loading="loading">
<el-header>
<el-form
ref="dialogForm"
:model="formbw"
:rules="rules"
label-width="80px"
style="width: 100%;"
>
<el-row>
<el-col :md="12" :sm="12">
<el-form-item label="检验员" prop="test_user">
<el-select
v-model="formbw.test_user"
placeholder="检验员"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="item in userList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :md="12" :sm="12">
<el-form-item label="检验时间" prop="test_date">
<el-date-picker
v-model="formbw.test_date"
type="date"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-header>
<el-main style="padding: 0 20px 20px 20px" id="mioitemwMain">
<scTable :tableHeight="tableHeight" :data="mioitemwList" row-key="id" border hideDo hidePagination>
<el-table-column label="物料编号" prop="number" min-width="170px" fixed="left">
</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"
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]"
:disabled="!scope.row.isEdit"
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"
@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"
@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"
@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"
v-model="scope.row[item.defect_name]"
style="--el-switch-on-color: red"
></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="操作" fixed="right" width="90">
<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-else
type="primary"
size="small"
@click="formTableEdit(scope.row)"
>检验</el-link
>
</template>
</el-table-column>
</scTable>
</el-main>
</el-container>
</el-drawer>
</template>
<script>
export default {
emits: ["success", "closed"],
props: {
mioitemId: { type: String, default: "" },
type: { type: String, default: "" },
cate: { type: String, default: "" },
objitem: { type: Object, default: () => {} },
},
data() {
return {
tableHeight:500,
tableData:[],
loading: false,
form: {
weight_kgs: [],
ftestitems: [],
},
rules: {
test_date: [
{
required: true,
message: "请选择检验日期",
trigger: "blur",
},
],
test_time: [
{
required: true,
message: "请选择检验时间",
trigger: "blur",
},
],
test_user: [
{
required: true,
message: "请选择检验人",
trigger: "blur",
},
],
},
formbw:{
test_date:'',
test_user:'',
},
project_code: null,
mioItem: {},
weight_kgs: [{ value: 0 }],
visible: false,
visibleDrawer:false,
isSaveing: false,
userList: [],
qct_defects:[],
qct_testitems:[],
processOptions: [],
deptOptions: [],
selectionFilters: [],
setFiltersVisible: false,
belong_dept_options: [],
group: [],
mioitemwList:[],
qctId:'',
mioitemwId:'',
};
},
mounted() {
let that = this;
let date = new Date();
let config_base = that.$TOOL.data.get("BASE_INFO").base;
that.form.test_date = that.$TOOL.dateFormat2(date, "yyyy-MM-dd");
that.project_code = config_base.base_code;
console.log("that.form.test_date", that.form.test_date);
setTimeout(() => {
this.tableHeight = document.getElementById('mioitemwMain').clientHeight-20;
},500)
that.getUserList();
if(that.project_code=='bxerp'){
that.mioitemwId = that.objitem.mioitemw[0].id;
this.getMioitemw();
}else{
if (that.type == "pur_in") {
console.log("objitem", that.objitem);
that.form.material_name = that.objitem.material_name;
that.form.batch = that.objitem.batch;
that.form.count = that.objitem.count;
that.form.count_ok = that.objitem.count;
that.form.count_bag = that.objitem.count_bag;
if(that.project_code=='gx'){
that.form.count_n_zw = 0;//直径
that.form.count_n_zz = 0;//亮面
that.form.count_n_b = 0;//崩面
that.form.count_n_dl = 0;//长度
}
}
if (
(that.type == "do_in" && that.cate == "halfgood") ||
that.type == "other_in"
) {
this.form.count_notok = 0;
this.form.count_n_zw = 0;
this.form.count_n_tw = 0;
this.form.count_n_qp = 0;
this.form.count_n_wq = 0;
this.form.count_n_dl = 0;
this.form.count_n_pb = 0;
this.form.count_n_dxt = 0;
this.form.count_n_js = 0;
this.form.count_n_qx = 0;
this.form.count_n_hs = 0;
this.form.count_n_ysq = 0;
this.form.count_n_zz = 0;
this.form.count_n_b = 0;
this.form.count_n_qt = 0;
}
if (that.type == "do_in" && that.cate == "good") {
this.form.count_notok = 0;
this.form.count_n_hs = 0;
this.form.count_n_cs = 0;
this.form.count_n_zz = 0;
this.form.count_n_tw = 0;
this.form.count_n_d = 0;
this.form.count_n_zdd = 0;
this.form.count_n_zw = 0;
this.form.count_n_dl = 0;
//棒
this.form.count_n_qp = 0;
this.form.count_n_bl = 0;
this.form.count_n_hw = 0;
this.form.count_n_yp = 0;
this.form.count_n_bp = 0;
this.form.count_n_sc = 0;
//管
this.form.count_n_qx = 0;
this.form.count_n_js = 0;
this.form.count_n_tydd = 0;
this.form.count_n_sw = 0;
this.form.count_n_bhpcd = 0;
this.form.count_n_wq = 0;
}
}
},
watch: {
qct_testitems: {
handler() {
// 初始化表单字段,确保每个字段都有默认值
this.qct_testitems.forEach(item => {
if (!(item.testitem_name in this.form)) {
this.form[item.testitem_name] = null;
}
});
},
immediate: true
},
qct_defects: {
handler() {
this.qct_defects.forEach(item => {
if (!(item.defect_name in this.form)) {
this.form[item.defect_name] = false;
}
});
},
immediate: true
}
},
methods: {
//显示
open(mode = "add") {
this.mode = mode;
let config_base = this.$TOOL.data.get("BASE_INFO").base.base_code;
if(config_base=='bxerp'){
this.getQctDetail();
this.visibleDrawer = true;
}else{
this.visible = true;
}
return this;
},
gxPurInCountChange(){
this.form.count_ok = this.form.count - this.form.count_notok;
},
nqtChange(){
this.form.count_notok = this.form.count_n_zw+this.form.count_n_zz+this.form.count_n_b+this.form.count_n_dl;
this.form.count_ok = this.form.count - this.form.count_notok;
},
getMaterialItem(){
let that = this;
that.$API.mtm.material.item.req(that.objitem.material).then(()=>{
})
},
getdefects(){
let that = this;
if(that.qct!==null&&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;
})
that.qct_defects = res.qct_defects;
that.qct_testitems = [];
res.qct_testitems.forEach((item2) => {
let obj2 = Object.assign({}, item2);
obj2.value = null;
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.getList();
})
}else{
that.getList();
}
},
//根据物料关联的检测表获取检测项和不合格项
getQctDetail(){
let that = this;
that.$API.qm.qct.list.req({ qctmat__material: that.objitem.material,page:0 }).then((res) => {
if(res.length>0){
that.qctId = res[0].id;
that.$API.qm.qct.item.req(that.qctId).then((res0) => {
//这里可以得到testitem和defectitem
that.qct_defects = [];
that.qct_testitems = [];
if(res0.qct_defects.length>0){
res0.qct_defects.forEach((item1) => {
let obj = Object.assign({}, item1);
obj.value = false;
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 = null;
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 = [];
}
})
}
});
},
defectCountSun(row){
let that = this;
that.qct_defects.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;
}else{
row[item.defect_name] = false;
}
});
},
getMioitemw(){
let that = this;
that.$API.inm.mioitemw.list.req({ mioitem: that.mioitemId,page:0 }).then((res) => {
that.mioitemwList = res;
if(res.length>0){
that.mioitemwList = [];
res.forEach((item) => {
let obj = {};
obj = Object.assign({},item);
obj.isEdit = false;
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.mioitemwList.push(obj);
})
}
});
},
//获取员工
getUserList() {
let that = this;
this.$API.system.user.list
.req({ page: 0, posts__code__contains: "check" })
.then((res) => {
that.userList = res;
});
},
addWeight() {
this.weight_kgs.push({ value: 0 });
this.form.count_sampling = this.weight_kgs.length;
},
delWeight(index) {
this.weight_kgs.splice(index, 1);
this.form.count_sampling = this.weight_kgs.length;
},
countSun() {
let that = this;
let sum = 0;
console.log("change");
that.weight_kgs.forEach((item) => {
sum = sum + item.value;
});
that.form.count_bag_weight_all =
(sum / that.weight_kgs.length) * that.form.count_bag;
},
countChange() {},
countNotOkSun() {
let that = this;
if (
(that.type == "do_in" && that.cate == "halfgood") ||
that.type == "other_in"
) {
this.form.count_notok =
this.form.count_n_zw +
this.form.count_n_tw +
this.form.count_n_qp +
this.form.count_n_wq +
this.form.count_n_dl +
this.form.count_n_pb +
this.form.count_n_dxt +
this.form.count_n_js +
this.form.count_n_qx +
this.form.count_n_hs +
this.form.count_n_ysq +
this.form.count_n_zz +
this.form.count_n_b +
this.form.count_n_qt;
}
if (that.type == "do_in" && that.cate == "good") {
this.form.count_notok =
this.form.count_n_hs +
this.form.count_n_cs +
this.form.count_n_zz +
this.form.count_n_tw +
this.form.count_n_d +
this.form.count_n_zdd +
this.form.count_n_zw +
this.form.count_n_dl +
//棒
this.form.count_n_qp +
this.form.count_n_bl +
this.form.count_n_hw +
this.form.count_n_yp +
this.form.count_n_bp +
this.form.count_n_sc +
//管
this.form.count_n_qx +
this.form.count_n_js +
this.form.count_n_tydd +
this.form.count_n_sw +
this.form.count_n_bhpcd +
this.form.count_n_wq;
}
},
//提交
submit() {
let that = this;
if (
(that.type == "do_in" && that.cate == "halfgood") ||
that.type == "other_in"
) {
this.form.count_notok =
this.form.count_n_zw +
this.form.count_n_tw +
this.form.count_n_qp +
this.form.count_n_wq +
this.form.count_n_dl +
this.form.count_n_pb +
this.form.count_n_dxt +
this.form.count_n_js +
this.form.count_n_qx +
this.form.count_n_hs +
this.form.count_n_ysq +
this.form.count_n_zz +
this.form.count_n_b +
this.form.count_n_qt;
}
if (that.type == "do_in" && that.cate == "good") {
this.form.count_notok =
this.form.count_n_hs +
this.form.count_n_cs +
this.form.count_n_zz +
this.form.count_n_tw +
this.form.count_n_d +
this.form.count_n_zdd +
this.form.count_n_zw +
this.form.count_n_dl +
//棒
this.form.count_n_qp +
this.form.count_n_bl +
this.form.count_n_hw +
this.form.count_n_yp +
this.form.count_n_bp +
this.form.count_n_sc +
//管
this.form.count_n_qx +
this.form.count_n_js +
this.form.count_n_tydd +
this.form.count_n_sw +
this.form.count_n_bhpcd +
this.form.count_n_wq;
}
that.$refs.dialogForm.validate(async (valid) => {
if (valid) {
that.isSaveing = true;
try {
if (that.type == "pur_in"&&that.project_code!="gx") {
console.log(that.form);
let arr = [];
if(that.weight_kgs.length>0){
that.weight_kgs.forEach((item) => {
arr.push(item.value);
});
that.form.weight_kgs = arr;
}
console.log('that.form',that.form);
that.$API.inm.mioitem.testpurin
.req(that.mioitemId, that.form)
.then((res) => {
that.isSaveing = false;
that.$emit("success");
that.visible = false;
that.$message.success("操作成功");
});
} else {
that.$API.inm.mioitem.test.req(that.mioitemId, that.form).then((res) => {
that.isSaveing = false;
that.$emit("success");
that.visible = false;
that.$message.success("操作成功");
});
}
} catch (err) {
//可以处理校验错误
this.isSaveing = false;
return err;
}
}
});
},
//表单注入数据
setData(data) {
let that = this;
Object.assign(that.form, data);
// that.form.test_group = that.form.split(',');
that.weight_kgs = [];
if (data.weight_kgs.length > 0) {
that.form.count_sampling = data.weight_kgs.length;
let sum = 0;
data.weight_kgs.forEach((item) => {
sum = sum + item;
let obj = {};
obj.value = item;
that.weight_kgs.push(obj);
});
that.form.count_bag_weight_all =
(sum / data.weight_kgs.length) * data.count_bag;
}
},
//设置过滤项
setFilters(filters) {
this.selectionFilters = filters;
this.setFiltersVisible = true;
},
//添加
formTableSave(row) {
let that = this;
this.$refs.dialogForm.validate(async (valid) => {
if (valid) {
let ftestdefects = [],ftestitems = [];
let obj = {};
that.qct_testitems.forEach((item) => {
console.log('row[item.testitem_name]',row[item.testitem_name]);
if(row[item.testitem_name]!==''&&row[item.testitem_name]!==null){
let obj0 = {};
obj0.testitem = item.testitem;
obj0.test_user = that.formbw.test_user;
obj0.test_date = that.formbw.test_date;
obj0.testitem_name = item.testitem_name;
obj0.test_val_json = row[item.testitem_name]?row[item.testitem_name]:null;
ftestitems.push(obj0);
}
})
that.qct_defects.forEach((item1) => {
if(row[item1.defect_name]!==''&&row[item1.defect_name]!==null){
let obj1 = {};
obj1.defect = item1.defect;
obj1.test_user = that.formbw.test_user;
obj1.defect_name = item1.defect_name;
obj1.test_date = that.formbw.test_date;
obj1.has = row[item1.defect_name]?row[item1.defect_name]:false;
ftestdefects.push(obj1);
}
})
obj.note = row.note;
obj.number = row.number;
obj.mioitem = row.mioitem;
obj.ftest = {};
obj.ftest.qct = row.ftest?row.ftest.qct:that.qctId;
obj.ftest.test_user = that.formbw.test_user;
obj.ftest.test_date = that.formbw.test_date;
obj.ftest.ftestitems = ftestitems;
obj.ftest.ftestdefects = ftestdefects;
that.isSaveing = true;
console.log('row.id',row.id);
that.$API.inm.mioitemw.update.req(row.id,obj).then((res) => {
that.isSaveing = false;
that.getMioitemw();
that.$message.success("操作成功");
}).catch((err) => {
that.isSaveing = false;
})
}
})
},
formTableCancel(row){
let that = this;
that.mioitemwList.forEach((item, index) => {
if (item.id == row.id) {
that.mioitemwList[index].isEdit = false;
}
});
},
formTableEdit(row) {
let that = this;
that.mioitemwList.forEach((item, index) => {
if (item.id == row.id) {
that.mioitemwList[index].isEdit = true;
}
});
},
},
};
</script>
<style>
.width-100{
width: 100%;
}
</style>