Browse Source

加入到指标库

Karsa 6 months ago
parent
commit
66b5e3adcb

+ 10 - 0
src/api/modules/dataSource.js

@@ -116,6 +116,16 @@ const selfDataInterface = {
      */
     batchSaveEdb: parmas => {
         return http.post('/datamanage/business_data/batch_add',parmas)
+    },
+
+    /**
+     * 数据列表
+     * @param {*} parmas 
+     * PageSize CurrentIndex IndexCode
+     * @returns 
+     */
+    getDataList: parmas => {
+        return http.get('/datamanage/business_data/data/list',parmas)
     }
 }
 

+ 3 - 0
src/lang/modules/DataSources/Zh.js

@@ -201,6 +201,9 @@ export default {
     col_start_time:'指标开始时间',
     col_newest_time:'指标最新时间',
     col_create:'入库时间',
+    col_menu: '目录',
+    col_part_menu: '分目录',
+    col_same_menu: '同目录',
 
   },
 

+ 126 - 66
src/views/dataEntry_manage/thirdBase/components/addToBaseDia.vue

@@ -12,86 +12,91 @@
     center
   >
     <div class="add-dialog-wrap">
-       <el-table 
-          :data="tableData" 
-          border 
-          height="500px"
-        >
-          <el-table-column :label="$t('Edb.Detail.e_id')" align="center" prop="EdbCode"/>
-          <el-table-column :label="$t('Edb.Detail.e_name')" align="center">
+          <el-table 
+            :data="tableData" 
+            border 
+            height="500px"
+          >
+            <el-table-column :label="$t('Edb.Detail.e_id')" align="center" prop="IndexCode"/>
+            <el-table-column :label="$t('Edb.Detail.e_name')" align="center">
+                <template slot-scope="scope">
+                      <el-input 
+                        v-model="scope.row.IndexName" 
+                        placeholder="请填写指标名称" 
+                        style="width:100%"
+                      />
+                      <div class="error">
+                        <!-- <span>指标名称已存在,请重新填写</span> -->
+                      </div>
+                </template>
+            </el-table-column>
+            <el-table-column :label="$t('Edb.Detail.e_unit')" align="center" width="200px">
+                <template slot-scope="scope">
+                    <selectUnit v-model="scope.row.Unit"/>
+                </template>
+            </el-table-column>
+            <el-table-column :label="$t('Edb.Detail.e_fre')" align="center" width="200px">
               <template slot-scope="scope">
-                  <el-input v-model="scope.row.name" placeholder="请填写指标名称" style="width:100%"/>
-              </template>
-          </el-table-column>
-          <el-table-column :label="$t('Edb.Detail.e_unit')" align="center" width="200px">
-              <template slot-scope="scope">
-                  <selectUnit v-model="scope.row.unit"/>
-              </template>
-          </el-table-column>
-          <el-table-column :label="$t('Edb.Detail.e_fre')" align="center" width="200px">
-            <template slot-scope="scope">
-              <el-select
-                v-model="scope.row.frequency"
-                placeholder="请选择频率"
-                @change="handleFrequencyChange(scope)"
-              >
-                <el-option
-                  v-for="item in frequencyArr"
-                  :key="item"
-                  :label="item"
-                  :value="item"
+                <el-select
+                  v-model="scope.row.Frequency"
+                  placeholder="请选择频率"
                 >
-                </el-option>
-              </el-select>
-            </template>
-          </el-table-column>
-          <el-table-column align="center" width="300px">
-              <template slot="header" slot-scope="scope">
-                  <span style="margin-right:40px;display:inline-block">目录</span>
-                  <el-radio-group 
-                    v-model="classifyType"
-                    @change="handleClassifyTypeChange"
+                  <el-option
+                    v-for="item in $parent.frequencyOptions"
+                    :key="item.val"
+                    :label="item.label"
+                    :value="item.val"
                   >
-                      <el-radio :label="0">分目录</el-radio>
-                      <el-radio :label="1">同目录</el-radio>
-                  </el-radio-group>
-              </template>
-              <template slot-scope="{row,$index}">
-                  <el-cascader
-                    v-model="row.classify"
-                    :options="classifyOpt"
-                    :props="levelProps"
-                    placeholder="请选择指标目录"
-                    :disabled="(classifyType===1&&$index>0)"
-                    @change="handleClassifyChange(row,$index)"
-                  />
+                  </el-option>
+                </el-select>
               </template>
-          </el-table-column>
-      </el-table>
+            </el-table-column>
+            <el-table-column align="center" width="300px">
+                <template slot="header">
+                    <span style="margin-right:40px;display:inline-block">目录</span>
+                    <el-radio-group 
+                      v-model="classifyType"
+                      @change="handleClassifyTypeChange"
+                    >
+                        <el-radio :label="0">分目录</el-radio>
+                        <el-radio :label="1">同目录</el-radio>
+                    </el-radio-group>
+                </template>
+                <template slot-scope="{row,$index}">
+                      <el-cascader
+                        v-model="row.ClassifyId"
+                        :options="classifyOpt"
+                        :props="levelProps"
+                        placeholder="请选择指标目录"
+                        :disabled="(classifyType===1&&$index>0)"
+                        @change="handleClassifyChange(row,$index)"
+                        class="cascader-wrapper"
+                      />
+                </template>
+            </el-table-column>
+          </el-table>
     </div>
+
     <div style="text-align: center; margin: 30px 0">
-      <el-button @click="cancelHandle">{{
-        $t("Dialog.cancel_btn")
-      }}</el-button>
+      <el-button @click="cancelHandle">{{$t("Dialog.cancel_btn")}}</el-button>
       <el-button
         type="primary"
-        @click="handleSave"
-        :loading="btnLoading"
-        >{{ $t("Dialog.confirm_save_btn") }}</el-button
+        @click="handleCheckName"
+        :loading="saveLoading"
       >
+        {{ $t("Dialog.confirm_save_btn") }}
+      </el-button>
     </div>
   </el-dialog>
 </template>
 <script>
 import { dataBaseInterface } from '@/api/api.js';
+import { selfDataInterface } from '@/api/modules/dataSource';
 export default {
   props: {
     isShow: {
       type: Boolean
     },
-    type: {
-      type: String
-    },
     list: {
       type: Array,
       default: () => []
@@ -100,6 +105,7 @@ export default {
   data() {
     return {
       tableData:[],
+      saveLoading: false,
 
       classifyType:0,
       classifyOpt: [],
@@ -118,10 +124,11 @@ export default {
       if(!nval) return
 
       this.getClassifyOpt()
-      
-      if(this.type==='single') {
 
-      }
+      this.tableData = this.list.map(_=>({
+        ..._,
+        ClassifyId: 0
+      }))
     }
   },
   methods: {
@@ -147,14 +154,67 @@ export default {
       this.$emit('update:isShow',false)
     },
 
-    handleClassifyTypeChange() {
+    // 同目录修改
+    handleClassifyChange(e,index){
+        if(this.classifyType===1){
+          // 修改所有的指标的目录为第一个
+          this.tableData.forEach(item=>{
+              item.ClassifyId=e.ClassifyId
+          })
+        }
+    },
 
+    handleClassifyTypeChange(){
+      this.handleClassifyChange(this.tableData[0])
+    },
+
+    handleCheckName() {
+
+      //重名校验
+      this.existNameArr = []
+      selfDataInterface.checkName(
+          this.tableData.map(_=>({EdbCode:_.IndexCode,EdbName:_.IndexName}))
+      ).then(res=>{
+          if(res.Ret!==200) return 
+          this.existNameArr = res.Data.filter(i=>i.Exist)
+
+          if(this.existNameArr.length) return
+          this.handleSave()
+      })
     },
 
     handleSave() {
 
+      let haveIncomplete = this.tableData.some(_ => !_.IndexName||!_.ClassifyId)
+      if(haveIncomplete) return this.$message.warning('指标信息填写不完整')
+
+      this.saveLoading = true;
+      selfDataInterface.batchSaveEdb(
+          this.tableData.map(i=>({
+            EdbCode: i.IndexCode,
+            EdbName: i.IndexName,
+            Frequency: i.Frequency,
+            Unit: i.Unit,
+            ClassifyId: i.ClassifyId,
+            Source: i.Source
+          }))
+      ).then(res=>{
+          this.saveLoading = false
+
+          if(res.Ret!==200) return 
+          this.$message.success(this.$t('MsgPrompt.add_msg2'))
+
+          this.cancelHandle();
+          this.$emit('success')
+      })
     }
   },
 };
 </script>
-<style scoped lang="scss"></style>
+<style lang="scss">
+.add-dialog-wrap {
+   .el-cascader .el-input{
+      width: 100%;
+    }
+}
+</style>

+ 90 - 20
src/views/dataEntry_manage/thirdBase/components/lookEdbDataDia.vue

@@ -42,17 +42,17 @@
       >
         <li
           class="value-item"
-          v-for="item in dataList"
-          :key="item.EdbDataId"
+          v-for="(item,index) in dataList"
+          :key="item.ID"
         >
           <span class="value-label">
             <span style="position: relative;">
-              <i class="new-tag" v-if="tableData[0].LatestDate===item.DataTime"></i>
+              <i class="new-tag" v-if="index===0"></i>
               {{item.DataTime}}
             </span>
           </span>
-          <span :class="'value-label'" style="min-width:200px;text-align:center;">
-            <span :class="['value-style',{'predict-act': tableData[0].DataInsertConfig.Date===item.DataTime}]">{{item.Value}}</span>
+          <span class="value-label" style="min-width:200px;text-align:center;">
+            <span class="value-style">{{item.Value}}</span>
           </span>
         </li>
         <li class="nodata value-item" v-if="!dataList.length">{{$t('Table.prompt_slogan')}}</li>
@@ -62,10 +62,14 @@
   </el-dialog>
 </template>
 <script>
+import { selfDataInterface } from '@/api/modules/dataSource';
 export default {
   props: {
     isShow: {
       type: Boolean
+    },
+    edbInfo: {
+      type: Object
     }
   },
   computed: {
@@ -73,32 +77,38 @@ export default {
       return [
          {
             label: this.$t('Edb.Detail.e_id'),
-            key: 'EdbCode',
-            widthsty: '120px',
+            key: 'IndexCode',
           },
          {
             label: this.$t('Edb.Detail.e_name'),
-            key: 'EdbName',
-            minwidthsty: '150px',
+            key: 'IndexName',
           },
-           {
+          {
             label: /* '指标开始时间' */this.$t('SelftDataPage.col_start_time'),
             key: 'StartDate',
-            sortable:true,
-            minwidthsty: '100px',
           },
           {
             label: /* '指标最新时间' */this.$t('SelftDataPage.col_newest_time'),
-            key: 'LatestDate',
-            sortable:true,
-            minwidthsty: '90px',
+            key: 'DataUpdateTime',
           },
       ]
     }
   },
+  watch: {
+    isShow(nval) {
+      if(!nval) return
+
+      console.log(this.edbInfo)
+      this.tableData = [this.edbInfo]
+      this.getData();
+    }
+  },
   data() {
     return {
-      dataList: []
+      tableData: [],
+      
+      dataList: [],
+      page_no: 1
     }
   },
   mounted(){
@@ -106,11 +116,35 @@ export default {
   },
   methods:{
     cancelHandle() {
+      this.page_no = 1;
+      this.$refs.valueUl.scrollTop=0
       this.$emit('update:isShow',false)
     },
+    
+    async getData() {
+      const res = await selfDataInterface.getDataList({
+        CurrentIndex: this.page_no,
+        PageSize: 10,
+        IndexCode: this.edbInfo.IndexCode
+      })
 
-    scrollHandle() {
-      
+      if(res.Ret!==200) return
+
+      this.haveMore = this.page_no  < res.Data.Paging.Pages ? true : false;
+      let data = res.Data.List||[];
+      this.dataList = this.page_no===1 ? data : this.dataList.concat(data)
+    },
+
+    scrollHandle(e) {
+      const dom = e.target
+			let scrollTop = dom.scrollTop; //滑入屏幕上方的高度
+			let windowHeitht = dom.clientHeight; //页面的高度
+			let scrollHeight = dom.scrollHeight; //整个div的高度
+			let total = scrollTop + windowHeitht
+			if(total >= scrollHeight && this.haveMore){
+				this.page_no ++;
+				this.getData();
+			}
     }
   },
 }
@@ -123,8 +157,44 @@ export default {
 	.main {
     padding: 20px 0;
   }
-	.value-ul{
+
+  .value-ul {
+    height: 300px;
+    margin-top: 10px;
+    border-bottom: 1px solid #EBEFF6;
     overflow-y: auto;
-	}
+    .value-item {
+      padding: 10px 0;
+      border: 1px solid #dcdfe6;
+      border-bottom: none;
+      display: flex;
+      justify-content: space-around;
+      >span{
+        padding:0 16px;
+        box-sizing: border-box;
+      }
+      .value-label {
+        position: relative;
+        color: #666;
+      }
+     
+      .new-tag {
+        width: 6px;
+        height: 6px;
+        display: inline-block;
+        position: absolute;
+        left: -12px;
+        top: 50%;
+        transform: translateY(-50%);
+        border-radius: 50%;
+        background: #f00;
+      }
+    }
+    .nodata {
+      text-align: center;
+      padding: 40px 0;
+      color: #999;
+    }
+  }
 }
 </style>

+ 43 - 60
src/views/dataEntry_manage/thirdBase/selfDataBase.vue

@@ -82,15 +82,15 @@
               <template v-if="item.key==='handle'">
                 <span 
                   class="editsty"
-                  @click="lookDataHandle"
+                  @click="lookDataHandle(row)"
                 >
                   <!-- 查看数据 -->{{$t('Edb.detail_lookdata_btn')}}
                 </span>
 
                 <span 
                   class="editsty"
-                  v-if="!row.EdbExist" 
-                  @click="handleCheckEdb('single')"
+                  v-if="!row.EdbInfoId" 
+                  @click="handleCheckEdb('single',row)"
                 >
                   <!-- 添加到指标库 -->{{$t('YsDataPage.add_base_btn')}}
                 </span>
@@ -118,12 +118,14 @@
     <!-- 查看数据弹窗 -->
     <lookEdbDataDia
       :isShow.sync="isLookDataDia"
+      :edbInfo="lookEdbInfo"
     />
 
     <!-- 加入指标库弹窗 -->
     <addToBaseDia
       :isShow.sync="isAddToBaseDia"
       :list="addToBaseList"
+      @success="pageChange(1)"
     />
 
     <!-- 操作提示弹窗 -->
@@ -139,19 +141,18 @@
       <div class="hint-dialog-wrap">
           <p style="margin-bottom: 20px;">{{ hintText }}</p>
           <ul>
-              <li v-for="(item,index) in existEdbList" :key="index" class="hint-item" @click="gotoEdbDetail(item)">
+              <li v-for="(item,index) in existEdbList" :key="index" class="hint-item" @click="goToEdbBase(item)">
                   {{ index+1 }}、{{ item.IndexName }}({{ item.IndexCode }})
               </li>
           </ul>
       </div>
       <div style="text-align: center;margin-bottom: 30px;">
-          <el-button type="primary" @click="handleCloseDialog">{{$t('Dialog.known')}}</el-button>
+          <el-button type="primary" @click="handleCloseHintDia">{{$t('Dialog.known')}}</el-button>
       </div>
     </el-dialog>
   </div>
 </template>
 <script>
-import { dataBaseInterface } from '@/api/api.js'
 import { selfDataInterface } from '@/api/modules/dataSource';
 import mPage from '@/components/mPage.vue';
 import lookEdbDataDia from './components/lookEdbDataDia.vue';
@@ -217,28 +218,23 @@ export default {
     },
 
     hintText(){
-        let msg = ''
-        // if(this.afterAddList.length) key++
-        // if(!this.beforeAddList.length) key++
-        // return {
-        //     0:'',
-        //     1:this.$t('YsDataPage.haved_all_msg'),//本次添加的指标均已在指标库中,请勿重复添加!
-        //     2:this.$t('YsDataPage.haved_some_msg'),//指标库中已存在以下指标,会自动过滤!
-        // }[key]
+        let key = 0
+        if(this.existEdbList.length) key++
+        if(!this.addToBaseList.length) key++
+
+        return {
+            0:'',
+            1:this.$t('YsDataPage.haved_all_msg'),//本次添加的指标均已在指标库中,请勿重复添加!
+            2:this.$t('YsDataPage.haved_some_msg'),//指标库中已存在以下指标,会自动过滤!
+        }[key]
     }
   },
   data() {
     return {
-      edbMenuList: [],
       tableLoading: false,
       total: 0,
       
-      tableData: [
-        { EdbCode: 'w102256',EdbName:'1dqwd',Frequency:'日度',Unit:'无',Source:'',StartDate:'',LatestDate:'',CreateTime:'' },
-        { EdbCode: 'w102256',EdbName:'1dqwd',Frequency:'日度',Unit:'无',Source:'',StartDate:'',LatestDate:'',CreateTime:'' },
-        { EdbCode: 'w102256',EdbName:'1dqwd',Frequency:'日度',Unit:'无',Source:'',StartDate:'',LatestDate:'',CreateTime:'' },
-        { EdbCode: 'w102256',EdbName:'1dqwd',Frequency:'日度',Unit:'无',Source:'',StartDate:'',LatestDate:'',CreateTime:'' },
-      ],
+      tableData: [],
 
       sourceOptions: [],
 
@@ -260,6 +256,7 @@ export default {
 
       /* 查看数据弹窗 */
       isLookDataDia: false,
+      lookEdbInfo: {},
 
       /* 加入指标库弹窗 */
       isAddToBaseDia: false,
@@ -274,29 +271,9 @@ export default {
   },
   mounted(){
     this.getSource();
-    this.getEdbMenuList();
     this.getTableData();
   },
   methods:{
-
-    getEdbMenuList() {
-      dataBaseInterface.menuListV3().then(res => {
-        if(res.Ret === 200) {
-            this.edbMenuList = res.Data.AllNodes || [];
-            this.filterNodes(this.edbMenuList);
-        }
-      })
-    },
-    // 递归改变目录结构
-    filterNodes(arr) {
-        arr.length && arr.forEach(item => {
-        item.Children.length && this.filterNodes(item.Children)
-        if(!item.Children.length) {
-            item.Children=null
-        }
-        })
-    },
-
     getSource() {
       selfDataInterface.getSourceList().then(res => {
         if(res.Ret!==200 ) return
@@ -308,12 +285,16 @@ export default {
     getTableData(type='filter') {
       this.tableLoading = true;
 
+      const { frequency,page_no,pageSize,keyWord,source,sortParam,sortType } = this.filterObj;
+
       let params = {
-        Frequency: this.filterObj.frequency,
-        CurrentIndex: this.filterObj.page_no,
-        PageSize: this.filterObj.pageSize,
-        Keywords: this.filterObj.keyWord,
-        Source: this.filterObj.source
+        Frequency: frequency,
+        CurrentIndex: page_no,
+        PageSize: pageSize,
+        Keywords: keyWord,
+        Source: source,
+        SortField: sortParam,
+        SortRule: sortType
       }
 			selfDataInterface.getEdbList(params).then(res => {
         this.tableLoading = false;
@@ -340,7 +321,7 @@ export default {
 
       if(!this.isSelectAll){
           this.checkedList.map(_ =>{
-              let row = this.tableData.find(item => item.DataId==_.DataId)
+              let row = this.tableData.find(item => item.IndexCode==_.IndexCode)
               if(row){ //设置部分选中
                   setTimeout(()=>{
                       this.$refs.table.toggleRowSelection(row,true)
@@ -350,7 +331,7 @@ export default {
       }else{
           this.$refs.table &&this.$refs.table.toggleAllSelection()
           this.checkedList.map(_ =>{
-              let row = this.tableData.find(item => item.DataId==_.DataId)
+              let row = this.tableData.find(item => item.IndexCode==_.IndexCode)
               if(row){ //设置部分不勾选
                   setTimeout(()=>{
                       this.$refs.table.toggleRowSelection(row,false)
@@ -406,13 +387,13 @@ export default {
         if(this.selectionReactCancel) return 
 
         //当前项是选中还是取消选
-        let haveChecked = selection.some(_ => _.DataId === row.DataId);
+        let haveChecked = selection.some(_ => _.IndexCode === row.IndexCode);
 
         //全选取消选和不全选选中才有意义
         if((haveChecked&&!this.isSelectAll) || (!haveChecked&&this.isSelectAll)) {
           this.checkedList.push(row)
         }else {
-          this.checkedList=this.checkedList.filter(_ => _.DataId!==row.DataId)
+          this.checkedList=this.checkedList.filter(_ => _.IndexCode!==row.IndexCode)
         }
     },
 
@@ -428,8 +409,8 @@ export default {
           this.checkedList = [...this.checkedList,...this.tableData]
         }else {
 
-          let pageIds = this.tableData.map(_ => _.DataId);
-          this.checkedList = this.checkedList.filter(_ => !pageIds.includes(_.DataId))
+          let pageIds = this.tableData.map(_ => _.IndexCode);
+          this.checkedList = this.checkedList.filter(_ => !pageIds.includes(_.IndexCode))
         }
     },
 
@@ -457,7 +438,9 @@ export default {
     },
 
     /* 查看数据 */
-    lookDataHandle() {
+    lookDataHandle(item) {
+
+      this.lookEdbInfo = item;
       this.isLookDataDia =  true
     },
 
@@ -473,7 +456,7 @@ export default {
           SortField:sortParam||0,
           SortRule:sortType||0,
           ListAll:type==='single'?false:this.isSelectAll,
-          IndexCodes:type==='single'?[data.IndexCode]:this.checkedList
+          IndexCodes:type==='single'?[data.IndexCode]:this.checkedList.map(_=>_.IndexCode)
       }).then(res=>{
           if(res.Ret!==200) return 
 
@@ -486,21 +469,21 @@ export default {
       })
     },
 
-
-    //操作提示弹窗关闭
+    //提示弹窗关闭
     handleCloseHintDia(){
         this.isHintDialogShow = false
         //判断是否要展示下一个弹窗
-        if(this.addToBaseList.length) return
+        if(!this.addToBaseList.length) return
+        
+        if(this.addToBaseList.length>100) return this.$message.warning('批量添加指标数量不得超过100个!')
 
-        this.addForm.list = this.addToBaseList
         this.isAddToBaseDia = true
     },
 
     //跳转至指标详情
-    gotoEdbBase(data){
+    goToEdbBase(data){
         const {EdbClassifyId,EdbInfoId,EdbUniqueCode} = data||{}
-        const href = this.$router.resolve({
+        const { href } = this.$router.resolve({
             path:'/database',
             query:{
                 code:EdbUniqueCode,