20261008
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
module.exports = {
|
||||
/**
|
||||
* 加工详情
|
||||
* @url client/process/sheet/pub/getInfo 前端调用的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} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
|
||||
const dbName = "jjx-process-sheet";
|
||||
const quoteDbName = "jjx-process-quote";
|
||||
const userDbName = "uni-id-users";
|
||||
|
||||
res = await vk.baseDao.findById({
|
||||
dbName, id: data.id
|
||||
})
|
||||
|
||||
res.quoteList = await vk.baseDao.selects({
|
||||
dbName: quoteDbName,
|
||||
whereJson: {
|
||||
sheetId: data.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.user = await vk.baseDao.findById({
|
||||
dbName: userDbName,
|
||||
id: res.userId
|
||||
})
|
||||
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
'use strict';
|
||||
const dbName = require('../../../../../dao/config.js')
|
||||
module.exports = {
|
||||
/**
|
||||
* 获取加工单
|
||||
* @url client/process/pub/getList 前端调用的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, userId, pageIndex, pageSize, keyword, categoryIds, provinceCodes, area, formData, status, isUser} = data;
|
||||
let res = {code: 0, msg: ""};
|
||||
// 业务逻辑开始-----------------------------------------------------------
|
||||
const dbName = "jjx-process-sheet";
|
||||
const whereJson = {isShow: 1};
|
||||
|
||||
if (vk.pubfn.isNotNull(keyword)) {
|
||||
whereJson.title = new RegExp(keyword)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(isUser)) {
|
||||
if (data.otherUid) whereJson.otherUid = data.otherUid;
|
||||
else whereJson.userId = userId;
|
||||
} else {
|
||||
if (vk.pubfn.isNotNull(data.status)) {
|
||||
whereJson.status = data.status
|
||||
}else whereJson.status = 0
|
||||
|
||||
}
|
||||
|
||||
if (formData && formData.hasOwnProperty('companyList') && vk.pubfn.isNotNull(formData.companyList)) {
|
||||
whereJson.userId = _.in(formData.companyList)
|
||||
}
|
||||
|
||||
if (formData && formData.hasOwnProperty('categoryIds') && vk.pubfn.isNotNull(formData.categoryIds)) {
|
||||
whereJson.productList = _.in(formData.categoryIds)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(categoryIds)) {
|
||||
whereJson.productList = _.in(categoryIds)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(area)) {
|
||||
if (area.length === 3) whereJson['addressRegion.area.code'] = area[2]
|
||||
if (area.length === 2) whereJson['addressRegion.city.code'] = area[1]
|
||||
if (area.length === 1) whereJson['addressRegion.province.code'] = area[0]
|
||||
} else if (vk.pubfn.isNotNull(provinceCodes)) {
|
||||
whereJson['addressRegion.province.code'] = _.in(provinceCodes)
|
||||
}
|
||||
|
||||
if (vk.pubfn.isNotNull(status) && status !== 'all') {
|
||||
if (status === 'noQuote') whereJson.quoteNum = 0
|
||||
else if (status === 'notPick') whereJson.status = 0
|
||||
else if (status === 'picked') whereJson.status = 1
|
||||
}
|
||||
console.log('where', whereJson)
|
||||
res = await vk.baseDao.selects({
|
||||
dbName,
|
||||
pageIndex,
|
||||
pageSize,
|
||||
whereJson,
|
||||
getCount: true,
|
||||
sortArr: [{name: "_add_time", type: "desc"}],
|
||||
foreignDB: [
|
||||
{
|
||||
dbName: "uni-id-users",
|
||||
localKey: "userId",
|
||||
foreignKey: "_id",
|
||||
as: "user",
|
||||
limit: 1, // limit=1则以对象形式返回
|
||||
fieldJson: {
|
||||
_id: true,
|
||||
company: {
|
||||
companyName: true
|
||||
},
|
||||
person: {
|
||||
personName: true
|
||||
},
|
||||
businessCard: true,
|
||||
accountType: true,
|
||||
},
|
||||
},
|
||||
|
||||
]
|
||||
});
|
||||
|
||||
for (const item of res.rows) {
|
||||
item.quoteList = await vk.baseDao.selects({
|
||||
dbName: 'jjx-process-quote',
|
||||
whereJson: {
|
||||
sheetId: item._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,
|
||||
},
|
||||
}
|
||||
]
|
||||
})
|
||||
item.contract = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'jjx-contract',
|
||||
whereJson: {
|
||||
sheetId: item._id,
|
||||
type: 'process',
|
||||
},
|
||||
})
|
||||
if (vk.pubfn.isNotNull(isUser)) {
|
||||
|
||||
item.otherUser = await vk.baseDao.findByWhereJson({
|
||||
dbName: 'uni-id-users',
|
||||
whereJson: {
|
||||
_id: !data.otherUid ? item.otherUid : item.userId,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
res.notPickNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
status: 0,
|
||||
isShow: 1
|
||||
},
|
||||
});
|
||||
|
||||
res.pickedNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
status: 1,
|
||||
isShow: 1
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
res.noQuoteNum = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
quoteNum: 0,
|
||||
isShow: 1
|
||||
},
|
||||
});
|
||||
|
||||
res.all = await vk.baseDao.count({
|
||||
dbName,
|
||||
whereJson: {
|
||||
userId: uid,
|
||||
isShow: 1
|
||||
},
|
||||
});
|
||||
|
||||
// 业务逻辑结束-----------------------------------------------------------
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user