Files
wuHanXinRui/mes/qd/src/views/wms/pf/initformula/DivDialog.vue
2022-07-03 18:07:05 +08:00

1126 lines
46 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-dialog
append-to-body
:visible.sync="dialogVisible"
v-loading.fullscreen.lock="fullscreenLoading"
destroy-on-close
:show-close="false"
fullscreen
@close="close"
@open="open"
>
<span slot="title" class="dialog-footer">
<div class="crud-opts2">
<span class="el-dialog__title2">手工开单</span>
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button slot="left" type="info" @click="dialogVisible = false">关闭</el-button>
<el-button slot="left" type="warning" @click="save">保存</el-button>
<el-button slot="left" type="primary" @click="submit">确认</el-button>
</span>
</div>
</span>
<el-form ref="form" style="border: 1px solid #cfe0df;margin-top: 10px;padding-top: 10px;" :inline="true" :model="form" :rules="rules" size="mini" label-width="105px" label-suffix=":">
<el-form-item label="工令号" prop="workorder_code">
<label slot="label">&nbsp;&nbsp;&nbsp;:</label>
<el-input v-model="form.workorder_code" disabled style="width: 210px" />
</el-form-item>
<el-form-item label="产品" prop="material_code">
<label slot="label">产品:</label>
<el-input v-model="form.material_code" disabled style="width: 210px" />
</el-form-item>
<el-form-item label="批次" prop="pcsn">
<label slot="label">批次:</label>
<el-input v-model="form.pcsn" style="width: 210px" disabled />
</el-form-item>
<el-form-item label="总重量" prop="workorder_qty">
<label slot="label">&nbsp;&nbsp;&nbsp;:</label>
<el-input-number
v-model="form.workorder_qty"
:controls="false"
:precision="3"
:min="1"
disabled
style="width: 210px"
/>
</el-form-item>
<el-form-item label="碳平衡" prop="c_balance">
<label slot="label">碳平衡:</label>
<el-input-number
v-model="form.c_balance"
:controls="false"
:precision="3"
:min="1"
disabled
style="width: 210px"
/>
</el-form-item>
<el-form-item label="配粉模式" prop="formula_type">
<el-select
v-model="form.formula_type"
placeholder="配粉模式"
style="width: 210px"
class="filter-item"
@change="storChange"
>
<el-option
v-for="item in dict.formula_type"
:key="item.id"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="是否二次投料" prop="is_again_put">
<el-select
v-model="form.is_again_put"
style="width: 210px"
placeholder="是否二次投料"
class="filter-item"
@change="storChange2"
>
<el-option
v-for="item in dict.is_again_put"
:key="item.id"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="软废含量%" prop="total_qty">
<label slot="label">软废含量%:</label>
<el-input-number
v-model="form.waste_limit_down"
:controls="false"
:precision="0"
:min="0"
:max="form.waste_limit_up"
style="width:80px"
/>
----
<el-input-number
v-model="form.waste_limit_up"
:controls="false"
:precision="0"
:min="form.waste_limit_down"
:max="100"
style="width: 80px"
/>
</el-form-item>
</el-form>
<div class="crud-opts2">
<span class="role-span">主桶</span>
<div class="crud-opts-form">
<el-form ref="form" :inline="true" :model="form2" size="mini">
<el-form-item label="主桶重量" prop="total_qty1">
<el-input-number
v-model="form2.total_qty1"
:controls="false"
:precision="3"
:min="0"
disabled
/>
</el-form-item>
<el-form-item label="添加辅料重量" prop="add_qty1">
<el-input-number
v-model="form2.add_qty1"
:controls="false"
:precision="3"
:min="0"
disabled
/>
</el-form-item>
</el-form>
</div>
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button
slot="left"
class="filter-item"
type="warning"
icon="el-icon-plus"
size="mini"
:disabled="button2"
@click="autoCalculation"
>
自动计算
</el-button>
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
:disabled="button1"
@click="allCancel()"
>
添加新料
</el-button>
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
:disabled="button1"
@click="allCancel2('1')"
>
添加软废
</el-button>
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
:disabled="button1"
@click="openYzj"
>
添加抑制剂
</el-button>
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
:disabled="button1"
@click="openStructIvt"
>
添加分类
</el-button>
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
:disabled="button1"
@click="openCxj"
>
添加成型剂
</el-button>
</span>
</div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}">
<!--表格渲染-->
<el-table
ref="table"
:data="tableDtl"
style="width: 100%;"
max-height="400"
size="mini"
border
:highlight-current-row="true"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="bucket_type" label="桶类型" align="center" width="60px" :formatter="bucket_typeFormat" />
<el-table-column prop="material_code" label="物料编码" align="center" width="150px" />
<el-table-column prop="material_name" label="物料名称" align="center" width="150px" />
<el-table-column prop="material_type" label="物料类别" align="center" :formatter="material_typeFormat" />
<!-- <el-table-column prop="seqno" label="顺序号" align="center" width="150px" />-->
<el-table-column prop="pcsn" label="批次号" align="center" width="70px"/>
<el-table-column prop="quality_scode" label="品质类型" align="center" width="70px" :formatter="quality_scodeFormat" />
<el-table-column prop="ivt_level" label="库存等级" align="center" width="70px" :formatter="ivt_levelFormat" />
<el-table-column prop="is_active" label="是否可用" align="center" width="70px" :formatter="is_activeFormat" />
<el-table-column prop="formula_qty" label="重量(KG)" :formatter="crud.formatNum3" width="150" align="center">
<template scope="scope">
<el-input-number size="mini" v-model="scope.row.formula_qty" :disabled="scope.row.edit" :precision="3" :controls="false" :min="0" :max="is_rf_xl(scope.row)" style="width: 120px" />
</template>
</el-table-column>
<el-table-column min-width="130" prop="need_sum_qty" label="需配重量(KG)" :formatter="crud.formatNum3" align="center" />
<el-table-column min-width="130" prop="sum_ivt_qty" label="库存重量(KG)" :formatter="crud.formatNum3" align="center" />
<el-table-column prop="is_need_manage" label="是否配粉" align="center" width="100px" :formatter="is_need_manageFormat" />
<el-table-column prop="is_need_move" label="是否需移库" align="center" width="100px" :formatter="is_need_moveFormat" />
<el-table-column prop="is_tan" label="碳%" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_09030102" label="钴%" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ001" label="石蜡" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ002" label="G3蜡" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ003" label="PEG2000" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ004" label="PVAC" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ005" label="SBP" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ006" label="白油" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ007" label="油酸" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ008" label="8号分散剂" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column align="center" label="操作" width="160" fixed="right">
<template scope="scope">
<el-button :disabled="!button2" type="danger" class="filter-item" size="mini" icon="el-icon-delete" @click.native.prevent="deleteRow(scope.$index,tableDtl)" />
<el-button v-show="!scope.row.edit" :disabled="!button2" type="primary" class="filter-item" size="mini" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button v-show="scope.row.edit" :disabled="!button2" type="success" class="filter-item" size="mini" icon="el-icon-check" @click="handleEdit(scope.$index, scope.row)">完成</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<div class="crud-opts2">
<span class="role-span">副桶</span>
<div class="crud-opts-form">
<el-form ref="form2" :inline="true" :model="form2" size="mini">
<el-form-item label="副桶重量" prop="total_qty2">
<el-input-number
v-model="form2.total_qty2"
:controls="false"
:precision="3"
:min="0"
disabled
/>
</el-form-item>
<!-- <el-form-item label="添加物料重量" prop="add_qty2">
<el-input-number
v-model="form2.add_qty2"
:controls="false"
:precision="3"
:min="0"
disabled
/>
</el-form-item>-->
</el-form>
</div>
<span class="crud-opts-right2">
<!--左侧插槽-->
<slot name="left" />
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-check"
size="mini"
:disabled="button3"
@click="allCancel2('2')"
>
添加软废
</el-button>
</span>
</div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}">
<!--表格渲染-->
<el-table
ref="table2"
:data="tabledis"
style="width: 100%;"
max-height="400"
border
size="mini"
:highlight-current-row="true"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
>
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="bucket_type" label="桶类型" align="center" width="110px" :formatter="bucket_typeFormat" />
<el-table-column min-width="130" show-overflow-tooltip prop="material_code" label="物料编码" align="center" />
<el-table-column min-width="130" show-overflow-tooltip prop="material_name" label="物料名称" align="center" />
<el-table-column prop="material_type" label="物料类别" align="center" :formatter="material_typeFormat" />
<el-table-column prop="pcsn" label="批次号" align="center" width="70px" />
<el-table-column prop="quality_scode" label="品质类型" align="center" width="70px" :formatter="quality_scodeFormat" />
<el-table-column prop="ivt_level" label="库存等级" align="center" width="70px" :formatter="ivt_levelFormat" />
<el-table-column prop="is_active" label="是否可用" align="center" width="70px" :formatter="is_activeFormat" />
<el-table-column prop="formula_qty" label="重量(KG)" :formatter="crud.formatNum3" width="150" align="center">
<template scope="scope">
<el-input-number v-model="scope.row.formula_qty" :disabled="scope.row.edit" :precision="3" :controls="false" :min="0" :max="is_rf_xl(scope.row)" style="width: 120px" />
</template>
</el-table-column>
<el-table-column min-width="130" prop="sum_ivt_qty" label="库存重量(KG)" :formatter="crud.formatNum3" align="center" />
<el-table-column prop="is_need_manage" label="是否配粉" align="center" width="100px" :formatter="is_need_manageFormat" />
<el-table-column prop="is_need_move" label="是否需移库" align="center" width="100px" :formatter="is_need_moveFormat" />
<el-table-column prop="is_tan" label="碳%" align="center" width="100px" :formatter="crud.formatQlNum4" />
<el-table-column prop="is_09030102" label="钴%" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ001" label="石蜡" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ002" label="G3蜡" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ003" label="PEG2000" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ004" label="PVAC" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ005" label="SBP" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ006" label="白油" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ007" label="油酸" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column prop="is_CXJ008" label="8号分散剂" align="center" width="100px" :formatter="crud.formatQlNum4"/>
<el-table-column align="center" label="操作" width="160" fixed="right">
<template scope="scope">
<el-button :disabled="!button2" type="danger" class="filter-item" size="mini" icon="el-icon-delete" @click.native.prevent="deleteRow2(scope.$index,tabledis)" />
<el-button v-show="!scope.row.edit" :disabled="!button2" type="primary" class="filter-item" size="mini" icon="el-icon-edit" @click="handleEdit2(scope.$index, scope.row)">编辑</el-button>
<el-button v-show="scope.row.edit" :disabled="!button2" type="success" class="filter-item" size="mini" icon="el-icon-check" @click="handleEdit2(scope.$index, scope.row)">完成</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<StructIvt :dialog-show.sync="structshow" :rowmst="form" @StructIvtClosed="queryTableDtl" />
<StructIvt2 :dialog-show.sync="structshow2" :rowmst="form" @StructIvtClosed="queryTableDtl2" />
<StructIvt3 :dialog-show.sync="structshow4" :rowmst="form" @StructIvtClosed="queryTableDtl4" />
<StructIvt4 :dialog-show.sync="structshow5" :rowmst="form" @StructIvtClosed="queryTableDtl5" />
<materTypeDialog :dialog-show.sync="structshow3" @StructIvtClosed="queryTableDtl3" />
</el-dialog>
</template>
<script>
import CRUD, { crud } from '@crud/crud'
import StructIvt from '@/views/wms/pf/initformula/StructIvt'
import StructIvt2 from '@/views/wms/pf/initformula/StructIvt2'
import StructIvt3 from '@/views/wms/pf/initformula/StructIvt3'
import StructIvt4 from '@/views/wms/pf/initformula/StructIvt4'
import materTypeDialog from '@/views/wms/pf/initformula/materTypeDialog'
import initformula from '@/api/wms/pf/initformula'
import autoformula from '@/api/wms/pf/autoformula'
export default {
name: 'DivDialog',
components: { StructIvt, StructIvt2, StructIvt3, StructIvt4, materTypeDialog },
mixins: [crud()],
dicts: ['material_type', 'formula_type', 'ST_QUALITY_SCODE', 'ST_IVT_LEVEL', 'is_used', 'is_again_put', 'is_usable', 'bucket_type'],
props: {
dialogShow: {
type: Boolean,
default: false
},
rowmst: {
type: Object
}
},
data() {
return {
dialogVisible: false,
fullscreenLoading: false,
structshow: false,
structshow2: false,
structshow3: false,
structshow4: false,
structshow5: false,
struct2type: '',
button1: true,
button2: true,
button3: true,
tableDtl: [],
mstrow: {},
tabledis: [],
form: { waste_limit_down:0, waste_limit_uo:0},
form2: {
total_qty1: '0',
add_qty1: '0',
total_qty2: '0',
add_qty2: '0'
},
rules: {
}
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
},
rowmst: {
handler(newValue, oldValue) {
this.mstrow = newValue
}
}
},
methods: {
open() {
initformula.getform({ 'material_id': this.mstrow.material_id, 'workorder_id': this.mstrow.workorder_id }).then(res => {
this.form = res.material
this.form.material_code = this.mstrow.material_code
this.form.workorder_qty = this.mstrow.workorder_qty
if (this.form.formula_type === '00') {
this.button1 = false
this.button2 = true
} else {
this.button1 = true
this.button2 = false
}
if (this.form.is_again_put === '1' && this.form.formula_type === '00') {
this.button3 = false
} else {
this.button3 = true
}
this.tableDtl = res.tableDtl
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
for (let i = 0; i < this.tableDtl.length; i++) {
const row = this.tableDtl[i]
row.edit = true
if (row.is_need_manage === '1') {
this.form2.total_qty1 = this.form2.total_qty1 + parseFloat(row.formula_qty)
} else {
this.form2.add_qty1 = this.form2.add_qty1 + parseFloat(row.formula_qty)
}
this.tableDtl.splice(i, 1, row)
}
this.tabledis = res.tabledis
this.form2.total_qty2 = 0
this.form2.add_qty2 = 0
for (let i = 0; i < this.tabledis.length; i++) {
const row = this.tabledis[i]
row.edit = true
if (row.is_need_manage === '1') {
this.form2.total_qty2 = this.form2.total_qty2 + parseFloat(row.formula_qty)
} else {
this.form2.add_qty2 = this.form2.add_qty2 + parseFloat(row.formula_qty)
}
this.tabledis.splice(i, 1, row)
}
})
},
close() {
this.$refs['form2'].resetFields()
this.$refs['form'].resetFields()
this.tableDtl = []
this.tabledis = []
this.$emit('DivChanged')
this.$emit('update:dialogShow', false)
},
bucket_typeFormat(row, column) {
return this.dict.label.bucket_type[row.bucket_type]
},
quality_scodeFormat(row, column) {
return this.dict.label.ST_QUALITY_SCODE[row.quality_scode]
},
ivt_levelFormat(row, column) {
return this.dict.label.ST_IVT_LEVEL[row.ivt_level]
},
is_activeFormat(row, column) {
return this.dict.label.is_usable[row.is_active]
},
material_typeFormat(row, column) {
return this.dict.label.material_type[row.material_type]
},
is_need_moveFormat(row, column) {
if (row.is_need_move === '') {
return '否'
} else {
return this.dict.label.is_again_put[row.is_need_move]
}
},
is_rf_xl(row){
let maxNum = 9999999999.0
if(row.is_rf_xl === '1'){
return parseFloat(row.sum_ivt_qty).toFixed(3)
}else{
return parseFloat(maxNum).toFixed(3)
}
},
is_need_manageFormat(row, column) {
return this.dict.label.is_again_put[row.is_need_manage]
},
openStructIvt() {
this.structshow3 = true
},
openCxj() {
this.structshow4 = true
},
openYzj() {
this.structshow5 = true
},
deleteRow(index, rows) {
this.$confirm('是否删除?')
.then(_ => {
rows.splice(index, 1)
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
this.tableDtl.forEach((item) => {
if (item.is_need_manage === '1') {
this.form2.total_qty1 = this.form2.total_qty1 + item.formula_qty
} else {
this.form2.add_qty1 = this.form2.add_qty1 + item.formula_qty
}
})
})
.catch(_ => {
})
},
deleteRow2(index, rows) {
this.$confirm('是否删除?')
.then(_ => {
rows.splice(index, 1)
this.form2.total_qty2 = 0
this.form2.add_qty2 = 0
this.tabledis.forEach((item) => {
if (item.is_need_manage === '1') {
this.form2.total_qty2 = this.form2.total_qty2 + item.formula_qty
} else {
this.form2.add_qty2 = this.form2.add_qty2 + item.formula_qty
}
})
})
.catch(_ => {
})
},
storChange(row) {
if (row === '00') {
this.$confirm('是否清空列表?','',{showClose:false})
.then(_ => {
this.button1 = false
this.button2 = true
this.tableDtl = []
this.tabledis = []
this.form2.total_qty2 = 0
this.form2.add_qty2 = 0
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
})
.catch(_ => {
this.button1 = false
this.button2 = true
})
} else {
this.button1 = true
this.button2 = false
this.tableDtl = []
this.tabledis = []
this.form2.total_qty2 = 0
this.form2.add_qty2 = 0
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
}
if (this.form.is_again_put === '1' && row === '00') {
this.button3 = false
} else {
this.button3 = true
}
},
storChange2(row) {
if (this.form.is_again_put === '1' && this.form.formula_type === '00') {
this.button3 = false
} else {
this.button3 = true
}
},
allCancel() {
this.structshow = true
},
allCancel2(type) {
this.struct2type = type
this.structshow2 = true
},
handleEdit(index, row) {
if (row.formula_qty === 0) {
this.crud.notify('重量不能为0')
return false
}
row.edit = !row.edit
this.tableDtl.splice(index, 1, row) // 通过splice 替换数据 触发视图更新
if (row.edit) {
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
this.tableDtl.forEach((item) => {
if (item.is_need_manage === '1') {
this.form2.total_qty1 = this.form2.total_qty1 + item.formula_qty
} else {
this.form2.add_qty1 = this.form2.add_qty1 + item.formula_qty
}
})
}
},
handleEdit2(index, row) {
if (row.formula_qty === 0) {
this.crud.notify('重量不能为0')
return false
}
row.edit = !row.edit
this.tabledis.splice(index, 1, row) // 通过splice 替换数据 触发视图更新
if (row.edit) {
this.form2.total_qty2 = 0
this.form2.add_qty2 = 0
this.tabledis.forEach((item) => {
if (item.is_need_manage === '1') {
this.form2.total_qty2 = this.form2.total_qty2 + item.formula_qty
} else {
this.form2.add_qty2 = this.form2.add_qty2 + item.formula_qty
}
})
}
},
queryTableDtl3(rows) {
const tablemap = new Map()
rows.forEach((item) => {
if (this.tableDtl.length !== 0) {
this.flagnow = false
for (let i = 0; i < this.tableDtl.length; i++) {
// ----就物料、批次、品质类型、等级、是否可用
if (this.tableDtl[i].material_id === item.class_id) {
this.flagnow = true
}
}
if (!this.flagnow) {
const row = { edit: false, is_rf_xl: '0', bucket_type: '01', material_type: '02', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '01', ivt_level: '01', is_active: '1', formula_qty: '0', sum_ivt_qty: '0', is_need_move: '0', is_need_manage: '1', is_tan: '', is_09030102: '', qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.class_id
if(row.material_id==='1503644362788179968'){
row.is_tan = '100.0'
}else if(row.material_id==='1503644362192588800'){
row.is_09030102 = '100.0'
}
row.material_code = item.class_code
row.material_name = item.class_name
tablemap.set(item.class_id, row)
}
} else {
const row = { edit: false, is_rf_xl: '0', bucket_type: '01', material_type: '02', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '01', ivt_level: '01', is_active: '1', formula_qty: '0', sum_ivt_qty: '0', is_need_move: '0', is_need_manage: '1', is_tan: '', is_09030102: '', qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.class_id
row.material_code = item.class_code
row.material_name = item.class_name
if(row.material_id==='1503644362788179968'){
row.is_tan = '100.0'
}else if(row.material_id==='1503644362192588800'){
row.is_09030102 = '100.0'
}
tablemap.set(item.class_id, row)
}
})
for (const value of tablemap.values()) {
this.tableDtl.push(value)
}
},
queryTableDtl2(rows) {
if (this.struct2type === '1') {
this.queryTableDtl(rows)
} else {
const tablemap = new Map()
rows.forEach((item) => {
if (this.tabledis.length !== 0) {
this.flagnow = false
for (let i = 0; i < this.tabledis.length; i++) {
// ----就物料、批次、品质类型、等级、是否可用
if (this.tableDtl[i].material_id === item.material_id
&& this.tableDtl[i].pcsn === item.pcsn
&& this.tableDtl[i].is_active === item.is_active
&& this.tableDtl[i].ivt_level === item.ivt_level
&& this.tableDtl[i].quality_scode === item.quality_scode ) {
this.flagnow = true
}
}
if (!this.flagnow) {
const row = { edit: false, is_rf_xl: '1', bucket_type: '02', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '', ivt_level: '', is_active: '', formula_qty: '0', sum_ivt_qty: '', is_need_move: '', is_need_manage: '1', is_tan: '', is_09030102: '', is_CXJ001: '',
is_CXJ003: '',is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.material_id
row.quality_scode = item.quality_scode
row.pcsn = item.pcsn
row.material_name = item.material_name
row.material_code = item.material_code
row.ivt_level = item.ivt_level
row.is_active = item.is_active
row.sum_ivt_qty = item.sum_ivt_qty
row.is_need_move = item.is_need_move
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_tan = item.is_tan
row.is_09030102 = item.is_09030102
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id+"--"+item.quality_scode+"--"+item.pcsn+"--"+item.is_active+"--"+item.ivt_level, row)
}
} else {
const row = { edit: false, is_rf_xl: '1', bucket_type: '02', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '', ivt_level: '', is_active: '', formula_qty: '0', sum_ivt_qty: '', is_need_move: '', is_need_manage: '1', is_tan: '', is_09030102: '', is_CXJ001: '',
is_CXJ003: '',is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.material_id
row.quality_scode = item.quality_scode
row.pcsn = item.pcsn
row.material_name = item.material_name
row.material_code = item.material_code
row.ivt_level = item.ivt_level
row.is_active = item.is_active
row.sum_ivt_qty = item.sum_ivt_qty
row.is_need_move = item.is_need_move
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_tan = item.is_tan
row.is_09030102 = item.is_09030102
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id+"--"+item.quality_scode+"--"+item.pcsn+"--"+item.is_active+"--"+item.ivt_level, row)
}
})
for (const value of tablemap.values()) {
this.tabledis.push(value)
}
}
},
queryTableDtl4(rows) {
debugger
const tablemap = new Map()
rows.forEach((item) => {
if (this.tableDtl.length !== 0) {
this.flagnow = false
for (let i = 0; i < this.tableDtl.length; i++) {
// ----就物料、批次、品质类型、等级、是否可用
if (this.tableDtl[i].material_id === item.material_id) {
this.flagnow = true
}
}
if (!this.flagnow) {
const row = { edit: false, bucket_type: '01',is_rf_xl: '0', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '01', need_sum_qty:'0',ivt_level: '01', is_active: '1', formula_qty: '0', sum_ivt_qty: '', is_need_move: '0', is_need_manage: '1', is_tan: '', is_09030102: '', is_CXJ001: '', is_CXJ003: '',is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.material_id
row.need_sum_qty = item.need_sum_qty
row.formula_qty = item.need_sum_qty
row.is_need_move = item.is_need_move
row.material_name = item.material_name
row.material_code = item.material_code
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id, row)
}
} else {
const row = { edit: false,is_rf_xl: '0', bucket_type: '01', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '01', need_sum_qty:'0', ivt_level: '01', is_active: '1', formula_qty: '0', sum_ivt_qty: '', is_need_move: '0', is_need_manage: '1', is_tan: '', is_09030102: '',is_CXJ001: '', is_CXJ003: '',is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.material_id
row.is_need_move = item.is_need_move
row.need_sum_qty = item.need_sum_qty
row.formula_qty = item.need_sum_qty
row.material_name = item.material_name
row.material_code = item.material_code
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id, row)
}
})
for (const value of tablemap.values()) {
this.tableDtl.push(value)
}
},
queryTableDtl5(rows) {
const tablemap = new Map()
rows.forEach((item) => {
if (this.tableDtl.length !== 0) {
this.flagnow = false
for (let i = 0; i < this.tableDtl.length; i++) {
// ----就物料、批次、品质类型、等级、是否可用
if (this.tableDtl[i].material_id === item.material_id) {
this.flagnow = true
}
}
if (!this.flagnow) {
const row = { edit: false, is_rf_xl: '0', bucket_type: '01', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '01', need_sum_qty:'0',ivt_level: '01', is_active: '1', formula_qty: '0', sum_ivt_qty: '', is_need_move: '0', is_need_manage: '1', is_tan: '', is_09030102: '', is_CXJ001: '', is_CXJ003: '',is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.is_need_move = item.is_need_move
row.is_need_manage = item.is_need_manage
row.need_sum_qty = item.need_sum_qty
row.formula_qty = item.need_sum_qty
row.material_id = item.material_id
row.material_name = item.material_name
row.material_code = item.material_code
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id, row)
}
} else {
const row = { edit: false, is_rf_xl: '0', bucket_type: '01', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '01', need_sum_qty:'0',ivt_level: '01', is_active: '1', formula_qty: '0', sum_ivt_qty: '', is_need_move: '0', is_need_manage: '1', is_tan: '', is_09030102: '',is_CXJ001: '', is_CXJ003: '',is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.material_id
row.is_need_move = item.is_need_move
row.need_sum_qty = item.need_sum_qty
row.formula_qty = item.need_sum_qty
row.is_need_manage = item.is_need_manage
row.material_name = item.material_name
row.material_code = item.material_code
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id, row)
}
})
for (const value of tablemap.values()) {
this.tableDtl.push(value)
}
},
queryTableDtl(rows) {
const tablemap = new Map()
rows.forEach((item) => {
if (this.tableDtl.length !== 0) {
this.flagnow = false
for (let i = 0; i < this.tableDtl.length; i++) {
// ----就物料、批次、品质类型、等级、是否可用
if (this.tableDtl[i].material_id === item.material_id
&& this.tableDtl[i].pcsn === item.pcsn
&& this.tableDtl[i].is_active === item.is_active
&& this.tableDtl[i].ivt_level === item.ivt_level
&& this.tableDtl[i].quality_scode === item.quality_scode ) {
this.flagnow = true
}
}
if (!this.flagnow) {
const row = { edit: false,is_rf_xl: '1', bucket_type: '01', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '', ivt_level: '', is_active: '', formula_qty: '0', sum_ivt_qty: '', is_need_move: '', is_need_manage: '1', is_tan: '', is_09030102: '',
is_CXJ001: '', is_CXJ003: '',need_sum_qty:'0', is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.material_id
row.quality_scode = item.quality_scode
row.pcsn = item.pcsn
row.material_name = item.material_name
row.material_code = item.material_code
row.ivt_level = item.ivt_level
row.is_active = item.is_active
row.sum_ivt_qty = item.sum_ivt_qty
row.need_sum_qty = item.need_sum_qty
row.formula_qty = item.need_sum_qty
row.is_need_move = item.is_need_move
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_tan = item.is_tan
row.is_09030102 = item.is_09030102
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id+"--"+item.quality_scode+"--"+item.pcsn+"--"+item.is_active+"--"+item.ivt_level, row)
}
} else {
const row = { edit: false, is_rf_xl: '1', bucket_type: '01', material_type: '01', material_id: '', material_code: '',
material_name: '', pcsn: '', quality_scode: '', need_sum_qty:'0',ivt_level: '', is_active: '', formula_qty: '0', sum_ivt_qty: '', is_need_move: '', is_need_manage: '1', is_tan: '', is_09030102: '', is_CXJ001: '',
is_CXJ003: '',is_CXJ004: '',is_CXJ005: '',is_CXJ006: '',is_CXJ007: '',is_CXJ008: '',is_CXJ002: '',
qty_unit_id: '', qty_unit_name: '' }
row.material_id = item.material_id
row.quality_scode = item.quality_scode
row.pcsn = item.pcsn
row.material_name = item.material_name
row.material_code = item.material_code
row.ivt_level = item.ivt_level
row.is_active = item.is_active
row.sum_ivt_qty = item.sum_ivt_qty
row.need_sum_qty = item.need_sum_qty
row.formula_qty = item.need_sum_qty
row.is_need_move = item.is_need_move
row.qty_unit_id = item.qty_unit_id
row.qty_unit_name = item.qty_unit_name
row.is_tan = item.is_tan
row.is_09030102 = item.is_09030102
row.is_CXJ001 = item.is_CXJ001
row.is_CXJ003 = item.is_CXJ003
row.is_CXJ004 = item.is_CXJ004
row.is_CXJ005 = item.is_CXJ005
row.is_CXJ006 = item.is_CXJ006
row.is_CXJ007 = item.is_CXJ007
row.is_CXJ008 = item.is_CXJ008
row.is_CXJ002 = item.is_CXJ002
tablemap.set(item.material_id+"--"+item.quality_scode+"--"+item.pcsn+"--"+item.is_active+"--"+item.ivt_level, row)
}
})
for (const value of tablemap.values()) {
this.tableDtl.push(value)
}
},
save() {
if (this.tableDtl.length === 0) {
this.crud.notify('主桶明细不能为空!')
return false
}
if (this.tabledis.length === 0 && this.form.is_again_put ==='1') {
this.$confirm('副桶记录数为0是否继续')
.then(_ => {
for (let i = 0; i < this.tabledis.length; i++) {
if (!this.tabledis[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
for (let i = 0; i < this.tableDtl.length; i++) {
if (!this.tableDtl[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
this.form.tabledis = this.tabledis
this.form.tableDtl = this.tableDtl
initformula.save(this.form).then(res => {
this.crud.notify('操作成功!')
this.$emit('DivChanged')
this.$emit('update:dialogShow', false)
})
})
.catch(_ => {
return false
})
}else{
for (let i = 0; i < this.tabledis.length; i++) {
if (!this.tabledis[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
for (let i = 0; i < this.tableDtl.length; i++) {
if (!this.tableDtl[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
this.form.tabledis = this.tabledis
this.form.tableDtl = this.tableDtl
initformula.save(this.form).then(res => {
this.crud.notify('操作成功!')
this.$emit('DivChanged')
this.$emit('update:dialogShow', false)
})
}
},
autoCalculation() {
this.fullscreenLoading = true
autoformula.autoCalculation(this.form).then(res => {
this.crud.notify('自动计算成功!')
this.tableDtl = res.tableDtl
this.form2.total_qty1 = 0
this.form2.add_qty1 = 0
for (let i = 0; i < this.tableDtl.length; i++) {
const row = this.tableDtl[i]
row.edit = true
if (row.is_need_manage === '1') {
this.form2.total_qty1 = this.form2.total_qty1 + parseFloat(row.formula_qty)
} else {
this.form2.add_qty1 = this.form2.add_qty1 + parseFloat(row.formula_qty)
}
this.tableDtl.splice(i, 1, row)
}
this.tabledis = res.tabledis
this.form2.total_qty2 = 0
this.form2.add_qty2 = 0
for (let i = 0; i < this.tabledis.length; i++) {
const row = this.tabledis[i]
row.edit = true
if (row.is_need_manage === '1') {
this.form2.total_qty2 = this.form2.total_qty2 + parseFloat(row.formula_qty)
} else {
this.form2.add_qty2 = this.form2.add_qty2 + parseFloat(row.formula_qty)
}
this.tabledis.splice(i, 1, row)
}
this.fullscreenLoading = false
}).catch(() => {
this.fullscreenLoading = false
})
},
submit() {
if (this.tableDtl.length === 0) {
this.crud.notify('主桶明细不能为空!')
return false
}
if (this.tabledis.length === 0 && this.form.is_again_put ==='1') {
this.$confirm('副桶记录数为0是否继续')
.then(_ => {
for (let i = 0; i < this.tabledis.length; i++) {
if (!this.tabledis[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
for (let i = 0; i < this.tableDtl.length; i++) {
if (!this.tableDtl[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
this.form.tabledis = this.tabledis
this.form.tableDtl = this.tableDtl
initformula.submit(this.form).then(res => {
this.crud.notify('操作成功!')
this.$emit('DivChanged')
this.$emit('update:dialogShow', false)
})
})
.catch(_ => {
return false
})
}else{
for (let i = 0; i < this.tabledis.length; i++) {
if (!this.tabledis[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
for (let i = 0; i < this.tableDtl.length; i++) {
if (!this.tableDtl[i].edit) {
this.crud.notify('尚有未完成编辑的副桶物料,明细序号为' + (i + 1) + '请检查!')
return false
}
}
this.form.tabledis = this.tabledis
this.form.tableDtl = this.tableDtl
initformula.submit(this.form).then(res => {
this.crud.notify('操作成功!')
this.$emit('DivChanged')
this.$emit('update:dialogShow', false)
})
}
}
}
}
</script>
<style>
.crud-opts2 {
padding: 0;
display: -webkit-flex;
display: flex;
align-items: center;
}
.crud-opts2 .el-dialog__title2 {
line-height: 24px;
font-size:20px;
color:#303133;
}
.crud-opts2 .role-span {
padding: 10px 0px 10px 0px;
}
.crud-opts2 .crud-opts-form {
padding: 10px 0px 0px 20px;
}
</style>