diff --git a/pages/components/pages/contract/add.vue b/pages/components/pages/contract/add.vue index b54ff44..2756cba 100644 --- a/pages/components/pages/contract/add.vue +++ b/pages/components/pages/contract/add.vue @@ -4,72 +4,62 @@ - - - + + - - - - - - + - + - + - + - + - - - - - - + - + + + + + + @@ -105,14 +95,14 @@ - 优惠金额: + 优惠金额 - 总额: + 总额 @@ -156,37 +146,6 @@ - - - - - - - 选择客户 - - - - - - - - - - - {{item.name}} - - - - - - - - - - - - @@ -225,6 +184,9 @@ + + + @@ -288,14 +250,15 @@ import { ref, unref, - computed + computed, + reactive, + nextTick } from 'vue' import { onLoad, onShow } from '@dcloudio/uni-app' import { - getCustomerListPage, getContactsPage, getUserTreeList } from '@/api/customer' @@ -342,18 +305,11 @@ selectProductList } = storeToRefs(main) const title = ref('添加合同') - const labelPosition = ref('left') const keyword = ref('') const listStatus = ref('loadmore') - const customerList = ref([]) - const goodsName = ref('') const page = ref(1) const page3 = ref(1) - const pageSize = ref(15) - const lastPage = ref(false) - const lastPage3 = ref(false) const selectList = ref([]) - const businessData = ref({}) const type = ref('add') const contractId = ref(0) const customerId = ref(0) @@ -382,16 +338,9 @@ signatoryId: '', // 签约人编号 signatoryName: '', // 签约人名称 }) - const timeText = ref('') const errorType = ref('message') - const rules = ref({ - - }) const customerContacts = ref([]) const userList = ref([]) - const username = ref('') - const keyword3 = ref('') - const businessList = ref([]) const isCheck = ref(false) onLoad((e) => { @@ -403,8 +352,8 @@ getContractInfo() } getUserList() //获取签约人 - getCustomerList() getCompanyList() //获取公司列表 + getBusinessList() //商机 }) onShow(() => { @@ -412,6 +361,31 @@ count_price() }) + //获取商机 + const tabCurrent = ref(0) + const tabList = ref([{ + name: '我的商机', + value: 'my' + }, { + name: '下属商机', + value: 'sub' + }]) + const businessList = ref([]) + const businessParams = reactive({ + relation: 'my', + pageNo: 1 + }) + const getBusinessList = () => { + getBusinessPage(businessParams).then(res => { + businessList.value = res.list + }) + } + const tabListClick = (e) => { + tabCurrent.value = e.index + businessParams.relation = e.value + getBusinessList() + } + // 附件上传相关 const imgFiles = ref([]) //图片列表 const pdfList = ref([]) //pdf列表 @@ -536,7 +510,6 @@ } } - const selectShowRef = ref() const selectShow = () => { unref(selectShowRef).open() @@ -621,12 +594,6 @@ contractId: contractId.value }) } - // 搜索 - const onSearch = () => { - page.value = 1 - lastPage.value = false - getCustomerList() - } // 去选择产品 const selectProduct = () => { @@ -635,83 +602,6 @@ }); } - const getCustomerList = async (isNextPage, pages) => { - await getCustomerListPage({ - pageNo: page.value, - pageSize: pageSize.value, - relation: 'my', - name: keyword.value, - }).then(res => { - if (res) { - // 不够一页 - if (res.list.length < pageSize.value) { - listStatus.value = 'nomore' - } - // 最后一页 - if (res.list.length == 0) { - lastPage.value = true - } - // 第二页开始 - if (isNextPage) { - customerList.value = customerList.value.concat(res.list) - return - } - customerList.value = res.list - - if (form.value.customerId) { - customerList.value.forEach((item, index) => { - if (form.value.customerId == item.id) { - item.checked = true - customerName.value = item.name - } else { - item.checked = false - } - }) - } - } - }) - } - - - // 滚动到底部加载更多 - const reachBottom = () => { - if (lastPage.value || listStatus.value == 'loading') return - listStatus.value = 'loading' - page.value++ - getCustomerList(true, page.value) - if (customerList.value.length >= pageSize.value) { - listStatus.value = 'loadmore'; - } else { - listStatus.values = 'loading'; - } - } - - - // 选择客户 - const onItem = async (val, i) => { - customerList.value.forEach((item, index) => { - if (val.id == item.id) { - item.checked = true - val.name = val.name ? val.name : item.name; - } else { - item.checked = false - } - }) - form.value.customerId = val.id - form.value.customerName = val.name ? val.name : '' - //选择了客户 返回客户联系人 - let data = await getContactsPage({ - customerId: val.id - }) - customerContacts.value = data.list - //根据客户查找商机 - let data2 = await getBusinessPage({ - customerId: val.id - }) - businessList.value = data2.list - selectShowClose() - } - const selectShowRef2 = ref() const selectShow2 = () => { unref(selectShowRef2).open() @@ -752,34 +642,53 @@ form.value.signatoryId = userId[0] form.value.signatoryName = name } - - - + //商机 const selectShowRef4 = ref() + const uvTabsRef = ref() const selectShow4 = async () => { unref(selectShowRef4).open() + nextTick(() => { + uvTabsRef.value.init() + }) } const selectShowClose4 = () => { unref(selectShowRef4).close() } const onItem4 = async (val, i) => { + businessList.value.forEach((item, index) => { if (val.id == item.id) { item.checked = true - val.name = val.name ? val.name : item.name; } else { item.checked = false } }) + //客户信息 + form.value.customerId = val.customerId + form.value.customerName = val.customerName + //商机信息 form.value.businessId = val.id - form.value.businessName = val.name ? val.name : '' + form.value.businessName = val.name + //产品 selectList.value = await getBusinessProductListByBusinessId({ businessId: val.id }) - selectShowClose4() + //客户联系人 + getContactsPageList(val.customerId) + //关闭弹窗 + setTimeout(() => { + selectShowClose4() + }, 300) } + //获取联系人 选完商机 客户联系人 + const getContactsPageList = async (customerId) => { + let data = await getContactsPage({ + customerId + }) + customerContacts.value = data.list + } //公司 const selectShowRef6 = ref() @@ -860,14 +769,6 @@ }) return } - if (form.value.customerId == '') { - uni.showToast({ - icon: 'error', - title: '请选择客户' - }) - return - } - if (form.value.businessName == '') { uni.showToast({ icon: 'error', @@ -875,7 +776,6 @@ }) return } - if (form.value.contractMoney == '') { uni.showToast({ icon: 'error', @@ -883,11 +783,31 @@ }) return } - - if (form.value.contactsName == '') { + if (form.value.signingDate == '') { uni.showToast({ icon: 'error', - title: '请选择客户签约人' + title: '请填写签约日期' + }) + return + } + if (form.value.startDate == '') { + uni.showToast({ + icon: 'error', + title: '请填写合同开始时间' + }) + return + } + if (form.value.endDate == '') { + uni.showToast({ + icon: 'error', + title: '请填写合同结束时间' + }) + return + } + if (form.value.companyName == '') { + uni.showToast({ + icon: 'error', + title: '请选择签约公司' }) return } @@ -898,7 +818,6 @@ }) return } - if (selectList.value.length <= 0) { uni.showToast({ icon: 'error', @@ -909,7 +828,6 @@ onSubmit() } - // 修确认提交 const submitBtn = ref(false) const onSubmit = () => {