353 lines
10 KiB
JavaScript
353 lines
10 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const store_modules_user = require("../../store/modules/user.js");
|
|
const api_booking_userInvoice_index = require("../../api/booking/userInvoice/index.js");
|
|
const utils_common = require("../../utils/common.js");
|
|
const store_modules_tenant = require("../../store/modules/tenant.js");
|
|
store_modules_tenant.useTenantStore();
|
|
const userStore = store_modules_user.useUserStore();
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
list: [],
|
|
statusBarHeight: 104,
|
|
isLogin: false,
|
|
fields: {},
|
|
logo: "",
|
|
bookingUser: {},
|
|
server: [],
|
|
order: [],
|
|
// 表单数据
|
|
formData: {
|
|
type: 0,
|
|
invoiceType: 0
|
|
},
|
|
// 发票类型
|
|
type: [
|
|
{
|
|
text: "个人",
|
|
value: 0
|
|
},
|
|
{
|
|
text: "单位",
|
|
value: 1
|
|
}
|
|
],
|
|
// 开票类型
|
|
invoiceType: [
|
|
{
|
|
text: "普票",
|
|
value: 0
|
|
},
|
|
{
|
|
text: "专票",
|
|
value: 1
|
|
}
|
|
],
|
|
rules: {
|
|
// 对name字段进行必填验证
|
|
name: {
|
|
rules: [
|
|
{
|
|
required: true,
|
|
errorMessage: "请输入开票名称"
|
|
}
|
|
]
|
|
},
|
|
// 对email字段进行必填验证
|
|
email: {
|
|
rules: [
|
|
{
|
|
format: "email",
|
|
errorMessage: "请输入正确的邮箱地址"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
};
|
|
},
|
|
onLoad() {
|
|
this.reload();
|
|
},
|
|
methods: {
|
|
async reload() {
|
|
const app = this;
|
|
const userInfo = await userStore.fetchUserInfo();
|
|
if (Object.keys(userInfo).length > 0) {
|
|
app.isLogin = true;
|
|
app.userInfo = userInfo;
|
|
} else {
|
|
app.isLogin = false;
|
|
}
|
|
api_booking_userInvoice_index.pageUserInvoice({
|
|
userId: userInfo.userId,
|
|
limit: 1
|
|
}).then((res) => {
|
|
if (res.count > 0 && !app.formData.id) {
|
|
app.formData = res.list[0];
|
|
}
|
|
});
|
|
},
|
|
navTo(item) {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
}
|
|
utils_common.openUrl(item);
|
|
},
|
|
// 弹出登录提示框
|
|
openLogin() {
|
|
if (!this.isLogin) {
|
|
this.$refs.login.open("bottom");
|
|
return false;
|
|
}
|
|
},
|
|
add() {
|
|
this.$refs.addForm.open("center");
|
|
},
|
|
onDel(item) {
|
|
const app = this;
|
|
common_vendor.index.showModal({
|
|
title: "确定要删除吗?",
|
|
success(o) {
|
|
if (o.confirm) {
|
|
common_vendor.index.showLoading({
|
|
title: "请求中."
|
|
});
|
|
api_booking_userInvoice_index.removeUserInvoice(item.id).then((res) => {
|
|
common_vendor.index.showToast({
|
|
title: "操作成功",
|
|
icon: "none"
|
|
});
|
|
});
|
|
app.reload();
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 复写 binddata 方法,如果只是为了校验,无复杂自定义操作,可忽略此方法
|
|
* @param {String} name 字段名称
|
|
* @param {String} value 表单域的值
|
|
*/
|
|
// binddata(name,value){
|
|
// // 通过 input 事件设置表单指定 name 的值
|
|
// this.$refs.form.setValue(name, value)
|
|
// },
|
|
// 触发提交表单
|
|
submit() {
|
|
this.$refs.form.validate().then((res) => {
|
|
const saveOrUpdate = this.formData.id ? api_booking_userInvoice_index.updateUserInvoice : api_booking_userInvoice_index.addUserInvoice;
|
|
saveOrUpdate(this.formData).then((message) => {
|
|
common_vendor.index.showToast({
|
|
title: "保存成功",
|
|
icon: "success"
|
|
});
|
|
setTimeout(() => {
|
|
common_vendor.index.navigateBack({
|
|
delta: 2
|
|
});
|
|
}, 1e3);
|
|
}).catch((err) => {
|
|
console.log(err);
|
|
});
|
|
console.log("表单数据信息:", res);
|
|
}).catch((err) => {
|
|
console.log("表单错误信息:", err);
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
|
|
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
|
|
const _easycom_uv_input2 = common_vendor.resolveComponent("uv-input");
|
|
const _easycom_uv_textarea2 = common_vendor.resolveComponent("uv-textarea");
|
|
const _easycom_uv_button2 = common_vendor.resolveComponent("uv-button");
|
|
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
|
|
const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card");
|
|
(_easycom_uni_data_checkbox2 + _easycom_uni_forms_item2 + _easycom_uv_input2 + _easycom_uv_textarea2 + _easycom_uv_button2 + _easycom_uni_forms2 + _easycom_uni_card2)();
|
|
}
|
|
const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
|
|
const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
|
|
const _easycom_uv_input = () => "../../uni_modules/uv-input/components/uv-input/uv-input.js";
|
|
const _easycom_uv_textarea = () => "../../uni_modules/uv-textarea/components/uv-textarea/uv-textarea.js";
|
|
const _easycom_uv_button = () => "../../uni_modules/uv-button/components/uv-button/uv-button.js";
|
|
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
|
|
const _easycom_uni_card = () => "../../uni_modules/uni-card/components/uni-card/uni-card.js";
|
|
if (!Math) {
|
|
(_easycom_uni_data_checkbox + _easycom_uni_forms_item + _easycom_uv_input + _easycom_uv_textarea + _easycom_uv_button + _easycom_uni_forms + _easycom_uni_card)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: common_vendor.o(($event) => $data.formData.isCompany = $event),
|
|
b: common_vendor.p({
|
|
localdata: $data.type,
|
|
modelValue: $data.formData.isCompany
|
|
}),
|
|
c: common_vendor.p({
|
|
label: "抬头类型",
|
|
name: "isCompany"
|
|
}),
|
|
d: $data.formData.isCompany == 0
|
|
}, $data.formData.isCompany == 0 ? {
|
|
e: common_vendor.o(($event) => $data.formData.name = $event),
|
|
f: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "真实姓名(必填)",
|
|
modelValue: $data.formData.name
|
|
}),
|
|
g: common_vendor.p({
|
|
label: "名称",
|
|
name: "name",
|
|
required: true
|
|
}),
|
|
h: common_vendor.o(($event) => $data.formData.phone = $event),
|
|
i: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "手机号码",
|
|
modelValue: $data.formData.phone
|
|
}),
|
|
j: common_vendor.p({
|
|
label: "手机号码",
|
|
name: "phone",
|
|
required: true
|
|
}),
|
|
k: common_vendor.o(($event) => $data.formData.email = $event),
|
|
l: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "电子邮箱",
|
|
modelValue: $data.formData.email
|
|
}),
|
|
m: common_vendor.p({
|
|
label: "电子邮箱",
|
|
name: "email",
|
|
required: true
|
|
})
|
|
} : {}, {
|
|
n: $data.formData.isCompany == 1
|
|
}, $data.formData.isCompany == 1 ? {
|
|
o: common_vendor.o(($event) => $data.formData.name = $event),
|
|
p: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "单位名称(必填)",
|
|
modelValue: $data.formData.name
|
|
}),
|
|
q: common_vendor.p({
|
|
label: "名称",
|
|
name: "name",
|
|
required: true
|
|
}),
|
|
r: common_vendor.o(($event) => $data.formData.invoiceCode = $event),
|
|
s: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "纳税人识别号(必填)",
|
|
modelValue: $data.formData.invoiceCode
|
|
}),
|
|
t: common_vendor.p({
|
|
label: "税号",
|
|
name: "invoiceCode",
|
|
required: true
|
|
}),
|
|
v: common_vendor.o(($event) => $data.formData.phone = $event),
|
|
w: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "手机号码",
|
|
modelValue: $data.formData.phone
|
|
}),
|
|
x: common_vendor.p({
|
|
label: "手机号码",
|
|
name: "phone",
|
|
required: true
|
|
}),
|
|
y: common_vendor.o(($event) => $data.formData.email = $event),
|
|
z: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "电子邮箱",
|
|
modelValue: $data.formData.email
|
|
}),
|
|
A: common_vendor.p({
|
|
label: "电子邮箱",
|
|
name: "email",
|
|
required: true
|
|
}),
|
|
B: common_vendor.o(($event) => $data.formData.bankName = $event),
|
|
C: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "开户银行名称",
|
|
modelValue: $data.formData.bankName
|
|
}),
|
|
D: common_vendor.p({
|
|
label: "开户行",
|
|
name: "bankName",
|
|
required: true
|
|
}),
|
|
E: common_vendor.o(($event) => $data.formData.bankAccount = $event),
|
|
F: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "开户银行账号",
|
|
modelValue: $data.formData.bankAccount
|
|
}),
|
|
G: common_vendor.p({
|
|
label: "银行账号",
|
|
name: "bankAccount",
|
|
required: true
|
|
}),
|
|
H: common_vendor.o(($event) => $data.formData.address = $event),
|
|
I: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "单位地址",
|
|
modelValue: $data.formData.address
|
|
}),
|
|
J: common_vendor.p({
|
|
label: "单位地址",
|
|
name: "address",
|
|
required: true
|
|
}),
|
|
K: common_vendor.o(($event) => $data.formData.tel = $event),
|
|
L: common_vendor.p({
|
|
type: "text",
|
|
placeholder: "单位电话",
|
|
modelValue: $data.formData.tel
|
|
}),
|
|
M: common_vendor.p({
|
|
label: "单位电话",
|
|
name: "tel",
|
|
required: true
|
|
}),
|
|
N: common_vendor.o(($event) => $data.formData.comments = $event),
|
|
O: common_vendor.p({
|
|
placeholder: "请输入备注信息",
|
|
["auto-height"]: true,
|
|
modelValue: $data.formData.comments
|
|
}),
|
|
P: common_vendor.p({
|
|
label: "备注",
|
|
name: "comments"
|
|
})
|
|
} : {}, {
|
|
Q: common_vendor.o($options.submit),
|
|
R: common_vendor.p({
|
|
customStyle: {
|
|
background: "linear-gradient(to right, #70b915, #008e04)",
|
|
borderRadius: "30px",
|
|
color: "#ffffff"
|
|
},
|
|
text: "保存"
|
|
}),
|
|
S: common_vendor.sr("form", "72cf4f60-1,72cf4f60-0"),
|
|
T: common_vendor.p({
|
|
modelValue: $data.formData,
|
|
rules: $data.rules,
|
|
["label-position"]: "top"
|
|
}),
|
|
U: common_vendor.p({
|
|
border: false,
|
|
["is-shadow"]: false,
|
|
padding: 20
|
|
})
|
|
});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/package/user/invoice-edit.vue"]]);
|
|
wx.createPage(MiniProgramPage);
|