init project
This commit is contained in:
405
mes/qd/src/views/wms/sb/outbill/AddDialog.vue
Normal file
405
mes/qd/src/views/wms/sb/outbill/AddDialog.vue
Normal file
@@ -0,0 +1,405 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="crud.status.title"
|
||||
fullscreen
|
||||
append-to-body
|
||||
:before-close="crud.cancelCU"
|
||||
:visible.sync="crud.status.cu > 0 || crud.status.view > 0"
|
||||
width="1200px"
|
||||
@open="open"
|
||||
@close="close"
|
||||
>
|
||||
<el-row v-show="crud.status.cu > 0" :gutter="20">
|
||||
<el-col :span="20" style="border: 1px solid white">
|
||||
<span/>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<span>
|
||||
<el-button icon="el-icon-check" size="mini" :loading="crud.cu === 2" type="primary"
|
||||
@click="crud.submitCU">保存</el-button>
|
||||
<el-button icon="el-icon-close" size="mini" type="info" @click="crud.cancelCU">关闭</el-button>
|
||||
</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<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="85px" label-suffix=":">
|
||||
<el-form-item label="单据号" prop="bill_code">
|
||||
<label slot="label">单 据 号:</label>
|
||||
<el-input v-model="form.bill_code" disabled placeholder="系统生成" clearable style="width: 210px"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="业务类型" prop="bill_type">
|
||||
<el-select
|
||||
v-model="form.bill_type"
|
||||
clearable
|
||||
placeholder="业务类型"
|
||||
style="width: 210px"
|
||||
class="filter-item"
|
||||
:disabled="crud.status.view > 0"
|
||||
@change="billTypeChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in billtypelist"
|
||||
:key="item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联设备" prop="bizperson">
|
||||
<label slot="label">关联设备:</label>
|
||||
<el-input v-model="form.bizperson" size="mini" style="width: 210px"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库" prop="stor_id">
|
||||
<label slot="label">仓 库:</label>
|
||||
<el-select
|
||||
v-model="form.stor_id"
|
||||
clearable
|
||||
placeholder="仓库"
|
||||
class="filter-item"
|
||||
style="width: 210px"
|
||||
:disabled="crud.status.view > 0"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in storlist"
|
||||
:key="item.stor_id"
|
||||
:label="item.stor_name"
|
||||
:value="item.stor_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="业务部门" prop="bizperson">
|
||||
<label slot="label">业务部门:</label>
|
||||
<el-input v-model="form.bizperson" size="mini" style="width: 210px"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="业务人员" prop="bizperson">
|
||||
<label slot="label">业务人员:</label>
|
||||
<el-input v-model="form.bizperson" size="mini" style="width: 210px"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="明细数" prop="detail_count">
|
||||
<label slot="label">明 细 数:</label>
|
||||
<el-input v-model="form.detail_count" size="mini" disabled style="width: 210px"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="总数量" prop="total_qty">
|
||||
<label slot="label">总 数 量:</label>
|
||||
<el-input-number
|
||||
v-model="form.total_qty"
|
||||
:controls="false"
|
||||
:precision="3"
|
||||
:min="0"
|
||||
disabled
|
||||
style="width: 210px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="摘要" prop="remark">
|
||||
<label slot="label">摘 要:</label>
|
||||
<el-input v-model="form.remark" style="width: 380px;" rows="2" type="textarea"
|
||||
:disabled="crud.status.view > 0"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<div class="crud-opts2" style="margin-bottom: 5px;">
|
||||
<span class="crud-opts-right2">
|
||||
<!--左侧插槽-->
|
||||
<slot name="left"/>
|
||||
<el-button
|
||||
slot="left"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
:disabled="mater_btn"
|
||||
@click="insertdtl()"
|
||||
>
|
||||
新增一行
|
||||
</el-button>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
:data="form.tableData"
|
||||
style="width: 100%;"
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="55" align="center"/>
|
||||
<el-table-column show-overflow-tooltip prop="material_code" label="物料编码" width="190" align="center">
|
||||
<template scope="scope">
|
||||
<el-input v-show="!scope.row.edit" v-model="scope.row.material_code" disabled class="input-with-select">
|
||||
<el-button slot="append" icon="el-icon-plus" @click="queryMater(scope.$index, scope.row)"/>
|
||||
</el-input>
|
||||
<span v-show="!scope.row.edit && mater_btn">{{ scope.row.material_code }}</span>
|
||||
<span v-show="scope.row.edit">{{ scope.row.material_code }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="material_name" label="物料名称" align="center" min-width="150px" show-overflow-tooltip/>
|
||||
<el-table-column prop="material_spec" label="规格" align="center" min-width="150px" show-overflow-tooltip/>
|
||||
<el-table-column prop="material_model" label="型号" align="center" min-width="150px" show-overflow-tooltip/>
|
||||
<el-table-column prop="sum_qty" label="库存" align="center" min-width="150px" show-overflow-tooltip/>
|
||||
<el-table-column prop="plan_qty" width="220" label="出库数量" align="center">
|
||||
<template scope="scope">
|
||||
<el-input-number v-model="scope.row.plan_qty" :disabled="scope.row.edit" :precision="3" :controls="false"
|
||||
:min="0" style="width: 120px"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="qty_unit_name" label="单位" align="center"/>
|
||||
<el-table-column v-if="crud.status.cu > 0" align="center" label="操作" width="190" fixed="right">
|
||||
<template scope="scope">
|
||||
<el-button
|
||||
type="danger"
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
@click.native.prevent="deleteRow(scope.$index, form.tableData)"
|
||||
/>
|
||||
<el-button
|
||||
v-show="!scope.row.edit"
|
||||
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"
|
||||
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>
|
||||
<MaterDtl
|
||||
:dialog-show.sync="materShow"
|
||||
:is-single="true"
|
||||
:mater-opt-code="materType"
|
||||
@tableChanged2="tableChanged2"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import CRUD, { crud, form } from '@crud/crud'
|
||||
import crudStorattr from '@/api/wms/basedata/st/storattr'
|
||||
import sparePart from '@/api/wms/sb/sparepartout'
|
||||
import crudRawAssist from '@/api/wms/st/core/inbill/rawassist'
|
||||
import MaterDtl from '@/views/wms/sb/outbill/IvtDialog'
|
||||
import checkoutbill from '@/api/wms/st/core/outbill/checkoutbill'
|
||||
|
||||
const defaultForm = {
|
||||
bill_code: '',
|
||||
stor_id: '',
|
||||
bill_status: '10',
|
||||
total_qty: '0',
|
||||
detail_count: '0',
|
||||
bill_type: '',
|
||||
remark: '',
|
||||
bizperson: '',
|
||||
source_id: '',
|
||||
biz_date: new Date().format('yyyy-MM-dd'),
|
||||
create_mode: '',
|
||||
tableData: []
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'AddDialog',
|
||||
components: { crudOperation, MaterDtl },
|
||||
mixins: [crud(), form(defaultForm)],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
bussConfig: {
|
||||
type: Object
|
||||
},
|
||||
openParam: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
materShow: false,
|
||||
dtlShow: false,
|
||||
opendtlParam: null,
|
||||
mater_btn: false,
|
||||
materType: '',
|
||||
storlist: [],
|
||||
billtypelist: [],
|
||||
rules: {
|
||||
stor_id: [
|
||||
{ required: true, message: '仓库不能为空', trigger: 'blur' }
|
||||
],
|
||||
bill_type: [
|
||||
{ required: true, message: '业务类型不能为空', trigger: 'blur' }
|
||||
],
|
||||
biz_date: [
|
||||
{ required: true, message: '业务日期不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
if (this.crud.status.cu > 0) {
|
||||
this.mater_btn = false
|
||||
}
|
||||
if (this.crud.status.view > 0) {
|
||||
this.mater_btn = true
|
||||
}
|
||||
// 查询原材料库的仓库
|
||||
crudStorattr.getStor({ 'is_materialstore': '1' }).then(res => {
|
||||
this.storlist = res.content
|
||||
this.form.stor_id = this.storlist[0].stor_id
|
||||
})
|
||||
// 获取单据类型
|
||||
crudRawAssist.getType({ 'io_code': '0109', 'io_flag': '01' }).then(res => {
|
||||
this.billtypelist = res
|
||||
this.form.bill_type = this.billtypelist[0].code
|
||||
})
|
||||
},
|
||||
[CRUD.HOOK.afterToEdit]() {
|
||||
// 获取入库单明细
|
||||
sparePart.getIODtl({ 'bill_code': this.form.bill_code }).then(res => {
|
||||
this.form.tableData = res
|
||||
// 将明细变成不可编辑
|
||||
for (let i = 0; i < this.form.tableData.length; i++) {
|
||||
const row = this.form.tableData[i]
|
||||
row.edit = true
|
||||
this.form.tableData.splice(i, 1, row)
|
||||
}
|
||||
})
|
||||
},
|
||||
[CRUD.HOOK.beforeSubmit]() {
|
||||
// 提交前校验
|
||||
if (this.form.tableData.length === 0) {
|
||||
this.crud.notify('请至少选择一条明细', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return false
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.form.tableData.length; i++) {
|
||||
if (!this.form.tableData[i].edit) {
|
||||
this.crud.notify('尚有未完成编辑的物料明细序号' + (i + 1) + ',请检查!')
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
billTypeChange(val) {
|
||||
this.form.tableData = []
|
||||
this.form.total_qty = 0
|
||||
this.form.detail_count = 0
|
||||
},
|
||||
tableChanged2(row) {
|
||||
debugger
|
||||
// 新增一行物料时,给行进行赋值
|
||||
this.nowrow.material_code = row.material_code
|
||||
this.nowrow.material_id = row.material_id
|
||||
this.nowrow.material_name = row.material_name
|
||||
this.nowrow.material_spec = row.material_spec
|
||||
this.nowrow.material_model = row.material_model
|
||||
this.nowrow.qty_unit_id = row.qty_unit_id
|
||||
this.nowrow.qty_unit_name = row.qty_unit_name
|
||||
this.nowrow.sum_qty = row.sum_qty
|
||||
this.form.tableData.splice(this.nowindex, 1, this.nowrow) // 通过splice 替换数据 触发视图更新
|
||||
},
|
||||
fun(val) {
|
||||
return Number(val).toFixed(3)
|
||||
},
|
||||
async queryMater(index, row) {
|
||||
checkoutbill.paramByCodeType({ 'bill_type': this.form.bill_type, 'io_flag': '01' }).then(res => {
|
||||
this.materType = res.materType
|
||||
this.materShow = true
|
||||
this.nowindex = index
|
||||
this.nowrow = row
|
||||
})
|
||||
},
|
||||
async insertdtl() {
|
||||
if (this.form.bill_type == '') {
|
||||
this.crud.notify('请选择业务类型!', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return
|
||||
}
|
||||
this.form.tableData.push({ edit: false, plan_qty: '0' })
|
||||
this.form.detail_count = this.form.tableData.length
|
||||
},
|
||||
handleEdit(index, row) {
|
||||
if (!row.edit) {
|
||||
if (parseFloat(row.plan_qty) <= 0) {
|
||||
this.crud.notify('数量不可为空!', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return false
|
||||
}
|
||||
|
||||
if (parseFloat(row.plan_qty) > parseFloat(row.sum_qty)) {
|
||||
this.crud.notify('出库数量不能大于库存!', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return false
|
||||
}
|
||||
}
|
||||
// 修改行的编辑状态
|
||||
row.edit = !row.edit
|
||||
this.form.tableData.splice(index, 1, row) // 通过splice 替换数据 触发视图更新
|
||||
if (row.edit) {
|
||||
this.form.total_qty = 0
|
||||
this.form.tableData.forEach((item) => {
|
||||
this.form.total_qty = this.form.total_qty + item.plan_qty
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteRow(index, rows) {
|
||||
this.form.total_qty = parseFloat(this.form.total_qty) - parseFloat(rows[index].plan_qty)
|
||||
rows.splice(index, 1)
|
||||
this.form.detail_count = this.form.tableData.length
|
||||
},
|
||||
tableChanged(rows) {
|
||||
// 对新增的行进行校验不能存在相同物料批次
|
||||
rows.forEach((item) => {
|
||||
let same_mater = true
|
||||
this.form.tableData.forEach((row) => {
|
||||
if (row.material_id === item.material_id && row.pcsn === item.pcsn) {
|
||||
same_mater = false
|
||||
}
|
||||
})
|
||||
if (same_mater) {
|
||||
item.edit = false
|
||||
item.quality_scode = '00'
|
||||
item.is_active = '1'
|
||||
item.plan_qty = item.need_qty
|
||||
this.form.total_qty = parseFloat(this.form.total_qty) + parseFloat(item.plan_qty)
|
||||
this.form.tableData.splice(-1, 0, item)
|
||||
}
|
||||
})
|
||||
this.form.detail_count = this.form.tableData.length
|
||||
},
|
||||
close() {
|
||||
this.$emit('AddChanged')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.crud-opts2 {
|
||||
padding: 4px 0;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.crud-opts2 .crud-opts-right2 {
|
||||
margin-left: auto;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user