#set($a="#")
<template>
  <el-dialog title="修改${entity.name}" v-model="show" width="400px" destroy-on-close append-to-body draggable>
    <el-form label-width="120px">
#foreach($item in $entity.all)
#if($item.update && !$item.updateDefault && !$item.isId)
      <el-form-item label="${item.name}" prop="${item.toLowerName()}">
        <el-input v-model="form.${item.toLowerName()}" placeholder="${item.name}" />
      </el-form-item>
#else
      <el-form-item label="${item.name}" prop="${item.toLowerName()}">
        {{ form.${item.toLowerName()} }}
      </el-form-item>
#end
#end
    </el-form>
    <template ${a}footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="show = false">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, getCurrentInstance } from 'vue'
import { ElLoading, ElMessage } from 'element-plus'
import * as api from '../../api/${entity.toSimpleLowerName()}'


const emit = defineEmits(["success"])

const { proxy } = getCurrentInstance()

const form = ref({});
const show = ref(false);

const open = async (obj = {}) => {
  form.value = { ...obj };
  show.value = true;
}

const submitForm = () => {
  let loading = ElLoading.service({ fullscreen: true, lock: true, background: '${a}0001' })
  api.doUpdate(form.value).then(r=>{
    ElMessage.success("修改成功")
    show.value = false
    emit("success", form.value)
  }).finally(()=>{
    loading.close()
  })
}


defineExpose({ open });
</script>

<style lang="scss" scoped></style>