|
@@ -263,11 +263,10 @@ export class UtilService {
|
|
|
const result = await this.dealRows(rows, mappingList);
|
|
|
const errorList = [];
|
|
|
// 需要查看是否有人,有人更新数据,没人添加数据
|
|
|
- const user_id = this.ctx.user.id;
|
|
|
for (const [index, i] of result.entries()) {
|
|
|
// 根据 企业名称 查重
|
|
|
- const { name } = i;
|
|
|
- const data = await this.companyModel.findOne({ where: { user: Equal(user_id), name: Equal(name) } });
|
|
|
+ const { name, industry } = i;
|
|
|
+ const data = await this.companyModel.findOne({ where: { name: Equal(name) } });
|
|
|
if (data && data.id) {
|
|
|
try {
|
|
|
i.id = data.id;
|
|
@@ -277,7 +276,7 @@ export class UtilService {
|
|
|
}
|
|
|
} else {
|
|
|
try {
|
|
|
- const userInfo = await this.userModel.insert({ account: name, nick_name: name, password: '123456', gender: '0', role: ['User', 'Company'], status: '1' });
|
|
|
+ const userInfo = await this.userModel.insert({ account: name, nick_name: name, password: '123456', industry: [industry], gender: '0', role: ['User', 'Company'], status: '1' });
|
|
|
const id = get(userInfo, 'identifiers.0.id');
|
|
|
await this.companyModel.insert({ ...i, user: id, status: '0' });
|
|
|
} catch (error) {
|
|
@@ -360,7 +359,11 @@ export class UtilService {
|
|
|
} else if (type === 'area') {
|
|
|
if (val) result = val.split('-');
|
|
|
} else if (type === 'number') {
|
|
|
- if (val) result = parseInt(val) || 0;
|
|
|
+ if (val === 0) {
|
|
|
+ result = val;
|
|
|
+ } else {
|
|
|
+ if (val) result = parseInt(val) || 0;
|
|
|
+ }
|
|
|
}
|
|
|
return result;
|
|
|
}
|