index.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412
  1. <template>
  2. <view class="invoice">
  3. <nav-bar title="发票申请"></nav-bar>
  4. <view class="invoice__tabs">
  5. <u-tabs :list="list" sticky :current="current" @change="change" active-color="#007AFF"></u-tabs>
  6. </view>
  7. <view class="invoice__content">
  8. <view class="open" v-if="current == 0">
  9. <view class="form">
  10. <u-form :model="form" ref="uForm">
  11. <u-form-item label="发票类型" label-width="150" required prop="type" >
  12. <u-radio-group v-model="form.type" @change="formTypeChange">
  13. <u-radio v-for="(item, index) in typeList" :key="index" :name="item.value">
  14. {{ item.name }}
  15. </u-radio>
  16. </u-radio-group>
  17. </u-form-item>
  18. <!-- 增值税发票 -->
  19. <template v-if="form.type == 2">
  20. <u-form-item label="申请主体" label-width="150" required prop="subject">
  21. <u-radio-group v-model="form.subject">
  22. <u-radio :key="index" name="2">
  23. 企业
  24. </u-radio>
  25. </u-radio-group>
  26. </u-form-item>
  27. <u-form-item label="发票抬头" label-width="150" required prop="invoiceTitle" >
  28. <u-input placeholder="请输入发票抬头" v-model="form.invoiceTitle" />
  29. </u-form-item>
  30. <u-form-item label="纳税登记号" label-width="150" required prop="taxRegistryNumber" >
  31. <u-input placeholder="请输入纳税登记号" v-model="form.taxRegistryNumber" />
  32. </u-form-item>
  33. <u-form-item label="单位地址" label-width="150" required prop="companyAddress" >
  34. <u-input placeholder="请输入单位地址" v-model="form.companyAddress" />
  35. </u-form-item>
  36. <u-form-item label="电话号码" label-width="150" required prop="phone" >
  37. <u-input placeholder="请输入电话号码" type="number" v-model="form.phone" />
  38. </u-form-item>
  39. <u-form-item label="开户银行" label-width="150" required prop="bankName" >
  40. <u-input placeholder="请输入开户银行" v-model="form.bankName" />
  41. </u-form-item>
  42. <u-form-item label="银行账号" label-width="150" required prop="bankAccount" >
  43. <u-input placeholder="请输入银行账号" type="number" v-model="form.bankAccount" />
  44. </u-form-item>
  45. <u-form-item label="收件地址" label-width="150" required prop="receivingAddress" >
  46. <u-input placeholder="请输入收件地址" v-model="form.receivingAddress" />
  47. </u-form-item>
  48. <u-form-item label="收件人" label-width="150" required prop="receivingName" >
  49. <u-input placeholder="请输入收件人" v-model="form.receivingName" />
  50. </u-form-item>
  51. <u-form-item label="收件手机" label-width="150" required prop="receivingTel" >
  52. <u-input placeholder="请输入收件手机" v-model="form.receivingTel" />
  53. </u-form-item>
  54. </template>
  55. <!-- 增值税发票 -->
  56. <!-- 普通发票 -->
  57. <template v-else>
  58. <u-form-item label="申请主体" label-width="150" required prop="subject">
  59. <u-radio-group v-model="form.subject">
  60. <u-radio v-for="(item, index) in mainList" :key="index" :name="item.value">
  61. {{ item.name }}
  62. </u-radio>
  63. </u-radio-group>
  64. </u-form-item>
  65. <u-form-item label="发票抬头" label-width="150" required prop="invoiceTitle" >
  66. <u-input placeholder="请输入发票抬头" v-model="form.invoiceTitle" />
  67. </u-form-item>
  68. <u-form-item v-if="form.subject == '2'" label="纳税登记号" label-width="150" required prop="taxRegistryNumber" >
  69. <u-input placeholder="请输入纳税登记号" v-model="form.taxRegistryNumber" />
  70. </u-form-item>
  71. </template>
  72. <!-- 普通发票 -->
  73. <u-form-item label="选择订单" label-width="150" required prop="orderGoodsIds" right-icon="arrow-right" ref="orderGoodsIds">
  74. <view class="form-item" @click="selectOrderModal = true">
  75. <u-input placeholder="请点击选择订单" disabled @click="selectOrderModal = true" />
  76. </view>
  77. </u-form-item>
  78. <view>
  79. <view class="check-order" v-for="(item,index) in orderList" :key="index" v-if="item.disabled">
  80. <view class="close" @click="deleteOrder(index)">
  81. <u-icon name="close-circle-fill" color="#FF2D55" size="40"></u-icon>
  82. </view>
  83. <view class="title">商品名称:{{item.goodsName}}</view>
  84. <view class="number">订单编号:{{item.orderSn}}</view>
  85. <view class="price">价格:¥ {{item.goodsPrice}}</view>
  86. </view>
  87. </view>
  88. </u-form>
  89. </view>
  90. <view class="order-text">
  91. <view class="order-text__label">本次申请开票金额:</view>
  92. <view class="order-text__price">¥ {{toFixed(invoicePirce)}}</view>
  93. </view>
  94. <view class="submit" @click="formSubmit">
  95. 提交申请
  96. </view>
  97. </view>
  98. <view class="record" v-if="current == 1">
  99. <view class="nodata" v-if="!recordList.length">
  100. 您暂无相关发票记录哦~
  101. </view>
  102. <view class="record__list">
  103. <view class="record-item" @click="showDetailModal(record);" v-for="(record,index) in recordList" :key="index">
  104. <view class="item__time">{{$method.timestampToTime(record.applyTime,false,false)}}</view>
  105. <view class="item__content">
  106. <view class="top">
  107. <view class="state" :class="{wait:record.periodStatus == 1,refuse:record.periodStatus == 2,agree:record.periodStatus == 3}">
  108. <text v-if="record.periodStatus == 1">待审核</text>
  109. <text v-if="record.periodStatus == 2">驳回</text>
  110. <text v-if="record.periodStatus == 3">通过</text>
  111. <u-icon class="arrow" name="arrow-right" color="#ffffff" size="28"></u-icon>
  112. </view>
  113. </view>
  114. <view class="bottom">
  115. <view class="flex">
  116. <view class="text">发票类型</view>
  117. <view class="flex__auto">
  118. <text v-if="record.type == 1">普通发票</text>
  119. <text v-if="record.type == 2">增值税专用发票</text>
  120. </view>
  121. </view>
  122. <view class="flex">
  123. <view class="text">申请主体</view>
  124. <view class="flex__auto">
  125. <text v-if="record.subject == 1">个人</text>
  126. <text v-if="record.subject == 2">企业</text>
  127. </view>
  128. </view>
  129. <view class="flex">
  130. <view class="text">发票状态</view>
  131. <view class="flex__auto">
  132. <text class="red" v-if="record.invoiceStatus == 1">未开票</text>
  133. <text class="green" v-if="record.invoiceStatus == 2">已开票</text>
  134. <text class="red" v-if="record.invoiceStatus == -1">已退票</text>
  135. </view>
  136. </view>
  137. <view @click.stop="showOrder(record.checked,index)">
  138. <view class="flex noborder" >
  139. <view class="text">开票订单</view>
  140. <view class="flex__auto">
  141. <text style="margin-right:10rpx;">{{record.orderList.length}}</text>
  142. <u-icon v-if="!record.checked" name="arrow-down" color="#ccc" size="28"></u-icon>
  143. <u-icon v-if="record.checked" name="arrow-up" color="#ccc" size="28"></u-icon>
  144. </view>
  145. </view>
  146. <view class="order-list" v-if="record.checked">
  147. <view class="order-item" :key="orderIndex" v-for="(orderItem,orderIndex) in record.orderList">{{orderIndex+1}}.{{orderItem.goodsName}}</view>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. <u-popup class="modal" v-model="selectOrderModal" mode="bottom" border-radius="24">
  157. <view class="select-order">
  158. <view class="line"></view>
  159. <view class="title">选择订单</view>
  160. <u-line color="#D6D6DB" />
  161. <view>
  162. <scroll-view scroll-y="true" style="height: 500rpx;">
  163. <view>
  164. <u-checkbox-group>
  165. <view v-for="(item, index) in orderList" :key="index" >
  166. <view class="order-item">
  167. <view>
  168. <u-checkbox
  169. :disabled="item.disabled"
  170. shape="circle"
  171. :name="item.name"
  172. v-model="item.checked"
  173. >
  174. <view class="order-item__bg" :class="item.checked?'active':''" >
  175. <view>
  176. <view class="order-title">{{item.goodsName}}</view>
  177. <view class="order-number">{{item.orderSn}}</view>
  178. <view class="order-price">¥ {{item.goodsPrice}}元</view>
  179. </view>
  180. </view>
  181. </u-checkbox >
  182. </view>
  183. </view>
  184. </view>
  185. </u-checkbox-group>
  186. </view>
  187. </scroll-view>
  188. </view>
  189. <view class="confrim-btn">
  190. <view class="okBtn" @click="okPopup()">确定</view>
  191. </view>
  192. </view>
  193. </u-popup>
  194. <u-popup class="modal" v-model="orderDetailModal" mode="center" border-radius="40">
  195. <view class="order-detail">
  196. <view class="order-detail__content">
  197. <scroll-view scroll-y="true" style="height: 860rpx;">
  198. <view class="content">
  199. <view class="header">{{$method.timestampToTime(invoiceDetail.applyTime,false,false)}}</view>
  200. <view class="body">
  201. <view class="body__item">
  202. <view class="title">发票申请信息</view>
  203. <view class="content">
  204. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  205. <view slot="title">发票类型:</view>
  206. <text v-if="invoiceDetail.type == 1">普通发票</text>
  207. <text v-if="invoiceDetail.type == 2">增值税专用发票</text>
  208. </u-cell-item>
  209. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  210. <view slot="title">申请主体:</view>
  211. <text v-if="invoiceDetail.subject == 1">个人</text>
  212. <text v-if="invoiceDetail.subject == 2">企业</text>
  213. </u-cell-item>
  214. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  215. <view slot="title">发票抬头:</view>
  216. <text>{{invoiceDetail.invoiceTitle}}</text>
  217. </u-cell-item>
  218. <template v-if="invoiceDetail.type == 2">
  219. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  220. <view slot="title">纳税登记号:</view>
  221. <text>{{invoiceDetail.taxRegistryNumber || ''}}</text>
  222. </u-cell-item>
  223. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  224. <view slot="title">单位地址:</view>
  225. <text>{{invoiceDetail.companyAddress || ''}}</text>
  226. </u-cell-item>
  227. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  228. <view slot="title">电话号码:</view>
  229. <text>{{invoiceDetail.phone || ''}}</text>
  230. </u-cell-item>
  231. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  232. <view slot="title">开户银行:</view>
  233. <text>{{invoiceDetail.bankName || ''}}</text>
  234. </u-cell-item>
  235. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  236. <view slot="title">银行账号:</view>
  237. <text>{{invoiceDetail.bankAccount || ''}}</text>
  238. </u-cell-item>
  239. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  240. <view slot="title">收件地址:</view>
  241. <text>{{invoiceDetail.receivingAddress || ''}}</text>
  242. </u-cell-item>
  243. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  244. <view slot="title">收件人:</view>
  245. <text>{{invoiceDetail.receivingName || ''}}</text>
  246. </u-cell-item>
  247. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" >
  248. <view slot="title">收件手机:</view>
  249. <text>{{invoiceDetail.receivingTel || ''}}</text>
  250. </u-cell-item>
  251. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" >
  252. <view slot="title">开票订单:</view>
  253. </u-cell-item>
  254. </template>
  255. <view class="order-list">
  256. <view class="order-item" :key="orderIndex" v-for="(orderItem,orderIndex) in invoiceDetail.orderList">
  257. <view class="order-title">{{orderItem.goodsName}}</view>
  258. <view class="order-number">{{orderItem.orderSn}}</view>
  259. <view class="order-price">¥ {{orderItem.goodsRealPrice}}元</view>
  260. </view>
  261. </view>
  262. <view class="order-text">
  263. <view class="order-text__label">本次申请开票金额:</view>
  264. <view class="order-text__price">¥ {{toFixed(invoiceDetail.amount)}}</view>
  265. </view>
  266. </view>
  267. </view>
  268. <view class="body__item">
  269. <view class="title">发票申请结果</view>
  270. <view class="content">
  271. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  272. <view slot="title">审核结果:</view>
  273. <text class="text wait" v-if="invoiceDetail.periodStatus == 1">待审核</text>
  274. <text class="text agree" v-if="invoiceDetail.periodStatus == 3">通过</text>
  275. <text class="text refuse" v-if="invoiceDetail.periodStatus == 2">驳回</text>
  276. </u-cell-item>
  277. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" v-if="invoiceDetail.periodReason">
  278. <view slot="title">审核反馈:</view>
  279. <text class="text">{{invoiceDetail.periodReason||''}}</text>
  280. </u-cell-item>
  281. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  282. <view slot="title">发票状态:</view>
  283. <text class="text refuse" v-if="invoiceDetail.invoiceStatus == 1">未开票</text>
  284. <text class="text agree" v-if="invoiceDetail.invoiceStatus == 2">已开票</text>
  285. <text class="text refuse" v-if="invoiceDetail.invoiceStatus == -1">已退票</text>
  286. </u-cell-item>
  287. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" v-if="invoiceDetail.periodStatus == 3 && (invoiceDetail.invoiceStatus == 2 || invoiceDetail.invoiceStatus == -1) && invoiceDetail.invoiceImg">
  288. <view slot="title">发票预览:</view>
  289. <view>
  290. <image class="preview" @click="previewImg(invoiceDetail)" :src="$method.splitImgHost(invoiceDetail.invoiceImg)"></image>
  291. <view class="download-btn" @click="download(invoiceDetail)">下载电子发票</view>
  292. </view>
  293. </u-cell-item>
  294. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" v-if="invoiceDetail.periodStatus == 3 && (invoiceDetail.invoiceStatus == 2 || invoiceDetail.invoiceStatus == -1) && invoiceDetail.type == 2 && invoiceDetail.subject == 2">
  295. <view slot="title">机构发票邮寄状态:</view>
  296. <text class="text" v-if="invoiceDetail.sendInvoice == 1">是</text>
  297. <text class="text" v-else>否</text>
  298. </u-cell-item>
  299. <u-cell-item v-if="invoiceDetail.periodStatus == 3 && (invoiceDetail.invoiceStatus == 2 || invoiceDetail.invoiceStatus == -1) && invoiceDetail.sendInvoice == 1 && invoiceDetail.type == 2 && invoiceDetail.subject == 2" @click.stop="copy(invoiceDetail.trackingNum)" :border-bottom="false" hover-class="none" :arrow="false">
  300. <view slot="title">发票邮寄快递单号:(点击可复制)</view>
  301. <text class="text">{{invoiceDetail.trackingNum || ''}}</text>
  302. </u-cell-item>
  303. </view>
  304. </view>
  305. </view>
  306. </view>
  307. </scroll-view>
  308. </view>
  309. <view class="order-detail__btns" v-if="invoiceDetail.periodStatus == 1">
  310. <view class="btn" @click="orderDetailModal = false;">知道了</view>
  311. <view class="btn warm" @click="orderCancelModal = true;">撤销申请</view>
  312. </view>
  313. <view class="order-detail__btns" v-else>
  314. <view class="btn ok" @click="orderDetailModal = false;">知道了</view>
  315. </view>
  316. </view>
  317. </u-popup>
  318. <u-popup class="modal" v-model="orderCancelModal" mode="center" border-radius="24">
  319. <view class="order-cancel">
  320. <view class="header">
  321. 温馨提示
  322. </view>
  323. <view class="body">
  324. <view>撤销申请后,</view>
  325. <view>本次的发票申请内容将不存在。</view>
  326. <view>请慎重考虑。 </view>
  327. <view>您确定要取消本次发票申请吗?</view>
  328. </view>
  329. <view class="footer">
  330. <view class="btn cancel" @click="orderCancelModal = false;">取消</view>
  331. <view class="btn ok" @click="orderCancel()">确定</view>
  332. </view>
  333. </view>
  334. </u-popup>
  335. </view>
  336. </template>
  337. <script>
  338. import { mapGetters } from 'vuex';
  339. export default {
  340. components: {},
  341. data() {
  342. return {
  343. checkOrderList:[],
  344. recordList:[],
  345. list: [
  346. {
  347. name: '发票申请'
  348. },
  349. {
  350. name: '发票记录'
  351. }
  352. ],
  353. invoiceDetail:{
  354. amount:0
  355. },
  356. form:{
  357. type:'1',
  358. subject:'1',
  359. invoiceTitle:'',
  360. orderGoodsIds:'',
  361. taxRegistryNumber:'',
  362. companyAddress:'',
  363. phone:'',
  364. bankName:'',
  365. bankAccount:'',
  366. receivingAddress:'',
  367. receivingName:'',
  368. receivingTel:'',
  369. },
  370. rules: {
  371. receivingTel: [
  372. {
  373. required: true,
  374. message: '请输入收件手机',
  375. // 可以单个或者同时写两个触发验证方式
  376. trigger: ['change'],
  377. },
  378. {
  379. validator: (rule, value, callback) => {
  380. // 上面有说,返回true表示校验通过,返回false表示不通过
  381. // this.$u.test.mobile()就是返回true或者false的
  382. console.log(this.$u.test.mobile(value),'this.$u.test.mobile(value)')
  383. return this.$u.test.mobile(value);
  384. },
  385. message: '手机号码格式不正确',
  386. // 触发器可以同时用blur和change
  387. trigger: ['change'],
  388. }
  389. ],
  390. type: [
  391. {
  392. required: true,
  393. message: '请选择发票类型',
  394. // 可以单个或者同时写两个触发验证方式
  395. trigger: ['change'],
  396. }
  397. ],
  398. subject: [
  399. {
  400. required: true,
  401. message: '请选择申请主体',
  402. // 可以单个或者同时写两个触发验证方式
  403. trigger: ['change'],
  404. }
  405. ],
  406. invoiceTitle: [
  407. {
  408. required: true,
  409. message: '请输入发票抬头',
  410. // 可以单个或者同时写两个触发验证方式
  411. trigger: ['change'],
  412. },
  413. ],
  414. taxRegistryNumber: [
  415. {
  416. required: true,
  417. message: '请输入纳税登记号',
  418. // 可以单个或者同时写两个触发验证方式
  419. trigger: ['change'],
  420. },
  421. {
  422. validator: (rule, value, callback) => {
  423. // 上面有说,返回true表示校验通过,返回false表示不通过
  424. var reg = /(^[0-9A-Z]{15,20}$)/;
  425. console.log( reg.test(value),' reg.test(value)')
  426. return reg.test(value);
  427. },
  428. message: '发票抬头格式不正确',
  429. // 触发器可以同时用blur和change
  430. trigger: ['change'],
  431. }
  432. ],
  433. companyAddress: [
  434. {
  435. required: true,
  436. message: '请输入单位地址',
  437. // 可以单个或者同时写两个触发验证方式
  438. trigger: ['change'],
  439. }
  440. ],
  441. phone: [
  442. {
  443. required: true,
  444. message: '请输入电话号码',
  445. // 可以单个或者同时写两个触发验证方式
  446. trigger: ['change'],
  447. },
  448. {
  449. validator: (rule, value, callback) => {
  450. var vartest = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
  451. var vartest1 = /^([0-9]{3,4})?[0-9]{7,8}$/;
  452. if (this.$u.test.mobile(value) || vartest.test(value) || vartest1.test(value)) {
  453. return true;
  454. } else {
  455. return false;
  456. }
  457. },
  458. message: '电话号码不正确',
  459. trigger: ['change', 'blur']
  460. }
  461. ],
  462. bankName: [
  463. {
  464. required: true,
  465. message: '请输入开户银行',
  466. // 可以单个或者同时写两个触发验证方式
  467. trigger: ['change'],
  468. },
  469. {
  470. validator: (rule, value, callback) => {
  471. var reg = /[\u4E00-\u9FA5]+/;
  472. return reg.test(value)
  473. },
  474. message: '开户银行名称不正确',
  475. trigger: ['change', 'blur']
  476. }
  477. ],
  478. bankAccount: [
  479. {
  480. required: true,
  481. message: '请输入银行账号',
  482. // 可以单个或者同时写两个触发验证方式
  483. trigger: ['change'],
  484. },
  485. {
  486. validator: (rule, value, callback) => {
  487. // 上面有说,返回true表示校验通过,返回false表示不通过
  488. var reg = /^[1-9]{1}(\d{15}|\d{18})$/;
  489. console.log( reg.test(value),' reg.test(value)')
  490. return reg.test(value);
  491. },
  492. message: '银行卡号格式不正确',
  493. // 触发器可以同时用blur和change
  494. trigger: ['change'],
  495. }
  496. ],
  497. receivingAddress: [
  498. {
  499. required: true,
  500. message: '请输入收件地址',
  501. // 可以单个或者同时写两个触发验证方式
  502. trigger: ['change'],
  503. }
  504. ],
  505. receivingName: [
  506. {
  507. required: true,
  508. message: '请输入收件人',
  509. // 可以单个或者同时写两个触发验证方式
  510. trigger: ['change'],
  511. }
  512. ],
  513. orderGoodsIds: [
  514. {
  515. required: true,
  516. message: '请选择订单',
  517. // 可以单个或者同时写两个触发验证方式
  518. trigger: ['change'],
  519. }
  520. ],
  521. },
  522. orderValue:'',
  523. orderList:[],
  524. selectOrderModal:false,
  525. orderDetailModal:false,
  526. orderCancelModal:false,
  527. current: 0,
  528. invoicePirce:0,
  529. order: [],
  530. typeList:[{
  531. name:'普通发票',
  532. value:'1'
  533. },{
  534. name:'增值税专用发票',
  535. value:'2'
  536. }],
  537. mainList:[{
  538. name:'个人',
  539. value:'1'
  540. },{
  541. name:'企业',
  542. value:'2'
  543. }]
  544. };
  545. },
  546. // onPullDownRefresh() {},
  547. onLoad(option) {
  548. this.orderInvoiceCanInvoiceList();
  549. this.$refs.uForm.setRules(this.rules)
  550. },
  551. onShow() {
  552. },
  553. methods: {
  554. orderCancel() {
  555. let invoiceDetail = JSON.parse(JSON.stringify(this.invoiceDetail))
  556. invoiceDetail.status = -1;
  557. this.$api.orderInvoiceCancel(invoiceDetail).then(res => {
  558. if(res.data.code == 200) {
  559. this.orderInvoiceList();
  560. this.orderInvoiceCanInvoiceList();
  561. this.orderDetailModal = false;
  562. this.orderCancelModal = false;
  563. uni.showToast({
  564. title:'撤销成功',
  565. icon:'none'
  566. })
  567. } else {
  568. }
  569. })
  570. },
  571. showDetailModal(item) {
  572. this.orderDetailModal = true;
  573. this.invoiceDetail = item;
  574. },
  575. toFixed(number) {
  576. console.log(number.toFixed(2))
  577. return number.toFixed(2)
  578. },
  579. /**
  580. * 获取可开发票的订单
  581. */
  582. orderInvoiceCanInvoiceList() {
  583. this.$api.orderInvoiceCanInvoiceList().then(res => {
  584. if(res.data.code == 200) {
  585. res.data.rows.forEach(item => {
  586. item.checked = false;
  587. })
  588. this.orderList = res.data.rows;
  589. }
  590. })
  591. },
  592. /**
  593. * @param {Object} checkedState 显示状态
  594. * @param {Object} index 索引值
  595. * 修改开票订单列表显示状态
  596. */
  597. showOrder(showState,index) {
  598. this.$set(this.recordList[index],'checked',!showState)
  599. },
  600. /**
  601. * 发票申请提交
  602. */
  603. formSubmit() {
  604. this.$refs.uForm.validate(valid => {
  605. console.log(valid,'valid')
  606. console.log(this.form,'this.form')
  607. if(valid) {
  608. if(this.invoicePirce > 10000) {
  609. uni.showModal({
  610. title:'提示',
  611. content:'您所选的订单总开票金额,大于10000元,超出单张发票的开票额度,请修改开票订单',
  612. showCancel:false,
  613. })
  614. return
  615. }
  616. let data = JSON.parse(JSON.stringify(this.form));
  617. data.orderGoodsIds = data.orderGoodsIds.split(',')
  618. data.amount = this.invoicePirce;
  619. if(data.subject == '1') {
  620. data.taxRegistryNumber = '';
  621. data.companyAddress = '';
  622. data.phone = '';
  623. data.bankName = '';
  624. data.bankAccount = '';
  625. data.receivingAddress = '';
  626. data.receivingName = '';
  627. data.receivingTel = '';
  628. }
  629. this.$api.orderInvoice(data).then(res => {
  630. if(res.data.code == 200) {
  631. this.orderInvoiceCanInvoiceList();
  632. this.form = {
  633. type:'1',
  634. subject:'1',
  635. invoiceTitle:'',
  636. orderGoodsIds:'',
  637. taxRegistryNumber:'',
  638. companyAddress:'',
  639. phone:'',
  640. bankName:'',
  641. bankAccount:'',
  642. receivingAddress:'',
  643. receivingName:'',
  644. receivingTel:'',
  645. };
  646. this.invoicePirce = 0;
  647. uni.showModal({
  648. title:'操作提示',
  649. content:`您本次的发票申请已经提交成功!\n机构将在3-7个工作日内进行处理,处理结果会在【发票记录】显示,请留意进度。`,
  650. showCancel:false,
  651. confirmText:'知道了'
  652. })
  653. } else {
  654. uni.showToast({
  655. icon:'none',
  656. title:res.data.msg
  657. })
  658. }
  659. })
  660. }
  661. })
  662. },
  663. /**
  664. * @param {Object} e value
  665. * 发票类型修改
  666. */
  667. formTypeChange(e) {
  668. console.log(e)
  669. if(e == '2') {
  670. this.$set(this.form,'subject','2')
  671. } else {
  672. }
  673. },
  674. /**
  675. * @param {Object} e
  676. * tabs 切换
  677. */
  678. change(e) {
  679. console.log(e)
  680. this.current = e;
  681. if(this.current == 1) {
  682. this.orderInvoiceList();
  683. } else {
  684. this.$nextTick(() => {
  685. this.$refs.uForm.setRules(this.rules)
  686. })
  687. }
  688. },
  689. orderInvoiceList() {
  690. this.$api.orderInvoiceList().then(res => {
  691. if(res.data.code == 200) {
  692. this.recordList = res.data.rows
  693. } else {
  694. uni.showToast({
  695. icon:'none',
  696. title:res.data.msg
  697. })
  698. }
  699. })
  700. },
  701. radioGroupChange(e) {
  702. console.log(e)
  703. },
  704. copy(str) {
  705. if(!str) {
  706. uni.showToast({
  707. icon:'none',
  708. title:'暂时没有可以复制的快递号'
  709. })
  710. return;
  711. }
  712. let newStr = String(str)
  713. uni.setClipboardData({
  714. data: newStr,
  715. success: function () {
  716. console.log('success');
  717. }
  718. });
  719. },
  720. okPopup() {
  721. this.selectOrderModal = false;
  722. let strArr = [];
  723. this.invoicePirce = 0;
  724. this.orderList.forEach((item,index) => {
  725. if(item.checked) {
  726. this.$set(this.orderList[index],'disabled',true)
  727. strArr.push(item.orderGoodsId)
  728. this.invoicePirce += item.goodsPrice
  729. }
  730. })
  731. this.form.orderGoodsIds = strArr.join(',')
  732. this.$nextTick(() => {
  733. this.$refs.orderGoodsIds.onFieldChange()
  734. })
  735. console.log(this.$refs.orderGoodsIds)
  736. },
  737. deleteOrder(index) {
  738. this.$set(this.orderList[index],'disabled',false)
  739. this.$set(this.orderList[index],'checked',false)
  740. let strArr = [];
  741. this.invoicePirce = 0;
  742. this.orderList.forEach((item,index) => {
  743. if(item.checked) {
  744. strArr.push(item.orderGoodsId)
  745. this.invoicePirce += item.goodsPrice
  746. }
  747. })
  748. this.form.orderGoodsIds = strArr.join(',')
  749. this.$nextTick(() => {
  750. this.$refs.orderGoodsIds.onFieldChange()
  751. })
  752. },
  753. previewImg(item) {
  754. // 预览图片
  755. uni.previewImage({
  756. urls: [this.$method.splitImgHost(item.invoiceImg,true,1000)],
  757. longPressActions: {
  758. itemList: ['发送给朋友', '保存图片', '收藏'],
  759. success: function(data) {
  760. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  761. },
  762. fail: function(err) {
  763. console.log(err.errMsg);
  764. }
  765. }
  766. });
  767. },
  768. download(item) {
  769. //获取相册授权
  770. uni.getSetting({
  771. success:(res) => {
  772. if (!res.authSetting['scope.writePhotosAlbum']) {
  773. uni.authorize({
  774. scope: 'scope.writePhotosAlbum',
  775. success() {
  776. //这里是用户同意授权后的回调
  777. this.saveImgToLocal(item);
  778. },
  779. fail() {//这里是用户拒绝授权后的回调
  780. }
  781. })
  782. } else {//用户已经授权过了
  783. this.saveImgToLocal(item);
  784. }
  785. }
  786. })
  787. },
  788. saveImgToLocal(item){
  789. uni.showModal({
  790. title: '提示',
  791. content: '确定保存到相册吗',
  792. success: (res) => {
  793. if (res.confirm) {
  794. uni.downloadFile({
  795. url: this.$method.splitImgHost(item.invoiceImg,true,1000),//图片地址
  796. success: (res) =>{
  797. if (res.statusCode === 200){
  798. uni.saveImageToPhotosAlbum({
  799. filePath: res.tempFilePath,
  800. success: function() {
  801. uni.showToast({
  802. title: "保存成功",
  803. icon: "none"
  804. });
  805. },
  806. fail: function() {
  807. uni.showToast({
  808. title: "保存失败",
  809. icon: "none"
  810. });
  811. }
  812. });
  813. }
  814. }
  815. })
  816. } else if (res.cancel) {
  817. }
  818. }
  819. });
  820. }
  821. },
  822. computed: { ...mapGetters(['userInfo']) }
  823. };
  824. </script>
  825. <style>
  826. page {
  827. background: #eaeef1;
  828. }
  829. </style>
  830. <style scoped lang="scss">
  831. .invoice {
  832. &__tabs {
  833. width: 100%;
  834. text-align: center;
  835. position: fixed;
  836. height: 96rpx;
  837. z-index: 999;
  838. }
  839. &__content {
  840. padding-top:96rpx;
  841. .open {
  842. padding-bottom:150rpx;
  843. margin:8rpx 24rpx 0;
  844. .form {
  845. padding:24rpx;
  846. width: 702rpx;
  847. background: #FFFFFF;
  848. border-radius: 24rpx;
  849. // /deep/ .u-input__input {
  850. // text-align: right;
  851. // }
  852. .form-item {
  853. height:78rpx;
  854. display: flex;
  855. align-items: center;
  856. .text {
  857. font-size: 28rpx;
  858. width:120rpx;
  859. // color: #999999;
  860. }
  861. .content {
  862. flex:1;
  863. text-align: left;
  864. color:#bbb;
  865. }
  866. }
  867. .check-order {
  868. margin-top:20rpx;
  869. width: 654rpx;
  870. height: 168rpx;
  871. background: #F5F5F5;
  872. border: 2px solid #F5F5F5;
  873. padding:20rpx;
  874. position:relative;
  875. .close {
  876. position:absolute;
  877. right:0;
  878. top:0;
  879. }
  880. .title,.number,.price {
  881. color:#333333;
  882. margin-top:10rpx;
  883. line-height: 30rpx;
  884. font-size: 30rpx;
  885. }
  886. .number {
  887. color:#999;
  888. }
  889. }
  890. }
  891. .order-text {
  892. margin-top:16rpx;
  893. padding:0 30rpx;
  894. width: 702rpx;
  895. height: 80rpx;
  896. background: #FFFFFF;
  897. border-radius: 24rpx;
  898. display: flex;
  899. align-items: center;
  900. &__label {
  901. font-size: 24rpx;
  902. }
  903. &__price {
  904. font-size: 30rpx;
  905. margin-left:20rpx;
  906. color:#FF2D55;
  907. }
  908. }
  909. .submit {
  910. text-align: center;
  911. line-height: 80rpx;
  912. color:#fff;
  913. font-size: 30rpx;
  914. width: 526rpx;
  915. height: 80rpx;
  916. background: #007AFF;
  917. box-shadow: 0rpx 8rpx 7rpx 1rpx rgba(0, 122, 255, 0.1);
  918. border-radius: 40rpx;
  919. position:fixed;
  920. left:50%;
  921. bottom:40rpx;
  922. z-index: 999;
  923. transform: translateX(-50%);
  924. }
  925. }
  926. .record {
  927. .nodata {
  928. padding-top:160rpx;
  929. font-size: 32rpx;
  930. text-align: center;
  931. color: #999999;
  932. }
  933. &__list {
  934. .record-item {
  935. margin:0 8rpx 10rpx;
  936. .item__time {
  937. padding:20rpx 0;
  938. text-align: center;
  939. font-size: 24rpx;
  940. color: #999999;
  941. }
  942. .item__content {
  943. background:#fff;
  944. border-radius: 16rpx;
  945. .top {
  946. padding:12rpx 0;
  947. border-bottom:1px solid #EEEEEE;
  948. .state {
  949. position:relative;
  950. text-align: center;
  951. color:#fff;
  952. font-size: 30rpx;
  953. margin:0 auto;
  954. width: 240rpx;
  955. height: 56rpx;
  956. line-height: 56rpx;
  957. background: #007AFF;
  958. border-radius: 28rpx;
  959. &.wait {
  960. background: #007AFF;
  961. }
  962. &.refuse {
  963. background: #FF3B30;
  964. }
  965. &.agree {
  966. background: #34C759;
  967. }
  968. .arrow {
  969. position:absolute;
  970. top:50%;
  971. transform: translateY(-50%);
  972. right:18rpx;
  973. }
  974. }
  975. }
  976. .bottom {
  977. padding:0 32rpx;
  978. .flex {
  979. height:80rpx;
  980. display: flex;
  981. align-items: center;
  982. border-bottom:1px solid #EEEEEE;
  983. &.noborder{
  984. border:0;
  985. }
  986. .text {
  987. font-size: 24rpx;
  988. color: #666666;
  989. }
  990. &__auto {
  991. text-align: right;
  992. flex:1;
  993. font-size: 30rpx;
  994. font-weight: bold;
  995. color: #666666;
  996. .red {
  997. color:#FF3B30;
  998. }
  999. .green {
  1000. color:#34C759;
  1001. }
  1002. }
  1003. }
  1004. .order-list {
  1005. padding-bottom:30rpx;
  1006. .order-item {
  1007. border-radius: 16rpx;
  1008. padding:14rpx;
  1009. background:#F5F5F5;
  1010. font-size: 30rpx;
  1011. color:#333;
  1012. margin-top:16rpx;
  1013. }
  1014. }
  1015. }
  1016. }
  1017. }
  1018. }
  1019. }
  1020. }
  1021. .modal {
  1022. .select-order {
  1023. .line {
  1024. width: 80rpx;
  1025. height: 8rpx;
  1026. background: #999999;
  1027. border-radius: 4rpx;
  1028. margin:8rpx auto 0;
  1029. }
  1030. .title {
  1031. margin:20rpx 0 15rpx;
  1032. text-align: center;
  1033. font-size: 24rpx;
  1034. color: #999999;
  1035. }
  1036. .order-item {
  1037. display: flex;
  1038. align-items: center;
  1039. padding: 20rpx;
  1040. &__bg {
  1041. width: 654rpx;
  1042. height: 168rpx;
  1043. background: #F5F5F5;
  1044. border: 2px solid #F5F5F5;
  1045. border-radius: 16rpx;
  1046. padding:20rpx;
  1047. &.active {
  1048. background: #EBF5FF;
  1049. border: 2px solid #007AFF;
  1050. }
  1051. .order-title,.order-number,.order-price {
  1052. color:#333333;
  1053. margin-top:10rpx;
  1054. line-height: 30rpx;
  1055. font-size: 30rpx;
  1056. }
  1057. .order-number {
  1058. color:#999;
  1059. }
  1060. }
  1061. }
  1062. .confrim-btn {
  1063. width: 750rpx;
  1064. height: 98rpx;
  1065. background: rgba(255, 255, 255, 0.98);
  1066. display: flex;
  1067. align-items: center;
  1068. justify-content: center;
  1069. .okBtn {
  1070. text-align: center;
  1071. line-height: 64rpx;
  1072. color:#fff;
  1073. font-size: 30rpx;
  1074. width: 200rpx;
  1075. height: 64rpx;
  1076. background: linear-gradient(0deg, #015EEA, #00C0FA);
  1077. border-radius: 32rpx;
  1078. }
  1079. }
  1080. }
  1081. .order-detail {
  1082. width: 640rpx;
  1083. height: 1000rpx;
  1084. background: #FFFFFF;
  1085. display: flex;
  1086. flex-direction: column;
  1087. &__content {
  1088. flex:1;
  1089. .content {
  1090. padding:24rpx 24rpx 0;
  1091. /deep/ .u-cell {
  1092. padding:10rpx;
  1093. &_title {
  1094. color:#999;
  1095. }
  1096. &__value {
  1097. color:#333;
  1098. text-align: left;
  1099. }
  1100. .text {
  1101. &.wait {
  1102. color:#007AFF;
  1103. }
  1104. &.agree {
  1105. color:#34C759;
  1106. }
  1107. &.refuse {
  1108. color:#FF3B30;
  1109. }
  1110. }
  1111. .preview {
  1112. width:240rpx;
  1113. height:160rpx;
  1114. }
  1115. .download-btn {
  1116. margin:10rpx 0 0;
  1117. text-align: center;
  1118. line-height: 56rpx;
  1119. color:#fff;
  1120. font-size: 30rpx;
  1121. width: 224rpx;
  1122. height: 56rpx;
  1123. background: #007AFF;
  1124. border-radius: 16rpx;
  1125. }
  1126. }
  1127. .header {
  1128. font-size: 30rpx;
  1129. font-weight: bold;
  1130. color: #333333;
  1131. line-height: 48rpx;
  1132. }
  1133. .body {
  1134. &__item {
  1135. border-bottom:1px solid #EEEEEE;
  1136. padding-bottom:30rpx;
  1137. &:last-child {
  1138. border:0;
  1139. }
  1140. .title {
  1141. margin-top:30rpx;
  1142. font-size: 24rpx;
  1143. color: #007AFF;
  1144. line-height: 48rpx;
  1145. &::before {
  1146. content:'';
  1147. width: 4rpx;
  1148. height: 24rpx;
  1149. background: #007AFF;
  1150. border-radius: 2rpx;
  1151. display: inline-block;
  1152. margin-right:10rpx;
  1153. }
  1154. }
  1155. .order-list {
  1156. .order-item {
  1157. overflow: hidden;
  1158. border-radius: 16rpx;
  1159. padding:0 14rpx 14rpx;
  1160. background:#F5F5F5;
  1161. font-size: 30rpx;
  1162. color:#333;
  1163. margin-top:16rpx;
  1164. .order-title,.order-number,.order-price {
  1165. color:#333333;
  1166. margin-top:20rpx;
  1167. line-height: 26rpx;
  1168. font-size: 26rpx;
  1169. }
  1170. .order-number {
  1171. color:#999;
  1172. }
  1173. }
  1174. }
  1175. .order-text {
  1176. margin-top:16rpx;
  1177. padding:0 30rpx;
  1178. height: 80rpx;
  1179. background: #F5F5F5;
  1180. border-radius: 16rpx;
  1181. display: flex;
  1182. align-items: center;
  1183. &__label {
  1184. font-size: 24rpx;
  1185. color:#999999;
  1186. }
  1187. &__price {
  1188. font-size: 30rpx;
  1189. margin-left:20rpx;
  1190. color:#FF2D55;
  1191. }
  1192. }
  1193. }
  1194. }
  1195. }
  1196. }
  1197. &__btns {
  1198. border-top:1px solid #EEEEEE;
  1199. padding:0 24rpx;
  1200. width: 100%;
  1201. height: 140rpx;
  1202. background: #FFFFFF;
  1203. display: flex;
  1204. justify-content: center;
  1205. align-items: center;
  1206. .btn {
  1207. text-align: center;
  1208. width: 200rpx;
  1209. height: 80rpx;
  1210. line-height: 80rpx;
  1211. background: #F5F5F5;
  1212. border-radius: 40rpx;
  1213. color:#007AFF;
  1214. font-size: 30rpx;
  1215. margin:0 10rpx;
  1216. &.warm {
  1217. background: #FF3B30;
  1218. color:#fff;
  1219. }
  1220. &.ok {
  1221. color:#fff;
  1222. width: 526rpx;
  1223. height: 80rpx;
  1224. background: #007AFF;
  1225. border-radius: 40rpx;
  1226. }
  1227. }
  1228. }
  1229. }
  1230. .order-cancel {
  1231. width: 640rpx;
  1232. height: 439rpx;
  1233. background: #FFFFFF;
  1234. padding:40rpx;
  1235. .header {
  1236. text-align: center;
  1237. font-size: 30rpx;
  1238. font-weight: bold;
  1239. color: #333333;
  1240. line-height: 48rpx;
  1241. }
  1242. .body {
  1243. margin-top:40rpx;
  1244. view {
  1245. font-size: 30rpx;
  1246. color: #666666;
  1247. line-height: 48rpx;
  1248. }
  1249. }
  1250. .footer {
  1251. margin-top:40rpx;
  1252. display: flex;
  1253. align-items: center;
  1254. justify-content: center;
  1255. .btn {
  1256. text-align: center;
  1257. line-height: 80rpx;
  1258. font-size: 30rpx;
  1259. color:#007AFF;
  1260. width: 200rpx;
  1261. height: 80rpx;
  1262. background: #F5F5F5;
  1263. border-radius: 40rpx;
  1264. margin:0 10rpx;
  1265. &.ok {
  1266. color:#fff;
  1267. background: #007AFF;
  1268. }
  1269. }
  1270. }
  1271. }
  1272. }
  1273. }
  1274. </style>