Browse Source

发票抬头可以删除操作

zaijin 1 year ago
parent
commit
a7e9775f0e

+ 1 - 2
pages.json

@@ -360,8 +360,7 @@
       "style": {
         "navigationBarTitleText": "新增抬头",
         "enablePullDownRefresh": false,
-        "navigationBarBackgroundColor": "#008CFF",
-        "navigationBarTextStyle": "white"
+        "navigationStyle": "custom"
       }
     },
     {

+ 4 - 0
pages/invoiceModule/addInvoiceHeader/addInvoiceHeader.scss

@@ -4,6 +4,10 @@ page {
 .invoice-header {
   padding: 30rpx;
 
+  &-right {
+    margin-right: 30rpx;
+  }
+
   &-form {
     padding: 0 30rpx 30rpx;
     background-color: #fff;

+ 52 - 4
pages/invoiceModule/addInvoiceHeader/addInvoiceHeader.vue

@@ -1,6 +1,20 @@
 <!-- 新增发票抬头 -->
 <template>
   <view class="invoice-header u-skeleton">
+    <!-- 导航栏 -->
+    <u-navbar
+      title-color="#fff"
+      :custom-back="customBack"
+      :border-bottom="false"
+      back-icon-color="#CCE8FF"
+      :background="{ background: '#008CFF' }"
+      :title="navigationBarTitle"
+      class="invoice-navbar"
+    >
+      <view slot="right" class="invoice-header-right" v-if="form.id">
+        <u-icon name="trash-fill" size="40" color="#fa3534" @click="handleDelete"></u-icon>
+      </view>
+    </u-navbar>
     <view class="invoice-header-form">
       <u-form :model="form" ref="uForm" label-width="220" label-align="right">
         <u-form-item label="抬 头:" prop="invoHeadType" class="u-skeleton-fillet">
@@ -60,15 +74,15 @@ export default {
         invoCode: [{ required: true, message: '请输入税号', trigger: ['blur', 'change'] }]
       },
       loading: false,
-      skeletonLoading: false
+      skeletonLoading: false,
+      navigationBarTitle: '新增抬头'
     };
   },
   onLoad(options) {
     const { id } = options;
+    this.navigationBarTitle = '新增抬头';
     if (id) {
-      uni.setNavigationBarTitle({
-        title: '编辑抬头'
-      });
+      this.navigationBarTitle = '编辑抬头';
       this.getInvoiceHeaderDetails(id);
     }
   },
@@ -76,6 +90,10 @@ export default {
     this.$refs.uForm.setRules(this.rules);
   },
   methods: {
+    customBack() {
+      uni.navigateBack();
+    },
+    addInvoice() {},
     /**
      * @description: 获取发票抬头信息
      * @param {*} id
@@ -99,6 +117,36 @@ export default {
         this.skeletonLoading = false;
       }
     },
+    handleDelete() {
+      uni.showModal({
+        title: '提示',
+        content: '你确认要删除该条发票抬头吗?',
+        success: async (res) => {
+          if (res.confirm) {
+            try {
+              this.loading = true;
+              const { id } = this.form;
+              const { code } = await this.$u.api.invoiceModuleApi.deleteInvoiceHeaderApi({ id });
+              if (code === 200) {
+                this.$refs.uToast.show({
+                  title: '删除成功!',
+                  type: 'success',
+                  duration: 2000
+                });
+                setTimeout(() => {
+                  this.loading = false;
+                  this.$u.route({
+                    url: '/pages/invoiceModule/invoiceHeaderList/invoiceHeaderList'
+                  });
+                }, 2000);
+              }
+            } catch (error) {
+              this.loading = false;
+            }
+          }
+        }
+      });
+    },
     /**
      * @description: 提交发票
      * @return {*}