editBill.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card" style="margin: 0.6%">
  4. <div class="text item">
  5. <el-form ref="bill" label-width="auto" :inline="true">
  6. <el-form-item label="创建人:" style="float: right">{{
  7. form.createUser
  8. }}</el-form-item>
  9. <el-form-item label="创建时间:" style="float: right">{{
  10. parseTime(new Date(form.createTime))
  11. }}</el-form-item>
  12. <el-form-item label="编号:" style="float: right">{{
  13. form.zbiNumber
  14. }}</el-form-item>
  15. </el-form>
  16. </div>
  17. </el-card>
  18. <el-card class="box-card" style="margin: 0.6%">
  19. <div slot="header" class="clearfix">
  20. <span style="color: #666ee8; font-weight: bold">基本信息</span>
  21. </div>
  22. <div class="text item" style="margin-bottom: 20px">
  23. <el-form
  24. ref="form"
  25. :model="form"
  26. :rules="rules"
  27. label-width="auto"
  28. label-position="top"
  29. :inline="true"
  30. >
  31. <el-form-item label="账款类型" prop="wplIsInput" style="width: 300px">
  32. <el-radio-group v-model="type" prop="type" :disabled="true">
  33. <el-radio-button label="00" v-if="type == '00'"
  34. >应付账款</el-radio-button
  35. >
  36. <el-radio-button label="01" v-if="type == '01'"
  37. >应收账款</el-radio-button
  38. >
  39. </el-radio-group>
  40. </el-form-item>
  41. <el-form-item label="账款名称" prop="zbiName">
  42. <el-input
  43. v-model="form.zbiName"
  44. clearable
  45. placeholder="请输入账款名称"
  46. maxlength="20"
  47. style="width: 300px"
  48. />
  49. </el-form-item>
  50. <el-form-item label="应付方" prop="zbiPayerId">
  51. <el-input
  52. v-model="form.payerName"
  53. maxlength="20"
  54. style="width: 300px"
  55. :disabled="true"
  56. v-if="
  57. company.scyId != form.zbiPayerId &&
  58. company.scyId != form.zbiPayeeId
  59. "
  60. />
  61. <el-select
  62. style="width: 300px"
  63. v-model="form.zbiPayerId"
  64. :disabled="true"
  65. filterable
  66. remote
  67. v-if="
  68. (type == '00' && company.scyId == form.zbiPayerId) ||
  69. (type == '00' && company.scyId == form.zbiPayeeId)
  70. "
  71. >
  72. <el-option :label="company.scyName" :value="company.scyId">
  73. </el-option>
  74. </el-select>
  75. <el-select
  76. style="width: 300px"
  77. v-model="form.zbiPayerId"
  78. :disabled="true"
  79. filterable
  80. clearable
  81. remote
  82. v-if="
  83. (type == '01' && company.scyId == form.zbiPayerId) ||
  84. (type == '01' && company.scyId == form.zbiPayeeId)
  85. "
  86. >
  87. <el-option
  88. v-for="(item, index) in companyRelList"
  89. :key="index"
  90. :label="
  91. item.launchScyId == company.scyId
  92. ? item.receiveScyName
  93. : item.launchScyName
  94. "
  95. :value="
  96. item.launchScyId == company.scyId
  97. ? item.receiveScyId
  98. : item.launchScyId
  99. "
  100. >
  101. </el-option>
  102. </el-select>
  103. </el-form-item>
  104. <el-form-item label="应收方" prop="zbiPayeeId">
  105. <el-input
  106. v-model="form.payeeName"
  107. maxlength="20"
  108. style="width: 300px"
  109. :disabled="true"
  110. v-if="
  111. company.scyId != form.zbiPayerId &&
  112. company.scyId != form.zbiPayeeId
  113. "
  114. />
  115. <el-select
  116. style="width: 300px"
  117. v-model="form.zbiPayeeId"
  118. :disabled="true"
  119. filterable
  120. remote
  121. v-if="
  122. (type == '01' && company.scyId == form.zbiPayerId) ||
  123. (type == '01' && company.scyId == form.zbiPayeeId)
  124. "
  125. >
  126. <el-option :label="company.scyName" :value="company.scyId">
  127. </el-option>
  128. </el-select>
  129. <el-select
  130. style="width: 300px"
  131. v-model="form.zbiPayeeId"
  132. :disabled="true"
  133. filterable
  134. clearable
  135. remote
  136. v-if="
  137. (type == '00' && company.scyId == form.zbiPayerId) ||
  138. (type == '00' && company.scyId == form.zbiPayeeId)
  139. "
  140. >
  141. <el-option
  142. v-for="(item, index) in companyRelList"
  143. :key="index"
  144. :label="
  145. item.launchScyId == company.scyId
  146. ? item.receiveScyName
  147. : item.launchScyName
  148. "
  149. :value="
  150. item.launchScyId == company.scyId
  151. ? item.receiveScyId
  152. : item.launchScyId
  153. "
  154. >
  155. </el-option>
  156. </el-select>
  157. </el-form-item>
  158. <el-form-item label="贸易日期" prop="zbiDate">
  159. <el-date-picker
  160. style="width: 300px"
  161. v-model="form.zbiDate"
  162. :disabled="true"
  163. clearable
  164. value-format="yyyy-MM-dd"
  165. type="date"
  166. placeholder="选择日期"
  167. :picker-options="pickerOptionsStart"
  168. >
  169. </el-date-picker>
  170. </el-form-item>
  171. <el-form-item
  172. :label="
  173. type == '00'
  174. ? '预计付款日期'
  175. : type == '01'
  176. ? '预计收款日期'
  177. : '预计收/付款日期'
  178. "
  179. prop="zbiPayDate"
  180. >
  181. <el-date-picker
  182. style="width: 300px"
  183. v-model="form.zbiPayDate"
  184. :disabled="true"
  185. clearable
  186. value-format="yyyy-MM-dd"
  187. type="date"
  188. placeholder="选择日期"
  189. :picker-options="pickerOptionsEnd"
  190. >
  191. </el-date-picker>
  192. </el-form-item>
  193. <el-form-item label="账款金额">
  194. <el-input
  195. :disabled="true"
  196. :value="allAmount()"
  197. maxlength="20"
  198. style="width: 300px"
  199. >
  200. <template slot="append">元</template>
  201. </el-input>
  202. </el-form-item>
  203. <el-form-item label="账款金额大写">
  204. <el-input
  205. :disabled="true"
  206. :value="smallToBig(allAmount())"
  207. style="width: 300px"
  208. >
  209. </el-input>
  210. </el-form-item>
  211. <el-form-item label="贸易合同编号" prop="zbiContractNo">
  212. <el-input
  213. v-model="form.zbiContractNo"
  214. clearable
  215. placeholder="请输入贸易合同编号"
  216. maxlength="20"
  217. style="width: 300px"
  218. />
  219. </el-form-item>
  220. <el-form-item label="贸易商品/服务">
  221. <el-input
  222. v-model="form.zbiService"
  223. clearable
  224. placeholder="请输入贸易商品/服务"
  225. maxlength="20"
  226. style="width: 300px"
  227. />
  228. </el-form-item>
  229. <el-form-item label="配送企业">
  230. <el-input
  231. v-model="form.zbiDistributor"
  232. clearable
  233. placeholder="请输入配送企业"
  234. maxlength="20"
  235. style="width: 300px"
  236. />
  237. </el-form-item>
  238. <el-form-item label="配送订单号">
  239. <el-input
  240. v-model="form.zbiOrderNo"
  241. clearable
  242. placeholder="请输入配送订单号"
  243. maxlength="20"
  244. style="width: 300px"
  245. />
  246. </el-form-item>
  247. <el-form-item label="备注">
  248. <el-input
  249. v-model="form.zbiRemark"
  250. placeholder="请输入备注"
  251. :autosize="{ minRows: 2, maxRows: 4 }"
  252. maxlength="100"
  253. type="textarea"
  254. style="width: 615px"
  255. />
  256. </el-form-item>
  257. </el-form>
  258. </div>
  259. </el-card>
  260. <el-card class="box-card" style="margin: 0.6%">
  261. <div slot="header" class="clearfix">
  262. <span style="color: #666ee8; font-weight: bold">发票列表</span>
  263. </div>
  264. <div class="text item" style="margin-bottom: 20px">
  265. <el-form ref="invoice" label-width="auto" :inline="true">
  266. <el-form-item label="合计:">{{
  267. handleInput(allAmount())
  268. }}</el-form-item>
  269. <el-form-item label="大写:">{{
  270. smallToBig(allAmount())
  271. }}</el-form-item>
  272. <el-form-item style="float: right"
  273. ><el-button type="primary" @click="delInvoice"
  274. >删除</el-button
  275. ></el-form-item
  276. >
  277. <el-form-item style="float: right"
  278. ><el-button type="primary" @click="openUpload()"
  279. >上传/修改</el-button
  280. ></el-form-item
  281. >
  282. </el-form>
  283. <el-table
  284. :data="fileList"
  285. @selection-change="handleInvoiceSelectionChange"
  286. row-key="ziiId"
  287. default-expand-all
  288. :row-class-name="tableRowClassName"
  289. border
  290. >
  291. <el-table-column type="selection" width="50" align="center" />
  292. <el-table-column
  293. label="发票代码"
  294. align="center"
  295. prop="ziiNo"
  296. maxlength="10"
  297. />
  298. <el-table-column
  299. label="发票号码"
  300. align="center"
  301. prop="ziiNumber"
  302. maxlength="10"
  303. />
  304. <el-table-column label="开票日期" align="center" prop="ziiDate" />
  305. <el-table-column
  306. label="购方识别号"
  307. align="center"
  308. prop="ziiPurchaserNo"
  309. />
  310. <el-table-column
  311. label="销方识别号"
  312. align="center"
  313. prop="ziiSellerNo"
  314. />
  315. <el-table-column
  316. label="合计金额"
  317. align="center"
  318. prop="ziiTotalAmount"
  319. />
  320. <el-table-column label="价税合计" align="center" prop="ziiAmount" />
  321. <el-table-column
  322. label="校验结果"
  323. align="center"
  324. prop="ziiCheckStt"
  325. :formatter="checkSttFormat"
  326. />
  327. <el-table-column
  328. label="附件"
  329. align="center"
  330. class-name="small-padding fixed-width"
  331. fixed="right"
  332. width="200"
  333. >
  334. <template slot-scope="scope">
  335. <el-button
  336. size="mini"
  337. type="text"
  338. @click="invoicePictureCardPreview(scope.row)"
  339. >详情</el-button
  340. >
  341. </template>
  342. </el-table-column>
  343. </el-table>
  344. <!-- 上传附件 -->
  345. <el-dialog
  346. title="上传发票"
  347. :visible.sync="uploadOpen"
  348. width="500px"
  349. append-to-body
  350. >
  351. <el-upload
  352. class="upload-demo"
  353. drag
  354. ref="upload"
  355. :file-list="fileList"
  356. :auto-upload="true"
  357. :http-request="httpRequest"
  358. :before-remove="beforeRemove"
  359. :on-remove="invoiceRemove"
  360. :before-upload="beforeAvatarUpload"
  361. accept=".jpg,.jpeg,.png"
  362. action=""
  363. multiple
  364. >
  365. <i class="el-icon-upload"></i>
  366. <div class="el-upload__text">
  367. 将文件拖到此处,或<em>点击选择文件</em>
  368. </div>
  369. <div class="el-upload__tip">
  370. 按住Ctrl可同时多选,单个文件不能超过2mb
  371. </div>
  372. <div class="el-upload__tip">
  373. 严禁上传包含色情、暴力、反动等相关违法信息的文件。
  374. </div>
  375. </el-upload>
  376. <!-- <el-button type="primary" @click="submitUpload()"
  377. >点击上传</el-button
  378. > -->
  379. <el-button type="primary" @click="toCheck()">完成去验真</el-button>
  380. </el-dialog>
  381. <!-- 发票验真 -->
  382. <el-dialog
  383. title="发票验真"
  384. :visible.sync="open"
  385. width="1050px"
  386. append-to-body
  387. >
  388. <el-container>
  389. <el-aside width="300px" style="background-color: white">
  390. <el-button type="primary" @click="openUploadInvoice"
  391. >上传发票</el-button
  392. >
  393. <el-header style="background-color: #dfe2e8; text-align: center">
  394. <el-checkbox
  395. :indeterminate="isIndeterminate"
  396. v-model="checkAll"
  397. @change="handleCheckAllChange"
  398. >全选</el-checkbox
  399. >
  400. <label>已上传发票列表</label>
  401. </el-header>
  402. <el-main style="height: 550px; border: groove">
  403. <div
  404. :style="
  405. item.ziiCheckStt == '1'
  406. ? { 'background-color': '#a8f87f' }
  407. : {}
  408. "
  409. v-for="(item, index) in fileList"
  410. :label="item"
  411. :key="index"
  412. >
  413. <i
  414. class="el-icon-question"
  415. style="color: blue"
  416. v-if="item.ziiCheckStt == '0'"
  417. ><label @click="changeInvoice(item)"
  418. ><el-link :underline="false">{{
  419. item.name
  420. }}</el-link></label
  421. ></i
  422. >
  423. <i
  424. class="el-icon-success"
  425. style="color: green"
  426. v-if="item.ziiCheckStt == '1'"
  427. ><label @click="changeInvoice(item)"
  428. ><el-link :underline="false">{{
  429. item.name
  430. }}</el-link></label
  431. ></i
  432. >
  433. <i
  434. class="el-icon-error"
  435. style="color: red"
  436. v-if="item.ziiCheckStt == '2' || item.ziiCheckStt == '3'"
  437. ><label @click="changeInvoice(item)"
  438. ><el-link :underline="false">{{
  439. item.name
  440. }}</el-link></label
  441. ><label>{{ checkSttFormat(item) }}</label></i
  442. >
  443. <el-link
  444. style="float: right"
  445. type="primary"
  446. :underline="false"
  447. @click="delInvoice(item)"
  448. >删除</el-link
  449. >
  450. </div>
  451. </el-main>
  452. <div style="text-align: center; margin-top: 20px">
  453. <el-button type="primary" @click="toCheckAgian()"
  454. >再次验证</el-button
  455. >
  456. <el-button type="primary" @click="submitCheck()"
  457. >保存并上传</el-button
  458. >
  459. </div>
  460. </el-aside>
  461. <el-container>
  462. <el-header height="300px">
  463. <el-image
  464. style="width: 650px; height: 267px"
  465. :src="invoice.url"
  466. fit="scale-down"
  467. @click="invoicePictureCardPreview(invoice)"
  468. ></el-image>
  469. <p
  470. v-if="invoice.zbiName && invoice.ziiCheckStt == '3'"
  471. style="text-align: center; color: red"
  472. >
  473. 发票重复,已存在名称为“{{ invoice.zbiName }}”的往来账款中!
  474. </p>
  475. </el-header>
  476. <el-main>
  477. <el-form
  478. ref="invoice"
  479. label-width="auto"
  480. :inline="true"
  481. label-position="top"
  482. :disabled="invoice.ziiCheckStt == '1'"
  483. >
  484. <el-form-item label="发票代码:">
  485. <el-input v-model="invoice.ziiNo" maxlength="20" />
  486. </el-form-item>
  487. <el-form-item label="发票号码:">
  488. <el-input v-model="invoice.ziiNumber" maxlength="20" />
  489. </el-form-item>
  490. <el-form-item label="开票日期:">
  491. <el-date-picker
  492. v-model="invoice.ziiDate"
  493. value-format="yyyy-MM-dd"
  494. type="date"
  495. placeholder="选择日期"
  496. >
  497. </el-date-picker>
  498. </el-form-item>
  499. <el-form-item label="购货纳税人编号:">
  500. <el-input v-model="invoice.ziiPurchaserNo" maxlength="20" />
  501. </el-form-item>
  502. <el-form-item label="销货纳税人编号:">
  503. <el-input v-model="invoice.ziiSellerNo" maxlength="20" />
  504. </el-form-item>
  505. <el-form-item label="发票金额:">
  506. <el-input v-model="invoice.ziiTotalAmount" maxlength="16" @input.native="changeRate($event,invoice.ziiTotalAmount,'0')" />
  507. </el-form-item>
  508. <el-form-item label="税价金额:">
  509. <el-input v-model="invoice.ziiAmount" maxlength="16" @input.native="changeRate($event,invoice.ziiAmount,'1')"/>
  510. </el-form-item>
  511. </el-form>
  512. </el-main>
  513. <el-footer>
  514. <el-button
  515. type="primary"
  516. @click="queryDouble()"
  517. style="float: right"
  518. >确定</el-button
  519. >
  520. </el-footer>
  521. </el-container>
  522. </el-container>
  523. </el-dialog>
  524. </div>
  525. </el-card>
  526. <el-card class="box-card" style="margin: 0.6%">
  527. <div slot="header" class="clearfix">
  528. <span style="color: #666ee8; font-weight: bold">合同附件</span>
  529. </div>
  530. <div class="text item" style="margin-bottom: 20px">
  531. <el-form ref="contract" label-width="auto" :inline="true">
  532. <!-- <el-form-item style="float: right"
  533. ><el-button type="primary" @click="submitUploadContract()"
  534. >上传</el-button
  535. ></el-form-item
  536. > -->
  537. </el-form>
  538. <el-upload
  539. :file-list="contractList"
  540. :auto-upload="true"
  541. :http-request="httpRequestContract"
  542. action=""
  543. ref="contractUpload"
  544. list-type="picture-card"
  545. accept=".jpg,.jpeg,.png"
  546. :before-upload="beforeUpload"
  547. :on-preview="invoicePictureCardPreview"
  548. :before-remove="beforeRemove"
  549. :on-remove="handleRemoveContract"
  550. >
  551. <i class="el-icon-plus"></i>
  552. </el-upload>
  553. </div>
  554. </el-card>
  555. <el-card class="box-card" style="margin: 0.6%">
  556. <div slot="header" class="clearfix">
  557. <span style="color: #666ee8; font-weight: bold">物流附件</span>
  558. </div>
  559. <div class="text item" style="margin-bottom: 20px">
  560. <el-form ref="logistics" label-width="auto" :inline="true">
  561. <!-- <el-form-item style="float: right"
  562. ><el-button type="primary" @click="submitUploadLogistics()"
  563. >上传</el-button
  564. ></el-form-item
  565. > -->
  566. </el-form>
  567. <el-upload
  568. :file-list="logisticsList"
  569. :auto-upload="true"
  570. :http-request="httpRequestLogistics"
  571. action=""
  572. ref="logisticsUpload"
  573. list-type="picture-card"
  574. accept=".jpg,.jpeg,.png"
  575. :before-upload="beforeUpload"
  576. :on-preview="invoicePictureCardPreview"
  577. :before-remove="beforeRemove"
  578. :on-remove="handleRemoveLogistics"
  579. >
  580. <i class="el-icon-plus"></i>
  581. </el-upload>
  582. </div>
  583. </el-card>
  584. <el-card class="box-card" style="margin: 0.6%">
  585. <div slot="header" class="clearfix">
  586. <span style="color: #666ee8; font-weight: bold">其他附件</span>
  587. </div>
  588. <div class="text item" style="margin-bottom: 20px">
  589. <el-form ref="other" label-width="auto" :inline="true">
  590. <!-- <el-form-item style="float: right"
  591. ><el-button type="primary" @click="submitUploadOther()"
  592. >上传</el-button
  593. ></el-form-item
  594. > -->
  595. </el-form>
  596. <el-upload
  597. :file-list="otherList"
  598. :auto-upload="true"
  599. :http-request="httpRequestOther"
  600. action=""
  601. ref="otherUpload"
  602. list-type="picture-card"
  603. accept=".jpg,.jpeg,.png"
  604. :before-upload="beforeUpload"
  605. :on-preview="invoicePictureCardPreview"
  606. :before-remove="beforeRemove"
  607. :on-remove="handleRemoveOther"
  608. >
  609. <i class="el-icon-plus"></i>
  610. </el-upload>
  611. </div>
  612. </el-card>
  613. <!-- 查看图片 -->
  614. <el-dialog :visible.sync="invoiceVisible">
  615. <img width="100%" :src="invoiceImageUrl" alt="" />
  616. </el-dialog>
  617. <div style="text-align: center">
  618. <el-button type="primary" @click="submit()">提交</el-button>
  619. </div>
  620. </div>
  621. </template>
  622. <script>
  623. import {
  624. getBill,
  625. getInvoice,
  626. addBill,
  627. getInvoiceText,
  628. invoiceVerification,
  629. delInvoice,
  630. uploadBillFile,
  631. getFile,
  632. delFile,
  633. commitBill,
  634. getAmount,
  635. queryDouble,
  636. } from "@/api/service/bill/bill";
  637. import { getOwnCompany, companyRelList } from "@/api/common/company";
  638. import { amtformat } from "@/utils/amtCommon";
  639. import { getToken } from "@/utils/auth";
  640. export default {
  641. name: "billEdit",
  642. components: {},
  643. props: {
  644. // 正常的业务数据,对应echarts饼图配置中series[0].data
  645. zbiId: {
  646. type: String,
  647. required: true,
  648. default: () => "",
  649. },
  650. },
  651. data() {
  652. return {
  653. // 选中数组
  654. ids: [],
  655. // 非单个禁用
  656. single: true,
  657. // 非多个禁用
  658. multiple: true,
  659. // 是否显示弹出层
  660. open: false,
  661. uploadOpen: false,
  662. // 查询参数
  663. queryParams: {},
  664. // 表单参数
  665. form: {},
  666. // 表单校验
  667. rules: {
  668. zbiName: [
  669. {
  670. required: true,
  671. message: "账款名称不能为空",
  672. trigger: ["blur", "change"],
  673. },
  674. {
  675. pattern: /^[\u4E00-\u9FA5A-Za-z0-9]+$/,
  676. message: "账款名称只能包含中文、英文、数字",
  677. trigger: ["blur", "change"],
  678. },
  679. ],
  680. zbiPayerId: [
  681. {
  682. required: true,
  683. message: "应付方不能为空",
  684. trigger: ["blur", "change"],
  685. },
  686. ],
  687. zbiDate: [
  688. {
  689. required: true,
  690. message: "贸易日期不能为空",
  691. trigger: ["blur", "change"],
  692. },
  693. ],
  694. zbiPayDate: [
  695. {
  696. required: true,
  697. message: "预计收/付款日期不能为空",
  698. trigger: ["blur", "change"],
  699. },
  700. ],
  701. zbiPayeeId: [
  702. {
  703. required: true,
  704. message: "应收方不能为空",
  705. trigger: ["blur", "change"],
  706. },
  707. ],
  708. zbiAmount: [
  709. {
  710. required: true,
  711. message: "贸易金额不能为空",
  712. trigger: ["blur", "change"],
  713. },
  714. {
  715. pattern: /^(?:0|[1-9]\d{0,13})(?:\.\d{1,2})?$/,
  716. message: "请输入正确的金额",
  717. trigger: ["blur", "change"],
  718. },
  719. ],
  720. zbiContractNo: [
  721. {
  722. required: true,
  723. message: "合同编号不能为空",
  724. trigger: ["blur", "change"],
  725. },
  726. {
  727. pattern: /^[a-zA-Z0-9]+$/,
  728. message: "请输入数字或英文",
  729. trigger: ["blur", "change"],
  730. },
  731. ],
  732. },
  733. //类型
  734. type: "00",
  735. //合同附件
  736. contractList: [],
  737. //物流附件
  738. logisticsList: [],
  739. //其他附件
  740. otherList: [],
  741. //发票列表
  742. fileList: [],
  743. //全选状态
  744. checkAll: false,
  745. //全选状态
  746. isIndeterminate: false,
  747. //选中值
  748. checkedInvoice: [],
  749. //发票对象
  750. invoice: {},
  751. //合计金额
  752. totalPrice: 0,
  753. //验证结果
  754. checkSttOptions: [],
  755. //图片路径
  756. invoiceImageUrl: null,
  757. //图片显示
  758. invoiceVisible: false,
  759. //等待框
  760. fullscreenLoading: false,
  761. //链属企业
  762. companyRelList: [],
  763. //链属企业
  764. company: {},
  765. pickerOptionsStart: {
  766. disabledDate: (time) => {
  767. if (this.form.zbiPayDate) {
  768. return (
  769. time.getTime() >
  770. new Date(this.form.zbiPayDate).getTime() -
  771. 14 * 24 * 60 * 60 * 1000
  772. );
  773. }
  774. },
  775. },
  776. pickerOptionsEnd: {
  777. disabledDate: (time) => {
  778. if (this.form.zbiDate) {
  779. return (
  780. time.getTime() <
  781. new Date(this.form.zbiDate).getTime() + 13 * 24 * 60 * 60 * 1000
  782. );
  783. }
  784. },
  785. },
  786. };
  787. },
  788. created() {
  789. const zbiId = this.zbiId;
  790. this.fullscreenLoading = true;
  791. getOwnCompany().then((response) => {
  792. this.company = response.data;
  793. });
  794. this.getCompanyRel();
  795. this.getDetail(zbiId);
  796. getInvoice(zbiId).then((response) => {
  797. response.data.forEach((element) => {
  798. element.url = element.url + "/" + getToken();
  799. });
  800. this.fileList = response.data;
  801. this.invoice = this.fileList[0] ? this.fileList[0] : {};
  802. this.ids = [];
  803. });
  804. getFile("0", zbiId).then((response) => {
  805. response.data.forEach((element) => {
  806. element.url = element.url + "/" + getToken();
  807. });
  808. this.contractList = response.data;
  809. });
  810. //查询物流
  811. getFile("1", zbiId).then((response) => {
  812. response.data.forEach((element) => {
  813. element.url = element.url + "/" + getToken();
  814. });
  815. this.logisticsList = response.data;
  816. });
  817. //查询其他附件
  818. getFile("2", zbiId).then((response) => {
  819. response.data.forEach((element) => {
  820. element.url = element.url + "/" + getToken();
  821. });
  822. this.otherList = response.data;
  823. });
  824. this.getDicts("zc_invoice_checkStt").then((response) => {
  825. this.checkSttOptions = response.data;
  826. });
  827. },
  828. activated() {},
  829. methods: {
  830. //查询往来账款详情
  831. getDetail(zbiId) {
  832. const loading = this.$loading({
  833. lock: true,
  834. text: "Loading",
  835. spinner: "el-icon-loading",
  836. background: "rgba(0, 0, 0, 0.7)",
  837. });
  838. getBill(zbiId)
  839. .then((response) => {
  840. this.form = response.data;
  841. if (this.form.zbiPayerId == this.company.scyId) {
  842. this.type = "00";
  843. } else {
  844. this.type = "01";
  845. }
  846. loading.close();
  847. })
  848. .catch(() => {
  849. loading.close();
  850. });
  851. },
  852. //切换账款类型
  853. changePayer(val) {
  854. if (val == "00") {
  855. this.form.zbiPayerId = this.company.scyId;
  856. this.form.zbiPayeeId = null;
  857. } else if (val == "01") {
  858. this.form.zbiPayerId = null;
  859. this.form.zbiPayeeId = this.company.scyId;
  860. }
  861. },
  862. //查询链属企业
  863. getCompanyRel(val) {
  864. this.queryParams.companyName = val;
  865. companyRelList(this.queryParams).then((response) => {
  866. this.companyRelList = response.data;
  867. });
  868. },
  869. //全选
  870. handleCheckAllChange(val) {
  871. this.checkedInvoice = val ? this.fileList : [];
  872. this.ids = val ? this.fileList.map((item) => item.id) : [];
  873. this.isIndeterminate = false;
  874. },
  875. // 多选框选中数据
  876. handleInvoiceSelectionChange(selection) {
  877. this.ids = selection.map((item) => item.id);
  878. this.single = selection.length !== 1;
  879. this.multiple = !selection.length;
  880. },
  881. //发票上传窗口
  882. openUpload() {
  883. this.open = true;
  884. },
  885. //上传
  886. submitUpload() {
  887. this.$refs.upload.submit();
  888. },
  889. //上传发票窗口
  890. openUploadInvoice() {
  891. this.uploadOpen = true;
  892. },
  893. //判重验证
  894. queryDouble() {
  895. const loading = this.$loading({
  896. lock: true,
  897. text: "Loading",
  898. spinner: "el-icon-loading",
  899. background: "rgba(0, 0, 0, 0.7)",
  900. });
  901. if (
  902. this.invoice &&
  903. this.invoice.ziiCheckStt != "1"
  904. ) {
  905. queryDouble(this.invoice).then((response) => {
  906. this.fileList.forEach((file) => {
  907. if (response.id == file.id) {
  908. file.ziiCheckStt = response.ziiCheckStt;
  909. file.zbiName = response.zbiName;
  910. }
  911. });
  912. // this.invoice = this.fileList[0] ? this.fileList[0] : {};
  913. loading.close();
  914. }).catch((response) => {
  915. loading.close();
  916. });
  917. }else{
  918. loading.close();
  919. }
  920. },
  921. //去验真
  922. toCheck() {
  923. this.uploadOpen = false;
  924. const loading = this.$loading({
  925. lock: true,
  926. text: "Loading",
  927. spinner: "el-icon-loading",
  928. background: "rgba(0, 0, 0, 0.7)",
  929. });
  930. let fd = new FormData(); // FormData 对象
  931. fd.append("fileList", JSON.stringify(this.fileList)); // 文件对象
  932. invoiceVerification(fd)
  933. .then((response) => {
  934. response.forEach((element) => {
  935. this.fileList.forEach((file) => {
  936. if (element.id == file.id) {
  937. file.ziiCheckStt = element.ziiCheckStt;
  938. file.zbiName = element.zbiName;
  939. }
  940. });
  941. });
  942. this.invoice = this.fileList[0] ? this.fileList[0] : {};
  943. loading.close();
  944. })
  945. .catch(() => {
  946. loading.close();
  947. });
  948. },
  949. //重新验真
  950. toCheckAgian() {
  951. const loading = this.$loading({
  952. lock: true,
  953. text: "Loading",
  954. spinner: "el-icon-loading",
  955. background: "rgba(0, 0, 0, 0.7)",
  956. });
  957. let checkList = this.checkedInvoice.filter((element) => {
  958. return element.ziiCheckStt == "0";
  959. });
  960. let fd = new FormData(); // FormData 对象
  961. fd.append("fileList", JSON.stringify(checkList)); // 文件对象
  962. invoiceVerification(fd)
  963. .then((response) => {
  964. response.forEach((element) => {
  965. this.fileList.forEach((file) => {
  966. if (element.id == file.id) {
  967. file.ziiCheckStt = element.ziiCheckStt;
  968. file.zbiName = element.zbiName;
  969. }
  970. });
  971. });
  972. loading.close();
  973. })
  974. .catch(() => {
  975. loading.close();
  976. });
  977. },
  978. //金额校验格式
  979. changeRate(e,input,type){
  980. e.target.value=(e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
  981. this.input=e.target.value;
  982. if("0"==type){
  983. this.invoice.ziiTotalAmount = e.target.value;
  984. }else if("1"==type){
  985. this.invoice.ziiAmount = e.target.value;
  986. }
  987. },
  988. //表格置灰
  989. tableRowClassName({ row, rowIndex }) {
  990. if (row.ziiCheckStt != "1") {
  991. return "warning-row";
  992. }
  993. return "";
  994. },
  995. //切换发票
  996. changeInvoice(item) {
  997. this.invoice = item;
  998. },
  999. //手动上传发票触发
  1000. httpRequest(param) {
  1001. const loading = this.$loading({
  1002. lock: true,
  1003. text: "Loading",
  1004. spinner: "el-icon-loading",
  1005. background: "rgba(0, 0, 0, 0.7)",
  1006. });
  1007. let fileObj = param.file; // 相当于input里取得的files
  1008. let fd = new FormData(); // FormData 对象
  1009. fd.append("file", fileObj); // 文件对象
  1010. fd.append("zbiId", this.form.zbiId); //文件类型
  1011. getInvoiceText(fd)
  1012. .then((response) => {
  1013. response.data.url = response.data.url + "/" + getToken();
  1014. var flag = true;
  1015. this.fileList.forEach((element) => {
  1016. if (element.ziiNo == response.data.ziiNo) {
  1017. flag = false;
  1018. }
  1019. });
  1020. if (flag) {
  1021. this.fileList.push(response.data);
  1022. } else {
  1023. let uid = fileObj.uid; // 关键作用代码,去除文件列表失败文件
  1024. let idx = this.$refs.upload.uploadFiles.findIndex(
  1025. (item) => item.uid === uid
  1026. ); // 关键作用代码,去除文件列表失败文件(uploadFiles为el-upload中的ref值)
  1027. this.$refs.upload.uploadFiles.splice(idx, 1); // 关键作用代码,去除文件列表失败文件
  1028. this.$message.error("检测发票重复上传,请检查后重试");
  1029. }
  1030. loading.close();
  1031. })
  1032. .catch(() => {
  1033. let uid = fileObj.uid; // 关键作用代码,去除文件列表失败文件
  1034. let idx = this.$refs.upload.uploadFiles.findIndex(
  1035. (item) => item.uid === uid
  1036. ); // 关键作用代码,去除文件列表失败文件(uploadFiles为el-upload中的ref值)
  1037. this.$refs.upload.uploadFiles.splice(idx, 1); // 关键作用代码,去除文件列表失败文件
  1038. loading.close();
  1039. });
  1040. },
  1041. beforeUpload(files) {
  1042. var testmsg = files.name.substring(files.name.lastIndexOf(".") + 1);
  1043. const extension = testmsg === "jpg";
  1044. const extension2 = testmsg === "jpeg";
  1045. const extension3 = testmsg === "png";
  1046. if (!extension && !extension2 && !extension3) {
  1047. this.$message.warning(`请选择图片格式文件`);
  1048. }
  1049. return extension || extension2 || extension3;
  1050. },
  1051. //上传前校验
  1052. beforeAvatarUpload(file) {
  1053. const isJPG = file.type === "image/jpeg" || file.type === "image/png";
  1054. const isLt2M = file.size / 1024 / 1024 < 2;
  1055. if (!isJPG) {
  1056. this.$message.error("上传图片只能是 JPG/PNG 格式");
  1057. }
  1058. if (!isLt2M) {
  1059. this.$message.error("上传图片大小不能超过 2MB");
  1060. }
  1061. return isJPG && isLt2M;
  1062. },
  1063. //上传合同
  1064. submitUploadContract() {
  1065. this.$refs.contractUpload.submit();
  1066. },
  1067. //上传物流
  1068. submitUploadLogistics() {
  1069. this.$refs.logisticsUpload.submit();
  1070. },
  1071. //上传其他
  1072. submitUploadOther() {
  1073. this.$refs.otherUpload.submit();
  1074. },
  1075. //手动上传合同触发
  1076. httpRequestContract(param) {
  1077. const loading = this.$loading({
  1078. lock: true,
  1079. text: "Loading",
  1080. spinner: "el-icon-loading",
  1081. background: "rgba(0, 0, 0, 0.7)",
  1082. });
  1083. let fileObj = param.file; // 相当于input里取得的files
  1084. let fd = new FormData(); // FormData 对象
  1085. fd.append("file", fileObj); // 文件对象
  1086. fd.append("zbiId", this.form.zbiId); //文件类型
  1087. fd.append("type", "0"); //文件类型
  1088. uploadBillFile(fd)
  1089. .then((response) => {
  1090. response.data.url = response.data.url + "/" + getToken();
  1091. this.contractList.push(response.data);
  1092. loading.close();
  1093. })
  1094. .catch(() => {
  1095. let uid = fileObj.uid; // 关键作用代码,去除文件列表失败文件
  1096. let idx = this.$refs.contractUpload.uploadFiles.findIndex(
  1097. (item) => item.uid === uid
  1098. ); // 关键作用代码,去除文件列表失败文件(uploadFiles为el-upload中的ref值)
  1099. this.$refs.contractUpload.uploadFiles.splice(idx, 1); // 关键作用代码,去除文件列表失败文件
  1100. loading.close();
  1101. });
  1102. },
  1103. //手动上传物流触发
  1104. httpRequestLogistics(param) {
  1105. const loading = this.$loading({
  1106. lock: true,
  1107. text: "Loading",
  1108. spinner: "el-icon-loading",
  1109. background: "rgba(0, 0, 0, 0.7)",
  1110. });
  1111. let fileObj = param.file; // 相当于input里取得的files
  1112. let fd = new FormData(); // FormData 对象
  1113. fd.append("file", fileObj); // 文件对象
  1114. fd.append("zbiId", this.form.zbiId); //文件类型
  1115. fd.append("type", "1"); //文件类型
  1116. uploadBillFile(fd)
  1117. .then((response) => {
  1118. response.data.url = response.data.url + "/" + getToken();
  1119. this.logisticsList.push(response.data);
  1120. loading.close();
  1121. })
  1122. .catch(() => {
  1123. let uid = fileObj.uid; // 关键作用代码,去除文件列表失败文件
  1124. let idx = this.$refs.logisticsUpload.uploadFiles.findIndex(
  1125. (item) => item.uid === uid
  1126. ); // 关键作用代码,去除文件列表失败文件(uploadFiles为el-upload中的ref值)
  1127. this.$refs.logisticsUpload.uploadFiles.splice(idx, 1); // 关键作用代码,去除文件列表失败文件
  1128. loading.close();
  1129. });
  1130. },
  1131. //手动上传其他触发
  1132. httpRequestOther(param) {
  1133. const loading = this.$loading({
  1134. lock: true,
  1135. text: "Loading",
  1136. spinner: "el-icon-loading",
  1137. background: "rgba(0, 0, 0, 0.7)",
  1138. });
  1139. let fileObj = param.file; // 相当于input里取得的files
  1140. let fd = new FormData(); // FormData 对象
  1141. fd.append("file", fileObj); // 文件对象
  1142. fd.append("zbiId", this.form.zbiId); //文件类型
  1143. fd.append("type", "2"); //文件类型
  1144. uploadBillFile(fd)
  1145. .then((response) => {
  1146. response.data.url = response.data.url + "/" + getToken();
  1147. this.otherList.push(response.data);
  1148. loading.close();
  1149. })
  1150. .catch(() => {
  1151. let uid = fileObj.uid; // 关键作用代码,去除文件列表失败文件
  1152. let idx = this.$refs.otherUpload.uploadFiles.findIndex(
  1153. (item) => item.uid === uid
  1154. ); // 关键作用代码,去除文件列表失败文件(uploadFiles为el-upload中的ref值)
  1155. this.$refs.otherUpload.uploadFiles.splice(idx, 1); // 关键作用代码,去除文件列表失败文件
  1156. loading.close();
  1157. });
  1158. },
  1159. //删除图片
  1160. beforeRemove(file, fileList) {
  1161. let a = true;
  1162. if (file && file.status === "success") {
  1163. a = this.$confirm(`确定移除 ${file.name}?`);
  1164. }
  1165. return a;
  1166. },
  1167. //删除合同附件
  1168. handleRemoveContract(file, fileList) {
  1169. var self = this;
  1170. // if (self.contractList) {
  1171. // const loading = this.$loading({
  1172. // lock: true,
  1173. // text: 'Loading',
  1174. // spinner: 'el-icon-loading',
  1175. // background: 'rgba(0, 0, 0, 0.7)'
  1176. // });
  1177. // delFile(file.id).then(function () {
  1178. self.contractList = self.contractList.reduce((total, current) => {
  1179. current.id !== file.id && total.push(current);
  1180. return total;
  1181. }, []);
  1182. // loading.close();
  1183. // }).catch(() => {
  1184. // loading.close();
  1185. // });
  1186. // }
  1187. },
  1188. //删除物流附件
  1189. handleRemoveLogistics(file, fileList) {
  1190. // var self = this
  1191. // if (this.logisticsList) {
  1192. // const loading = this.$loading({
  1193. // lock: true,
  1194. // text: 'Loading',
  1195. // spinner: 'el-icon-loading',
  1196. // background: 'rgba(0, 0, 0, 0.7)'
  1197. // });
  1198. // delFile(file.id).then(function () {
  1199. self.logisticsList = self.logisticsList.reduce((total, current) => {
  1200. current.id !== file.id && total.push(current);
  1201. return total;
  1202. }, []);
  1203. // loading.close();
  1204. // }).catch(() => {
  1205. // loading.close();
  1206. // });
  1207. // }
  1208. },
  1209. //删除其他附件
  1210. handleRemoveOther(file, fileList) {
  1211. // var self = this
  1212. // if (this.otherList) {
  1213. // const loading = this.$loading({
  1214. // lock: true,
  1215. // text: 'Loading',
  1216. // spinner: 'el-icon-loading',
  1217. // background: 'rgba(0, 0, 0, 0.7)'
  1218. // });
  1219. // delFile(file.id).then(function () {
  1220. self.otherList = self.otherList.reduce((total, current) => {
  1221. current.id !== file.id && total.push(current);
  1222. return total;
  1223. }, []);
  1224. // loading.close();
  1225. // }).catch(() => {
  1226. // loading.close();
  1227. // });
  1228. // }
  1229. },
  1230. //删除附件
  1231. delFile(row) {
  1232. var self = this;
  1233. const ids = row.id || this.ids;
  1234. self.fullscreenLoading = true;
  1235. delFile(ids).then(function () {
  1236. self.fullscreenLoading = false;
  1237. });
  1238. },
  1239. //查看图片
  1240. invoicePictureCardPreview(file) {
  1241. this.invoiceImageUrl = file.url;
  1242. this.invoiceVisible = true;
  1243. },
  1244. //删除发票
  1245. invoiceRemove(file, fileList) {
  1246. var self = this;
  1247. if (file && file.status === "success") {
  1248. this.fileList = this.fileList.filter((item) => {
  1249. if (item.uid !== file.uid) {
  1250. return item;
  1251. } else {
  1252. // const loading = this.$loading({
  1253. // lock: true,
  1254. // text: 'Loading',
  1255. // spinner: 'el-icon-loading',
  1256. // background: 'rgba(0, 0, 0, 0.7)'
  1257. // });
  1258. // delFile(item.id)
  1259. // .then(function () {
  1260. // loading.close();
  1261. // this.msgSuccess("删除成功");
  1262. // })
  1263. // .catch(() => {
  1264. // loading.close();
  1265. // });
  1266. }
  1267. });
  1268. }
  1269. },
  1270. //删除发票
  1271. delInvoice(row) {
  1272. var self = this;
  1273. const ids = [row.id] || this.ids;
  1274. if (ids && ids.length != 0) {
  1275. this.$confirm("是否确认删除此数据项?", "警告", {
  1276. confirmButtonText: "确定",
  1277. cancelButtonText: "取消",
  1278. type: "warning",
  1279. })
  1280. // .then(function () {
  1281. // self.fullscreenLoading = true;
  1282. // return delFile(ids);
  1283. // })
  1284. .then(() => {
  1285. // self.fullscreenLoading = false;
  1286. ids.forEach((element) => {
  1287. self.fileList = self.fileList.reduce((total, current) => {
  1288. current.id !== element && total.push(current);
  1289. return total;
  1290. }, []);
  1291. });
  1292. this.msgSuccess("删除成功");
  1293. });
  1294. }
  1295. },
  1296. //确认发票
  1297. submitCheck() {
  1298. this.open = false;
  1299. },
  1300. //发票合计
  1301. allAmount() {
  1302. var strarr = [0.0];
  1303. for (let i in this.fileList) {
  1304. if (this.fileList[i]["ziiCheckStt"] == "1") {
  1305. strarr.push(this.fileList[i]["ziiAmount"]);
  1306. }
  1307. }
  1308. return (Math.floor(eval(strarr.join("+")) * 100) / 100).toFixed(2); //结果
  1309. // return this.handleInput(eval(strarr.join("+"))); //结果
  1310. },
  1311. // 结束
  1312. submit() {
  1313. this.$refs["form"].validate((valid) => {
  1314. if (valid) {
  1315. this.form.zbiAmount = this.allAmount();
  1316. this.form.fileList = this.fileList;
  1317. this.form.contractList = this.contractList;
  1318. this.form.logisticsList = this.logisticsList;
  1319. this.form.otherList = this.otherList;
  1320. const loading = this.$loading({
  1321. lock: true,
  1322. text: "Loading",
  1323. spinner: "el-icon-loading",
  1324. background: "rgba(0, 0, 0, 0.7)",
  1325. });
  1326. commitBill(this.form)
  1327. .then((response) => {
  1328. loading.close();
  1329. this.msgSuccess("修改账款成功");
  1330. this.$emit("editClick", this.form.zbiId);
  1331. })
  1332. .catch(() => {
  1333. loading.close();
  1334. });
  1335. }else{
  1336. this.$message({
  1337. message: "账款基本信息未完善,请检查确认",
  1338. type: "warning",
  1339. });
  1340. }
  1341. });
  1342. },
  1343. //校验结果字典
  1344. checkSttFormat(row, column) {
  1345. return this.selectDictLabel(this.checkSttOptions, row.ziiCheckStt);
  1346. },
  1347. /* 金额展示 */
  1348. handleInput(str) {
  1349. return amtformat(str, 2, ".", ",");
  1350. },
  1351. /* // 将数字金额转换为大写金额 */
  1352. smallToBig(money) {
  1353. // 将数字金额转换为大写金额
  1354. var cnNums = new Array(
  1355. "零",
  1356. "壹",
  1357. "贰",
  1358. "叁",
  1359. "肆",
  1360. "伍",
  1361. "陆",
  1362. "柒",
  1363. "捌",
  1364. "玖"
  1365. ); //汉字的数字
  1366. var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
  1367. var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
  1368. var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
  1369. var cnInteger = "整"; //整数金额时后面跟的字符
  1370. var cnIntLast = "元"; //整数完以后的单位
  1371. //最大处理的数字
  1372. var maxNum = 999999999999999.9999;
  1373. var integerNum; //金额整数部分
  1374. var decimalNum; //金额小数部分
  1375. //输出的中文金额字符串
  1376. var chineseStr = "";
  1377. var parts; //分离金额后用的数组,预定义
  1378. if (money == "" || money == null || money == undefined) {
  1379. return "零元零角零分";
  1380. }
  1381. money = parseFloat(money);
  1382. if (money >= maxNum) {
  1383. //超出最大处理数字
  1384. return "超出最大处理数字";
  1385. }
  1386. if (money == 0) {
  1387. chineseStr = cnNums[0] + cnIntLast + cnInteger;
  1388. return chineseStr;
  1389. }
  1390. //四舍五入保留两位小数,转换为字符串
  1391. money = Math.round(money * 100).toString();
  1392. integerNum = money.substr(0, money.length - 2);
  1393. decimalNum = money.substr(money.length - 2);
  1394. //获取整型部分转换
  1395. if (parseInt(integerNum, 10) > 0) {
  1396. var zeroCount = 0;
  1397. var IntLen = integerNum.length;
  1398. for (var i = 0; i < IntLen; i++) {
  1399. var n = integerNum.substr(i, 1);
  1400. var p = IntLen - i - 1;
  1401. var q = p / 4;
  1402. var m = p % 4;
  1403. if (n == "0") {
  1404. zeroCount++;
  1405. } else {
  1406. if (zeroCount > 0) {
  1407. chineseStr += cnNums[0];
  1408. }
  1409. //归零
  1410. zeroCount = 0;
  1411. chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
  1412. }
  1413. if (m == 0 && zeroCount < 4) {
  1414. chineseStr += cnIntUnits[q];
  1415. }
  1416. }
  1417. chineseStr += cnIntLast;
  1418. }
  1419. //小数部分
  1420. if (decimalNum != "") {
  1421. var decLen = decimalNum.length;
  1422. for (var i = 0; i < decLen; i++) {
  1423. var n = decimalNum.substr(i, 1);
  1424. if (n != "0") {
  1425. chineseStr += cnNums[Number(n)] + cnDecUnits[i];
  1426. }
  1427. }
  1428. }
  1429. if (chineseStr == "") {
  1430. chineseStr += cnNums[0] + cnIntLast + cnInteger;
  1431. } else if (decimalNum == "" || /^0*$/.test(decimalNum)) {
  1432. chineseStr += cnInteger;
  1433. }
  1434. return chineseStr;
  1435. },
  1436. },
  1437. };
  1438. </script>
  1439. <style>
  1440. .el-table .warning-row {
  1441. background: rgb(223, 223, 223);
  1442. }
  1443. </style>