You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
hai-oil-web/src/app/services/common/common.service.ts

104 lines
2.3 KiB

import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {environment} from "../../../environments/environment";
import {ObjectData} from "../../utils/objectData.service";
import {NzUploadFile} from "ng-zorro-antd/upload";
@Injectable({
providedIn: 'root'
})
export class CommonService {
constructor(private http: HttpClient) { }
/**
*
* 查询数据字典
* @param codeType 【非必填】 码值类型
* @param codeValue 【非必填】码值
* @param callBack
*/
public queryDictionary(codeType: string, codeValue: string, callBack:any) {
const param = {
codeType: codeType,
codeValue: codeValue
};
this.http.get(environment.baseUrl + 'common/queryDictionary?'+ObjectData.objectByString(param)).subscribe(data => {
callBack(data);
});
}
/**
*
* 分级查询区域信息
* @param regionId 地区id
* @param callBack
*/
public getRegion(regionId: string, callBack:any) {
this.http.get(environment.baseUrl + 'common/getRegion?regionId=' + regionId).subscribe(data => {
callBack(data);
});
}
/**
*
* 查询数据字典
* @param imgData 【必填】 图片数据
*/
public imgList(imgData: NzUploadFile[]): string {
if (imgData[0]['response'] != null) {
return imgData[0]['response']['return_data'][0];
} else {
return imgData[0].name;
}
}
/**
*
* 拼接图片
* @param imgArray 【必填】 图片数据
*/
public postImg(imgArray: any): any {
const array = [];
for (const i of imgArray) {
if (i['response'] != null) {
array.push(i['response']['return_data'][0]);
} else {
array.push(i.name);
}
}
return array.join(',');
}
/**
*
* 拼接图片数组
* @param imgUrl 【必填】 图片数据
*/
public stitchImg(imgUrl: string): any {
const imgArray = [];
for (const i of imgUrl.split(',')) {
imgArray.push(
{
uid: 1,
name: i,
status: 'done',
url: environment.imageUrl + i
});
}
console.log(imgArray);
return imgArray;
}
// 判断字符串是否为空
public whetherStringIsNull(s: string): boolean {
if (s != null && s !== '') {
return false;
} else {
return true;
}
}
}