From e6a21130e1fa5d22a42001a79ca141e093a8b001 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期一, 24 六月 2024 18:08:05 +0800 Subject: [PATCH] 添加自定义弹出拖拽指令&上传文件下载文件action配置以及页面编写&创建默认表格option配置&表格加上自定义宽度 --- Source/plt-web/plt-web-ui/src/components/actions/handlers.js | 8 Source/plt-web/plt-web-ui/src/directive/el-drag-dialog/dialogDrag.js | 51 +++++ Source/plt-web/plt-web-ui/src/page/login/userlogin.vue | 2 Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js | 64 ++++++ Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js | 74 +++++++ Source/plt-web/plt-web-ui/src/store/modules/user.js | 3 Source/plt-web/plt-web-ui/src/views/base/UIContentViewer.vue | 1 Source/plt-web/plt-web-ui/src/main.js | 2 /dev/null | 0 Source/plt-web/plt-web-ui/src/option/user/basic-option.js | 14 + Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue | 183 ++++++++++++++++++ Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-table.vue | 2 Source/plt-web/plt-web-ui/src/views/user/userManage.vue | 137 +++++++++++++ 13 files changed, 540 insertions(+), 1 deletions(-) diff --git a/Source/plt-web/plt-web-ui/public/img/Group.png b/Source/plt-web/plt-web-ui/public/img/Group.png deleted file mode 100644 index 9ffeefa..0000000 --- a/Source/plt-web/plt-web-ui/public/img/Group.png +++ /dev/null Binary files differ diff --git a/Source/plt-web/plt-web-ui/public/img/image.png.png b/Source/plt-web/plt-web-ui/public/img/image.png.png deleted file mode 100644 index 86cfdeb..0000000 --- a/Source/plt-web/plt-web-ui/public/img/image.png.png +++ /dev/null Binary files differ diff --git a/Source/plt-web/plt-web-ui/public/img/login-background.png b/Source/plt-web/plt-web-ui/public/img/login-background.png deleted file mode 100644 index 18fd869..0000000 --- a/Source/plt-web/plt-web-ui/public/img/login-background.png +++ /dev/null Binary files differ diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js new file mode 100644 index 0000000..4c6c358 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js @@ -0,0 +1,64 @@ +/** + * 鎸夐挳澶勭悊 涓氬姟绫诲瀷瀹$ + */ +import {paramLow,callPreEvent, callPostEvent} from '../BaseAction'; +import {validatenull} from "@/util/validate"; +import Vue from "vue"; +import func from "@/util/func"; + +export const doAction = (options,callback) => { + options.sourceData = options.sourceData || {}; + options.dataStore = options.dataStore || []; + if (!options.dataStore || options.dataStore.length < 1) { + Vue.prototype.$message.error("璇烽�夋嫨闇�瑕佷笅杞界殑鏁版嵁"); + return false; + } + if (!options.paramVOS.multi && options.dataStore.length > 1) { + Vue.prototype.$message.error("浠呰兘閫夋嫨涓�鏉℃暟鎹繘琛屼笅杞�"); + return false; + } + + + callPreEvent(options, doBefore, function (options) { + showStartWindow(options, function () { + callPostEvent(options, doAfter, callback,type); + }); + }); +}; + +/** + * 鏄剧ず娴佺▼鐨勭獥鍙� + * @param options 鎸夐挳鐨勯厤缃俊鎭� + * @param callback 鍥炶皟 + */ +export const showStartWindow = (options,callback)=> { + const paramVOS = options.paramVOS; + if (!paramVOS['form'] && !paramVOS['context']) { + Vue.prototype.$message.error("鎸夐挳閰嶇疆涓嶆纭�"); + return false; + } + // func.downloadFileByBlobHandler(); + +} +/** + * 鍓嶇疆浜嬩欢 + * @param options 鎸夐挳鐨勯厤缃俊鎭� + * @param callback 鍥炶皟 + */ +export const doBefore = (options,callback)=> { + console.log("鎵ц澧炲姞鍓嶇疆浜嬩欢") + if(callback){ + callback(options); + } +} +/** + * 鍚庣疆浜嬩欢 + * @param options 鎸夐挳鐨勯厤缃俊鎭� + * @param callback 鍥炶皟 + */ +export const doAfter = (options,callback,actionType)=> { + console.log('鎵ц澧炲姞鍚庣疆浜嬩欢'); + if(callback){ + callback(actionType); + } +} diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue new file mode 100644 index 0000000..433d92d --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue @@ -0,0 +1,183 @@ +<template> + <el-dialog + v-dialogDrag + :width="width" + :visible.sync="visible" + :destroy-on-close="true" + :close-on-click-modal="false" + append-to-body + title="涓婁紶鏂囦欢" + class="avue-dialog" + > + <Divider left="30px" text="瀵煎叆鎻愮ず"></Divider> + <ul> + <li> + 1.绾㈣壊瀛椾綋琛ㄧず蹇呰緭椤� + </li> + <li> + 2.姣忔浠呰兘鏈�澶氬鍏�10000鏉℃暟鎹� + </li> + </ul> + <Divider left="30px" text="excel鏂囦欢锛岄�夋嫨鏂囦欢鍚庝細鑷姩涓婁紶"></Divider> + <el-upload + :before-upload="beforeUpload" + :headers="uploadHeaders" + :on-change="uploadChange" + :on-error="onError" + :on-success="onSuccess" + :show-file-list="false" + accept=".xlsx, .xls" + action="/api/ubcs-code/codeClassify/importClassify" + class="upload-demo"> + <el-button size="small" style="margin: 15px 35px" type="primary">娴忚鏂囦欢</el-button> + </el-upload> + <template #footer> + <el-button + :loading="downloadLoading" + size="small" + type="primary" + @click="downloadTemplateFun" + >涓嬭浇瀵煎叆妯℃澘 + </el-button + > + <el-button size="small" @click="visible = false">鍏抽棴</el-button> + </template> + </el-dialog> +</template> + +<script> +// import {downloadErrorFile,downloadBatchImportApplyTemplate} from '@/api/template/templateAttr' +import {getToken} from "@/util/auth"; +import func from "@/util/func"; +import {validatenull} from "@/util/validate"; + +export default { + name: "upload-file", + props: { + paramVOS: { + type: Object, + default: {} + }, + sourceData: { + //鎵�灞炲尯鍩熺殑涓婁竴鍖哄煙閫変腑鏁版嵁 + type: Object, + default: {} + }, + dataStore: { + //寮圭獥鏃舵寜閽墍灞炲尯鍩熼�変腑鏁版嵁 + type: Array, + default: [] + }, + }, + data() { + return { + flga: true, + pageLoading: null, + downloadLoading: false, + visible:false, + } + }, + watch: { + visible: { + handler(newval, oldval) { + // console.log('newval',newval) + } + } + }, + computed: { + uploadHeaders() { + return { + "Blade-Auth": "bearer " + getToken(), + }; + }, + width() { + if (!validatenull(this.paramVOS.width)) { + if (this.paramVOS.width.includes("px") || this.paramVOS.width.includes("%")) { + return this.paramVOS.width; + } else { + return this.paramVOS.width + "px"; + } + } else { + return "60%"; + } + }, + fullscreen(){ + console.log(this.paramVOS) + if(this.paramVOS.width || this.paramVOS.height){ + return false; + }else if(this.paramVOS.form){ + return false; + } + return true; + } + }, + methods: { + //鏂囦欢涓婁紶鍓� + async beforeUpload(file) { + const fileType = file.name.split(".").pop(); + if (fileType !== "xlsx" && fileType !== "xls") { + // 涓婁紶鏍煎紡涓嶇鍚堣姹傦紝鎻愮ず閿欒淇℃伅骞跺彇娑堜笂浼� + this.$message.error("鍙厑璁镐笂浼爔lsx銆亁ls鏍煎紡鐨勬枃浠�"); + return Promise.reject(false); + } + this.pageLoading = this.$loading({ + lock: true, + text: "鏂囦欢涓婁紶涓�", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }); + return true; + }, + // 鏂囦欢涓婁紶鎴愬姛 + onSuccess(resbonse) { + if (Object.keys(resbonse.data).length === 0) { + this.$message.success("涓婁紶鎴愬姛锛�"); + this.dialogVisible = false; + return; + } + if (resbonse.data.fileOid) { + const fileName = resbonse.data.filePath.split("/").pop(); + this.$message.error("璇蜂笅杞介敊璇俊鎭枃浠惰繘琛屾煡鐪嬶紒"); + downloadErrorFile({uuid: resbonse.data.fileOid}).then((res) => { + func.downloadFileByBlobHandler(res); + }); + } + }, + //鐐瑰嚮涓嬭浇妯℃澘 + downloadTemplateFun() { + this.downloadLoading = true; + downloadBatchImportApplyTemplate({codeClassifyOid: this.codeClassifyOid}).then(res => { + this.$utilFunc.downloadFileByBlob(res.data, "妯℃澘鏂囦欢.xls"); + this.downloadLoading = false; + }).catch((res) => { + this.$message.warning(res) + this.downloadLoading = false; + }) + }, + //鏂囦欢涓婁紶澶辫触 + onError(res) { + this.pageLoading.close(); + }, + //鏂囦欢鐘舵�佹敼鍙� + uploadChange(file) { + if (file.status === "success" || file.status === "error") { + this.pageLoading.close(); + } + } + } +} +</script> + +<style lang="scss" scoped> +ul { + color: rgb(188, 188, 188); + margin: 20px 0 20px 0; + padding: 0 0 0 30px; + list-style: none; + + li { + margin-bottom: 5px; + font-size: 13px; + } +} +</style> diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js new file mode 100644 index 0000000..b486c54 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js @@ -0,0 +1,74 @@ +/** + * 鎸夐挳澶勭悊 涓氬姟绫诲瀷瀹$ + */ +import {paramLow,callPreEvent, callPostEvent} from '../BaseAction'; +import {validatenull} from "@/util/validate"; +import Vue from "vue"; +import uploadFileDialog from "@/components/actions/base/uploadFile" + + +export const doAction = (options,callback) => { + options.sourceData = options.sourceData || {}; + options.dataStore = options.dataStore || []; + + callPreEvent(options, doBefore, function (options) { + showStartWindow(options, function () { + callPostEvent(options, doAfter, callback,type); + }); + }); +}; + +/** + * 鏄剧ず娴佺▼鐨勭獥鍙� + * @param options 鎸夐挳鐨勯厤缃俊鎭� + * @param callback 鍥炶皟 + */ +export const showStartWindow = (options,callback)=> { + const paramVOS = options.paramVOS; + // if (!paramVOS['form'] && !paramVOS['context']) { + // Vue.prototype.$message.error("鎸夐挳閰嶇疆涓嶆纭�"); + // return false; + // } + + const dialogConstructor = Vue.extend(uploadFileDialog); + let instance = new dialogConstructor(); + instance.sourceData = options.sourceData; + instance.dataStore = options.dataStore; + instance.paramVOS = paramVOS; + + instance.dialogClose = function () { + vm.visible = false; + document.body.removeChild(vm.$el); + instance.$destroy(); + instance = null; + }; + if (callback) { + instance.saveCallback = callback; + } + let vm = instance.$mount(); + document.body.appendChild(vm.$el); + instance.visible = true; + +} +/** + * 鍓嶇疆浜嬩欢 + * @param options 鎸夐挳鐨勯厤缃俊鎭� + * @param callback 鍥炶皟 + */ +export const doBefore = (options,callback)=> { + console.log("鎵ц澧炲姞鍓嶇疆浜嬩欢") + if(callback){ + callback(options); + } +} +/** + * 鍚庣疆浜嬩欢 + * @param options 鎸夐挳鐨勯厤缃俊鎭� + * @param callback 鍥炶皟 + */ +export const doAfter = (options,callback,actionType)=> { + console.log('鎵ц澧炲姞鍚庣疆浜嬩欢'); + if(callback){ + callback(actionType); + } +} diff --git a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js b/Source/plt-web/plt-web-ui/src/components/actions/handlers.js index ec54208..b3685d3 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js +++ b/Source/plt-web/plt-web-ui/src/components/actions/handlers.js @@ -31,6 +31,14 @@ launchworkflow: () => {import("@/components/actions/base/StartWorkflowAction").then(module => { module.doAction(options,callback); })}, + //涓婁紶鏂囦欢 + uploadfile: () => {import("@/components/actions/base/uploadFileAction").then(module => { + module.doAction(options,callback); + })}, + //涓婁紶鏂囦欢 + downloadfile: () => {import("@/components/actions/base/downloadFileAction").then(module => { + module.doAction(options,callback); + })}, }; if (handlers[type]) { handlers[type]() diff --git a/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-table.vue b/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-table.vue index 6dca0c5..9d71bfd 100644 --- a/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-table.vue +++ b/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-table.vue @@ -143,6 +143,8 @@ //琛ㄦ牸鏁版嵁 tableList: [], option: { + border:true, + stripe:true, index: true, addBtn: false, editBtn: false, diff --git a/Source/plt-web/plt-web-ui/src/directive/el-drag-dialog/dialogDrag.js b/Source/plt-web/plt-web-ui/src/directive/el-drag-dialog/dialogDrag.js new file mode 100644 index 0000000..a279b60 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/directive/el-drag-dialog/dialogDrag.js @@ -0,0 +1,51 @@ +import Vue from 'vue'; + +// v-dialogDrag: 寮圭獥鎷栨嫿 +Vue.directive('dialogDrag', { + bind(el) { + const dialogHeaderEl = el.querySelector('.el-dialog__header'); + const dragDom = el.querySelector('.el-dialog'); + dialogHeaderEl.style.cursor = 'move'; + + // 鑾峰彇鍘熸湁灞炴�� ie dom鍏冪礌.currentStyle 鐏嫄璋锋瓕 window.getComputedStyle(dom鍏冪礌, null); + const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null); + + dialogHeaderEl.onmousedown = (e) => { + // 榧犳爣鎸変笅锛岃绠楀綋鍓嶅厓绱犺窛绂诲彲瑙嗗尯鐨勮窛绂� + const disX = e.clientX - dialogHeaderEl.offsetLeft; + const disY = e.clientY - dialogHeaderEl.offsetTop; + + // 鑾峰彇鍒扮殑鍊煎甫px 姝e垯鍖归厤鏇挎崲 + let styL, styT; + + // 娉ㄦ剰鍦╥e涓� 绗竴娆¤幏鍙栧埌鐨勫�间负缁勪欢鑷甫50% 绉诲姩涔嬪悗璧嬪�间负px + if (sty.left.includes('%')) { + styL = +document.body.clientWidth * (+sty.left.replace(/%/g, '') / 100); + styT = +document.body.clientHeight * (+sty.top.replace(/%/g, '') / 100); + } else { + styL = +sty.left.replace(/\px/g, ''); + styT = +sty.top.replace(/\px/g, ''); + } + + document.onmousemove = function(e) { + // 閫氳繃浜嬩欢濮旀墭锛岃绠楃Щ鍔ㄧ殑璺濈 + const l = e.clientX - disX; + const t = e.clientY - disY; + + // 绉诲姩褰撳墠鍏冪礌 + dragDom.style.left = `${l + styL}px`; + dragDom.style.top = `${t + styT}px`; + + // 灏嗘鏃剁殑浣嶇疆浼犲嚭鍘� + // binding.value({x:e.pageX,y:e.pageY}) + }; + + document.onmouseup = function() { + document.onmousemove = null; + document.onmouseup = null; + }; + }; + } +}); + + diff --git a/Source/plt-web/plt-web-ui/src/main.js b/Source/plt-web/plt-web-ui/src/main.js index d05fcec..ddd3748 100644 --- a/Source/plt-web/plt-web-ui/src/main.js +++ b/Source/plt-web/plt-web-ui/src/main.js @@ -24,6 +24,8 @@ import website from '@/config/website'; import crudCommon from '@/mixins/crud'; import Divider from '@/components/Divider/index' +import '@/directive/el-drag-dialog/dialogDrag' + //琛ㄥ崟缁勪欢 import basicForm from "@/components/PLT-basic-component/basicForm"; // 涓氬姟缁勪欢 diff --git a/Source/plt-web/plt-web-ui/src/option/user/basic-option.js b/Source/plt-web/plt-web-ui/src/option/user/basic-option.js new file mode 100644 index 0000000..aa2feb4 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/option/user/basic-option.js @@ -0,0 +1,14 @@ +export default { + border:true, + height:'auto', + index:true, + dialogDrag:true, + searchShow:true, + searchIcon:true, + selection:true, + stripe:true, + // selection 鏄惁鏈夐�夋嫨妗� + // indexFixed:true/left/right, 鍥哄畾鍒� + // menu:false, 鏄惁鏈夋搷浣滄爮 + // menuTitle:xxx, 鎿嶄綔鏍忔爣棰� +} diff --git a/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue b/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue index 421eb65..7d11644 100644 --- a/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue +++ b/Source/plt-web/plt-web-ui/src/page/login/userlogin.vue @@ -74,7 +74,7 @@ //鐢ㄦ埛鍚� username: "admin", //瀵嗙爜 - password: "admin", + password: "", selectInput:'', //涓嬫媺input鏁版嵁 value:'绠$悊缁�', diff --git a/Source/plt-web/plt-web-ui/src/store/modules/user.js b/Source/plt-web/plt-web-ui/src/store/modules/user.js index cc12802..fbbaba8 100644 --- a/Source/plt-web/plt-web-ui/src/store/modules/user.js +++ b/Source/plt-web/plt-web-ui/src/store/modules/user.js @@ -65,6 +65,9 @@ loginByUsername(userInfo.deptId, userInfo.roleId, userInfo.username, userInfo.password, userInfo.type, userInfo.key,).then(res => { const data = res.data; if (data.code === 200) { + // commit('SET_TOKEN', data.obj.sessionInfo.token); + // commit('SET_REFRESH_TOKEN', data.obj.sessionInfo.token); + commit('SET_TOKEN', data.obj.tokenVO.accessToken); commit('SET_REFRESH_TOKEN', data.obj.tokenVO.accessToken); commit('DEL_ALL_TAG'); diff --git a/Source/plt-web/plt-web-ui/src/views/base/UIContentViewer.vue b/Source/plt-web/plt-web-ui/src/views/base/UIContentViewer.vue index 8279a53..93e2f7f 100644 --- a/Source/plt-web/plt-web-ui/src/views/base/UIContentViewer.vue +++ b/Source/plt-web/plt-web-ui/src/views/base/UIContentViewer.vue @@ -117,6 +117,7 @@ } }, created() { + console.log(this.$route); if (verifyNull(this.$route.query.type) || (verifyNull(this.$route.query.context) && verifyNull(this.$route.query.content))) { this.$message.error("閰嶇疆鐨勪俊鎭敊璇紝璇峰弬鑰冣��?type=xxx&context=yyy¶m=zzz鈥濊繖绉嶅舰寮忋�傚叾涓璽ype鏄笟鍔$被鍨嬶紙鎴栭摼鎺ョ被鍨嬶級锛宑ontext鏄疷I涓婁笅鏂囩殑鍚嶇О"); return false; diff --git a/Source/plt-web/plt-web-ui/src/views/user/userManage.vue b/Source/plt-web/plt-web-ui/src/views/user/userManage.vue new file mode 100644 index 0000000..7bda956 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/views/user/userManage.vue @@ -0,0 +1,137 @@ +<template> + <basic-container> + <avue-crud :data="data" + :option="option"> + </avue-crud> + </basic-container> +</template> + +<script> +import basicOption from '@/option/user/basic-option' +export default { + name: "userManage", + data() { + return { + data: [ + { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + }, + { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + }, + { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + }, { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + , { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + , { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + , { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + , { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + , { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + , { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + , { + id: 1, + name: '寮犱笁', + sex: '鐢�' + }, { + id: 2, + name: '鏉庡洓', + sex: '濂�' + } + ], + option: { + ...basicOption, + column: [ + { + label: '濮撳悕', + prop: 'name', + search:true + }, { + label: '鎬у埆', + prop: 'sex', + search:true + } + ] + } + } + } + +} +</script> + +<style scoped> + +</style> -- Gitblit v1.9.3