morphone1995 4 vuotta sitten
vanhempi
commit
326451502e
2 muutettua tiedostoa jossa 151 lisäystä ja 79 poistoa
  1. 1 1
      src/components/icss/bill/AddBill.vue
  2. 150 78
      src/components/icss/bill/ConditionForm1.vue

+ 1 - 1
src/components/icss/bill/AddBill.vue

@@ -120,7 +120,7 @@ export default {
     return {
       form: {
         ruleName: '',
-        ruleType: 2,
+        ruleType: '',
         conceptType: '',
         conceptName: '',
         concept: {

+ 150 - 78
src/components/icss/bill/ConditionForm1.vue

@@ -1,6 +1,7 @@
 <template>
   <el-row>
-    <el-col :span="8">
+    <!-- 文本类型 -->
+    <el-col :span="24" v-if="ruleType == 1">
       <el-form
         :model="form"
         ref="form"
@@ -8,8 +9,7 @@
         :validate-on-rule-change="false"
         :rules="rules"
       >
-        <!-- 文本类型 -->
-        <el-form-item label="条件明细" label-width="80px" v-if="ruleType==1" prop="condition">
+        <el-form-item label="条件明细" label-width="80px" prop="condition">
           <el-select
             style="width:100%;minWidth: 240px"
             v-model="form.name"
@@ -34,87 +34,120 @@
             ></el-option>
           </el-select>
         </el-form-item>
-
-        <el-row v-if="ruleType==2">
-          <el-form-item label="条件明细" label-width="80px" v-if="ruleType==2" prop="condition">
-            <el-select
-              style="width:100%"
-              v-model="form.name"
-              filterable
-              remote
-              clearable
-              :loading="showDrop"
-              loading-text="加载中..."
-              @change="changeWord"
-              @visible-change="handleVisible"
-              placeholder="搜索开单项目"
-              :remote-method="searchCondition"
-              reserve-keyword
-              ref="conditionListName"
-            >
-              <el-option
-                v-for="item in conditionList"
-                :key="item.id + item.name"
-                :label="item.name"
-                :value="item.name"
-                :title="item.name"
-              ></el-option>
-            </el-select>
-          </el-form-item>
-          <el-form-item label label-width="0px" v-if="ruleType==2&&isOpen">
-            <span class="font">1</span>
-          </el-form-item>
-        </el-row>
       </el-form>
     </el-col>
-    <el-form :rules="rules1" ref="ruleForm" :model="ruleForm">
-      <el-col :span="16" v-for="(item,index) in ruleForm.ruleForm" :key="index">
-        <el-row>
-          <el-col :span="8">
-            <el-form-item label-width="0px" prop="compare">
+    <el-col :span="24" v-if="ruleType == 2">
+      <el-col :span="8">
+        <el-form
+          :model="form"
+          ref="form"
+          class="sub-form"
+          :validate-on-rule-change="false"
+          :rules="rules"
+        >
+          <el-row>
+            <el-form-item label="条件明细" label-width="80px" prop="condition">
               <el-select
-                v-model="item.compare"
-                placeholder="请输入比较"
-                style="width: 100%"
-                ref="compare"
+                style="width:100%"
+                v-model="form.name"
+                filterable
+                remote
+                clearable
+                :loading="showDrop"
+                loading-text="加载中..."
+                @change="changeWord"
+                @visible-change="handleVisible"
+                placeholder="搜索开单项目"
+                :remote-method="searchCondition"
+                reserve-keyword
+                ref="conditionListName"
               >
-                <el-option label="大于" value=">"></el-option>
-                <el-option label="大于等于" value=">="></el-option>
-                <el-option label="小于" value="<"></el-option>
-                <el-option label="小于等于" value="<="></el-option>
+                <el-option
+                  v-for="item in conditionList"
+                  :key="item.id + item.name"
+                  :label="item.name"
+                  :value="item.name"
+                  :title="item.name"
+                ></el-option>
               </el-select>
             </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label-width="0px" :prop="index===0?'amount0':'amount1'">
-              <el-input
-                v-model="item.value"
-                placeholder="填写数值"
-                @blur="handleValue('value',index)"
-                :disabled="item.compare ==''"
-                :ref="index===0?'amount0':'amount1'"
-              ></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8">
-            <el-form-item label-width="0px" :prop="index===0?'unit0':'unit1'">
-              <el-input
-                v-model="item.unit"
-                placeholder="填写单位"
-                @blur="handleValue('unit',index)"
-                :ref="index===0?'unit0':'unit1'"
-              ></el-input>
+            <el-form-item label label-width="0px">
+              <span class="font">1</span>
             </el-form-item>
-          </el-col>
-          <el-col :span="1" class="operation">
-            <div class="icon">
-              <img src="../../../images/plus.png" v-if="!isOpen" @click="addForm()" />
-              <img src="../../../images/cut.png" v-if="isOpen" @click="cutForm(index)" />
-            </div>
-          </el-col>
-        </el-row>
+          </el-row>
+        </el-form>
       </el-col>
-    </el-form>
+      <el-form :rules="rules1" ref="ruleForm" :model="ruleForm">
+        <el-col :span="16" v-for="(item,index) in ruleForm.ruleForm" :key="index">
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label-width="0px" prop="compare">
+                <el-select
+                  v-model="item.compare"
+                  placeholder="请输入比较"
+                  style="width: 100%"
+                  ref="compare"
+                  clearable
+                  @clear="handleClear(index)"
+                >
+                  <el-option
+                    label="大于"
+                    value=">"
+                    :disabled="index=== 0 ? isCompare1==='>' : isCompare2==='>'"
+                  ></el-option>
+                  <el-option
+                    label="大于等于"
+                    value=">="
+                    :disabled="index=== 0 ? isCompare1==='>' : isCompare2==='>'"
+                  ></el-option>
+                  <el-option
+                    label="小于"
+                    value="<"
+                    :disabled="index=== 0 ? isCompare1==='<' : isCompare2==='<'"
+                  ></el-option>
+                  <el-option
+                    label="小于等于"
+                    value="<="
+                    :disabled="index=== 0 ? isCompare1==='<' : isCompare2==='<'"
+                  ></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label-width="0px" :prop="index===0?'amount0':'amount1'">
+                <el-input
+                  clearable
+                  v-model="item.value"
+                  placeholder="填写数值"
+                  @blur="handleValue('value',index)"
+                  :disabled="item.compare ==''"
+                  :ref="index===0?'amount0':'amount1'"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label-width="0px" :prop="index===0?'unit0':'unit1'">
+                <el-input
+                  clearable
+                  v-model="item.unit"
+                  placeholder="填写单位"
+                  @blur="handleValue('unit',index)"
+                  :ref="index===0?'unit0':'unit1'"
+                  :disabled="index==1"
+                  @clear="handleUnitClear(index)"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="1" class="operation">
+              <div class="icon">
+                <img src="../../../images/plus.png" v-if="!isOpen" @click="addForm()" />
+                <img src="../../../images/cut.png" v-if="isOpen" @click="cutForm(index)" />
+              </div>
+            </el-col>
+          </el-row>
+        </el-col>
+      </el-form>
+    </el-col>
   </el-row>
 </template>
 
@@ -234,6 +267,28 @@ export default {
       } else {
         return false;
       }
+    },
+    isCompare1() {
+      const { ruleForm } = this.ruleForm;
+      if (ruleForm.length != 2) return false;
+      if (ruleForm[1].compare == '') {
+        return false;
+      } else if (ruleForm[1].compare == '>' || ruleForm[1].compare == '>=') {
+        return '>';
+      } else if (ruleForm[1].compare == '<' || ruleForm[1].compare == '<=') {
+        return '<';
+      }
+    },
+    isCompare2() {
+      const { ruleForm } = this.ruleForm;
+      if (ruleForm.length != 2) return false;
+      if (ruleForm[0].compare == '') {
+        return false;
+      } else if (ruleForm[0].compare == '>' || ruleForm[0].compare == '>=') {
+        return '>';
+      } else if (ruleForm[0].compare == '<' || ruleForm[0].compare == '<=') {
+        return '<';
+      }
     }
   },
   created() {
@@ -244,7 +299,7 @@ export default {
     _initData() {
       this.form = { ...this.data };
       const { maxValue, minValue, unit } = this.form;
-      console.log(maxValue, 'maxValue', minValue, 'minValue');
+      // console.log(maxValue, 'maxValue', minValue, 'minValue');
       if (minValue === null && maxValue === null) {
         this.ruleForm.ruleForm = [
           {
@@ -297,7 +352,15 @@ export default {
       let condition = this.conditionList.find(item => item.name == val);
       this.$emit('split', condition);
     },
-
+    handleClear(index) {
+      this.ruleForm.ruleForm[index].value = '';
+    },
+    handleUnitClear(index) {
+      // 两条规则
+      if (index === 0 && this.ruleForm.ruleForm.length == 2) {
+        this.ruleForm.ruleForm[1].unit = '';
+      }
+    },
     // handleSelectChange(val) {
     //   console.log(val, '===========');
     //   this.$refs.form.clearValidate();
@@ -348,11 +411,16 @@ export default {
           value: this.form.maxValue
         });
       } else if (from === 'unit') {
+        console.log(item, 'unit');
         this.form.unit = item.unit;
         this.$emit('handleInput', {
           type: 'unit',
           value: this.form.unit
         });
+        // 两条规则
+        if (idx === 0 && this.ruleForm.ruleForm.length == 2) {
+          this.ruleForm.ruleForm[1].unit = item.unit;
+        }
       }
     },
 
@@ -364,6 +432,10 @@ export default {
         value: '',
         unit: ''
       });
+      // 两条规则
+      if (this.ruleForm.ruleForm.length == 2) {
+        this.ruleForm.ruleForm[1].unit = this.ruleForm.ruleForm[0].unit;
+      }
     },
     // 减少表单
     cutForm(i) {