Browse Source

temp save

liujq 4 years ago
parent
commit
7812d64f48

+ 15 - 0
src/api/house.js

@@ -19,6 +19,21 @@ export default {
   admestatedel: params => { // 楼盘删除
     return getRequestNoSort('/adm/estate/del', params, 'loading')
   },
+  admoldhouselist: params => { // 二手房列表接口
+    return getRequest('/adm/oldhouse/list', params)
+  },
+  admoldhouseadd: params => { // 二手房添加
+    return getRequestNoSort('/adm/oldhouse/add', params, 'loading')
+  },
+  admoldhouseedit: params => { // 二手房编辑
+    return getRequestNoSort('/adm/oldhouse/edit', params, 'loading')
+  },
+  admoldhousedetail: params => { // 二手房详情
+    return getRequestNoSort('/adm/oldhouse/detail', params, 'loading')
+  },
+  admoldhousedel: params => { // 二手房删除
+    return getRequestNoSort('/adm/oldhouse/del', params, 'loading')
+  },
   admschoollist: params => { // 学校列表接口
     return getRequest('/adm/school/list', params)
   },

+ 20 - 10
src/router/index.js

@@ -59,12 +59,22 @@ export const moreRoutes = [
     path: '/house',
     component: Layout,
     redirect: '/house/index',
-    children: [{
-      path: 'index',
-      name: 'houseIndex',
-      component: () => import('@/views/house/index'),
-      meta: { title: '楼盘管理', icon: 'dashboard', affix: true }
-    }]
+    name: 'House',
+    meta: { title: '楼盘管理', icon: 'dashboard' },
+    children: [
+      {
+        path: 'index',
+        name: 'HouseIndex',
+        component: () => import('@/views/house/index'),
+        meta: { title: '楼盘列表', affix: true }
+      },
+      {
+        path: 'old',
+        name: 'HouseOld',
+        component: () => import('@/views/house/old'),
+        meta: { title: '二手房管理', affix: true }
+      },
+    ]
   },
   {
     path: '/school',
@@ -72,7 +82,7 @@ export const moreRoutes = [
     redirect: '/school/index',
     children: [{
       path: 'index',
-      name: 'schoolIndex',
+      name: 'SchoolIndex',
       component: () => import('@/views/school/index'),
       meta: { title: '学校管理', icon: 'dashboard', affix: true }
     }]
@@ -83,9 +93,9 @@ export const moreRoutes = [
     redirect: '/news/index',
     children: [{
       path: 'index',
-      name: 'newsIndex',
+      name: 'NewsIndex',
       component: () => import('@/views/news/index'),
-      meta: { title: '测评资讯', icon: 'dashboard', affix: true }
+      meta: { title: '洪楼News', icon: 'dashboard', affix: true }
     }]
   },
   {
@@ -94,7 +104,7 @@ export const moreRoutes = [
     redirect: '/user/index',
     children: [{
       path: 'index',
-      name: 'userIndex',
+      name: 'UserIndex',
       component: () => import('@/views/user/index'),
       meta: { title: '用户管理', icon: 'dashboard', affix: true }
     }]

+ 1 - 1
src/views/house/components/popup/IndexEdit.vue

@@ -462,7 +462,7 @@ export default {
     }
     .el-icon-plus {
       color: #999;
-      margin-top: 30px;
+      padding: 30px;
     }
   }
   .ri-deal {

+ 266 - 0
src/views/house/components/popup/OldEdit.vue

@@ -0,0 +1,266 @@
+<template>
+  <div>
+    <el-drawer
+      v-loading="loading"
+      :show-close="false"
+      :title="curObj.id ? '编辑房源' : '新增房源'"
+      :wrapper-closable="false"
+      :close-on-press-escape="false"
+      :visible.sync="isShow"
+      size="960px"
+      custom-class="xl-drawer"
+      direction="rtl"
+    >
+      <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px" :insertSlotArr="[8,9]">
+        <div slot="OI8">
+          <div class="scoped-img-area">
+            <div class="sia-op" v-for="(imgsrc,index) in imagesArr" :key="index">
+              <img class="img" :src="imgsrc" alt="img">
+            </div>
+            <el-upload
+              class="sia-img"
+              :action="`${domainUrl}/adm/upload/picture`"
+              :data="{logic_type: 'estate', token}"
+              name="upload"
+              :show-file-list="false"
+              :on-success="roomAreaUploadSuccess"
+              :before-upload="roomAreaUploadBefore"
+              >
+              <i class="el-icon-plus icon"/>
+            </el-upload>
+          </div>
+        </div>
+        <div slot="OI9" class="scoped-other-form">
+          <el-form-item label="点位坐标" class="scoped-item-two item">
+            纬度N<el-input v-model="cObj.latitude" disabled />
+            经度E<el-input v-model="cObj.longitude" disabled />
+            <el-button type="primary" class="map-btn" size="small" @click="openMap">点击从地图获取</el-button>
+          </el-form-item>
+        </div>
+      </base-form>
+      <div class="xl-form">
+        <div class="xl-form-footer fixed" style="width:960px;padding-top: 20px;border-top: 1px solid #dcdcdc;right:0;">
+          <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
+          <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
+        </div>
+      </div>
+    </el-drawer>
+    <handle-map :is-show="isShowMap" @close="closeMap" />
+  </div>
+</template>
+<script>
+import { arrToObj } from '@/utils'
+import handleMap from '@/components/Common/Map'
+export default {
+  components: { handleMap },
+  mixins,
+  props: {
+    isShow: Boolean,
+    curObj: Object
+  },
+  inject: ['parentData'],
+  data() {
+    const token = window.sessionStorage.getItem('fp_token')
+    let domainUrl = process.env.VUE_APP_BASE_API
+    return {
+      domainUrl,
+      token,
+      loading: false,
+      formData: [],
+      cObj: {},
+      isShowMap: false,
+      imagesArr: [],
+    }
+  },
+  watch: {
+    isShow: function(val) {
+      if (val) {
+        if (this.curObj.id) {
+          this.loading = true
+          this.$api.house.admoldhousedetail({id: this.curObj.id}).then(res => {
+            let curData = res || {}
+            if (curData.pri_image) curData.pri_image = `${curData.domain}${curData.pri_image}?url=${curData.pri_image}`
+            this.cObj = curData || {}
+            this.getDef()
+            this.loading = false
+          })
+        } else {
+          this.cObj = this.curObj
+          this.getDef()
+        }
+      }
+    },
+  },
+  methods: {
+    roomAreaUploadSuccess(res, file) {
+      const data = res.data || {}
+      this.imagesArr.push(`${data.domain}${data.url}?url=${data.url}&id=${data.file_id}`)
+    },
+    roomAreaUploadBefore(file) {
+      const isJPGPNG = file.type === 'image/jpeg' || file.type === 'image/png'
+      const isLt2M = file.size / 1024 / 1024 < 2
+      if (!isJPGPNG) {
+        this.$message.error('上传图片只能是 JPG PNG 格式!')
+      }
+      if (!isLt2M) {
+        this.$message.error('上传图片大小不能超过 400k!')
+      }
+      return isJPGPNG && isLt2M
+    },
+    getDef (str) {
+      let params = {}
+      params = { ...this.cObj }
+      let disabled = false
+      if (params.id) disabled = true
+      this.formData = [
+        { label: '房源标题', key: 'title'},
+        { label: '所属区域', key: 'area_type', type: 'select', class: 'c-3', options: this.$dictData.area_type },
+        { label: '产品类型', key: 'product_type', class: 'c-3', type: 'select', options: this.$dictData.product_type},
+        { label: '房源户型', key: 'house_type', class: 'c-3', type: 'select', options: this.$dictData.house_type},
+        { label: '面积', key: 'area', class: 'c-3', type: 'inputFont', appendFont: '㎡'},
+        { label: '总价', key: 'price', class: 'c-3'},
+        { label: '所属楼盘', key: 'estate_id', class: 'c-3', type: 'selectRemote',
+          remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' },
+        },
+        { label: '房源主图', key: 'pri_image', class: 'c-3', type: 'upload' }, 
+        { label: '房源简介', key: 'remarked', class: 'c-3s', type: 'textarea' },
+        { label: '房源地址', key: 'address' },
+      ]
+      this.setDefaultValue(params)
+    },
+    getImgUrl (str) {
+      let backStr = ''
+      if (str && str.indexOf('?') > -1) {
+        const imgArr = str.split('?')
+        const queryArr = imgArr[1].split('&')
+        queryArr.forEach(q =>{
+          const curQArr = q.split('=')
+          if (curQArr[0] === 'url') {
+            backStr = curQArr[1]
+          }
+        })
+      }
+      return backStr
+    },
+    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.curObj.id) newForm.id = this.curObj.id
+            newForm.longitude = this.cObj.longitude
+            newForm.latitude = this.cObj.latitude
+            if (!newForm.longitude) return this.$msgw('请选择经度!')
+            else if (!newForm.latitude) return this.$msgw('请选择纬度!')
+            // if (newForm.pri_image && newForm.pri_image.indexOf('?') > -1) {
+            //   const imgArr = newForm.pri_image.split('?')
+            //   const queryArr = imgArr[1].split('&')
+            //   queryArr.forEach(q =>{
+            //     const curQArr = q.split('=')
+            //     if (curQArr[0] === 'url') {
+            //       newForm.pri_image = curQArr[1]
+            //     }
+            //   })
+            // }
+            newForm.pri_image = this.getImgUrl(newForm.pri_image)
+            const imgUrlArr = this.imagesArr.map(urlStr => {
+              return this.getImgUrl(urlStr)
+            })
+            newForm.images = imgUrlArr.join(',')
+            let apiStr = 'admoldhouseadd'
+            if (this.curObj.id) apiStr = 'admoldhouseedit'
+            this.$api.house[apiStr](newForm).then(data => {
+              this.$msgs(newForm.id ? '编辑成功' : '新增成功')
+              this.productData = []
+              this.$emit('close', newForm)
+            })
+          }
+        })
+      } else {
+        this.$emit('close')
+        this.productData = []
+        this.setDefaultValue()
+      }
+    },
+    openMap() { // 定位
+      this.isShowMap = true
+      const pointObj = {
+        latitude: this.cObj.latitude || '',
+        longitude: this.cObj.longitude || '',
+        address: this.cObj.address || ''
+      }
+      this.$root.$emit('handleMap', pointObj)
+    },
+    closeMap(obj) {
+      if (obj) {
+        const oldform = this.$refs.ruleForm.baseForm
+        const newForm = { ...oldform, ...obj }
+        this.cObj = newForm
+        this.setDefaultValue(newForm)
+      }
+      this.isShowMap = false
+    }
+  }
+}
+</script>
+<style lang="scss" scoped>
+@import '../../../../styles/libEdit.scss';
+.lib-edit {
+  width: 900px;
+  padding-top: 0;
+  padding-left: 0;
+  padding-bottom: 40px;
+  ::v-deep .el-form-item {
+    margin-bottom: 10px;
+  }
+  ::v-deep .el-date-editor.el-input {
+    width: 100%;
+  }
+}
+.scoped-other-form {
+  .scoped-item-two {
+    .el-input {
+      display: inline-block;
+      width: 140px;
+      margin: 0 10px;
+    }
+  }
+}
+.map-btn{
+  height: 36px;
+}
+::v-deep .el-drawer__header {
+  margin-bottom: 10px;
+}
+.scoped-img-area {
+  text-align: center;
+  .sia-op {
+    display: inline-block;
+    vertical-align: middle;
+    margin-right: 10px;
+    margin-bottom: 10px;
+    border: 1px solid #f2f2f2;
+    width: 80px;
+    height: 80px;
+    overflow: hidden;
+    .img {
+      width: 80px;
+      height: 80px;
+    }
+  }
+  .sia-img {
+    display: inline-block;
+    vertical-align: middle;
+    width: 80px;
+    height: 80px;
+    overflow: hidden;
+    border: 1px dashed #999;
+    margin-bottom: 10px;
+    .el-icon-plus {
+      color: #999;
+      padding: 30px;
+    }
+  }
+}
+</style>

+ 50 - 0
src/views/house/components/searchForm/Old.vue

@@ -0,0 +1,50 @@
+<template>
+  <header-collapse>
+    <base-form slot="content" ref="ruleForm" :data="searchData">
+      <div slot="footer">
+        <el-button :loading="listLoading" icon="el-icon-search" class="xl-form-btn bgc1" @click="searchHandle">查询</el-button>
+        <!-- <el-button :loading="listLoading" icon="el-icon-document" class="xl-form-btn bgc2" @click="toExportExcel">导出{{ this.$route.meta.title }}信息</el-button> -->
+      </div>
+    </base-form>
+  </header-collapse>
+</template>
+<script>
+export default {
+  props: {
+    listLoading: Boolean
+  },
+  inject: ['parentData'],
+  mixins,
+  data() {
+    return {
+      searchData: []
+    }
+  },
+  mounted () {
+    this.getDef()
+  },
+  methods: {
+    subwayLineChange (val) {
+      this.getDef('change')
+    },
+    getDef (str) {
+      let params = { ...this.$refs.ruleForm.baseForm }
+      this.searchData = [
+        { label: '标题', key: 'title' },
+        { label: '所属楼盘', key: 'estate_id', type: 'selectRemote',
+          remoteParams: { skey: 'estate_name', api: `house.admestatelist`, opKey: 'estate_name', opVal: 'id' }
+        },
+        { label: '所属区域', key: 'area_type', type: 'select', options: this.$dictData.area_type},
+        { label: '楼盘类型', key: 'product_type', type: 'select', options: this.$dictData.product_type},
+        { label: '房源户型', key: 'house_type', type: 'select', options: this.$dictData.house_type},
+      ]
+      this.setDefaultValue(params, 'searchData')
+    },
+    searchHandle() {
+      const oldform = this.$refs.ruleForm.baseForm
+      const newForm = { ...oldform }
+      this.$emit('change', newForm)
+    }
+  }
+}
+</script>

+ 1 - 1
src/views/house/index.vue

@@ -101,7 +101,7 @@ export default {
   methods: {
     delHandle(row) {
       this.$msg(`您确定要删除该楼盘吗?`, 'confirm', () => {
-        this.$api.base.merchantpointstatusupdate({
+        this.$api.house.admestatedel({
           id: row.id,
           status: 2
         }).then(data => {

+ 129 - 0
src/views/house/old.vue

@@ -0,0 +1,129 @@
+<template>
+  <div class="app-container">
+    <search-form
+      :list-loading="listLoading"
+      @change="searchHandle"
+    />
+    <table-list
+      :list-loading="listLoading"
+      :data="tableData2"
+      :columns="listConfig"
+      :current-page="currentPage"
+      :page-size="pageSize"
+      :total-records="totalRecords"
+      @currentChange="pageHandle"
+      :isAdd="true"
+      @add="openPopup"
+    />
+    <popup-edit
+      :isShow="isDtlShow"
+      :curObj="curObj"
+      @close="closePopup"
+    />
+  </div>
+</template>
+<script>
+import { arrToObj } from '@/utils'
+import SearchForm from './components/searchForm/Old'
+import PopupEdit from './components/popup/OldEdit'
+import baseTable from '_m/baseTable.js'
+import xData from './mixin'
+export default {
+  name: 'old',
+  components: {
+    SearchForm,
+    PopupEdit,
+  },
+  provide() {
+    return {
+      parentData: this
+    }
+  },
+  mixins: [baseTable],
+  data() {
+    return {
+      apiStr: 'house.admoldhouselist',
+      searchForm: null,
+      isDtlShow: false,
+      // noCreated: true,
+      curObj: {},
+      ...xData
+    }
+  },
+  computed: {
+    tableData2() {
+      const arr = [...this.tableData]
+      arr.map(item => {
+        const metro_type = item.metro_type ? item.metro_type.split(',') : []
+        const metroTypeName = metro_type.map(v => {
+          return arrToObj(this.$dictData.metro_type)[v]
+        })
+        item.metroTypeName = metroTypeName.join(',')
+        const product_type = item.product_type ? item.product_type.split(',') : []
+        const productTypeName = product_type.map(v => {
+          return arrToObj(this.$dictData.product_type)[v]
+        })
+        item.productTypeName = productTypeName.join(',')
+        const metro_line = item.metro_line ? item.metro_line.split(',') : []
+        const metroLineName = metro_line.map(v => {
+          return arrToObj(this.$dictData.metro_line)[v]
+        })
+        item.metroLineName = metroLineName.join(',')
+      })
+      return arr
+    }
+  },
+  created() {},
+  mounted() {
+    this.listConfig = {
+      rows: [
+        { label: '标题', prop: 'title' },
+        { label: '主图', prop: 'pri_image', type: 'img' },
+        { label: '总价', prop: 'price' },
+        { label: '面积㎡', prop: 'area' },
+        { label: '房源类型', prop: 'house_type', type: 'flag', flags: arrToObj(this.$dictData.house_type) },
+        { label: '所属区域', prop: 'area_type', type: 'flag', flags: arrToObj(this.$dictData.area_type) },
+        { label: '产品类型', prop: 'productTypeName'},
+        { label: '房源地址', prop: 'address', fullShow: true, minWidth: 200 },
+        // { label: '地铁线路', prop: 'metroLineName'},
+        // { label: '地铁站名', prop: 'metroTypeName'},
+        { label: '更新人', prop: 'update_by' },
+        { label: '更新时间', prop: 'update_at' },
+        { label: '操作', width: 120, type: 'handle2', operations:
+          [
+            { label: '编辑', func: this.openPopup, btnType: 'primary' },
+            { label: '删除', func: this.delHandle, btnType: 'danger' },
+          ]
+        }
+      ]
+    }
+  },
+  methods: {
+    delHandle(row) {
+      this.$msg(`您确定要删除该楼盘吗?`, 'confirm', () => {
+        this.$api.house.admoldhousedel({
+          id: row.id,
+          status: 2
+        }).then(data => {
+          this.$msgs(`已删除!`)
+          this.fetchData()
+        })
+      }, null, true)
+    },
+    openPopup(row) {
+      if (row && row.id) {
+        this.curObj = row
+      } else {
+        this.curObj = {}
+      }
+      this.isDtlShow = true
+    },
+    closePopup(obj) {
+      this.isDtlShow = false
+      if (obj) {
+        this.fetchData()
+      }
+    }
+  }
+}
+</script>