editLengend.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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='editTable.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='editTable'
  17. tooltip-effect='dark'
  18. width='100%'
  19. @selection-change='handleSelectionChange'
  20. >
  21. <el-table-column prop label='项目' :show-overflow-tooltip='true'>
  22. <template slot-scope='{row}'>{{row.Name||'--'}}</template>
  23. </el-table-column>
  24. <el-table-column prop label='数量'>
  25. <template slot-scope='{row}'>
  26. <div v-if='row.IsModify'>
  27. <div v-if='row.Num!=row.RealNum ' class='redData'>
  28. <el-tooltip class='item' effect='dark' :content='`当前图例 ${row.Name} 与平面图中的不一致,平面图中为xx`' placement='top'>
  29. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  30. </el-tooltip>
  31. </div>
  32. <div v-else-if='!row.Num' class='nullData'>
  33. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  34. </div>
  35. <div v-else style='width:50px'>
  36. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  37. </div>
  38. </div>
  39. <!-- 第二部分数据 -->
  40. <div v-else>
  41. <el-tooltip
  42. v-if='!row.IsModify'
  43. class='item'
  44. effect='dark'
  45. :content='`当前图例 ${row.Name},从平面图中直接获取,如需编辑请修改平面图`'
  46. placement='top'
  47. >
  48. <div class='dataTwo'>{{row.Num}}</div>
  49. </el-tooltip>
  50. </div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop label='单位'>
  54. <template slot-scope='{row}'>{{row.Unit||'--'}}</template>
  55. </el-table-column>
  56. <el-table-column prop label='图例'>
  57. <template slot-scope='{row}'>
  58. <div v-if='row.Url' class='Url-img'>
  59. <img :src='`/serve/topology-wanda/Picture/query/${row.Url}`' alt />
  60. </div>
  61. <div v-else>{{'--'}}</div>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. </div>
  66. <!-- <div class='legend-table2' v-if='tbData2.length>0'>
  67. <el-table ref='multipleTable' height='430px' :data='tbData2' tooltip-effect='dark' @selection-change='handleSelectionChange'>
  68. <el-table-column prop='project' label='项目' width='100'></el-table-column>
  69. <el-table-column prop='num' label='数量'>
  70. <template slot-scope='{row}'>
  71. <div style='width:50px'>
  72. <el-input v-model='row.num' size='mini'></el-input>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. <el-table-column prop='type' label='单位' width='60'></el-table-column>
  77. <el-table-column prop='lege' label='图例'>
  78. <template slot-scope='scope'>{{ scope.row.lege }}</template>
  79. </el-table-column>
  80. </el-table>
  81. </div>-->
  82. <!-- <div class='legend-table2' v-if='tbData3.length>0'>
  83. <el-table ref='multipleTable' height='430px' :data='tbData3' tooltip-effect='dark' @selection-change='handleSelectionChange'>
  84. <el-table-column prop='project' label='项目' width='100'></el-table-column>
  85. <el-table-column prop='num' label='数量'>
  86. <template slot-scope='{row}'>
  87. <div style='width:50px'>
  88. <el-input v-model='row.num' size='mini'></el-input>
  89. </div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column prop='type' label='单位' width='60'></el-table-column>
  93. <el-table-column prop='lege' label='图例'>
  94. <template slot-scope='scope'>{{ scope.row.lege }}</template>
  95. </el-table-column>
  96. </el-table>
  97. </div>-->
  98. </div>
  99. <div class='swich'>
  100. <el-switch v-model='value' @change='changeSwitch'></el-switch>
  101. <span>隐藏数量为0的项目</span>
  102. </div>
  103. <div class='legendFoot'>
  104. <el-button size='mini' @click='cancel'>取消</el-button>
  105. <el-button size='mini' v-if='editNum.length<=0' disabled type='primary'>保存</el-button>
  106. <el-button size='mini' v-else @click='save' type='primary'>保存</el-button>
  107. </div>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. export default {
  113. props: ['editTable', 'loading'],
  114. data() {
  115. return {
  116. value: false,
  117. tbData1: [],
  118. tbData2: [],
  119. tbData3: [],
  120. editNum: []
  121. }
  122. },
  123. methods: {
  124. handleSelectionChange(val) {
  125. this.multipleSelection = val
  126. },
  127. cancel() {
  128. this.save()
  129. // this.$emit('cance')
  130. },
  131. changeTable(val) {
  132. this.editNum.push(val)
  133. var obj = {}
  134. this.editNum = this.editNum.reduce(function(item, next) {
  135. obj[next.key] ? '' : (obj[next.key] = true && item.push(next))
  136. return item
  137. }, [])
  138. },
  139. changeSwitch(val) {
  140. this.$emit('handleSwich2', val)
  141. },
  142. save() {
  143. this.$confirm('图例中的数据发生变化, 是否需要保存?', {
  144. confirmButtonText: '保存',
  145. cancelButtonText: '放弃修改',
  146. type: 'warning'
  147. })
  148. .then(() => {
  149. this.$emit('saveNum', this.editNum)
  150. })
  151. .catch(() => {
  152. this.$message({
  153. type: 'info',
  154. message: '已放弃修改'
  155. })
  156. this.$emit('saveNum')
  157. })
  158. },
  159. init() {
  160. this.tbData1 = []
  161. this.tbData2 = []
  162. this.tbData3 = []
  163. if (this.editTable.length > 0) {
  164. this.tbData1 = this.editTable
  165. // 以下不要动 不要删
  166. // let len = this.tableData.length
  167. // if (len <= 10) {
  168. // this.tbData1 = this.tableData
  169. // } else if (len > 10 && len <= 20) {
  170. // this.tbData1 = this.tableData.slice(0, 10)
  171. // this.tbData2 = this.tableData.slice(10, len)
  172. // } else if (len > 10 && len <= 30) {
  173. // this.tbData1 = this.tableData.slice(0, 10)
  174. // this.tbData2 = this.tableData.slice(10, 20)
  175. // this.tbData3 = this.tableData.slice(20, len)
  176. // } else {
  177. // this.tbData1 = this.tableData.slice(0, parseInt(len / 3))
  178. // this.tbData2 = this.tableData.slice(parseInt(len / 3), parseInt(len / 3) * 2)
  179. // this.tbData3 = this.tableData.slice(parseInt(len / 3) * 2, len)
  180. // }
  181. }
  182. }
  183. },
  184. mounted() {}
  185. }
  186. </script>
  187. <style lang="less" scoped>
  188. .view {
  189. position: relative;
  190. .legend-tab2 {
  191. position: absolute;
  192. top: -44px;
  193. right: 44px;
  194. width: 385px;
  195. // width: 420px;
  196. height: 535px;
  197. // min-width: 350px;
  198. // width: auto;
  199. background: rgba(255, 255, 255, 1);
  200. box-shadow: 0px 2px 8px 0px rgba(31, 36, 41, 0.06);
  201. border-radius: 2px;
  202. border: 1px solid rgba(228, 229, 231, 1);
  203. .legend-table2-box {
  204. display: flex;
  205. justify-content: flex-end;
  206. .legend-table2 {
  207. padding: 16px 10px;
  208. height: 430px;
  209. width: 100%;
  210. }
  211. }
  212. }
  213. .dataTwo {
  214. padding: 0 5px;
  215. cursor: pointer;
  216. }
  217. .swich {
  218. position: absolute;
  219. right: 16px;
  220. bottom: 56px;
  221. span {
  222. margin-left: 8px;
  223. }
  224. }
  225. .Url-img {
  226. width: 20px;
  227. height: 22px;
  228. line-height: 20px;
  229. img {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. }
  234. .legendFoot {
  235. position: absolute;
  236. right: 16px;
  237. bottom: 12px;
  238. }
  239. }
  240. </style>
  241. <style lang="less">
  242. .view {
  243. .el-input--mini .el-input__inner {
  244. width: 50px;
  245. }
  246. .el-input__inner {
  247. padding: 0 5px;
  248. }
  249. .legend-container .el-table td,
  250. .legend-container .el-table th {
  251. padding: 6px 0 !important;
  252. }
  253. .nullData {
  254. .el-input__inner {
  255. color: #ccc !important;
  256. }
  257. }
  258. .redData {
  259. .el-input__inner {
  260. border: 1px solid rgba(255, 77, 79, 0.5) !important;
  261. }
  262. }
  263. }
  264. </style>