Commit 8b5582ff authored by jingnan's avatar jingnan 👀

返厂入库明细编辑修改

parent 040a2f6b
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<template> <template>
<div class="flow-edit"> <div class="flow-edit">
<edit-purchase v-if="purchaseVis" :basic-data="basicData" /> <edit-purchase v-if="purchaseVis" :basic-data="basicData" />
<InStorageRecalEdit v-if="InStorageRecallVis" :basic-data="basicData" />
<dee-as-com <dee-as-com
v-else v-else
style="border:none;" style="border:none;"
...@@ -17,9 +18,10 @@ ...@@ -17,9 +18,10 @@
</template> </template>
<script> <script>
import EditPurchase from '@/privateComponents/components/PurchasingWarehousingNewOrEdit' import EditPurchase from '@/privateComponents/components/PurchasingWarehousingNewOrEdit'
import InStorageRecalEdit from '@/privateComponents/components/InStorageRecallItemCom'
export default { export default {
name: 'FlowEdit', // name写在组件的最前方,自定义组件为必填 name: 'FlowEdit', // name写在组件的最前方,自定义组件为必填
components: { EditPurchase }, components: { EditPurchase, InStorageRecalEdit },
props: { props: {
basicData: { basicData: {
type: Object, type: Object,
...@@ -32,7 +34,8 @@ export default { ...@@ -32,7 +34,8 @@ export default {
typeName: 'InStorageRecall', typeName: 'InStorageRecall',
layKey: 'edit_applyApproval' layKey: 'edit_applyApproval'
}, },
purchaseVis: false purchaseVis: false,
InStorageRecallVis: false
} }
}, },
inject: { inject: {
...@@ -51,10 +54,12 @@ export default { ...@@ -51,10 +54,12 @@ export default {
if (val && val.subTypeName) { if (val && val.subTypeName) {
switch (val.subTypeName) { switch (val.subTypeName) {
case 'InStorageRecall': case 'InStorageRecall':
this.cmpOptions = { // this.cmpOptions = {
typeName: 'InStorageRecall', // 返厂入库 // typeName: 'InStorageRecall', // 返厂入库
layKey: 'edit_applyApproval' // layKey: 'edit_applyApproval'
} // }
// 采购入库
this.InStorageRecallVis = true
break break
case 'InStorageExpire': case 'InStorageExpire':
this.cmpOptions = { this.cmpOptions = {
......
/**
* @Description: 采购入库导入
* @author xioln
* @date 2023-06-21
* @FilePath: applications/dee-mes/src/privateComponents/components/ProcurementWarehousingImport/index.vue
*/
<template>
<div class="procurement-Warehousing-import">
<dee-dialog
:visible="dialogVisible"
title="导入"
width="40%"
@handleClose="close"
>
<el-form ref="fileForm" label-width="100px">
<el-form-item label="选择文件">
<el-upload
ref="upload"
class="upload-demo"
accept=".xlsx, .xlsm, .xls"
:auto-upload="false"
action="#"
:limit="1"
:file-list="fileList"
:on-change="handleChange"
:on-exceed="handleExceed"
:on-remove="handleRemove"
>
<el-button size="small" style="width: 400px; text-align: right">
<i class="fa fa-folder-open-o" />
</el-button>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
:disabled="uploading"
@click="handleImportExcel"
>确定导入</el-button>
</div>
</dee-dialog>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
componentName: '导入',
name: 'ProcurementWarehousingImport', // name写在组件的最前方,自定义组件为必填
components: {},
props: {
param: {
type: Object,
required: true
}
// baseComInfo: {
// type: Object,
// default: () => { }
// }
},
data() {
return {
dialogVisible: false,
fileList: [], // 文件列表
file: {},
uploading: true // 默认置灰确定导入按钮
}
},
computed: {},
created() {
// 初始化数据
},
mounted() {
this.$nextTick(() => {
// this.handleExcel()
})
},
methods: {
open() {
this.dialogVisible = true
},
close() {
this.dialogVisible = false
},
// 文件状态改变触发
handleChange(file) { // (file,fileList)参数
this.uploading = false
this.file = file
},
// 文件超出个数限制
handleExceed() {
this.$message.warning('仅允许上传一个文件!')
},
// 移除文件
handleRemove() {
this.uploading = true
},
// 导入excel
handleImportExcel() {
if (!this.file.size) {
this.$message.warning('请选择上传的文件')
return
}
this.uploading = true
if (this.param.id) {
this.upLoadExcel(this.param.id)
} else {
post('/InventoryRequest/batch/recursionAdd', this.param).then(res => {
if (res.items.id) {
this.upLoadExcel(res.items.id, 'newData')
}
}).catch((err) => {
console.log(err)
})
}
},
// 上传excel
upLoadExcel(id, isNew) {
const formData = new FormData()
formData.append('file', this.file.raw)
this.$api.apiUploadFile(`/InStorageRequestItem/importByExcel?id=${id}`, formData).then(res => { // 调用接口
this.uploading = false
this.$utils.showMessageSuccess(res.data.message)
const reqId = isNew ? id : null
this.$emit('refreshTable', reqId)
this.close()
}).catch(err => {
this.uploading = false
// this.$utils.showMessageError(err)
console.log('err', err)
})
}
}
}
</script>
<style lang='scss'>
.procurement-Warehousing-import {
.dialog-footer{
margin-right: 25px;
}
}
</style>
/**
* @Description: 入库明细新增
* @author xioln
* @date 2023-06-21
* @FilePath: applications/dee-mes/src/privateComponents/components/StorageDetailsCreate/index.cue
*/
<template>
<div class="storageDetails-create">
<dee-dialog :dialog-visible="dialogVisibleDetails" title="采购入库申请创建" width="90%" @handleClose="handleClose">
<dee-form
ref="form"
:form="form"
:form-data="formFileds"
:rules="rules"
label-width="200px"
form-btn-position="center"
:form-buttons="formButtons"
@on-submit="save"
@on-cancel="handleClose"
>
<!-- <el-button ref="saveButton" :disabled="disabled" :loading="saveLoading" type="primary" size="medium" @click.native="()=>{save()}">确定</el-button>
<el-button :disabled="disabled" size="medium" @click="handleClose">取消</el-button> -->
</dee-form>
</dee-dialog>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
componentName: '采购入库申请创建',
name: 'StorageDetailsCreate', // name写在组件的最前方,自定义组件为必填
components: {},
props: {
basicData: {
type: Object,
default: () => { }
}
},
data() {
return {
dialogVisibleDetails: false,
disabled: false,
saveLoading: false,
header: {},
billType: '',
form: {},
formFileds: [
{
split: 3,
data: []
}
],
formButtons: [
{
text: '提交',
type: 'submit',
component: {
type: 'primary',
loading: false
}
},
{
text: '取消',
type: 'cancel'
}
],
material: [],
suppliers: [],
isChild: false,
// 表单校验
rules: {
resCode: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
resName: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
airModel: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
reqUnit: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
reqAmount: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
supplier: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
arrivalDate: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
withProductMaterial: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
urgency: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
isSupplierY: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
lotNo: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
storageCondition: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
arrivalVer: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
producedTime: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
modelNo: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
sorties: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
serialNo: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
arrivedDrawNo: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
contractNo: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
taxRate: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
taxUnitPrice: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
isVirtual: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
smallType: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
]
// purchaseAmount: [{ required: true, message: '请填写表单信息', trigger: ['blur', 'change'] }],
},
extMaterialId: '',
parentId: null,
operateType: null
}
},
computed: {
},
watch: {
// 'form.resCode': {
// handler: function(v) {
// this.resetMaterial(v)
// }
// }
// 'basicData': {
// handler: function(v) {
// console.log('vvv', v)
// },
// deep: true
// },
'form.airModel': {
handler: function(val) {
val && this.changeSorties()
}
},
// 1.父级明细不是虚拟件时,含税单价及税率必填,子明细非必填,如果添加子明细时,子明细税率及单价禁用,取值取父级上的
// 2.父级明细是虚拟件时,含税单价及税率为0且禁用,子明细必填,子明细上的税率及单价也必填
// 3.子明细添加时查询物料不作限制
'form.isVirtual': {
immediate: true,
handler: function(val) {
if (this.isChild) return
let isVirtualFlag = false
if (val) { // 父级明细是虚拟件时,含税单价及税率为0且禁用
isVirtualFlag = true
this.$set(this.form, 'taxRate', 0)
this.$set(this.form, 'taxUnitPrice', 0)
} else {
isVirtualFlag = false
}
const targetArr = this.formFileds[0].data.filter(item => item.title === '税率' || item.title === '含税单价')
targetArr.forEach(item => (item.component.disabled = isVirtualFlag))
}
},
isChild: {
immediate: true,
handler(val) {
if (val) return
let isVirtualFlag = false
if (this.form.isVirtual) { // 父级明细是虚拟件时,含税单价及税率为0且禁用
isVirtualFlag = true
this.$set(this.form, 'taxRate', 0)
this.$set(this.form, 'taxUnitPrice', 0)
} else {
isVirtualFlag = false
}
const targetArr = this.formFileds[0].data.filter(item => item.title === '税率' || item.title === '含税单价')
targetArr.forEach(item => (item.component.disabled = isVirtualFlag))
}
}
},
created() {
// 初始化数据
},
mounted() {
// this.form.arrivalDate = this.basicData.arrivalDate || ''
},
methods: {
handleOpen(type, basicData, row) {
this.basicData = basicData
this.form = { 'reqAmount': 1 }
this.dialogVisibleDetails = true
this.operateType = type
if (type === 'NEW') {
this.$set(this.form, 'operator', 'ADD')
} else if (type === 'ADD') {
this.parentId = row.id || null
this.parentRowId = row.rowId ? row.rowId : row.id
this.$set(this.form, 'operator', 'ADD')
delete row.id
this.form = JSON.parse(JSON.stringify(row))
this.$set(this.form, 'supplier', row.extDxSipplierId)
this.$set(this.form, 'withProductMaterial', Array.isArray(row.withProductMaterial) ? row.withProductMaterial : row.withProductMaterial && row.withProductMaterial.split(';') || '')
this.resetMaterial(row.extMaterial ? row.extMaterial.resCode : '')
this.changeMaterial(row.extMaterial ? row.extMaterial.resCode : '')
this.$set(this.form, 'resCode', '')
this.$set(this.form, 'resName', '')
this.$set(this.form, 'reqUnit', '')
this.$set(this.form, 'modelNo', '')
} else if (type === 'MODIFY') {
this.dispalyData(row)
}
this.resetForm()
},
// 回显数据
dispalyData(row) {
this.form = JSON.parse(JSON.stringify(row))
this.$set(this.form, 'operator', row.id && this.basicData.operator !== 'ADD' ? 'MODIFY' : 'ADD')
row.billType === 'AirEquipment' && this.$set(this.form, 'reqAmount', 1)
this.$set(this.form, 'resCode', row.extMaterial && row.extMaterial.resCode || row.resCode || '')
this.$set(this.form, 'resName', row.extMaterial && row.extMaterial.resName || row.resName || '')
this.$set(this.form, 'reqUnit', row.extMaterial && row.extMaterial.extUnit.unitName || row.reqUnit || '')
this.$set(this.form, 'modelNo', row.extMaterial && row.extMaterial.modelNo || row.modelNo || '')
this.$set(this.form, 'extMaterialId', row.extMaterialId || '')
this.$set(this.form, 'supplier', row.extDxSipplier && row.extDxSipplier.supplierFullName || row.supplier || '')
this.$set(this.form, 'withProductMaterial', Array.isArray(row.withProductMaterial) ? row.withProductMaterial : row.withProductMaterial && row.withProductMaterial.split(';') || '')
this.resetMaterial(row.extMaterial ? row.extMaterial.resCode : row.resCode || '')
this.changeMaterial(row.extMaterial ? row.extMaterial.resCode : row.resCode || '')
},
handleClose() {
this.dialogVisibleDetails = false
this.form = {}
},
getBasicData() {
const v = this.basicData
if (
v.billType === 'AirEquipment' &&
(['标准件', '金属材料', '非金属材料'].includes(v.materialTypeName.label)) &&
this.formFileds[0].data.find(item => item.title !== '所属设备')
) {
this.formFileds[0].data.unshift({
title: '所属设备',
key: 'subEquipment',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入所属设备'
}
})
this.$set(this.rules, 'subEquipment', [
{
required: true,
message: '请输入所属设备',
trigger: ['blur', 'change']
}
])
}
},
// 重设表单
resetForm() {
this.header = this.basicData
if (!this.header) return
this.$set(this.form, 'supplier', this.header.supplierFullName.label || '')
this.$set(this.form, 'arrivalDate', this.header.arrivalDate)
const childrenAddOrEdit = this.header.materialTypeName.label === '外购成品' && (this.operateType === 'ADD' || (this.operateType === 'MODIFY' && !this.form.isRoot))
const parentIsVirtual = this.form.isVirtual
switch (this.header.billType) {
case '器材':
case 'Material':
this.billType = '器材'
this.formFileds[0].data = [
{
title: '物料关键词',
key: 'resCode',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入物料关键词',
remote: true,
disabled: this.form.callBackReason !== '设计更改',
filterable: true,
'remote-method': this.resetMaterial,
options: []
},
handler: {
change: (v) => this.changeMaterial(v)
}
},
// 返厂入库申请环节,编辑明细信息时根据明细上的返厂原因判断,如果返厂原因是“设计更改“,则允许用户修改物料编码,否则只能修改其余信息
{
title: '物料编码',
key: 'resCode',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入物料名称'
}
},
{
title: '物料名称',
key: 'resName',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入物料编码'
}
},
{
title: '计量单位',
key: 'reqUnit',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入计量单位'
}
},
// { title: '物料类型', key: 'subTypeName', component: { name: 'el-input', disabled: true, placeholder: '请输入物料类型' }},
// { title: '名称', key: 'resName', component: { name: 'el-input', disabled: true, placeholder: '请输入名称' }},
// { title: '编号', key: 'number', component: { name: 'el-input', disabled: true, placeholder: '请输入编号' }},
{
title: '牌号/型号/件号',
key: 'modelNo',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入牌号/型号/件号'
}
},
{
title: '技术条件',
key: 'techSpec',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入技术条件'
}
},
{
title: '规格',
key: 'spec',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入规格'
}
},
{
title: '供应状态',
key: 'supplyStatus',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入供应状态'
}
},
{
title: '炉/批号',
key: 'lotNo',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入炉/批号'
}
},
{
title: '机型',
key: 'airModel',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入机型',
options: []
},
change: (v) => {
v && this.changeSorties()
}
},
{
title: '架次',
key: 'sorties',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入架次',
options: []
}
},
// { title: '采购数量/重量', key: 'purchaseAmount', component: { name: 'el-input-number', placeholder: '请输入采购数量/重量' }},
// { title: '采购单位', key: 'purchaseUnit', component: { name: 'el-select', placeholder: '请输入采购单位' }},
{
title: '入库数量',
key: 'reqAmount',
component: {
clearable: true,
name: 'el-input-number',
min: 0,
disabled: true,
placeholder: '请输入入库数量'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '供应商',
key: 'supplier',
component: {
name: 'el-select',
disabled: true,
placeholder: '请输入供应商'
},
handler: {
}
},
// {
// title: '是否合格供应商',
// key: 'isSupplierY',
// component: {
// clearable: true,
// name: 'el-select',
// disabled: true,
// placeholder: '请选择是否合格供应商',
// options: [
// { label: '是', value: true },
// { label: '否', value: false }
// ]
// }
// },
{
title: '制造商',
key: 'manufacturer',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入制造商'
}
},
{
title: '到货日期',
key: 'arrivalDate',
component: {
clearable: true,
name: 'el-date-picker',
disabled: true,
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd hh:mm:ss',
placeholder: '请选择到货日期'
}
},
{
title: '生产日期',
key: 'producedTime',
component: {
clearable: true,
name: 'el-date-picker',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd hh:mm:ss',
placeholder: '请选择生产日期'
}
},
{
title: '贮存条件',
key: 'storageCondition',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入贮存条件'
}
},
{
title: '随产品资料',
key: 'withProductMaterial',
component: {
clearable: true,
name: 'el-select',
multiple: true,
placeholder: '请选择随产品资料',
options: []
}
},
{
title: '紧急程度',
key: 'urgency',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择紧急程度',
options: [
{ label: '紧急', value: true },
{ label: '正常', value: false }
]
}
},
{
title: '到货标准',
key: 'arrivedDrawNo',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入到货标准'
}
},
{
title: '到货版次',
key: 'arrivalVer',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入到货版次'
}
},
{
title: '入库单价',
key: 'stockUnitPrice',
component: {
clearable: true,
disabled: true,
name: 'el-input',
placeholder: '请输入入库单价'
}
},
{
title: '税率',
key: 'taxRate',
component: {
clearable: true,
name: 'el-input-number',
min: 0,
placeholder: '请输入税率'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '入库金额',
key: 'stockPrice',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入入库金额'
}
},
{
title: '含税单价',
key: 'taxUnitPrice',
component: {
clearable: true,
name: 'el-input-number',
placeholder: '请输入含税单价'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '含税金额',
key: 'taxPrice',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入含税金额'
}
},
// { title: '报检人', key: 'userName', component: { name: 'el-input', disabled: true, placeholder: '请输入报检人' }},
{
title: '接收仓库',
key: 'storageZone',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入接收仓库',
options: []
},
handler: {
change: (v) => {
const STORAGE = this.formFileds[0].data.find(
(item) => item.key === 'storageZone'
)
const label = STORAGE.component.options.find(item => item.value === v).label
this.form.storageZoneName = label
}
}
},
{
title: '合同号/框架协议号',
key: 'contractNo',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入合同号'
}
},
// { title: '订货单号', key: 'purchaseOrderNo', component: { name: 'el-input', placeholder: '请输入订货单号' }},
{
title: '备注',
key: 'remark',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入备注'
}
}
]
break
case '机载设备':
case 'AirEquipment':
this.billType = '机载设备'
this.formFileds[0].data = [
{
title: '物料关键词',
key: 'resCode',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入物料关键词',
remote: true,
filterable: true,
'remote-method': this.resetMaterial,
options: []
},
handler: {
change: (v) => this.changeMaterial(v)
}
},
// { title: '物料编码', key: 'resCode', component: { name: 'el-select', placeholder: '请输入物料编码', remote: true, filterable: true, 'remote-method': this.resetMaterial, options: [] }, handler: {
// change: v => this.changeMaterial(v)
// }},
{
title: '物料编码',
key: 'resCode',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入物料名称'
}
},
{
title: '物料名称',
key: 'resName',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入物料编码'
}
},
{
title: '计量单位',
key: 'reqUnit',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入计量单位'
}
},
// { title: '物料类型', key: 'resType2.typeName', component: { name: 'el-input', disabled: true, placeholder: '请输入物料类型' }},
// { title: '名称', key: 'resName', component: { name: 'el-input', disabled: true, placeholder: '请输入名称' }},
{
title: '牌号/型号/件号',
key: 'modelNo',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入牌号/型号/件号'
}
},
{
title: '系列号',
key: 'serialNo',
component: {
clearable: true,
name: 'el-input',
disabled: childrenAddOrEdit,
placeholder: '请输入系列号'
}
},
{
title: '机型',
key: 'airModel',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
placeholder: '请输入机型',
options: []
},
change: (v) => {
v && this.changeSorties()
}
},
{
title: '架次',
key: 'sorties',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入架次',
options: []
}
},
{
title: '入库数量',
key: 'reqAmount',
component: {
clearable: true,
name: 'el-input-number',
min: 1,
disabled: false,
placeholder: '请输入入库数量'
},
handler: {
change: (v) => {
this.changeComputed()
}
}
},
{
title: '供应商',
key: 'supplier',
component: {
name: 'el-select',
disabled: true,
placeholder: '请输入供应商'
},
handler: {
}
},
// {
// title: '是否合格供应商',
// key: 'isSupplierY',
// component: {
// clearable: true,
// name: 'el-select',
// disabled: true,
// placeholder: '请选择是否合格供应商',
// options: [
// { label: '是', value: true },
// { label: '否', value: false }
// ]
// }
// },
{
title: '制造商',
key: 'manufacturer',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入制造商'
}
},
{
title: '到货日期',
key: 'arrivalDate',
component: {
clearable: true,
name: 'el-date-picker',
disabled: true,
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd',
placeholder: '请选择到货日期'
}
},
{
title: '生产日期',
key: 'producedTime',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-date-picker',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd hh:mm:ss',
placeholder: '请选择生产日期'
}
},
{
title: '产品图号/版本',
key: 'productDwawVer',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入产品图号/版本'
}
},
{
title: 'ATP名称',
key: 'atpName',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入ATP名称'
}
},
{
title: 'ATP编号及版次',
key: 'atpNo',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入ATP编号及版次'
}
},
{
title: '软件构型件号/版次',
key: 'softConfPieceNo',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入软件构型件号/版次',
type: 'textarea',
rows: 3
}
},
{
title: '电子硬件构型件号/版本',
key: 'elecHardwareConfPieceNo',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入电子硬件构型件号/版本',
type: 'textarea',
rows: 3
}
},
{
title: '适航批准标签/批准放行证书',
key: 'approvalCert',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入适航批准标签/批准放行证书'
}
},
{
title: '随产品资料',
key: 'withProductMaterial',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
multiple: true,
placeholder: '请选择随产品资料',
options: []
}
},
{
title: '紧急程度',
key: 'urgency',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
placeholder: '请选择紧急程度',
options: [
{ label: '紧急', value: true },
{ label: '正常', value: false }
]
}
},
{
title: '是否新研产品',
key: 'isNewlyProduct',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
placeholder: '请选择是否新研产品',
options: [
{ label: '是', value: true },
{ label: '否', value: false }
]
}
},
{
title: '入库单价',
key: 'stockUnitPrice',
component: {
clearable: true,
disabled: true,
name: 'el-input',
placeholder: '请输入入库单价'
}
},
{
title: '税率',
key: 'taxRate',
component: {
clearable: true,
disabled: childrenAddOrEdit && !parentIsVirtual,
name: 'el-input-number',
min: 0,
placeholder: '请输入税率'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '入库金额',
key: 'stockPrice',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入入库金额'
}
},
{
title: '含税单价',
key: 'taxUnitPrice',
component: {
clearable: true,
disabled: childrenAddOrEdit && !parentIsVirtual,
name: 'el-input-number',
placeholder: '请输入含税单价'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '含税金额',
key: 'taxPrice',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入含税金额'
}
},
// { title: '报检人', key: 'userName', component: { name: 'el-input', disabled: true, placeholder: '请输入报检人' }},
{
title: '接收仓库',
key: 'storageZone',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
placeholder: '请输入接收仓库',
options: []
},
handler: {
change: (v) => {
const STORAGE = this.formFileds[0].data.find(
(item) => item.key === 'storageZone'
)
const label = STORAGE.component.options.find(item => item.value === v).label
this.form.storageZoneName = label
}
}
},
{
title: '合同号/框架协议号',
key: 'contractNo',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入合同号/框架协议号'
}
},
// { title: '订货单号', key: 'purchaseOrderNo', component: { name: 'el-input', placeholder: '请输入订货单号' }},
{
title: '备注',
key: 'remark',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入备注'
}
}
]
break
case '外包产品':
case 'OutSource':
this.billType = '外包产品'
this.formFileds[0].data = [
{
title: '物料关键词',
key: 'resCode',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入物料关键词',
remote: true,
filterable: true,
'remote-method': this.resetMaterial,
options: []
},
handler: {
change: (v) => this.changeMaterial(v)
}
},
// { title: '物料编码', key: 'resCode', component: { name: 'el-select', placeholder: '请输入物料编码', remote: true, filterable: true, 'remote-method': this.resetMaterial, options: [] }, handler: {
// change: v => this.changeMaterial(v)
// }},
{
title: '物料编码',
key: 'resCode',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入物料编码'
}
},
{
title: '物料名称',
key: 'resName',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入物料名称'
}
},
{
title: '计量单位',
key: 'reqUnit',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入计量单位'
}
},
// { title: '物料类型', key: 'subTypeName', component: { name: 'el-input', disabled: true, placeholder: '请输入物料类型' }},
// { title: '名称', key: 'resName', component: { name: 'el-input', disabled: true, placeholder: '请输入名称' }},
{
title: '牌号/型号/件号',
key: 'modelNo',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入牌号/型号/件号'
}
},
{
title: '生产序列号',
key: 'serialNo',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入生产序列号'
}
},
{
title: '机型',
key: 'airModel',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
placeholder: '请输入机型',
options: []
},
handler: {
change: (v) => {
v && this.changeSorties()
}
}
},
{
title: '架次',
key: 'sorties',
component: {
clearable: true,
name: 'el-select',
placeholder: '请输入架次',
options: []
}
},
{
title: '入库数量',
key: 'reqAmount',
component: {
name: 'el-input-number',
disabled: childrenAddOrEdit,
min: 0,
placeholder: '请输入入库数量'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '供应商',
key: 'supplier',
component: {
name: 'el-select',
disabled: true,
placeholder: '请输入供应商'
},
handler: {
}
},
// {
// title: '是否合格供应商',
// key: 'isSupplierY',
// component: {
// clearable: true,
// name: 'el-select',
// disabled: true,
// placeholder: '请选择是否合格供应商',
// options: [
// { label: '是', value: true },
// { label: '否', value: false }
// ]
// }
// },
{
title: '制造商',
key: 'manufacturer',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入制造商'
}
},
{
title: '到货日期',
key: 'arrivalDate',
component: {
clearable: true,
name: 'el-date-picker',
disabled: true,
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd hh:mm:ss',
placeholder: '请选择到货日期'
}
},
{
title: '生产日期',
key: 'producedTime',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-date-picker',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd hh:mm:ss',
placeholder: '请选择生产日期'
}
},
{
title: '到货图号',
key: 'arrivedDrawNo',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入到货图号'
}
},
{
title: '到货版次',
key: 'arrivalVer',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入到货版次'
}
},
{
title: '交付规范及版次',
key: 'deliverySpec',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入交付规范及版次'
}
},
{
title: '适航批准标签/批准放行证书',
key: 'approvalCert',
component: {
name: 'el-input',
disabled: childrenAddOrEdit,
placeholder: '请输入适航批准标签/批准放行证书'
}
},
{
title: '随产品资料',
key: 'withProductMaterial',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
multiple: true,
placeholder: '请选择随产品资料',
options: []
}
},
{
title: '紧急程度',
key: 'urgency',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
placeholder: '请选择紧急程度',
options: [
{ label: '紧急', value: false },
{ label: '正常', value: true }
]
}
},
{
title: '入库单价',
key: 'stockUnitPrice',
component: {
clearable: true,
disabled: true,
name: 'el-input',
placeholder: '请输入入库单价'
}
},
{
title: '税率',
key: 'taxRate',
component: {
clearable: true,
disabled: childrenAddOrEdit && !parentIsVirtual,
name: 'el-input-number',
min: 0,
placeholder: '请输入税率'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '入库金额',
key: 'stockPrice',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入入库金额'
}
},
{
title: '含税单价',
key: 'taxUnitPrice',
component: {
clearable: true,
disabled: childrenAddOrEdit && !parentIsVirtual,
name: 'el-input-number',
placeholder: '请输入含税单价'
},
handler: {
change: () => this.changeComputed()
}
},
{
title: '含税金额',
key: 'taxPrice',
component: {
clearable: true,
name: 'el-input',
disabled: true,
placeholder: '请输入含税金额'
}
},
// { title: '报检人', key: 'userName', component: { name: 'el-input', disabled: true, placeholder: '请输入报检人' }},
{
title: '接收仓库',
key: 'storageZone',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-select',
placeholder: '请输入接收仓库',
options: []
},
handler: {
change: (v) => {
const STORAGE = this.formFileds[0].data.find(
(item) => item.key === 'storageZone'
)
const label = STORAGE.component.options.find(item => item.value === v).label
this.form.storageZoneName = label
}
}
},
{
title: '合同号/框架协议号',
key: 'contractNo',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入合同号'
}
},
// { title: '订货单号', key: 'purchaseOrderNo', component: { name: 'el-input', placeholder: '请输入订货单号' }},
{
title: '备注',
key: 'remark',
component: {
clearable: true,
disabled: childrenAddOrEdit,
name: 'el-input',
placeholder: '请输入备注'
}
}
]
break
default:
break
}
// 外购成品添加明细时
if (this.header.materialTypeName.label === '外购成品' && !childrenAddOrEdit) {
this.isChild = false
this.formFileds[0].data.unshift(
{
title: '是否虚拟件',
key: 'isVirtual',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择是否虚拟件',
options: [
{ label: '否', value: false },
{ label: '是', value: true }
]
}
}
)
}
// 添加子明细时
if (childrenAddOrEdit) {
this.isChild = true
this.formFileds[0].data.push(
{
title: '批次号',
key: 'lotNo',
component: {
clearable: true,
name: 'el-input',
placeholder: '请输入批次号'
}
},
{
title: '子件附件',
key: 'smallType',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择子件附件',
options: [
{ label: '子件', value: '子件' },
{ label: '附件', value: '附件' }
]
}
}
)
}
this.getBasicData()
// 设置物料类型下拉
this.resetMaterial()
// 设置带出接收仓库
this.defaultStorage()
// 设置带出机型
this.defaultAirModel()
// 设置随产品资料
this.resetProductFiles()
// 设置供应商
this.getExtDxSipplier()
},
// 设置物料类型下拉
async resetMaterial(query) {
if (query && query.length > 1) {
let paramsArr = []
await post(
`/ExtDxProcessResourceType/search`,
{
'pageFrom': 1,
'pageSize': 20,
'searchItems': {
'children': [
{
'items': [
{
'fieldName': 'parentId',
'operator': 'EQ',
'value': this.basicData.materialTypeId
}
],
'operator': 'AND'
}
],
'items': [],
'operator': 'AND'
},
'openProps': [],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
}
)
.then((res) => {
paramsArr = res.items.content.map(item => {
return item.id
})
paramsArr.push(this.basicData.materialTypeId)
})
.catch((err) => {
console.log(err)
})
let parentIdItems = []
if (!this.isChild) {
parentIdItems = [
{
'fieldName': 'resType2.id',
'operator': 'IN',
'value': paramsArr
}
]
} else {
parentIdItems = []
}
await post(
`/ExtDxProcessMaterial/search`,
{
'pageFrom': 1,
'pageSize': 20,
'searchItems': {
'children': [
{
'items': parentIdItems,
'operator': 'AND'
},
{
'items': [
{
'fieldName': 'resCode',
'operator': 'LIKE',
'value': query
},
{
'fieldName': 'resName',
'operator': 'LIKE',
'value': query
},
{
'fieldName': 'modelNo',
'operator': 'LIKE',
'value': query
},
{
'fieldName': 'spec',
'operator': 'LIKE',
'value': query
},
{
'fieldName': 'techSpec',
'operator': 'LIKE',
'value': query
}
],
'operator': 'OR'
}
],
'items': []
},
'openProps': [
{
'name': 'extUnit'
},
{
'name': 'resType2'
}
],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
}
)
.then((res) => {
this.material = res.items.content
const keywordField = this.formFileds[0].data.find(field => field.title === '物料关键词')
if (keywordField) {
keywordField.component.options = res.items.content.map(item => {
const labelParts = []
if (item.resName) labelParts.push(item.resName + '/')
if (item.modelNo) labelParts.push(item.modelNo + '/')
if (item.techSpec) labelParts.push(item.techSpec + '/')
if (item.spec) labelParts.push(item.spec + '/')
if (item.supplyStatus) labelParts.push(item.supplyStatus + '/')
if (item.supplierName) labelParts.push(item.supplierName + '/')
const label = labelParts.join('')
return {
label,
value: item.resCode,
disabled: ((this.operateType === 'MODIFY' && !this.form.isRoot) || this.operateType === 'ADD') && (this.form.extMaterial && item.resCode === this.form.extMaterial.resCode)
}
})
}
// this.formFileds[0].data.forEach(filed => {
// if (filed.title === '物料关键词') {
// filed.component.options = res.items.content.map(
// (item) => {
// // 新增或编辑子产品时和父产品物料类型不能一致
// if (((this.operateType === 'MODIFY' && !this.form.isRoot) || this.operateType === 'ADD') && item.resCode === this.form.extMaterial.resCode) {
// return {
// label: `${item.resName ? item.resName + '/' : ''}${item.modelNo ? item.modelNo + '/' : ''
// }${item.techSpec ? item.techSpec + '/' : ''}${item.spec ? item.spec + '/' : ''
// }${item.supplyStatus ? item.supplyStatus + '/' : ''}${item.supplierName ? item.supplierName + '/' : ''
// }`,
// value: item.resCode,
// disabled: true
// }
// } else {
// return {
// label: `${item.resName ? item.resName + '/' : ''}${item.modelNo ? item.modelNo + '/' : ''
// }${item.techSpec ? item.techSpec + '/' : ''}${item.spec ? item.spec + '/' : ''
// }${item.supplyStatus ? item.supplyStatus + '/' : ''}${item.supplierName ? item.supplierName + '/' : ''
// }`,
// value: item.resCode
// }
// }
// }
// )
// }
// })
})
.catch((err) => {
console.log(err)
})
}
},
// 默认带出机型
defaultAirModel() {
const params = {
searchItems: {
'operator': 'AND',
'items': [
// {
// 'fieldName': 'name',
// 'operator': 'EQ',
// 'value': ''
// }
]
}
}
this.$api.searchApi('AircraftType', params).then(res => {
const AIRMODEL = this.formFileds[0].data.find(
(item) => item.key === 'airModel'
)
AIRMODEL.component.options = res.items.content.map((item) => {
return {
label: item.defName,
value: item.defCode
}
})
this.$set(this.form, 'airModel', AIRMODEL.component.options[0].label)
})
},
// 根据机型带出架次
changeSorties() {
const params = {
searchItems: {
'operator': 'AND',
'items': [
{
'fieldName': 'aircraftType.defCode',
'operator': 'EQ',
'value': this.form.airModel
}
]
}
}
this.$api.searchApi('AircraftSorties', params).then(res => {
const SORTIES = this.formFileds[0].data.find(
(item) => item.key === 'sorties'
)
SORTIES.component.options = res.items.content.map((item) => {
return {
label: item.defName,
value: item.defCode
}
})
})
},
// material display
materialDisplay(id) {
post(
`/ExtDxProcessResourceType/search`,
{
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'children': [
{
'items': [
{
'fieldName': 'id',
'operator': 'EQ',
'value': id || ''
}
],
'operator': 'AND'
}
],
'items': []
},
'openProps': [],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
},
)
.then((res) => {
console.log('materialDisplay', res)
})
.catch((err) => {
console.log(err)
})
},
// 默认带出接收仓库
defaultStorage() {
post(
`/ExtDxProductWorkCenter/search`,
{
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'children': [
{
'items': [
{
'fieldName': 'extDxProductArea.id',
'operator': 'EQ',
'value': this.basicData.extDxProductAreaId || ''
}
],
'operator': 'AND'
}
],
'items': []
},
'openProps': [],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
},
)
.then((res) => {
this.form.storageZone =
res.items && res.items.content.length ? res.items.content[0].id : ''
const STORAGE = this.formFileds[0].data.find(
(item) => item.key === 'storageZone'
)
STORAGE.component.options = res.items.content.map((item) => {
return {
label: item.extname,
value: item.id
}
})
})
.catch((err) => {
console.log(err)
})
},
// 切换物料下拉
changeMaterial(v) {
// 带出物料相关默认值
const SELECT_MATERIAL = this.material.find((item) => item.resCode === v)
if (SELECT_MATERIAL) {
this.form.modelNo = SELECT_MATERIAL.modelNo || ''
this.form.techSpec = SELECT_MATERIAL.techSpec || ''
this.form.spec = SELECT_MATERIAL.spec || ''
this.form.supplyStatus = SELECT_MATERIAL.supplyStatus || ''
this.form.reqUnit = SELECT_MATERIAL.extUnit.unitName || ''
this.form.resName = SELECT_MATERIAL.resName || ''
this.form.extMaterial = SELECT_MATERIAL
this.extMaterialId = SELECT_MATERIAL.id || ''
this.extUnitId = SELECT_MATERIAL.extUnitId || ''
}
},
// 供应商ExtDxSipplier/find/recursion
getExtDxSipplier() {
const param = {}
post('ExtDxSipplier/find/recursion', param).then(res => {
this.formFileds[0].data.forEach(item => {
item.key === 'supplier' && (item.component.options = res.items.content.map(row => { return { value: row.id, label: `${row.supplierCode}-${row.supplierName}` } }))
})
}).catch((err) => {
console.log(err)
})
},
// 设置随产品资料
resetProductFiles(value) {
const PRODUCT = this.formFileds[0].data.find(
(item) => item.key === 'withProductMaterial'
)
switch (this.header.billType) {
case 'Material':
PRODUCT.component.options = [
{ label: '合格证', value: '合格证' },
{ label: '试验报告', value: '试验报告' },
{ label: '其他资料', value: '其他资料' }
]
break
case 'AirEquipment':
PRODUCT.component.options = [
{ label: '装箱单/发货清单', value: '装箱单/发货清单' },
{ label: '交付资料清单', value: '交付资料清单' },
{ label: '合格证', value: '合格证' },
{ label: '履历本', value: '履历本' },
{
label: '适航批准标签/批准放行证书',
value: '适航批准标签/批准放行证书'
},
{ label: '不合格品审理单清单', value: '不合格品审理单清单' },
{ label: '不合格品审理单复印件', value: '不合格品审理单复印件' },
{ label: '器材代用单清单', value: '器材代用单清单' },
{ label: '器材代用单复印件', value: '器材代用单复印件' },
{ label: '配套清单及合格证', value: '配套清单及合格证' },
{ label: '备件清单及合格证', value: '备件清单及合格证' },
{ label: '工具清单及合格证', value: '工具清单及合格证' },
{ label: '使用说明书', value: '使用说明书' },
{ label: '维护手册', value: '维护手册' },
{ label: '光盘', value: '光盘' },
{ label: '其他资料', value: '其他资料' }
]
break
case 'OutSource':
PRODUCT.component.options = [
{ label: '装箱单/发货清单', value: '装箱单/发货清单' },
{ label: '合格证', value: '合格证' },
{
label: '适航批准标签/批准放行证书',
value: '适航批准标签/批准放行证书'
},
{ label: '器材合格证', value: '器材合格证' },
{ label: '测量报告/尺寸数据报告', value: '测量报告/尺寸数据报告' },
{ label: '试验报告', value: '试验报告' },
{ label: '器材代用单清单', value: '器材代用单清单' },
{ label: '不合格品审理单清单', value: '不合格品审理单清单' },
{ label: '多余物声明', value: '多余物声明' },
{ label: '光盘', value: '光盘' },
{ label: '其他资料', value: '其他资料' }
]
break
default:
break
}
if (value) this.$set(this.form, 'withProductMaterial', value)
},
// 计算金额
changeComputed() {
// 含税金额=含税单价 * 入库数量
if (this.form.taxUnitPrice && this.form.reqAmount) {
this.form = Object.assign({}, this.form, {
taxPrice: (this.form.taxUnitPrice * this.form.reqAmount).toFixed(2)
})
} else {
this.form = Object.assign({}, this.form, { taxPrice: '' })
}
// 入库单价=含税单价/(1+税率/100)
if (
this.form.taxUnitPrice &&
(this.form.taxRate || this.form.taxRate === 0)
) {
this.form = Object.assign({}, this.form, {
stockUnitPrice: (
this.form.taxUnitPrice /
(1 + this.form.taxRate / 100)
).toFixed(8)
})
} else {
this.form = Object.assign({}, this.form, { stockUnitPrice: '' })
}
// 入库金额=含税单价/(1+税率/100)* 入库数量
if (
this.form.taxUnitPrice &&
(this.form.taxRate || this.form.taxRate === 0) &&
this.form.reqAmount
) {
this.form = Object.assign({}, this.form, {
stockPrice: (
(this.form.taxUnitPrice / (1 + this.form.taxRate / 100)) *
this.form.reqAmount
).toFixed(2)
})
} else {
this.form = Object.assign({}, this.form, { stockPrice: '' })
}
},
save() {
this.$set(this.formButtons[0].component, 'loading', true)
this.$refs.form.validate((isok) => {
if (isok) {
// 校验通过
const newTableData = {
...this.form,
'operator': 'MODIFY',
'subTypeName': 'InStorageRecallItem',
'rowId': this.form.id || this.generateUUID(),
'parentId': this.form.parentId ? this.form.parentId : this.parentId,
'parentRowId': this.parentRowId,
'extMaterialId': this.extMaterialId ? this.extMaterialId : this.form.extMaterialId,
'extMaterialIdType': 'ExtDxProcessMaterial',
'materialTypeName': this.basicData.materialTypeName.label,
'purchaseUnitId': this.extUnitId,
'purchaseUnitIdType': 'ExtUnit',
'lotNo': this.form.lotNo,
'airModel': this.form.airModel,
'sorties': this.form.sorties,
// 'reqAmount': this.form.reqAmount,
'extDxSipplierId': this.basicData.extDxSipplierId || '',
'extDxSipplierIdType': 'ExtDxSipplier',
'manufacturer': this.form.manufacturer,
'arrivalDate': this.form.arrivalDate,
'producedTime': this.form.producedTime,
'storageCondition': this.form.storageCondition,
'withProductMaterial': Array.isArray(this.form.withProductMaterial) ? this.form.withProductMaterial.join(';') : this.form.withProductMaterial,
'urgency': this.form.urgency,
'arrivedDrawNo': this.form.arrivedDrawNo,
'arrivalVer': this.form.arrivalVer,
'stockUnitPrice': this.form.stockUnitPrice,
'taxRate': this.form.taxRate,
'stockPrice': this.form.stockPrice,
'taxUnitPrice': this.form.taxUnitPrice,
'taxPrice': this.form.taxPrice,
'storageZoneName': this.form.storageZoneName,
'storageZoneId': this.form.storageZone,
'storageZoneIdType': 'ExtDxProductWorkCenter',
'inventoryReqId': this.basicData.id,
'inventoryReqIdType': 'InventoryRequest',
'contractNo': this.form.contractNo,
'isRoot': !this.isChild,
'subEquipment': this.form.subEquipment,
'productDwawVer': this.form.productDwawVer,
'atpName': this.form.atpName,
'atpNo': this.form.atpNo,
'softConfPieceNo': this.form.softConfPieceNo,
'elecHardwareConfPieceNo': this.form.elecHardwareConfPieceNo,
'approvalCert': this.form.approvalCert,
'isNewlyProduct': this.form.isNewlyProduct,
'reqUnit': this.form.reqUnit,
'remark': this.form.remark,
'operateType': this.operateType,
'MaterialResCode': this.form.resCode
}
this.$emit('addTableData', newTableData)
this.handleClose()
}
this.$set(this.formButtons[0].component, 'loading', false)
})
// post(
// '/InStorageRequestItem/recursion',
// {
// 'operator': 'ADD',
// 'subTypeName': 'InStoragePurchaseItem',
// 'extMaterialId': this.extMaterialId,
// 'extMaterialIdType': 'ExtDxProcessMaterial',
// 'purchaseUnitId': this.extUnitId,
// 'purchaseUnitIdType': 'ExtUnit',
// 'lotNo': this.form.lotNo,
// 'airModel': this.form.airModel,
// 'sorties': this.form.sorties,
// 'reqAmount': this.form.reqAmount,
// 'extDxSipplierId': this.basicData.extDxSipplierId,
// 'extDxSipplierIdType': 'ExtDxSipplier',
// 'manufacturer': this.form.manufacturer,
// 'arrivalDate': this.form.arrivalDate ? this.form.arrivalDate : null,
// 'producedTime': this.form.producedTime ? this.form.producedTime + ' 00:00:00' : null,
// 'storageCondition': this.form.storageCondition,
// 'withProductMaterial': this.form.withProductMaterial ? this.form.withProductMaterial.join(';') : '',
// 'urgency': this.form.urgency,
// 'arrivedDrawNo': this.form.arrivedDrawNo,
// 'arrivalVer': this.form.arrivalVer,
// 'stockUnitPrice': this.form.stockUnitPrice,
// 'taxRate': this.form.taxRate,
// 'stockPrice': this.form.stockPrice,
// 'taxUnitPrice': this.form.taxUnitPrice,
// 'taxPrice': this.form.taxPrice,
// 'storageZoneId': this.form.storageZone,
// 'storageZoneIdType': 'ExtDxProductWorkCenter',
// 'inventoryReqId': this.basicData.id,
// 'inventoryReqIdType': 'InventoryRequest',
// 'contractNo': this.form.contractNo,
// 'isRoot': true,
// 'subEquipment': this.form.subEquipment,
// 'productDwawVer': this.form.productDwawVer,
// 'atpName': this.form.atpName,
// 'atpNo': this.form.atpNo,
// 'softConfPieceNo': this.form.softConfPieceNo,
// 'elecHardwareConfPieceNo': this.form.elecHardwareConfPieceNo,
// 'approvalCert': this.form.approvalCert,
// 'isNewlyProduct': this.form.isNewlyProduct
// }
// ).then((res) => {
// this.$utils.showMessageSuccess('保存成功')
// this.handleClose()
// })
// .catch((err) => {
// console.log(err)
// })
},
generateUUID() {
let d = new Date().getTime()
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = (d + Math.random() * 16) % 16 | 0
d = Math.floor(d / 16)
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
})
return uuid
}
}
}
</script>
<style lang='scss'></style>
/**
* @Description: 返厂入库申请编辑
* @author gjn
* @date 2023-10-19
*/
<template>
<div class="purchasingWarehousing-newOrEdit">
<!-- <dee-tools :tools="topTools" mode="normal" style="justify-content: end;" /> -->
<dee-form
ref="form"
label-width="120"
:form="form"
:form-data="formData"
:rules="rules"
@on-submit="submit"
/>
<div class="sub-title"> 返厂入库申请明细 </div>
<dee-up-table
ref="treeTable"
:data="tableData"
:columns="columns"
:pagination="pagination"
:options="optionsTree"
:empty-content="emptyContent"
@pagination-size-change="changePageSize"
@pagination-current-change="changePageNum"
>
<!-- <div slot="header" class="table-title-wrap">
<dee-tools v-if="!isSignApproval" :tools="tools" mode="normal" />
</div> -->
</dee-up-table>
<span style="position: absolute;top: calc(100% - 70px);left: calc(50% - 70px);}">
<el-button type="primary" class="searchBtn" @click="submit">确认</el-button>
<el-button type="primary" class="searchBtn" @click="cancel">取消</el-button>
</span>
<storage-details ref="storageDetailsCreatOrEdit" :basic-data="detailsPropData" @addTableData="addTableData" />
<import-file ref="importFile" :param="importParam" @refreshTable="searchInStorageRequestItem" />
</div>
</template>
<script>
import { post, get } from '@/utils/http'
import StorageDetails from './component/storageDetailsCreateCom'
import ImportFile from './component/importFile'
// import { downloadFile } from '@/utils/http'
export default {
name: 'InStorageRecallItemCom', // name写在组件的最前方,自定义组件为必填
components: { StorageDetails, ImportFile },
props: {
basicData: {
type: Object,
default: () => null
}
},
inject: {
'InStorageApplyProcessInfo': {
default: () => {
return { InStorageApplyProcessInfo: null }
}
} // 流程basicData的id
},
data() {
const that = this
return {
currBasicData: null,
form: {},
formData: [{
title: '基本信息',
split: 2,
data: [
{
title: '申请单号',
key: 'reqNo',
component: {
disabled: true,
clearable: true,
placeholder: '自动生成',
name: 'el-input'
}
},
{
title: '验收单类型',
key: 'billType',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择',
options: []
},
handler: {
change: function(val) {
that.getExtDxProcessResourceType(val)
}
}
},
{
title: '器材类别',
key: 'materialTypeId',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择',
options: []
}
},
{
title: '区域',
key: 'extDxProductAreaId',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择',
options: []
}
},
{
title: '供应商',
key: 'extDxSipplierId',
component: {
clearable: true,
name: 'el-select',
placeholder: '请选择',
options: []
}
},
{
title: '到货日期',
key: 'arrivalDate',
component: {
name: 'el-date-picker',
disabled: false,
// type: 'daterange',
clearable: true,
valueFormat: 'yyyy-MM-dd HH:mm:ss'
}
},
{
title: '创建人',
key: 'creator.userName',
component: {
disabled: true,
clearable: true,
placeholder: '自动生成',
name: 'el-input'
}
},
{
title: '创建时间',
key: 'createTime',
component: {
disabled: true,
clearable: true,
placeholder: '自动生成',
name: 'el-input'
}
}
]
}],
buttonTools: [
{
name: '保存',
icon: '/icons/components/new/add.png',
handler: {
click: () => {
}
}
}
],
pagination: {
currentPage: 1,
pageSize: 20,
total: 0,
pageSizes: [10, 20, 50, 100]
},
rules: {
billType: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
materialTypeId: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
arrivalDate: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
extDxProductAreaId: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
],
extDxSipplierId: [
{
required: true,
message: '请填写表单信息',
trigger: ['blur', 'change']
}
]
},
// tools: [
// {
// name: '添加入库物料',
// icon: '/icons/components/new/add.png',
// handler: {
// click: () => {
// this.$refs.form.validate((isok) => {
// if (isok) {
// // 校验通过
// this.$refs.storageDetailsCreatOrEdit.handleOpen('NEW', this.detailsPropData)
// } else {
// this.$utils.showMessageWarning('请填写基本信息!')
// }
// })
// }
// }
// },
// {
// name: '导入',
// icon: '/icons/components/new/addAffectedData.png',
// handler: {
// click: () => {
// this.$refs.form.validate((isok) => {
// if (isok) {
// // 校验通过
// this.$refs.importFile.open()
// } else {
// this.$utils.showMessageWarning('请填写基本信息!')
// }
// })
// }
// }
// },
// {
// name: '模版下载',
// icon: '/icons/c-down.png',
// handler: {
// click: () => {
// this.$refs.form.validate((isok) => {
// if (isok) {
// let fileName = ''
// // 使用一个映射来将不同的billType映射到对应的文件名
// const billTypeToFileNameMap = {
// 'Material': '器材导入模板.xlsx',
// 'AirEquipment': '机载设备导入模板.xlsx',
// 'OutSource': '外包产品导入模板.xlsx'
// }
// if (billTypeToFileNameMap[this.form.billType]) {
// fileName = billTypeToFileNameMap[this.form.billType]
// }
// // 然后下载文件
// if (fileName) {
// downloadFile(`/download/template/${fileName}`, 'get').then(res => {
// this.$utils.downLoadFile(res, fileName)
// })
// }
// } else {
// this.$utils.showMessageWarning('请填写基本信息!')
// }
// })
// }
// }
// }
// ],
topTools: [
{
name: '返回',
icon: '/icons/toleft.png',
handler: {
click: () => {
that.cancel()
}
}
}
],
optionsTree: {
rowKey: 'rowId',
'tree-props': { children: 'children' }
},
num: 1,
childNum: 1,
columns: [
{ title: '序号', minWidth: 90, key: 'parentIndex', align: 'center', headerAlign: 'center' },
{
title: '操作', minWidth: 120, align: 'center', component: {
name: 'EditTableRow',
show: true,
props: {
btns: [{
operation: '新增',
handleClick: (row, index) => {
row.operator = 'ADD'
this.$refs.storageDetailsCreatOrEdit.handleOpen('ADD', this.detailsPropData, row)
},
icon: '/icons/components/new/add.png',
showFun: (row) => {
const value = row.extMaterial ? row.extMaterial.resType2.typeName : row.materialTypeName
if (!row.isRoot || value !== '外购成品') {
return false
}
return true
}
},
{
operation: '编辑',
handleClick: (row, index) => {
this.$refs.storageDetailsCreatOrEdit.handleOpen('MODIFY', this.detailsPropData, row)
},
icon: '/icons/components/new/edit.png',
showFun: (row) => {
return true
}
},
{
operation: '移除',
handleClick: (row, index) => {
this.$confirm('确认是否删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// const id = row.id
if (row.id) {
// del(`InStorageRequestItem/batch/${id}`).then(res => {
for (const item of this.tableData) {
const index = this.submitData.findIndex(el => el.rowId === row.rowId || el.rowId === row.parentId)
// 父类修改
if (item.rowId === row.rowId) {
this.tableData.splice(this.tableData.indexOf(item), 1)
this.submitData[index].operator = 'REMOVE'
}
// 子类修改
for (const child of item.children) {
if (child.rowId === row.rowId) {
const childIndex = this.submitData[index].children.findIndex(elChild => elChild.rowId === row.rowId)
this.tableData[this.tableData.indexOf(item)].children.splice(item.children.indexOf(child), 1)
this.submitData[index].children[childIndex].operator = 'REMOVE'
}
}
}
this.treeTableNoArrange(this.tableData, 'remove')
// }).catch((err) => {
// console.log(err)
// })
} else {
for (const item of this.tableData) {
// 父类修改
if (item.rowId === row.rowId) {
this.tableData.splice(this.tableData.indexOf(item), 1)
break
}
// 子类修改
for (const child of item.children) {
if (child.rowId === row.rowId) {
this.tableData[this.tableData.indexOf(item)].children.splice(item.children.indexOf(child), 1)
break
}
}
}
this.treeTableNoArrange(this.tableData)
this.$message({
type: 'success',
message: '删除成功!'
})
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
icon: '/icons/c-creatbackups.png',
showFun: (row) => {
return row.parentId
}
}]
}
}
},
{ title: '返厂出库原因', key: 'callBackReason', headerAlign: 'center' },
{ title: '所属设备', key: 'subEquipment', headerAlign: 'center' },
{
title: '物料类型', key: 'typeName', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
const value = row.extMaterial ? row.extMaterial.resType2.typeName : row.materialTypeName
return value
}
},
{
title: '编码', key: 'typeCode', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
const value = row.resCode ? row.resCode : row.extMaterial ? row.extMaterial.resCode : ''
return value
}
},
{ title: '机型', key: 'airModel', headerAlign: 'center' },
{ title: '架次', key: 'sorties', headerAlign: 'center' },
{
title: '计量单位', key: 'unitName', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
const value = row.reqUnit ? row.reqUnit : row.extMaterial ? row.extMaterial.extUnit.unitName : ''
return value
}
},
{ title: '入库数量', key: 'reqAmount', headerAlign: 'center' },
{
title: '供应商', key: 'supplierFullName', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
const value = row.extDxSipplier ? row.extDxSipplier.supplierFullName : row.supplier
return value
}
},
// { title: '是否合格供应商', key: 'extDxSipplier.isValid', headerAlign: 'center' },
{ title: '制造商', key: 'manufacturer', headerAlign: 'center' },
{ title: '到货日期', key: 'arrivalDate', headerAlign: 'center' },
{ title: '生产日期', key: 'producedTime', headerAlign: 'center' },
{
title: '随产品资料', key: 'withProductMaterial', width: '120', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
return Array.isArray(row.withProductMaterial) ? row.withProductMaterial.join(';') : row.withProductMaterial
}
},
{ title: '紧急程度', key: 'urgency', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
return row.urgency ? '紧急' : '正常'
} },
{ title: '入库单价', key: 'stockUnitPrice', headerAlign: 'center' },
{ title: '入库金额', key: 'stockPrice', headerAlign: 'center' },
{ title: '含税单价', key: 'taxUnitPrice', headerAlign: 'center' },
{ title: '含税金额', key: 'taxPrice', headerAlign: 'center' },
{ title: '税率', key: 'taxRate', headerAlign: 'center' },
{ title: '报检人', key: 'creator.userName', headerAlign: 'center' },
{
title: '接受仓库', key: 'extname', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
const value = row.storageZone ? row.storageZone.extname : row.storageZoneName
return value
}
},
{ title: '合同号', key: 'contractNo', headerAlign: 'center' },
{ title: '备注', key: 'remark', headerAlign: 'center' },
{
'title': '状态',
'key': 'state',
'width': '140px',
'fildProp': {
'type': 'DictDataVO',
'rule': {
'typeName': 'DictDataVO',
'dictTypeCode': 'StorageReqStatus'
}
}
},
// { title: '是否虚拟件', key: 'isVirtual', width: '100', headerAlign: 'center', formatter: (row, column, cellValue, index) => {
// return cellValue ? '是' : '否'
// } },
{ title: '创建时间', key: 'createTime', headerAlign: 'center' }
],
tableData: [],
submitData: [],
tableParam: [],
operator: null,
addData: {},
emptyContent: { 'icon': '/icons/dee-doc/noData.png', 'text': '暂无数据' },
newDataImportResId: '' // 初次创建申请单导入时返回的id
}
},
computed: {
detailsPropData: function() {
return {
materialTypeName: this.formData[0].data.find(item => item.key === 'materialTypeId').component.options.find(item => item.value === this.form.materialTypeId),
supplierFullName: this.formData[0].data.find(item => item.key === 'extDxSipplierId').component.options.find(item => item.value === this.form.extDxSipplierId),
...this.form
}
},
importParam: function() {
if (this.form.id) {
return {
'id': this.form.id
}
} else {
return {
'operator': 'ADD',
'materialTypeIdType': 'ExtDxProcessResourceType',
'extDxProductAreaIdType': 'ExtDxProductArea',
'extDxSipplierIdType': 'ExtDxSipplier',
'subTypeName': 'InStorageRecall',
'reqStatus': 'Apply',
'billType': this.form.billType,
'arrivalDate': this.form.arrivalDate,
'materialTypeId': this.form.materialTypeId,
'extDxProductAreaId': this.form.extDxProductAreaId,
'extDxSipplierId': this.form.extDxSipplierId
}
}
},
isSignApproval() {
return this.$route && this.$route.name === 'TaskCenterHome'
}
},
watch: {
},
created() {
// 初始化数据
this.initData()
this.operator = 'ADD'
this.form.operator = 'ADD'
},
methods: {
cancel() {
this.$emit('cancel')
this.$bus.$emit('refreshPurchaseData')
},
initData() {
this.getInventoryRequest()
this.getDictData()
this.getExtDxProductArea()
this.getExtDxSipplier()
},
editInit(currBasicData) {
this.currBasicData = currBasicData
this.form = currBasicData
this.searchInStorageRequestItem()
this.operator = 'MODIFY'
this.form.operator = 'MODIFY'
this.getExtDxProcessResourceType(currBasicData.billType)
},
// 获取验收单数据InventoryRequest/search
getInventoryRequest() {
if (!this.basicData.hasOwnProperty('id')) return
const param = {
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'children': [],
'items': [{
'fieldName': 'reqStatus',
'operator': 'IN',
'value': [
'Apply',
'PartAudit'
]
},
{
'fieldName': 'subTypeName',
'operator': 'EQ',
'value': 'InStorageRecall'
},
{
'fieldName': 'id',
'operator': 'EQ',
// 'value': this.$route.query.id
'value': this.basicData.id
}
],
'operator': 'AND'
},
'openProps': [
{
'name': 'materialType',
'pageFrom': 1,
'pageSize': 9999
},
{
'name': 'extDxProductArea',
'pageFrom': 1,
'pageSize': 9999
},
{
'name': 'extDxSipplier',
'pageFrom': 1,
'pageSize': 9999
},
{
'name': 'creator',
'pageFrom': 1,
'pageSize': 9999
}
],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
}
post('InventoryRequest/search', param).then(res => {
this.currBasicData = res.items.content[0]
this.editInit(res.items.content[0])
}).catch((err) => {
console.log(err)
})
},
// 验收单类型 DictData/search
getDictData() {
const param = { 'pageFrom': 1, 'pageSize': 9999, 'searchItems': { 'items': [{ 'fieldName': 'dictState', 'operator': 'EQ', 'value': 'ENABLE' }, { 'fieldName': 'dictCode', 'operator': 'EQ', 'value': 'BillType' }] }, 'sortItem': [{ 'fieldName': 'dictSeq', 'sortOrder': 'asc' }] }
post('DictData/search', param).then(res => {
this.formData[0].data.forEach(item => {
item.key === 'billType' && (item.component.options = res.items.content.map(row => { return { value: row.dictKey, label: row.dictValue } }))
})
}).catch((err) => {
console.log(err)
})
},
// 器材类型/ExtDxProcessResourceType/search
getExtDxProcessResourceType(val) {
get(`/ExtDxProcessResourceType/findByBillTypeCode?billTypeCode=${val}`).then(res => {
const targetItem = this.formData[0].data.find(item => item.key === 'materialTypeId')
if (targetItem) {
targetItem.component.options = res.items.content.map(row => ({ value: row.id, label: row.typeName }))
}
// this.form.materialTypeId = ''
}).catch((err) => {
console.log(err)
})
},
// 区域ExtDxProductArea/search
getExtDxProductArea() {
const param = { 'pageFrom': 1, 'pageSize': 100, 'indices': ['DxProductArea'], 'searchItems': { 'items': [], 'operator': 'AND' }}
post('ExtDxProductArea/search', param).then(res => {
this.formData[0].data.forEach(item => {
item.key === 'extDxProductAreaId' && (item.component.options = res.items.content.map(row => { return { value: row.id, label: row.extname } }))
})
}).catch((err) => {
console.log(err)
})
},
// 供应商ExtDxSipplier/find/recursion
getExtDxSipplier() {
const param = {}
post('ExtDxSipplier/find/recursion', param).then(res => {
this.formData[0].data.forEach(item => {
item.key === 'extDxSipplierId' && (item.component.options = res.items.content.map(row => { return { value: row.id, label: `${row.supplierCode}-${row.supplierName}` } }))
})
}).catch((err) => {
console.log(err)
})
},
// 编辑采购入库明细查询InStorageRequestItem/search
searchInStorageRequestItem(id) {
this.newDataImportResId = id
const param = {
'rootCondition': {
'pageFrom': this.pagination.currentPage,
'pageSize': this.pagination.pageSize,
'searchItems': {
'children': [
{
'items': [
{
'fieldName': 'inventoryReq.id',
'operator': 'EQ',
'value': id || this.currBasicData.id
},
{
'fieldName': 'isRoot',
'operator': 'EQ',
'value': 'true'
},
{
'fieldName': 'parentId',
'operator': 'ISNULL'
},
{
'fieldName': 'state',
'operator': 'EQ',
'value': 'Apply'
}
],
'operator': 'AND'
}
],
'items': [
]
},
'openProps': [
{
'name': 'extMaterial',
'openProps': [
{ 'name': 'resType2' },
{ 'name': 'extUnit' }
]
},
{ 'name': 'extDxSipplier' },
{ 'name': 'storageZone' }
],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
},
'childCondition': {
'pageFrom': 1,
'pageSize': 9999,
'searchItems': {
'children': [
],
'items': [
]
},
'openProps': [
{
'name': 'extMaterial',
'openProps': [
{ 'name': 'resType2' },
{ 'name': 'extUnit' }
]
},
{ 'name': 'extDxSipplier' },
{ 'name': 'storageZone' }
],
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'desc'
}
]
}
}
if (this.isSignApproval) {
param.rootCondition.searchItems.items.push({
'fieldName': 'id',
'operator': 'EQ',
'value': this.InStorageApplyProcessInfo && this.InStorageApplyProcessInfo.id || ''
})
}
post('InStorageRequestItem/treeSearch', param).then(res => {
const data = res.items.map(item => {
return {
...item,
operator: 'NO_CHANGE',
rowId: item.id,
// hasChildren: item.children.length > 0,
children: item.children && item.children.map(child => {
return {
...child,
rowId: child.id,
operator: 'NO_CHANGE'
// hasChildren: false
}
})
}
})
if (data.length > 0) {
this.formData[0].data.forEach(item => {
item.component.disabled = true
})
}
this.pagination.total = data.length
this.treeTableNoArrange(data)
this.num = 1
this.childNum = 1
}).catch((err) => {
console.log(err)
})
},
// 组装表格数据
addTableData(formData) {
const tableData = Array.from(this.submitData)
this.tableData = []
this.addData = formData
const tableDataItem = {
...formData,
children: formData.isRoot && formData.children || []
}
// 根据父子关系添加数据
if (tableDataItem.operateType === 'ADD') {
for (let i = 0; i < tableData.length; i++) {
const item = tableData[i]
if (item.rowId === tableDataItem.parentRowId) {
// item.hasChildren = true
item.children.push(tableDataItem)
break
}
}
}
if (tableDataItem.operateType === 'MODIFY') {
for (const item of tableData) {
// 父类修改
if (item.id === tableDataItem.id) {
tableData.splice(tableData.indexOf(item), 1, tableDataItem)
break
}
// 子类修改
for (const child of item.children) {
if (child.id === tableDataItem.id) {
tableData[tableData.indexOf(item)].children.splice(item.children.indexOf(child), 1, tableDataItem)
break
}
}
}
}
if (tableDataItem.operateType === 'NEW') {
tableData.push(tableDataItem)
}
this.treeTableNoArrange(tableData)
},
submit() {
const tableData = this.submitData.slice()
tableData.forEach((obj, i) => {
for (const key in obj) {
if (key === 'storageZone') {
delete tableData[i][key]
}
}
if (obj.children.length > 0) {
obj.children.forEach((child, j) => {
for (const ckey in child) {
if (ckey === 'storageZone') {
delete tableData[i]['children'][j][ckey]
}
}
})
}
})
const isVirtualHasChild = tableData.find(item => item.isVirtual && (!item.children || !item.children.length || item.children && !(item.children.find(child => child.operator !== 'REMOVE'))))
if (isVirtualHasChild) return this.$utils.showMessageWarning('父件为虚拟件时,必须添加子件!')
const paramOperator = this.newDataImportResId ? 'MODIFY' : this.operator
const param = {
'operator': 'MODIFY',
'billType': this.form.billType,
'arrivalDate': this.form.arrivalDate,
'materialTypeIdType': 'ExtDxProcessResourceType',
'extDxProductAreaIdType': 'ExtDxProductArea',
'extDxSipplierIdType': 'ExtDxSipplier',
'subTypeName': 'InStorageRecall',
'reqStatus': 'Apply',
'extDxProductAreaId': this.form.extDxProductAreaId,
'extDxSipplierId': this.form.extDxSipplierId,
'materialTypeId': this.form.materialTypeId,
'inStorageRequestItems': tableData
}
if (paramOperator === 'MODIFY') {
param.id = this.newDataImportResId || this.form.id
}
post('/InventoryRequest/batch/recursionAdd', param).then(res => {
this.$utils.showMessageSuccess('保存成功')
this.cancel()
}).catch((err) => {
console.log(err)
})
},
treeTableNoArrange(tableData, type) {
if (type !== 'remove') {
this.submitData = this.$utils.deepClone(tableData)
this.tableData = this.$utils.deepClone(tableData)
}
this.tableData.forEach((item, i) => {
item.parentIndex = i + 1
if (item.children) {
item.children.forEach((child, j) => {
child.parentIndex = item.parentIndex + '.' + (j + 1)
child.state = ''
})
}
})
},
changePageSize(pageSize) {
this.pagination.pageSize = pageSize
this.pagination.currentPage = 1
this.searchInStorageRequestItem()
},
changePageNum(pageNum) {
this.pagination.currentPage = pageNum
this.searchInStorageRequestItem()
}
}
}
</script>
<style lang='scss'>
.purchasingWarehousing-newOrEdit{
.dee-up-table {
height: 300px;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment