Commit 03d00146 authored by jingnan's avatar jingnan 👀

无指令领用及供外出库批量导入联调

parent 4fcb3dd1
<template>
<div class="OutStorageDetailImport">
<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 type="primary" size="small" style="width: 400px; text-align: center">
选择待上传文件
</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>
export default {
componentName: '导入',
name: 'OutStorageDetailImport', // name写在组件的最前方,自定义组件为必填
components: {},
props: {
param: {
type: Object,
required: true
}
},
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
this.upLoadExcel()
},
// 上传excel
upLoadExcel() {
const formData = new FormData()
formData.append('file', this.file.raw)
formData.append('outStorageRequest', new Blob([JSON.stringify(this.param)], { type: 'application/json' }))
this.$api.apiUploadFile(`/InStorageRequestItem/item/importByExcel`, formData).then(res => { // 调用接口
this.uploading = false
this.$utils.showMessageSuccess(res.data.message)
const outStorageRequest = res.data.items
outStorageRequest && this.$emit('refreshTable', outStorageRequest)
this.close()
}).catch(err => {
this.uploading = false
console.log('err', err)
})
}
}
}
</script>
<style lang='scss'>
.OutStorageDetailImport {
.dialog-footer{
margin-right: 25px;
}
}
</style>
......@@ -8,7 +8,7 @@
<div class="sub-title">领用类型</div>
<div class="useType">
<span class="typeName">领用类型:</span>
<el-select v-model="typeName" style="width: 200px;" :disabled="!!basicData.id" placeholder="请选择" size="mini">
<el-select v-model="typeName" style="width: 200px;" :disabled="!!basicData.id || !!outStorageUseId" placeholder="请选择" size="mini">
<el-option
v-for="item in options"
:key="item.value"
......@@ -59,7 +59,7 @@ export default {
typeName: 'OutStorageUse',
layKey: 'outStorageUseApplyAdd_useAO'
},
outStorageUseId: [] // 取消使解除占用操作需要
outStorageUseId: ''//
}
},
computed: {},
......
......@@ -33,17 +33,19 @@
@cancel="dialogShow = false"
/>
</dee-dialog>
<import-file ref="importFile" :param="basicForm" @refreshTable="refreshTable" />
</div>
</template>
<script>
import AddOutStorageUseDetailDialog from './components/AddOutStorageUseDetailDialog'
import AdjustOccupyCom from '../adjustOccupyCom'
import ImportFile from '@/components/importFile'
import { post } from '@/utils/http'
export default {
componentName: '领用出库明细',
name: 'AddOutStorageUseDetail',
components: { AddOutStorageUseDetailDialog, AdjustOccupyCom },
components: { AddOutStorageUseDetailDialog, AdjustOccupyCom, ImportFile },
provide() { // 用于报废领用申领数量编辑校验
return {
parentType_Inject: this.basicData && this.basicData.useRequestType || ''
......@@ -95,7 +97,8 @@ export default {
cmpOptions: {
typeName: 'OutStorageUseItem',
layKey: 'add_outStorageUseItem_useAO'
}
},
basicForm: {}
}
},
computed: {
......@@ -160,6 +163,9 @@ export default {
case 'remove':
this.remove()
break
case 'import':
this.importHandle()
break
default:
break
}
......@@ -337,6 +343,28 @@ export default {
})
})
},
importHandle() {
this.$utils.findForm(this).validate((isok) => {
if (isok) {
// 校验通过
this.basicForm = {
...this.form,
aircraftType: this.form.aircraftType.split('+')[1],
sorties: this.form.sorties.split('+')[1],
subTypeName: 'OutStorageUse',
typeName: this.basicData.useRequestType
}
this.$refs.importFile.open()
} else {
this.$utils.showMessageWarning('请填写基本信息!')
}
})
},
refreshTable(res) {
this.$set(this.form, 'id', res.id)
this.getDetailsData(res.id)
this.$bus.$emit('getApplyId', res.id)
},
submitEvent({ formData, addContinue }) {
const extMaterialIds = this.tableData.map(item => item.extMaterialId).includes(formData[0].extMaterialId)
if (extMaterialIds) return this.$utils.showMessageWarning('相同物料不能重复添加,请重新选择!')
......
......@@ -28,17 +28,19 @@
:lay-config="{ typeName: 'JobResponseOutStorageOut', layKey: 'table' }"
/>
</dee-dialog>
<import-file ref="importFile" :param="basicForm" @refreshTable="refreshTable" />
</div>
</template>
<script>
import AddOutStorageOfferDetailDialog from './components/addOutStorageOfferDetailDialog'
import OutStorageOfferAdjustOccupy from './components/outStorageOfferAdjustOccupy'
import ImportFile from '@/components/importFile'
import { post } from '@/utils/http'
export default {
componentName: '供外出库申请明细',
name: 'OutStorageOfferDetail',
components: { AddOutStorageOfferDetailDialog, OutStorageOfferAdjustOccupy },
components: { AddOutStorageOfferDetailDialog, OutStorageOfferAdjustOccupy, ImportFile },
props: {
form: {
type: Object,
......@@ -52,6 +54,7 @@ export default {
data() {
return {
dialogVisible: false,
basicForm: {},
tableColumns: [
{ title: '物料编码', key: 'extMaterial.resCode', align: 'center' },
{ title: '物料名称', key: 'extMaterial.resName', align: 'center' },
......@@ -162,7 +165,39 @@ export default {
this.remove()
}
}
}],
},
{
name: '导入',
icon: '/icons/c-import.png',
handler: {
click: () => {
this.$utils.findForm(this).validate((isok) => {
if (isok) {
// 校验通过
this.basicForm = {
...this.form,
aircraftType: this.form.aircraftType.split('+')[1],
sorties: this.form.sorties.split('+')[1],
subTypeName: 'OutStorageOut'
}
this.$refs.importFile.open()
} else {
this.$utils.showMessageWarning('请填写基本信息!')
}
})
}
}
},
{
name: '模板下载',
icon: '/icons/c-down.png',
handler: {
click: () => {
this.$utils.downLoadFileUrl('/出库明细导入模板.xlsx', '出库明细导入模板')
}
}
}
],
param: {},
aoDialogVisible: false,
selectTableData: [],
......@@ -239,6 +274,7 @@ export default {
post('OutStorageRequest/outStorageOut/saveAndTake', param).then(res => {
this.$utils.findForm(this).applyId = res.items.id
this.applyId = res.items.id
this.$set(this.form, 'id', res.items.id)
this.$utils.showMessageSuccess('占用成功!')
const data = res.items.inStorageRequestItems
const tableData = [...this.tableData]
......@@ -347,6 +383,10 @@ export default {
console.log(err)
})
},
refreshTable(res) {
this.$set(this.form, 'id', res.id)
this.getEditData(res.id)
},
sumArray(array, key) {
let sum = 0
for (let i = 0; i < array.length; i++) {
......
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