ticket.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <template>
  2. <div class="ticket" v-if="showTicket">
  3. <div class="search-list">
  4. <div class="search-left">
  5. <el-select v-model="logicJudge">
  6. <el-option value="and" label="并且"></el-option>
  7. <el-option value="or" label="或者"></el-option>
  8. </el-select>
  9. </div>
  10. <div class="search-right">
  11. <div class="search-type" v-for="(item, index) in searchList">
  12. <el-select v-model="item.name" style="margin-right: 20px; width: 200px" disabled>
  13. <el-option value="contactPerson" label="对接人"></el-option>
  14. <el-option value="signDate" label="签单时间"></el-option>
  15. <el-option value="ptlAgreement" label="出单协议"></el-option>
  16. <el-option value="orderType" label="订单类型"></el-option>
  17. <el-option value="signYear" label="签单年份"></el-option>
  18. <el-option value="companyId" label="保险公司"></el-option>
  19. </el-select>
  20. <el-select v-model="item.type" v-if="item.name != 'signDate'" style="margin-right: 20px; width: 150px"
  21. @change="val => signDateSelectChange(index, val)">
  22. <el-option value="等于" label="等于"></el-option>
  23. <el-option value="不等于" label="不等于"></el-option>
  24. <el-option value="包含" label="包含"></el-option>
  25. <el-option value="不包含" label="不包含"></el-option>
  26. <el-option value="为空" label="为空"></el-option>
  27. </el-select>
  28. <el-select v-model="item.type" v-else style="margin-right: 20px; width: 150px"
  29. @change="val => signDateSelectChange(index, val)">
  30. <el-option value="大于等于" label="大于等于"></el-option>
  31. <el-option value="小于等于" label="小于等于"></el-option>
  32. <el-option value="固定范围" label="固定范围"></el-option>
  33. <el-option value="不在固定范围" label="不在固定范围"></el-option>
  34. <el-option value="为空" label="为空"></el-option>
  35. </el-select>
  36. <el-select class="w-350px" v-if="item.name == 'contactPerson'" v-model="item.search" placeholder="请选择" filterable
  37. clearable :disabled="item.type == '为空'" @change="handleContactPersonChange(index, $event)">
  38. <el-option v-for="item in options" :key="item.contactPerson" :value="item.contactPerson"
  39. :label="item.contactPerson"></el-option>
  40. </el-select>
  41. <el-select class="w-350px" v-if="item.name == 'companyId'" v-model="item.search" placeholder="请选择" clearable
  42. filterable :disabled="item.type == '为空'">
  43. <el-option v-for="item in companyList" :key="item.id" :value="item.id" :label="item.name"></el-option>
  44. </el-select>
  45. <el-date-picker style="width: 350px" v-model="datesearch" v-if="item.name == 'signDate'"
  46. :type="item.type == '大于等于' || item.type == '小于等于' ? 'date' : 'daterange'" placeholder="请选择"
  47. :disabled="item.type == '为空'" @change="handlePtlAgreementChange(index, $event)" value-format="YYYY-MM-DD" />
  48. <el-select style="width: 350px" v-model="multipleSearch" v-if="item.name == 'ptlAgreement'" multiple
  49. filterable :disabled="item.type == '为空'" @change="handlePtlAgreementChange(index, $event)">
  50. <el-option v-for="item in insurerContract" :key="item.id" :value="item.id"
  51. :label="item.agreementName"></el-option>
  52. </el-select>
  53. <el-select style="width: 350px" v-model="orderTypesearch" v-if="item.name == 'orderType'" multiple
  54. :disabled="item.type == '为空'" @change="handlePtlAgreementChange(index, $event)">
  55. <el-option value="1" label="车险订单"></el-option>
  56. <el-option value="2" label="代客录单"></el-option>
  57. <el-option value="3" label="补录订单"></el-option>
  58. </el-select>
  59. <el-date-picker v-if="item.name == 'signYear'" style="width: 350px" format="YYYY" value-format="YYYY"
  60. v-model="yearrangesearch" type="yearrange" range-separator="-" :disabled="item.type == '为空'"
  61. @change="handlePtlAgreementChange(index, $event)" />
  62. <!-- <el-icon style="margin-left: 20px; cursor:pointer;"><CircleClose /></el-icon> -->
  63. </div>
  64. <el-button type="primary" @click="handleSearch">搜索</el-button>
  65. </div>
  66. </div>
  67. <div class="tips">
  68. <p>应收明细</p>
  69. <el-button type="primary" @click="addTicket">添加应收</el-button>
  70. </div>
  71. <el-table :data="tableData" style="height: calc(100% - 380px)" show-summary :summary-method="getSummaries">
  72. <template #empty>
  73. <div v-if="noData">暂无应收,点击<el-button link type="primary" @click="batchShow = true">导入应收</el-button></div>
  74. <div v-else>没有符合的应收单据~</div>
  75. </template>
  76. <el-table-column prop="licenseNo" label="车牌号"></el-table-column>
  77. <el-table-column prop="contactPerson" label="对接人"></el-table-column>
  78. <el-table-column prop="contactPersonPhone" label="对接人手机号"></el-table-column>
  79. <el-table-column prop="companyName" label="保险公司"></el-table-column>
  80. <el-table-column prop="signingTime" label="签单时间"></el-table-column>
  81. <el-table-column prop="agreementName" label="协议名称"></el-table-column>
  82. <el-table-column prop="orderType" label="订单类型"></el-table-column>
  83. <el-table-column prop="signYear" label="签单年份"></el-table-column>
  84. <el-table-column prop="orderNo" label="订单号"></el-table-column>
  85. <el-table-column prop="jqPolicyNo" label="交强保单号"></el-table-column>
  86. <el-table-column prop="syPolicyNo" label="商业保单号"></el-table-column>
  87. <el-table-column prop="jqPremium" label="交强险保费"></el-table-column>
  88. <el-table-column prop="jqSuperviseCostsProportion" label="交强险手续费比例"></el-table-column>
  89. <el-table-column prop="syPremium" label="商业险保费"></el-table-column>
  90. <el-table-column prop="sySuperviseCostsProportion" label="商业险手续费比例"></el-table-column>
  91. <el-table-column label="应收金额" prop="receivableAmount"></el-table-column>
  92. </el-table>
  93. <div class="footer">
  94. <el-button plain @click="handleBack">取消</el-button>
  95. <el-button type="primary" @click="handleSettlement">结算</el-button>
  96. </div>
  97. <el-dialog :close-on-click-modal="false" v-model="addShow" width="800" title="添加应收">
  98. <div class="add-content">
  99. <el-input v-model="addSearchValue" style="max-width: 500px" :placeholder="`请输入${placeholder}`"
  100. class="input-with-select">
  101. <template #prepend>
  102. <el-select v-model="addSelectType" placeholder="请选择" style="width: 120px"
  103. @change="handleAddSelectTypeChange">
  104. <el-option label="订单号查询" value="1" />
  105. <el-option label="交强险保单号查询" value="2" />
  106. <el-option label="商业险保单号查询" value="3" />
  107. </el-select>
  108. </template>
  109. <template #append>
  110. <el-button type="primary" @click="getUnauditedOrder">搜索</el-button>
  111. </template>
  112. </el-input>
  113. <el-table :data="selectingData" style="width: 100%;">
  114. <el-table-column prop="a" label="费用状态" width="100"></el-table-column>
  115. <el-table-column prop="signingTime" label="签单时间" width="120"></el-table-column>
  116. <el-table-column prop="licenseNo" label="车牌号" width="120"></el-table-column>
  117. <el-table-column prop="jqPolicyNo" label="交强保单号" width="120"></el-table-column>
  118. <el-table-column prop="syPolicyNo" label="商业保单号" width="120"></el-table-column>
  119. <el-table-column prop="jqPremium" label="交强保费" width="100"></el-table-column>
  120. <el-table-column prop="jqSuperviseCostsProportion" label="交强手续费比例" width="100"></el-table-column>
  121. <el-table-column prop="syPremium" label="商业保费" width="100"></el-table-column>
  122. <el-table-column prop="sySuperviseCostsProportion" label="商业手续费比例" width="100"></el-table-column>
  123. <el-table-column prop="a" label="应收金额" width="100"></el-table-column>
  124. <el-table-column label="操作" fixed="right" width="100">
  125. <template #default="scope">
  126. <el-button link type="primary" @click="handleToAdd(scope.row)">添加</el-button>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <p>已添加的应收单据</p>
  131. <el-table :data="selectedData" style="width: 100%;">
  132. <el-table-column prop="a" label="费用状态" width="100"></el-table-column>
  133. <el-table-column prop="signingTime" label="签单时间" width="120"></el-table-column>
  134. <el-table-column prop="licenseNo" label="车牌号" width="120"></el-table-column>
  135. <el-table-column prop="jqPolicyNo" label="交强保单号" width="120"></el-table-column>
  136. <el-table-column prop="syPolicyNo" label="商业保单号" width="120"></el-table-column>
  137. <el-table-column prop="jqPremium" label="交强保费" width="100"></el-table-column>
  138. <el-table-column prop="jqSuperviseCostsProportion" label="交强手续费比例" width="100"></el-table-column>
  139. <el-table-column prop="syPremium" label="商业保费" width="100"></el-table-column>
  140. <el-table-column prop="sySuperviseCostsProportion" label="商业手续费比例" width="100"></el-table-column>
  141. <el-table-column prop="a" label="应收金额" width="100"></el-table-column>
  142. <el-table-column label="操作" fixed="right" width="100">
  143. <template #default="scope">
  144. <el-button link type="primary" @click="handleDel(scope.row)">删除</el-button>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. </div>
  149. <template #footer>
  150. <el-button class="border-[#0083FF] color-[#0083FF]" plain @click="addShow = false">取消</el-button>
  151. <el-button type="primary" @click="handleAddSubmit">确定</el-button>
  152. </template>
  153. </el-dialog>
  154. </div>
  155. <el-dialog :close-on-click-modal="false" v-model="settlementDialog" width="600" title="结算">
  156. <el-form ref="CountFormRef" :model="countForm" :rules="settlementRules" label-width="120">
  157. <el-form-item label="应收金额">
  158. <el-input v-model="receivablePremium" placeholder="请输入" disabled></el-input>
  159. </el-form-item>
  160. <el-form-item prop="actualReceivedAmount" label="实收金额">
  161. <el-input-number v-model="countForm.actualReceivedAmount" style="width: 100%;" :min="0" :precision="5"
  162. controls-position="right" @change="handleChange" />
  163. </el-form-item>
  164. <el-form-item prop="settlementPaymentDifference" label="回款差额" >
  165. <el-input v-model="countForm.settlementPaymentDifference" disabled></el-input>
  166. </el-form-item>
  167. <el-form-item prop="settlementPaymentReason" label="差额原因">
  168. <el-input v-model="countForm.settlementPaymentReason" placeholder="请输入"></el-input>
  169. </el-form-item>
  170. <el-form-item prop="receivePaymentDate" label="收款日期">
  171. <el-date-picker v-model="countForm.receivePaymentDate" type="datetime" value-format="YYYY-MM-DD HH:mm:ss"
  172. format="YYYY-MM-DD HH:mm:ss" />
  173. </el-form-item>
  174. <el-form-item prop="attachmentIds" label="收款凭证" class="upload-btn">
  175. <el-upload style="margin: 0 10px 10px 0" :auto-upload="false" multiple v-if="!countForm.h"
  176. :show-file-list="false" accept=".png, .jpg, .jpeg" @change="uploadImage" drag>
  177. <el-button style="height: 0;" link size="large" icon="Plus" />
  178. </el-upload>
  179. <div class="imageDiv" v-for="(item, index) in imageUrl" :key="item">
  180. <img :src="item" />
  181. <div class="model">
  182. <span class="icon-view" @click="handelViewImage(item, index)">
  183. <el-icon>
  184. <View />
  185. </el-icon>
  186. </span>
  187. <span class="icon-del" @click="handelDelImage(item, index)">
  188. <el-icon>
  189. <Delete />
  190. </el-icon>
  191. </span>
  192. </div>
  193. </div>
  194. </el-form-item>
  195. </el-form>
  196. <template #footer>
  197. <el-button class="border-[#0083FF] color-[#0083FF]" plain @click="settlementDialog = false">取消</el-button>
  198. <el-button type="primary" @click="handelComfirm(CountFormRef)">确定结算</el-button>
  199. </template>
  200. </el-dialog>
  201. <el-dialog v-model="batchShow" width="800" title="数据导入">
  202. <div style="display: flex; align-items: center; justify-content: center; margin-bottom: 10px">
  203. 下载「标准导入模板」,编辑后上传;系统将自动匹配相关字段
  204. <el-button link type="primary" @click="downloadTemplate">下载模板</el-button>
  205. </div>
  206. <el-upload class="upload-demo " drag accept=".xls, .xlsx" :auto-upload="false" @change="uploadJYFile">
  207. <div class="flex f-c a-c">
  208. <el-icon class="el-icon--upload"><upload-filled /></el-icon>
  209. <div class="el-upload__text">
  210. 点击或将文件拖拽到这里上传
  211. </div>
  212. <a style="color: #999; font-size: 12px">目前支持的文件类型为*.xls, *.xlsx</a>
  213. </div>
  214. </el-upload>
  215. <div v-if="importModifyCallback">
  216. <div>
  217. 您将导入 <span style="color:#409eff;">{{ importModifyCallback?.failedNumber +
  218. importModifyCallback?.successNumber
  219. ||
  220. 0 }}
  221. </span> 条数据,其中 <span style="color:#409eff;">{{ importModifyCallback?.successNumber || 0 }} </span>
  222. 条正常导入;<span style="color: red;">{{ importModifyCallback?.failedNumber || 0 }}</span> 条不符合要求无法导入。
  223. </div>
  224. <el-button type="primary" link @click="downloadImportFailedData(importModifyCallback)">下载导入失败文件</el-button>
  225. </div>
  226. <template #footer>
  227. <el-button class="border-[#0083FF] color-[#0083FF]" plain @click="batchShow = false">取消</el-button>
  228. <el-button type="primary" @click="batchShow = false">确定</el-button>
  229. </template>
  230. </el-dialog>
  231. <el-image-viewer v-if="imageShow" :url-list="[bigImageUrl]" @close="imageShow = false" />
  232. </template>
  233. <script setup lang="ts">
  234. import api from '@/api'
  235. import { useRoute, useRouter } from 'vue-router'
  236. import { ElMessage, FormInstance } from "element-plus";
  237. let route = useRoute()
  238. let router = useRouter()
  239. const previousRoute = ref(router.options.history.state.back)
  240. const companyList = ref()//保险公司
  241. const CountFormRef = ref<FormInstance>()
  242. const batchShow = ref(false)//数据导入弹窗
  243. const selectedList = ref([])//选中的应收单据
  244. const options = ref()//保险公司
  245. const insurerContract = ref()//保险公司协议
  246. const multipleSearch = ref('')
  247. const orderTypesearch = ref('')
  248. const yearrangesearch = ref('')
  249. const datesearch = ref('')
  250. const countForm = ref({
  251. invoicingId: '',
  252. actualReceivedAmount: undefined,
  253. settlementPaymentDifference: '',
  254. settlementPaymentReason: '',
  255. receivePaymentDate: '',
  256. attachmentIds: [],
  257. })
  258. const receivablePremium = ref('')
  259. const settlementDialog = ref(false)//结算弹窗
  260. let settlementRules = ref({
  261. actualReceivedAmount: [{ required: true, trigger: "blur", message: "请输入" }],
  262. receivePaymentDate: [{ required: true, trigger: "change", message: "请选择" }],
  263. attachmentIds: [{ required: true, message: "请上传" }]
  264. })
  265. let imageUrl = ref([])
  266. //获取保险公司协议
  267. const getByCompanyId = () => {
  268. api.dispatchApi.getByCompanyIdt(route.query.contactPerson).then((res: any) => {
  269. if (res.code == 200) {
  270. insurerContract.value = res.data
  271. }
  272. })
  273. }
  274. // 保险公司
  275. const initCompany = () => {
  276. api.insuranceApi.leftList('').then((res: any) => {
  277. if (res.code == 200) {
  278. companyList.value = res.data
  279. }
  280. })
  281. }
  282. // 对接人改变时 赋值
  283. const handleContactPersonChange = (index: number, val: string) => {
  284. contactPerson.value = val
  285. searchList.value[index].search = val
  286. }
  287. //保险公司协议
  288. const initData = () => {
  289. // router
  290. api.financeApi.getSelectedReceivableList({ orderNos: selectedList.value.map(v => v.orderNo), searchList: searchList.value, logicJudge: logicJudge.value, }).then((res: any) => {
  291. if (res.code == 200) {
  292. tableData.value = res.data
  293. initCompanyContact()
  294. }
  295. })
  296. }
  297. let logicJudge = ref('and')
  298. let searchList = ref([
  299. {
  300. name: 'contactPerson',
  301. type: '等于',
  302. search: ''
  303. }, {
  304. name: 'signDate',
  305. type: '固定范围',
  306. search: ''
  307. }, {
  308. name: 'ptlAgreement',
  309. type: '等于',
  310. search: ''
  311. }, {
  312. name: 'orderType',
  313. type: '等于',
  314. search: ''
  315. }, {
  316. name: 'signYear',
  317. type: '等于',
  318. search: ''
  319. }, {
  320. name: 'companyId',
  321. type: '等于',
  322. search: ''
  323. },
  324. ])
  325. // 保险公司
  326. const initCompanyContact = () => {
  327. api.financeApi.queryReceivableContact({
  328. incomeIds: tableData.value.map((item: any) => item.id)
  329. }).then((res: any) => {
  330. if (res.code == 200) {
  331. options.value = res.data
  332. }
  333. })
  334. }
  335. const getqueryContractVos = async () => {
  336. api.financeApi.queryContractVos().then((res: any) => {
  337. if (res.code == 200) {
  338. options.value = res.data
  339. }
  340. })
  341. }
  342. const showTicket = ref(false)
  343. const contactPerson = ref('')
  344. if (route.query?.invoiceType) {
  345. showTicket.value = true
  346. selectedList.value = JSON.parse(route.query.selectedList || '[]')
  347. searchList.value[0].search = route.query.contactPerson || ''
  348. contactPerson.value = route.query.contactPerson || ''
  349. getByCompanyId()
  350. // 勾选数据查询对应对接人 未勾选查全部
  351. if(selectedList.value.length > 0) {
  352. initData()
  353. }else{
  354. getqueryContractVos()
  355. }
  356. } else {
  357. showTicket.value = false
  358. }
  359. const downloadTemplate = () => {
  360. api.financeApi.exportAccountsReceivableInvoiceTemplate({type:'20'}).then((res: any) => {
  361. if (res.code == 200) {
  362. const link = document.createElement('a');
  363. fetch(res.msg).then((res) => res.blob())
  364. .then((blob) => {
  365. // 将链接地址字符内容转变成blob地址
  366. link.href = URL.createObjectURL(blob)
  367. console.log(link.href)
  368. link.download = '平台结算导入模版.xlsx' //下载的文件的名字
  369. document.body.appendChild(link)
  370. link.click()
  371. })
  372. }
  373. })
  374. }
  375. let importModifyCallback = ref()// 导入数据回调
  376. const uploadJYFile = async (file) => {
  377. let files = file.raw
  378. const params = new FormData(); // 声明formData数据类型
  379. params.append("file", files);
  380. params.append("type", '20')
  381. const { code, data, msg } = await api.financeApi.importPlatformReceivableInvoice(params)
  382. if (code == 200) {
  383. importModifyCallback.value = data
  384. if (data.orderNos.length > 0) {
  385. api.financeApi.getSelectedReceivableList({ orderNos: data.orderNos }).then((res: any) => {
  386. if (res.code == 200) {
  387. tableData.value = res.data
  388. }
  389. })
  390. }
  391. ElMessage({
  392. message: msg,
  393. type: 'success'
  394. })
  395. }
  396. }
  397. const getSummaries = (param) => {
  398. const { columns, data } = param
  399. const sums: (string | VNode)[] = []
  400. // 指定需要计算的字段列表(可根据需求添加字段名)
  401. const specifiedFields = ['jqPremium', 'jqSuperviseCostsProportion','syPremium','sySuperviseCostsProportion','receivableAmount'] // 替换为您需要的字段名
  402. columns.forEach((column, index) => {
  403. if (index === 0) {
  404. sums[index] = h('div', { style: { textDecoration: 'underline' } }, [
  405. '',
  406. ])
  407. return
  408. }
  409. // 计算数字类型字段和指定字段
  410. const values = data.map((item) => {
  411. const val = item[column.property]
  412. // 排除空值
  413. if (val === '' || val === null || val === undefined) {
  414. return NaN
  415. }
  416. // 如果是数字类型,直接参与计算
  417. if (typeof val === 'number') {
  418. return val
  419. }
  420. // 如果字段在指定列表中,尝试转换为数字
  421. if (specifiedFields.includes(column.property)) {
  422. const num = Number(val)
  423. return Number.isNaN(num) ? NaN : num
  424. }
  425. // 其他情况不参与计算
  426. return NaN
  427. })
  428. if (!values.every((value) => Number.isNaN(value))) {
  429. const total = values.reduce((prev, curr) => {
  430. if (!Number.isNaN(curr)) {
  431. return prev + curr
  432. } else {
  433. return prev
  434. }
  435. }, 0)
  436. // 保留五位小数
  437. sums[index] = ` ${total.toFixed(5)}`
  438. } else {
  439. sums[index] = '-'
  440. }
  441. })
  442. return sums
  443. }
  444. // 下载导入失败文件
  445. const downloadImportFailedData = (item) => {
  446. const link = document.createElement('a');
  447. link.href = item.failFileUrl;
  448. link.download = '';
  449. // 触发下载
  450. document.body.appendChild(link);
  451. link.click();
  452. document.body.removeChild(link);
  453. }
  454. let noData = ref(true)
  455. let tableData = ref([])
  456. const addTicket = () => {
  457. addShow.value = true
  458. }
  459. const handleSearch = () => {
  460. // router
  461. api.financeApi.getSelectedReceivableList({
  462. orderNos: selectedList.value.map(item => item.orderNo),
  463. searchList: searchList.value,
  464. invoiceType: route.query.invoiceType,
  465. logicJudge: logicJudge.value,
  466. }).then((res: any) => {
  467. if (res.code == 200) {
  468. tableData.value = res.data
  469. }
  470. })
  471. }
  472. let addShow = ref(false)
  473. let addSearchValue = ref('')
  474. let placeholder = ref('订单号查询')
  475. let addSelectType = ref('1')
  476. const handleAddSelectTypeChange = (e) => {
  477. switch (e) {
  478. case '1':
  479. placeholder.value = '订单号查询'
  480. break;
  481. case '2':
  482. placeholder.value = '交强险保单号查询'
  483. break;
  484. case '3':
  485. placeholder.value = '商业险保单号查询'
  486. break;
  487. }
  488. }
  489. let selectingData = ref([])
  490. let selectedData = ref([])
  491. // 出单协议多选转换
  492. const handlePtlAgreementChange = (index: any, e: any) => {
  493. console.log(e)
  494. if (Array.isArray(e)) {
  495. searchList.value[index].search = e.join(',') || ''
  496. } else {
  497. searchList.value[index].search = e || ''
  498. }
  499. }
  500. // 签单时间选择器改变时触发
  501. const signDateSelectChange = (index: any, e: any) => {
  502. switch (e) {
  503. case '为空':
  504. searchList.value[index].search = ''
  505. break;
  506. case '大于等于':
  507. case '小于等于':
  508. searchList.value[index].search = ''
  509. datesearch.value = ''
  510. break;
  511. }
  512. }
  513. // 未审核订单查询
  514. const getUnauditedOrder = () => {
  515. api.financeApi.getUnauditedOrder(addSearchValue.value).then((res: any) => {
  516. if (res.code == 200) {
  517. selectingData.value = res.data
  518. }
  519. })
  520. }
  521. const handleDel = (row) => {
  522. selectedData.value = selectedData.value.filter(item => item.id != row.id)
  523. }
  524. const handleAddSubmit = () => {
  525. if (selectedData.value.length < 1) {
  526. ElMessage({
  527. message: '请选择要添加的数据!',
  528. type: 'warning'
  529. })
  530. } else {
  531. api.financeApi.addReceivable(selectedData.value).then((res: any) => {
  532. if (res.code == 200) {
  533. ElMessage({
  534. message: res.msg,
  535. type: 'success'
  536. })
  537. addShow.value = false
  538. }
  539. })
  540. }
  541. }
  542. const handleToAdd = (row) => {
  543. if (selectedData.value.length < 1) {
  544. selectedData.value.push(row)
  545. } else {
  546. if (!selectedData.value.some(item => item.id === row.id)) {
  547. selectedData.value.push(row)
  548. }
  549. }
  550. }
  551. let imageShow = ref(false)
  552. let bigImageUrl = ref('')
  553. const handelViewImage = (item, index) => {
  554. bigImageUrl.value = item
  555. imageShow.value = true
  556. }
  557. const handelDelImage = (item, index) => {
  558. imageUrl.value.splice(index, 1)
  559. countForm.value.attachmentIds.splice(index, 1)
  560. }
  561. // 开票并结算
  562. const handleBack = () => {
  563. if (previousRoute.value == '/platform/platformOrder') {
  564. router.back()
  565. }
  566. }
  567. const handleSettlement = () => {
  568. if (contactPerson.value == '') {
  569. ElMessage({
  570. message: '请选择对接人!',
  571. type: 'warning'
  572. })
  573. return
  574. }
  575. // 查应收金额
  576. api.financeApi.getPlatformSettlementReceivableAmount({
  577. invoiceType: "5",
  578. orderNos: tableData.value.length > 0 ? tableData.value.map(item => item.orderNo) : selectedList.value.map(item => item.orderNo),
  579. }).then((res: any) => {
  580. if (res.code == 200) {
  581. receivablePremium.value = res.data
  582. countForm.value.actualReceivedAmount = res.data
  583. }
  584. })
  585. settlementDialog.value = true
  586. }
  587. const handelComfirm = (formEl: FormInstance | undefined) => {
  588. if (!formEl) return
  589. formEl.validate((valid) => {
  590. console.log(countForm.value)
  591. if (valid) {
  592. api.financeApi.platformSettlement({
  593. settlementVo: countForm.value,
  594. invoicingVo: {
  595. incomeIds: tableData.value.map(item => item.id),
  596. orderNos: tableData.value.map(item => item.orderNo),
  597. contactPerson: contactPerson.value,
  598. receivablePremium: receivablePremium.value,
  599. invoiceType: "5"
  600. }
  601. }).then((res: any) => {
  602. if (res.code == 200) {
  603. ElMessage({
  604. message: res.msg,
  605. type: 'success'
  606. })
  607. settlementDialog.value = false
  608. if (previousRoute.value == '/platform/platformOrder') {
  609. setTimeout(() => {
  610. router.back()
  611. }, 1000)
  612. }else{
  613. setTimeout(() => {
  614. window.location.reload()
  615. }, 1000)
  616. }
  617. } else {
  618. }
  619. })
  620. }
  621. })
  622. }
  623. const uploadImage = async (file, fileList) => {
  624. let files = file.raw
  625. const params = new FormData(); // 声明formData数据类型
  626. params.append("file", files);
  627. params.append("type", "image");
  628. const { code, data, msg } = await api.commonApi.fileUpload(params)
  629. if (code == 200) {
  630. imageUrl.value.push(data.downloadUrl)
  631. countForm.value.attachmentIds.push(data.id)
  632. }
  633. }
  634. const handleChange = async () => {
  635. const num = await calSub(countForm.value.actualReceivedAmount, receivablePremium.value)
  636. countForm.value.settlementPaymentDifference = num
  637. }
  638. /**
  639. * 计算两个数值的差值(被减数 - 减数)
  640. * @param minuend 被减数
  641. * @param subtrahend 减数
  642. * @returns 差值,若接口无数据则返回 0
  643. */
  644. const calSub = async (minuend: number = 0, subtrahend: number) => {
  645. const res = await api.financeApi.calSub({ minuend, subtrahend })
  646. return res.data || 0
  647. }
  648. const openSettlement = (list, name) => {
  649. contactPerson.value = name
  650. selectedList.value = list
  651. handleSettlement()
  652. initData()
  653. }
  654. onMounted(() => {
  655. initCompany()
  656. })
  657. defineExpose({
  658. openSettlement,
  659. });
  660. </script>
  661. <style scoped lang="scss">
  662. .ticket {
  663. height: calc(100vh - 135px);
  664. width: calc(100% - 24px);
  665. margin: 12px auto;
  666. padding: 12px;
  667. background: #FFFFFF;
  668. overflow-y: auto;
  669. .search-list {
  670. display: flex;
  671. align-items: center;
  672. justify-content: flex-start;
  673. .search-left {
  674. width: 150px;
  675. display: flex;
  676. align-items: center;
  677. justify-content: center;
  678. margin-right: 20px;
  679. }
  680. .search-right {
  681. width: 700px;
  682. .search-type {
  683. display: flex;
  684. align-items: center;
  685. justify-content: flex-start;
  686. margin-bottom: 10px;
  687. }
  688. }
  689. }
  690. .tips {
  691. display: flex;
  692. align-items: center;
  693. justify-content: flex-start;
  694. p {
  695. margin-right: 30px;
  696. }
  697. }
  698. .footer {
  699. width: 100%;
  700. position: absolute;
  701. left: 0;
  702. bottom: 0;
  703. display: flex;
  704. align-items: center;
  705. justify-content: center;
  706. height: 80px;
  707. }
  708. }
  709. .imageDiv {
  710. position: relative;
  711. width: 80px;
  712. height: 80px;
  713. margin: 0 10px 10px 0;
  714. &:hover {
  715. .model {
  716. display: flex;
  717. align-items: center;
  718. justify-content: center;
  719. background-color: rgba(0, 0, 0, .3);
  720. }
  721. }
  722. img {
  723. display: block;
  724. width: 100%;
  725. height: 100%;
  726. border-radius: 4px;
  727. }
  728. .model {
  729. position: absolute;
  730. width: 80px;
  731. height: 80px;
  732. border-radius: 4px;
  733. display: none;
  734. top: 0;
  735. left: 0;
  736. .icon-view,
  737. .icon-del {
  738. color: #FFFFFF;
  739. margin: 0 10px;
  740. cursor: pointer;
  741. }
  742. }
  743. }
  744. .upload-btn {
  745. :deep(.el-button) {
  746. width: 80px;
  747. height: 80px;
  748. font-size: 30px;
  749. color: #ccc;
  750. }
  751. }
  752. </style>