editLengend.vue 11 KB

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