|
@@ -27,14 +27,20 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" name="EnquiryPublicBlackEmailForm" setup>
|
|
|
- import { httpAction, getAction } from '/@/api/manage/manage';
|
|
|
- import pick from 'lodash.pick';
|
|
|
+import {getAction, httpAction} from '/@/api/manage/manage';
|
|
|
+import pick from 'lodash.pick';
|
|
|
|
|
|
- import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
|
|
- import { computed, nextTick, onBeforeMount, reactive, ref, toRaw } from 'vue';
|
|
|
- import { Form } from 'ant-design-vue';
|
|
|
+import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
|
|
+import {computed, onBeforeMount, reactive, ref, toRaw} from 'vue';
|
|
|
+import {Form} from 'ant-design-vue';
|
|
|
+import {useMessage} from "@/hooks/web/useMessage";
|
|
|
+
|
|
|
+const emit = defineEmits(["ok", "close"])
|
|
|
+
|
|
|
+ const { createMessage, createConfirm } = useMessage();
|
|
|
|
|
|
const useForm = Form.useForm;
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
formData: {
|
|
|
type: Object,
|
|
@@ -55,7 +61,7 @@
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- let modelRef = reactive({ email: '', blackOrWhite: null });
|
|
|
+ let modelRef = reactive({id: '', email: '', blackOrWhite: null });
|
|
|
|
|
|
const labelCol = reactive({
|
|
|
xs: { span: 24 },
|
|
@@ -114,7 +120,7 @@
|
|
|
modelRef.email = '';
|
|
|
modelRef.blackOrWhite = null;
|
|
|
} else {
|
|
|
- Object.assign(modelRef, pick(record, 'email', 'blackOrWhite'));
|
|
|
+ Object.assign(modelRef, pick(record, 'id', 'email', 'blackOrWhite'));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -132,7 +138,32 @@
|
|
|
const onSubmit = () => {
|
|
|
validate()
|
|
|
.then(() => {
|
|
|
- console.log(toRaw(modelRef));
|
|
|
+ confirmLoading.value = true;
|
|
|
+
|
|
|
+ let httpUrl = '';
|
|
|
+ let method = '';
|
|
|
+
|
|
|
+ if(!modelRef.id){
|
|
|
+ httpUrl = url.add;
|
|
|
+ method = 'post';
|
|
|
+ }else{
|
|
|
+ httpUrl = url.edit;
|
|
|
+ method = 'put';
|
|
|
+ }
|
|
|
+
|
|
|
+ let formData = toRaw(modelRef);
|
|
|
+ console.log("表单提交数据",formData)
|
|
|
+
|
|
|
+ httpAction(httpUrl, formData, method).then((res)=>{
|
|
|
+ if(res.success){
|
|
|
+ createMessage.success(res.message);
|
|
|
+ emit('ok');
|
|
|
+ }else{
|
|
|
+ createMessage.warning(res.message);
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ confirmLoading.value = false;
|
|
|
+ })
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
console.log('error', err);
|