|
@@ -2,29 +2,47 @@
|
|
|
<template>
|
|
|
<view class="invoice">
|
|
|
<view class="invoice-form">
|
|
|
- <u-form :model="form" ref="uForm" label-width="150">
|
|
|
- <u-form-item label="抬头类型">
|
|
|
- <u-radio-group v-model="form.type">
|
|
|
- <u-radio name="company">企业</u-radio>
|
|
|
- <u-radio name="personal">个人/机关事业单位</u-radio>
|
|
|
+ <u-form :model="form" :rules="rules" ref="uForm" label-width="150" label-align="right">
|
|
|
+ <u-form-item label="抬头:">
|
|
|
+ <u-radio-group v-model="form.invoType" prop="invoType" @change="invoTypeChange">
|
|
|
+ <u-radio :name="1">企业</u-radio>
|
|
|
+ <u-radio :name="2">个人</u-radio>
|
|
|
</u-radio-group>
|
|
|
</u-form-item>
|
|
|
- <u-form-item label="公司名称">
|
|
|
- <u-input v-model="form.companyName" placeholder="请输入公司名称" />
|
|
|
+ <u-form-item label="抬头名称:" prop="invoName">
|
|
|
+ <u-input v-model="form.invoName" placeholder="请输入抬头名称" border />
|
|
|
<u-icon slot="right" name="list-dot" size="40" color="#606266" @click="moreCompany" />
|
|
|
</u-form-item>
|
|
|
- <u-form-item label="公司税号">
|
|
|
- <u-input v-model="form.dutyNum" placeholder="" disabled />
|
|
|
+ <u-form-item label="税号:" prop="invoCode" v-if="form.invoType === 1">
|
|
|
+ <u-input v-model="form.invoCode" placeholder="请输入税号" border />
|
|
|
</u-form-item>
|
|
|
- <u-form-item label="备注">
|
|
|
- <u-input v-model="form.remark" placeholder="请输入备注" />
|
|
|
+ <u-form-item label="发票金额:"> ¥{{ form.amount }} </u-form-item>
|
|
|
+ </u-form>
|
|
|
+ </view>
|
|
|
+ <view class="invoice-form margin-top">
|
|
|
+ <u-form :model="form" ref="uForm1" label-width="150" label-align="right">
|
|
|
+ <u-form-item label="开户银行:" prop="openBank">
|
|
|
+ <u-input v-model="form.openBank" placeholder="选填" border />
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="银行账号:" prop="numBank">
|
|
|
+ <u-input v-model="form.numBank" placeholder="选填" border />
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="企业地址:" prop="mapCom">
|
|
|
+ <u-input v-model="form.mapCom" placeholder="选填" border />
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="企业电话:" prop="phoneCom">
|
|
|
+ <u-input v-model="form.phoneCom" placeholder="选填" border />
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="电子邮箱:" prop="invoMail">
|
|
|
+ <u-input v-model="form.invoMail" placeholder="选填" border />
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="手机号码:" prop="invoPhone">
|
|
|
+ <u-input v-model="form.invoPhone" placeholder="选填" border />
|
|
|
</u-form-item>
|
|
|
- <u-form-item label="发票金额"> ¥{{ form.price }}元 </u-form-item>
|
|
|
</u-form>
|
|
|
</view>
|
|
|
- <view class="invoice-tips"> 注:本公司目前只支持开具增值税普通发票 </view>
|
|
|
<view class="invoice-submit">
|
|
|
- <u-button type="primary" @click="submitForm">提交</u-button>
|
|
|
+ <u-button type="primary" :loading="loading" @click="submitForm">提交</u-button>
|
|
|
</view>
|
|
|
<!-- 公司弹框 -->
|
|
|
<u-popup v-model="companyPop.show" mode="bottom" :closeable="true" height="50vh">
|
|
@@ -35,10 +53,10 @@
|
|
|
class="popup-list-item"
|
|
|
v-for="(item, index) in companyPop.list"
|
|
|
:key="index"
|
|
|
- :name="item.name"
|
|
|
+ :name="item.invoName"
|
|
|
@change="companyRadioClick(item)"
|
|
|
>
|
|
|
- {{ item.name }}
|
|
|
+ {{ item.invoName }}
|
|
|
</u-radio>
|
|
|
</u-radio-group>
|
|
|
</view>
|
|
@@ -50,6 +68,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
+ <u-toast ref="uToast" />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -58,18 +77,48 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
form: {
|
|
|
- type: 'company',
|
|
|
- companyName: '',
|
|
|
- dutyNum: '',
|
|
|
- remark: '',
|
|
|
- price: 100
|
|
|
+ invoName: '',
|
|
|
+ invoCode: '',
|
|
|
+ invoHeadId: '',
|
|
|
+ invoMail: '',
|
|
|
+ invoPhone: '',
|
|
|
+ invoType: 1,
|
|
|
+ phoneCom: '',
|
|
|
+ mapCom: '',
|
|
|
+ openBank: '',
|
|
|
+ numBank: '',
|
|
|
+ amount: '',
|
|
|
+ orderIds: []
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ invoType: [{ required: true, message: '请选择发票类型', trigger: 'change' }],
|
|
|
+ invoName: [{ required: true, message: '请输入抬头名称', trigger: 'blur' }],
|
|
|
+ invoCode: [{ required: true, message: '请输入税号', trigger: 'blur' }]
|
|
|
},
|
|
|
companyPop: {
|
|
|
show: false,
|
|
|
list: []
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ queryParams: {
|
|
|
+ invoHeadType: 1
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
+ onLoad(options) {
|
|
|
+ this.getInvoiceHeaderSelect();
|
|
|
+ uni.getStorage({
|
|
|
+ key: 'availableOrderKey',
|
|
|
+ success: (res) => {
|
|
|
+ const { total, ids } = JSON.parse(res.data);
|
|
|
+ this.form.amount = total;
|
|
|
+ this.form.orderIds = ids;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onReady() {
|
|
|
+ this.$refs.uForm.setRules(this.rules);
|
|
|
+ },
|
|
|
methods: {
|
|
|
/**
|
|
|
* @description: 选择企业
|
|
@@ -78,21 +127,80 @@ export default {
|
|
|
moreCompany() {
|
|
|
this.companyPop.show = true;
|
|
|
},
|
|
|
+ /**
|
|
|
+ * @description: 获取发票抬头下拉
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ async getInvoiceHeaderSelect() {
|
|
|
+ const { code, data } = await this.$u.api.invoiceModuleApi.getInvoiceHeadSelectApi({ ...this.queryParams });
|
|
|
+ if (code === 200) {
|
|
|
+ this.companyPop.list = data;
|
|
|
+ if (data[0].invoStatus === 1) {
|
|
|
+ this.form.invoName = data[0].invoName;
|
|
|
+ this.form.invoCode = data[0].invoCode;
|
|
|
+ this.form.invoHeadId = data[0].id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 选择抬头
|
|
|
+ * @param {*} item
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
companyRadioClick(item) {
|
|
|
this.companyPop.show = false;
|
|
|
- this.form.companyName = item.name;
|
|
|
- this.form.dutyNum = item.no;
|
|
|
+ this.form.invoName = item.invoName;
|
|
|
+ this.form.invoCode = item.invoCode;
|
|
|
+ this.form.invoHeadId = item.id;
|
|
|
},
|
|
|
addInvoiceHeader() {
|
|
|
this.companyPop.show = false;
|
|
|
this.$u.route({
|
|
|
url: '/pages/invoiceModule/invoiceHeaderList/invoiceHeaderList'
|
|
|
- })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * @description: 抬头类型切换
|
|
|
+ * @param {*} val
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ invoTypeChange(val) {
|
|
|
+ this.queryParams.invoHeadType = val;
|
|
|
+ this.getInvoiceHeaderSelect();
|
|
|
},
|
|
|
submitForm() {
|
|
|
- this.$u.route({
|
|
|
- url: '/pages/invoiceModule/invoiceSuccess/invoiceSuccess'
|
|
|
- })
|
|
|
+ this.$refs.uForm.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ try {
|
|
|
+ this.loading = true;
|
|
|
+ const { invoHeadId, invoName, invoCode, invoMail, invoPhone, invoType, phoneCom, mapCom, openBank, numBank, orderIds } = this.form;
|
|
|
+ const { code } = await this.$u.api.invoiceModuleApi.addInvoiceApi({
|
|
|
+ invoHeadId,
|
|
|
+ invoName,
|
|
|
+ invoCode,
|
|
|
+ invoMail,
|
|
|
+ invoPhone,
|
|
|
+ invoType,
|
|
|
+ phoneCom,
|
|
|
+ mapCom,
|
|
|
+ openBank,
|
|
|
+ numBank,
|
|
|
+ orderIds
|
|
|
+ });
|
|
|
+ if (code === 200) {
|
|
|
+ this.loading = false;
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ title: '添加成功!',
|
|
|
+ type: 'success',
|
|
|
+ duration: 2000,
|
|
|
+ url: '/pages/invoiceModule/invoiceSuccess/invoiceSuccess'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|