editWeChatUser.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div class="weChatUser-container">
  3. <el-dialog v-model="state.isShowDialog" draggable width="600px">
  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" size="default" label-width="80px">
  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" size="default">取 消</el-button>
  22. <el-button type="primary" @click="submit" size="default">确 定</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 mittBus from '/@/utils/mitt';
  31. import { getAPI } from '/@/utils/axios-utils';
  32. import { SysWechatUserApi } from '/@/api-services/api';
  33. import { SysWechatUser } from '/@/api-services/models';
  34. const props = defineProps({
  35. title: String,
  36. });
  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. };
  47. // 关闭弹窗
  48. const closeDialog = () => {
  49. mittBus.emit('submitRefresh');
  50. state.isShowDialog = false;
  51. };
  52. // 取消
  53. const cancel = () => {
  54. state.isShowDialog = false;
  55. };
  56. // 提交
  57. const submit = () => {
  58. ruleFormRef.value.validate(async (valid: boolean) => {
  59. if (!valid) return;
  60. if (state.ruleForm.id != undefined && state.ruleForm.id > 0) {
  61. await getAPI(SysWechatUserApi).apiSysWechatUserUpdatePost(state.ruleForm);
  62. } else {
  63. await getAPI(SysWechatUserApi).apiSysWechatUserAddPost(state.ruleForm);
  64. }
  65. closeDialog();
  66. });
  67. };
  68. // 导出对象
  69. defineExpose({ openDialog });
  70. </script>