|
@@ -2,21 +2,25 @@
|
|
|
import { getDict, type messageData, saveMessage } from '@/views/message/type'
|
|
import { getDict, type messageData, saveMessage } from '@/views/message/type'
|
|
|
import { reactive, ref, toRaw, watch } from 'vue'
|
|
import { reactive, ref, toRaw, watch } from 'vue'
|
|
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
|
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
|
|
-import { saveComplaint } from '@/views/complaint/type'
|
|
|
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
+import SliderVerify from '@/components/SliderVerify.vue'
|
|
|
|
|
|
|
|
const dickArr = ref<{ dictValue: string, dictLabel: string }[]>([{ dictLabel: '', dictValue: '' }])
|
|
const dickArr = ref<{ dictValue: string, dictLabel: string }[]>([{ dictLabel: '', dictValue: '' }])
|
|
|
const dickMap = ref()
|
|
const dickMap = ref()
|
|
|
-const messageFormRef = ref()
|
|
|
|
|
|
|
+const messageFormRef = ref<FormInstance>()
|
|
|
|
|
+const verifyVisible = ref(false)
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
|
|
+const sliderVerifyRef = ref();
|
|
|
const messageForm = reactive<messageData>({
|
|
const messageForm = reactive<messageData>({
|
|
|
- card: '',
|
|
|
|
|
- content: '',
|
|
|
|
|
|
|
+ card: '430111199911111111',
|
|
|
|
|
+ content: '123',
|
|
|
enterpriseName: '',
|
|
enterpriseName: '',
|
|
|
- name: '',
|
|
|
|
|
- phone: '',
|
|
|
|
|
|
|
+ name: '123',
|
|
|
|
|
+ phone: '13245678910',
|
|
|
type: 'personal_message',
|
|
type: 'personal_message',
|
|
|
- unifiedSocialCreditCode: ''
|
|
|
|
|
|
|
+ unifiedSocialCreditCode: '',
|
|
|
|
|
+ imageCode: 0,
|
|
|
|
|
+ imageKey: ''
|
|
|
})
|
|
})
|
|
|
const unifiedSocialCreditCodeRuleValid = (rule: any, value: any, callback: any) => {
|
|
const unifiedSocialCreditCodeRuleValid = (rule: any, value: any, callback: any) => {
|
|
|
if (messageForm.type == 'personal_message') callback()
|
|
if (messageForm.type == 'personal_message') callback()
|
|
@@ -67,12 +71,15 @@ const rules = reactive<FormRules<typeof messageForm>>({
|
|
|
]
|
|
]
|
|
|
})
|
|
})
|
|
|
const uploadMessage = (formEl: FormInstance | undefined) => {
|
|
const uploadMessage = (formEl: FormInstance | undefined) => {
|
|
|
- // console.log(messageForm)
|
|
|
|
|
- // console.log(formEl)
|
|
|
|
|
if (!formEl) return
|
|
if (!formEl) return
|
|
|
formEl.validate(async (valid) => {
|
|
formEl.validate(async (valid) => {
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
const res = await saveMessage(toRaw(messageForm))
|
|
const res = await saveMessage(toRaw(messageForm))
|
|
|
|
|
+ if (res.code == 999) {
|
|
|
|
|
+ ElMessage.warning(res.msg);
|
|
|
|
|
+ sliderVerifyRef.value.reset();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
|
ElMessage({
|
|
ElMessage({
|
|
|
message: res.msg,
|
|
message: res.msg,
|
|
@@ -88,13 +95,32 @@ const uploadMessage = (formEl: FormInstance | undefined) => {
|
|
|
type: 'error'
|
|
type: 'error'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+ sliderVerifyRef.value.reset();
|
|
|
|
|
+ verifyVisible.value = false
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+const verifyCode = (formEl: FormInstance | undefined) => {
|
|
|
|
|
+ if (!formEl) return
|
|
|
|
|
+ formEl.validate(async (valid) => {
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ verifyVisible.value = true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+const verify = (k: string, c: number) => {
|
|
|
|
|
+ messageForm.imageKey = k
|
|
|
|
|
+ messageForm.imageCode = c
|
|
|
|
|
+ uploadMessage(messageFormRef.value)
|
|
|
|
|
+}
|
|
|
const resetForm = (formEl: FormInstance | undefined) => {
|
|
const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
if (!formEl) return
|
|
|
formEl.resetFields()
|
|
formEl.resetFields()
|
|
|
}
|
|
}
|
|
|
|
|
+const resetSlider = ()=>{
|
|
|
|
|
+ ElMessage.warning('验证时长太长,请重新验证')
|
|
|
|
|
+ sliderVerifyRef.value.reset();
|
|
|
|
|
+}
|
|
|
const init = async () => {
|
|
const init = async () => {
|
|
|
let res = await getDict('message_type')
|
|
let res = await getDict('message_type')
|
|
|
dickArr.value = res.data
|
|
dickArr.value = res.data
|
|
@@ -148,10 +174,15 @@ init()
|
|
|
<el-form-item label="内容" prop="content">
|
|
<el-form-item label="内容" prop="content">
|
|
|
<el-input v-model="messageForm.content" type="textarea" rows="8" placeholder="请输入留言内容" />
|
|
<el-input v-model="messageForm.content" type="textarea" rows="8" placeholder="请输入留言内容" />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-button type="primary" @click="uploadMessage(messageFormRef)">提交投诉</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" @click="verifyCode(messageFormRef)">提交投诉</el-button>
|
|
|
<el-button @click="resetForm(messageFormRef)">重置</el-button>
|
|
<el-button @click="resetForm(messageFormRef)">重置</el-button>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <el-dialog v-model="verifyVisible" title="滑动验证" draggable width="355">
|
|
|
|
|
+ <template #default>
|
|
|
|
|
+ <SliderVerify ref="sliderVerifyRef" @verify="verify" @resetSlider="resetSlider" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|