

<template>
<Mask :width="600" :height="500" :is-show="show" @close="show=false" :title="levelId?'编辑等级':'添加等级'">
    <el-select v-model="levelId">
      <el-option
        v-for="item in options"
        :key="item.levelId"
        :label="item.name"
        :value="item.levelId"
      ></el-option>
    </el-select>
  <el-button @click="save" type="primary">保存</el-button>
  <el-button @click="close" type="primary">取消</el-button>
</Mask>
</template>
<script setup lang="ts">
import Mask from "@/components/common/Mask.vue";
import {onMounted, ref} from "vue";
import {post} from "@/utils/request.ts";
import {API} from "@/assets/config/API.ts";
const show = ref(false);
const options = ref<any>([])
const levelId = ref(0);
const curVip =ref<any>({})
const getLevelConfig = () => {
 post(API.Patient.LevelConfig.List).then((res: any) => {
   options.value = res
 })
}
const emit = defineEmits(['close'])
const save = () => {
  post(API.Patient.LevelConfig.Edit,{vipId:curVip.value.id,levelId:levelId.value}).then((res:any)=>{
    close()
  })
 }
const close = () => {
  show.value = false;
  emit('close')
};
const init = (vip:any)=>{
  curVip.value = vip
  levelId.value = vip.levelId
  show.value = true

}
defineExpose({init})
onMounted(()=>{
  getLevelConfig()
})
</script>
<style scoped lang="scss">

</style>