index.vue 38 KB

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