editLengend.vue 13 KB

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