editLengend.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. import { updateStatis } from '@/api/public.js'
  118. export default {
  119. props: ['editTable', 'loading'],
  120. data() {
  121. return {
  122. value: false,
  123. tbData1: [],
  124. tbData2: [],
  125. tbData3: [],
  126. editNum: []
  127. }
  128. },
  129. methods: {
  130. handleSelectionChange(val) {
  131. this.multipleSelection = val
  132. },
  133. // 编辑图例取消
  134. cancel() {
  135. if (this.editNum.length > 0) {
  136. this.$confirm('图例中的数据发生变化, 是否需要保存?', {
  137. confirmButtonText: '保存',
  138. cancelButtonText: '放弃修改',
  139. type: 'warning'
  140. })
  141. .then(() => {
  142. this.$emit('saveNum', this.editNum)
  143. })
  144. .catch(() => {
  145. this.$message({
  146. type: 'info',
  147. message: '已放弃修改'
  148. })
  149. this.editNum = []
  150. this.$emit('saveNum', this.editNum)
  151. this.$store.commit('SETSHOWVIEW', 1)
  152. })
  153. } else {
  154. this.$store.commit('SETSHOWVIEW', 1)
  155. }
  156. },
  157. // 编辑图里保存
  158. save() {
  159. this.queryEdit(this.editNum)
  160. },
  161. // 编辑数量
  162. queryEdit(val) {
  163. let params = {
  164. postParams: {
  165. Content: val
  166. }
  167. }
  168. updateStatis(params).then(res => {
  169. if (res.Result == 'success') {
  170. this.$message({
  171. message: '操作成功',
  172. type: 'success'
  173. })
  174. this.$store.commit('SETSHOWVIEW', 1)
  175. } else {
  176. this.$message({
  177. message: '操作失败',
  178. type: 'error'
  179. })
  180. }
  181. })
  182. },
  183. // 修改图例数量
  184. changeTable(val) {
  185. this.editNum.push(val)
  186. let result = [],
  187. obj = {}
  188. for (var i = 0; i < this.editNum.length; i++) {
  189. if (!obj[this.editNum[i].GraphElementId]) {
  190. result.push(this.editNum[i])
  191. obj[this.editNum[i].GraphElementId] = true
  192. }
  193. }
  194. },
  195. // 修改隐藏为0的项目的开关
  196. changeSwitch(val) {
  197. this.$emit('handleSwich2', val)
  198. }
  199. // init() {
  200. // this.tbData1 = []
  201. // this.tbData2 = []
  202. // this.tbData3 = []
  203. // if (this.editTable.length > 0) {
  204. // this.tbData1 = this.editTable
  205. // 以下不要动 不要删
  206. // let len = this.tableData.length
  207. // if (len <= 10) {
  208. // this.tbData1 = this.tableData
  209. // } else if (len > 10 && len <= 20) {
  210. // this.tbData1 = this.tableData.slice(0, 10)
  211. // this.tbData2 = this.tableData.slice(10, len)
  212. // } else if (len > 10 && len <= 30) {
  213. // this.tbData1 = this.tableData.slice(0, 10)
  214. // this.tbData2 = this.tableData.slice(10, 20)
  215. // this.tbData3 = this.tableData.slice(20, len)
  216. // } else {
  217. // this.tbData1 = this.tableData.slice(0, parseInt(len / 3))
  218. // this.tbData2 = this.tableData.slice(parseInt(len / 3), parseInt(len / 3) * 2)
  219. // this.tbData3 = this.tableData.slice(parseInt(len / 3) * 2, len)
  220. // }
  221. // }
  222. // }
  223. },
  224. mounted() {}
  225. }
  226. </script>
  227. <style lang="less" scoped>
  228. .view {
  229. position: relative;
  230. .legend-tab2 {
  231. position: absolute;
  232. top: -44px;
  233. right: 47px;
  234. width: 385px;
  235. // width: 420px;
  236. height: 535px;
  237. // min-width: 350px;
  238. // width: auto;
  239. background: rgba(255, 255, 255, 1);
  240. box-shadow: 0px 2px 8px 0px rgba(31, 36, 41, 0.06);
  241. border-radius: 2px;
  242. border: 1px solid rgba(228, 229, 231, 1);
  243. .legend-table2-box {
  244. display: flex;
  245. justify-content: flex-end;
  246. .legend-table2 {
  247. padding: 16px 10px;
  248. height: 430px;
  249. width: 100%;
  250. }
  251. }
  252. }
  253. .dataTwo {
  254. padding: 0 5px;
  255. cursor: pointer;
  256. }
  257. .swich {
  258. position: absolute;
  259. right: 16px;
  260. bottom: 56px;
  261. span {
  262. margin-left: 8px;
  263. }
  264. }
  265. .Url-img {
  266. width: 20px;
  267. height: 22px;
  268. line-height: 20px;
  269. margin: 0 auto;
  270. img {
  271. display: block;
  272. max-width: 100%;
  273. max-height: 100%;
  274. margin: 0 auto;
  275. }
  276. }
  277. .legendFoot {
  278. position: absolute;
  279. right: 16px;
  280. bottom: 12px;
  281. }
  282. }
  283. </style>
  284. <style lang="less">
  285. .view {
  286. .el-input--mini .el-input__inner {
  287. width: 50px;
  288. }
  289. .el-input__inner {
  290. padding: 0 5px;
  291. }
  292. .legend-container .el-table td,
  293. .legend-container .el-table th {
  294. padding: 3px 0 !important;
  295. }
  296. .nullData {
  297. .el-input__inner {
  298. color: #ccc !important;
  299. }
  300. }
  301. .redData {
  302. .el-input__inner {
  303. border: 1px solid rgba(255, 77, 79, 0.5) !important;
  304. }
  305. }
  306. }
  307. </style>