lzTable.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. let sourceTypeOne = ['smm','coal','baiinfo','yyzx','icpi','coalWord']
  71. if(this.source==='gl'){
  72. arr=['IndexName','IndexCode','FrequencyName','UnitName','UpdateTime']
  73. }else if(sourceTypeOne.includes(this.source)){
  74. arr=['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  75. }
  76. return arr
  77. },
  78. labelArr(){
  79. let temMap=new Map([
  80. ['QuotaName', '指标名称'],
  81. ['LzCode', '指标ID'],
  82. ['Frequency', '频度'],
  83. ['UnitName', '单位'],
  84. ['ModifyTime', '更新时间'],
  85. ])
  86. let sourceTypeOne = ['smm','coal','baiinfo','yyzx','icpi','coalWord']
  87. if(this.source==='gl'){
  88. temMap=new Map([
  89. ['IndexName', '指标名称'],
  90. ['IndexCode', '指标ID'],
  91. ['FrequencyName', '频度'],
  92. ['UnitName', '单位'],
  93. ['UpdateTime', '更新时间'],
  94. ])
  95. }else if(sourceTypeOne.includes(this.source)){
  96. temMap=new Map([
  97. ['IndexName', '指标名称'],
  98. ['IndexCode', '指标ID'],
  99. ['Frequency', '频度'],
  100. ['Unit', '单位'],
  101. ['ModifyTime', '更新时间'],
  102. ])
  103. }
  104. return temMap
  105. },
  106. dynamic_key(){
  107. let key='InputValue'
  108. if(['smm','baiinfo','coal','yyzx','icpi'].includes(this.source)){
  109. key='Value'
  110. }else if(this.source=='coalWord'){
  111. key='DealValue'
  112. }
  113. return key
  114. }
  115. },
  116. data() {
  117. return {
  118. // dynamic_key: (this.source === 'smm'||this.source ==='baiinfo')? 'Value'
  119. // :this.source==='coal'?'Value': 'InputValue',
  120. // headerArr: this.source === 'gl'
  121. // ? ['IndexName','IndexCode','FrequencyName','UnitName','UpdateTime']
  122. // : this.source === 'smm'
  123. // ? ['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  124. // : this.source==='coal'
  125. // ? ['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  126. // : this.source==='baiinfo'
  127. // ? ['IndexName','IndexCode','Frequency','Unit','ModifyTime']
  128. // :['QuotaName','LzCode','Frequency','UnitName','ModifyTime'],
  129. frequencyType:new Map([
  130. [1,'日度'],
  131. [2,'周度'],
  132. [3,'月度'],
  133. [4,'季度'],
  134. [5,'年度'],
  135. [99,'无固定频率'],
  136. ]),
  137. // labelArr: this.source === 'gl' ? new Map([
  138. // ['IndexName', '指标名称'],
  139. // ['IndexCode', '指标ID'],
  140. // ['FrequencyName', '频度'],
  141. // ['UnitName', '单位'],
  142. // ['UpdateTime', '更新时间'],
  143. // ]): this.source === 'smm' ? new Map([
  144. // ['IndexName', '指标名称'],
  145. // ['IndexCode', '指标ID'],
  146. // ['Frequency', '频度'],
  147. // ['Unit', '单位'],
  148. // ['ModifyTime', '更新时间'],
  149. // ]) :this.source === 'coal' ? new Map([
  150. // ['IndexName', '指标名称'],
  151. // ['IndexCode', '指标ID'],
  152. // ['Frequency', '频度'],
  153. // ['Unit', '单位'],
  154. // ['ModifyTime', '更新时间'],
  155. // ]) :this.source==='baiinfo'?new Map([
  156. // ['IndexName', '指标名称'],
  157. // ['IndexCode', '指标ID'],
  158. // ['Frequency', '频度'],
  159. // ['Unit', '单位'],
  160. // ['ModifyTime', '更新时间'],
  161. // ]):new Map([
  162. // ['QuotaName', '指标名称'],
  163. // ['LzCode', '指标ID'],
  164. // ['Frequency', '频度'],
  165. // ['UnitName', '单位'],
  166. // ['ModifyTime', '更新时间'],
  167. // ]),
  168. };
  169. },
  170. methods: {
  171. initCss() {
  172. if( this.source !== 'lz') {
  173. $('table').find('td').css({
  174. minWidth: '299px',
  175. maxWidth: '300px'
  176. })
  177. }
  178. },
  179. editTarget(data){
  180. this.$emit('editTarget',data)
  181. }
  182. },
  183. created() {},
  184. updated() {
  185. this.initCss()
  186. },
  187. mounted() {
  188. },
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. table {
  193. font-size: 14px;
  194. color: #666;
  195. td,
  196. th {
  197. min-width: 179px;
  198. max-width: 180px;
  199. word-break: break-all;
  200. border: 1px solid #dcdfe6;
  201. height: 40px;
  202. background-color: #fff;
  203. }
  204. td {
  205. &:first-child {
  206. border-left: none;
  207. }
  208. }
  209. th {
  210. position: sticky;
  211. border-right: none;
  212. left: 0;
  213. &:before {
  214. content: " ";
  215. width: 1px;
  216. height: 100%;
  217. position: absolute;
  218. right: 0;
  219. top: 0;
  220. border-right: 1px solid #dcdfe6;
  221. }
  222. }
  223. .header {
  224. th,td {
  225. background-color: #F0F2F5;
  226. }
  227. &:last-child {
  228. th,td {
  229. border-bottom: none;
  230. }
  231. }
  232. }
  233. }
  234. </style>