Commit 57cf79e4 authored by Step_by_step's avatar Step_by_step

feat: 融资意向接口联调

parent ec282208
......@@ -66,11 +66,20 @@
<DatetimePicker v-model="currentDate" type="date" title="选择年月日" @confirm="typeOnConfirm($event, 'date')"
@cancel="typeOnCancel" />
</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>
</template>
<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 { ref } from "vue";
......@@ -104,9 +113,12 @@ const emit = defineEmits(['update:modelValue'])
const nowItem = ref({})
const typeShow = ref(false)
const typeShowDate = ref(false)
const typeShowCascader = ref(false)
const typeShowArea = ref(false)
const typeColumns = ref([])
const currentDate = ref(new Date())
const cascaderValue = ref('')
// const miniDate = ref(new Date('1920-01-1 00:46:53'))
const currencyFormatter = (value) => currency(value.replace(/[^0-9.]*/g, ''))
......@@ -140,6 +152,12 @@ function chooser(formItem) {
typeShowDate.value = true
} else if (typeof formItem.select === "function") {
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 {
typeShow.value = true
typeColumns.value = formItem.select
......@@ -156,6 +174,14 @@ function typeOnConfirm(value, type) {
}
} else if (type === 'date') {
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()
}
......@@ -164,6 +190,8 @@ function isObject(obj) {
}
function typeOnCancel() {
typeShow.value = typeShowDate.value = false
typeShowCascader.value = false;
typeShowArea.value = false;
}
function getClass(item) {
......
......@@ -10,6 +10,12 @@ const api = {
getDetail(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;
const state = {};
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export default {
namespaced: true,
state,
};
export const useIntention = defineStore('formStore', () => {
const intentionData = ref({})
const agentList = ref([])
return { intentionData, agentList }
})
......@@ -3,48 +3,64 @@
<NavBar title="融资意向" left-arrow @click-left="goBack" />
<section class="list">
<PullRefresh v-model="refreshing" @refresh="onRefresh" class="scroll">
<List :finished="finished" finished-text="没有更多了" @load="loadApproval">
<PullRefresh v-model="refreshing" @refresh="getList" class="scroll">
<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"
@click="jump" />
@click="jump(item.intentionId)" />
</List>
</PullRefresh>
</section>
<Plus @click="jump" />
<Plus @click="jump('')" />
</div>
</template>
<script setup>
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 Plus from '@/components/Plus.vue'
import api from "../api";
import { useRouter } from "vue-router";
import { useIntention } from '../store/index'
const listValue = $ref([
{
title: 'R00001',
other_title: "2022-07-18",
values: [["合同金额", "状态"], ["¥ 20,000.00", "受理中"]]
const formStore = useIntention()
const listValue = $ref([])
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 finished = $ref(true);
const onRefresh = () => {
// 下拉重置参数,重新加载
};
const loadApproval = () => {
}
const router = useRouter();
const jump = () => {
router.push({ name: 'intention-views-intentionForm' })
const jump = async (intentionId = '') => {
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>
......
<template>
<div class="container">
<NavBar title="申请融资意向" left-arrow @click-left="goBack" />
<NavBar title="申请融资意向" left-arrow @click-left="toLast" />
<div class="content">
<section class="form-area">
<AuForm v-model="formConfig" :key="form" />
<Field v-model="message" rows="2" autosize label="备注说明" type="textarea" maxlength="200" placeholder="最多可编写200字"
show-word-limit />
<Field v-model="message" rows="2" autosize :readonly="messageDisabled" label="备注说明" type="textarea"
maxlength="200" placeholder="最多可编写200字" show-word-limit />
</section>
<section class="sub">
<Button type="primary" block>确认</Button>
<Button type="primary" v-show="!messageDisabled" @click="save" block>确认</Button>
</section>
</div>
</div>
......@@ -18,50 +18,53 @@
<script setup>
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 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 formConfig = $ref(new AuFormClass([
const formStore = useIntention()
let location = useLocation()
const formRaw = [
{
title: '合同总额',
propName: 'paymentReqDate',
propName: 'contractAmount',
type: 'currency',
value: '',
isRequired: true
},
{
title: '融资租期(月)',
propName: 'paymentReqDat3e',
propName: 'term',
type: 'digit',
value: '',
isRequired: true
},
{
title: '首付款比例',
propName: 'paymentReqDat3e',
propName: 'firstGoldRatio',
type: 'rate',
value: '',
isRequired: true
},
{
title: '首付款比例',
propName: 'paymentReqDat3e',
type: 'rate',
value: '',
value: '6',
isRequired: true
},
{
title: '首付款金额',
propName: 'paymentReqDat3e',
propName: 'firstGold',
type: 'currency',
value: '',
isRequired: true
},
{
title: '代理店',
propName: 'paymentRe3qDat3e',
propName: 'agentBpName',
type: 'cell',
value: '',
isRequired: true,
......@@ -69,41 +72,130 @@ const formConfig = $ref(new AuFormClass([
},
{
title: '代理店联系电话',
propName: 'paymentRe3qDat3e',
propName: 'agentPhone',
type: 'digit',
value: '',
isRequired: true,
reg: phoneReg
},
{
title: '您的姓名/公司名称',
propName: 'paymentRe3qDat3e',
type: 'input',
value: '',
isRequired: true,
},
{
title: '您的姓名/公司名称',
propName: 'paymentRe3qDat3e',
propName: 'name',
type: 'input',
value: '',
isRequired: true,
},
{
title: '您的电话号码',
propName: 'digit',
propName: 'phone',
type: 'input',
value: '',
isRequired: true,
reg: phoneReg
},
{
title: '联系地址',
propName: 'paymentRe3qDat3e',
propName: 'contactAddress',
type: 'cell',
value: '',
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>
<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