From 07169ff81588a71fe3e9d49d6f14d9e17c7c1b71 Mon Sep 17 00:00:00 2001 From: yyy <2605810609@qq.com> Date: Fri, 6 Dec 2024 16:43:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E6=8E=A5=E5=8F=A3=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/components/pages/clues/followUp.vue | 325 ++++++------ pages/components/pages/contract/add.vue | 6 +- pages/components/pages/invoice/add.vue | 577 ++++++++++++---------- pages/components/pages/invoice/index.vue | 33 +- 4 files changed, 497 insertions(+), 444 deletions(-) diff --git a/pages/components/pages/clues/followUp.vue b/pages/components/pages/clues/followUp.vue index e90f391..7e6aea3 100644 --- a/pages/components/pages/clues/followUp.vue +++ b/pages/components/pages/clues/followUp.vue @@ -1,194 +1,195 @@ - diff --git a/pages/components/pages/invoice/add.vue b/pages/components/pages/invoice/add.vue index 0db9ccf..7282a9b 100644 --- a/pages/components/pages/invoice/add.vue +++ b/pages/components/pages/invoice/add.vue @@ -2,100 +2,106 @@ - - - - + + - - + + + - - + + - + + + + - + {{ item.text }} - + - + {{ item.text }} - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - + + + + + 图片 + + + + + + + + + + + + 附件 (pdf) + + + + + + + + {{item.name || ''}} + + + + + - - 确定提交 - 开具发票 - - - - 审核 - - - 拒绝 - + + 确定提交 @@ -114,7 +120,6 @@ 确定 - @@ -128,20 +133,17 @@ - - {{item.name}} + {{item.contractName}} - @@ -164,7 +166,7 @@ onShow } from '@dcloudio/uni-app' import { - getContractPage + getListByDeptId } from '@/api/contract' import { invoiceCreate, @@ -176,7 +178,9 @@ import { getSimpleUserList, getFlowUsers, - getSimpleUserList2 + getSimpleUserList2, + uploadFile, + deleteBpmFile } from '@/api/user' import AddressSelect from '@/components/AddressSelect/index.vue' import { @@ -185,8 +189,6 @@ } from '@/utils/util' const title = ref('申请发票') const labelPosition = ref('left') - const keyword = ref('') - const listStatus = ref('loadmore') const listStatus3 = ref('loadmore') const customerList = ref([]) const accountName = ref('') @@ -205,12 +207,25 @@ const content = ref('') const customerName = ref('') const form = ref({ - invoiceIssue: 1, - invoiceType: 1, - contractName: '', - invoiceBody: '', - invoiceName: '', - money: '', + invoiceDate: undefined, // 开票日期 + customerName: undefined, // 客户名称 + customerId: undefined, // 客户编号 + projectId: [], // 开票项目 + invoiceBody: undefined, // 开票主体 + invoiceName: undefined, // 发票抬头 + invoiceIssue: 1, // 抬头类型 | 1企业2个人3事业单位 + invoiceType: 1, // 发票类型 | 1增值税普票2增值税专票 + registerNo: undefined, // 纳税人识别号 + amount: undefined, // 开票金额 + content: undefined, // 开票内容 + unitAddress: undefined, // 开票单位地址 + unitPhone: undefined, // 开票单位联系方式 + unitBankName: undefined, // 开票单位开户行 + unitBankNo: undefined, // 开票单位银行账号 + email: undefined, // 开票单位邮箱 + contractId: undefined, // 关联合同编号 + contractInstanceId: undefined, // 关联合同审批单编号 + fileItems: [] }) const timeText = ref('') const errorType = ref('message') @@ -219,22 +234,32 @@ required: true, message: '请选择合同', trigger: ['change', 'blur'] - }, ], + }], + invoiceDate: [{ + required: true, + message: '请选择开票日期', + trigger: ['change', 'blur'] + }], invoiceBody: [{ required: true, message: '请填写开票主体', trigger: ['change', 'blur'] - }, ], + }], invoiceName: [{ required: true, message: '请填写发票抬头', trigger: ['change', 'blur'] - }, ], - money: [{ + }], + registerNo: [{ + required: true, + message: '请填写统一社会信用代码', + trigger: ['change', 'blur'] + }], + amount: [{ required: true, message: '请填写发票金额', trigger: ['change', 'blur'] - }, ], + }], }) const customerContacts = ref([]) const userList = ref([]) @@ -262,59 +287,24 @@ ]) const typeList = ref([{ name: 1, - text: '增值税普票', + text: '普票', }, { name: 2, - text: '增值税专票', + text: '专票', }, ]) - const fileList = ref([]) onLoad((e) => { - if (e.type) { - type.value = e.type - } - if (type.value == 'check') { - isCheck.value = true - title.value = '审核发票' - contractId.value = e.id - getContractInfo() - } - if (type.value == "edit") { - title.value = '编辑发票' - contractId.value = e.id - getContractInfo() - } + type.value = e.type getCustomerList() - getFlowUsersList() - }) - - onShow(() => { - - }) - - const getFlowUsersList = async () => { - let data = await getFlowUsers({ - flowType: 'invoice' - }) - let users = await getSimpleUserList2() - let userIdArr = [] - let userArr = [] - for (var i = 0; i <= data.length; i++) { - users.forEach((item, index) => { - if (data[i] == item.id) { - userIdArr.push(item.id) - userArr.push(item.nickname) - } - }) + if (type.value == 'detail') { + isCheck.value = true + title.value = '发票详情' + contractId.value = e.id + getContractInfo() } - - form.value.flowAdminIdName = userArr.join(',') - form.value.flowAdminId = userIdArr - - - } + }) const getNumber = async () => { form.value.number = await getCode() @@ -328,96 +318,53 @@ unref(selectShowRef).close() } - - // 获取商机数据详情 const getContractInfo = async () => { form.value = await getInvoice({ id: contractId.value }) - form.value.flowAdminId = form.value.flowAdminId2 - } - // 搜索 - const onSearch = () => { - page.value = 1 - lastPage.value = false - getCustomerList() - } + form.value.invoiceDate = form.value.invoiceDate.join("-") + if (form.value.fileItems.length) { + form.value.fileItems.forEach(item => { + if (getFileType(item.name) == 'image') { + imgFiles.value.push(item) + } + if (getFileType(item.name) == 'pdf') { + pdfList.value.push(item) + } + }) + } - const getCustomerList = async (isNextPage, pages) => { - await getContractPage({ - pageNo: page.value, - pageSize: pageSize.value, - relation: 'my', - name: keyword.value, - }).then(res => { - if (res) { - // 不够一页 - if (res.list.length < 10) { - 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 - } - }) - } + customerList.value.forEach(item => { + if (item.id == form.value.contractId) { + form.value.contractName = item.contractName } }) } - - // 滚动到底部加载更多 - const reachBottom = () => { - if (lastPage.value || listStatus.value == 'loading') return - listStatus.value = 'loading' - setTimeout(() => { - getCustomerList(true, ++page.value) - if (customerList.value.length >= 10) { - listStatus.value = 'loadmore'; - } else { - listStatus.values = 'loading'; - } - }, 1200) + //获取合同 + const getCustomerList = async () => { + await getListByDeptId().then(res => { + customerList.value = res + }) } - // 选择客户 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.contractId = val.id - form.value.invoiceBody = val.customerName - form.value.invoiceName = val.customerName - //customerId.value = val.id - form.value.contractName = val.name ? val.name : '' + form.value.contractName = val.contractName + form.value.contractInstanceId = val.processInstanceId selectShowClose() } - - const selectShowRef5 = ref() const selectShow5 = async () => { unref(selectShowRef5).open() @@ -426,15 +373,12 @@ unref(selectShowRef5).close() } - - const submitCheck = async (type) => { if (type == 2 && form2.value.remark == '') { uni.showToast({ icon: 'error', title: '请填写驳回理由' }) - return } form2.value.id = contractId.value @@ -452,34 +396,6 @@ }, 1000); } - const submit2 = async () => { - console.log('fileList:', fileList.value) - if (fileList.value.length == 0) { - uni.showToast({ - icon: 'error', - title: '请上传发票附件' - }) - - return - } - let fileArr = [] - fileList.value.forEach((item, index) => { - fileArr.push(item.url) - }) - const files = fileArr.join(",") - form.value.files = files - await invoiceIssue(form.value) - uni.showToast({ - title: '开具成功', - icon: 'success', - duration: 2000 - }) - prePage().$vm.isRefresh = true - setTimeout(() => { - uni.navigateBack(); - }, 1000); - - } // 提交跟进 const uForm = ref() @@ -489,57 +405,145 @@ icon: 'error', title: '请选择合同' }) - return } - uForm.value.validate().then(res => { onSubmit() }).catch(errors => { uni.showToast({ icon: 'error', - title: '校验失败' + title: '请完善发票信息' }) }) - - } - // 修确认提交 const onSubmit = async () => { - if (type.value == 'add') { - await invoiceCreate(form.value) + await invoiceCreate(form.value) + uni.showToast({ + title: '申请成功', + icon: 'success', + duration: 2000 + }) + prePage().$vm.isRefresh = true + setTimeout(() => { + uni.navigateBack(); + }, 1000); + } - uni.showToast({ - title: '申请成功', - icon: 'success', - duration: 2000 - }) - prePage().$vm.isRefresh = true - setTimeout(() => { - uni.navigateBack(); - }, 1000); - } else { - await invoiceUpdate(form.value) - uni.showToast({ - title: '修改成功', - icon: 'success', - duration: 2000 - }) - prePage().$vm.isRefresh = true - setTimeout(() => { - uni.navigateBack(); - }, 1000); - } + // 附件上传相关 + const imgFiles = ref([]) //图片列表 + const pdfList = ref([]) //pdf列表 + //删除文件 + const deleteFiles = (val, i) => { + deleteBpmFile({ + url: val.url + }).then(res => { + pdfList.value.splice(i, 1) + }) + } + //上传 + const uploadFileApi = (url) => { + return new Promise((reslove, reject) => { + uploadFile(url, true) + .then((res) => { + console.log(res, 'success') + reslove(res); + }) + .catch((err) => { + console.log(err, 'err') + reject(err); + }); + }); + } + //获取文件后缀名 + const getExtension = (fileName) => { + let arr = fileName.split('.'); + return arr[arr.length - 1]; + } + //选择图片 + const chooseImage = () => { + uni.chooseImage({ + count: 9 - imgFiles.value.length, //默认9 + sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], //从相册选择 + success: (res) => { + let promise = Promise.resolve(); + let arr = []; + uni.showLoading({ + title: '上传中' + }) + + res.tempFilePaths.forEach((item) => { + promise = promise.then(() => uploadFileApi(item)); + promise + .then((ress) => { + arr.push(1) + imgFiles.value.push({ + name: ress.name, + url: ress.url + }) + if (arr.length >= res.tempFilePaths.length) { + uni.hideLoading() + } + }) + .catch((err) => { + uni.hideLoading() + }); + }); + } + }); + } + //上传文件 pdf + const chooseFiles = () => { + wx.chooseMessageFile({ + count: 9 - pdfList.value.length, //默认100 + extension: ['pdf', '.pdf'], + success: (res) => { + let isUploadFile = true + res.tempFiles.forEach(item => { + if (getExtension(item.name) != 'pdf') { + isUploadFile = false + } + }) + if (!isUploadFile) { + uni.showToast({ + title: '请您上传pdf格式文件', + }); + return + } + let promise = Promise.resolve(); + let arr = []; + uni.showLoading({ + title: '上传中' + }) + + res.tempFiles.forEach((item) => { + promise = promise.then(() => uploadFileApi(item.path)); + promise + .then((ress) => { + arr.push(1) + pdfList.value.push({ + name: ress.name, + url: ress.url + }) + if (arr.length >= res.tempFilePaths.length) { + uni.hideLoading() + } + }) + .catch((err) => { + uni.hideLoading() + }); + }); + } + }); } \ No newline at end of file diff --git a/pages/components/pages/invoice/index.vue b/pages/components/pages/invoice/index.vue index 0020df4..e1535d8 100644 --- a/pages/components/pages/invoice/index.vue +++ b/pages/components/pages/invoice/index.vue @@ -18,7 +18,7 @@ @scrolltolower="reachBottom"> - + {{items.invoiceName}} @@ -39,11 +39,8 @@ ¥{{items.amount}} - - 审核 - - - 开具 + + 详情 @@ -140,16 +137,10 @@ } // 审核 - const onCheck = (id, type) => { - if (type == 'look') { - uni.navigateTo({ - url: '/pages/components/pages/invoice/add?id=' + id + '&type=edit' - }); - } else { - uni.navigateTo({ - url: '/pages/components/pages/invoice/add?id=' + id + '&type=check' - }); - } + const onCheck = (id) => { + uni.navigateTo({ + url: '/pages/components/pages/invoice/add?id=' + id + '&type=detail' + }); } const handleSelect = (key) => { @@ -228,12 +219,6 @@ getList() } - const onItem = (val) => { - uni.navigateTo({ - url: '/pages/components/pages/invoice/add?id=' + val + '&type=edit' - }); - } - // 添加 const onAdd = () => { uni.navigateTo({ @@ -324,10 +309,6 @@ color: $uv-info-dark; } - .entity { - color: #fff; - background-color: #FF6146; - } .primary { color: #FFF;