var t = (0,
require("../../../@babel/runtime/helpers/interopRequireDefault").default)(
require("../../../utils/request"),
),
e = getApp();
Page({
data: {
type: "",
custId: "",
signId: "",
contractId: "",
info: {},
title: "",
roomTypeData: [],
roomData: [],
sourceData: [],
parityData: [],
babyQuantity: 1,
saleData: [],
collectMoney: {},
typeData: [],
wayData: [],
},
onLoad: function (t) {
this.getUserInfo(t.id);
this.setData({
custId: t.id,
type: t.type,
contractId: t.contractId ? t.contractId : "",
title: t.title ? t.title : "",
signId: t.signId ? t.signId : "",
}),
"contract" == t.type
? (wx.setNavigationBarTitle({ title: "新增合同" }),
this.getClientSource(),
this.getRoomType(),
this.getRoom(),
this.getParityData()
)
: "money" == t.type &&
(wx.setNavigationBarTitle({
title: t.title ? "编辑收款" : "新增收款",
}),
t.title && this.getCollectMoney(t.signId)),
this.getType(),
this.getSale(),
this.getCollectWay();
},
getUserInfo: function (id) {
var a = this;
t.default
.get("/project/customer/".concat(id))
.then(function (t) {
if (200 == t.code) {
a.setData({ info: t.data });
}
})
.catch(function (t) {
e.alert("系统繁忙~请稍后重试~"), console.error("抛异常了:".concat(t.msg));
});
},
getCollectWay: function () {
var a = this;
t.default
.get("/system/dict/data/type/way_type")
.then(function (t) {
if(t.code == 200) {
const map = (t.data || []).reduce((acc, item) => {
item?.dictValue !== undefined && (acc[item.dictValue] = item.dictLabel);
return acc;
}, {});
a.setData({ wayData: map });
}
})
.catch(function (t) {
e.alert("系统繁忙~请稍后重试~"), console.error("抛异常了:".concat(t.msg));
});
},
formSubmit: function (a) {
var i = this.data,
n = a.detail.value;
const saleName = i.saleData.find(e=>e.userId == n.sale).nickName;
return "" == n.number.trim()
? e.toast("请输入合同编号")
: "" == n.name.trim()
? e.toast("请输入合同名称")
: "" == n.roomType
? e.toast("请选择合同房型")
: "" == n.room
? e.toast("请选择房间")
: "" == n.deposit.trim()
? e.toast("请输入合同定金")
: "" == n.balance.trim()
? e.toast("请输入合同尾款")
: "" == n.realPrice.trim()
? e.toast("请输入合实际价格")
: "" == n.packagePrice.trim()
? e.toast("请输入合同套餐价")
: null == n.enterDate
? e.toast("请选择入住日期")
: "" == n.totalDays.trim()
? e.toast("请输入入住天数")
: null == n.signDate
? e.toast("请选择签约时间")
: "" == n.parity
? e.toast("请选择胎次")
: "" == n.origin
? e.toast("请选择订单来源")
: "" == n.sale
? e.toast("请选择母婴顾问")
: void t.default
.post("/project/customerContract", {
custId: i.custId,
babyQuantity: i.babyQuantity,
parity: n.parity,
enterDate: n.enterDate,
signDate: n.signDate,
totalDays: n.totalDays,
deposit: n.deposit,
first: n.first,
continueType: n.continueType,
outDate: i.outDate,
insurancePrice: n.insurancePrice,
name: n.name,
number: n.number,
origin: i.info.origin,
packagePrice: n.packagePrice,
remark: n.remark,
room: n.room,
roomType: n.roomType,
saleId: n.sale,
saleName: saleName,
status: n.status,
balance: n.balance,
realPrice: n.realPrice,
})
.then(function (t) {
200 == t.code &&
(wx.showToast({
title: "新增成功",
icon: "success",
}),
setTimeout(function () {
wx.navigateBack({ delta: 1 });
}, 800));
});
},
editMoney: function (a) {
var i = this.data,
n = a.detail.value;
if ("" == n.userName.trim()) return e.toast("请输入客户名字");
if ("" == n.collectName.trim()) return e.toast("请输入收款名称");
if ("" == n.collectNumber.trim()) return e.toast("请输入收款编号");
if ("" == n.money.trim()) return e.toast("请输入收款金额");
if (null == n.payType) return e.toast("请选择收款类型");
if (null == n.date) return e.toast("请选择入收款日期");
if (null == n.way) return e.toast("请选择收款方式");
var o = i.title ? "/custSignRec/update" : "/custSignRec/insert";
t.default
.post(o, {
custId: i.custId,
contractId: i.contractId,
custSignRecId: i.signId,
money: n.money,
name: n.collectName,
recMode: n.way,
recNum: n.collectNumber,
recTime: n.date,
recType: n.payType,
remarks: n.remarks,
serialNumber: n.serialNumber,
serviceRemarks: n.desc,
status: n.status,
})
.then(function (t) {
1 == t.code && e.backAlert(i.title ? "修改成功" : "新增成功");
})
.catch(function (t) {
console.error("抛异常了:".concat(t));
});
},
getSale: function () {
var e = this;
t.default.get("/system/user/list").then(function (t) {
200 == t.code && e.setData({ saleData: t.rows });
});
},
getType: function () {
var e = this;
t.default
.get("/system/dict/data/type/pay_type")
.then(function (t) {
if(t.code == 200) {
const map = (t.data || []).reduce((acc, item) => {
item?.dictValue !== undefined && (acc[item.dictValue] = item.dictLabel);
return acc;
}, {});
e.setData({ typeData: map });
}
})
.catch(function (t) {
console.error("抛异常了:".concat(t));
});
},
getRoomType: function () {
var e = this;
t.default.get("/system/dict/data/type/room_type").then(function (t) {
if (t.code == 200) {
e.setData({ roomTypeData: t.data });
}
});
},
getParityData: function () {
var e = this;
t.default.get("/system/dict/data/type/parity_type").then(function (t) {
if (t.code == 200) {
e.setData({ parityData: t.data });
}
});
},
getRoom: function () {
var e = this;
t.default.get("/app/roomList").then(function (t) {
200 == t.code && e.setData({ roomData: t.data });
});
},
selectSale: function (t) {
this.setData({ sale: t.detail.value });
},
selectDueDate: function (t) {
this.setData({ dueDate: t.detail.value });
},
selectEnterDate: function (t) {
var e = this.data;
this.setData({ enterDate: t.detail.value }),
t.detail.value && e.days && this.getOutDate(t.detail.value, e.days);
},
inputDays: function (t) {
var e = this.data;
this.setData({ days: t.detail.value }),
t.detail.value &&
e.enterDate &&
this.getOutDate(e.enterDate, t.detail.value);
},
getOutDate: function (t, e) {
var a = new Date(t).valueOf() + 24 * e * 3600 * 1e3,
i = new Date(a),
n = i.getFullYear(),
o = i.getMonth() + 1;
o < 10 && (o = "0" + o);
var s = i.getDate();
s < 10 && (s = "0" + s), this.setData({ outDate: n + "-" + o + "-" + s });
},
selectSignDate: function (t) {
this.setData({ signDate: t.detail.value });
},
selectRoomType: function (t) {
this.setData({ roomType: t.detail.value });
},
selectRoom: function (t) {
this.setData({ room: t.detail.value });
},
selectSource: function (t) {
this.setData({ origin: t.detail.value });
},
selectDate: function (t) {
this.setData({ date: t.detail.value });
},
selectParity: function (t) {
this.setData({ parity: t.detail.value });
},
selectBabyQuantity: function (t) {
this.setData({ babyQuantity: parseInt(t.detail) });
},
getClientSource: function () {
var a = this;
t.default
.get("/system/dict/data/type/customer_origin")
.then(function (t) {
if(t.code == 200) {
const map = (t.data || []).reduce((acc, item) => {
item?.dictValue !== undefined && (acc[item.dictValue] = item.dictLabel);
return acc;
}, {});
a.setData({ sourceData: map });
}
})
.catch(function (t) {
e.alert("系统繁忙~请稍后重试~"), console.error("抛异常了:".concat(t));
});
},
getCollectMoney: function (a) {
var i = this;
t.default
.get("/custSignRec/findById?custSignRecId=".concat(a))
.then(function (t) {
1 == t.code && i.setData({ collectMoney: t.result });
})
.catch(function (t) {
e.alert("系统繁忙~请稍后重试~"), console.error("抛异常了:".concat(t));
});
},
selectWay: function (t) {
this.setData({ way: t.detail.value });
},
selectType: function (t) {
this.setData({ payType: t.detail.value });
},
});
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。