|
@@ -1134,7 +1134,7 @@ export class UtilService {
|
|
|
}
|
|
|
} else {
|
|
|
try {
|
|
|
- await this.companyModel.insert({ ...i, status: '1', is_show: '1' });
|
|
|
+ await this.companyModel.insert({ ...i, status: '1', is_show: '0' });
|
|
|
} catch (error) {
|
|
|
const namek = Object.keys(error.errors)[0];
|
|
|
const mapping = mappingList.find(i => i.field === namek);
|
|
@@ -1179,6 +1179,38 @@ export class UtilService {
|
|
|
}
|
|
|
return { result: result.length, errorList };
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 孵化基地
|
|
|
+ * @param {Object} rows excel数据
|
|
|
+ */
|
|
|
+ async incubate(rows) {
|
|
|
+ const mappingList = mappings.incubate;
|
|
|
+ const result = await this.dealRows(rows, mappingList);
|
|
|
+ const errorList = [];
|
|
|
+
|
|
|
+ for (const [index, i] of result.entries()) {
|
|
|
+ const { name } = i;
|
|
|
+ const data = await this.incubatorModel.findOne({ where: { name: Equal(name) } });
|
|
|
+ if (data && data.id) {
|
|
|
+ try {
|
|
|
+ i.id = data.id;
|
|
|
+ await this.yModel.update({ id: data.id }, i);
|
|
|
+ } catch (error) {
|
|
|
+ errorList.push(`修改第${index + 1}条${name}出现错误!!!`);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ await this.incubatorModel.insert({ ...i, status: '1', is_show: '0' });
|
|
|
+ } catch (error) {
|
|
|
+ const namek = Object.keys(error.errors)[0];
|
|
|
+ const mapping = mappingList.find(i => i.field === namek);
|
|
|
+ errorList.push(`第${index + 1}条${mapping.zh}列${name}字段出现错误!!!`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return { result: result.length, errorList };
|
|
|
+ }
|
|
|
|
|
|
* 处理excel传来的数据
|
|
|
* @param {Array} rows excel数据,二维数组
|
|
@@ -1286,6 +1318,7 @@ export class UtilService {
|
|
|
供给: 'supply',
|
|
|
企业: 'company',
|
|
|
企业年度: 'companyYear',
|
|
|
+ 孵化基地: 'incubate',
|
|
|
};
|
|
|
return get(obj, name);
|
|
|
}
|