wyh 1 년 전
부모
커밋
e21dcce83b

+ 64 - 12
src/views/module_base/energyRate/modules/EnergyRateForm.vue

@@ -63,32 +63,39 @@
         >
 
         <template slot="begintime" slot-scope="text, record,index">
-            <a-form-model-item :prop="'data.'+index+'.begintime'" :rules="validatorListRules.begintime" style="margin-bottom: 0px;">
+            <a-form-model-item :prop="'data.'+index+'.begintime'" :rules="validatorRules.begintime2" style="margin-bottom: 0px;">
               <a-time-picker date-format="HH:mm:ss" placeholder="请选择分时开始时间" v-model="record.begintime" style="width: 100%" />
             </a-form-model-item>
         </template>
         <template slot="endtime" slot-scope="text, record,index">
-            <a-form-model-item :prop="'data.'+index+'.endtime'" :rules="validatorListRules.endtime" style="margin-bottom: 0px;">
+            <a-form-model-item :prop="'data.'+index+'.endtime'" :rules="validatorRules.endtime2" style="margin-bottom: 0px;">
               <a-time-picker date-format="HH:mm:ss" placeholder="请选择分时结束时间" v-model="record.endtime" style="width: 100%" />
             </a-form-model-item>
         </template>
         <template slot="pandv" slot-scope="text, record,index">
-            <a-form-model-item :prop="'data.'+index+'.pandv'" :rules="validatorListRules.pandv" style="margin-bottom: 0px;">
-              <j-dict-select-tag type="list" v-model="record.pandv" dictCode="ems_pandv" placeholder="请选择峰平谷" style="width: 100%" />
+            <a-form-model-item :prop="'data.'+index+'.pandv'" :rules="validatorRules.pandv" style="margin-bottom: 0px;">
+              <!-- <j-dict-select-tag type="list" v-model="record.pandv" dictCode="ems_pandv" placeholder="请选择峰平谷" style="width: 100%" /> -->
+              <a-select
+              v-model="record.pandv"
+              placeholder="请选择峰平谷"
+              showSearch
+              :filterOption="filterOption"
+              :options="typeOptions">
+              </a-select>
             </a-form-model-item>
         </template>
         <template slot="price" slot-scope="text, record,index">
-            <a-form-model-item :prop="'data.'+index+'.price'" :rules="validatorListRules.price" style="margin-bottom: 0px;">
+            <a-form-model-item :prop="'data.'+index+'.price'" :rules="validatorRules.price" style="margin-bottom: 0px;">
               <a-input v-model="record.price" placeholder="请输入价格" ></a-input>
             </a-form-model-item>
         </template>
         <template slot="beginamount" slot-scope="text, record,index">
-            <a-form-model-item :prop="'data.'+index+'.beginamount'" :rules="validatorListRules.beginamount" style="margin-bottom: 0px;">
+            <a-form-model-item :prop="'data.'+index+'.beginamount'" :rules="validatorRules.beginamount" style="margin-bottom: 0px;">
               <a-input v-model="record.beginamount" placeholder="请输入起始量" ></a-input>
             </a-form-model-item>
         </template>
         <template slot="endamount" slot-scope="text, record,index">
-            <a-form-model-item :prop="'data.'+index+'.endamount'" :rules="validatorListRules.endamount" style="margin-bottom: 0px;">
+            <a-form-model-item :prop="'data.'+index+'.endamount'" :rules="validatorRules.endamount" style="margin-bottom: 0px;">
               <a-input v-model="record.endamount" placeholder="请输入结束量" ></a-input>
             </a-form-model-item>
         </template>
@@ -124,6 +131,7 @@
   import { FormTypes,getRefPromise,VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'
   import { JEditableTableModelMixin } from '@/mixins/JEditableTableModelMixin'
   import { validateDuplicateValue } from '@/utils/util'
+  import {ajaxGetDictItems,getDictItemsFromCache} from '@/api/api'
 
   export default {
     name: 'EnergyRateForm',
@@ -132,6 +140,12 @@
     },
     data() {
       return {
+        // typeOptions: [
+        //   {label: '尖', value: 0},
+        //   {label: '峰', value: 1},
+        //   {label: '平', value: 2},
+        //   {label: '谷', value: 3},
+        // ],
         labelCol: {
           xs: { span: 24 },
           sm: { span: 6 },
@@ -175,12 +189,10 @@
            endtime: [
               { required: true, message: '请输入费率有效期结束!'},
            ],
-        },
-        validatorListRules: {
-          begintime: [
+           begintime2: [
             { required: true, message: '请选择分时开始时间!'},
           ],
-          endtime: [
+          endtime2: [
             { required: true, message: '请选择分时结束时间!'},
           ],
           pandv: [
@@ -196,6 +208,26 @@
             { required: true, message: '请输入结束量!'},
           ],
         },
+        // validatorListRules: {
+        //   begintime: [
+        //     { required: true, message: '请选择分时开始时间!'},
+        //   ],
+        //   endtime: [
+        //     { required: true, message: '请选择分时结束时间!'},
+        //   ],
+        //   pandv: [
+        //     { required: true, message: '请选择峰平谷!'},
+        //   ],
+        //   price: [
+        //     { required: true, message: '请输入价格!'},
+        //   ],
+        //   beginamount: [
+        //     { required: true, message: '请输入起始量!'},
+        //   ],
+        //   endamount: [
+        //     { required: true, message: '请输入结束量!'},
+        //   ],
+        // },
         // 新增时子表默认添加几行空数据
         addDefaultRowNum: 1,
         refKeys: ['baseEnergyRateDetail', ],
@@ -215,7 +247,8 @@
           },
         },
         count: 1,
-        ratetype: ''
+        ratetype: '',
+        dictCode: 'ems_pandv'
       }
     },
     props: {
@@ -232,8 +265,27 @@
       },
     },
     created () {
+      this.initDictData()
     },
     methods: {
+      initDictData() {
+        //优先从缓存中读取字典配置
+        if(getDictItemsFromCache(this.dictCode)){
+          this.typeOptions = getDictItemsFromCache(this.dictCode);
+          return
+        }
+
+        //根据字典Code, 初始化字典数组
+        ajaxGetDictItems(this.dictCode, null).then((res) => {
+          if (res.success) {
+//                console.log(res.result);
+            this.typeOptions = res.result;
+          }
+        })
+      },
+      filterOption (value, option) {
+          return option.componentOptions.children[0].text.indexOf(value) >= 0
+      },
       addBefore(){
             this.model.data=[]
       },

+ 1 - 4
src/views/module_tpm/tag/modules/TagForm.vue

@@ -28,7 +28,7 @@
           </a-col> -->
           <a-col :span="12">
             <a-form-model-item label="点位类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tagtype">
-              <j-search-select-tag v-model="model.tagtype" placeholder="请选择点位类型" dict="tpm_tag_type" getPopupContainer="getModalAsContainer"/>
+              <j-search-select-tag v-model="model.tagtype" placeholder="请选择点位类型" dict="tpm_tag_type" />
             </a-form-model-item>
           </a-col>
           <a-col :span="12">
@@ -147,9 +147,6 @@
       this.getPointOptions()
     },
     methods: {
-      getModalAsContainer(node){
-        return document.querySelector('.j-modal-box .ant-modal-content')
-      },
       add () {
         this.edit(this.modelDefault);
       },

+ 72 - 1
src/views/module_tpm/tag/modulesPL/TagFormPL1.vue

@@ -69,17 +69,38 @@
                                 </template> -->
                                 <template slot="tagtype" slot-scope="text, record,index">
                                     <a-form-model-item :prop="'data.'+index+'.tagtype'" :rules="validatorRules.tagtype" style="margin-bottom: 0px;">
-                                        <j-search-select-tag v-model="record.tagtype" placeholder="请选择点位类型" dict="tpm_tag_type"/>
+                                        <!-- <j-search-select-tag v-model="record.tagtype" placeholder="请选择点位类型" dict="tpm_tag_type"/> -->
+                                        <a-select
+                                        v-model="record.tagtype"
+                                        showSearch
+                                        :filterOption="filterOption"
+                                        placeholder="请选择点位类型"
+                                        :options="tagTypeOptions">
+                                        </a-select>
                                     </a-form-model-item>
                                 </template>
                                 <template slot="energytypeid" slot-scope="text, record,index">
                                     <a-form-model-item :prop="'data.'+index+'.energytypeid'" :rules="validatorRules.energytypeid" style="margin-bottom: 0px;">
                                         <j-search-select-tag v-model="record.energytypeid" placeholder="请选择能源分类" dict="base_energy_type,name,id"/>
+                                        <!-- <a-select
+                                        v-model="record.energytypeid"
+                                        showSearch
+                                        :filterOption="filterOption"
+                                        placeholder="请选择能源分类"
+                                        :options="energyTypeOptions">
+                                        </a-select> -->
                                     </a-form-model-item>
                                 </template>
                                 <template slot="energyitemid" slot-scope="text, record,index">
                                     <a-form-model-item :prop="'data.'+index+'.energyitemid'" :rules="validatorRules.energyitemid" style="margin-bottom: 0px;">
                                         <j-search-select-tag v-model="record.energyitemid" placeholder="请选择能源分项" dict="base_energy_item,energyitemname,id"/>
+                                        <!-- <a-select
+                                        v-model="record.energyitemid"
+                                        showSearch
+                                        :filterOption="filterOption"
+                                        placeholder="请选择能源分项"
+                                        :options="energyItemOptions">
+                                        </a-select> -->
                                     </a-form-model-item>
                                 </template>
                                 <template slot="max" slot-scope="text, record,index">
@@ -125,6 +146,7 @@
 
 <script>
 import { httpAction, getAction } from '@/api/manage'
+import {ajaxGetDictItems,getDictItemsFromCache} from '@/api/api'
 
 export default {
     name: 'TagFormPL1',
@@ -273,13 +295,62 @@ export default {
                     { required: true, message: '请选择设备!'},
                 ],
             },
+            dictCode: 'tpm_tag_type',
+            dictCode2: 'base_energy_type',
+            dictCode3: 'base_energy_item',
+            tagTypeOptions: [],
+            energyTypeOptions: [],
+            energyItemOptions: []
         }
     },
     created () {
       // 获取点位数据
       this.getPointOptions()
+      this.initDictData()
     },
     methods: {
+        initDictData() {
+            //优先从缓存中读取字典配置
+            if(getDictItemsFromCache(this.dictCode)){
+            this.tagTypeOptions = getDictItemsFromCache(this.dictCode);
+            return
+            }
+
+            //根据字典Code, 初始化字典数组
+            ajaxGetDictItems(this.dictCode, null).then((res) => {
+            if (res.success) {
+                console.log(111,res)
+                this.tagTypeOptions = res.result;
+            }
+            })
+        },
+        // // a-select可搜索
+        // handleInput(e='') {
+        //     console.log(111,e,this.tagTypeOptions)
+        //     var resultArr = [];
+ 
+        //     // 遍历数组中的每个对象
+        //     for (let i = 0; i < this.tagTypeOptions.length; i++) {
+        //         // 判断当前对象的name属性是否包含指定的关键字
+        //         if (this.tagTypeOptions[i].label.includes(e)) {
+        //             // 如果包含则将该对象添加到结果数组中
+        //             resultArr.push(this.tagTypeOptions[i]);
+        //         }
+        //     }
+        //     console.log(999,resultArr);
+        //     this.tagTypeOptions = resultArr
+        //     return this.tagTypeOptions
+        // },
+        filterOption (value, option) {
+            return option.componentOptions.children[0].text.indexOf(value) >= 0
+        },
+        setCurrentDictOptions(tagTypeOptions){
+            this.tagTypeOptions = tagTypeOptions
+        },
+        getCurrentDictOptions(){
+            return this.tagTypeOptions
+        },
+        // 获取点位数据
         getPointOptions() {
             getAction(this.url.getPoint, this.queryParam).then((res) => {
                 this.dataPoint = res.result.map(item => {