Browse Source

Merge branch 'dev' of http://1.116.113.26:8088/zhuliu/RMS-FrontEnd into dev

zhuhao 2 năm trước cách đây
mục cha
commit
07cba0584a

+ 3 - 0
RMS-FrontEnd/src/main.js

@@ -22,6 +22,9 @@ import lodash from 'lodash'
 import {hasPermission} from './directives/permission';
 Vue.prototype.$permission = hasPermission
 
+import directive from './utils/directives'
+Vue.use(directive)
+
 import {reportPermission} from '@/utils/reportPermission'
 // import Directives from './directives/index'
 // Vue.use(Directives)

+ 25 - 0
RMS-FrontEnd/src/utils/directives.js

@@ -0,0 +1,25 @@
+// 引入拖拽js
+import { startDrag } from './drag.js'
+ 
+/**
+ * 为el-dialog弹框增加拖拽功能
+ * @param {*} el 指定dom
+ * @param {*} binding 绑定对象
+ * desc   只要用到了el-dialog的组件,都可以通过增加v-draggable属性变为可拖拽的弹框
+ */
+const draggable = (el, binding) => {
+    // 绑定拖拽事件 [绑定拖拽触发元素为弹框头部、拖拽移动元素为整个弹框]
+    startDrag(el.querySelector('.el-dialog__header'), el.querySelector('.el-dialog'), binding.value);
+};
+ 
+const directives = {
+    draggable,
+};
+// 这种写法可以批量注册指令
+export default {
+  install(Vue) {
+      Object.keys(directives).forEach((key) => {
+      Vue.directive(key, directives[key]);
+    });
+  },
+};

+ 100 - 0
RMS-FrontEnd/src/utils/drag.js

@@ -0,0 +1,100 @@
+
+ export function startDrag(bar, target, callback) {
+    var params = {
+      top: 0,
+      left: 0,
+      currentX: 0,
+      currentY: 0,
+      flag: false,
+      cWidth: 0,
+      cHeight: 0,
+      tWidth: 0,
+      tHeight: 0
+    };
+   
+    // 给拖动块添加样式
+    bar.style.cursor = 'move';
+   
+    // 获取相关CSS属性
+    // o是移动对象
+    // var getCss = function (o, key) {
+    //   return o.currentStyle ? o.currentStyle[key] :             document.defaultView.getComputedStyle(o, false)[key];
+    // };
+   
+    bar.onmousedown = function (event) {
+      // 按下时初始化params
+      var e = event ? event : window.event;
+      params = {
+        top: target.offsetTop,
+        left: target.offsetLeft,
+        currentX: e.clientX,
+        currentY: e.clientY,
+        flag: true,
+        cWidth: document.body.clientWidth,
+        cHeight: document.body.clientHeight,
+        tWidth: target.offsetWidth,
+        tHeight: target.offsetHeight
+      };
+   
+      // 给被拖动块初始化样式
+      target.style.margin = 0;
+      target.style.top = params.top + 'px';
+      target.style.left = params.left + 'px';
+   
+      if (!event) {
+        // 防止IE文字选中
+        bar.onselectstart = function () {
+          return false;
+        }
+      }
+   
+      document.onmousemove = function (event) {
+        // 防止文字选中
+        window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
+   
+        var e = event ? event : window.event;
+        if (params.flag) {
+          var nowX = e.clientX;
+          var nowY = e.clientY;
+          // 差异距离
+          var disX = nowX - params.currentX;
+          var disY = nowY - params.currentY;
+          // 最终移动位置
+          var zLeft = 0;
+          var zTop = 0;
+   
+          zLeft = parseInt(params.left) + disX;
+          // 限制X轴范围
+          if (zLeft <= -parseInt(params.tWidth / 2)) {
+            zLeft = -parseInt(params.tWidth / 2);
+          }
+          if (zLeft >= params.cWidth - parseInt(params.tWidth * 0.5)) {
+            zLeft = params.cWidth - parseInt(params.tWidth * 0.5);
+          }
+   
+          zTop = parseInt(params.top) + disY;
+          // 限制Y轴范围
+          if (zTop <= 0) {
+            zTop = 0;
+          }
+          if (zTop >= params.cHeight - parseInt(params.tHeight * 0.5)) {
+            zTop = params.cHeight - parseInt(params.tHeight * 0.5);
+          }
+   
+          // 执行移动
+          target.style.left = zLeft + 'px';
+          target.style.top = zTop + 'px';
+        }
+   
+        if (typeof callback == "function") {
+          callback(zLeft, zTop);
+        }
+      }
+   
+      document.onmouseup = function () {
+        params.flag = false;
+        document.onmousemove = null;
+        document.onmouseup = null;
+      };
+    };
+  }

+ 1 - 1
RMS-FrontEnd/src/views/components/articles/index.vue

@@ -108,7 +108,7 @@
    
   </el-container>
 
-  <el-dialog title="添加对比" :visible.sync="visible" width="1000px" :before-close="close">
+  <el-dialog title="添加对比" v-draggable :visible.sync="visible" width="1000px" :before-close="close">
     <el-form :model="ruleForm" ref="ruleForm" label-width="100px" label-position="left">
        
        <el-form-item label="选中文本" class="item">

+ 3 - 3
RMS-FrontEnd/src/views/report/components/CreateReport.vue

@@ -652,9 +652,9 @@ export default {
       if(dictMessage){
         this.dictMessage.REPORT_TYPE = dictMessage
       }
-      if(row.track && this.form.status == 3){
-        this.changeStatus(3)
-      }
+      // if(row.track && this.form.status == 3){
+        this.changeStatus(this.form.status)
+      // }
       var reportType = this.dictMessage.REPORT_TYPE.filter(item=>{return item.dictChildValue == this.form.type})[0].dictChildLabel
       this.title = a + reportType + '报告'
       if(row.track){