提交 f212b69e 编写于 作者: zcdtk's avatar zcdtk

代码格式化

上级 1343fe66
......@@ -15,20 +15,19 @@
</ion-button>
</van-uploader>
</ion-row>
</div>
</template>
<script lang="ts">
import {Vue,Component, Prop,Provide,Emit,Watch} from 'vue-property-decorator';
import {Environment} from '@/environments/environment';
import { Subject, Unsubscribable} from 'rxjs';
import Axios from 'axios';
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
import { Environment } from '@/environments/environment';
import { Subject, Unsubscribable } from 'rxjs';
import Axios from 'axios';
import { Uploader} from 'vant';
import { Uploader } from 'vant';
Vue.use(Uploader);
@Component({
Vue.use(Uploader);
@Component({
i18n: {
messages: {
'ZH-CN': {
......@@ -40,8 +39,8 @@
}
},
components: {}
})
export default class AppMobFileUpload extends Vue {
})
export default class AppMobFileUpload extends Vue {
// MOB LOGIC BEGIN
/**
* 单选按钮状态
......@@ -50,7 +49,7 @@
* @type {Array<string>}
* @memberof AppMobFileUpload
*/
get singleChoiceBtnState(): Array < string > {
get singleChoiceBtnState(): Array<string> {
return [
this.files.length > 0 ? 'file-list' : '',
!this.multiple && this.files.length === 1 ? 'hidden-choice-button' : '',
......@@ -62,7 +61,7 @@
*
* @readonly
* @type {boolean}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
get state(): boolean {
// 禁用
......@@ -81,15 +80,15 @@
*
* @private
* @type {Array<any>}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
private devFiles: Array < any > = [];
private devFiles: Array<any> = [];
/**
* 文件上传模式
*
* @type {string}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public resultType: string = process.env.NODE_ENV === 'development' ? 'dataUrl' : 'file';
......@@ -98,7 +97,7 @@
*
* @param {*} file 文件信息
* @param {*} detail 详情
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public onDelete(file: any, detail: any): void {
this.onRemove({
......@@ -113,7 +112,7 @@
* @param {*} file
* @param {*} detail
* @returns {boolean}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public beforeRead(file: any, detail: any): boolean {
if (file && Array.isArray(file)) {
......@@ -132,7 +131,7 @@
* @protected
* @param {*} file 文件信息
* @param {*} detail 详情
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
protected afterRead(file: any, detail: any): void {
const params = new FormData()
......@@ -164,24 +163,24 @@
* 表单状态
*
* @type {Subject<any>}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public formState ? : Subject < any >
@Prop() public formState?: Subject<any>
/**
* 是否忽略表单项书香值变化
*
* @type {boolean}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public ignorefieldvaluechange ? : boolean;
@Prop() public ignorefieldvaluechange?: boolean;
/**
* 表单状态事件
*
* @private
* @type {(Unsubscribable | undefined)}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
private formStateEvent: Unsubscribable | undefined;
......@@ -189,7 +188,7 @@
* 表单数据
*
* @type {string}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public data!: string;
......@@ -197,9 +196,9 @@
* 初始化值
*
* @type {*}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public value ? : any;
@Prop() public value?: any;
/**
* 数据值变化
......@@ -207,7 +206,7 @@
* @param {*} newval
* @param {*} val
* @returns
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Watch('value')
onValueChange(newval: any, val: any) {
......@@ -226,7 +225,7 @@
* 所属表单项名称
*
* @type {string}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public name!: string;
......@@ -234,84 +233,84 @@
* 是否禁用
*
* @type {boolean}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public disabled ? : boolean;
@Prop() public disabled?: boolean;
/**
* 上传参数
*
* @type {string}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public uploadparams ? : string;
@Prop() public uploadparams?: string;
/**
* 下载参数
*
* @type {string}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public exportparams ? : string;
@Prop() public exportparams?: string;
/**
* 自定义参数
*
* @type {*}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop() public customparams ? : any;
@Prop() public customparams?: any;
/**
* 上传文件路径
*
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public uploadUrl = Environment.BaseUrl + Environment.UploadFile;
/**
* 下载文件路径
*
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public downloadUrl = Environment.BaseUrl + Environment.ExportFile;
/**
* 文件列表
*
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Provide() public files: Array < any > = [];
@Provide() public files: Array<any> = [];
/**
* 上传keys
*
* @type {Array<any>}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public upload_keys: Array < any > = [];
public upload_keys: Array<any> = [];
/**
* 导出keys
*
* @type {Array<any>}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public export_keys: Array < any > = [];
public export_keys: Array<any> = [];
/**
* 自定义数组
*
* @type {Array<any>}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public custom_arr: Array < any > = [];
public custom_arr: Array<any> = [];
/**
* 应用参数
*
* @type {*}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public appData: any = "";
......@@ -319,11 +318,11 @@
* 数据处理
*
* @private
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
private dataProcess(): void {
let upload_arr: Array < string > = [];
let export_arr: Array < string > = [];
let upload_arr: Array<string> = [];
let export_arr: Array<string> = [];
const _data: any = JSON.parse(this.data);
this.upload_keys.forEach((key: string) => {
upload_arr.push(`${key}=${_data[key]}`);
......@@ -358,7 +357,7 @@
/**
* vue 生命周期
*
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public created() {
if (this.formState) {
......@@ -378,14 +377,14 @@
/**
* vue 生命周期
*
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public mounted() {
this.appData = this.$store.getters.getAppData();
let custom_arr: Array < string > = [];
let upload_keys: Array < string > = [];
let export_keys: Array < string > = [];
let custom_arr: Array<string> = [];
let upload_keys: Array<string> = [];
let export_keys: Array<string> = [];
if (this.uploadparams && !Object.is(this.uploadparams, '')) {
upload_keys = this.uploadparams.split(';');
......@@ -413,19 +412,21 @@
/**
* 修改label默认样式
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public changeLabelStyle() {
document.querySelectorAll(".app-mobile-file-upload").forEach((element: any) => {
let prev = this.getNearEle(element, 1);
if (prev) {
prev.style.transform = 'none';
}
})
}
/**
* 查找相邻前一个元素
*
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public getNearEle(ele: any, type: any) {
type = type == 1 ? "previousSibling" : "nextSibling";
......@@ -445,7 +446,7 @@
/**
* 组件销毁
*
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public destroyed(): void {
if (this.formStateEvent) {
......@@ -457,7 +458,7 @@
* 上传之前
*
* @param {*} file
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public beforeUpload(file: any) {
// console.log('上传之前');
......@@ -470,7 +471,7 @@
* @param {*} file
* @param {*} fileList
* @returns
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public onSuccess(response: any, file: any, fileList: any) {
if (!response) {
......@@ -480,7 +481,7 @@
name: response.name,
id: response.id
};
let arr: Array < any > = [];
let arr: Array<any> = [];
this.files.forEach((_file: any) => {
arr.push({
name: _file.name,
......@@ -502,7 +503,7 @@
* @param {*} error
* @param {*} file
* @param {*} fileList
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public onError(error: any, file: any, fileList: any) {
this.$notify({
......@@ -516,10 +517,10 @@
*
* @param {*} file
* @param {*} fileList
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public onRemove(file: any, fileList: any) {
let arr: Array < any > = [];
let arr: Array<any> = [];
fileList.forEach((f: any) => {
if (f.id != file.id) {
arr.push({
......@@ -539,7 +540,7 @@
* 下载文件
*
* @param {*} file
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public onDownload(file: any) {
window.open(file.url);
......@@ -549,7 +550,7 @@
* 预览图片地址
*
* @type {string}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public dialogImageUrl: string = '';
......@@ -557,7 +558,7 @@
* 是否显示预览界面
*
* @type {boolean}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public dialogVisible: boolean = false;
......@@ -565,23 +566,21 @@
* 是否支持多个上传
*
* @type {boolean}
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
@Prop({
default: true
}) public multiple ? : boolean;
@Prop({ default: true }) public multiple?: boolean;
/**
* 预览
*
* @param {*} file
* @memberof AppMobPicture
* @memberof AppMobFileUpload
*/
public onPreview(file: any) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
}
}
}
</script>
<style lang="less">
......
......@@ -397,9 +397,11 @@ export default class AppMobPicture extends Vue {
public changeLabelStyle() {
document.querySelectorAll(".app-mobile-picture").forEach((element: any) => {
let prev = this.getNearEle(element, 1);
if (prev) {
prev.style.transform = 'none';
prev.style.marginBottom = "10px";
})
}
});
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册