editInvoiceTitle.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view>
  3. <u-navbar title="编辑发票抬头">
  4. <text class="delete" @click="delBtn()" v-if="obj.id&&!invoice">删除</text>
  5. </u-navbar>
  6. <u-cell-group>
  7. <u-cell-item title="抬头类型" required :arrow="false">
  8. <view class="">
  9. <u-radio-group v-model="obj.headerType" @change="radioGroupChange">
  10. <u-radio
  11. @change="radioChange"
  12. v-for="(item, index) in list" :key="index"
  13. :name="item.value"
  14. active-color="#00b962"
  15. >
  16. {{item.name}}
  17. </u-radio>
  18. </u-radio-group>
  19. </view>
  20. </u-cell-item>
  21. <u-cell-item title="发票抬头" :arrow="false" required >
  22. <u-input placeholder="请填写发票抬头" v-model="obj.title" ></u-input>
  23. </u-cell-item>
  24. <u-cell-item title="公司税号" :arrow="false" >
  25. <u-input placeholder="请填写纳税人识别号" v-model="obj.companyTaxNo" ></u-input>
  26. </u-cell-item>
  27. <u-cell-item title="设为默认" required :arrow="false" style="text-align: right;">
  28. <u-switch v-model="obj.defaultHeader" size="40" active-color="#00e266"></u-switch>
  29. </u-cell-item>
  30. </u-cell-group>
  31. <u-button type="success" shape="circle" @click="submit()">提交</u-button>
  32. </view>
  33. </template>
  34. <script>
  35. import * as API from '@/apis/invoiceApi.js'
  36. export default {
  37. data() {
  38. return {
  39. id:'',
  40. obj:{
  41. headerType:"1",
  42. title:"",
  43. companyTaxNo:"",
  44. defaultHeader:"1",
  45. },
  46. list: [
  47. {
  48. value:'1',
  49. name: '企业单位',
  50. disabled: false
  51. },
  52. {
  53. value:'2',
  54. name: '个人/非企业单位',
  55. disabled: false
  56. },
  57. ],
  58. invoice:false,
  59. checked:false,
  60. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  61. value: '企业单位',
  62. };
  63. },
  64. onLoad(op) {
  65. if(op.id){
  66. this.id=op.id;
  67. this.getInfo();
  68. }
  69. if(op.invoice){
  70. this.invoice=true;
  71. }
  72. },
  73. methods: {
  74. delBtn(){
  75. uni.showLoading({
  76. title: "加载中",
  77. mask: true,
  78. })
  79. API.deleteInvoiceType({
  80. invoiceTypeId:this.id
  81. }).then((res) => {
  82. uni.navigateBack({
  83. })
  84. uni.hideLoading()
  85. }).catch(error => {
  86. uni.showToast({
  87. title: error,
  88. icon: "none"
  89. })
  90. })
  91. },
  92. getInfo(){
  93. uni.showLoading({
  94. title: "加载中",
  95. mask: true,
  96. })
  97. API.invoiceTypeDetail({
  98. invoiceTypeId:this.id
  99. }).then((res) => {
  100. uni.hideLoading()
  101. this.obj=res.data.invoiceType
  102. }).catch(error => {
  103. uni.showToast({
  104. title: error,
  105. icon: "none"
  106. })
  107. })
  108. },
  109. submit(){
  110. if(!this.obj.title){
  111. uni.showToast({
  112. title:"请填写发票抬头"
  113. })
  114. return
  115. }
  116. uni.showLoading({
  117. title: "加载中",
  118. mask: true,
  119. })
  120. API.saveInvoiceType(this.obj).then((res) => {
  121. uni.navigateBack({
  122. })
  123. uni.hideLoading()
  124. }).catch(error => {
  125. uni.showToast({
  126. title: error,
  127. icon: "none"
  128. })
  129. })
  130. },
  131. // 选中某个单选框时,由radio时触发
  132. radioChange(e) {
  133. // console.log(e);
  134. },
  135. // 选中任一radio时,由radio-group触发
  136. radioGroupChange(e) {
  137. // console.log(e);
  138. }
  139. }
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. page {
  144. background-color: #fff;
  145. }
  146. .delete {
  147. position: absolute;
  148. right: 16px;
  149. color: rgba(238, 49, 56, 100);
  150. font-size: 12px
  151. }
  152. /deep/.u-cell__value{
  153. text-align: left;
  154. margin-left: 8%;
  155. font-size: 16px
  156. }
  157. /deep/.u-switch{
  158. margin: auto 0;
  159. float: right;;
  160. }
  161. /deep/.u-btn{
  162. width: 91.4%;
  163. margin: 12px auto;
  164. position: fixed;
  165. bottom: 0;
  166. left: 0;
  167. right: 0;
  168. }
  169. </style>