<script setup>
|
import request from "@/utils/request"
|
import {onMounted, ref, watch} from "vue";
|
import {useI18n} from "vue-i18n"
|
import {ElMessage} from "element-plus"
|
import {useRouter,useRoute} from "vue-router"
|
const { t } = useI18n()
|
const router = useRouter()
|
const route = useRoute()
|
|
|
let basic = ref({
|
operateType:'',
|
type : '',
|
input:''
|
})
|
let options=ref([
|
{ label: "库存组织",
|
value: "inventoryOrganization",
|
},
|
{ label: "领出",
|
value: "takeOut",
|
},
|
{ label: "材料出库类型",
|
value: "outboundType",
|
},
|
{ label: "材料返库类型",
|
value: "returningType",
|
},
|
])
|
|
let props = defineProps({
|
rowIndex:{
|
Object,
|
default: null
|
}
|
})
|
onMounted(() =>{
|
if(props.rowIndex){
|
basic.value.operateType = props.rowIndex.operateType
|
basic.value.type = props.rowIndex.type
|
basic.value.input = props.rowIndex.operateTypeName
|
}
|
})
|
|
const emit = defineEmits(['gaveParent'])
|
const saveBasicData = () =>{
|
if (basic.value.operateType[0]==='inventoryOrganization'){
|
basic.value.type='库存组织'
|
}
|
else if(basic.value.operateType[0]==='takeOut'){
|
basic.value.type='领出'
|
}
|
else if(basic.value.operateType[0]==='outboundType'){
|
basic.value.type='材料出库类型'
|
}
|
else if(basic.value.operateType[0]==='returningType'){
|
basic.value.type='材料返库类型'
|
}
|
if(basic.value.operateType[0]==='' || basic.value.input===''){
|
return
|
}
|
request.post(`/BasicWarehouse/addBasicWarehouse`, basic.value).then(res => {
|
if (res.data) {
|
ElMessage.success('保存成功')
|
emit('gaveParent', true)
|
}
|
}).catch((err)=>{
|
ElMessage.error('系统错误')
|
router.push("/login")
|
})
|
}
|
const updateBasicData = () =>{
|
let submitArr = props.rowIndex
|
submitArr.operateType = basic.value.operateType
|
submitArr.type = basic.value.type
|
submitArr.operateTypeName = basic.value.input
|
if(basic.value.input===''){
|
ElMessage.warning('请输入数据')
|
}else{
|
request.post(`/BasicWarehouse/updateBasicWarehouse`, submitArr).then(res => {
|
if (res.data) {
|
ElMessage.success('修改成功')
|
emit('gaveParent', true)
|
}
|
}).catch((err)=>{
|
ElMessage.error('系统错误')
|
router.push("/login")
|
})
|
}
|
|
|
}
|
|
const handleChange = (value) => {
|
const filterArr = options.value.filter((item) =>item.value === value[0]
|
).map((item) =>item.children.filter((item) =>item.value === value[1]))
|
}
|
|
|
</script>
|
|
<template>
|
<div>
|
<el-row>
|
<el-col :span="4">基础类型:</el-col>
|
<el-col :span="12">
|
<el-cascader
|
v-model="basic.operateType"
|
:options="options"
|
clearable
|
placeholder=""
|
:disabled="props.rowIndex"
|
/>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="4">名称:</el-col>
|
<el-col :span="12">
|
<el-input v-model="basic.input"/>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="4"></el-col>
|
<el-col :span="12">
|
<el-button v-show="!props.rowIndex" @click="saveBasicData" type="primary">新增</el-button>
|
<el-button v-show="props.rowIndex" @click="updateBasicData" type="primary">修改</el-button>
|
|
</el-col>
|
</el-row>
|
|
</div>
|
</template>
|
|
<style scoped>
|
div{
|
text-align: center;
|
}
|
.el-row{
|
margin-top: 10px;
|
}
|
</style>
|