<template>
|
<el-dialog
|
top="5vh"
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-tabs type="border-card" ref="tabs">
|
<el-tab-pane label="主要">
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="80px"
|
class="l-mes"
|
:disabled="!editable"
|
>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="退库单号" prop="returnNo">
|
<el-input
|
v-model="dataForm.returnNo"
|
placeholder=""
|
disabled
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="退库类型" prop="returnType">
|
<el-select
|
v-model="dataForm.returnType"
|
filterable
|
placeholder=""
|
style="width:100%"
|
>
|
<el-option
|
v-for="item in receiveTypes"
|
:key="item.id"
|
:label="item.stockCodeName"
|
:value="item.id"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="申请时间" prop="applyDate">
|
<el-date-picker
|
v-model="dataForm.applyDate"
|
style="width: 100%"
|
type="datetime"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="状态" prop="status">
|
<el-select
|
v-model="dataForm.status"
|
filterable
|
placeholder=""
|
style="width:100%"
|
disabled
|
>
|
<el-option
|
v-for="item in statusList"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="10">
|
<el-col :span="12">
|
<el-form-item label="申请人" prop="applyUser">
|
<el-input
|
v-model="dataForm.applyUser"
|
placeholder=""
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="确认人" prop="confirmUser">
|
<el-input
|
v-model="dataForm.confirmUser"
|
placeholder=""
|
disabled
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="备注" prop="remark">
|
<el-input
|
v-model="dataForm.remark"
|
type="textarea"
|
:rows="4"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</el-tab-pane>
|
<el-tab-pane label="退库明细">
|
<return-detail
|
:visible="visible"
|
:mainId="dataForm.id"
|
:status="dataForm.status"
|
ref="returnDetail"
|
@refreshDataList="refreshDataList"
|
></return-detail>
|
</el-tab-pane>
|
</el-tabs>
|
<span slot="footer" class="dialog-footer">
|
<el-button
|
type="primary"
|
:loading="saveLoading"
|
@click="dataFormSubmit(false)"
|
>保存</el-button
|
>
|
<el-button
|
type="primary"
|
:loading="saveAndReturnLoading"
|
@click="dataFormSubmit(true)"
|
>保存并返回</el-button
|
>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import { getReturn, addReturn, putReturn } from '@/api/warehouse/return'
|
import { loadStockInCode } from '@/api/warehouse/stockincode'
|
import { dateFormat } from '@/util/date'
|
import ReturnDetail from './return-detail-index'
|
|
export default {
|
data() {
|
return {
|
visible: false,
|
dataForm: {
|
id: 0,
|
returnNo: '',
|
applyDate: '',
|
applyUser: '',
|
confirmUser: '',
|
returnType: '',
|
status: '',
|
remark: ''
|
},
|
dataRule: {
|
applyDate: [
|
{ required: true, message: '申请日期不能为空', trigger: 'blur' }
|
],
|
returnType: [
|
{ required: true, message: '退库类型不能为空', trigger: 'blur' }
|
],
|
remark: [{ required: true, message: '备注不能为空', trigger: 'blur' }]
|
},
|
receiveTypes: [],
|
statusList: [],
|
saveLoading: false,
|
saveAndReturnLoading: false
|
}
|
},
|
computed: {
|
...mapGetters(['userInfo']),
|
editable: function() {
|
if (!this.dataForm.id) {
|
return true
|
}
|
if (this.dataForm.id && this.dataForm.status == '未下发') {
|
return true
|
}
|
return false
|
}
|
},
|
components: {
|
ReturnDetail
|
},
|
created() {
|
this.initReceiveTypeSelect()
|
this.initStatusListSelect()
|
},
|
methods: {
|
init(id) {
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
getReturn(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
})
|
} else {
|
this.dataForm.applyDate = dateFormat(new Date())
|
this.dataForm.applyUser = this.userInfo.username
|
this.dataForm.status = '未下发'
|
}
|
})
|
},
|
// 表单提交
|
dataFormSubmit(flag) {
|
if (flag) {
|
this.saveAndReturnLoading = true
|
} else {
|
this.saveLoading = true
|
}
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putReturn(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.$emit('refreshDataList')
|
if (flag) {
|
this.visible = false
|
this.saveAndReturnLoading = false
|
} else {
|
this.saveLoading = false
|
}
|
})
|
} else {
|
addReturn(this.dataForm).then((response) => {
|
this.dataForm = response.data.data
|
this.$message.success('添加成功')
|
this.$emit('refreshDataList')
|
if (flag) {
|
this.visible = false
|
this.saveAndReturnLoading = false
|
} else {
|
this.saveLoading = false
|
}
|
})
|
}
|
} else {
|
this.saveAndReturnLoading = false
|
this.saveLoading = false
|
}
|
})
|
},
|
// 1.主要
|
// 获取入库类型
|
initReceiveTypeSelect() {
|
loadStockInCode(
|
Object.assign({
|
stockCodeType: 0,
|
stockCodeStatus: 1
|
})
|
).then((res) => {
|
this.receiveTypes = res.data.data
|
})
|
},
|
initStatusListSelect() {
|
this.statusList = [
|
{ value: '未下发', label: '未下发' },
|
{ value: '已下发', label: '已下发' },
|
{ value: '已处理', label: '已处理' }
|
]
|
},
|
// 2.退库明细
|
refreshDataList() {
|
this.init(this.dataForm.id)
|
this.$emit('refreshDataList')
|
}
|
}
|
}
|
</script>
|