123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <template>
- <div>
- <el-dialog
- v-loading="loading"
- :show-close="false"
- :close-on-click-modal="false"
- :visible.sync="isShow"
- :title="mteStr === 'polygonAdd' || mteStr === 'polylineAdd' ? '多边形或折线操作' : '文字或圆点操作'"
- :fullscreen="false"
- width="400px"
- custom-class="xl-dialog"
- center
- >
- <base-form ref="ruleForm" :data="formData" :is-inline="false" label-width="70px">
- </base-form>
- <div class="scoped-color-quick" v-if="mteStr === 'polygonAdd' || mteStr === 'polylineAdd'">
- <div class="t">快速选择颜色</div>
- <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>
- <div style="padding-top: 10px;">
- <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>
- </div>
- </div>
- <div class="xl-form">
- <div class="xl-form-footer">
- <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
- <el-button v-if="curObj.obj" class="xl-form-btn t1" @click="close('confirm')">保存</el-button>
- <el-button v-else class="xl-form-btn t3" @click="close('confirm')">去画图</el-button>
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { arrToObj } from '@/utils'
- export default {
- components: { },
- mixins,
- props: {
- isShow: Boolean,
- curObj: Object,
- mteStr: String,
- },
- data() {
- return {
- loading: false,
- formData: [],
- fillColor: '#ff003f',
- strokeColor: '#ff003f',
- colorArr: [
- {color: '#ff0', t: '新楼盘'},
- {color: '#bb9c2c', t: '二手房'},
- {color: '#e8d0e6', t: '还建房'},
- {color: '#ff9149', t: '幼儿园'},
- {color: '#ff7fbf', t: '小初中'},
- // {color: '#60c68b', t: ''},
- {color: '#e77ad4', t: '高中'},
- {color: '#fb6557', t: '专本科'},
- ],
- colorArr2: [
- {color: '#ff003f', t: '纯商业'},
- {color: '#999', t: '商综合'},
- {color: '#007299', t: '政府企业办公楼'},
- {color: '#00ff3f', t: '公园'},
- {color: '#4da4ee', t: '医院'},
- {color: '#dc3021', t: '变电站污水处理厂等'},
- {color: '#f8a41c', t: '商业娱乐'},
- {color: '#795ab8', t: 'other3'},
- ],
- cObj: {},
- estateObj: {},
- schoolObj: {},
- facilityObj: {},
- }
- },
- watch: {
- isShow: function(val) {
- if (val) {
- this.estateObj = {}
- this.schoolObj = {}
- this.facilityObj = {}
- this.cObj = JSON.parse(JSON.stringify(this.curObj))
- this.getDef()
- }
- },
- },
- methods: {
- getDef (str) {
- let params = { ...this.curObj.obj }
- let remoteEstateOptions = []
- if (params.estateObj) {
- let estateObj = {}
- if (typeof(params.estateObj) === 'object') {
- estateObj = params.estateObj
- } else {
- estateObj = JSON.parse(params.estateObj)
- }
- if (estateObj.id) {
- params.estate_id = estateObj.id
- remoteEstateOptions = [{ keyRO: estateObj.estate_name, valRO: estateObj.id }]
- }
- }
- let remoteSchoolOptions = []
- if (params.schoolObj) {
- let schoolObj = {}
- if (typeof(params.schoolObj) === 'object') {
- schoolObj = params.schoolObj
- } else {
- schoolObj = JSON.parse(params.schoolObj)
- }
- if (schoolObj.id) {
- params.school_id = schoolObj.id
- remoteSchoolOptions = [{ keyRO: schoolObj.school_name, valRO: schoolObj.id }]
- }
- }
- let remoteFacilityOptions = []
- if (params.facilityObj) {
- const facilityObj = JSON.parse(params.facilityObj)
- if (facilityObj.id) {
- params.facility_id = facilityObj.id
- remoteFacilityOptions = [{ keyRO: facilityObj.facility_name, valRO: facilityObj.id }]
- }
- }
- if (str === 'color') {
- const oldform = this.$refs.ruleForm.baseForm
- params = {...oldform}
- params.fillColor = this.fillColor
- params.strokeColor = this.strokeColor
- }
- if (str === 'facility') {
- const oldform = this.$refs.ruleForm.baseForm
- params = {...oldform}
- params.text = this.facilityObj.facility_name
- remoteFacilityOptions = [{ keyRO: this.facilityObj.facility_name, valRO: this.facilityObj.id }]
- params.school_id = ''
- params.estate_id = ''
- }
- if (str === 'estate') {
- const oldform = this.$refs.ruleForm.baseForm
- params = {...oldform}
- params.text = this.estateObj.estate_name
- remoteEstateOptions = [{ keyRO: this.estateObj.estate_name, valRO: this.estateObj.id }]
- params.school_id = ''
- params.facility_id = ''
- }
-
- if (str === 'school') {
- const oldform = this.$refs.ruleForm.baseForm
- params = {...oldform}
- params.text = this.schoolObj.school_name
- remoteSchoolOptions = [{ keyRO: this.schoolObj.school_name, valRO: this.schoolObj.id }]
- params.estate_id = ''
- params.facility_id = ''
- }
- if (!params.text) params.text = '标题示例'
- if (!params.strokeStyle) params.strokeStyle = 'solid'
- if (this.mteStr === 'polygonAdd' || this.mteStr === 'polylineAdd') {
- if (!params.fillColor) {
- params.fillColor = this.fillColor
- params.fillOpacity = '0.4'
- params.strokeColor = this.strokeColor
- }
- this.formData = [
- { label: '关联配套', key: 'facility_id', type: 'selectRemote', changeHandle: this.facilityChange,
- remoteParams: { skey: 'name', api: `facility.admfacilitylist`, opKey: 'name', opVal: 'id' },
- remoteOptions: remoteFacilityOptions
- },
- { label: '关联楼盘', key: 'estate_id', type: 'selectRemote', changeHandle: this.estateChange,
- remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
- remoteOptions: remoteEstateOptions
- },
- { label: '关联学校', key: 'school_id', type: 'selectRemote', changeHandle: this.schoolChange,
- remoteParams: { skey: 'school_name', api: `school.admschoollist`, opKey: 'school_name', opVal: 'id' },
- remoteOptions: remoteSchoolOptions
- },
- { label: '标题', key: 'text', rules: 1},
- { label: '填充色', key: 'fillColor', type: 'colorPicker', rules: 1},
- { label: '透明度', key: 'fillOpacity', rules: 1},
- { label: '轮廓色', key: 'strokeColor', type: 'colorPicker', rules: 1},
- { label: '实虚线', key: 'strokeStyle', type: 'select', options: [{key: '实线', val: 'solid'}, {key: '虚线', val: 'dashed'}]},
- ]
- } else {
- if (!params.color) {
- params.color = '#d71139'
- }
- this.formData = [
- { label: '内容', key: 'text', rules: 1},
- { label: '颜色', key: 'color', type: 'colorPicker', rules: 1},
- ]
- }
- this.setDefaultValue(params)
- },
- facilityChange (val, op, valObj) {
- this.facilityObj = {
- id: valObj.id,
- facility_name: valObj.name,
- pri_image: valObj.pri_image,
- remarked: valObj.remarked,
- }
- this.getDef('facility')
- },
- estateChange (val, op, valObj) {
- this.estateObj = {
- id: valObj.id,
- estate_name: valObj.estate_name,
- pri_image: valObj.pri_image,
- price_range: valObj.price_range,
- product_type: valObj.product_type,
- // property_type: valObj.property_type,
- // area_type: valObj.area_type,
- // metro_type: valObj.metro_type,
- // metro_line: valObj.metro_line,
- // vr_image: valObj.vr_image,
- // vr_key: valObj.vr_key,
- }
- this.getDef('estate')
- },
- schoolChange (val, op, valObj) {
- this.schoolObj = {
- id: valObj.id,
- school_name: valObj.school_name,
- pri_image: valObj.pri_image,
- school_attrib: valObj.school_attrib,
- school_type: valObj.school_type,
- remarked: valObj.remarked,
- }
- this.getDef('school')
- },
- colorHandle (item) {
- this.fillColor = item.color
- this.strokeColor = item.color
- this.getDef('color')
- },
- close (str) {
- if (str === 'confirm') {
- this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
- if (valid) {
- const oldform = this.$refs.ruleForm.baseForm
- const newForm = { ...oldform }
- if (this.estateObj && this.estateObj.id) {
- newForm.estateObj = JSON.stringify(this.estateObj)
- }
- if (this.schoolObj && this.schoolObj.id) {
- newForm.schoolObj = JSON.stringify(this.schoolObj)
- }
- if (this.facilityObj && this.facilityObj.id) {
- newForm.facilityObj = JSON.stringify(this.facilityObj)
- }
-
- if (this.curObj.obj) {
- this.$emit('close', newForm, 'edit')
- } else {
- this.$emit('close', newForm)
- }
- this.setDefaultValue()
- }
- })
- } else {
- this.$emit('close')
- this.setDefaultValue()
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '../../../../styles/libEdit.scss';
- .lib-edit {
- padding-top: 0;
- ::v-deep .el-date-editor.el-input {
- width: 100%;
- }
- ::v-deep .el-textarea__inner {
- height: 300px;
- }
- }
- .scoped-color-quick {
- margin-bottom: 20px;
- .t {
- color: #313131;
- }
- .op {
- display: inline-block;
- vertical-align: middle;
- width: 40px;
- height: 26px;
- line-height: 26px;
- color: #fff;
- cursor: pointer;
- text-align: center;
- margin-right: 10px;
- margin-bottom: 10px;
- opacity: .6;
- color: #000;
- user-select: none;
- font-size: 12px;
- &.cur {
- opacity: 1;
- color: #fff;
- }
- }
- }
- </style>
|