editLengend.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. :max-height='tableHeigth'
  16. :data='editTable'
  17. tooltip-effect='dark'
  18. width='100%'
  19. @selection-change='handleSelectionChange'
  20. id='lenged_tab'
  21. >
  22. <el-table-column prop label='项目' :show-overflow-tooltip='true'>
  23. <template slot-scope='{row}'>{{row.Name||'--'}}</template>
  24. </el-table-column>
  25. <el-table-column prop label='数量'>
  26. <template slot-scope='{row}'>
  27. <div v-if='row.IsModify'>
  28. <div v-if='row.Num!=row.RealNum && (row.Num!=null && row.RealNum!=null)' class='redData'>
  29. <el-tooltip
  30. class='item'
  31. effect='dark'
  32. :content='`当前图例 ${row.Name} 与平面图中的不一致,平面图中为${row.RealNum}`'
  33. placement='top'
  34. >
  35. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  36. </el-tooltip>
  37. </div>
  38. <div v-else-if='row.Num==null||row.RealNum==null'>
  39. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  40. </div>
  41. <div v-else-if='!row.Num' class='nullData'>
  42. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  43. </div>
  44. <div v-else style='width:50px'>
  45. <el-input @change='changeTable(row)' v-model='row.Num' size='mini'></el-input>
  46. </div>
  47. </div>
  48. <!-- 第二部分数据 -->
  49. <div v-else>
  50. <el-tooltip
  51. v-if='!row.IsModify'
  52. class='item'
  53. effect='dark'
  54. :content='`当前图例 ${row.Name},从平面图中直接获取,如需编辑请修改平面图`'
  55. placement='top'
  56. >
  57. <div class='dataTwo'>{{row.Num}}</div>
  58. </el-tooltip>
  59. </div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop label='单位'>
  63. <template slot-scope='{row}'>{{row.Unit||'--'}}</template>
  64. </el-table-column>
  65. <el-table-column prop label='图例' align='center'>
  66. <template slot-scope='{row}'>
  67. <div v-if='row.Url' class='Url-img'>
  68. <img :src='`/serve/topology-wanda/Picture/query/${row.Url}`' alt />
  69. </div>
  70. <div v-else>{{'--'}}</div>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. </div>
  75. <!-- <div class='legend-table2' v-if='tbData2.length>0'>
  76. <el-table ref='multipleTable' height='430px' :data='tbData2' tooltip-effect='dark' @selection-change='handleSelectionChange'>
  77. <el-table-column prop='project' label='项目' width='100'></el-table-column>
  78. <el-table-column prop='num' label='数量'>
  79. <template slot-scope='{row}'>
  80. <div style='width:50px'>
  81. <el-input v-model='row.num' size='mini'></el-input>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column prop='type' label='单位' width='60'></el-table-column>
  86. <el-table-column prop='lege' label='图例'>
  87. <template slot-scope='scope'>{{ scope.row.lege }}</template>
  88. </el-table-column>
  89. </el-table>
  90. </div>-->
  91. <!-- <div class='legend-table2' v-if='tbData3.length>0'>
  92. <el-table ref='multipleTable' height='430px' :data='tbData3' tooltip-effect='dark' @selection-change='handleSelectionChange'>
  93. <el-table-column prop='project' label='项目' width='100'></el-table-column>
  94. <el-table-column prop='num' label='数量'>
  95. <template slot-scope='{row}'>
  96. <div style='width:50px'>
  97. <el-input v-model='row.num' size='mini'></el-input>
  98. </div>
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop='type' label='单位' width='60'></el-table-column>
  102. <el-table-column prop='lege' label='图例'>
  103. <template slot-scope='scope'>{{ scope.row.lege }}</template>
  104. </el-table-column>
  105. </el-table>
  106. </div>-->
  107. </div>
  108. <div class='lengend-text'>本楼层没有的图例数据填为 0</div>
  109. <div class='swich'>
  110. <el-switch v-model='value' @change='changeSwitch'></el-switch>
  111. <span>隐藏数量为0的项目</span>
  112. </div>
  113. <div class='legendFoot'>
  114. <el-button size='mini' @click='cancel'>取消</el-button>
  115. <el-button size='mini' v-if='editNum.length==0' type='primary' disabled style='opacity: 0.5'>保存</el-button>
  116. <el-button size='mini' v-else @click='save' type='primary'>保存</el-button>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import { updateStatis } from '@/api/public.js'
  123. import { mapGetters } from 'vuex'
  124. export default {
  125. props: ['editTable', 'loading', 'tableHeigth'],
  126. data() {
  127. return {
  128. value: false,
  129. tbData1: [],
  130. tbData2: [],
  131. tbData3: [],
  132. editNum: []
  133. }
  134. },
  135. computed: {
  136. ...mapGetters(['plazaId'])
  137. },
  138. methods: {
  139. handleSelectionChange(val) {
  140. this.multipleSelection = val
  141. },
  142. // 编辑图例取消
  143. cancel() {
  144. if (this.editNum.length > 0) {
  145. this.$confirm('图例中的数据发生变化, 是否需要保存?', {
  146. confirmButtonText: '保存',
  147. cancelButtonText: '放弃修改',
  148. type: 'warning'
  149. })
  150. .then(() => {
  151. this.$emit('saveNum', this.editNum)
  152. })
  153. .catch(() => {
  154. this.$message({
  155. type: 'info',
  156. message: '已放弃修改'
  157. })
  158. this.editNum = []
  159. this.$emit('saveNum', this.editNum)
  160. })
  161. } else {
  162. this.$store.commit('SETSHOWVIEW', 1)
  163. this.$emit('saveNum', this.editNum)
  164. }
  165. },
  166. // 编辑图里保存
  167. save() {
  168. this.queryEdit(this.editNum)
  169. },
  170. // 编辑数量
  171. queryEdit(val) {
  172. let arr = []
  173. if (val.length > 0) {
  174. val.forEach(e => {
  175. let obj = {
  176. BuildingId: '1',
  177. Num: e.Num == '' ? null : Number(e.Num),
  178. GraphElementId: e.GraphElementId,
  179. FloorId: this.$cookie.get('floorMapId'),
  180. ProjectId: e.ProjectId,
  181. CategoryId: e.GraphCategoryId
  182. }
  183. arr.push(obj)
  184. })
  185. }
  186. let params = {
  187. postParams: {
  188. Content: arr
  189. }
  190. }
  191. updateStatis(params)
  192. .then(res => {
  193. if (res.Result == 'success') {
  194. this.$message({
  195. message: '操作成功',
  196. type: 'success'
  197. })
  198. this.$emit('changeSwitch', true)
  199. this.$store.commit('SETSHOWVIEW', 1)
  200. } else {
  201. this.$message({
  202. message: '操作失败',
  203. type: 'error'
  204. })
  205. }
  206. })
  207. .catch(err => {
  208. this.$message({
  209. message: err,
  210. type: 'error'
  211. })
  212. })
  213. },
  214. // 修改图例数量
  215. changeTable(val) {
  216. this.editNum.push(val)
  217. let result = [],
  218. obj = {}
  219. for (var i = 0; i < this.editNum.length; i++) {
  220. if (!obj[this.editNum[i].GraphElementId]) {
  221. result.push(this.editNum[i])
  222. obj[this.editNum[i].GraphElementId] = true
  223. }
  224. }
  225. this.editNum = result
  226. },
  227. // 修改隐藏为0的项目的开关
  228. changeSwitch(val) {
  229. this.$emit('handleSwich2', val)
  230. }
  231. // init() {
  232. // this.tbData1 = []
  233. // this.tbData2 = []
  234. // this.tbData3 = []
  235. // if (this.editTable.length > 0) {
  236. // this.tbData1 = this.editTable
  237. // 以下不要动 不要删
  238. // let len = this.tableData.length
  239. // if (len <= 10) {
  240. // this.tbData1 = this.tableData
  241. // } else if (len > 10 && len <= 20) {
  242. // this.tbData1 = this.tableData.slice(0, 10)
  243. // this.tbData2 = this.tableData.slice(10, len)
  244. // } else if (len > 10 && len <= 30) {
  245. // this.tbData1 = this.tableData.slice(0, 10)
  246. // this.tbData2 = this.tableData.slice(10, 20)
  247. // this.tbData3 = this.tableData.slice(20, len)
  248. // } else {
  249. // this.tbData1 = this.tableData.slice(0, parseInt(len / 3))
  250. // this.tbData2 = this.tableData.slice(parseInt(len / 3), parseInt(len / 3) * 2)
  251. // this.tbData3 = this.tableData.slice(parseInt(len / 3) * 2, len)
  252. // }
  253. // }
  254. // },
  255. },
  256. mounted() {},
  257. watch: {
  258. editTable: {
  259. handler() {
  260. setTimeout(() => {
  261. let tabHeight = document.getElementById('lenged_tab').offsetHeight
  262. let dom = document.getElementsByClassName('legend-tab2')[0]
  263. let dom2 = document.getElementsByClassName('legend-table2')[0]
  264. console.log('tabHeight', tabHeight)
  265. if (!dom) {
  266. return
  267. }
  268. dom.style.height = tabHeight + 100 + 'px'
  269. dom2.style.height = tabHeight + 100 + 'px'
  270. })
  271. },
  272. deep: true,
  273. immediate: true
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="less" scoped>
  279. .view {
  280. // position: relative;
  281. .legend-tab2 {
  282. position: absolute;
  283. top: 0;
  284. right: 47px;
  285. background: rgba(255, 255, 255, 1);
  286. box-shadow: 0px 2px 8px 0px rgba(31, 36, 41, 0.06);
  287. border-radius: 2px;
  288. border: 1px solid rgba(228, 229, 231, 1);
  289. .legend-table2-box {
  290. display: flex;
  291. justify-content: flex-end;
  292. .legend-table2 {
  293. padding: 16px 10px;
  294. height: 430px;
  295. width: 100%;
  296. }
  297. }
  298. }
  299. .dataTwo {
  300. padding: 0 5px;
  301. cursor: pointer;
  302. }
  303. .swich {
  304. position: absolute;
  305. right: 16px;
  306. bottom: 56px;
  307. span {
  308. margin-left: 8px;
  309. }
  310. }
  311. .Url-img {
  312. width: 20px;
  313. height: 22px;
  314. line-height: 20px;
  315. margin: 0 auto;
  316. img {
  317. display: block;
  318. max-width: 100%;
  319. max-height: 100%;
  320. margin: 0 auto;
  321. }
  322. }
  323. .lengend-text {
  324. font-size: 12px;
  325. color: red;
  326. padding-left: 16px;
  327. margin-top: -37px;
  328. }
  329. .legendFoot {
  330. position: absolute;
  331. right: 16px;
  332. bottom: 12px;
  333. }
  334. }
  335. </style>
  336. <style lang="less">
  337. .view {
  338. .el-input--mini .el-input__inner {
  339. width: 50px;
  340. }
  341. .el-input__inner {
  342. padding: 0 5px;
  343. }
  344. .legend-container .el-table td,
  345. .legend-container .el-table th {
  346. padding: 3px 0 !important;
  347. }
  348. .nullData {
  349. .el-input__inner {
  350. color: #ccc !important;
  351. }
  352. }
  353. .redData {
  354. .el-input__inner {
  355. border: 1px solid rgba(255, 77, 79, 0.5) !important;
  356. }
  357. }
  358. }
  359. </style>