legendremarks.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /**
  2. *@author:Guoxiaohuan
  3. *@date:2020.05.27
  4. *@info:楼层功能-编辑图例备注
  5. */
  6. <template>
  7. <div class='editModel' v-if='visible'>
  8. <a-modal v-model='visible' :title='title' :closable='false' :maskClosable='false' :width='648' :footer='null'>
  9. <div class='edit-x' @click='handlCancel'>X</div>
  10. <div class='edit_container' style='width:600px;height:156px'>
  11. <quill-editor
  12. v-model='remarksTexts'
  13. :options='editorOption'
  14. @blur='onEditorBlur($event)'
  15. @focus='onEditorFocus($event)'
  16. @change='onEditorChange($event)'
  17. @ready='onEditorReady($event)'
  18. ></quill-editor>
  19. <p class='p1'>{{valLen||remarksText.length}}/200</p>
  20. </div>
  21. <div class='edit-foot'>
  22. <span @click='handlCancel'>取消</span>
  23. <span @click='handleOk'>保存</span>
  24. </div>
  25. </a-modal>
  26. </div>
  27. </template>
  28. <script>
  29. import { updateRead } from '@/api/public.js'
  30. import { mapGetters } from 'vuex'
  31. import { queryRead } from '@/api/public.js'
  32. export default {
  33. name: 'EditdMarks',
  34. data() {
  35. return {
  36. valLen: 0, //输入字数限制
  37. remarksTexts: '', //展示的备注
  38. text1: '主要设备房包括:冷源机房,热源机房,开闭站,配变电所(室),发电机房,消防水泵房,消防高位水箱间,生活水泵房,慧云机房,垃圾房',
  39. text2: '图例后×的数字,代表此位置的数量',
  40. editorOption: {
  41. modules: {
  42. toolbar: [['bold', 'underline'], [{ color: [] }], [{ list: 'ordered' }]]
  43. },
  44. theme: 'snow',
  45. placeholder: '请输入内容...'
  46. },
  47. title: '编辑图例备注',
  48. visible: false
  49. }
  50. },
  51. computed: {
  52. ...mapGetters(['remarksText', 'typeNum', 'planNum'])
  53. },
  54. methods: {
  55. // 点击取消
  56. handlCancel() {
  57. if (this.remarksTexts != this.remarksText) {
  58. this.$confirm('是否保存编辑后的备注?', '提示', {
  59. confirmButtonText: '保存',
  60. cancelButtonText: '取消',
  61. type: 'warning'
  62. })
  63. .then(() => {
  64. this.handleOk()
  65. })
  66. .catch(() => {
  67. this.$message({
  68. type: 'info',
  69. message: '已取消保存'
  70. })
  71. this.visible = false
  72. })
  73. } else {
  74. this.visible = false
  75. }
  76. },
  77. // val为传过来的备注
  78. showModal() {
  79. // this.$emit('queryMarks')
  80. // this.$emit('')
  81. // return
  82. this.query()
  83. this.visible = true
  84. // this.remarksTexts = this.remarksText
  85. },
  86. query() {
  87. if (this.remarksText) {
  88. if (this.planNum && this.typeNum) {
  89. this.remarksTexts = `<ol style="padding-left: 1.5em;"><li>${this.text1}</li><li>${this.text2}</li></ol>`
  90. } else if (this.planNum) {
  91. this.remarksTexts = `<ol style="padding-left: 1.5em;"><li>${this.text1}</li></ol>`
  92. } else if (this.typeNum) {
  93. this.remarksTexts = `<ol style="padding-left: 1.5em;" ><li>${this.text2}</li></ol>`
  94. } else {
  95. this.remarksTexts = ''
  96. }
  97. if (this.remarksText.search(`${this.text1}`) != -1) {
  98. this.remarksTexts = this.remarksText
  99. } else {
  100. if (this.planNum) {
  101. this.remarksTexts = `${this.remarksText}<ol style="padding-left: 1.5em;"><li>${this.text1}</li></ol>`
  102. } else {
  103. this.remarksTexts = this.remarksText
  104. }
  105. }
  106. if (this.remarksText.search(`${this.text2}`) != -1) {
  107. this.remarksTexts = this.remarksText
  108. } else {
  109. if (this.planNum) {
  110. this.remarksTexts = `${this.remarksText}<ol style="padding-left: 1.5em;"><li>${this.text2}</li></ol>`
  111. } else {
  112. this.remarksTexts = this.remarksText
  113. }
  114. }
  115. } else {
  116. if (this.planNum && this.typeNum) {
  117. this.remarksTexts = `<ol style="padding-left: 1.5em;"><li>${this.text1}</li><li>${this.text2}</li></ol>`
  118. } else if (this.planNum) {
  119. this.remarksTexts = `<ol style="padding-left: 1.5em;"><li>${this.text1}</li></ol>`
  120. } else if (this.typeNum) {
  121. this.remarksTexts = `<ol style="padding-left: 1.5em;" ><li>${this.text2}</li></ol>`
  122. } else {
  123. this.remarksTexts = ''
  124. }
  125. }
  126. },
  127. // 更新底图备注
  128. markUpdate(val) {
  129. let params = {
  130. postParams: {
  131. graphId: this.$cookie.get('graphId'),
  132. projectId: this.$store.state.plazaId,
  133. Note: val
  134. }
  135. }
  136. updateRead(params).then(res => {
  137. this.$message({
  138. showClose: true,
  139. message: '更新成功',
  140. type: 'success'
  141. })
  142. this.$emit('queryMarks')
  143. this.visible = false
  144. })
  145. },
  146. // 点击保存
  147. handleOk() {
  148. this.markUpdate(this.remarksTexts)
  149. },
  150. onEditorReady(editor) {},
  151. onEditorBlur(val) {},
  152. onEditorFocus(val) {},
  153. onEditorChange(val) {
  154. val.quill.deleteText(200, 6)
  155. if (this.remarksTexts === '') {
  156. this.valLen = 0
  157. } else {
  158. this.valLen = val.quill.getLength() - 1
  159. }
  160. if (val.html) {
  161. this.remarksTexts = val.html
  162. }
  163. }
  164. },
  165. mounted() {}
  166. }
  167. </script>
  168. <style lang="less" >
  169. .editModel {
  170. .ant-modal-body {
  171. padding: 0 24px 35px !important;
  172. }
  173. .edit_container {
  174. .ql-editor {
  175. padding: 12px 15px 4px;
  176. }
  177. .ql-toolbar.ql-snow .ql-formats {
  178. margin-right: 0px;
  179. }
  180. }
  181. }
  182. </style>
  183. <style lang="less" scoped>
  184. .edit-x {
  185. position: absolute;
  186. width: 9px;
  187. height: 10px;
  188. color: #000000;
  189. right: 20px;
  190. top: 20px;
  191. cursor: pointer;
  192. }
  193. .edit_container {
  194. margin: 0px;
  195. .p1 {
  196. position: absolute;
  197. bottom: 65px;
  198. right: 30px;
  199. margin-bottom: 0;
  200. }
  201. }
  202. .edit-foot {
  203. height: 30px;
  204. width: 100%;
  205. margin-top: 20px;
  206. display: flex;
  207. justify-content: flex-end;
  208. padding-top: 10px;
  209. span {
  210. height: 32px;
  211. line-height: 32px;
  212. border-radius: 2px;
  213. width: 65px;
  214. text-align: center;
  215. font-size: 14px;
  216. font-family: PingFangSC-Regular, PingFang SC;
  217. font-weight: 400;
  218. cursor: pointer;
  219. }
  220. span:nth-of-type(1) {
  221. background: rgba(255, 255, 255, 1);
  222. border: 1px solid rgba(0, 0, 0, 0.15);
  223. margin-right: 8px;
  224. color: rgba(0, 0, 0, 0.65);
  225. }
  226. span:nth-of-type(2) {
  227. color: rgba(255, 255, 255, 1);
  228. background: linear-gradient(180deg, rgba(54, 156, 247, 1) 0%, rgba(2, 91, 170, 1) 100%);
  229. }
  230. }
  231. .quill-editor {
  232. height: 130px;
  233. }
  234. // 修改保存按钮背景色
  235. /deep/ .ant-btn-primary {
  236. background: linear-gradient(180deg, rgba(54, 156, 247, 1) 0%, rgba(2, 91, 170, 1) 100%);
  237. }
  238. </style>