editLengend.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. val.map(item => {
  164. item.BuildingId = '1'
  165. item.FloorId = this.$store.state.currentFloor.gname
  166. item.ProjectId = this.$store.state.plazaId
  167. item.CategoryId = this.$cookie.get('categoryId')
  168. })
  169. let params = {
  170. postParams: {
  171. Content: val
  172. }
  173. }
  174. updateStatis(params).then(res => {
  175. if (res.Result == 'success') {
  176. this.$message({
  177. message: '操作成功',
  178. type: 'success'
  179. })
  180. this.$store.commit('SETSHOWVIEW', 1)
  181. } else {
  182. this.$message({
  183. message: '操作失败',
  184. type: 'error'
  185. })
  186. }
  187. })
  188. },
  189. // 修改图例数量
  190. changeTable(val) {
  191. this.editNum.push(val)
  192. let result = [],
  193. obj = {}
  194. for (var i = 0; i < this.editNum.length; i++) {
  195. if (!obj[this.editNum[i].GraphElementId]) {
  196. result.push(this.editNum[i])
  197. obj[this.editNum[i].GraphElementId] = true
  198. }
  199. }
  200. },
  201. // 修改隐藏为0的项目的开关
  202. changeSwitch(val) {
  203. this.$emit('handleSwich2', val)
  204. }
  205. // init() {
  206. // this.tbData1 = []
  207. // this.tbData2 = []
  208. // this.tbData3 = []
  209. // if (this.editTable.length > 0) {
  210. // this.tbData1 = this.editTable
  211. // 以下不要动 不要删
  212. // let len = this.tableData.length
  213. // if (len <= 10) {
  214. // this.tbData1 = this.tableData
  215. // } else if (len > 10 && len <= 20) {
  216. // this.tbData1 = this.tableData.slice(0, 10)
  217. // this.tbData2 = this.tableData.slice(10, len)
  218. // } else if (len > 10 && len <= 30) {
  219. // this.tbData1 = this.tableData.slice(0, 10)
  220. // this.tbData2 = this.tableData.slice(10, 20)
  221. // this.tbData3 = this.tableData.slice(20, len)
  222. // } else {
  223. // this.tbData1 = this.tableData.slice(0, parseInt(len / 3))
  224. // this.tbData2 = this.tableData.slice(parseInt(len / 3), parseInt(len / 3) * 2)
  225. // this.tbData3 = this.tableData.slice(parseInt(len / 3) * 2, len)
  226. // }
  227. // }
  228. // }
  229. },
  230. mounted() {}
  231. }
  232. </script>
  233. <style lang="less" scoped>
  234. .view {
  235. position: relative;
  236. .legend-tab2 {
  237. position: absolute;
  238. top: -44px;
  239. right: 47px;
  240. width: 385px;
  241. // width: 420px;
  242. height: 535px;
  243. // min-width: 350px;
  244. // width: auto;
  245. background: rgba(255, 255, 255, 1);
  246. box-shadow: 0px 2px 8px 0px rgba(31, 36, 41, 0.06);
  247. border-radius: 2px;
  248. border: 1px solid rgba(228, 229, 231, 1);
  249. .legend-table2-box {
  250. display: flex;
  251. justify-content: flex-end;
  252. .legend-table2 {
  253. padding: 16px 10px;
  254. height: 430px;
  255. width: 100%;
  256. }
  257. }
  258. }
  259. .dataTwo {
  260. padding: 0 5px;
  261. cursor: pointer;
  262. }
  263. .swich {
  264. position: absolute;
  265. right: 16px;
  266. bottom: 56px;
  267. span {
  268. margin-left: 8px;
  269. }
  270. }
  271. .Url-img {
  272. width: 20px;
  273. height: 22px;
  274. line-height: 20px;
  275. margin: 0 auto;
  276. img {
  277. display: block;
  278. max-width: 100%;
  279. max-height: 100%;
  280. margin: 0 auto;
  281. }
  282. }
  283. .legendFoot {
  284. position: absolute;
  285. right: 16px;
  286. bottom: 12px;
  287. }
  288. }
  289. </style>
  290. <style lang="less">
  291. .view {
  292. .el-input--mini .el-input__inner {
  293. width: 50px;
  294. }
  295. .el-input__inner {
  296. padding: 0 5px;
  297. }
  298. .legend-container .el-table td,
  299. .legend-container .el-table th {
  300. padding: 3px 0 !important;
  301. }
  302. .nullData {
  303. .el-input__inner {
  304. color: #ccc !important;
  305. }
  306. }
  307. .redData {
  308. .el-input__inner {
  309. border: 1px solid rgba(255, 77, 79, 0.5) !important;
  310. }
  311. }
  312. }
  313. </style>