edbDetail.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="edb-detail-wrap" v-show="edbData.DataList">
  3. <chartInfo
  4. :edbData="edbData"
  5. :lang="lang"
  6. @refreshData="refreshData"
  7. ref="chartInfo"
  8. />
  9. <div class="info" style="display: flex;justify-content: flex-end;">
  10. <!-- <span>数据来源:{{edbData.EdbInfo.SourceName}}</span> -->
  11. <span>添加人:{{edbData.EdbInfo.SysUserRealName}}</span>
  12. </div>
  13. <ul
  14. class="value-ul"
  15. v-show="showData&&dataList.length"
  16. >
  17. <li class="value-item" style="background-color: #EBEFF6;">
  18. <span style="width:240px">日期(频度:{{EdbData.Frequency}})</span>
  19. <span style="flex:1;">值</span>
  20. </li>
  21. <li
  22. class="value-item"
  23. v-for="item in dataList.slice(0,3)"
  24. :key="item.EdbDataId"
  25. >
  26. <span class="value-label date" style="width:240px">
  27. <span style="position: relative;">
  28. <i class="new-tag" v-if="EdbData.LatestDate===item.DataTime"></i>
  29. {{ item.DataTime }}
  30. </span>
  31. </span>
  32. <span
  33. :class="['value-label',{'predict-act': item.isPredic}]"
  34. style="flex:1;"
  35. >
  36. <span :class="['value-style',{'predict-act': item.isPredic}]">{{item.Value}}</span>
  37. </span
  38. >
  39. </li>
  40. <li class="nodata value-item" v-if="!dataList.length">暂无数据</li>
  41. </ul>
  42. </div>
  43. </template>
  44. <script>
  45. import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
  46. import { dataBaseInterface } from '@/api/api.js';
  47. import chartInfo from './chartInfo.vue'
  48. export default {
  49. props:{
  50. id: Number,
  51. lang: String
  52. },
  53. components:{chartInfo},
  54. watch:{
  55. id:{
  56. handler(n){
  57. if(n){
  58. this.$nextTick(()=>{
  59. this.getDetail()
  60. })
  61. }
  62. },
  63. immediate:true
  64. },
  65. lang(newval){
  66. this.$emit('updateTit',{
  67. edb_name: this.edbData.EdbInfo.EdbName,
  68. edb_nameEn: this.edbData.EdbInfo.EdbNameEn,
  69. userid: this.edbData.EdbInfo.SysUserId
  70. })
  71. }
  72. },
  73. data() {
  74. return {
  75. edbData:{
  76. DataList:null,
  77. EdbInfo:{}
  78. },
  79. showData:false,
  80. dataList: [],
  81. EdbData:{}
  82. }
  83. },
  84. methods: {
  85. getDetail(type=''){
  86. let dateArray=[]
  87. let DateType,StartYear;
  88. if(this.$refs.chartInfo.chartInfo.ChartType==2){
  89. DateType=this.$refs.chartInfo.year_select_season
  90. StartYear=this.$refs.chartInfo.count_year_season
  91. if(!(this.$refs.chartInfo.season_year && this.$refs.chartInfo.season_year.length>0)){
  92. // 初始化日期显示
  93. let latestYear = parseInt(this.$refs.chartInfo.tableData[0].LatestDate.substring(0,4))
  94. this.$refs.chartInfo.season_year = [`${latestYear-StartYear+1}-01-01`,`${latestYear}-12-31`];
  95. }
  96. dateArray = this.$refs.chartInfo.season_year
  97. }else{
  98. DateType=this.$refs.chartInfo.year_select
  99. StartYear=this.$refs.chartInfo.count_year
  100. dateArray = this.$refs.chartInfo.select_date
  101. }
  102. preDictEdbInterface.edbChartInfo({
  103. EdbInfoId: this.id,
  104. DateType,
  105. StartDate: dateArray[0]||'',
  106. EndDate: dateArray[1]||'',
  107. ChartType:this.$refs.chartInfo.chartInfo.ChartType,
  108. // ETA1.0.5 去除了这两个参数
  109. // SeasonStartDate:this.$refs.chartInfo.season_year[0]||'',
  110. // SeasonEndDate:this.$refs.chartInfo.season_year[1]||'',
  111. Calendar:this.$refs.chartInfo.calendar_type,
  112. StartYear:StartYear || 0
  113. }).then(res=>{
  114. if(res.Ret!=200) return
  115. this.edbData.DataList=res.Data.DataList||[]
  116. this.edbData.EdbInfo={
  117. ...res.Data.EdbInfo,
  118. ChartColor:'',
  119. ChartStyle:'',
  120. ChartType:0,
  121. ChartWidth:0,
  122. MaxData:type==='saveLimit' ? this.$refs.chartInfo.tableData[0].MaxData : res.Data.EdbInfo.MaxValue,
  123. MinData:type==='saveLimit' ? this.$refs.chartInfo.tableData[0].MinData : res.Data.EdbInfo.MinValue,
  124. EdbInfoCategoryType:1,
  125. EdbInfoType:1,
  126. EdbName:res.Data.EdbInfo.EdbName,
  127. IsAxis:1
  128. }
  129. this.$emit('updateTit',{
  130. edb_name: res.Data.EdbInfo.EdbName,
  131. edb_nameEn: res.Data.EdbInfo.EdbNameEn,
  132. userid: res.Data.EdbInfo.SysUserId
  133. })
  134. this.$emit('setOpera',res.Data.Button)
  135. this.$emit('setCurrentClassify',res.Data.EdbInfo.ClassifyId)
  136. //更新图片
  137. if(type==='updateImg' || !res.Data.EdbInfo.ChartImage) {
  138. console.log(type);
  139. console.log(res.Data.EdbInfo.ChartImage);
  140. this.$nextTick(() => {
  141. this.setChartImage()
  142. })
  143. }
  144. this.getData()
  145. })
  146. },
  147. refreshData(type=''){
  148. this.getDetail(type)
  149. },
  150. changeEnOptions() {
  151. this.$emit('openEnNameDia',this.edbData.EdbInfo)
  152. },
  153. /* 关联图片 */
  154. setChartImage() {
  155. let svg = this.$refs.chartInfo.$refs.chartRef.chart.getSVG({
  156. chart:{
  157. width: 340,
  158. height: 230,
  159. }
  160. });
  161. let form = new FormData();
  162. form.append('Img', svg);
  163. this.setImageHandle(form);
  164. },
  165. async setImageHandle(form) {
  166. let { Data } = await dataBaseInterface.uploadImgSvg(form);
  167. await preDictEdbInterface.setImg({
  168. EdbInfoId: this.id,
  169. ImageUrl: Data.ResourceUrl,
  170. });
  171. },
  172. getData(){
  173. preDictEdbInterface.edbDataInfo({
  174. EdbInfoId: this.id,
  175. CurrentIndex: 1
  176. }).then(res => {
  177. this.showData = true;
  178. if(res.Ret!==200) return
  179. const {Item} = res.Data
  180. Item.PredictDataList && Item.PredictDataList.forEach(_ => {
  181. _.isPredic = true;
  182. })
  183. this.EdbData = Item
  184. this.dataList = [...Item.PredictDataList,...Item.DataList]
  185. })
  186. },
  187. },
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. .value-ul {
  192. margin-top: 10px;
  193. border-bottom: 1px solid #EBEFF6;
  194. .value-item {
  195. padding: 10px 0;
  196. border: 1px solid #EBEFF6;
  197. border-bottom: none;
  198. display: flex;
  199. justify-content: space-around;
  200. >span{
  201. padding:0 16px;
  202. box-sizing: border-box;
  203. }
  204. .value-label {
  205. position: relative;
  206. color: #666;
  207. .value-style{
  208. /* background-color: #ECF2FE;
  209. color: #0052D9; */
  210. padding:5px;
  211. border-radius: 4px;
  212. &.predict-act {
  213. color: orange;
  214. }
  215. }
  216. &.date{
  217. &::after{
  218. content: '';
  219. position:absolute;
  220. right:0;
  221. top:-14px;
  222. height:calc(100% + 28px);
  223. width:1px;
  224. background-color: #EBEFF6;
  225. }
  226. }
  227. }
  228. .predict-act {
  229. color: orange;
  230. }
  231. .new-tag {
  232. width: 6px;
  233. height: 6px;
  234. display: inline-block;
  235. position: absolute;
  236. left: -12px;
  237. top: 50%;
  238. transform: translateY(-50%);
  239. border-radius: 50%;
  240. background: #f00;
  241. }
  242. }
  243. .nodata {
  244. text-align: center;
  245. padding: 40px 0;
  246. color: #999;
  247. }
  248. }
  249. </style>