ticket.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  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="请选择"
  37. filterable 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. <div v-if="uploadMsg" class="text-red">上传错误信息:{{ uploadMsg }}</div>
  227. <template #footer>
  228. <el-button class="border-[#0083FF] color-[#0083FF]" plain @click="batchShow = false,uploadMsg = null">取消</el-button>
  229. <el-button type="primary" @click="batchShow = false,uploadMsg = null">确定</el-button>
  230. </template>
  231. </el-dialog>
  232. <el-image-viewer v-if="imageShow" :url-list="[bigImageUrl]" @close="imageShow = false" />
  233. </template>
  234. <script setup lang="ts">
  235. import api from '@/api'
  236. import { useRoute, useRouter } from 'vue-router'
  237. import { ElMessage, FormInstance } from "element-plus";
  238. let route = useRoute()
  239. let router = useRouter()
  240. const previousRoute = ref(router.options.history.state.back)
  241. const companyList = ref()//保险公司
  242. const CountFormRef = ref<FormInstance>()
  243. const batchShow = ref(false)//数据导入弹窗
  244. const selectedList = ref([])//选中的应收单据
  245. const options = ref()//保险公司
  246. const insurerContract = ref()//保险公司协议
  247. const multipleSearch = ref('')
  248. const orderTypesearch = ref('')
  249. const yearrangesearch = ref('')
  250. const datesearch = ref('')
  251. const countForm = ref({
  252. invoicingId: '',
  253. actualReceivedAmount: undefined,
  254. settlementPaymentDifference: '',
  255. settlementPaymentReason: '',
  256. receivePaymentDate: '',
  257. attachmentIds: [],
  258. })
  259. const receivablePremium = ref('')
  260. const settlementDialog = ref(false)//结算弹窗
  261. let settlementRules = ref({
  262. actualReceivedAmount: [{ required: true, trigger: "blur", message: "请输入" }],
  263. receivePaymentDate: [{ required: true, trigger: "change", message: "请选择" }],
  264. attachmentIds: [{ required: true, message: "请上传" }]
  265. })
  266. let imageUrl = ref([])
  267. //获取保险公司协议
  268. const getByCompanyId = () => {
  269. api.dispatchApi.getByCompanyIdt(route.query.contactPerson).then((res: any) => {
  270. if (res.code == 200) {
  271. insurerContract.value = res.data
  272. }
  273. })
  274. }
  275. // 保险公司
  276. const initCompany = () => {
  277. api.insuranceApi.leftList('').then((res: any) => {
  278. if (res.code == 200) {
  279. companyList.value = res.data
  280. }
  281. })
  282. }
  283. // 对接人改变时 赋值
  284. const handleContactPersonChange = (index: number, val: string) => {
  285. contactPerson.value = val
  286. searchList.value[index].search = val
  287. }
  288. //保险公司协议
  289. const initData = () => {
  290. // router
  291. api.financeApi.getSelectedReceivableList({ orderNos: selectedList.value.map(v => v.orderNo), searchList: searchList.value, logicJudge: logicJudge.value, }).then((res: any) => {
  292. if (res.code == 200) {
  293. tableData.value = res.data
  294. initCompanyContact()
  295. }
  296. })
  297. }
  298. let logicJudge = ref('and')
  299. let searchList = ref([
  300. {
  301. name: 'contactPerson',
  302. type: '等于',
  303. search: ''
  304. }, {
  305. name: 'signDate',
  306. type: '固定范围',
  307. search: ''
  308. }, {
  309. name: 'ptlAgreement',
  310. type: '等于',
  311. search: ''
  312. }, {
  313. name: 'orderType',
  314. type: '等于',
  315. search: ''
  316. }, {
  317. name: 'signYear',
  318. type: '等于',
  319. search: ''
  320. }, {
  321. name: 'companyId',
  322. type: '等于',
  323. search: ''
  324. },
  325. ])
  326. // 保险公司
  327. const initCompanyContact = () => {
  328. api.financeApi.queryReceivableContact({
  329. incomeIds: tableData.value.map((item: any) => item.id)
  330. }).then((res: any) => {
  331. if (res.code == 200) {
  332. options.value = res.data
  333. }
  334. })
  335. }
  336. const getqueryContractVos = async () => {
  337. api.financeApi.queryContractVos().then((res: any) => {
  338. if (res.code == 200) {
  339. options.value = res.data
  340. }
  341. })
  342. }
  343. const showTicket = ref(false)
  344. const contactPerson = ref('')
  345. if (route.query?.invoiceType) {
  346. showTicket.value = true
  347. selectedList.value = JSON.parse(route.query.selectedList || '[]')
  348. searchList.value[0].search = route.query.contactPerson || ''
  349. contactPerson.value = route.query.contactPerson || ''
  350. getByCompanyId()
  351. // 勾选数据查询对应对接人 未勾选查全部
  352. if (selectedList.value.length > 0) {
  353. initData()
  354. } else {
  355. getqueryContractVos()
  356. }
  357. } else {
  358. showTicket.value = false
  359. }
  360. const downloadTemplate = () => {
  361. api.financeApi.exportAccountsReceivableInvoiceTemplate({ type: '20' }).then((res: any) => {
  362. if (res.code == 200) {
  363. const link = document.createElement('a');
  364. fetch(res.msg).then((res) => res.blob())
  365. .then((blob) => {
  366. // 将链接地址字符内容转变成blob地址
  367. link.href = URL.createObjectURL(blob)
  368. console.log(link.href)
  369. link.download = '平台结算导入模版.xlsx' //下载的文件的名字
  370. document.body.appendChild(link)
  371. link.click()
  372. })
  373. }
  374. })
  375. }
  376. let importModifyCallback = ref()// 导入数据回调
  377. let uploadMsg = ref(null);//上传失败信息
  378. const uploadJYFile = async (file) => {
  379. let files = file.raw
  380. const params = new FormData(); // 声明formData数据类型
  381. params.append("file", files);
  382. params.append("type", '20')
  383. const { code, data, msg } = await api.financeApi.importPlatformReceivableInvoice(params)
  384. if (code == 200) {
  385. importModifyCallback.value = data
  386. if (data.orderNos.length > 0) {
  387. batchShow.value = false;
  388. api.financeApi.getSelectedReceivableList({ orderNos: data.orderNos }).then((res: any) => {
  389. if (res.code == 200) {
  390. tableData.value = res.data
  391. }
  392. })
  393. }
  394. ElMessage({
  395. message: msg,
  396. type: 'success'
  397. })
  398. }else{
  399. uploadMsg.value = msg
  400. console.log(uploadMsg.value)
  401. }
  402. }
  403. const getSummaries = (param) => {
  404. const { columns, data } = param
  405. const sums: (string | VNode)[] = []
  406. // 指定需要计算的字段列表(可根据需求添加字段名)
  407. const specifiedFields = ['jqPremium', 'jqSuperviseCostsProportion', 'syPremium', 'sySuperviseCostsProportion', 'receivableAmount'] // 替换为您需要的字段名
  408. columns.forEach((column, index) => {
  409. if (index === 0) {
  410. sums[index] = h('div', { style: { textDecoration: 'underline' } }, [
  411. '',
  412. ])
  413. return
  414. }
  415. // 计算数字类型字段和指定字段
  416. const values = data.map((item) => {
  417. const val = item[column.property]
  418. // 排除空值
  419. if (val === '' || val === null || val === undefined) {
  420. return NaN
  421. }
  422. // 如果是数字类型,直接参与计算
  423. if (typeof val === 'number') {
  424. return val
  425. }
  426. // 如果字段在指定列表中,尝试转换为数字
  427. if (specifiedFields.includes(column.property)) {
  428. const num = Number(val)
  429. return Number.isNaN(num) ? NaN : num
  430. }
  431. // 其他情况不参与计算
  432. return NaN
  433. })
  434. if (!values.every((value) => Number.isNaN(value))) {
  435. const total = values.reduce((prev, curr) => {
  436. if (!Number.isNaN(curr)) {
  437. return prev + curr
  438. } else {
  439. return prev
  440. }
  441. }, 0)
  442. // 保留五位小数
  443. sums[index] = ` ${total.toFixed(5)}`
  444. } else {
  445. sums[index] = '-'
  446. }
  447. })
  448. return sums
  449. }
  450. // 下载导入失败文件
  451. const downloadImportFailedData = (item) => {
  452. const link = document.createElement('a');
  453. link.href = item.failFileUrl;
  454. link.download = '';
  455. // 触发下载
  456. document.body.appendChild(link);
  457. link.click();
  458. document.body.removeChild(link);
  459. }
  460. let noData = ref(true)
  461. let tableData = ref([])
  462. const addTicket = () => {
  463. addShow.value = true
  464. }
  465. const handleSearch = () => {
  466. // router
  467. api.financeApi.getSelectedReceivableList({
  468. orderNos: selectedList.value.map(item => item.orderNo),
  469. searchList: searchList.value,
  470. invoiceType: route.query.invoiceType,
  471. logicJudge: logicJudge.value,
  472. }).then((res: any) => {
  473. if (res.code == 200) {
  474. tableData.value = res.data
  475. }
  476. })
  477. }
  478. let addShow = ref(false)
  479. let addSearchValue = ref('')
  480. let placeholder = ref('订单号查询')
  481. let addSelectType = ref('1')
  482. const handleAddSelectTypeChange = (e) => {
  483. switch (e) {
  484. case '1':
  485. placeholder.value = '订单号查询'
  486. break;
  487. case '2':
  488. placeholder.value = '交强险保单号查询'
  489. break;
  490. case '3':
  491. placeholder.value = '商业险保单号查询'
  492. break;
  493. }
  494. }
  495. let selectingData = ref([])
  496. let selectedData = ref([])
  497. // 出单协议多选转换
  498. const handlePtlAgreementChange = (index: any, e: any) => {
  499. console.log(e)
  500. if (Array.isArray(e)) {
  501. searchList.value[index].search = e.join(',') || ''
  502. } else {
  503. searchList.value[index].search = e || ''
  504. }
  505. }
  506. // 签单时间选择器改变时触发
  507. const signDateSelectChange = (index: any, e: any) => {
  508. switch (e) {
  509. case '为空':
  510. searchList.value[index].search = ''
  511. break;
  512. case '大于等于':
  513. case '小于等于':
  514. searchList.value[index].search = ''
  515. datesearch.value = ''
  516. break;
  517. }
  518. }
  519. // 未审核订单查询
  520. const getUnauditedOrder = () => {
  521. api.financeApi.getUnauditedOrder(addSearchValue.value).then((res: any) => {
  522. if (res.code == 200) {
  523. selectingData.value = res.data
  524. }
  525. })
  526. }
  527. const handleDel = (row) => {
  528. selectedData.value = selectedData.value.filter(item => item.id != row.id)
  529. }
  530. const handleAddSubmit = () => {
  531. if (selectedData.value.length < 1) {
  532. ElMessage({
  533. message: '请选择要添加的数据!',
  534. type: 'warning'
  535. })
  536. } else {
  537. api.financeApi.addReceivable(selectedData.value).then((res: any) => {
  538. if (res.code == 200) {
  539. ElMessage({
  540. message: res.msg,
  541. type: 'success'
  542. })
  543. addShow.value = false
  544. }
  545. })
  546. }
  547. }
  548. const handleToAdd = (row) => {
  549. if (selectedData.value.length < 1) {
  550. selectedData.value.push(row)
  551. } else {
  552. if (!selectedData.value.some(item => item.id === row.id)) {
  553. selectedData.value.push(row)
  554. }
  555. }
  556. }
  557. let imageShow = ref(false)
  558. let bigImageUrl = ref('')
  559. const handelViewImage = (item, index) => {
  560. bigImageUrl.value = item
  561. imageShow.value = true
  562. }
  563. const handelDelImage = (item, index) => {
  564. imageUrl.value.splice(index, 1)
  565. countForm.value.attachmentIds.splice(index, 1)
  566. }
  567. // 开票并结算
  568. const handleBack = () => {
  569. if (previousRoute.value == '/platform/platformOrder') {
  570. router.back()
  571. }
  572. }
  573. const handleSettlement = () => {
  574. if (contactPerson.value == '') {
  575. ElMessage({
  576. message: '请选择对接人!',
  577. type: 'warning'
  578. })
  579. return
  580. }
  581. // 查应收金额
  582. api.financeApi.getPlatformSettlementReceivableAmount({
  583. invoiceType: "5",
  584. orderNos: tableData.value.length > 0 ? tableData.value.map(item => item.orderNo) : selectedList.value.map(item => item.orderNo),
  585. }).then((res: any) => {
  586. if (res.code == 200) {
  587. receivablePremium.value = res.data
  588. countForm.value.actualReceivedAmount = res.data
  589. }
  590. })
  591. settlementDialog.value = true
  592. }
  593. const handelComfirm = (formEl: FormInstance | undefined) => {
  594. if (!formEl) return
  595. formEl.validate((valid) => {
  596. console.log(countForm.value)
  597. if (valid) {
  598. api.financeApi.platformSettlement({
  599. settlementVo: countForm.value,
  600. invoicingVo: {
  601. incomeIds: tableData.value.map(item => item.id),
  602. orderNos: tableData.value.map(item => item.orderNo),
  603. contactPerson: contactPerson.value,
  604. receivablePremium: receivablePremium.value,
  605. invoiceType: "5"
  606. }
  607. }).then((res: any) => {
  608. if (res.code == 200) {
  609. ElMessage({
  610. message: res.msg,
  611. type: 'success'
  612. })
  613. settlementDialog.value = false
  614. if (previousRoute.value == '/platform/platformOrder') {
  615. setTimeout(() => {
  616. router.back()
  617. }, 1000)
  618. } else {
  619. setTimeout(() => {
  620. window.location.reload()
  621. }, 1000)
  622. }
  623. } else {
  624. }
  625. })
  626. }
  627. })
  628. }
  629. const uploadImage = async (file, fileList) => {
  630. let files = file.raw
  631. const params = new FormData(); // 声明formData数据类型
  632. params.append("file", files);
  633. params.append("type", "image");
  634. const { code, data, msg } = await api.commonApi.fileUpload(params)
  635. if (code == 200) {
  636. imageUrl.value.push(data.downloadUrl)
  637. countForm.value.attachmentIds.push(data.id)
  638. }
  639. }
  640. const handleChange = async () => {
  641. const num = await calSub(countForm.value.actualReceivedAmount, receivablePremium.value)
  642. countForm.value.settlementPaymentDifference = num
  643. }
  644. /**
  645. * 计算两个数值的差值(被减数 - 减数)
  646. * @param minuend 被减数
  647. * @param subtrahend 减数
  648. * @returns 差值,若接口无数据则返回 0
  649. */
  650. const calSub = async (minuend: number = 0, subtrahend: number) => {
  651. const res = await api.financeApi.calSub({ minuend, subtrahend })
  652. return res.data || 0
  653. }
  654. const openSettlement = (list, name) => {
  655. contactPerson.value = name
  656. selectedList.value = list
  657. handleSettlement()
  658. initData()
  659. }
  660. onMounted(() => {
  661. initCompany()
  662. })
  663. defineExpose({
  664. openSettlement,
  665. });
  666. </script>
  667. <style scoped lang="scss">
  668. .ticket {
  669. height: calc(100vh - 135px);
  670. width: calc(100% - 24px);
  671. margin: 12px auto;
  672. padding: 12px;
  673. background: #FFFFFF;
  674. overflow-y: auto;
  675. .search-list {
  676. display: flex;
  677. align-items: center;
  678. justify-content: flex-start;
  679. .search-left {
  680. width: 150px;
  681. display: flex;
  682. align-items: center;
  683. justify-content: center;
  684. margin-right: 20px;
  685. }
  686. .search-right {
  687. width: 700px;
  688. .search-type {
  689. display: flex;
  690. align-items: center;
  691. justify-content: flex-start;
  692. margin-bottom: 10px;
  693. }
  694. }
  695. }
  696. .tips {
  697. display: flex;
  698. align-items: center;
  699. justify-content: flex-start;
  700. p {
  701. margin-right: 30px;
  702. }
  703. }
  704. .footer {
  705. width: 100%;
  706. position: absolute;
  707. left: 0;
  708. bottom: 0;
  709. display: flex;
  710. align-items: center;
  711. justify-content: center;
  712. height: 80px;
  713. }
  714. }
  715. .imageDiv {
  716. position: relative;
  717. width: 80px;
  718. height: 80px;
  719. margin: 0 10px 10px 0;
  720. &:hover {
  721. .model {
  722. display: flex;
  723. align-items: center;
  724. justify-content: center;
  725. background-color: rgba(0, 0, 0, .3);
  726. }
  727. }
  728. img {
  729. display: block;
  730. width: 100%;
  731. height: 100%;
  732. border-radius: 4px;
  733. }
  734. .model {
  735. position: absolute;
  736. width: 80px;
  737. height: 80px;
  738. border-radius: 4px;
  739. display: none;
  740. top: 0;
  741. left: 0;
  742. .icon-view,
  743. .icon-del {
  744. color: #FFFFFF;
  745. margin: 0 10px;
  746. cursor: pointer;
  747. }
  748. }
  749. }
  750. .upload-btn {
  751. :deep(.el-button) {
  752. width: 80px;
  753. height: 80px;
  754. font-size: 30px;
  755. color: #ccc;
  756. }
  757. }
  758. </style>