MapTextEdit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-loading="loading"
  5. :show-close="false"
  6. :close-on-click-modal="false"
  7. :visible.sync="isShow"
  8. :title="mteStr === 'polygonAdd' || mteStr === 'polylineAdd' ? '多边形或折线操作' : '文字或圆点操作'"
  9. :fullscreen="false"
  10. width="400px"
  11. custom-class="xl-dialog"
  12. center
  13. >
  14. <base-form ref="ruleForm" :data="formData" :is-inline="false" label-width="70px">
  15. </base-form>
  16. <div class="scoped-color-quick" v-if="mteStr === 'polygonAdd' || mteStr === 'polylineAdd'">
  17. <div class="t">快速选择颜色</div>
  18. <div :class="fillColor === item.color ? 'op cur' : 'op'" v-for="(item, i) in colorArr" @click="colorHandle(item)" :style="`background: ${item.color}`" :key="i">{{item.t}}</div>
  19. <div style="padding-top: 10px;">
  20. <div :class="fillColor === item.color ? 'op cur' : 'op'" v-for="(item, i) in colorArr2" @click="colorHandle(item)" :style="`background: ${item.color}`" :key="i">{{item.t}}</div>
  21. </div>
  22. </div>
  23. <div class="xl-form">
  24. <div class="xl-form-footer">
  25. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  26. <el-button v-if="curObj.obj" class="xl-form-btn t1" @click="close('confirm')">保存</el-button>
  27. <el-button v-else class="xl-form-btn t3" @click="close('confirm')">去画图</el-button>
  28. </div>
  29. </div>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. import { arrToObj } from '@/utils'
  35. export default {
  36. components: { },
  37. mixins,
  38. props: {
  39. isShow: Boolean,
  40. curObj: Object,
  41. mteStr: String,
  42. },
  43. data() {
  44. return {
  45. loading: false,
  46. formData: [],
  47. fillColor: '#ff003f',
  48. strokeColor: '#ff003f',
  49. colorArr: [
  50. {color: '#ff0', t: '新楼盘'},
  51. {color: '#bb9c2c', t: '二手房'},
  52. {color: '#e8d0e6', t: '还建房'},
  53. {color: '#ff9149', t: '幼儿园'},
  54. {color: '#ff7fbf', t: '小初中'},
  55. // {color: '#60c68b', t: ''},
  56. {color: '#e77ad4', t: '高中'},
  57. {color: '#fb6557', t: '专本科'},
  58. ],
  59. colorArr2: [
  60. {color: '#ff003f', t: '纯商业'},
  61. {color: '#999', t: '商综合'},
  62. {color: '#007299', t: '政府企业办公楼'},
  63. {color: '#00ff3f', t: '公园'},
  64. {color: '#4da4ee', t: '医院'},
  65. {color: '#dc3021', t: '变电站污水处理厂等'},
  66. {color: '#f8a41c', t: '商业娱乐'},
  67. {color: '#795ab8', t: 'other3'},
  68. ],
  69. cObj: {},
  70. estateObj: {},
  71. schoolObj: {},
  72. facilityObj: {},
  73. }
  74. },
  75. watch: {
  76. isShow: function(val) {
  77. if (val) {
  78. this.estateObj = {}
  79. this.schoolObj = {}
  80. this.facilityObj = {}
  81. this.cObj = JSON.parse(JSON.stringify(this.curObj))
  82. this.getDef()
  83. }
  84. },
  85. },
  86. methods: {
  87. getDef (str) {
  88. let params = { ...this.curObj.obj }
  89. let remoteEstateOptions = []
  90. if (params.estateObj) {
  91. let estateObj = {}
  92. if (typeof(params.estateObj) === 'object') {
  93. estateObj = params.estateObj
  94. } else {
  95. estateObj = JSON.parse(params.estateObj)
  96. }
  97. if (estateObj.id) {
  98. params.estate_id = estateObj.id
  99. remoteEstateOptions = [{ keyRO: estateObj.estate_name, valRO: estateObj.id }]
  100. }
  101. }
  102. let remoteSchoolOptions = []
  103. if (params.schoolObj) {
  104. let schoolObj = {}
  105. if (typeof(params.schoolObj) === 'object') {
  106. schoolObj = params.schoolObj
  107. } else {
  108. schoolObj = JSON.parse(params.schoolObj)
  109. }
  110. if (schoolObj.id) {
  111. params.school_id = schoolObj.id
  112. remoteSchoolOptions = [{ keyRO: schoolObj.school_name, valRO: schoolObj.id }]
  113. }
  114. }
  115. let remoteFacilityOptions = []
  116. if (params.facilityObj) {
  117. const facilityObj = JSON.parse(params.facilityObj)
  118. if (facilityObj.id) {
  119. params.facility_id = facilityObj.id
  120. remoteFacilityOptions = [{ keyRO: facilityObj.facility_name, valRO: facilityObj.id }]
  121. }
  122. }
  123. if (str === 'color') {
  124. const oldform = this.$refs.ruleForm.baseForm
  125. params = {...oldform}
  126. params.fillColor = this.fillColor
  127. params.strokeColor = this.strokeColor
  128. }
  129. if (str === 'facility') {
  130. const oldform = this.$refs.ruleForm.baseForm
  131. params = {...oldform}
  132. params.text = this.facilityObj.facility_name
  133. remoteFacilityOptions = [{ keyRO: this.facilityObj.facility_name, valRO: this.facilityObj.id }]
  134. params.school_id = ''
  135. params.estate_id = ''
  136. }
  137. if (str === 'estate') {
  138. const oldform = this.$refs.ruleForm.baseForm
  139. params = {...oldform}
  140. params.text = this.estateObj.estate_name
  141. remoteEstateOptions = [{ keyRO: this.estateObj.estate_name, valRO: this.estateObj.id }]
  142. params.school_id = ''
  143. params.facility_id = ''
  144. }
  145. if (str === 'school') {
  146. const oldform = this.$refs.ruleForm.baseForm
  147. params = {...oldform}
  148. params.text = this.schoolObj.school_name
  149. remoteSchoolOptions = [{ keyRO: this.schoolObj.school_name, valRO: this.schoolObj.id }]
  150. params.estate_id = ''
  151. params.facility_id = ''
  152. }
  153. if (!params.text) params.text = '标题示例'
  154. if (!params.strokeStyle) params.strokeStyle = 'solid'
  155. if (this.mteStr === 'polygonAdd' || this.mteStr === 'polylineAdd') {
  156. if (!params.fillColor) {
  157. params.fillColor = this.fillColor
  158. params.fillOpacity = '0.4'
  159. params.strokeColor = this.strokeColor
  160. }
  161. this.formData = [
  162. { label: '关联配套', key: 'facility_id', type: 'selectRemote', changeHandle: this.facilityChange,
  163. remoteParams: { skey: 'name', api: `facility.admfacilitylist`, opKey: 'name', opVal: 'id' },
  164. remoteOptions: remoteFacilityOptions
  165. },
  166. { label: '关联楼盘', key: 'estate_id', type: 'selectRemote', changeHandle: this.estateChange,
  167. remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
  168. remoteOptions: remoteEstateOptions
  169. },
  170. { label: '关联学校', key: 'school_id', type: 'selectRemote', changeHandle: this.schoolChange,
  171. remoteParams: { skey: 'school_name', api: `school.admschoollist`, opKey: 'school_name', opVal: 'id' },
  172. remoteOptions: remoteSchoolOptions
  173. },
  174. { label: '标题', key: 'text', rules: 1},
  175. { label: '填充色', key: 'fillColor', type: 'colorPicker', rules: 1},
  176. { label: '透明度', key: 'fillOpacity', rules: 1},
  177. { label: '轮廓色', key: 'strokeColor', type: 'colorPicker', rules: 1},
  178. { label: '实虚线', key: 'strokeStyle', type: 'select', options: [{key: '实线', val: 'solid'}, {key: '虚线', val: 'dashed'}]},
  179. ]
  180. } else {
  181. if (!params.color) {
  182. params.color = '#d71139'
  183. }
  184. this.formData = [
  185. { label: '内容', key: 'text', rules: 1},
  186. { label: '颜色', key: 'color', type: 'colorPicker', rules: 1},
  187. ]
  188. }
  189. this.setDefaultValue(params)
  190. },
  191. facilityChange (val, op, valObj) {
  192. this.facilityObj = {
  193. id: valObj.id,
  194. facility_name: valObj.name,
  195. pri_image: valObj.pri_image,
  196. remarked: valObj.remarked,
  197. }
  198. this.getDef('facility')
  199. },
  200. estateChange (val, op, valObj) {
  201. this.estateObj = {
  202. id: valObj.id,
  203. estate_name: valObj.estate_name,
  204. pri_image: valObj.pri_image,
  205. price_range: valObj.price_range,
  206. product_type: valObj.product_type,
  207. // property_type: valObj.property_type,
  208. // area_type: valObj.area_type,
  209. // metro_type: valObj.metro_type,
  210. // metro_line: valObj.metro_line,
  211. // vr_image: valObj.vr_image,
  212. // vr_key: valObj.vr_key,
  213. }
  214. this.getDef('estate')
  215. },
  216. schoolChange (val, op, valObj) {
  217. this.schoolObj = {
  218. id: valObj.id,
  219. school_name: valObj.school_name,
  220. pri_image: valObj.pri_image,
  221. school_attrib: valObj.school_attrib,
  222. school_type: valObj.school_type,
  223. remarked: valObj.remarked,
  224. }
  225. this.getDef('school')
  226. },
  227. colorHandle (item) {
  228. this.fillColor = item.color
  229. this.strokeColor = item.color
  230. this.getDef('color')
  231. },
  232. close (str) {
  233. if (str === 'confirm') {
  234. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  235. if (valid) {
  236. const oldform = this.$refs.ruleForm.baseForm
  237. const newForm = { ...oldform }
  238. if (this.estateObj && this.estateObj.id) {
  239. newForm.estateObj = JSON.stringify(this.estateObj)
  240. }
  241. if (this.schoolObj && this.schoolObj.id) {
  242. newForm.schoolObj = JSON.stringify(this.schoolObj)
  243. }
  244. if (this.facilityObj && this.facilityObj.id) {
  245. newForm.facilityObj = JSON.stringify(this.facilityObj)
  246. }
  247. if (this.curObj.obj) {
  248. this.$emit('close', newForm, 'edit')
  249. } else {
  250. this.$emit('close', newForm)
  251. }
  252. this.setDefaultValue()
  253. }
  254. })
  255. } else {
  256. this.$emit('close')
  257. this.setDefaultValue()
  258. }
  259. },
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped>
  264. @import '../../../../styles/libEdit.scss';
  265. .lib-edit {
  266. padding-top: 0;
  267. ::v-deep .el-date-editor.el-input {
  268. width: 100%;
  269. }
  270. ::v-deep .el-textarea__inner {
  271. height: 300px;
  272. }
  273. }
  274. .scoped-color-quick {
  275. margin-bottom: 20px;
  276. .t {
  277. color: #313131;
  278. }
  279. .op {
  280. display: inline-block;
  281. vertical-align: middle;
  282. width: 40px;
  283. height: 26px;
  284. line-height: 26px;
  285. color: #fff;
  286. cursor: pointer;
  287. text-align: center;
  288. margin-right: 10px;
  289. margin-bottom: 10px;
  290. opacity: .6;
  291. color: #000;
  292. user-select: none;
  293. font-size: 12px;
  294. &.cur {
  295. opacity: 1;
  296. color: #fff;
  297. }
  298. }
  299. }
  300. </style>