addBill.vue 43 KB

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