提交 fd20017c 编写于 作者: tony001's avatar tony001

Merge branch 'dev'

{
"name": "app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service serve --mode test",
"dev-serve": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service serve --mode development",
"build": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service build",
"dev-build": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service build --mode development",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@fullcalendar/core": "^4.4.0",
"@fullcalendar/daygrid": "^4.4.0",
"@fullcalendar/interaction": "^4.4.0",
"@fullcalendar/list": "^4.4.0",
"@fullcalendar/timegrid": "^4.4.0",
"@fullcalendar/vue": "^4.4.0",
"vuedraggable": "^2.23.2",
"async-validator": "^3.3.0",
"@popperjs/core": "^2.4.3",
"axios": "^0.19.1",
"core-js": "^3.4.4",
"echarts": "^4.6.0",
"element-ui": "^2.13.0",
"file-saver": "^2.0.2",
"font-awesome": "^4.7.0",
"ibiz-gantt-elastic": "^1.0.17",
"ibiz-vue-lib": "^0.1.13",
"interactjs": "^1.9.4",
"moment": "^2.24.0",
"path-to-regexp": "^6.1.0",
"qs": "^6.9.1",
"rxjs": "^6.5.4",
"tinymce": "4.8.5",
"view-design": "4.2.0",
"vue": "^2.6.10",
"vue-class-component": "^7.0.2",
"vue-grid-layout": "^2.3.7",
"vue-i18n": "^8.15.3",
"vue-property-decorator": "^8.3.0",
"vue-router": "^3.1.3",
"vuex": "^3.1.2",
"xlsx": "^0.15.6"
},
"devDependencies": {
"@types/echarts": "^4.4.3",
"@types/jest": "^24.0.19",
"@types/mockjs": "^1.0.2",
"@types/qs": "^6.9.0",
"@vue/cli-plugin-babel": "^4.1.0",
"@vue/cli-plugin-e2e-cypress": "^4.1.0",
"@vue/cli-plugin-router": "^4.1.0",
"@vue/cli-plugin-typescript": "^4.1.0",
"@vue/cli-plugin-unit-jest": "^4.1.0",
"@vue/cli-plugin-vuex": "^4.1.0",
"@vue/cli-service": "^4.1.0",
"@vue/test-utils": "1.0.0-beta.29",
"axios-mock-adapter": "^1.17.0",
"compression-webpack-plugin": "^4.0.0",
"less": "^3.0.4",
"less-loader": "^5.0.0",
"mockjs": "^1.1.0",
"script-loader": "^0.7.2",
"typescript": "~3.5.3",
"vue-template-compiler": "^2.6.10"
}
}
......@@ -65,7 +65,7 @@ export default class AppPicker extends Vue {
* 视图上下文
*
* @type {*}
* @memberof AppFormDRUIPart
* @memberof AppPicker
*/
@Prop() public context!: any;
......@@ -73,7 +73,7 @@ export default class AppPicker extends Vue {
* 视图参数
*
* @type {*}
* @memberof AppFormDRUIPart
* @memberof AppPicker
*/
@Prop() public viewparams!: any;
......@@ -81,15 +81,23 @@ export default class AppPicker extends Vue {
* AC参数
*
* @type {*}
* @memberof AppFormDRUIPart
* @memberof AppPicker
*/
@Prop({default: () => {}}) public acParams?: any;
/**
* 外键值附加数据
*
* @type {*}
* @memberof AppPicker
*/
@Prop() public pickUpData?: string;
/**
* 表单服务
*
* @type {*}
* @memberof AppFormDRUIPart
* @memberof AppPicker
*/
@Prop() public service?: any;
......@@ -97,7 +105,7 @@ export default class AppPicker extends Vue {
* 应用实体主信息属性名称
*
* @type {string}
* @memberof AppAutocomplete
* @memberof AppPicker
*/
@Prop({default: 'srfmajortext'}) public deMajorField!: string;
......@@ -105,7 +113,7 @@ export default class AppPicker extends Vue {
* 应用实体主键属性名称
*
* @type {string}
* @memberof AppAutocomplete
* @memberof AppPicker
*/
@Prop({default: 'srfkey'}) public deKeyField!: string;
......@@ -240,7 +248,7 @@ export default class AppPicker extends Vue {
* 输入状态
*
* @type {boolean}
* @memberof AppAutocomplete
* @memberof AppPicker
*/
public inputState: boolean = false;
......@@ -397,6 +405,7 @@ export default class AppPicker extends Vue {
if (this.name) {
this.$emit('formitemvaluechange', { name: this.name, value: item[this.deMajorField] });
}
this.fillPickUpData(item);
}
/**
......@@ -430,6 +439,7 @@ export default class AppPicker extends Vue {
if (this.name) {
this.$emit('formitemvaluechange', { name: this.name, value: '' });
}
this.fillPickUpData();
this.$forceUpdate();
}
......@@ -672,6 +682,7 @@ export default class AppPicker extends Vue {
if (this.name) {
this.$emit('formitemvaluechange', { name: this.name, value: item[this.deMajorField]?item[this.deMajorField]:item["srfmajortext"] });
}
this.fillPickUpData(item);
}
}
......@@ -752,7 +763,7 @@ export default class AppPicker extends Vue {
/**
* 输入过程中
*
* @memberof AppAutocomplete
* @memberof AppPicker
*/
public onInput($event: any) {
if (Object.is($event, this.value)) {
......@@ -784,6 +795,34 @@ export default class AppPicker extends Vue {
}
}
/**
* 填充外键值附加数据
*
* @param {item} 数据集
* @memberof AppPicker
*/
public fillPickUpData(item?:any){
if(this.pickUpData){
let pickUpDataArray:Array<any> = this.pickUpData.split(";")
if(pickUpDataArray && pickUpDataArray.length >0){
for(let i=0;i<pickUpDataArray.length;i++){
if(item){
this.$emit("formitemvaluechange", {
name: pickUpDataArray[i],
value: item[pickUpDataArray[i]],
});
}else{
this.$emit("formitemvaluechange", {
name: pickUpDataArray[i],
value: "",
});
}
}
}
}
}
}
</script>
......
......@@ -20,10 +20,10 @@ export default class AvueCustomForm extends Vue {
/**
* 编辑器参数传入组件配置
*
* @type {any}
* @type {*}
* @memberof AvueCustomForm
*/
@Prop() public options?: any;
public options: any;
/**
* 是否需要转换为string类型
......@@ -47,7 +47,7 @@ export default class AvueCustomForm extends Vue {
* @type {any}
* @memberof AvueCustomForm
*/
@Model('change') public value: any;
@Model("change") public value: any;
/**
* 是否将表单数据通过组件配置带入组件中
......@@ -57,13 +57,22 @@ export default class AvueCustomForm extends Vue {
*/
@Prop() public isFormData?: boolean;
/**
* 是否为子表单
*
* @type {boolean}
* @memberof AvueCustomForm
*/
@Prop() public isSubForm?: boolean;
/**
* 表单数据
*
* @type {any}
* @type {*}
* @memberof AvueCustomForm
*/
@Prop() public formData: any;
@Prop()
public formData?: any;
/**
* 表单状态
......@@ -84,6 +93,8 @@ export default class AvueCustomForm extends Vue {
if (this.value) {
if (this.isParseString) obj = JSON.parse(this.value);
else obj = this.value;
if (this.isSubForm && obj instanceof Array)
obj = this.loadSubFormData(obj);
}
return obj;
}
......@@ -110,7 +121,7 @@ export default class AvueCustomForm extends Vue {
/**
* 当前组件配置设置属性
*
* @type {any}
* @type {*}
* @memberof AvueCustomForm
*/
public formOption: any = null;
......@@ -118,7 +129,7 @@ export default class AvueCustomForm extends Vue {
/**
* avue-form默认配置
*
* @type {any}
* @type {*}
* @memberof AvueCustomForm
*/
public defaultOptions: any = {
......@@ -185,22 +196,26 @@ export default class AvueCustomForm extends Vue {
*
* @memberof AvueCustomForm
*/
public load() {
public async load() {
let that: any = this;
if (!this.options && this.options == null) {
if (this.url && this.options == null) {
const get: Promise<any> = this.$http.get(this.url);
get.then((response: any) => {
await get.then((response: any) => {
if (response && response.data) {
that.formOption = response.data;
if (this.isFormData) that.getFormData();
let options: any = response.data;
this.transitionDicUrlCondition(options);
that.formOption = options;
if (that.isFormData) that.getFormData();
}
});
} else {
this.transitionDicUrlCondition(this.defaultOptions);
this.formOption = this.defaultOptions;
if (this.isFormData) that.getFormData();
}
} else {
this.transitionDicUrlCondition(this.options);
this.formOption = this.options;
if (this.isFormData) that.getFormData();
}
......@@ -239,18 +254,77 @@ export default class AvueCustomForm extends Vue {
* @memberof AvueCustomForm
*/
public setValue(value: any) {
if (this.isSubForm) value = this.getSubFormData(value);
if (this.isParseString) this.$emit("change", JSON.stringify(value));
else this.$emit("change", value);
}
/**
* 提取第一个属性值
*
* @memberof AvueCustomForm
* @return {Array<any>}
*/
public getSubFormData(value: any): Array<any> {
let arr: Array<any> = [];
for (let val in value) {
arr = value[val];
break;
}
return arr;
}
/**
* 加载子表单值
*
* @memberof AvueCustomForm
* @return {*}
*/
public loadSubFormData(arr: Array<any>): any {
let value: any = {};
value[this.formOption.column[0].prop] = arr;
return value;
}
/**
* 配置的下拉列表转换符号支持动态配置
*
* @memberof AvueCustomForm
* @param {*}
*/
public transitionDicUrlCondition(options: any) {
let that: any = this;
let recursive: any = function (obj: any) {
if (obj.column && obj.column.length > 0) {
obj.column.forEach((col: any) => {
if (col.dicUrl && col.dicUrl.indexOf("$") > 0) {
let g = /\${[^+]+}/;
let dicGroup = col.dicUrl.match(g);
dicGroup.forEach((dic: any) => {
col.dicUrl = col.dicUrl.replace(
dic,
that.formData[dic.substring(2, dic.length - 1)]
);
});
}
if (col.children) recursive(col.children);
if (col.group) recursive(col.group);
});
}
if (obj.children) recursive(obj.children);
if (obj.group) recursive(obj.group);
};
recursive(options);
}
/**
* 销毁组件(vue生命周期)
*
* @type {Subject<any>}
* @memberof AvueCustomForm
*/
public destroy(){
if(this.formStateEvent){
public destroy() {
if (this.formStateEvent) {
this.formStateEvent.unsubscribe();
}
}
......
......@@ -12,7 +12,6 @@
:headers="myHeaders"
:file-list="uploadFileList"
:show-file-list="false"
:limit="limit"
:http-request="customUploadFile">
<div>
<i class="el-icon-upload"></i>
......@@ -20,7 +19,6 @@
<span>{{$t('components.diskFileUpload.fileDrag')}}</span>
<span style="color:#409EFF;">{{$t('components.diskFileUpload.clickUpload')}}</span>
</div>
<div slot="tip" class="el-upload__tip">{{uploadTip}}</div>
</div>
</el-upload>
</el-col>
......@@ -34,10 +32,10 @@
:headers="myHeaders"
:file-list="uploadFileList"
:show-file-list="false"
:limit="limit"
:http-request="customUploadFile">
<el-button type="primary" size="small" icon="el-icon-upload">{{$t('components.diskFileUpload.clickUpload')}}</el-button>
<div slot="tip" class="el-upload__tip">{{uploadTip}}</div>
<el-button type="primary" size="small" icon="el-icon-upload">
{{$t('components.diskFileUpload.clickUpload')}}
</el-button>
</el-upload>
</el-col>
<!--文件操作-->
......@@ -47,8 +45,11 @@
<span>{{item.name}}</span>
</div>
<div class="fileMain">
<el-link type="success" icon="el-icon-download" @click="onDownload(item)">{{$t('components.diskFileUpload.load')}}</el-link>
<el-link type="warning" icon="el-icon-view" v-show="showPreview" @click="onPreview(item)">{{$t('components.diskFileUpload.preview')}}
<el-link type="success" icon="el-icon-download" @click="onDownload(item)">
{{$t('components.diskFileUpload.load')}}
</el-link>
<el-link type="warning" icon="el-icon-view" v-show="showPreview" @click="onPreview(item)">
{{$t('components.diskFileUpload.preview')}}
</el-link>
<el-link type="primary" icon="el-icon-edit"
v-show="showEdit && (item.name.match(/^.+\.(doc|DOC|docx|DOCX|wps|WPS|xls|XLS|xlsx|XLSX|ppt|PPT|et|ET)$/))"
......@@ -58,21 +59,40 @@
v-show="showOcrview && (item.name.match(/^.+\.(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|bmp|BMP|pdf|PDF)$/))"
@click="onOcr(item)">OCR
</el-link>
<el-link type="danger" icon="el-icon-delete" @click="onRemove(item,index)">{{$t('components.diskFileUpload.delete')}}</el-link>
<el-link type="danger" icon="el-icon-delete" @click="onRemove(item,index)">
{{$t('components.diskFileUpload.delete')}}
</el-link>
</div>
</el-col>
</el-row>
<!-- 自定义弹框 -->
<div class="dialogDiv">
<el-dialog
:title="dialogTitle"
center
width="70%"
top="5vh"
:visible="showDialog"
:close-on-click-modal="true"
:show-close="true"
:before-close="dialogClose"
:modal-append-to-body="false">
<div style="height: 100%;">
<iframe id="fileIframe" :src="iframeUrl" frameborder="0" width="100%"></iframe>
</div>
</el-dialog>
</div>
</div>
</template>
<script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import {Button, Row, Col, Link, Icon, Upload, Message, MessageBox} from 'element-ui';
import Axios from 'axios';
import {Subject, Unsubscribable} from 'rxjs';
import {Component, Vue, Prop, Watch} from 'vue-property-decorator';
import {Button, Row, Col, Link, Icon, Upload, Message, MessageBox} from 'element-ui';
import Axios from 'axios';
import {Subject, Unsubscribable} from 'rxjs';
@Component({})
export default class DiskFileUpload extends Vue {
@Component({})
export default class DiskFileUpload extends Vue {
/**
* 当前表单对象
......@@ -170,22 +190,6 @@ export default class DiskFileUpload extends Vue {
*/
@Prop({default: false}) public showOcrview?: boolean;
/**
* 单文件大小
*
* @type {number}
* @memberof DiskFileUpload
*/
@Prop({default: 1}) public size!: number;
/**
* 文件上传个数
*
* @type {number}
* @memberof DiskFileUpload
*/
@Prop({default: 5}) public limit!: number;
/**
* 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存)
*
......@@ -194,15 +198,6 @@ export default class DiskFileUpload extends Vue {
*/
public srfuf: string = '0';
/**
* 上传提示语
*
* @type {string}
* @memberof DiskFileUpload
*/
get uploadTip(): string {
return this.$t('components.diskFileUpload.clues')+this.size.toString()+"M,"+this.$t('components.diskFileUpload.clues1')+this.limit;
}
/**
* 文件列表
......@@ -252,14 +247,50 @@ export default class DiskFileUpload extends Vue {
*/
public isCreate: boolean = true;
/**
* 自定义弹框标题
*
* @type {*}
* @memberof DiskFileUpload
*/
public dialogTitle: any = '';
/**
* 是否显示自定义弹框
*
* @type {boolean}
* @memberof DiskFileUpload
*/
public showDialog: boolean = false;
/**
* 嵌入自定义弹框中iframe的url
*
* @type {*}
* @memberof DiskFileUpload
*/
public iframeUrl: any = '';
/**
* 关闭自定义弹框
*
* @memberof DiskFileUpload
*/
public dialogClose() {
this.dialogTitle = '';
this.showDialog = false;
this.iframeUrl = '';
let iframe: any = document.getElementById("fileIframe");
iframe.parentNode.removeChild("fileIframe");
}
/**
* 拼接上传路径
*
* @memberof DiskFileUpload
*/
public getAction() {
const uploadUrl = '/net-disk/upload/' + this.getFolder() + '?ownertype=' + this.getOwnertype() + '&ownerid=' + this.getOwnerid();
return uploadUrl;
return '/net-disk/upload/' + this.getFolder() + '?ownertype=' + this.getOwnertype() + '&ownerid=' + this.getOwnerid();
}
/**
......@@ -268,8 +299,7 @@ export default class DiskFileUpload extends Vue {
* @memberof DiskFileUpload
*/
public getFolder() {
const folder = typeof this.folder == "string" ? this.folder : JSON.stringify(this.folder);
return folder;
return typeof this.folder == "string" ? this.folder : JSON.stringify(this.folder);
}
/**
......@@ -278,8 +308,7 @@ export default class DiskFileUpload extends Vue {
* @memberof DiskFileUpload
*/
public getOwnertype() {
const ownertype = typeof this.ownertype == "string" ? this.ownertype : JSON.stringify(this.ownertype);
return ownertype;
return typeof this.ownertype == "string" ? this.ownertype : JSON.stringify(this.ownertype);
}
/**
......@@ -288,16 +317,15 @@ export default class DiskFileUpload extends Vue {
* @memberof DiskFileUpload
*/
public getOwnerid() {
const ownerid = typeof this.ownerid == "string" ? this.ownerid : JSON.stringify(this.ownerid);
return ownerid;
return typeof this.ownerid == "string" ? this.ownerid : JSON.stringify(this.ownerid);
}
/**
*
* vue创建
*
* @memberof DiskFileUpload
*/
public created(){
public created() {
this.formStateEvent = this.formState.subscribe(($event: any) => {
// 表单加载完成
if (Object.is($event.type, 'load')) {
......@@ -325,7 +353,7 @@ export default class DiskFileUpload extends Vue {
if (Object.is($event.type, 'save')) {
// 批量更新文件表中的ownerid
if (this.isUpdateBatch == true && this.uploadFileList.length > 0) {
this.updateFileBatch(this.uploadFileList, 'update');
this.updateFileBatch(this.uploadFileList);
}
}
});
......@@ -336,9 +364,9 @@ export default class DiskFileUpload extends Vue {
*
* @memberof DiskFileUpload
*/
public getFiles(){
public getFiles() {
// 拼接url
let _this:any = this;
let _this: any = this;
const getUrl = '/net-disk/files/' + this.getFolder();
// 发送get请求
Axios.get(getUrl, {
......@@ -346,9 +374,9 @@ export default class DiskFileUpload extends Vue {
ownertype: this.getOwnertype(),
ownerid: this.getOwnerid(),
},
}).then(response => {
}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.getFileFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.getFileFailure') + '!');
return;
}
// 返回的是一个jsonArray
......@@ -358,8 +386,8 @@ export default class DiskFileUpload extends Vue {
this.uploadFileList.push.apply(this.uploadFileList, files);
}
}
}).catch(error => {
Message.error(_this.$t('components.diskFileUpload.getFileFailure')+':'+ error);
}).catch((error: any) => {
Message.error(_this.$t('components.diskFileUpload.getFileFailure') + ':' + error);
});
}
......@@ -373,21 +401,15 @@ export default class DiskFileUpload extends Vue {
// 上传的文件
let _this: any = this;
let file = param.file;
// 文件大小
const isSize = file.size / 1024 / 1024 < this.size;
if (!isSize) {
Message.error(_this.$t('components.diskFileUpload.loadFailure1')+_this.size.toString()+"M!");
return;
}
// formData传参
let formData = new FormData();
formData.append('file', file);
// 拼接url
const uploadUrl = this.getAction();
// 发送post请求
Axios.post(uploadUrl, formData, {timeout: 2000}).then(response => {
Axios.post(uploadUrl, formData, {timeout: 2000}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.loadFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.loadFailure') + '!');
}
// 返回的是一个jsonobject
if (response.data) {
......@@ -403,8 +425,8 @@ export default class DiskFileUpload extends Vue {
this.$emit('formitemvaluechange', {name: this.formItemName, value: value});
}
}
}).catch(err => {
Message.error(_this.$t('components.diskFileUpload.loadFailure')+':'+ err);
}).catch((error: any) => {
Message.error(_this.$t('components.diskFileUpload.loadFailure') + ':' + error);
})
}
......@@ -423,12 +445,12 @@ export default class DiskFileUpload extends Vue {
// 发送get请求
Axios.get(downloadUrl, {
headers: {
'authcode': item.authcode
'authcode': item.authcode,
},
responseType: 'arraybuffer',
}).then(response => {
}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.downloadFile')+'!');
Message.error(_this.$t('components.diskFileUpload.downloadFile') + '!');
return;
}
// 请求成功,后台返回的是一个文件流
......@@ -437,13 +459,17 @@ export default class DiskFileUpload extends Vue {
const disposition = response.headers['content-disposition'];
const filename = disposition.split('filename=')[1];
// 用blob对象获取文件流
var blob = new Blob([response.data], {type: response.headers['content-type']});
// 创建下载链接
let blob = new Blob([response.data], {type: response.headers['content-type']});
// 通过文件流创建下载链接
var href = URL.createObjectURL(blob);
// 创建一个a元素并设置相关属性
var a = document.createElement('a');
let a = document.createElement('a');
a.href = href;
if (name) {
a.download = name;
} else {
a.download = filename;
}
// 添加a元素到当前网页
document.body.appendChild(a);
// 触发a元素的点击事件,实现下载
......@@ -455,8 +481,8 @@ export default class DiskFileUpload extends Vue {
} else {
Message.error(_this.$t('components.diskFileUpload.downloadFile1'));
}
}).catch(error => {
Message.error(_this.$t('components.diskFileUpload.downloadFile')+':'+ error);
}).catch((error: any) => {
Message.error(_this.$t('components.diskFileUpload.downloadFile') + ':' + error);
});
}
......@@ -470,9 +496,20 @@ export default class DiskFileUpload extends Vue {
// 拼接url
const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id);
const name = typeof item.name == "string" ? item.name : JSON.stringify(item.name);
const previewUrl = '/net-disk/preview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// 新窗口打开url
window.open(previewUrl);
let previewUrl = '/net-disk/preview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
Axios.get(previewUrl).then((response: any) => {
if (!response || response.status != 200) {
return;
}
// 返回一个url,通过自定义弹框打开
if (response.data) {
this.dialogTitle = name;
this.showDialog = true;
this.iframeUrl = response.data;
}
}).catch((error: any) => {
Message.error(error);
});
}
/**
......@@ -485,8 +522,8 @@ export default class DiskFileUpload extends Vue {
// 拼接url
const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id);
const name = typeof item.name == "string" ? item.name : JSON.stringify(item.name);
const editUrl = '/net-disk/edit/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// 新窗口打开url
const editUrl = '/net-disk/editview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// TODO:暂时用window.open
window.open(editUrl);
}
......@@ -501,8 +538,19 @@ export default class DiskFileUpload extends Vue {
const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id);
const name = typeof item.name == "string" ? item.name : JSON.stringify(item.name);
const ocrUrl = '/net-disk/ocrview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// 新窗口打开url
window.open(ocrUrl);
Axios.get(ocrUrl).then((response: any) => {
if (!response || response.status != 200) {
return;
}
// 返回一个url,通过自定义弹框打开
if (response.data) {
this.dialogTitle = name;
this.showDialog = true;
this.iframeUrl = response.data;
}
}).catch((error: any) => {
Message.error(error);
});
}
/**
......@@ -513,7 +561,7 @@ export default class DiskFileUpload extends Vue {
* @memberof DiskFileUpload
*/
public onRemove(item: any, index: number) {
let _this:any = this;
let _this: any = this;
if (item) {
MessageBox.confirm(_this.$t('components.diskFileUpload.deleteFile'), _this.$t('components.diskFileUpload.deleteFilePrompt'), {
confirmButtonText: _this.$t('components.diskFileUpload.true'),
......@@ -523,9 +571,9 @@ export default class DiskFileUpload extends Vue {
// 拼接url
const deleteUrl = '/net-disk/files/' + item.id;
// 发送delete请求
Axios.delete(deleteUrl).then(response => {
Axios.delete(deleteUrl).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure') + '!');
}
// 从文件列表中删除
this.uploadFileList.splice(index, 1);
......@@ -534,9 +582,9 @@ export default class DiskFileUpload extends Vue {
const value = JSON.stringify(this.uploadFileList);
this.$emit('formitemvaluechange', {name: this.formItemName, value: value});
}
}).catch(error => {
}).catch((error: any) => {
// 提示删除失败
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure')+':'+ error);
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure') + ':' + error);
});
});
}
......@@ -547,8 +595,8 @@ export default class DiskFileUpload extends Vue {
*
* @memberof DiskFileUpload
*/
public updateFileBatch(files: any, opt: any) {
let _this:any = this;
public updateFileBatch(files: any) {
let _this: any = this;
// 拼接url
const updateUrl = '/net-disk/files/' + this.getFolder() + '?ownertype=' + this.getOwnertype() + "&ownerid=" + this.getOwnerid();
// requestBody参数
......@@ -562,69 +610,93 @@ export default class DiskFileUpload extends Vue {
"Content-Type": "application/json;charset=UTF-8"
},
timeout: 2000
}).then(response => {
}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.updateFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.updateFailure') + '!');
return;
}
}).catch(error => {
Message.error(_this.$t('components.diskFileUpload.updateFailure')+':'+ error);
}).catch((error: any) => {
Message.error(_this.$t('components.diskFileUpload.updateFailure') + ':' + error);
});
}
}
}
</script>
<style lang="less">
#file-upload {
#file-upload {
width: auto;
height: auto;
border: 0px solid black;
}
}
#el-row {
#el-row {
border: 0px solid red;
width: 400px;
}
}
.withDrag {
.withDrag {
border: 0px solid grey;
width: 400px;
}
}
.withoutDrag {
.withoutDrag {
border: 0px solid grey;
width: 400px;
text-align: left;
padding-left: 0px;
padding-top: 0px;
margin-top: 0px;
}
.el-upload__tip {
margin-top: 0px;
}
}
.fileList {
.fileList {
width: 400px;
border: 0px solid grey;
margin-top: 0px;
}
}
.fileTitle {
.fileTitle {
text-align: left;
margin-left: 0px;
}
}
.fileTitle i {
.fileTitle i {
margin-right: 5px;
}
}
.fileMain {
.fileMain {
text-align: left;
margin-left: 0px;
margin-top: -10px;
}
}
.fileMain .el-link:nth-child(n+2) {
.fileMain .el-link:nth-child(n+2) {
margin-left: 10px;
}
}
.dialogDiv {
// el-dialog头部
.el-dialog__header {
height: 40px;
}
// el-dialog面板
.el-dialog__wrapper {
height: 90vh;
overflow: visible;
}
// el-dialog
.el-dialog {
height: 100%;
}
// el-dailog内容
.el-dialog__body {
height: inherit;
}
#fileIframe {
height: calc(100% - 40px);
}
}
</style>
\ No newline at end of file
......@@ -7,7 +7,6 @@
list-type="picture-card"
:action="getAction()"
:headers="myHeaders"
:limit="limit"
:before-upload="beforeUpload"
:http-request="customImageUpload">
<i class="el-icon-plus"></i>
......@@ -15,40 +14,62 @@
<img class="el-upload-list__item-thumbnail" :src="file.url">
<span class="el-upload-list__item-actions">
<!--预览按钮-->
<span class="el-upload-list__item-preview" @click="onPreview(file)" :title="$t('components.diskImageUpload.preview')"
<span class="el-upload-list__item-preview" @click="onPreview(file)"
:title="$t('components.diskImageUpload.preview')"
v-show="showPreview">
<i class="el-icon-view"></i>
</span>
<!--OCR按钮-->
<span class="el-upload-list__item-delete" @click="onOcr(file)" :title="$t('components.diskImageUpload.OCRdiscern')"
<span class="el-upload-list__item-delete" @click="onOcr(file)"
:title="$t('components.diskImageUpload.OCRdiscern')"
v-show="showOcrview && (file.name.match(/^.+\.(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|bmp|BMP)$/))">
<i class="el-icon-camera"></i>
</span>
<!--下载按钮-->
<span class="el-upload-list__item-delete" @click="onDownload(file)" :title="$t('components.diskImageUpload.load')">
<span class="el-upload-list__item-delete" @click="onDownload(file)"
:title="$t('components.diskImageUpload.load')">
<i class="el-icon-download"></i>
</span>
<!--删除按钮-->
<span class="el-upload-list__item-delete" @click="onRemove(file)" :title="$t('components.diskImageUpload.delete')">
<span class="el-upload-list__item-delete" @click="onRemove(file)"
:title="$t('components.diskImageUpload.delete')">
<i class="el-icon-delete"></i>
</span>
</span>
</div>
</el-upload>
<!-- 预览弹框 -->
<el-dialog :visible.sync="dialogVisible" :modal="false">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
<!-- 自定义弹框 -->
<div class="dialogDiv">
<el-dialog
:title="dialogTitle"
center
width="70%"
top="5vh"
:visible="showDialog"
:close-on-click-modal="true"
:show-close="true"
:before-close="dialogClose"
:modal-append-to-body="false">
<div style="height: 100%;">
<iframe id="fileIframe" :src="iframeUrl" frameborder="0" width="100%"></iframe>
</div>
</el-dialog>
</div>
</div>
</template>
<script lang="ts">
import {Component, Vue, Prop, Watch} from 'vue-property-decorator';
import {Message, MessageBox} from 'element-ui';
import Axios from 'axios';
import {Subject, Unsubscribable} from 'rxjs';
import {Component, Vue, Prop, Watch} from 'vue-property-decorator';
import {Message, MessageBox} from 'element-ui';
import Axios from 'axios';
import {Subject, Unsubscribable} from 'rxjs';
@Component({})
export default class DiskImageUplaod extends Vue {
@Component({})
export default class DiskImageUplaod extends Vue {
/**
* 当前表单对象
......@@ -131,21 +152,6 @@ export default class DiskImageUplaod extends Vue {
*/
@Prop({default: false}) public showOcrview?: boolean;
/**
* 单文件大小
*
* @type {number}
* @memberof DiskImageUplaod
*/
@Prop({default: 1}) public size!: number;
/**
* 文件上传个数
*
* @type {number}
* @memberof DiskImageUplaod
*/
@Prop({default: 5}) public limit!: number;
/**
* 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存)
......@@ -227,6 +233,43 @@ export default class DiskImageUplaod extends Vue {
*/
public imageFileids: Array<any> = [];
/**
* 自定义弹框标题
*
* @type {*}
* @memberof DiskImageUplaod
*/
public dialogTitle: any = '';
/**
* 是否显示自定义弹框
*
* @type {boolean}
* @memberof DiskImageUplaod
*/
public showDialog: boolean = false;
/**
* 嵌入自定义弹框中iframe的url
*
* @type {*}
* @memberof DiskImageUplaod
*/
public iframeUrl: any = '';
/**
* 关闭自定义弹框
*
* @memberof DiskImageUplaod
*/
public dialogClose() {
this.dialogTitle = '';
this.showDialog = false;
this.iframeUrl = '';
let iframe: any = document.getElementById("fileIframe");
iframe.parentNode.removeChild("fileIframe");
}
/**
* 拼接上传路径
*
......@@ -264,7 +307,7 @@ export default class DiskImageUplaod extends Vue {
}
/**
* vue生命周期create
* vue创建
*
* @memberof DiskImageUplaod
*/
......@@ -312,7 +355,7 @@ export default class DiskImageUplaod extends Vue {
*/
public getFiles() {
// 拼接url
let _this:any = this;
let _this: any = this;
const getUrl = '/net-disk/files/' + this.getFolder();
// 发送get请求
Axios.get(getUrl, {
......@@ -320,9 +363,9 @@ export default class DiskImageUplaod extends Vue {
ownertype: this.getOwnertype(),
ownerid: this.getOwnerid(),
},
}).then(response => {
}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskImageUpload.getImageFailure')+"!");
Message.error(_this.$t('components.diskImageUpload.getImageFailure') + "!");
return;
}
// 返回的是一个jsonArray
......@@ -337,8 +380,8 @@ export default class DiskImageUplaod extends Vue {
});
}
}
}).catch(error => {
Message.error(_this.$t('components.diskImageUpload.getImageFailure')+':'+ error);
}).catch((error: any) => {
Message.error(_this.$t('components.diskImageUpload.getImageFailure') + ':' + error);
});
}
......@@ -358,14 +401,14 @@ export default class DiskImageUplaod extends Vue {
'authcode': fileData.authcode
},
responseType: 'blob',
}).then(res => {
if (!res || res.status != 200) {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure')+'!');
}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure') + '!');
}
// 请求成功,后台返回的是一个文件流
if (res.data) {
if (response.data) {
// 用blob对象获取文件流
var blob = new Blob([res.data], {type: res.headers['content-type']});
var blob = new Blob([response.data], {type: response.headers['content-type']});
// 通过文件流创建下载链接
var href = URL.createObjectURL(blob);
// 将下载链接保存到图片中
......@@ -384,8 +427,8 @@ export default class DiskImageUplaod extends Vue {
} else {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure1'));
}
}).catch(error => {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure')+':' + error);
}).catch((error: any) => {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure') + ':' + error);
});
}
......@@ -401,12 +444,6 @@ export default class DiskImageUplaod extends Vue {
Message.error(_this.$t('components.diskImageUpload.uploadImageFailure1'));
return false;
}
// 文件大小
const isSize = file.size / 1024 / 1024 < this.size;
if (!isSize) {
Message.error(_this.$t('components.diskImageUpload.uploadFailure')+this.size.toString()+"M!");
return false;
}
}
/**
......@@ -424,9 +461,9 @@ export default class DiskImageUplaod extends Vue {
// 拼接url
const uploadUrl = this.getAction();
// 发送post请求
Axios.post(uploadUrl, formData, {timeout: 2000}).then(response => {
Axios.post(uploadUrl, formData, {timeout: 2000}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskImageUpload.uploadImageFailure')+"!");
Message.error(_this.$t('components.diskImageUpload.uploadImageFailure') + "!");
}
// 返回的是一个jsonobject
if (response.data) {
......@@ -439,15 +476,15 @@ export default class DiskImageUplaod extends Vue {
'authcode': returnData.authcode
},
responseType: 'blob',
}).then(res => {
if (!res || res.status != 200) {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure')+"!");
}).then((response2) => {
if (!response2 || response2.status != 200) {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure') + "!");
return;
}
// 请求成功,后台返回的是一个文件流
if (res.data) {
if (response2.data) {
// 用blob对象获取文件流
var blob = new Blob([res.data], {type: res.headers['content-type']});
var blob = new Blob([response2.data], {type: response2.headers['content-type']});
// 通过文件流创建下载链接
var href = URL.createObjectURL(blob);
// 将下载链接保存到本次上传成功后返回的jsonobject中
......@@ -475,12 +512,12 @@ export default class DiskImageUplaod extends Vue {
} else {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure1'));
}
}).catch(error => {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure')+':' + error);
}).catch((error2: any) => {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure') + ':' + error2);
});
}
}).catch(err => {
Message.error(_this.$t('components.diskImageUpload.uploadImageFailure')+':' + err);
}).catch((error: any) => {
Message.error(_this.$t('components.diskImageUpload.uploadImageFailure') + ':' + error);
});
}
......@@ -510,8 +547,19 @@ export default class DiskImageUplaod extends Vue {
const id = typeof file.id == "string" ? file.id : JSON.stringify(file.id);
const name = typeof file.name == "string" ? file.name : JSON.stringify(file.name);
const ocrUrl = '/net-disk/ocrview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + file.authcode;
// 新窗口打开url
window.open(ocrUrl);
Axios.get(ocrUrl).then((response: any) => {
if (!response || response.status != 200) {
return;
}
// 返回一个url,通过自定义弹框打开
if (response.data) {
this.dialogTitle = name;
this.showDialog = true;
this.iframeUrl = response.data;
}
}).catch((error: any) => {
Message.error(error);
});
}
/**
......@@ -531,9 +579,9 @@ export default class DiskImageUplaod extends Vue {
'authcode': file.authcode
},
responseType: 'blob',
}).then(response => {
}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure2')+'!');
Message.error(_this.$t('components.diskImageUpload.loadImageFailure2') + '!');
return;
}
// 请求成功,后台返回的是一个文件流
......@@ -548,7 +596,11 @@ export default class DiskImageUplaod extends Vue {
// 创建一个a元素并设置相关属性
var a = document.createElement('a');
a.href = href;
if (name) {
a.download = name;
} else {
a.download = filename;
}
// 添加a元素到当前网页
document.body.appendChild(a);
// 触发a元素的点击事件,实现下载
......@@ -560,8 +612,8 @@ export default class DiskImageUplaod extends Vue {
} else {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure3'));
}
}).catch(error => {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure2')+':' + error);
}).catch((error: any) => {
Message.error(_this.$t('components.diskImageUpload.loadImageFailure2') + ':' + error);
});
}
......@@ -574,7 +626,7 @@ export default class DiskImageUplaod extends Vue {
public onRemove(file: any) {
let _this: any = this;
if (file) {
MessageBox.confirm(_this.$t('components.diskImageUpload.deleteFile'),_this.$t('components.diskImageUpload.deleteFilePrompt'), {
MessageBox.confirm(_this.$t('components.diskImageUpload.deleteFile'), _this.$t('components.diskImageUpload.deleteFilePrompt'), {
confirmButtonText: _this.$t('components.diskImageUpload.true'),
cancelButtonText: _this.$t('components.diskImageUpload.false'),
type: 'warning'
......@@ -585,9 +637,9 @@ export default class DiskImageUplaod extends Vue {
// 拼接url
const deleteUrl = '/net-disk/files/' + file.id;
// 发送delete请求
Axios.delete(deleteUrl).then(response => {
Axios.delete(deleteUrl).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskImageUpload.deleteImageFailure')+'!');
Message.error(_this.$t('components.diskImageUpload.deleteImageFailure') + '!');
}
// 从fileid数组中删除
this.imageFileids.splice(index, 1);
......@@ -598,9 +650,9 @@ export default class DiskImageUplaod extends Vue {
const value = JSON.stringify(this.imageList);
this.$emit('formitemvaluechange', {name: this.formItemName, value: value});
}
}).catch(error => {
}).catch((error: any) => {
// 提示删除失败
Message.error(_this.$t('components.diskImageUpload.deleteImageFailure')+':' + error);
Message.error(_this.$t('components.diskImageUpload.deleteImageFailure') + ':' + error);
});
}
});
......@@ -628,20 +680,46 @@ export default class DiskImageUplaod extends Vue {
"Content-Type": "application/json;charset=UTF-8"
},
timeout: 2000
}).then(response => {
}).then((response: any) => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskImageUpload.updateFailure')+'!');
Message.error(_this.$t('components.diskImageUpload.updateFailure') + '!');
return;
}
}).catch(error => {
Message.error(_this.$t('components.diskImageUpload.updateFailure')+':' + error);
}).catch((error: any) => {
Message.error(_this.$t('components.diskImageUpload.updateFailure') + ':' + error);
});
}
}
}
</script>
<style scoped>
<style lang="less">
.dialogDiv {
// el-dialog头部
.el-dialog__header {
height: 40px;
}
// el-dialog面板
.el-dialog__wrapper {
height: 90vh;
overflow: visible;
}
// el-dialog
.el-dialog {
height: 100%;
}
// el-dailog内容
.el-dialog__body {
height: inherit;
}
// iframe
#fileIframe {
height: calc(100% - 40px);
}
}
</style>
\ No newline at end of file
......@@ -81,6 +81,9 @@ export default class CalendarExpViewEngine extends ViewEngine {
this.view.$emit('viewload', args);
}
if (Object.is(eventName, 'selectionchange')) {
if(this.calendarExpBar && this.calendarExpBar.calcNavigationToolbarState && this.calendarExpBar.calcNavigationToolbarState instanceof Function){
this.calendarExpBar.calcNavigationToolbarState();
}
this.view.$emit('viewdataschange', args);
}
if (Object.is(eventName, 'activated')) {
......
......@@ -78,6 +78,9 @@ export default class DataViewExpViewEngine extends ViewEngine {
*/
public dataviewExpBarEvent(eventName: string, args: any): void {
if (Object.is(eventName, 'load')) {
if(this.dataviewExpBar && this.dataviewExpBar.calcNavigationToolbarState && this.dataviewExpBar.calcNavigationToolbarState instanceof Function){
this.dataviewExpBar.calcNavigationToolbarState();
}
this.view.$emit('viewload', args);
}
if (Object.is(eventName, 'selectionchange')) {
......
......@@ -78,6 +78,9 @@ export default class GridExpViewEngine extends ViewEngine {
*/
public gridExpBarEvent(eventName: string, args: any): void {
if (Object.is(eventName, 'load')) {
if(this.gridExpBar && this.gridExpBar.calcNavigationToolbarState && this.gridExpBar.calcNavigationToolbarState instanceof Function){
this.gridExpBar.calcNavigationToolbarState();
}
this.view.$emit('viewload', args);
}
if (Object.is(eventName, 'selectionchange')) {
......
......@@ -78,6 +78,9 @@ export default class ListExpViewEngine extends ViewEngine {
*/
public listExpBarEvent(eventName: string, args: any): void {
if (Object.is(eventName, 'load')) {
if(this.listExpBar && this.listExpBar.calcNavigationToolbarState && this.listExpBar.calcNavigationToolbarState instanceof Function){
this.listExpBar.calcNavigationToolbarState();
}
this.view.$emit('viewload', args);
}
if (Object.is(eventName, 'selectionchange')) {
......
......@@ -401,10 +401,10 @@ export default class MDViewEngine extends ViewEngine {
if (this.view.viewparams && Object.keys(this.view.viewparams).length > 0) {
Object.assign(arg, this.view.viewparams);
}
if (this.getSearchForm() && this.view.isExpandSearchForm) {
if (this.getSearchForm()) {
Object.assign(arg, this.getSearchForm().getData());
}
if (this.view && this.view.$refs.searchbar && this.view.isExpandSearchForm) {
if (this.view && this.view.$refs.searchbar) {
Object.assign(arg, this.view.$refs.searchbar.getData());
}
if (this.view && !this.view.isExpandSearchForm) {
......
......@@ -79,6 +79,9 @@ export default class TreeExpView extends ViewEngine {
*/
public treeExpBarEvent(eventName: string, args: any): void {
if (Object.is(eventName, 'load')) {
if(this.treeExpBar && this.treeExpBar.calcNavigationToolbarState && this.treeExpBar.calcNavigationToolbarState instanceof Function){
this.treeExpBar.calcNavigationToolbarState();
}
this.view.$emit('viewload', args);
}
if (Object.is(eventName, 'selectionchange')) {
......
......@@ -47,12 +47,21 @@ export const getLocalData = (state: any) => () => {
* @param state
*/
export const getAppData = (state: any) => () => {
if(!state.appdata){
state.appdata = {};
}
let result:any = JSON.parse(JSON.stringify(state.appdata));
if(state.localdata && Object.keys(state.localdata).length >0){
let copyContext:any = result.context?result.context:{};
if(state.localdata && Object.keys(state.localdata).length >0){
Object.assign(copyContext,state.localdata);
result.context = copyContext;
}else if(localStorage.getItem('localdata')){
try{
Object.assign(copyContext,JSON.parse(localStorage.getItem('localdata') as string));
}catch(error){
console.warn(error);
}
}
result.context = copyContext;
return result;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册