瀏覽代碼

Merge branch 'master' of http://192.168.4.246:3000/zhangs/surveyMaker

曹冬冬 5 年之前
父節點
當前提交
1e0287b748
共有 3 個文件被更改,包括 87 次插入25 次删除
  1. 81 23
      src/components/EditPanel.vue
  2. 5 2
      src/components/Element/ButtonElement.vue
  3. 1 0
      src/model/Element.js

+ 81 - 23
src/components/EditPanel.vue

@@ -54,19 +54,27 @@
             <span style="font-size:14px;
             font-family:MicrosoftYaHei;
             color:rgba(100,107,129,1);
-            margin-bottom: 16px;
             line-height:19px;">
               {{element.imgSrc|currentImageName}}
             </span>
-            <div style="width:108px;
-            height:28px;
-            background:rgba(78,93,255,1);
-            border-radius:14px;font-size:14px;
-            font-family:MicrosoftYaHei;
-            color:rgba(255,255,255,1);
-            display: flex;
-            justify-content: center;
-            line-height:28px;">替换元素</div>
+
+            <label style="display: block;
+            cursor: pointer; width:108px; position: relative;
+            margin-bottom: 12px;
+              height:28px;">
+              <div style="width:108px;
+              height:28px;
+              background:rgba(78,93,255,1);
+              border-radius:14px;font-size:14px;
+              font-family:MicrosoftYaHei;
+              color:rgba(255,255,255,1);
+              display: flex;
+              justify-content: center;
+              line-height:28px;">替换元素
+              </div>
+              <input style="display: none;position: absolute;top: 0px;" type="file" @change="fileChange"
+                multiple="false">
+            </label>
           </div>
         </div>
         <div style="vertical-align: middle;display: flex;flex-direction: column;border-bottom: #E2E4EE solid 1px">
@@ -301,19 +309,25 @@
               <span style="font-size:14px;
               font-family:MicrosoftYaHei;
               color:rgba(100,107,129,1);
-              margin-bottom: 16px;
               line-height:19px;">
                 {{element.imgSrc|currentImageName}}
               </span>
-              <div style="width:108px;
-              height:28px;
-              background:rgba(78,93,255,1);
-              border-radius:14px;font-size:14px;
-              font-family:MicrosoftYaHei;
-              color:rgba(255,255,255,1);
-              display: flex;
-              justify-content: center;
-              line-height:28px;">替换元素</div>
+              <label style="display: block;margin-bottom: 12px;
+              cursor: pointer; width:108px;position: relative;
+                height:28px;">
+                <div style="width:108px;
+                height:28px;
+                background:rgba(78,93,255,1);
+                border-radius:14px;font-size:14px;
+                font-family:MicrosoftYaHei;
+                color:rgba(255,255,255,1);
+                display: flex;
+                justify-content: center;
+                line-height:28px;">替换元素
+                </div>
+                <input style="display: none;position: absolute;top: 0px;" type="file" @change="fileChange"
+                  multiple="false">
+              </label>
             </div>
           </div>
 
@@ -330,7 +344,8 @@
             text-align: center;
             justify-content: center;
             line-height: 24px;
-            color:rgba(255,255,255,1);" @click="setGroup(element)">{{element.children.length>0?'解组':'组合'}}</div>
+            color:rgba(255,255,255,1);" @click="setGroup(element)">
+              {{element.children!=null?(element.children.length>0?'解组':'组合'):'组合'}}</div>
           </div>
 
         </div>
@@ -531,7 +546,7 @@
         <div style="margin-bottom: 12px;">
           <span
             style="font-size:12px;font-family:MicrosoftYaHei;color:rgba(51,51,51,1);line-height:16px; margin-left: 20px;">相对固定</span>
-          <el-switch v-model="value" active-color="#4E5DFF" inactive-color="#D7E2FF">
+          <el-switch v-model="element.isFixed" active-color="#4E5DFF" inactive-color="#D7E2FF">
           </el-switch>
         </div>
       </div>
@@ -694,7 +709,7 @@
 
 <script>
 
-
+  import * as http from '../util/http'
   var positionFlag = false
   export default {
     props: {
@@ -1036,6 +1051,49 @@
           that.$message.error("组合失败!")
         }
       },
+      fileChange(event) {
+        console.log("当前元素", this.element);
+        this.upload(event)
+      },
+      async upload(event) {
+        var that = this;
+        let files = event.target.files
+        if (!files.length) {
+          return false
+        }
+
+        const loading = this.$loading({
+          lock: true,
+          text: 'Loading',
+          spinner: 'el-icon-loading',
+          background: 'rgba(0, 0, 0, 0.7)'
+        });
+        for (var i = 0; i < files.length; i++) {
+          var file = files[i]
+          if (file) {
+            http.uploadMaterielFile(file, function (res) {
+              loading.close();
+              let img = document.createElement('img')
+              img.onload = () => {
+                that.$emit('uploaded', {
+                  'filePath': res,
+                  'width': img.width,
+                  'height': img.height,
+                  'isButton': that.isButton,
+                });
+                that.element.imgSrc = res;
+                that.element.width = img.width;
+                that.element.height = img.height;
+              }
+              img.src = res;
+            }, function (res) {
+              if (res.total.percent == 100 && (files.length == i + 1)) {
+                loading.close();
+              }
+            })
+          }
+        }
+      },
     },
     computed: {
       elements() {

+ 5 - 2
src/components/Element/ButtonElement.vue

@@ -59,8 +59,10 @@
       stopEvent: {
         type: Boolean
       },
-      type: ''
+      type: '',
+      isOverView:Boolean
     },
+    
     data() {
       return {
         left: 0,
@@ -334,7 +336,8 @@
   .content {
     /*white-space: pre-wrap;*/
     word-wrap: break-word;
-    position: relative;
+    position: absolute;
+    top: 0;
     z-index: 3;
   }
 

+ 1 - 0
src/model/Element.js

@@ -55,5 +55,6 @@ export default class Element {
     this.animatedFont = ele.animatedFont || ''
     this.eleCanvas = ele.eleCanvas || ''
     this.swiperType = ele.swiperType || 'mtswiper'
+    this.isFixed = ele.isFixed || false
   }
 }