childData.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="data-wrapper" v-if="showData">
  3. <el-table
  4. :data="tableData"
  5. style="box-shadow: 0px 3px 6px rgba(155, 170, 219, 0.2)"
  6. border
  7. >
  8. <el-table-column
  9. v-for="item in tableColums"
  10. :key="item.label"
  11. :label="item.label"
  12. :width="item.widthsty"
  13. :min-width="item.minwidthsty"
  14. align="center"
  15. >
  16. <template #header>
  17. <span>{{ item.label }}</span>
  18. </template>
  19. <template slot-scope="{row}">
  20. <span v-if="item.key === 'Unit'">{{ lang === 'en'?row.UnitEn||getUnitTrans(row.Unit):getUnitTrans(row.Unit) }}</span>
  21. <span v-else-if="item.key === 'Frequency'">{{ lang === 'en' ? row.FrequencyEn||getFrequencyTrans(row.Frequency):getFrequencyTrans(row.Frequency) }}</span>
  22. <span v-else>{{ row[item.key] }}</span>
  23. </template>
  24. </el-table-column>
  25. <div slot="empty" style="padding: 50px 0 320px">
  26. <tableNoData text="暂无数据" size="mini"/>
  27. </div>
  28. </el-table>
  29. <el-table
  30. :data="tableData"
  31. style="box-shadow: 0px 3px 6px rgba(155, 170, 219, 0.2);"
  32. border>
  33. <el-table-column
  34. v-for="item in tableColumsTwo"
  35. :key="item.label"
  36. :label="item.label"
  37. :width="item.widthsty"
  38. :min-width="item.minwidthsty"
  39. align="center"
  40. >
  41. <template #header>
  42. <span>{{ item.label }}</span>
  43. </template>
  44. <template slot-scope="scope">
  45. <span>{{ scope.row[item.key] }}</span>
  46. </template>
  47. </el-table-column>
  48. <div slot="empty" style="padding: 50px 0 320px;">
  49. <tableNoData :text="defaultWarn"/>
  50. </div>
  51. </el-table>
  52. <ul
  53. class="value-ul"
  54. ref="valueUl"
  55. @scroll="scrollHandle"
  56. v-show="dataList.length"
  57. >
  58. <li
  59. class="value-item"
  60. v-for="item in dataList"
  61. :key="item.EdbDataId"
  62. >
  63. <span class="value-label">
  64. <span style="position: relative;">
  65. <i class="new-tag" v-if="tableData[0].LatestDate===item.DataTime"></i>
  66. {{item.DataTime}}
  67. </span>
  68. </span>
  69. <span
  70. :class="['value-label',{'predict-act': item.isPredic}]"
  71. style="min-width: 200px; text-align: center"
  72. ><span :class="['value-style',{'predict-act': item.isPredic}]">{{item.Value}}</span></span
  73. >
  74. </li>
  75. <li class="nodata value-item" v-if="!dataList.length"><!-- 暂无数据 -->{{$t('Table.prompt_slogan')}}</li>
  76. </ul>
  77. </div>
  78. </template>
  79. <script>
  80. import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
  81. export default {
  82. props: {
  83. id: Number,
  84. lang: String
  85. },
  86. watch: {
  87. id(newval) {
  88. this.getData()
  89. },
  90. lang(newval) {
  91. this.$emit('updateTit',{
  92. edb_name: this.tableData[0].EdbName,
  93. edb_nameEn: this.tableData[0].EdbNameEn,
  94. userid: this.tableData[0].SysUserId})
  95. }
  96. },
  97. computed: {
  98. /*表格列 */
  99. tableColums(){
  100. return [
  101. {
  102. label: this.$t('Edb.Detail.e_id'),
  103. key: 'EdbCode',
  104. widthsty: '280px'
  105. },
  106. {
  107. label: this.$t('Edb.Detail.e_name'),
  108. key: 'EdbName',
  109. minwidthsty: '200px'
  110. },
  111. {
  112. label: this.$t('Edb.Detail.e_fre'),
  113. key: 'Frequency',
  114. widthsty: '100px'
  115. },
  116. {
  117. label: this.$t('Edb.Detail.e_unit'),
  118. key: 'Unit',
  119. widthsty: '140px'
  120. },
  121. ]
  122. },
  123. tableColumsTwo() {
  124. return [
  125. {
  126. label: this.$t('Edb.Detail.e_menu'),
  127. key: 'Menu',
  128. widthsty: '280px',
  129. },
  130. {
  131. label: this.$t('Edb.Detail.e_start_time'),
  132. key: 'StartDate',
  133. minwidthsty: '100px',
  134. },
  135. {
  136. label: this.$t('Edb.Detail.predict_end_date'),
  137. key: 'EndDate',
  138. minwidthsty: '100px'
  139. },
  140. {
  141. label: this.$t('Edb.Detail.e_update_time'),
  142. key: 'ModifyTime',
  143. minminwidthsty: '120px',
  144. },
  145. {
  146. label: this.$t('Edb.creater'),
  147. key: 'SysUserRealName',
  148. widthsty: '140px',
  149. }
  150. ]
  151. },
  152. },
  153. data() {
  154. return {
  155. showData: false,
  156. tableData: [],
  157. page_no: 1,
  158. dataList: [],
  159. };
  160. },
  161. methods: {
  162. /* 获取数据 */
  163. getData() {
  164. preDictEdbInterface.edbDataInfo({
  165. EdbInfoId: this.id,
  166. CurrentIndex: this.page_no
  167. }).then(res => {
  168. this.showData = true;
  169. if(res.Ret !== 200) return
  170. const { Item } = res.Data;
  171. this.tableData = [Item] || [];
  172. Item.PredictDataList && Item.PredictDataList.forEach(_ => {
  173. _.isPredic = true;
  174. })
  175. const classify_arr = res.Data.ClassifyList || [];
  176. let str = '';
  177. classify_arr.length && classify_arr.reverse().map((item) => str += item.ClassifyName + '/');
  178. this.$set(Item,'Menu',str);
  179. this.haveMore = this.page_no < res.Data.Paging.Pages;
  180. this.dataList = this.page_no === 1 ? [...Item.PredictDataList,...Item.DataList] : [...this.dataList,...Item.DataList];
  181. this.$emit('updateTit',{
  182. edb_name: Item.EdbName,
  183. edb_nameEn: Item.EdbNameEn,
  184. userid: Item.SysUserId,
  185. })
  186. this.$emit('setCurrentClassify',Item.ClassifyId)
  187. })
  188. },
  189. changeLangOptions() {
  190. this.$emit('openLangInfoDia',this.tableData[0])
  191. },
  192. /* 滚动加载 */
  193. scrollHandle: _.throttle(function() {
  194. let scrollTop = this.$refs.valueUl.scrollTop;
  195. let clientHeight = this.$refs.valueUl.clientHeight;
  196. let scrollHeight = this.$refs.valueUl.scrollHeight;
  197. if(scrollTop + clientHeight >= scrollHeight-10 && this.haveMore){
  198. this.page_no ++;
  199. this.getData();
  200. }
  201. },200),
  202. },
  203. mounted() {
  204. this.getData()
  205. },
  206. };
  207. </script>
  208. <style lang="scss">
  209. .data-wrapper {
  210. .el-table--enable-row-transition .el-table__body td{
  211. background: #fff !important;
  212. }
  213. .el-table td, .el-table th.is-leaf {
  214. background: #F2F6FA !important;
  215. }
  216. }
  217. </style>
  218. <style scoped lang="scss">
  219. .data-wrapper {
  220. .value-ul {
  221. margin-top: 10px;
  222. border-bottom: 1px solid #dcdfe6;
  223. border-top: 1px solid #dcdfe6;
  224. /* max-height: 520px; */
  225. max-height: calc(100vh - 445px);
  226. overflow-y: auto;
  227. .value-item {
  228. /* width: 100%; */
  229. padding: 14px 0;
  230. border: 1px solid #dcdfe6;
  231. border-bottom: none;
  232. display: flex;
  233. justify-content: space-around;
  234. &:first-child { border-top: none; }
  235. span{
  236. flex: 1;
  237. text-align: center;
  238. }
  239. .value-label {
  240. position: relative;
  241. color: #666;
  242. .value-style{
  243. /* background-color: #ECF2FE;
  244. color: #0052D9; */
  245. padding:5px;
  246. border-radius: 4px;
  247. &.predict-act{
  248. color: orange;
  249. }
  250. }
  251. }
  252. .predict-act {
  253. color: orange;
  254. }
  255. .new-tag {
  256. width: 6px;
  257. height: 6px;
  258. display: inline-block;
  259. position: absolute;
  260. left: -12px;
  261. top: 50%;
  262. transform: translateY(-50%);
  263. border-radius: 50%;
  264. background: #f00;
  265. }
  266. }
  267. .nodata {
  268. text-align: center;
  269. padding: 40px 0;
  270. color: #999;
  271. }
  272. }
  273. }
  274. </style>