addLegend.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div class='add-legend'>
  3. <el-dialog :title='title' :visible.sync='dialogVisible'>
  4. <!-- <add-list v-show='title=="" && GraphCategoryId' ref='searchList' :GraphCategoryId='GraphCategoryId' @mesg='mesg'></add-list> -->
  5. <add-form ref='add' :ruleForm='info' @addSuccess='addSuccess' @updateSuccess='updateSuccess' :title='title'></add-form>
  6. <span slot='footer' class='dialog-footer'>
  7. <el-button @click='dialogVisible = false,cancal()' size='small'>取 消</el-button>
  8. <el-button type='primary' @click='save' size='small'>确 定</el-button>
  9. </span>
  10. </el-dialog>
  11. <TransferSelectModal
  12. defaultExpandAll
  13. default-expand-all
  14. v-if='treeData.length'
  15. :modalShow='modalShow4'
  16. placeholder='搜索'
  17. :linkage='false'
  18. :lastStage='true'
  19. :data='treeData'
  20. @cancel='treeCancel'
  21. @confirm='treeConfirm'
  22. />
  23. </div>
  24. </template>
  25. <script>
  26. import addForm from './addForm'
  27. import addList from '../legendRules/addList'
  28. import { groupByCategory, updateRelation } from '@/api/legendLibrary.js'
  29. export default {
  30. data() {
  31. return {
  32. dialogVisible: false,
  33. info: {
  34. Name: '',
  35. Type: 'None',
  36. Unit: '',
  37. FillColor: '',
  38. Url: '',
  39. LineWidth: '',
  40. LineDash: '',
  41. InfoTypeId: [] //铺位可视化typeid
  42. // InfoLocal: [], //工程信息化位置与设备分类
  43. // InfoSystem: [] //工程信息化专业/系统
  44. },
  45. title: '',
  46. GraphCategoryId: 'DTXT',
  47. modalShow4: false,
  48. treeData: []
  49. }
  50. },
  51. components: { addForm, addList },
  52. methods: {
  53. open(row, title, GraphCategoryId) {
  54. this.title = title
  55. this.GraphCategoryId = GraphCategoryId
  56. console.log(title)
  57. if (GraphCategoryId) {
  58. groupByCategory({}).then(res => {
  59. this.treeData = []
  60. this.treeData = res.Data.map(i => this.getTree(i))
  61. })
  62. //treeSelect
  63. this.modalShow4 = true
  64. this.info = {
  65. Name: '',
  66. Type: 'None',
  67. Unit: '',
  68. FillColor: '',
  69. Url: '',
  70. InfoTypeId: [] //铺位可视化typeid
  71. // InfoLocal: [], //工程信息化位置与设备分类
  72. // InfoSystem: [] //工程信息化专业/系统
  73. }
  74. } else if (title == '添加图例库') {
  75. this.dialogVisible = true
  76. this.info = {
  77. Name: '',
  78. Type: 'None',
  79. Unit: '',
  80. FillColor: '',
  81. Url: '',
  82. InfoTypeId: [] //铺位可视化typeid
  83. // InfoLocal: [], //工程信息化位置与设备分类
  84. // InfoSystem: [] //工程信息化专业/系统
  85. }
  86. } else if (title == '修改图例库') {
  87. this.dialogVisible = true
  88. this.info = row
  89. // 图例库规则中的transform
  90. } else if (title == '' && this.$refs.searchList) {
  91. this.$refs.searchList.queryAll()
  92. }
  93. },
  94. getTree(data) {
  95. return {
  96. id: data.Id,
  97. name: data.Name,
  98. children: data.Children && data.Children.length > 0 ? data.Children.map(i => this.getTree(i)) : []
  99. }
  100. },
  101. cancal() {
  102. this.info = {
  103. Name: '',
  104. Type: 'None',
  105. Unit: '',
  106. FillColor: '',
  107. Url: '',
  108. InfoTypeId: [] //铺位可视化typeid
  109. // InfoLocal: [], //工程信息化位置与设备分类
  110. // InfoSystem: [] //工程信息化专业/系统
  111. }
  112. },
  113. mesg() {
  114. this.$emit('mesg')
  115. },
  116. updateSuccess() {
  117. this.$emit('updateSuccess')
  118. },
  119. addSuccess() {
  120. this.$emit('addSuccess')
  121. this.cancal()
  122. },
  123. save() {
  124. // FillColor,Color,Name
  125. if (this.info.Name == '') {
  126. this.$message.info('请填写图例名称')
  127. return false
  128. }
  129. // else if (this.info.Type == 'Zone') {
  130. // if (this.info.FillColor == '') {
  131. // this.$message.info('请选择填充色以及透明度')
  132. // return false
  133. // }
  134. // if (this.info.Color == '') {
  135. // this.$message.info('请选择边框颜色')
  136. // return false
  137. // }
  138. // } else if (this.info.Type == 'Line') {
  139. // if (this.info.Color == '') {
  140. // this.$message.info('请选择边框颜色')
  141. // return false
  142. // }
  143. // }
  144. else {
  145. if (this.info.Type != 'Image' && this.info.Type != 'None') {
  146. this.$refs.add.saveImg()
  147. } else {
  148. if (this.title == '添加图例库') {
  149. this.$refs.add.create()
  150. this.$emit('addSuccess')
  151. } else if (this.title == '修改图例库') {
  152. this.$refs.add.update()
  153. this.$emit('updateSuccess')
  154. }
  155. }
  156. this.dialogVisible = false
  157. // if (!this.title || this.info.Type == 'None') {
  158. // this.$refs.add.create()
  159. // }
  160. }
  161. },
  162. treeConfirm(ids, dataObj) {
  163. let postParams = {
  164. GraphCategoryId: this.GraphCategoryId.join(' '),
  165. GraphElementIds: ids
  166. }
  167. updateRelation({ postParams }).then(res => {
  168. if (res.Result == 'success') {
  169. this.$message.success('添加成功!')
  170. this.$emit('mesg')
  171. }
  172. })
  173. },
  174. treeCancel() {
  175. this.modalShow4 = false
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang='less' scoped>
  181. .add-legend {
  182. }
  183. </style>
  184. <style lang='less'>
  185. .add-legend {
  186. .el-dialog {
  187. width: 840px;
  188. height: 509px;
  189. }
  190. .el-dialog__footer {
  191. position: absolute;
  192. bottom: 20px;
  193. right: 20px;
  194. }
  195. }
  196. </style>