addInvoiceTitle.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <view>
  3. <u-navbar :title="title" title-color="#101010" >
  4. <view class="slot" style=" color: #ee3138;" v-if="id"
  5. slot="right" @click="show=true">
  6. 删除
  7. </view>
  8. </u-navbar>
  9. <!-- 删除弹出框 -->
  10. <u-popup v-model="show" mode="bottom" border-radius="12" >
  11. <view class="popup">
  12. <view class="headline">
  13. 确认删除
  14. </view>
  15. <view class="hint">
  16. 是否删除此发票抬头?
  17. </view>
  18. <view class="btn-box">
  19. <view class="think" @click="show=false" >
  20. 我再想想
  21. </view>
  22. <view class="confirm" @click="deleteBtn" >
  23. 确认删除
  24. </view>
  25. </view>
  26. </view>
  27. </u-popup>
  28. <!-- 类型 -->
  29. <view class="main">
  30. <u-cell-group>
  31. <u-cell-item title="抬头类型" required :arrow="false" >
  32. <u-radio-group v-model="form.headerType" @change="radioGroupChange">
  33. <u-radio
  34. @change="radioChange"
  35. v-for="(item, index) in list" :key="index"
  36. :name="item.id"
  37. :disabled="item.disabled"
  38. >
  39. {{item.name}}
  40. </u-radio>
  41. </u-radio-group>
  42. </u-cell-item>
  43. <u-cell-item title="发票类型" required :arrow="false" v-show="setparameter('type')" >
  44. <u-radio-group v-model="form.type" @change="radioGroupChange">
  45. <u-radio
  46. @change="radioChange"
  47. v-for="(item, index) in list2" :key="index"
  48. :name="item.id"
  49. :disabled="item.disabled"
  50. >
  51. {{item.name}}
  52. </u-radio>
  53. </u-radio-group>
  54. </u-cell-item>
  55. </u-cell-group>
  56. </view>
  57. <!-- 其他信息 -->
  58. <view class="main">
  59. <u-cell-group>
  60. <u-cell-item title="发票抬头" required :arrow="false" v-show="setparameter('title')" >
  61. <u-input placeholder="请填写发票抬头" v-model="form.title" ></u-input>
  62. </u-cell-item>
  63. <u-cell-item title="公司税号" required :arrow="false" v-show="setparameter('companyTaxNo')" >
  64. <u-input placeholder="请填写纳税人税号" v-model="form.companyTaxNo" ></u-input>
  65. </u-cell-item>
  66. <u-cell-item title="开户银行" :required="setparameter('bankName')==2" :arrow="false" v-show="setparameter('bankName')" >
  67. <u-input placeholder="请填写开户银行全称" v-model="form.bankName" ></u-input>
  68. </u-cell-item>
  69. <u-cell-item title="银行账户" :required="setparameter('accountNo')==2" :arrow="false" v-show="setparameter('accountNo')" >
  70. <u-input placeholder="请填写银行账户" v-model="form.accountNo" ></u-input>
  71. </u-cell-item>
  72. <u-cell-item title="公司地址" :required="setparameter('companyAddress')==2" :arrow="false" v-show="setparameter('companyAddress')" >
  73. <u-input placeholder="请填写公司详细地址" v-model="form.companyAddress" ></u-input>
  74. </u-cell-item>
  75. <u-cell-item title="身份证号" required :arrow="false" v-show="setparameter('idCard')" >
  76. <u-input placeholder="请填写身份证号" v-model="form.idCard" ></u-input>
  77. </u-cell-item>
  78. </u-cell-group>
  79. </view>
  80. <view class="main">
  81. <u-cell-item title="联系电话" required :arrow="false" v-show="setparameter('companyTelephone')" >
  82. <u-input placeholder="请填写联系电话" v-model="form.companyTelephone" ></u-input>
  83. </u-cell-item>
  84. </view>
  85. <!-- 默认 -->
  86. <view class="main ">
  87. <u-cell-item title="设为默认" :arrow="false" >
  88. <u-switch size="40" v-model="defaultHeader"
  89. active-color="#00e266"></u-switch>
  90. </u-cell-item>
  91. </view>
  92. <button class="save" @click="submit">保存</button>
  93. </view>
  94. </template>
  95. <script>
  96. import * as API from '@/apis/pagejs/invoiceApi.js'
  97. import {
  98. checkPhone
  99. } from '@/apis/utils'
  100. export default {
  101. data() {
  102. return {
  103. show:false,
  104. checked:true,
  105. list: [
  106. {
  107. id:1,
  108. name: '企业单位',
  109. disabled: false
  110. },
  111. {
  112. id:2,
  113. name: '个人/非企业单位',
  114. disabled: false
  115. }
  116. ],
  117. list2: [
  118. {
  119. id:1,
  120. name: '增值税专票',
  121. disabled: false
  122. },
  123. {
  124. id:2,
  125. name: '增值税普票',
  126. disabled: false
  127. }
  128. ],
  129. defaultHeader:true,
  130. value: 'orange',
  131. id:"",
  132. detail:{},
  133. form:{
  134. headerType:'',//专票必填
  135. type:"",//专票必填
  136. //companyName:"",//专票必填
  137. companyTaxNo:"",//专票必填
  138. bankName:"",
  139. accountNo:"",
  140. companyAddress:"",
  141. companyTelephone:"",
  142. defaultHeader:1,
  143. title:"",//个人
  144. idCard:"",//个人
  145. },
  146. formKey:{
  147. headerType:'抬头类型',//专票必填
  148. type:"发票类型",//专票必填
  149. //companyName:"",//专票必填
  150. companyTaxNo:"公司税号",//专票必填
  151. bankName:"开户银行",
  152. accountNo:"银行账户",
  153. companyAddress:"公司地址",
  154. companyTelephone:"联系电话",
  155. defaultHeader:1,
  156. title:"发票抬头",//个人
  157. idCard:"身份证号",//个人
  158. },
  159. title:"新增发票抬头"
  160. };
  161. },
  162. computed:{
  163. ruleReqlist(){
  164. if(this.form.headerType==2){
  165. return ["headerType","title","idCard","companyTelephone"]
  166. }else if(this.form.headerType==1&&this.form.type==2){
  167. return ["headerType","type","title","companyTaxNo",
  168. "companyTelephone"]
  169. }else{
  170. return ["headerType","type","title","companyTaxNo",
  171. "bankName","accountNo","companyAddress",
  172. "companyTelephone"]
  173. }
  174. },
  175. rulelist(){
  176. if(this.form.headerType==1&&this.form.type==2){
  177. return ["bankName","accountNo","companyAddress"]
  178. }else {
  179. return []
  180. }
  181. }
  182. },
  183. onLoad(op) {
  184. if(op.id){
  185. this.id=op.id;
  186. this.title="修改发票抬头"
  187. this.getInvoiceTypeDetail();
  188. }
  189. },
  190. methods: {
  191. deleteBtn(){
  192. this.show=false;
  193. uni.showLoading({
  194. title: "加载中",
  195. mask: true,
  196. })
  197. API.deleteInvoiceType({
  198. id: this.id,
  199. }).then((response) => {
  200. const eventChannel = this.getOpenerEventChannel();
  201. eventChannel.emit('refreshData');
  202. uni.showModal({
  203. title:"提示",
  204. content:"操作成功!",
  205. showCancel:false,
  206. success() {
  207. uni.navigateBack()
  208. }
  209. })
  210. }).catch(error => {
  211. uni.showToast({
  212. title: error,
  213. icon: "none"
  214. })
  215. })
  216. },
  217. getInvoiceTypeDetail(){
  218. uni.showLoading({
  219. title: "加载中",
  220. mask: true,
  221. })
  222. API.invoiceTypeDetail({
  223. id: this.id,
  224. }).then((response) => {
  225. uni.hideLoading();
  226. this.form=response.data.invoiceType;
  227. this.defaultHeader=this.form.defaultHeader
  228. }).catch(error => {
  229. uni.showToast({
  230. title: error,
  231. icon: "none"
  232. })
  233. })
  234. },
  235. submit(){
  236. console.log(this.form)
  237. var obj={}
  238. if(this.id){
  239. obj.id=this.id
  240. }
  241. obj.defaultHeader=(this.defaultHeader?1:0)
  242. var bl=false
  243. for(var i in this.form){
  244. var set=this.setparameter(i);
  245. console.log(set,i)
  246. if(set){
  247. if(set==2){
  248. if(this.form[i]==""){
  249. var k=this.formKey[i]
  250. uni.showToast({
  251. icon: "none",
  252. title: "请填写"+k,
  253. })
  254. bl=true;
  255. break
  256. }
  257. }
  258. obj[i]=this.form[i]
  259. }
  260. }
  261. if(bl){
  262. return
  263. }
  264. var checkPhoneResult = checkPhone(this.form.companyTelephone);
  265. if (checkPhoneResult !== true) {
  266. uni.showToast({
  267. icon: "none",
  268. title: checkPhoneResult,
  269. })
  270. return;
  271. }
  272. uni.showLoading({
  273. title: "加载中",
  274. mask: true,
  275. })
  276. API.saveInvoiceType(obj).then((response) => {
  277. uni.hideLoading();
  278. const eventChannel = this.getOpenerEventChannel();
  279. eventChannel.emit('refreshData');
  280. uni.showModal({
  281. title:"提示",
  282. content:"操作成功!",
  283. showCancel:false,
  284. success() {
  285. uni.navigateBack()
  286. }
  287. })
  288. }).catch(error => {
  289. uni.hideLoading();
  290. uni.showToast({
  291. title: error,
  292. icon: "none"
  293. })
  294. })
  295. },
  296. setparameter(key){
  297. if(this.ruleReqlist.indexOf(key)!=-1){
  298. //console.log(2,key,this.ruleReqlist)
  299. return 2
  300. }
  301. if(this.rulelist.indexOf(key)!=-1){
  302. //console.log(1,key,this.rulelist)
  303. return 1
  304. }
  305. //console.log(0,key)
  306. return 0
  307. },
  308. // 选中某个单选框时,由radio时触发
  309. radioChange(e) {
  310. // console.log(e);
  311. },
  312. // 选中任一radio时,由radio-group触发
  313. radioGroupChange(e) {
  314. }
  315. }
  316. };
  317. </script>
  318. <style lang="scss" scoped>
  319. .main{
  320. background-color: #fff;
  321. margin-bottom: 24rpx;
  322. }
  323. /deep/.u-cell{
  324. height: 96rpx;
  325. }
  326. /deep/.u-cell__value{
  327. text-align: left;
  328. margin-left: 8%;
  329. font-size: 32rpx;
  330. }
  331. /deep/.u-switch{
  332. margin: auto 0;
  333. float: left;;
  334. }
  335. .save{
  336. margin: 24rpx 32rpx;
  337. line-height: 88rpx;
  338. border-radius: 50px;
  339. background: linear-gradient(-88.46deg, rgba(34,109,198,1) 2.59%,rgba(9,158,237,1) 97.02%);
  340. color: rgba(255,255,255,1);
  341. font-size: 36rpx;
  342. }
  343. .popup{
  344. padding: 32rpx;
  345. text-align: center;
  346. .headline{
  347. color: rgba(16,16,16,1);
  348. font-size: 36rpx;
  349. font-weight: bold;
  350. }
  351. .hint{
  352. color: rgba(16,16,16,1);
  353. font-size: 32rpx;
  354. margin-top: 40rpx;
  355. }
  356. .btn-box{
  357. margin-top: 82rpx;
  358. display: flex;
  359. justify-content: space-between;
  360. .think{
  361. width: 328rpx;
  362. line-height: 80rpx;
  363. border-radius: 4px;
  364. background-color: rgba(222,225,228,1);
  365. color: rgba(51,51,51,1);
  366. font-size: 32rpx;
  367. }
  368. .confirm{
  369. width: 328rpx;
  370. line-height: 80rpx;
  371. border-radius: 4px;
  372. background-color: rgba(255,68,68,1);
  373. color: rgba(255,255,255,1);
  374. font-size: 32rpx;
  375. }
  376. }
  377. }
  378. </style>