Browse Source

预览字符串处理

Luolei1992 5 years ago
parent
commit
db0dcb0947
4 changed files with 33 additions and 14 deletions
  1. 6 5
      src/common/MultiLineInput.vue
  2. 6 1
      src/components/AddContent.vue
  3. 10 5
      src/components/Preview.vue
  4. 11 3
      src/utils/tools.js

+ 6 - 5
src/common/MultiLineInput.vue

@@ -8,14 +8,14 @@
               class="contentVal" 
               :type="content.type=='number'?'tel':'text'" 
               :style="{'width':1/content.iptLis.length*100-3+'%'}" 
-              :key="item.placeholder+idx" 
+              :key="item.placeholder+idx"
               v-model="item.value"
               :placeholder="item.placeholder"
               @input="changeVal($event,idx,content.type)" 
               @blur="blur" 
               @click="handleClick">
             <input v-show="content.iptLis.length==1" class="contentVal" 
-              :type="content.type=='number'?'tel':'text'" 
+              :type="content.type=='number'?'tel':'text'"
               :placeholder="content.placeholder" 
               v-model="item.value" 
               @input="changeVal($event,idx,content.type)" 
@@ -29,7 +29,7 @@
   </div>
 </template>
 <script>
-import { getModelExpStr } from '@utils/tools';
+import {getModelExpStr} from '@utils/tools.js';
 
 export default {
   props:{
@@ -120,8 +120,8 @@ export default {
       // background-color: #fff;
       background: transparent;
       outline-color: invert;
-      height: .36rem;
-      line-height: .36rem;
+      height: .38rem;
+      line-height: .38rem;
       width: 100%;
       padding:0 0.1rem;
       box-sizing: border-box;
@@ -143,6 +143,7 @@ export default {
   .prefix {
     float: left;
     color: #666;
+    line-height: .72rem;
   }
   .suffix {
     position: absolute;

+ 6 - 1
src/components/AddContent.vue

@@ -4,6 +4,7 @@
       <ul class="addPart">
         <li v-for="(item,idx) in dataTrd">
           <p class="question">{{idx+1 + '. ' +(item.description||item.name)}}</p>
+          <img class="questionImg" :src="item.url.replace('{imageUrlPrefix}',imgUrl)" v-if="item.url">
           <Radio v-if="item.controlType==1" 
             :item="item"
             :key="item.id"
@@ -57,13 +58,14 @@ import MultiLineInput from '../common/MultiLineInput.vue';
 import Input from '../common/Input.vue';
 import Radio from '../common/Radio.vue';
 import CheckBox from '../common/CheckBox.vue';
-import {getAllStr} from '@utils/tools.js'
+import {imageUrlPrefix,getAllStr} from '@utils/tools.js';
 
 export default {
   name: 'AddContent',
   props: ['allMoudles','preName'],
   data() {
     return {
+      imgUrl:imageUrlPrefix,
       dataTrd: [],
       val: '',
       allStr:''
@@ -120,6 +122,9 @@ export default {
 </script>
 <style lang="less" scoped>
 @import "../less/base.less";
+.questionImg {
+  width: 100%;
+}
 .symp-wrap {
   font-size: 0.3rem;
   padding-right: .3rem;

+ 10 - 5
src/components/Preview.vue

@@ -47,8 +47,8 @@
           <p>{{addContent.txt}}</p>
         </li>
         <li v-if="JSON.stringify(diagnose.imgSrc) !='{}'">
-          <h4><i></i> 最近一次治疗报告:</h4>
-          <div v-for="(value,key) in diagnose.imgSrc" class="imgView">
+          <h4 class="imgTitle"><i></i> 最近一次治疗报告:</h4>
+          <div v-for="(value,key,idx) in diagnose.imgSrc" class="imgView" :style="{'margin-left':idx==0?0:''}">
             <img :src="value" alt="">
           </div>
         </li>
@@ -270,14 +270,19 @@ export default {
   overflow: auto;
 }
 .imgView {
-  width: 2.44rem;
-  height: 3.25rem;
+  width: 1.86rem;
+  height: 1.9rem;
   float: left;
-  margin: .3rem .2rem 0 0;
+  border: 1px solid #dfe0e4;
+  margin: 0 0 0.3rem 0.3rem;
+  box-sizing: border-box;
   img {
     width: 100%;
   }
 }
+.imgTitle {
+  padding-bottom: .20rem;
+}
 .personMsg {
   padding: 0.3rem 0.4rem;
   box-sizing: border-box;

+ 11 - 3
src/utils/tools.js

@@ -107,7 +107,7 @@ const getAllStr = (allData) =>{//获取界面数据,拼接字符串
   let allStr = '',data = allData.data;
   for(let i = 0;i < data.length;i++){
     if(data[i].controlType != 3&&data[i].value){
-        allStr += (data[i].value).replace('{','').replace('}','')+';'
+        allStr += (data[i].valueP).replace('{','').replace('}','')+';'
     }
     if(data[i].controlType == 3){//多列选择
       let tmpStr = '';
@@ -121,7 +121,7 @@ const getAllStr = (allData) =>{//获取界面数据,拼接字符串
       allStr+=tmpStr
     }
   }
-  return allStr;
+  return trimDots(allStr);
 }
 
 const moduleCP = {
@@ -209,6 +209,13 @@ function scrollToV(e){
   }, 400)
 }
 
+function trimDots(str){
+  console.log(str)
+  return str.replace(/[,,.。::"“??”;;、!!]+/g,function(word){
+    return word.substr(0,1);
+  }).replace(/^[,,.。::"“??”;;、!!\s]+/,'');
+}
+
 module.exports =  {
   imageUrlPrefix,
   getUrlArgObject,
@@ -220,7 +227,8 @@ module.exports =  {
   moduleCP,
   getExpStr,
   fixedKeyboard,
-  scrollToV
+  scrollToV,
+  trimDots
 }