ysy пре 1 година
родитељ
комит
b986c66a03
4 измењених фајлова са 46 додато и 10 уклоњено
  1. 7 6
      src/main.js
  2. 35 0
      src/utils/clickOnce.js
  3. 1 3
      src/utils/file.js
  4. 3 1
      src/views/workOrder/index.vue

+ 7 - 6
src/main.js

@@ -16,7 +16,9 @@ import authSelection from '@/components/authSelection';
 Vue.component('HeaderTitle', HeaderTitle);
 Vue.component('authSelection', authSelection);
 
-
+import clickOnce from './utils/clickOnce.js';
+// 注册全局自定义指令
+Vue.directive('click-once', clickOnce);
 
 // bpmnProcessDesigner 需要引入
 import MyPD from '@/components/bpmnProcessDesigner/package/index.js';
@@ -27,7 +29,6 @@ import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css';
 import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css';
 import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css';
 
-
 // // register globally
 import '@/icons';
 Vue.component('DictSelection', DictSelection);
@@ -45,7 +46,7 @@ Vue.use(permission);
 Vue.use(VueClipboard);
 let instance = null;
 
-function render (props = {}) {
+function render(props = {}) {
   const { container, routerBase } = props;
   // const router = new VueRouter({
   //   base: window.__POWERED_BY_QIANKUN__ ? routerBase : process.env.BASE_URL,
@@ -66,11 +67,11 @@ if (!window.__POWERED_BY_QIANKUN__) {
   render();
 }
 
-export async function bootstrap () {
+export async function bootstrap() {
   console.log('[vue] vue app bootstraped');
 }
 
-export async function mount (props) {
+export async function mount(props) {
   console.log('[vue] props from main framework', props);
   Vue.prototype.$portalStore = props.store;
 
@@ -83,7 +84,7 @@ export async function mount (props) {
   render(props);
 }
 
-export async function unmount () {
+export async function unmount() {
   instance.$destroy();
   instance.$el.innerHTML = '';
   instance = null;

+ 35 - 0
src/utils/clickOnce.js

@@ -0,0 +1,35 @@
+export default {
+  bind(el, binding, vnode) {
+    // 创建加载指示器元素
+    const loadingIndicator = document.createElement('i');
+    loadingIndicator.classList.add('loading-indicator', 'el-icon-loading'); // 假设使用 Element UI 的加载图标
+    el.appendChild(loadingIndicator);
+
+    // 隐藏加载指示器,默认不显示
+    loadingIndicator.style.display = 'none';
+
+    // 保存加载指示器引用
+    el._loadingIndicator = loadingIndicator;
+
+    // 添加点击事件监听器
+    el.addEventListener('click', () => {
+      // 显示加载指示器
+      loadingIndicator.style.display = 'inline-block';
+
+      // 禁用按钮
+      el.setAttribute('disabled', '');
+
+      // 假设这里有一个异步操作,完成后需要隐藏加载指示器和重新启用按钮
+      setTimeout(() => {
+        loadingIndicator.style.display = 'none';
+        el.removeAttribute('disabled'); // 重新启用按钮
+      }, 2000); // 模拟异步操作耗时2秒
+    });
+
+    // 清理事件监听器,防止内存泄漏
+    vnode.context.$once('hook:beforeDestroy', () => {
+      el.removeEventListener('click', () => {});
+      el.removeChild(loadingIndicator);
+    });
+  }
+};

+ 1 - 3
src/utils/file.js

@@ -1,5 +1,3 @@
-
-
 // 获取图片反显url
 export function getImageUrl(path) {
   return `${sessionStorage.filePath}${path}`;
@@ -24,7 +22,7 @@ export function getImagePath(url) {
 
 // 下载方法
 
-export function download (data, name) {
+export function download(data, name) {
   const a = document.createElement('a');
   const url = window.URL.createObjectURL(data);
   const filename = name;

+ 3 - 1
src/views/workOrder/index.vue

@@ -97,7 +97,7 @@
       
       <div class="footer" slot="footer">
           <el-button @click="visible = false">取消</el-button>
-          <el-button type="primary" @click="confirm">确定</el-button>
+          <el-button type="primary" v-click-once @click="confirm">确定</el-button>
         </div>
     </el-dialog>
   </div>
@@ -338,6 +338,8 @@
       },
       // 下达
       confirm() {
+        console.log(111)
+        return false;
         const loading = this.$loading({ text: '加载中...' });
         releaseWorkOrder({
           id: this.current.id,