Commit 57cf79e4 authored by Step_by_step's avatar Step_by_step

feat: 融资意向接口联调

parent ec282208
...@@ -66,11 +66,20 @@ ...@@ -66,11 +66,20 @@
<DatetimePicker v-model="currentDate" type="date" title="选择年月日" @confirm="typeOnConfirm($event, 'date')" <DatetimePicker v-model="currentDate" type="date" title="选择年月日" @confirm="typeOnConfirm($event, 'date')"
@cancel="typeOnCancel" /> @cancel="typeOnCancel" />
</Popup> </Popup>
<Popup v-model:show="typeShowCascader" position="bottom">
<Cascader v-model="cascaderValue" title="请选择" :options="typeColumns" @close="typeOnCancel"
@finish="typeOnConfirm($event, 'cascader')" />
</Popup>
<Popup v-model:show="typeShowArea" position="bottom">
<Area title="请选择" :area-list="typeColumns" @confirm="typeOnConfirm($event, 'area')" />
</Popup>
</div> </div>
</template> </template>
<script setup> <script setup>
import { Popup, Picker, Cell, Field, DatetimePicker, CheckboxGroup, Checkbox } from 'vant'; import { Popup, Picker, Cell, Field, DatetimePicker, CheckboxGroup, Checkbox, Cascader, Area } from 'vant';
import { currency, toPercent } from '@/utils/textFormat' import { currency, toPercent } from '@/utils/textFormat'
import { ref } from "vue"; import { ref } from "vue";
...@@ -104,9 +113,12 @@ const emit = defineEmits(['update:modelValue']) ...@@ -104,9 +113,12 @@ const emit = defineEmits(['update:modelValue'])
const nowItem = ref({}) const nowItem = ref({})
const typeShow = ref(false) const typeShow = ref(false)
const typeShowDate = ref(false) const typeShowDate = ref(false)
const typeShowCascader = ref(false)
const typeShowArea = ref(false)
const typeColumns = ref([]) const typeColumns = ref([])
const currentDate = ref(new Date()) const currentDate = ref(new Date())
const cascaderValue = ref('')
// const miniDate = ref(new Date('1920-01-1 00:46:53')) // const miniDate = ref(new Date('1920-01-1 00:46:53'))
const currencyFormatter = (value) => currency(value.replace(/[^0-9.]*/g, '')) const currencyFormatter = (value) => currency(value.replace(/[^0-9.]*/g, ''))
...@@ -140,6 +152,12 @@ function chooser(formItem) { ...@@ -140,6 +152,12 @@ function chooser(formItem) {
typeShowDate.value = true typeShowDate.value = true
} else if (typeof formItem.select === "function") { } else if (typeof formItem.select === "function") {
formItem.select() formItem.select()
} else if (Object.prototype.toString.call(formItem.select) === '[object Object]') {
typeShowArea.value = true
typeColumns.value = formItem.select
} else if (formItem.select[0].hasOwnProperty('children')) {
typeShowCascader.value = true
typeColumns.value = formItem.select
} else { } else {
typeShow.value = true typeShow.value = true
typeColumns.value = formItem.select typeColumns.value = formItem.select
...@@ -156,6 +174,14 @@ function typeOnConfirm(value, type) { ...@@ -156,6 +174,14 @@ function typeOnConfirm(value, type) {
} }
} else if (type === 'date') { } else if (type === 'date') {
nowItem.value.value = value.toLocaleDateString() nowItem.value.value = value.toLocaleDateString()
} else if (type === 'cascader') {
nowItem.value.value = value
} else if (type === 'area') {
if (value[0].name === value[1].name) {
nowItem.value.value = value[0].name + value[2].name
} else {
nowItem.value.value = value[0].name + value[1].name + value[2].name
}
} }
typeOnCancel() typeOnCancel()
} }
...@@ -164,6 +190,8 @@ function isObject(obj) { ...@@ -164,6 +190,8 @@ function isObject(obj) {
} }
function typeOnCancel() { function typeOnCancel() {
typeShow.value = typeShowDate.value = false typeShow.value = typeShowDate.value = false
typeShowCascader.value = false;
typeShowArea.value = false;
} }
function getClass(item) { function getClass(item) {
......
...@@ -10,6 +10,12 @@ const api = { ...@@ -10,6 +10,12 @@ const api = {
getDetail(data = {}) { getDetail(data = {}) {
return post(`${baseURL}/app/api/app/financing/intention/file`, data) return post(`${baseURL}/app/api/app/financing/intention/file`, data)
}, },
saveInfo(data = {}) {
return post(`${baseURL}/app/api/app/financing/intention/save`, { userId: window.localStorage.getItem('userId'), ...data })
},
getAgent() {
return post(`${baseURL}/app/api/app/agent/file`, {})
}
}; };
export default api; export default api;
const state = {}; import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export default {
namespaced: true, export const useIntention = defineStore('formStore', () => {
state, const intentionData = ref({})
};
const agentList = ref([])
return { intentionData, agentList }
})
...@@ -3,48 +3,64 @@ ...@@ -3,48 +3,64 @@
<NavBar title="融资意向" left-arrow @click-left="goBack" /> <NavBar title="融资意向" left-arrow @click-left="goBack" />
<section class="list"> <section class="list">
<PullRefresh v-model="refreshing" @refresh="onRefresh" class="scroll"> <PullRefresh v-model="refreshing" @refresh="getList" class="scroll">
<List :finished="finished" finished-text="没有更多了" @load="loadApproval"> <List :finished="finished" finished-text="没有更多了">
<Empty v-if="!listValue.length" description="无记录" />
<ListItem v-for="item in listValue" :other_title="item.other_title" :title="item.title" :values="item.values" <ListItem v-for="item in listValue" :other_title="item.other_title" :title="item.title" :values="item.values"
@click="jump" /> @click="jump(item.intentionId)" />
</List> </List>
</PullRefresh> </PullRefresh>
</section> </section>
<Plus @click="jump" /> <Plus @click="jump('')" />
</div> </div>
</template> </template>
<script setup> <script setup>
import { goBack } from "@/utils/globalFun" import { goBack } from "@/utils/globalFun"
import { NavBar, List, PullRefresh } from "vant"; import { NavBar, List, PullRefresh, Empty } from "vant";
import ListItem from '@/components/ListItem.vue' import ListItem from '@/components/ListItem.vue'
import Plus from '@/components/Plus.vue' import Plus from '@/components/Plus.vue'
import api from "../api"; import api from "../api";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { useIntention } from '../store/index'
const listValue = $ref([ const formStore = useIntention()
{
title: 'R00001', const listValue = $ref([])
other_title: "2022-07-18",
values: [["合同金额", "状态"], ["¥ 20,000.00", "受理中"]] const getList = async () => {
let res = await api.getlist()
if (res.result === 'SUCCESS' && res.data.length) {
listValue = res.data.map(item => {
return {
title: item.intentionNumber,
other_title: item.creationDate,
values: [["合同金额", "状态"], ["¥ " + item.contractAmount, item.intentionStatusN]],
intentionId: item.intentionId
}
})
} else {
listValue = []
} }
]) refreshing = false;
}
getList()
const refreshing = $ref(true); const refreshing = $ref(true);
const finished = $ref(true); const finished = $ref(true);
const onRefresh = () => {
// 下拉重置参数,重新加载
};
const loadApproval = () => {
}
const router = useRouter(); const router = useRouter();
const jump = () => { const jump = async (intentionId = '') => {
router.push({ name: 'intention-views-intentionForm' }) if (intentionId) {
let res = await api.getDetail({ intentionId: intentionId + '' })
if (res.result === 'SUCCESS' && res.data.length) {
formStore.intentionData = res.data[0];
router.push({ name: 'intention-views-intentionForm' })
}
} else {
router.push({ name: 'intention-views-intentionForm' })
}
} }
</script> </script>
......
<template> <template>
<div class="container"> <div class="container">
<NavBar title="申请融资意向" left-arrow @click-left="goBack" /> <NavBar title="申请融资意向" left-arrow @click-left="toLast" />
<div class="content"> <div class="content">
<section class="form-area"> <section class="form-area">
<AuForm v-model="formConfig" :key="form" /> <AuForm v-model="formConfig" :key="form" />
<Field v-model="message" rows="2" autosize label="备注说明" type="textarea" maxlength="200" placeholder="最多可编写200字" <Field v-model="message" rows="2" autosize :readonly="messageDisabled" label="备注说明" type="textarea"
show-word-limit /> maxlength="200" placeholder="最多可编写200字" show-word-limit />
</section> </section>
<section class="sub"> <section class="sub">
<Button type="primary" block>确认</Button> <Button type="primary" v-show="!messageDisabled" @click="save" block>确认</Button>
</section> </section>
</div> </div>
</div> </div>
...@@ -18,50 +18,53 @@ ...@@ -18,50 +18,53 @@
<script setup> <script setup>
import { goBack } from "@/utils/globalFun" import { goBack } from "@/utils/globalFun"
import { NavBar, Button, Field } from "vant"; import { NavBar, Button, Field, Toast } from "vant";
import AuForm from '@/components/AuForm.vue'; import AuForm from '@/components/AuForm.vue';
import AuFormClass from "@/components/useAuForm"; import AuFormClass from "@/components/useAuForm";
import { useLocation } from "@/utils/location"
import { phoneReg } from "@/utils/Reg"
import { useRouter } from "vue-router";
import { useIntention } from '../store/index'
import { unref } from "vue";
import api from "../api";
import { areaList } from '@vant/area-data';
console.log(areaList);
const form = $ref(); const formStore = useIntention()
const formConfig = $ref(new AuFormClass([ let location = useLocation()
const formRaw = [
{ {
title: '合同总额', title: '合同总额',
propName: 'paymentReqDate', propName: 'contractAmount',
type: 'currency', type: 'currency',
value: '', value: '',
isRequired: true isRequired: true
}, },
{ {
title: '融资租期(月)', title: '融资租期(月)',
propName: 'paymentReqDat3e', propName: 'term',
type: 'digit', type: 'digit',
value: '', value: '',
isRequired: true isRequired: true
}, },
{ {
title: '首付款比例', title: '首付款比例',
propName: 'paymentReqDat3e', propName: 'firstGoldRatio',
type: 'rate', type: 'rate',
value: '', value: '6',
isRequired: true
},
{
title: '首付款比例',
propName: 'paymentReqDat3e',
type: 'rate',
value: '',
isRequired: true isRequired: true
}, },
{ {
title: '首付款金额', title: '首付款金额',
propName: 'paymentReqDat3e', propName: 'firstGold',
type: 'currency', type: 'currency',
value: '', value: '',
isRequired: true isRequired: true
}, },
{ {
title: '代理店', title: '代理店',
propName: 'paymentRe3qDat3e', propName: 'agentBpName',
type: 'cell', type: 'cell',
value: '', value: '',
isRequired: true, isRequired: true,
...@@ -69,41 +72,130 @@ const formConfig = $ref(new AuFormClass([ ...@@ -69,41 +72,130 @@ const formConfig = $ref(new AuFormClass([
}, },
{ {
title: '代理店联系电话', title: '代理店联系电话',
propName: 'paymentRe3qDat3e', propName: 'agentPhone',
type: 'digit', type: 'digit',
value: '', value: '',
isRequired: true, isRequired: true,
reg: phoneReg
}, },
{ {
title: '您的姓名/公司名称', title: '您的姓名/公司名称',
propName: 'paymentRe3qDat3e', propName: 'name',
type: 'input',
value: '',
isRequired: true,
},
{
title: '您的姓名/公司名称',
propName: 'paymentRe3qDat3e',
type: 'input', type: 'input',
value: '', value: '',
isRequired: true, isRequired: true,
}, },
{ {
title: '您的电话号码', title: '您的电话号码',
propName: 'digit', propName: 'phone',
type: 'input', type: 'input',
value: '', value: '',
isRequired: true, isRequired: true,
reg: phoneReg
}, },
{ {
title: '联系地址', title: '联系地址',
propName: 'paymentRe3qDat3e', propName: 'contactAddress',
type: 'cell', type: 'cell',
value: '', value: '',
isRequired: true, isRequired: true,
select: [], select: areaList,
}, },
])) ]
const form = $ref();
const message = $ref('')
const formConfig = $ref(new AuFormClass(formRaw))
const messageDisabled = $ref(false)
let agentList = []
const router = useRouter()
const toLast = () => {
formStore.intentionData = {}
goBack()
}
const save = async () => {
if (formConfig.validate()) {
let formValueObj = formConfig.getValues()
for (const key in formValueObj) {
formValueObj[key] = formValueObj[key] + '';
}
console.log(formValueObj);
if (formConfig.validate()) {
let res = await api.saveInfo({ remark: message, ...formValueObj })
if (res.success) {
Toast.success('保存成功');
} else {
Toast.fail('保存失败, 请稍后重试');
}
setTimeout(() => {
toLast()
}, 2000);
}
} else {
Toast({ message: '请将信息填写完整', position: 'top' });
}
}
const handleAgent = async () => {
if (formStore.agentList.length) {
agentList = formStore.agentList
} else {
let agentRes = await api.getAgent()
if (agentRes.success) {
agentList = agentRes.rows.map(item => ({
provinceIdN: item.provinceIdN || '',
cityIdN: item.cityIdN || '',
bpName: item.bpName,
bpCode: item.bpCode,
})
).map(item => {
return { text: item.provinceIdN + item.cityIdN + item.bpName, value: item.bpName }
}).sort((a, b) => (a.text.localeCompare(b.text)))
formStore.agentList = agentList;
}
}
formConfig.setFormValue('agentBpName', 'select', agentList)
}
handleAgent()
const getLocation = () => {
location(function (info) {
console.log(info);
let provineReg = new RegExp(info.address.province)
let cityReg = new RegExp(info.address.city)
let temp1 = agentList.filter(item => provineReg.test(item.text));
if (temp1.length) {
let temp2 = temp1.filter(item => cityReg.test(item.text))
if (temp2.length) {
formConfig.setFormValue('agentBpName', 'value', temp2[0].text)
} else {
formConfig.setFormValue('agentBpName', 'value', temp1[0].text)
}
}
}, function (error) {
console.error('定位error', error)
})
}
const getFormVal = () => {
if (formStore.intentionData?.intentionId) {
formConfig.fillValues(unref(formStore.intentionData));
message = formStore.intentionData.remark;
formConfig.setAll('disabled', () => true);
messageDisabled = true;
} else {
getLocation()
}
}
getFormVal()
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
function useLocation(onSuccess = (message) => { console.info(message) }, onError = (error) => { console.error(error) }) {
return function location() {
let options = {
"platform": "gaode",//百度(baidu)或高德(gaode)
}
let arg = {
className: "LocationBridge",
function: "location",
params: options,
successCallBack: "onSuccess",
failCallBack: "onError"
}
HandBridge.postMessage(JSON.stringify(arg));
}
}
export { useLocation }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment