editWeChatUser.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div class="weChatUser-container">
  3. <el-dialog v-model="state.isShowDialog" draggable :close-on-click-modal="false" width="700px">
  4. <template #header>
  5. <div style="color: #fff">
  6. <el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
  7. <span> {{ props.title }} </span>
  8. </div>
  9. </template>
  10. <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
  11. <el-row :gutter="35">
  12. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  13. <el-form-item label="昵称" prop="nickName" :rules="[{ required: true, message: '昵称不能为空', trigger: 'blur' }]">
  14. <el-input v-model="state.ruleForm.nickName" placeholder="昵称" clearable />
  15. </el-form-item>
  16. </el-col>
  17. </el-row>
  18. </el-form>
  19. <template #footer>
  20. <span class="dialog-footer">
  21. <el-button @click="cancel">取 消</el-button>
  22. <el-button type="primary" @click="submit">确 定</el-button>
  23. </span>
  24. </template>
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script lang="ts" setup name="sysEditWeChatUser">
  29. import { reactive, ref } from 'vue';
  30. import { getAPI } from '/@/utils/axios-utils';
  31. import { SysWechatUserApi } from '/@/api-services/api';
  32. import { SysWechatUser } from '/@/api-services/models';
  33. const props = defineProps({
  34. title: String,
  35. });
  36. const emits = defineEmits(['handleQuery']);
  37. const ruleFormRef = ref();
  38. const state = reactive({
  39. isShowDialog: false,
  40. ruleForm: {} as SysWechatUser,
  41. });
  42. // 打开弹窗
  43. const openDialog = (row: any) => {
  44. state.ruleForm = JSON.parse(JSON.stringify(row));
  45. state.isShowDialog = true;
  46. ruleFormRef.value?.resetFields();
  47. };
  48. // 关闭弹窗
  49. const closeDialog = () => {
  50. emits('handleQuery');
  51. state.isShowDialog = false;
  52. };
  53. // 取消
  54. const cancel = () => {
  55. state.isShowDialog = false;
  56. };
  57. // 提交
  58. const submit = () => {
  59. ruleFormRef.value.validate(async (valid: boolean) => {
  60. if (!valid) return;
  61. if (state.ruleForm.id != undefined && state.ruleForm.id > 0) {
  62. await getAPI(SysWechatUserApi).apiSysWechatUserUpdatePost(state.ruleForm);
  63. } else {
  64. await getAPI(SysWechatUserApi).apiSysWechatUserAddPost(state.ruleForm);
  65. }
  66. closeDialog();
  67. });
  68. };
  69. // 导出对象
  70. defineExpose({ openDialog });
  71. </script>