<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: t('ingredientsStock.inventoryOrganization'),
|
value: "inventoryOrganization",
|
},
|
{ label: t('warehouseBasicData.takeOut'),
|
value: "takeOut",
|
},
|
{ label: t('ingredientsStock.materialOutboundType'),
|
value: "outboundType",
|
},
|
{ label: t('ingredientsStock.materialReturnType'),
|
value: "returningType",
|
},
|
/*{ label: t('ingredients.originalFilm'),
|
value: "originalFilm",
|
},
|
{ label: t('ingredients.accessories'),
|
value: "accessories",
|
},*/
|
])
|
|
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=t('ingredientsStock.inventoryOrganization')
|
}
|
else if(basic.value.operateType[0]==='takeOut'){
|
basic.value.type=t('warehouseBasicData.takeOut')
|
}
|
else if(basic.value.operateType[0]==='outboundType'){
|
basic.value.type=t('ingredientsStock.materialOutboundType')
|
}
|
else if(basic.value.operateType[0]==='returningType'){
|
basic.value.type=t('ingredientsStock.materialReturnType')
|
}
|
/*else if(basic.value.operateType[0]==='originalFilm'){
|
basic.value.type=t('ingredients.originalFilm')
|
}
|
else if(basic.value.operateType[0]==='accessories'){
|
basic.value.type=t('ingredients.accessories')
|
}*/
|
if(basic.value.operateType[0]==='' || basic.value.input===''){
|
return
|
}
|
request.post(`/BasicWarehouse/addBasicWarehouse`, basic.value).then(res => {
|
if (res.data) {
|
ElMessage.success(t('basicData.msg.saveSuccess'))
|
emit('gaveParent', true)
|
}
|
}).catch((err)=>{
|
ElMessage.error(t('basicData.msg.ServerConnectionError'))
|
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(t('ingredients.pleaseEnterData'))
|
}else{
|
request.post(`/BasicWarehouse/updateBasicWarehouse`, submitArr).then(res => {
|
if (res.data) {
|
ElMessage.success(t('basicData.msg.saveSuccess'))
|
emit('gaveParent', true)
|
}
|
}).catch((err)=>{
|
ElMessage.error(t('basicData.msg.ServerConnectionError'))
|
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">{{$t('orderBasicData.basicType')}}:</el-col>
|
<el-col :span="12">
|
<el-cascader
|
v-model="basic.operateType"
|
:options="options"
|
clearable
|
:placeholder="$t('processCard.pleaseSelect')"
|
:disabled="props.rowIndex"
|
/>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="4">{{$t('orderBasicData.name')}}:</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">{{$t('basicData.insert')}}</el-button>
|
<el-button v-show="props.rowIndex" @click="updateBasicData" type="primary">{{$t('basicData.update')}}</el-button>
|
|
</el-col>
|
</el-row>
|
|
</div>
|
</template>
|
|
<style scoped>
|
div{
|
text-align: center;
|
}
|
.el-row{
|
margin-top: 10px;
|
}
|
</style>
|