¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud :option="option" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | :page.sync="page" |
| | | :before-open="beforeOpen" |
| | | :permission="permissionList" |
| | | v-model="form" |
| | | ref="crud" |
| | | @row-del="rowDel" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad"> |
| | | <template slot="menuLeft"> |
| | | <el-button v-if="hasUpload" type="primary" |
| | | size="small" |
| | | plain |
| | | icon="el-icon-upload2" |
| | | @click="handleUpload">ä¸ ä¼ |
| | | </el-button> |
| | | <el-button v-if="hasEdit" type="primary" |
| | | size="small" |
| | | plain |
| | | icon="el-icon-edit" |
| | | @click="handleEdit">ä¿® æ¹ |
| | | </el-button> |
| | | <el-button v-if="hasDownload" type="primary" |
| | | size="small" |
| | | icon="el-icon-download" |
| | | plain |
| | | @click="handleDownload">ä¸ è½½ |
| | | </el-button> |
| | | <el-button v-if="hasDel" type="danger" |
| | | size="small" |
| | | icon="el-icon-delete" |
| | | plain |
| | | @click="handleDelete">å é¤ |
| | | </el-button> |
| | | </template> |
| | | <template slot-scope="scope" slot="menu"> |
| | | <el-button v-if="hasDownload" type="text" |
| | | icon="el-icon-download" |
| | | size="small" |
| | | @click="handleDownload(scope.row)">ä¸è½½ |
| | | </el-button> |
| | | </template> |
| | | </avue-crud> |
| | | <el-dialog title="é件管ç" |
| | | append-to-body |
| | | :visible.sync="attachBox" |
| | | width="555px"> |
| | | <avue-form ref="form" :option="attachOption" v-model="attachForm" :upload-before="uploadBefore" :upload-after="uploadAfter" :upload-error="uploadError"> |
| | | </avue-form> |
| | | </el-dialog> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import {getList, getFile,upload,update, remove,download} from "@/api/resource/file"; |
| | | import {mapGetters} from "vuex"; |
| | | import {dateFormat} from "@/util/date"; |
| | | import {validatenull} from "@/util/validate"; |
| | | |
| | | export default { |
| | | props: ["options","visible"], |
| | | data() { |
| | | return { |
| | | form: {}, |
| | | query: {}, |
| | | params:{}, |
| | | loading: false, |
| | | page: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0 |
| | | }, |
| | | attachBox: false, |
| | | selectionList: [], |
| | | hasUpload:validatenull(this.options.hasUpload) ? true :this.options.hasUpload, |
| | | hasEdit:validatenull(this.options.hasEdit) ? true :this.options.hasEdit, |
| | | hasDel:validatenull(this.options.hasDel) ? true :this.options.hasDel, |
| | | hasDownload:validatenull(this.options.hasDownload) ? true :this.options.hasDownload, |
| | | option: { |
| | | height:(this.options.tableHeight?this.options.tableHeight:'auto'), |
| | | calcHeight: 30, |
| | | tip: false, |
| | | searchShow: true, |
| | | searchMenuSpan: 6, |
| | | border: true, |
| | | index: true, |
| | | viewBtn: true, |
| | | selection: true, |
| | | dialogClickModal: false, |
| | | column: [ |
| | | { |
| | | label: "æä»¶åç§°", |
| | | prop: "name", |
| | | search: true, |
| | | /*formatter:function(d){ |
| | | if(this.options.hasDownloadRight != false){ |
| | | //说ææä¸è½½æä»¶çæéï¼é£ä¹æä»¬å°±æ·»å ä¸ä¸ªè¶
龿¥ |
| | | return ''//'<a name="filenamedownloadlink " class="layui-btn layui-btn-intable" lay-event="PREVIEW" fileoid="' + d.oid +'">' + (d.id?d.id:d.name) + '</a>'; |
| | | }else{ |
| | | return d.id || d.name; |
| | | } |
| | | }*/ |
| | | }, |
| | | { |
| | | label: "æä»¶å¤§å°", |
| | | prop: "fileSize", |
| | | formatter:function(d){ |
| | | if(!d.fileSize || d.fileSize == null || d.fileSize*1 == 0 || isNaN(d.fileSize*1) ){ |
| | | return "æªç¥å¤§å°"; |
| | | }else{ |
| | | //åå§å¤§å°æ¯B |
| | | var filesize = d.fileSize*1; |
| | | if(filesize>1024*1024*1024*1024){ |
| | | return parseInt(filesize/(1024*1024*1024*1024)) + "TB"; |
| | | }else if(filesize> 1024*1024*1024){ |
| | | return parseInt(filesize/(1024*1024*1024)) + "GB"; |
| | | }else if(filesize> 1024*1024){ |
| | | return parseInt(filesize/(1024*1024)) + "MB"; |
| | | }else if(filesize> 1024){ |
| | | return parseInt(filesize/1024) + "KB"; |
| | | }else { |
| | | return filesize + "B"; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | /*{ |
| | | label: "å¯çº§", |
| | | prop: "secretGradeText" |
| | | }, |
| | | { |
| | | label: "ææ¡£ç±»å«", |
| | | prop: "fileDocClassifyName" |
| | | },*/ |
| | | { |
| | | label: "å建è
", |
| | | prop: "creator" |
| | | }, |
| | | { |
| | | label: "å建æ¶é´", |
| | | prop: "createTime" |
| | | }, |
| | | ] |
| | | }, |
| | | columnType: { |
| | | text: "input", |
| | | combox: "select", |
| | | truefalse: "switch", |
| | | number: "number", |
| | | textarea: "textarea", |
| | | datetime: "datetime", |
| | | date: "date", |
| | | refer: "refer", |
| | | }, |
| | | data: [], |
| | | attachForm: {}, |
| | | attachOption: { |
| | | submitBtn: false, |
| | | emptyBtn: false, |
| | | column: [{ |
| | | prop: 'fileDocClassify', |
| | | label: 'æä»¶ç±»å', |
| | | props: { |
| | | label: 'value', |
| | | value: 'key' |
| | | }, |
| | | change: () => { |
| | | (!!this.options.fileDocClassifyCombox) && this.changeFun('fileDocClassify'); |
| | | }, |
| | | blur: () => { |
| | | (!this.options.fileDocClassifyCombox) && this.changeFun('fileDocClassify'); |
| | | }, |
| | | value: this.options.fileDocClassify || "ADMIN_SHARE", |
| | | type: (!this.options.fileDocClassifyCombox) ? 'input' : 'select', |
| | | dicData: (this.options.fileDocClassifyCombox || []),//[{key: 'text', value: 'ææ¬æ¡'}] |
| | | display: (!!this.options.fileDocClassifyCombox) |
| | | }, { |
| | | label: 'éä»¶ä¸ä¼ ', |
| | | prop: 'attachFile', |
| | | type: 'upload', |
| | | dragFile: true, |
| | | accept: this.options.uploadAccept || 'file', |
| | | loadText: 'æä»¶ä¸ä¼ ä¸ï¼è¯·ç¨ç', |
| | | span: 24, |
| | | propsHttp: { |
| | | res: 'data' |
| | | }, |
| | | data: { |
| | | ownbizOid:this.options.ownbizOid || "share", |
| | | ownBtmname:this.options.ownbizBtm || "share", |
| | | fileDocClassify:this.options.fileDocClassify || "ADMIN_SHARE", |
| | | fileDocClassifyName:this.options.fileDocClassifyName || "管çåå
±äº«æä»¶" |
| | | }, |
| | | action: "/api/ubcs-resource/fileController/uploadFile" |
| | | } |
| | | ] |
| | | } |
| | | }; |
| | | }, |
| | | computed: { |
| | | ...mapGetters([ "permission"]), |
| | | permissionList() { |
| | | return { |
| | | addBtn: false, |
| | | viewBtn: false, |
| | | delBtn: this.vaildData(this.permission.attach_delete, false), |
| | | editBtn: false |
| | | }; |
| | | }, |
| | | oids() { |
| | | let oids = []; |
| | | this.selectionList.forEach(ele => { |
| | | oids.push(ele.oid); |
| | | }); |
| | | return oids.join(","); |
| | | } |
| | | }, |
| | | created() { |
| | | this.setFormItem(); |
| | | this.setParams() |
| | | }, |
| | | mounted() { |
| | | |
| | | }, |
| | | methods: { |
| | | setFormItem(){ |
| | | /*this.options.formItems=[{ |
| | | field: 'fileDocClassify11', |
| | | title: 'æä»¶ç±»å', |
| | | type: 'combox', |
| | | data: [{key: 'text', value: 'ææ¬æ¡'},{key: 'number', value: 'æ°åæ¡'}] |
| | | }]*/ |
| | | if(this.options && this.options.formItems){ |
| | | this.options.formItems.forEach(item => { |
| | | // è®¾ç½®è¡¨åæ ¡éªçè§åï¼ææ¬ |
| | | let message = "è¯·éæ©"; |
| | | let trigger = "change"; |
| | | if (item.type === "text") { |
| | | message = "请è¾å
¥"; |
| | | trigger = "blur"; |
| | | } |
| | | this.attachOption.column.push( { |
| | | ...item, |
| | | label: item.title, |
| | | prop: item.field, |
| | | display: !item.hidden, |
| | | value: item.defaultValue, |
| | | disabled: item.readOnly, |
| | | type: this.columnType[item.type], |
| | | dicData: this.getDataList(item.type, item.data), |
| | | change: () => { |
| | | if(item.type !== "text" && item.type !== "number" && item.type !== "textarea"){ |
| | | this.changeFun(item.field); |
| | | } |
| | | }, |
| | | blur: () => { |
| | | if(item.type == "text" || item.type == "number" || item.type == "textarea"){ |
| | | this.changeFun(item.field); |
| | | } |
| | | }, |
| | | rules: [ |
| | | { |
| | | required: item.required, |
| | | message: `请${message}${item.title}`, |
| | | trigger, |
| | | }, |
| | | { |
| | | // å¦ææ²¡ææ£ååå¹é
ä»»ä½å符 |
| | | pattern: item.verify ? item.verify : /[\s\S.]*/g, |
| | | message: item.tooltips, |
| | | trigger, |
| | | }, |
| | | ], |
| | | props: { |
| | | label: 'value', |
| | | value: 'key' |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }, |
| | | changeFun( prop) { |
| | | this.attachOption.column[1].data[prop]=this.attachForm[prop] |
| | | }, |
| | | getDataList(type, dicData) { |
| | | if (type === "truefalse") { |
| | | return [ |
| | | { |
| | | key: false, |
| | | value: "å¦", |
| | | }, |
| | | { |
| | | key: true, |
| | | value: "æ¯", |
| | | }, |
| | | ]; |
| | | } else if (type === "combox") { |
| | | return dicData; |
| | | } |
| | | return []; |
| | | }, |
| | | setParams() { |
| | | var queryMap = { |
| | | currentButtonKey: 'VIEW', |
| | | ownbizOid: this.options.ownbizOid, |
| | | ownbizBtm: this.options.ownbizBtm, |
| | | fileDocClassify: this.options.fileDocClassify, |
| | | fileDocClassifyName: this.options.fileDocClassifyName |
| | | }; |
| | | if (this.options.where) { |
| | | Object.assign(queryMap, this.options.where); |
| | | } |
| | | this.params = queryMap; |
| | | |
| | | if (!this.options.pageObject) { |
| | | this.options.pageObject = { |
| | | limit: 10, |
| | | page: 1 |
| | | }; |
| | | } |
| | | this.page.pageSize = this.options.pageObject.limit; |
| | | this.page.currentPage = this.options.pageObject.page; |
| | | }, |
| | | handleUpload() { |
| | | this.attachOption.column[1].data.fileOid=''; |
| | | delete this.attachOption.column[1].data.oid; |
| | | delete this.attachOption.column[1].data.updateFileFlag; |
| | | this.attachBox = true; |
| | | }, |
| | | handleEdit() { |
| | | if(this.selectionList.length==0){ |
| | | this.$message.warning('è¯·éæ©éè¦ä¿®æ¹çæä»¶') |
| | | return false; |
| | | }else if(this.selectionList.length>1){ |
| | | this.$message.warning('è¯·éæ©ä¸æ¡æ°æ®') |
| | | return false; |
| | | } |
| | | this.attachOption.column[1].data.fileOid=this.oids; |
| | | this.attachOption.column[1].data.oid=this.oids; |
| | | this.attachOption.column[1].data.updateFileFlag=true |
| | | this.attachBox = true; |
| | | }, |
| | | uploadBefore(file, done, loading,column) { |
| | | done(); |
| | | }, |
| | | uploadAfter(res, done, loading, column) { |
| | | if(res.success){ |
| | | this.attachBox = false; |
| | | this.$message.success('æä»¶ä¸ä¼ æå') |
| | | }else{ |
| | | this.$message.error(res.msg); |
| | | } |
| | | this.refreshChange(); |
| | | done(); |
| | | }, |
| | | uploadError(error, column) { |
| | | this.$message.error('ä¸ä¼ æä»¶åºç°äºå¼å¸¸') |
| | | }, |
| | | handleDownload(row) { |
| | | //window.open(`${row.link}`); |
| | | if(row && row.oid){ |
| | | download(row.oid) |
| | | }else{ |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | return; |
| | | } |
| | | download(this.oids); |
| | | } |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm("ç¡®å®å°éæ©æä»¶å é¤?", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }) |
| | | .then(() => { |
| | | return remove(row.oid); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "æä½æå!" |
| | | }); |
| | | }); |
| | | }, |
| | | handleDelete() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | return; |
| | | } |
| | | this.$confirm("ç¡®å®å°éæ©æ°æ®å é¤?", { |
| | | confirmButtonText: "ç¡®å®", |
| | | cancelButtonText: "åæ¶", |
| | | type: "warning" |
| | | }) |
| | | .then(() => { |
| | | return remove(this.oids); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "æä½æå!" |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (["edit", "view"].includes(type)) { |
| | | getDetail(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | }); |
| | | } |
| | | done(); |
| | | }, |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.onLoad(this.page); |
| | | }, |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page); |
| | | done(); |
| | | }, |
| | | selectionChange(list) { |
| | | this.selectionList = list; |
| | | }, |
| | | selectionClear() { |
| | | this.selectionList = []; |
| | | this.$refs.crud.toggleSelection(); |
| | | }, |
| | | currentChange(currentPage) { |
| | | this.page.currentPage = currentPage; |
| | | }, |
| | | sizeChange(pageSize) { |
| | | this.page.pageSize = pageSize; |
| | | }, |
| | | refreshChange() { |
| | | this.onLoad(this.page, this.query); |
| | | }, |
| | | onLoad(page, params={}) { |
| | | this.loading = true; |
| | | var query={} |
| | | if (this.query) { |
| | | for (var key in this.query) { |
| | | query['conditionMap["' + key + '"]'] = this.query[key]; |
| | | } |
| | | } |
| | | getList(page.currentPage, page.pageSize, Object.assign(params,this.params, query,this.query)).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | if(data && data.records.length>0 && this.options.fileDocClassifyCombox){ |
| | | this.data = data.records.map(item => { |
| | | if(validatenull(item.fileDocClassifyName)&& !validatenull(item.fileDocClassify)){ |
| | | item.fileDocClassifyName = this.options.fileDocClassifyCombox[item.fileDocClassify] || ''; |
| | | } |
| | | return { |
| | | ...item |
| | | } |
| | | }) |
| | | } |
| | | //this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }).catch(error=>{ |
| | | this.$message.error(error); |
| | | this.loading = false; |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |