editLengend.vue 13 KB

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