import BaseController from "../../baseController";
|
import { Post } from "egg-shell-decorators";
|
import { BaseClient } from "../../../entity/crm/client/baseClient";
|
import { Like } from "typeorm";
|
import { CRMClientLinker } from "../../../entity/crm/linker/crmClientLinker";
|
|
export default class ClientController extends BaseController {
|
//#region
|
/**
|
* 获得TableSelect获得客户信息列表
|
*/
|
@Post()
|
public async getList() {
|
let userInfo = await this.userInfo;
|
var dataList = await this.dbRead.find(BaseClient, {
|
select: [
|
"client_Id",
|
"clientCode",
|
"clientShortName",
|
"mobile",
|
"shippingName",
|
"shippingAddress",
|
"province_Id",
|
"provinceName",
|
"city_Id",
|
"cityName",
|
"region_Id",
|
"regionName",
|
"tel",
|
"countryName",
|
"expandFields",
|
"tel"
|
],
|
where: {
|
userProduct_Id: userInfo.userProduct_Id,
|
clientShortName: Like("%" + this.body.name + "%")
|
}
|
});
|
if (dataList.length == 0) {
|
this.info.result = false;
|
this.info.data = dataList;
|
} else {
|
this.info.result = true;
|
this.info.data = dataList;
|
}
|
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
|
//#region 获取联系人信息
|
@Post()
|
public async getClientLinker() {
|
let userInfo = await this.userInfo;
|
try {
|
let dataList = await this.dbRead.find(CRMClientLinker, {
|
where: {
|
clientShortName: this.body.name,
|
userProduct_Id: userInfo.userProduct_Id
|
}
|
});
|
|
this.info.result = true;
|
this.info.data = dataList;
|
|
this.ctx.body = this.info;
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = "出现异常" + ex.message;
|
this.ctx.body = this.info;
|
}
|
}
|
//#endregion
|
}
|