Ver código fonte

Merge branch 'chart15.3'

Karsa 1 ano atrás
pai
commit
38b9b35c72

+ 9 - 0
src/api/modules/sheetApi.js

@@ -245,4 +245,13 @@ export const searchTarget  = params => {
  */
 export const insertData = params => {
 	return http.get('/datamanage/edb_info/date_data',params)
+}
+
+/**
+ * 获取日期最近几期的数据
+ * @param {*} params EdbInfoId Date Num
+ * @returns 
+ */
+export const getDateLatelyData = params => {
+	return http.get('/datamanage/edb_info/date_data/before_after',params)
 }

+ 1 - 0
src/views/Home.vue

@@ -869,6 +869,7 @@ export default {
     collapseHandle () {
       //折叠导航栏
       this.isCollapse = !this.isCollapse;
+      this.$store.commit('SET_COLLAPSE',this.isCollapse)
       // 派发折叠导航栏事件
       EventBus.$emit("collapseHandle", this.isCollapse);
     },

+ 43 - 1
src/views/chartRelevance_manage/components/selectTarget.vue

@@ -14,7 +14,8 @@
         :value="item.val"
       />
     </el-select>
-    <div v-else>
+
+    <div v-else-if="selectStyleType===2">
       <label>选择指标:</label>
       <el-radio-group v-model="targetType" @change="targetTypeChange">
         <el-radio  
@@ -24,9 +25,50 @@
         >{{item.label}}</el-radio>
       </el-radio-group>
     </div>
+
+    <div v-else-if="selectStyleType===3" style="display:flex;align-items:center">
+      <el-select
+        v-model="targetType"
+        placeholder="请选择指标种类"
+        @change="targetTypeChange"
+        style="width: 150px;"
+      >
+        <el-option
+          v-for="item in etaTypeOpt"
+          :key="item.val"
+          :label="item.label"
+          :value="item.val"
+        />
+      </el-select>
+      <el-select
+        v-model="search_txt"
+        v-loadMore="searchLoad"
+        :filterable="!search_txt"
+        remote
+        clearable
+        placeholder="请选择指标名称"
+        style="flex: 1;margin-left: 15px"
+        :remote-method="searchHandle"
+        @click.native="inputFocusHandle"
+        @change="handleSelectTarget"
+      >
+        <i slot="prefix" class="el-input__icon el-icon-search"></i>
+        <el-option
+          v-for="item in searchOptions"
+          :key="item.EdbInfoId"
+          :label="item.EdbName"
+          :value="item.EdbInfoId"
+        >
+          <edbDetailPopover :info="item">
+            <div slot="reference">{{item.EdbName}}</div>
+          </edbDetailPopover>
+        </el-option>
+      </el-select>
+    </div>
     <el-select
       v-model="search_txt"
       v-loadMore="searchLoad"
+      v-if="selectStyleType!==3"
       :filterable="!search_txt"
       remote
       clearable

+ 27 - 4
src/views/datasheet_manage/common/customTable.js

@@ -149,7 +149,9 @@ export function getRightClickMenu(pos) {
       { label: "删除", key: "del" },
     ],
     'cell': [
+      { label: "选择指标", key: "choose-target" },
       { label: "插入指标值", key: "insert-value" },
+      { label: "清空", key: "reset" },
     ]
   }
 
@@ -159,6 +161,9 @@ export function getRightClickMenu(pos) {
 //日期格式识别转换
 export function checkDateFormat(str) {
   const dateRegex = /^(?:(?:19|20)\d\d)([-/.])(0?[1-9]|1[0-2])\1(0?[1-9]|[12][0-9]|3[01])$/;
+
+  //也支持年-月
+  const dateMonthRegex = /^(?:(?:19|20)\d\d)([-])(0[1-9]|1[0-2])$/;
   
   if(dateRegex.test(str)) {
     const date = new Date(str);
@@ -171,19 +176,21 @@ export function checkDateFormat(str) {
     } else {
       return false;
     }
-  }else {
+  } else if(dateMonthRegex.test(str)){
+    return str
+  } else {
     return false
   }
 }
 
-/* 根据key找到关联格子 设置关联格子样式 */
-export function setRelationStyle(query) {
+/* 根据key找到格子 设置格子样式 */
+export function setRelationStyle(query,classname="td-relation") {
   const { key } = query;
 
   let table = document.querySelector('.table');
   let el = table.querySelector("td[data-key='" + key + "']");
   
-  el.nodeName==='TD' && $(el).addClass("td-relation")
+  el.nodeName==='TD' && $(el).addClass(classname)
 }
 
 //根据cell key找到cell数据
@@ -203,3 +210,19 @@ export function findCellByKey(arr,key) {
   return cell
 }
 
+/* 清空插入单元格重置关联样式 */
+export function resetRelationStyle() {
+  let table = document.querySelector('.table');
+  table.querySelectorAll(".td-relation").forEach(el => {
+    el.classList.remove('td-relation')
+  })
+}
+
+/* 重置右键选择指标时的单元格标识样式 弹窗消失样式就消失 */
+export function resetDialogCellStyle() {
+  let table = document.querySelector('.table');
+  table.querySelectorAll(".td-choose-insert-target").forEach(el => {
+    el.classList.remove('td-choose-insert-target')
+  })
+}
+

+ 20 - 10
src/views/datasheet_manage/components/CustomTable.vue

@@ -72,7 +72,7 @@
                 :key="edb_index"
                 :data-rindex="rowHeader[dateIndex]"
                 :data-cindex="columnHeader[edb_index]"
-                :class="([2,3].includes(edb.Data.find(_ =>_.DataTime === date).DataType)&&edb.Data.find(_ =>_.DataTime === date).ShowValue)?'insert': ''"
+                :class="([2,3,5].includes(edb.Data.find(_ =>_.DataTime === date).DataType)&&edb.Data.find(_ =>_.DataTime === date).ShowValue)?'insert': ''"
                 @click="clickCell($event,edb.Data.find(_ =>_.DataTime === date))"
                 @dblclick="dblClickCell($event,edb.Data.find(_ =>_.DataTime === date))"
               >
@@ -113,7 +113,7 @@
                 :key="`${index}_${cell_index}`"
                 :data-rindex="rowHeader[index+dateArr.length]"
                 :data-cindex="cell_index===0?-1:columnHeader[cell_index-1]"
-                :class="([2,3].includes(cell.DataType)&&cell.ShowValue)?'insert': ''"
+                :class="([2,3,5].includes(cell.DataType)&&cell.ShowValue)?'insert': ''"
                 @click="clickCell($event,cell)"
                 @dblclick="dblClickCell($event,cell)"
               >
@@ -189,7 +189,7 @@
                 :key="index"
                 :data-cindex="-1"
                 :data-rindex="rowHeader[index+dateArr.length]"
-                :class="([2,3].includes(column[0].DataType)&&column[0].ShowValue)?'insert': ''"
+                :class="([2,3,5].includes(column[0].DataType)&&column[0].ShowValue)?'insert': ''"
                 @click="clickCell($event,column[0])"
                  @dblclick="dblClickCell($event,column[0])"
               >
@@ -243,7 +243,7 @@
                 :key="`${edb.EdbInfoId}_${rowHeader[data_index]}_${columnHeader[edb_index]}`"
                 :data-rindex="rowHeader[data_index]"
                 :data-cindex="columnHeader[edb_index]"
-                :class="([2,3].includes(data.DataType)&&data.ShowValue)?'insert': ''"
+                :class="([2,3,5].includes(data.DataType)&&data.ShowValue)?'insert': ''"
                 @click="clickCell($event,data)"
                 @dblclick="dblClickCell($event,data)"
               >
@@ -274,7 +274,7 @@
                 :key="`${rowHeader[column_index+dateArr.length]}_${columnHeader[edb_index]}`"
                 :data-rindex="rowHeader[column_index+dateArr.length]"
                 :data-cindex="columnHeader[edb_index]"
-                :class="([2,3].includes(column[edb_index+1].DataType)&&column[edb_index+1].ShowValue)?'insert': ''"
+                :class="([2,3,5].includes(column[edb_index+1].DataType)&&column[edb_index+1].ShowValue)?'insert': ''"
                 @click="clickCell($event,column[edb_index+1])"
                 @dblclick="dblClickCell($event,column[edb_index+1])"
               >
@@ -303,7 +303,7 @@
 
 
       <!-- 添加 -->
-      <div class="add-fixed" v-if="!disabled">
+      <div class="add-fixed" v-if="!disabled" draggable @dragend="dragEnd" :style="isCollapse?'left:70px;':'left:200px;'">
         <div class="add-wrapper" v-show="!isSlideLeft">
           <div @click="addDateRow"> <i class="el-icon-circle-plus-outline"></i> 添加日期</div>
           <div @click="addTextRow"> <i class="el-icon-circle-plus-outline"></i> 添加文本</div>
@@ -429,6 +429,9 @@ export default {
     dateArr() {
       console.log(this.config.data)
       return this.config.data.length ? this.config.data[0].Data.map(_ => _.DataTime) : []
+    },
+    isCollapse() {
+      return this.$store.state.isCollapse
     }
   },
   data() {
@@ -437,9 +440,9 @@ export default {
       formula: '',
       config: {
         type: this.sheetType,
-        order: 1,// 1降序 2升序
+        order: 2,// 1降序 2升序
         EdbKeys: ["EdbName", "Unit"],
-        data: [],
+        data: [], //单元格类型 1默认格 2补充格 3自定义输入 4公式求值格 5预测值
         textRowData: [],
         contextMenuOption: [
           { label: '删除',key: 'del' },
@@ -750,6 +753,11 @@ export default {
     reset() {
       this.config.data = [];
       this.config.textRowData = [];
+    },
+
+    dragEnd(e) {
+      let dom = document.querySelector('.add-fixed');
+      dom.style.top = e.clientY-10 + 'px';
     }
   },
 };
@@ -874,9 +882,11 @@ export default {
   }
 
   .add-fixed {
-    position: absolute;
-    bottom: 20%;
+    cursor: move;
+    position: fixed;
+    top: 70%;
     left: 0;
+    z-index: 99;
     .add-wrapper {
       position: relative;
       padding: 5px 50px 5px 20px;

+ 204 - 53
src/views/datasheet_manage/components/MixedTable.vue

@@ -46,15 +46,43 @@
               :data-key="cell.Uid"
               @click="clickCell($event, cell)"
               @contextmenu.prevent="rightClickHandle($event,cell)"
+              @mouseenter="getRelationEdbInfo(cell)"
             >
+
+            <!-- 插入单元格禁止编辑 -->
+            <template v-if="[4,5].includes(cell.DataType) || disabled">
+              <!-- 单元格类型5显示指标浮窗 -->
+              <el-popover
+                v-if="cell.DataType===5&&!disabled"
+                placement="top-start"
+                width="350"
+                trigger="hover"
+              >
+                <ul>
+                  <li style="display:flex;margin:10px;">
+                    <label style="min-width:80px;">指标名称</label> 
+                    {{cellrelationEdbInfo.EdbName}}
+                  </li>
+                  <li style="display:flex;margin:10px;">
+                    <label style="min-width:80px;">指标ID</label> 
+                    {{cellrelationEdbInfo.EdbCode}}
+                  </li>
+                </ul>
+                <span
+                  slot="reference"
+                  :data-rindex="rowHeader[index]"
+                  :data-cindex="columnHeader[cell_index]"
+                  :data-key="cell.Uid"
+                >{{ cell.ShowValue }}</span>
+              </el-popover>
+
               <span
                 :data-rindex="rowHeader[index]"
                 :data-cindex="columnHeader[cell_index]"
                 :data-key="cell.Uid"
-                v-if="cell.DataType === 4 || disabled"
-              >
-                {{ cell.ShowValue }}</span
-              >
+                v-else
+              >{{ cell.ShowValue }}</span>
+            </template>
 
               <el-autocomplete
                 v-else
@@ -64,15 +92,19 @@
                 :data-key="cell.Uid"
                 :data-rindex="rowHeader[index]"
                 :data-cindex="columnHeader[cell_index]"
+                :highlight-first-item="cell.DataType===2"
                 @select="selectTarget($event,cell)"
                 @click="clickCell($event, cell)"
                 @change.native="changeVal($event, cell)"
               >
                 <template slot-scope="scope">
                     <edbDetailPopover :info="scope.item">
-                      <div slot="reference">
-                          {{ scope.item.EdbName }}
+                      <div slot="reference" v-if="cell.DataType===2" class="edb-item">
+                         <span class="edb-item-name text_oneLine">{{ scope.item.EdbName }}</span>
+                         <i class="el-icon-check" style="color:#0052D9;font-size:18px;"/>
                       </div>
+
+                      <div slot="reference" v-else>{{ scope.item.EdbName }}</div>
                     </edbDetailPopover>
                 </template>
               </el-autocomplete>
@@ -83,13 +115,20 @@
 
       <!-- 右键菜单 -->
       <div class="contextMenu-wrapper" id="contextMenu-wrapper" @mouseleave="hideContextMenu">
-        <div class="item" v-for="menu in config.contextMenuOption" :key="menu.key" @click="handleContext(menu.key)">{{menu.label}}</div>
+        <div :class="['item',{'deletesty': menu.key==='reset'}]" v-for="menu in config.contextMenuOption" :key="menu.key" @click="handleContext(menu.key)">{{menu.label}}</div>
       </div>
     </template>
 
     <div class="nodata" v-else>
       <tableNoData text="暂无数据"/>
     </div>
+
+    <!-- 选择指标 -->
+    <selectTargetValueDia
+      :isShow.sync="isSelectTargetValueDialog"
+      @insert="insertSelectData"
+      ref="selectTargetValueRef"
+    />
   </div>
 </template>
 <script>
@@ -102,18 +141,22 @@ import {
   getRightClickMenu,
   checkDateFormat,
   setFocus,
-  findCellByKey
-  
+  findCellByKey,
+  resetRelationStyle,
+  resetDialogCellStyle
 } from "../common/customTable";
 import * as sheetInterface from "@/api/modules/sheetApi.js";
-import md5 from '@/utils/md5.js'
+import { dataBaseInterface } from '@/api/api.js';
+import md5 from '@/utils/md5.js';
+import selectTargetValueDia from './selectTargetValueDia.vue';
 export default {
   props: {
     disabled: { //是否只预览
       type: Boolean,
-      default: false
+      default: false,
     }
   },
+  components: { selectTargetValueDia },
   computed: {
     //列头
     columnHeader() {
@@ -131,15 +174,21 @@ export default {
   data() {
     return {
       config: {
-        data: [],
+        data: [], //单元格类型 1日期格 2指标格 3自定义输入 4插入值 有关联的日期和指标格 5弹窗里的插入值 有关联日期格
         contextMenuOption: [],
       },
 
-      selectCell: {},
+      selectCell: {},//选中单元格info
+
+      rightClickCell: {},//右键单元格 key c r
+
+      insertTargetCell: {},//选择右键插入指标的单元格 可和右键单元格不一样 key c r
+
+      insertRelationArr: [],
 
-      rightClickCell: {},
+      isSelectTargetValueDialog: false,
 
-      insertRelationArr: []
+      cellrelationEdbInfo: {}
     };
   },
   mounted() {
@@ -148,17 +197,21 @@ export default {
   methods: {
 
     async searchTarget(query,cb) {
-      if(!query) return cb([])
-      // cb([])
+      if(!query||checkDateFormat(query)) return cb([])
       
-      const res = await sheetInterface.searchTarget({
-        KeyWord: query,
-        CurrentIndex: 1,
-        PageSize: 1000
-      })
+      const { DataType,EdbInfoId } = this.selectCell;
+
+      const res = DataType===2 
+        ? await dataBaseInterface.targetDetail({EdbInfoId})
+        : await sheetInterface.searchTarget({
+            KeyWord: query,
+            CurrentIndex: 1,
+            PageSize: 1000
+          })
       if(res.Ret !== 200) return
 
-      cb(res.Data.List)
+      let arr = DataType===2 ? [res.Data] : (res.Data.List||[])
+      cb(arr);
     },
 
     /* 单击 */
@@ -171,14 +224,16 @@ export default {
       setFocus(e);
 
       //插入值时寻找关联依赖的单元格 设置选框
-      if(cell.DataType === 4) {
+      if([4,5].includes(cell.DataType)) {
         const { key } = e.target.dataset;
         if(!this.insertRelationArr.find(_ => _.key===key)) return
         let { relation_date,relation_edb } = this.insertRelationArr.find(_ => _.key===key)
 
-        setRelationStyle(relation_date)
-        setRelationStyle(relation_edb)
+        relation_date.key && setRelationStyle(relation_date)
+        relation_edb.key && setRelationStyle(relation_edb)
       }
+
+      this.isSelectTargetValueDialog&&this.$refs.selectTargetValueRef.chooseEdb(this.$refs.selectTargetValueRef.edbInfo)
     },
 
     /* 插入值 往左往上寻找同行同列是否有符合条件的一指标一日期 */
@@ -223,10 +278,10 @@ export default {
     },
     
     // 建立插入单元格和依赖单元格关联关系
-    setRelation(data) {
+    setRelation(data,cellType=4) {
       const { insert_cell } = data;
       let relation_obj = {
-        type: 4,
+        type: cellType,
         key: insert_cell.key,
         relation_date: {
           type: 1,
@@ -291,24 +346,27 @@ export default {
 
     },
 
-    /* 选择指标 单元格类型为2*/
+    /* 选择指标 单元格类型为2 已经是指标单元格了就重置单元格 否则就视为选择指标*/
     selectTarget(e,cell) {
       const { EdbName,EdbInfoId }  = e;
 
-      cell.DataType = 2;
-      cell.DataTime = '';
-      cell.ShowValue = EdbName;
-      cell.Value = EdbName;
-      cell.EdbInfoId = EdbInfoId;
-
+      //如果已经是指标单元格了再次点击就清空
+      if(cell.DataType===2&&cell.EdbInfoId) {
+        this.clearCell()
+      }else {
+        cell.DataType = 2;
+        cell.DataTime = '';
+        cell.ShowValue = EdbName;
+        cell.Value = EdbName;
+        cell.EdbInfoId = EdbInfoId;
+      }
 
-      this.checkCellRelation(e,cell)
+      this.checkCellRelation(cell)
     },
 
     /* 输入框失焦  */
     async changeVal(e, cell) {
       // 是日期格式 DataType为1
-      //是指标 DataType为2
       // 否则是3
 
       const {value} = e.target;
@@ -319,6 +377,9 @@ export default {
         cell.EdbInfoId = 0;
         cell.DataTime = '';
       }else {
+        //指标类型不做格式处理
+        if(cell.DataType===2) return
+        
         console.log(checkDateFormat(value))
         if(checkDateFormat(value)) { //是日期格式
           cell.DataType = 1;
@@ -337,11 +398,11 @@ export default {
       }
 
       //判断是否是有插入值的依赖单元格 更新值或重置关系
-      this.checkCellRelation(e,cell)
+      this.checkCellRelation(cell)
     },
 
     /* 当前单元格是否和插入值有关联 无就不管 */
-    async checkCellRelation(e,cell) {
+    async checkCellRelation(cell) {
       if(!this.insertRelationArr.length) return
 
       const key= cell.Uid;
@@ -360,7 +421,7 @@ export default {
           //刷新插入值结果
           let params = null;
           if(relation_date.key === key && cell.DataType === 1) { //修改的是依赖日期格
-            let { EdbInfoId } = findCellByKey(this.config.data,relation_edb.key)
+            let { EdbInfoId } = findCellByKey(this.config.data,relation.key)
             params = {
               EdbInfoId,
               Date: cell.ShowValue
@@ -377,12 +438,12 @@ export default {
           const res = await sheetInterface.insertData(params)
           if(res.Ret !==200) return
 
-          !res.Data && this.updateInsertCell(relation.key,true);
+          !res.Data && this.updateInsertCell(relation.key);
   
           res.Data && this.config.data.forEach(row => {
             row.forEach(cell => {
               if(cell.Uid === relation.key) {
-                  cell.DataType = 4;
+                  cell.DataType = relation.type;
                   cell.ShowValue = res.Data;
                   cell.Value = res.Data;
                   cell.EdbInfoId = params.EdbInfoId;
@@ -400,17 +461,15 @@ export default {
     },
 
     // 清除插入值单元格式和关联关系
-    updateInsertCell(key,initValue=false) {
+    updateInsertCell(key) {
       this.config.data.forEach(row => {
         row.forEach(cell => {
           if(cell.Uid === key) {
             cell.DataType = 3;
             cell.EdbInfoId = 0;
             cell.DataTime = '';
-            if(initValue) {
-                cell.ShowValue = '';
-                cell.Value = '';
-            }
+            cell.ShowValue = '';
+            cell.Value = '';
           }
         })
       })
@@ -466,12 +525,61 @@ export default {
         'insert-col-right': this.insertCol,
         'insert-row-up': this.insertRow,
         'insert-row-down': this.insertRow,
-        'insert-value': this.insertValue
+        'insert-value': this.insertValue,
+        'choose-target': this.selectTargetOpen,
+        'reset': this.clearCell
       }
       keyMap[key] && keyMap[key](key)
+      
       this.hideContextMenu()
     },
 
+    /* 打开选择指标弹窗  
+    打开弹窗后仍可以在页面上点击 多存一个选择指标时的信息 */
+    selectTargetOpen() {
+      this.insertTargetCell = this.selectCell;
+      resetDialogCellStyle();
+      setRelationStyle({ key:this.insertTargetCell.Uid },'td-choose-insert-target')
+      this.isSelectTargetValueDialog = true;
+    },
+
+    /* 插入选择指标的值 */
+    insertSelectData({ edbId,value }) {
+
+      this.insertTargetCell.DataType = 5;
+      this.insertTargetCell.ShowValue = value;
+      this.insertTargetCell.Value = value;
+      this.insertTargetCell.EdbInfoId = edbId;
+      this.insertTargetCell.DataTime = this.selectCell.ShowValue;
+
+      this.$message.success('插入成功')
+
+      //建立新的关联关系
+      let relation = {
+        insert_cell: {
+          key: this.insertTargetCell.Uid,
+          relation_date: this.selectCell.Uid,
+          relation_edb: '',
+        }
+      }
+
+      this.setRelation(relation,5);
+
+    },
+
+    /* 清除单元格内容 格式 关联关系 */
+    clearCell() {
+      if([4,5].includes(this.selectCell.DataType)) resetRelationStyle();
+
+      this.selectCell.DataType = 3;
+      this.selectCell.ShowValue = '';
+      this.selectCell.Value = '';
+      this.selectCell.DataTime = '';
+      this.selectCell.EdbInfoId = 0;
+
+      this.checkCellRelation(this.selectCell)
+    },
+
     /* 删除行列 */
     delColOrRow() {
       let { rindex,cindex } = this.rightClickCell;
@@ -486,7 +594,8 @@ export default {
         //删除时清除关系
         if(this.insertRelationArr.length) {
           let delCellIds = this.config.data.map(row => row[index].Uid);
-          this.insertRelationArr = this.insertRelationArr.filter(_ => !delCellIds.includes(_.key)&&!delCellIds.includes(_.relation_date.key)&&!delCellIds.includes(_.relation_edb.key))
+          
+          this.clearRelationInsertCell(delCellIds);
         }
 
         this.config.data.forEach(row => {
@@ -502,13 +611,27 @@ export default {
         if(this.insertRelationArr.length) {
           //删除时清除关系
           let delCellIds = this.config.data[index].map(cell => cell.Uid);
-          this.insertRelationArr = this.insertRelationArr.filter(_ => !delCellIds.includes(_.key)&&!delCellIds.includes(_.relation_date.key)&&!delCellIds.includes(_.relation_edb.key));
+          
+          this.clearRelationInsertCell(delCellIds);
         }
 
         this.config.data.splice(index,1)
 
       }
-      console.log(this.insertRelationArr)
+      // console.log(this.insertRelationArr)
+    },
+
+    /* 删除时清除关联关系 和删除单元格有关联的插入值单元格和 */
+    clearRelationInsertCell(delCellIds) {
+      //清除关联插入值得单元格
+      let haveRelationArr = this.insertRelationArr.filter(_ => delCellIds.includes(_.relation_date.key)||delCellIds.includes(_.relation_edb.key));
+      // console.log(haveRelationArr)
+
+      haveRelationArr.forEach(relation => {
+        !delCellIds.includes(relation)&&this.updateInsertCell(relation.key);
+      })
+
+      this.insertRelationArr = this.insertRelationArr.filter(_ => !delCellIds.includes(_.key)&&!delCellIds.includes(_.relation_date.key)&&!delCellIds.includes(_.relation_edb.key))
     },
 
     /* 插入列 */
@@ -549,6 +672,17 @@ export default {
 
     },
 
+    /* 单元格类型5 浮到上面展示指标信息浮窗 */
+    async getRelationEdbInfo({EdbInfoId,DataType}) {
+      if(DataType!==5||this.disabled) return
+
+      const res = await dataBaseInterface.targetDetail({EdbInfoId})
+
+      if(res.Ret !== 200) return
+
+      this.cellrelationEdbInfo =  res.Data;
+    },
+
     /* 初始化8行5列 */
     initData(initData=null) {
       if(initData) {
@@ -645,8 +779,17 @@ export default {
       border-left: none;
       border-right: none;
     }
-    &.insert {
-      background: #ffefdd;
+    &.td-choose-insert-target::after {
+      position: absolute;
+      top: 0;
+      left: 0;
+      right: 0;
+      bottom: 0;
+      content: "";
+      display: block;
+      outline: 0;
+      border: 2px dashed orange;
+      box-shadow: 0 0 5px rgba(73, 177, 249, 0.5);
     }
   }
 
@@ -716,5 +859,13 @@ export default {
 }
 .edb-select-popover {
   width: 300px !important;
+  .edb-item {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    .edb-item-name {
+      max-width: 260px;
+    }
+  }
 }
 </style>

+ 161 - 0
src/views/datasheet_manage/components/selectTargetValueDia.vue

@@ -0,0 +1,161 @@
+<template>
+<div v-dialogDrag v-show="isShow" >
+  <div class="select-target-value-dia el-dialog" >
+    <div class="header el-dialog__header">
+      <span>选择指标</span>
+      <i class="el-icon-close" @click="cancelHandle"/>
+    </div>
+    <div class="main">
+      <selectTarget
+        ref="selectRef"
+        :selectStyleType="3"
+        @select="chooseEdb"
+      />
+
+      <ul class="data-cont">
+        <template v-if="result.List">
+          <li v-for="(item,index) in result.List" :key="index" :class="[{'choose': item.DataTime===result.Date},'data-li']">
+            <span>{{item.DataTime}}</span>
+            <span style="min-width:150px">{{item.Value}}</span>
+          </li>
+        </template>
+        <tableNoData size="mini" v-else/>
+      </ul>
+
+      <div class="dia-bot">
+        <el-button type="primary" style="margin-right: 20px" :disabled="!result.Date" @click="insertData"
+          >插入值</el-button
+        >
+        <el-button type="primary" plain @click="cancelHandle">取消</el-button>
+      </div>
+    </div>
+    
+  </div>
+</div>
+</template>
+<script>
+import * as sheetInterface from "@/api/modules/sheetApi.js";
+import selectTarget from '@/views/chartRelevance_manage/components/selectTarget.vue';
+import { resetDialogCellStyle } from "../common/customTable";
+export default {
+  props: {
+    isShow: {
+      type: Boolean,
+    }
+  },
+  components: { selectTarget },
+  data() {
+    return {
+      result: {},
+      edbInfo: null,
+      chooseItem: {
+        edbId: 0,
+        value:''
+      }
+    }
+  },
+  methods:{
+    /* 选择指标和日期获取近5期数据 */
+    async chooseEdb(edb) {
+      if(!edb){
+        this.initData();
+        return
+      } 
+
+      this.edbInfo = edb;
+      
+      if(this.$parent.selectCell.DataType !== 1){
+
+        this.$message.warning('请在表格中选择日期')
+        this.initData();
+        return
+      }
+
+      const res = await sheetInterface.getDateLatelyData({ 
+        EdbInfoId: edb.EdbInfoId,
+        Date: this.$parent.selectCell.ShowValue
+      })
+      if(res.Ret !== 200) return
+
+      this.result = res.Data;
+      if(!this.result.Date) return this.$message.warning('所选指标所选日期无值')
+      this.chooseItem = {
+        edbId: edb.EdbInfoId,
+        value: this.result.Date?this.result.List.find(_ =>_.DataTime===this.result.Date).Value.toString():''
+      }
+
+    },
+
+    insertData() {
+      this.$emit('insert',this.chooseItem)
+      this.cancelHandle();
+    },
+
+    initData() {
+      this.$refs.selectRef.search_txt='';
+      this.result = {};
+      this.edbInfo=null;
+      this.chooseItem = { edbId: 0,value: '' }
+    },
+
+    cancelHandle() {
+      this.initData();
+      this.$emit('update:isShow',false);
+      resetDialogCellStyle();
+    }
+  },
+}
+</script>
+<style scoped lang='scss'>
+@import "../../../styles/theme-vars.scss";
+.select-target-value-dia {
+  background: #fff;
+  position: fixed;
+  top: 20%;
+  left: 55%;
+  width: 500px;
+  border-radius: 2px;
+  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
+  z-index: 999;
+  .header { 
+    height: 50px;
+    font-size: 16px;
+    background: $theme-color;
+    color: #fff;
+    padding: 0 15px;
+    display: flex;
+    align-content: center;
+    justify-content: space-between;
+    span {
+      line-height: 50px;
+    }
+    .el-icon-close {
+      font-size: 20px;
+      line-height: 50px;
+      cursor: pointer;
+    }
+  }
+  .main {
+    padding: 20px 15px;
+    .data-cont {
+      margin: 15px 0;
+      border: 1px solid #DCDFE6;
+      /* padding: 20px; */
+      .data-li {
+        display: flex;
+        padding: 15px;
+        text-align: center;
+        justify-content: space-around;
+        &.choose {
+          background: #ECF5FF;
+        }
+      }
+    }
+    .dia-bot {
+      margin-top: 20px; 
+      display: flex;
+      justify-content: center;
+    }
+  }
+}
+</style>

+ 10 - 2
src/views/datasheet_manage/customSheetEdit.vue

@@ -132,8 +132,16 @@ export default {
       if(this.$refs.customTableRef.config.data.find(_ => _.EdbInfoId===EdbInfoId)) return this.$message.warning('指标已存在')
       
       const {Data} = this.$refs.customTableRef.config.data.length 
-      ? await sheetInterface.getEdbInsertDataOther({EdbInfoId: EdbInfoId,DateList: this.$refs.customTableRef.dateArr})
-      : await sheetInterface.getEdbInsertDataA({EdbInfoId: EdbInfoId,Num: 12})
+      ? await sheetInterface.getEdbInsertDataOther({
+        EdbInfoId: EdbInfoId,
+        DateList: this.$refs.customTableRef.dateArr,
+        SortType: this.$refs.customTableRef.config.order===1 ? 'desc' : 'asc'
+      })
+      : await sheetInterface.getEdbInsertDataA({
+        EdbInfoId: EdbInfoId,
+        SortType: this.$refs.customTableRef.config.order===1 ? 'desc' : 'asc',
+        Num: 12
+      })
       
       this.$refs.customTableRef.updateEdbData({
         Data: Data.Data.map(_ => ({..._,DataTimeType: 1,})),

+ 1 - 0
src/vuex/index.js

@@ -20,6 +20,7 @@ const state = {
     "rai_researcher", //权益研究员
     "ficc_researcher", //ficc研究员
   ],
+  isCollapse: false
 };
 
 export default {

+ 3 - 0
src/vuex/mutations.js

@@ -8,6 +8,9 @@ const mutations = {
   SET_DATA_AUTH(state, bool) {
     state.dataAuth = bool;
   },
+  SET_COLLAPSE(state,bool) {
+    state.isCollapse = bool;
+  }
 };
 
 export default mutations;