addBill.vue 38 KB

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