75 lines
2.1 KiB
JavaScript
75 lines
2.1 KiB
JavaScript
'use strict';
|
|
module.exports = {
|
|
/**
|
|
* 获取报价单详情
|
|
* @url client/enquiry/sheet/pub/getDetail 前端调用的url参数地址
|
|
* data 请求参数
|
|
* @param {String} params1 参数1
|
|
*/
|
|
main: async (event) => {
|
|
let { data = {}, userInfo, util, filterResponse, originalParam } = event;
|
|
let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
|
|
let { uid, _id } = data;
|
|
let res = { code: 0, msg: "" };
|
|
// 业务逻辑开始-----------------------------------------------------------
|
|
let dbName = "jjx-enquiry-sheet";
|
|
res.data = await vk.baseDao.findByWhereJson({
|
|
dbName,
|
|
whereJson: {
|
|
_id: _id
|
|
},
|
|
// foreignDB: [
|
|
// {
|
|
// dbName:"uni-id-users",
|
|
// localKey:"userId",
|
|
// foreignKey:"_id",
|
|
// as:"user",
|
|
// limit:1, // limit=1则以对象形式返回
|
|
// fieldJson:{
|
|
// _id: true,
|
|
// company: {
|
|
// companyName: true,
|
|
// mobile: true,
|
|
// },
|
|
// person: {
|
|
// personName: true,
|
|
// mobile: true,
|
|
// },
|
|
// businessCard: true,
|
|
// accountType: true,
|
|
// },
|
|
// }
|
|
// ]
|
|
});
|
|
|
|
res.data.user = await vk.baseDao.findByWhereJson({
|
|
dbName:"uni-id-users",
|
|
whereJson: {
|
|
_id: res.data.userId
|
|
}
|
|
})
|
|
if (res.data.user && (res.data.user.isNotaryBusiness === undefined || res.data.user.isNotaryBusiness === null)) {
|
|
res.data.user.isNotaryBusiness = res.data.user.notaryUnionPayProfile && res.data.user.notaryUnionPayProfile.status === 1 ? 1 : 0
|
|
}
|
|
|
|
res.data.quoteList = []
|
|
const quoteList = await vk.baseDao.select({
|
|
dbName: "jjx-enquiry-quote",
|
|
whereJson: {
|
|
sheetId: _id
|
|
}
|
|
})
|
|
|
|
res.data.hasQuote = false
|
|
res.data.isMine = res.data.userId === uid
|
|
quoteList.rows.forEach(quote => {
|
|
if (quote.userId === uid) res.data.hasQuote = true
|
|
})
|
|
|
|
if (quoteList.rows.length > 0) res.data.quoteList = quoteList.rows
|
|
|
|
// 业务逻辑结束-----------------------------------------------------------
|
|
return res;
|
|
}
|
|
}
|