浏览代码

独立单选类型添加

zhouna 6 年之前
父节点
当前提交
7bfe169f5b
共有 5 个文件被更改,包括 50 次插入44 次删除
  1. 1 0
      src/api/config.js
  2. 3 0
      src/api/preTreat.js
  3. 16 1
      src/api/utils.js
  4. 29 42
      src/components/preTreat/PubSelect.vue
  5. 1 1
      src/components/preTreat/SimpleQuestion.vue

+ 1 - 0
src/api/config.js

@@ -220,6 +220,7 @@ export default {
     'questionDel':'/api/precman/questionInfo_prec/delete',      //删除
     'uploadImg':'/api/precman/file_prec/uploadImage',       //图片上传
     'fileDel':'/api/precman/file_prec/deleteRemoteFile',          //图片删除
+    'questionDetail':'/api/precman/questionInfo_prec/getById',                //填写单详情
   },
 	menuIconList: { //菜单对应图标
 		'YH-KZT': 'el-icon-menu',

+ 3 - 0
src/api/preTreat.js

@@ -18,6 +18,9 @@ export default {
   questionDel(param){
     return axios.post(urls.questionDel,param);
   },
+  questionDetail(param){
+    return axios.post(urls.questionDetail,param);
+  },
   fileDel(param){
     return axios.post(urls.fileDel,param);
   }

+ 16 - 1
src/api/utils.js

@@ -239,6 +239,21 @@ export default {
       tmpArr.push(obj)
     }
     return tmpArr;
-  }
+  },
+  /*返回n个row的数组
+  *n:Number
+  * row:Object
+  * orderName:编号字段名称,默认orderNo
+   */
+  getInitRow(row,n,orderName){
+    let arr = [];
+    let obj = {};
+    for(let i=0;i<n;i++){
+      obj = Object.assign({},row);
+      obj[orderName||'orderNo'] = i;
+      arr.push(obj);
+    }
+    return arr;
+  },
 }
 

+ 29 - 42
src/components/preTreat/PubSelect.vue

@@ -8,7 +8,7 @@
                 <el-checkbox-group size="small"  v-if="type==2">
                     <el-checkbox-button :label="0">数字输入框占位符</el-checkbox-button>
                 </el-checkbox-group>
-                <el-checkbox-group size="small">
+                <el-checkbox-group size="small" v-if="type==1&&ascription!=1">
                     <el-checkbox-button :label="0">互斥项</el-checkbox-button>
                 </el-checkbox-group>
                 <span v-if="type == 11" class="tip">可输入中文全角括号"()", 当作可输入内容的占位符</span>
@@ -26,16 +26,16 @@
                                   v-bind:class="{select:focusOn==i}"
                                   @focus="selectRow(i)"
                                   ref = "inputName"
-                                  @input="HandleInputName(i, rows[i].name)"
+                                  @input="HandleInputName(i, rows[i].name,true)"
                                   @blur="emitValues"></el-input>
                         <el-input v-model="rows[i].description"
                                   v-bind:class="{select:focusOn==i}"
                                   @focus="selectRow(i)"
-                                  ref = "inputName"
-                                  @input="HandleInputName(i, rows[i].name)"
+                                  ref = "inputDesc"
+                                  @input="HandleInputName(i, rows[i].description)"
                                   @blur="emitValues"></el-input>
                      </div>
-                    <el-tag v-if="it.isExclu" type="info" size="mini">互斥项</el-tag>
+                    <el-tag v-if="it.isExclu" type="info" size="mini" @click="">互斥项</el-tag>
                 </el-col>
                 <el-button @click="addRow">+</el-button>
             </div>
@@ -68,6 +68,7 @@
     }
     .operation-row{
         margin-left:150px;
+        text-align: right;
     .del{
         margin-left: 150px;
     }
@@ -119,25 +120,29 @@
 <script>
   import utils from '@api/utils.js';
   import Vue from 'vue';
+
+  //单行数据
+  const initRow = {orderNo:0,name:'',description:'',exclusion:0};
+  const initRows = utils.getInitRow(initRow,4);
   export default {
     props:['type','options','ascription','sexType'],
     data(){
       return {
         //maps:{isBan:'同“伴”',isNone:'同“无”',defaultSelect:'默认选中',isError:'异常选项'},
-        rows:new Array(4).fill({name:'',description:'',isExclu:false}),
-        focusOn:-1
+        rows:[...initRows],
+        focusOn:-1,         //聚焦的行index
       }
     },
     mounted(){
       const {options} = this.$props;
       if(options){
         const arr = options.map((it)=>{
-          return {name:it.name,defaultSelect:it.defaultSelect=='1'?true:false,isBan:it.code==1?true:'',isNone:it.code==2?true:'',isError:it.abnormal==1?true:''};
+          return {name:it.name,description:'',isExclu:false};
         });
         const arrLen = arr.length;
         if(arrLen < 4) {
           for (let i = 0; i < 4 - arrLen; i++) {
-            arr.push({name:'',defaultSelect:'',isBan:'',isNone:'',isError:''})
+            arr.push(utils.getInitRow(initRow,1))
           }
         }
         this.rows = arr;
@@ -154,57 +159,33 @@
           return this.maps[name];
         }
       },
-      hasDefault:function(){               //是否有选项默认选中
-        let index =this.rows.findIndex((it)=>{
-          return it.defaultSelect;
-        });
-        return index;
-      },
-      hasNone:function(){                 //是否有选项同无
-        let index =this.rows.findIndex((it)=>{
-          return it.isNone;
-        });
-        return index;
-      },
-      hasBan:function(){                  //是否有选项同伴
-        let index =this.rows.findIndex((it)=>{
-          return it.isBan;
-        });
-        return index;
-      },
-      hasError:function(){        //是否为正确选项
-        let index =this.rows.findIndex((it)=>{
-          return it.isError;
-        });
-        return index;
-      }
     },
     watch: {
       ascription(newVal, preVal) {
         if (newVal != preVal) {
           if (JSON.stringify(newVal) != JSON.stringify(preVal)) {
-            this.rows = [{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''}];
+            this.rows = [...initRows];
           }
         }
       },
       type(newVal, preVal) {
         if (newVal != preVal) {
           if (JSON.stringify(newVal) != JSON.stringify(preVal)) {
-            this.rows = [{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''}];
+            this.rows = [...initRows];
           }
         }
       },
       sexType(newVal, preVal) {
         if (newVal != preVal) {
           if (JSON.stringify(newVal) != JSON.stringify(preVal)) {
-            this.rows = [{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''},{name:'',defaultSelect:'',isBan:'',isNone:'',isError:''}];
+            this.rows = [...initRows];
           }
         }
       },
     },
     methods:{
       addRow(){
-        this.rows.push({name:'',defaultSelect:'',isBan:'',isNone:'',isError:''});
+        this.rows.push(utils.getInitRow(initRow,1));
       },
       selectRow(index){
         this.focusOn = index;
@@ -219,19 +200,25 @@
           });
           return;
         }
-        const items = utils.simpleOptionData(this.rows);
+        const items = this.rows;
         this.$emit('pushValues',items);
       },
-      HandleInputName(i, name) {
+      HandleInputName(i, name, isName) {
         if(name.length > 30) {
-          Vue.set(this.rows[i], 'name', this.rows[i].name.slice(0, 30))
-          this.$refs.inputName[i].currentValue = this.rows[i].name
+          if(isName){
+            Vue.set(this.rows[i], 'name', this.rows[i].name.slice(0, 30));
+            this.$refs.inputName[i].currentValue = this.rows[i].name;
+          }else{
+            Vue.set(this.rows[i], 'description', this.rows[i].description.slice(0, 30));
+            this.$refs.inputDesc[i].currentValue = this.rows[i].description;
+          }
+
           this.$message({
             message: '最多输入30个字',
             type: 'warning',
             showClose: true,
           });
-          return
+          return;
         }
 
       },

+ 1 - 1
src/components/preTreat/SimpleQuestion.vue

@@ -155,7 +155,7 @@
         this.$router.push({path:'LT-YWZSJWH-TJDLTXD'})
       },
       modifyIndeptTag(row) {
-        api.detailsTag({id:row.id}).then((res)=>{
+        api.questionDetail({id:row.id}).then((res)=>{
           const {code,data,msg} = res.data;
           if(code=='0'){
             const item = Object.assign({},row,data);