zhouna 6 år sedan
förälder
incheckning
e2dd1536cc

+ 22 - 0
src/api/utils.js

@@ -146,5 +146,27 @@ export default {
       }
     }
     return tmpArr;
+  },
+  /**
+   * @
+   * **/
+  simpleOptionData(data){
+    const {options,defaultCheckeds,sameToNones,sameToBans} = data;
+    let defaultSelect = '0',code='';
+    let arr=[];
+    options.forEach((it,i)=>{
+      if(it){
+        defaultSelect = +defaultCheckeds[0]===i?'1':'0';
+        if(+sameToNones[0]===i){
+          code='2';
+        }
+        if(+sameToBans[0] === i){
+          code = '1';
+        }
+        arr.push({name:it,defaultSelect,code,remark:'单选'});
+      }
+    });
+    return arr;
   }
 }
+

+ 17 - 18
src/components/icss/AddIndeptLabel.vue

@@ -13,7 +13,7 @@
         ></PubIndeptTag>
         <div class="main">
             <p class="title"> <i>*</i> 标签明细:</p>
-            <SingleSelect></SingleSelect>
+            <SingleSelect v-if="dataPub.region2==1" :type="dataPub.region2" @pushValues="pushValues"></SingleSelect>
             <div class="btn">
                 <el-button
                         type="primary"
@@ -45,7 +45,7 @@
             { required: true, message: '选择标签成文顺序', trigger: 'change' }
           ]
         },
-        sendIds: [[], [], [], [], [], []],           //标签明细右侧操作数据
+        options: [],           //标签明细右侧操作数据
       }
     },
     computed: {
@@ -64,37 +64,36 @@
       back() { this.$router.go(-1) },
       changeVal(val) {    //子组件数据改变传递到父组件
         this.dataPub = val
-        console.log('公用组件传的值都在这', val)
+        //console.log('公用组件传的值都在这', val)
       },
       changeSex(sex) {       //性别改变,清空标签明细
-        console.log(sex)
+        //console.log(sex)
       },
       changeType(type) {        //填写单类型改变,标签明细左侧更新,右侧清空
-        console.log(type)
+        //console.log(type)
       },
-      changeActionData(arr) {          //标签明细右侧数据id
-        this.sendIds = arr
+      pushValues(its){
+        this.options = its;
       },
       submitForm() {       // 调用子组件的方法验证公用部分
         this.$refs.submitForm.submitForm('groups');
       },
       validatePass() {      //验证成功回调,调取接口
         //仍需验证标签明细是否选择
-        if (JSON.stringify(this.sendIds) == '[[],[],[],[],[],[]]') {
+        if ([0,1,2].includes(+this.dataPub.region2)&&this.options.length==0) {
           this.$message({
-            message: '请选择标签明细',
+            message: '至少填一个选项',
             type: 'warning'
           });
           return;
         }
 
-        let detailLis = utils.dataRecombination(this.sendIds, this.dataPub.region2)
         let param = {
           "questionWrapper": {
-            "controlType": 0,                            //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
+            "controlType": this.dataPub.region2,                            //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
             "id": "",                                    //新增id置空
             "type": this.dataPub.region1,                //标签归属
-            "tagType": this.dataPub.region2,             //标签类型
+            "tagType": 1,             //标签类型
             "tagName": this.dataPub.region3,             //系统名称
             "name": this.dataPub.region4,                //界面名称
             "joint": this.dataPub.region5,               //标签间的连接符
@@ -106,14 +105,14 @@
             "copyType": this.dataPub.region2 == 6 ? this.dataPub.region10 : (this.dataPub.region2 == 3 ? this.dataPub.region11 : ''),                               //是否复制
             "showAdd": 0,                                //是否显示加号血压
             "showInfo": 0,
-            "questionDetails": [],
-            "questionMappings": detailLis       //映射关系,
+            "questionDetails": this.options,
+            "questionMappings": []       //映射关系,
           }
-        }
-        // this.showDelDialog(param)
+        };console.log(param)
+        //this.showSaveDialog(param);
       },
-      showDelDialog(param) {
-        this.showConfirmDialog('是否保存该标签?', () => {
+      showSaveDialog(param) {
+        this.showConfirmDialog('是否保存该标签?', () => {
           api.saveOrUpdate(param).then((res) => {
             if (res.data.code === '0') {
               this.warning(res.data.msg || '保存成功', 'success')

+ 2 - 29
src/components/icss/PubIndeptTag.vue

@@ -245,19 +245,7 @@
     watch: {
       newSex(nextVal, prevVal) {
         this.tmpSex = prevVal;
-      },
-      newType(nextVal, prevVal) {
-        this.tmpOwn = prevVal;
-        if (nextVal != prevVal) {
-          this.searchTagList()
-        }
-      },
-      newSign(nextVal, prevVal) {
-        this.tmpType = prevVal;
-        if (nextVal != prevVal && JSON.stringify(this.form.tagPool) != '[]' ) {
-          this.searchTagList()
-        }
-      },
+      }
     },
     methods: {
       getDropList() {
@@ -270,20 +258,6 @@
           }
         })
       },
-      searchTagList() {
-        let region1 = this.form.region1, region2 = this.form.region2;
-        let param = {
-          "type": region1,
-          "tagType": region2 == 2?[1]:(region2 == 6?[1,2,3,4,10]:[]),
-          "controlType":region2 == 2?[1,2]:[],
-          "sexType": this.form.region7,
-        }
-        api.searchTagList(param).then((res) => {
-          if (res.data.code === '0') {
-            this.form.tagPool = res.data.data
-          }
-        })
-      },
       validateSystomName(name,callback) {
         if(this.form.region3.trim() == ''){ return }
         let param = {
@@ -310,10 +284,9 @@
       changeSex(data) {   //改变性别清空数据
         this.$emit('changeVal', this.form, false);
         this.$emit('changeSex', data, false);
-        this.searchTagList()
       },
       readyChangeSelect(tmpData,type) {
-        console.log(tmpData)
+        //console.log(tmpData)
         this.changeSex(tmpData);
       },
       submitForm(formName) {

+ 132 - 15
src/components/icss/SingleSelect.vue

@@ -1,23 +1,48 @@
 <template>
     <div class="single-container">
-        <el-form>
+        <el-form :model="form">
             <div class="operation-row">
-                <el-button size="small">默认选中</el-button>
-                <el-button size="small">同“无”类型</el-button>
-                <el-button size="small">同“伴”类型</el-button>
-                <el-button type="danger" size="small" class="del">删除</el-button>
+                <el-checkbox-group size="small" v-model="form.defaultCheckeds" @change="emitValues">
+                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :label="i">默认选中</el-checkbox-button>
+                </el-checkbox-group>
+                <el-checkbox-group size="small" v-model="form.sameToNones" @change="emitValues">
+                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :label="i">同“无”类型</el-checkbox-button>
+                </el-checkbox-group>
+                <el-checkbox-group size="small" v-model="form.sameToBans" @change="emitValues">
+                    <el-checkbox-button v-for="(it,i) in rows" v-if="focusOn==i||(focusOn==-1&&i==0)" :label="i">同“伴”类型</el-checkbox-button>
+                </el-checkbox-group>
+                <el-button type="danger" size="small" class="del" @click="delRow">删除</el-button>
             </div>
             <div class="main-area">
-                <el-input></el-input>
-                <el-input></el-input>
-                <el-input></el-input>
-                <el-input></el-input>
-                <el-button>+</el-button>
+                <el-input v-for="(it,i) in rows"
+                          v-model="form.options[i]"
+                          v-bind:class="{select:focusOn==i}"
+                          @focus="selectRow(i)"
+                          @blur="emitValues"></el-input>
+                <el-button @click="addRow">+</el-button>
             </div>
         </el-form>
     </div>
 </template>
 <style lang="less">
+    @import "../../less/common.less";
+    .el-checkbox-button--small .el-checkbox-button__inner{
+        font-size: 14px;
+    }
+    .el-checkbox-button:last-child .el-checkbox-button__inner{
+        border-radius: 3px;
+        border-color: @adminBase;
+        color: @adminBase;
+        margin-right: 15px;
+    }
+    .el-checkbox-button.is-checked:first-child .el-checkbox-button__inner{
+        background-color:@adminBase;
+        border-left-color:@adminBase;
+        color:#fff;
+    }
+    .el-checkbox-group{
+        display: inline-block;
+    }
     .operation-row{
         margin-left:150px;
         .del{
@@ -30,6 +55,11 @@
         .el-input {
             width: 200px;
             display: block;
+            &.select{
+                input{
+                    border-color: @adminBase;
+                }
+            }
         }
         .el-button{
             width: 200px;
@@ -37,15 +67,102 @@
     }
 </style>
 <script>
+    import utils from '@api/utils';
     export default {
-      props:{
-
-      },
-      data:()=>{
-        return {}
+      props:['type'],
+      data(){
+        return {
+          form:{
+            options:[],
+            defaultCheckeds:[],
+            sameToNones:[],
+            sameToBans:[]
+          },
+          rows:[{},{},{},{}],
+          focusOn:-1
+        }
       },
+      /*watch:{
+        defaultChecked:function(next){
+          if(this.focusOn==-1){
+            this.defaultChecked = false;
+            this.$message({
+              message: '请先选择要操作的行',
+              type: 'warning'
+            });
+            return;
+          }
+          this.form.defaultChecked=next?this.focusOn:-1;console.log(this.form)
+          this.emitValues();
+        },
+        sameToNone:function(next){
+          if(this.focusOn==-1){
+            this.sameToNone = false;
+            this.$message({
+              message: '请先选择要操作的行',
+              type: 'warning'
+            });
+            return;
+          }
+          this.form.sameToNone=next?this.focusOn:-1;
+          this.emitValues();
+        },
+        sameToBan:function(next){
+          if(this.focusOn==-1){
+            this.sameToBan = false;
+            this.$message({
+              message: '请先选择要操作的行',
+              type: 'warning'
+            });
+            return;
+          }
+          this.form.sameToBan=next?this.focusOn:-1;
+          this.emitValues();
+        }
+      },*/
       methods:{
+        setValues(name){
+          if(this.focusOn==-1){
+            this[name] = false;
+            this.$message({
+              message: '请先选择要操作的行',
+              type: 'warning'
+            });
+            return;
+          }
+          this.form[name]=this[name]?this.focusOn:-1;
+          this.emitValues();
+        },
+        addRow(){
+          this.rows.push({});
+        },
+        selectRow(index){
+          this.focusOn = index;
 
+        },
+        emitValues(){
+          //console.log(this.form)
+          const items = utils.simpleOptionData(this.form);
+          //this.$emit('pushValues',items);
+        },
+        delRow(){
+          if(this.focusOn==-1){
+            this.$message({
+              message: '请先选择要删除的行',
+              type: 'warning'
+            });
+            return;
+          }
+          this.$alert('确定要删除该行吗?', '提示', {
+            confirmButtonText: '确定',
+            type: 'warning'
+          }).then(() => {
+            this.form.options.splice(this.focusOn,1);
+            this.rows.splice(this.focusOn,1);
+            this.focusOn = -1;
+            this.emitValues();
+          }).catch(() => {});
+        }
       }
     }
 </script>