lzTable.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <table width="auto" border="0">
  3. <template v-if="tableType === 'header'">
  4. <tr
  5. v-for="(item, index) in headerArr"
  6. :key="index"
  7. align="center"
  8. class="header"
  9. >
  10. <th>{{ labelArr.get(item) }}</th>
  11. <td v-for="(data, sub_index) in tableOption" :key="sub_index">
  12. <template v-if="source!=='baiinfo'">
  13. {{ (item === 'Frequency' && source === 'lz') ? frequencyType.get(data[item]) : data[item] }}
  14. </template>
  15. <!-- 百川盈孚数据源 频度和单位需要可编辑 -->
  16. <template v-else>
  17. <span>
  18. {{data[item]}}
  19. <span v-if="data['IndexCode']&&(item==='Frequency'||item==='Unit')">
  20. <img
  21. v-permission="permissionBtn.dataSourcePermission.bcyfData_edit"
  22. src="~@/assets/img/set_m/edit.png"
  23. alt="edit"
  24. style="width: 14px; height: 14px; margin-left: 5px;cursor:pointer;"
  25. @click.stop="editTarget(data)"
  26. />
  27. </span>
  28. </span>
  29. </template>
  30. </td>
  31. </tr>
  32. </template>
  33. <template v-else>
  34. <tr
  35. v-for="(date,index) in dateArr"
  36. :key="index"
  37. align="center"
  38. >
  39. <th>{{date}}</th>
  40. <td v-for="(data, sub_index) in tableOption" :key="sub_index">
  41. {{data.DataList && data.DataList.find(item => date === item.DataTime) ?
  42. data.DataList.find(item => date === item.DataTime)[dynamic_key]
  43. : ''}}
  44. </td>
  45. </tr>
  46. </template>
  47. </table>
  48. </template>
  49. <script>
  50. export default {
  51. name: '',
  52. props: {
  53. tableOption: {
  54. type: Array,
  55. },
  56. tableType: {
  57. type: String
  58. },
  59. dateArr: {
  60. type: Array,
  61. },
  62. source: {
  63. type: String,
  64. defalut:'lz'
  65. }
  66. },
  67. computed: {
  68. headerArr(){
  69. let arr=['QuotaName','LzCode','Frequency','UnitName','ModifyTime']
  70. if(this.source==='gl'){
  71. arr=['IndexName','IndexCode','FrequencyName','UnitName','UpdateTime']
  72. }
  73. if(this.source==='smm'){
  74. arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  75. }
  76. if(this.source==='coal'){
  77. arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  78. }
  79. if(this.source==='baiinfo'){
  80. arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  81. }
  82. if(this.source==='yyzx'){
  83. arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  84. }
  85. return arr
  86. },
  87. labelArr(){
  88. let temMap=new Map([
  89. ['QuotaName', '指标名称'],
  90. ['LzCode', '指标ID'],
  91. ['Frequency', '频度'],
  92. ['UnitName', '单位'],
  93. ['ModifyTime', '更新时间'],
  94. ])
  95. if(this.source==='gl'){
  96. temMap=new Map([
  97. ['IndexName', '指标名称'],
  98. ['IndexCode', '指标ID'],
  99. ['FrequencyName', '频度'],
  100. ['UnitName', '单位'],
  101. ['UpdateTime', '更新时间'],
  102. ])
  103. }
  104. if(this.source==='smm'){
  105. temMap=new Map([
  106. ['IndexName', '指标名称'],
  107. ['IndexCode', '指标ID'],
  108. ['Frequency', '频度'],
  109. ['Unit', '单位'],
  110. ['ModifyTime', '更新时间'],
  111. ])
  112. }
  113. if(this.source==='coal'){
  114. temMap=new Map([
  115. ['IndexName', '指标名称'],
  116. ['IndexCode', '指标ID'],
  117. ['Frequency', '频度'],
  118. ['Unit', '单位'],
  119. ['ModifyTime', '更新时间'],
  120. ])
  121. }
  122. if(this.source==='baiinfo'){
  123. temMap=new Map([
  124. ['IndexName', '指标名称'],
  125. ['IndexCode', '指标ID'],
  126. ['Frequency', '频度'],
  127. ['Unit', '单位'],
  128. ['ModifyTime', '更新时间'],
  129. ])
  130. }
  131. if(this.source==='yyzx'){
  132. temMap=new Map([
  133. ['IndexName', '指标名称'],
  134. ['IndexCode', '指标ID'],
  135. ['Frequency', '频度'],
  136. ['Unit', '单位'],
  137. ['ModifyTime', '更新时间'],
  138. ])
  139. }
  140. return temMap
  141. },
  142. dynamic_key(){
  143. let key='InputValue'
  144. if(['smm','baiinfo','coal','yyzx'].includes(this.source)){
  145. key='Value'
  146. }
  147. return key
  148. }
  149. },
  150. data() {
  151. return {
  152. // dynamic_key: (this.source === 'smm'||this.source ==='baiinfo')? 'Value'
  153. // :this.source==='coal'?'Value': 'InputValue',
  154. // headerArr: this.source === 'gl'
  155. // ? ['IndexName','IndexCode','FrequencyName','UnitName','UpdateTime']
  156. // : this.source === 'smm'
  157. // ? ['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  158. // : this.source==='coal'
  159. // ? ['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  160. // : this.source==='baiinfo'
  161. // ? ['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  162. // :['QuotaName','LzCode','Frequency','UnitName','ModifyTime'],
  163. frequencyType:new Map([
  164. [1,'日度'],
  165. [2,'周度'],
  166. [3,'月度'],
  167. [4,'季度'],
  168. [5,'年度'],
  169. [99,'无固定频率'],
  170. ]),
  171. // labelArr: this.source === 'gl' ? new Map([
  172. // ['IndexName', '指标名称'],
  173. // ['IndexCode', '指标ID'],
  174. // ['FrequencyName', '频度'],
  175. // ['UnitName', '单位'],
  176. // ['UpdateTime', '更新时间'],
  177. // ]): this.source === 'smm' ? new Map([
  178. // ['IndexName', '指标名称'],
  179. // ['IndexCode', '指标ID'],
  180. // ['Frequency', '频度'],
  181. // ['Unit', '单位'],
  182. // ['ModifyTime', '更新时间'],
  183. // ]) :this.source === 'coal' ? new Map([
  184. // ['IndexName', '指标名称'],
  185. // ['IndexCode', '指标ID'],
  186. // ['Frequency', '频度'],
  187. // ['Unit', '单位'],
  188. // ['ModifyTime', '更新时间'],
  189. // ]) :this.source==='baiinfo'?new Map([
  190. // ['IndexName', '指标名称'],
  191. // ['IndexCode', '指标ID'],
  192. // ['Frequency', '频度'],
  193. // ['Unit', '单位'],
  194. // ['ModifyTime', '更新时间'],
  195. // ]):new Map([
  196. // ['QuotaName', '指标名称'],
  197. // ['LzCode', '指标ID'],
  198. // ['Frequency', '频度'],
  199. // ['UnitName', '单位'],
  200. // ['ModifyTime', '更新时间'],
  201. // ]),
  202. };
  203. },
  204. methods: {
  205. initCss() {
  206. if( this.source !== 'lz') {
  207. $('table').find('td').css({
  208. minWidth: '299px',
  209. maxWidth: '300px'
  210. })
  211. }
  212. },
  213. editTarget(data){
  214. this.$emit('editTarget',data)
  215. }
  216. },
  217. created() {},
  218. updated() {
  219. this.initCss()
  220. },
  221. mounted() {
  222. },
  223. };
  224. </script>
  225. <style lang="scss" scoped>
  226. table {
  227. font-size: 14px;
  228. color: #666;
  229. td,
  230. th {
  231. min-width: 179px;
  232. max-width: 180px;
  233. word-break: break-all;
  234. border: 1px solid #dcdfe6;
  235. height: 40px;
  236. background-color: #fff;
  237. }
  238. td {
  239. &:first-child {
  240. border-left: none;
  241. }
  242. }
  243. th {
  244. position: sticky;
  245. border-right: none;
  246. left: 0;
  247. &:before {
  248. content: " ";
  249. width: 1px;
  250. height: 100%;
  251. position: absolute;
  252. right: 0;
  253. top: 0;
  254. border-right: 1px solid #dcdfe6;
  255. }
  256. }
  257. .header {
  258. th,td {
  259. background-color: #F0F2F5;
  260. }
  261. &:last-child {
  262. th,td {
  263. border-bottom: none;
  264. }
  265. }
  266. }
  267. }
  268. </style>