editLengend.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /**
  2. *@author:Guoxiaohuan
  3. *@date:2020.05.27
  4. *@info:图例编辑状态
  5. */
  6. <template>
  7. <div class='view'>
  8. <div class='legend-tab2'>
  9. <div class='legend-table2-box'>
  10. <div class='legend-table2' v-if='tbData1.length>=0'>
  11. <el-table
  12. v-loading='loading'
  13. :header-cell-style='{background:"rgba(2,91,170,0.1)",fontFamily:"PingFangSC-Medium,PingFang SC;",color:"rgba(0,0,0,0.85);",fontSize:"12px"}'
  14. ref='multipleTable'
  15. height='430px'
  16. :data='tbData1'
  17. tooltip-effect='dark'
  18. @selection-change='handleSelectionChange'
  19. >
  20. <el-table-column prop label='项目' :show-overflow-tooltip='true' width='100'>
  21. <template slot-scope='{row}'>{{row.Name||'--'}}</template>
  22. </el-table-column>
  23. <el-table-column prop label='数量'>
  24. <template slot-scope='{row}'>
  25. <div style='width:50px'>
  26. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  27. </div>
  28. </template>
  29. </el-table-column>
  30. <el-table-column prop label='单位' width='60'>
  31. <template slot-scope='{row}'>{{row.Unit||'--'}}</template>
  32. </el-table-column>
  33. <el-table-column prop label='图例'>
  34. <template slot-scope='{row}'>
  35. <div v-if='row.Url' class='Url-img'>
  36. <img :src='`/serve/Picture/query/${row.Url}`' alt />
  37. </div>
  38. <div v-else>{{'--'}}</div>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. </div>
  43. <!-- <div class='legend-table2' v-if='tbData2.length>0'>
  44. <el-table ref='multipleTable' height='430px' :data='tbData2' tooltip-effect='dark' @selection-change='handleSelectionChange'>
  45. <el-table-column prop='project' label='项目' width='100'></el-table-column>
  46. <el-table-column prop='num' label='数量'>
  47. <template slot-scope='{row}'>
  48. <div style='width:50px'>
  49. <el-input v-model='row.num' size='mini'></el-input>
  50. </div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop='type' label='单位' width='60'></el-table-column>
  54. <el-table-column prop='lege' label='图例'>
  55. <template slot-scope='scope'>{{ scope.row.lege }}</template>
  56. </el-table-column>
  57. </el-table>
  58. </div>-->
  59. <!-- <div class='legend-table2' v-if='tbData3.length>0'>
  60. <el-table ref='multipleTable' height='430px' :data='tbData3' tooltip-effect='dark' @selection-change='handleSelectionChange'>
  61. <el-table-column prop='project' label='项目' width='100'></el-table-column>
  62. <el-table-column prop='num' label='数量'>
  63. <template slot-scope='{row}'>
  64. <div style='width:50px'>
  65. <el-input v-model='row.num' size='mini'></el-input>
  66. </div>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop='type' label='单位' width='60'></el-table-column>
  70. <el-table-column prop='lege' label='图例'>
  71. <template slot-scope='scope'>{{ scope.row.lege }}</template>
  72. </el-table-column>
  73. </el-table>
  74. </div>-->
  75. </div>
  76. <div class='swich'>
  77. <el-switch v-model='value' @change='witchChange'></el-switch>
  78. <span>隐藏数量为0的项目</span>
  79. </div>
  80. <div class='legendFoot'>
  81. <el-button size='mini' @click='cancel'>取消</el-button>
  82. <el-button size='mini' @click='save' type='primary'>保存</el-button>
  83. </div>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. export default {
  89. props: ['editTable', 'loading'],
  90. data() {
  91. return {
  92. value: false,
  93. showT: false,
  94. tbData1: [],
  95. tbData2: [],
  96. tbData3: [],
  97. editNum: []
  98. }
  99. },
  100. methods: {
  101. handleSelectionChange(val) {
  102. this.multipleSelection = val
  103. },
  104. cancel() {
  105. this.$emit('cance')
  106. },
  107. changeTable(val) {
  108. this.editNum.push(val)
  109. var obj = {}
  110. this.editNum = this.editNum.reduce(function(item, next) {
  111. obj[next.key] ? '' : (obj[next.key] = true && item.push(next))
  112. return item
  113. }, [])
  114. },
  115. witchChange(val) {
  116. console.log(val)
  117. },
  118. save() {
  119. console.log(this.editNum)
  120. this.$emit('saveNum', this.editNum)
  121. },
  122. init() {
  123. this.tbData1 = []
  124. this.tbData2 = []
  125. this.tbData3 = []
  126. if (this.editTable.length > 0) {
  127. this.tbData1 = this.editTable
  128. // 以下不要动 不要删
  129. // let len = this.tableData.length
  130. // if (len <= 10) {
  131. // this.tbData1 = this.tableData
  132. // } else if (len > 10 && len <= 20) {
  133. // this.tbData1 = this.tableData.slice(0, 10)
  134. // this.tbData2 = this.tableData.slice(10, len)
  135. // } else if (len > 10 && len <= 30) {
  136. // this.tbData1 = this.tableData.slice(0, 10)
  137. // this.tbData2 = this.tableData.slice(10, 20)
  138. // this.tbData3 = this.tableData.slice(20, len)
  139. // } else {
  140. // this.tbData1 = this.tableData.slice(0, parseInt(len / 3))
  141. // this.tbData2 = this.tableData.slice(parseInt(len / 3), parseInt(len / 3) * 2)
  142. // this.tbData3 = this.tableData.slice(parseInt(len / 3) * 2, len)
  143. // }
  144. }
  145. }
  146. },
  147. mounted() {
  148. // this.init()
  149. }
  150. }
  151. </script>
  152. <style lang="less" scoped>
  153. .view {
  154. position: relative;
  155. .legend-tab2 {
  156. position: absolute;
  157. top: -44px;
  158. right: 44px;
  159. height: 535px;
  160. min-width: 350px;
  161. width: auto;
  162. background: rgba(255, 255, 255, 1);
  163. box-shadow: 0px 2px 8px 0px rgba(31, 36, 41, 0.06);
  164. border-radius: 2px;
  165. border: 1px solid rgba(228, 229, 231, 1);
  166. .legend-table2-box {
  167. display: flex;
  168. justify-content: flex-end;
  169. .legend-table2 {
  170. padding: 16px 10px;
  171. height: 430px;
  172. width: 345px;
  173. }
  174. }
  175. }
  176. .swich {
  177. position: absolute;
  178. right: 16px;
  179. bottom: 56px;
  180. span {
  181. margin-left: 8px;
  182. }
  183. }
  184. .Url-img {
  185. width: 20px;
  186. height: 22px;
  187. line-height: 20px;
  188. img {
  189. width: 100%;
  190. height: 100%;
  191. }
  192. }
  193. .legendFoot {
  194. position: absolute;
  195. right: 16px;
  196. bottom: 12px;
  197. }
  198. }
  199. </style>
  200. <style lang="less">
  201. .view {
  202. .el-input--mini .el-input__inner {
  203. width: 50px;
  204. }
  205. .el-input__inner {
  206. padding: 0 5px;
  207. }
  208. .legend-container .el-table td,
  209. .legend-container .el-table th {
  210. padding: 6px 0 !important;
  211. }
  212. }
  213. </style>