lzTable.vue 6.9 KB

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