liujq 3 years ago
parent
commit
b64d0540a7

+ 15 - 0
src/api/other.js

@@ -187,4 +187,19 @@ export default {
   admmapcoordincount: params => { // 地图 测试 统计
     return getRequestNoSort('/adm/map/coordin/count', params)
   },
+  admmetroinfolist: params => { // 地铁管理 - 列表
+    return getRequest('/adm/metro/info/list', params)
+  },
+  admmetroinfoedit: params => { // 地铁管理 - 编辑
+    return getRequestNoSort('/adm/metro/info/edit', params, 'loading')
+  },
+  admmetroinfoadd: params => { // 地铁管理 - 添加
+    return getRequestNoSort('/adm/metro/info/add', params, 'loading')
+  },
+  admmetroinfodel: params => { // 地铁管理 - 删除
+    return getRequestNoSort('/adm/metro/info/del', params, 'loading')
+  },
+  admmetroinfodetail: params => { // 地铁管理 - 详情
+    return getRequestNoSort('/adm/metro/info/detail', params, 'loading')
+  },
 }

+ 1 - 1
src/main.js

@@ -49,7 +49,7 @@ Vue.use(VueAMap)
 VueAMap.initAMapApiLoader({
   key: '8343df94cab859af3bd36362029a4e19',
   plugin: ['AMap.MouseTool'],
-  // plugin: ['AMap.AutoComplete','AMap.MarkerClusterer','AMap.DistrictSearch', 'AMap.MouseTool', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PlaceSearch', 'AMap.Geolocation', 'AMap.Geocoder', 'AMap.TileLayer'],
+  plugin: ['AMap.AutoComplete','AMap.MarkerClusterer','AMap.DistrictSearch', 'AMap.MouseTool', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PlaceSearch', 'AMap.Geolocation', 'AMap.Geocoder', 'AMap.TileLayer'],
   v: '1.4.15',
   uiVersion: '1.0' })
 /**

+ 184 - 0
src/views/metro/components/popup/IndexEdit.vue

@@ -0,0 +1,184 @@
+<template>
+  <div>
+    <el-dialog
+      v-loading="loading"
+      :show-close="false"
+      :close-on-click-modal="false"
+      :visible.sync="isShow"
+      :title="curObj.id ? '编辑地铁信息' : '添加地铁信息'"
+      :fullscreen="false"
+      width="700px"
+      custom-class="xl-dialog"
+      center
+    >
+      <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="100px" :insertSlotArr="[2]">
+        <div slot="OI2" class="scoped-other-form">
+          <el-form-item label="地铁坐标" class="scoped-item-two">
+            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>
+        <div slot="footer" style="padding-top: 20px;">
+          <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
+          <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
+        </div>
+      </base-form>
+    </el-dialog>
+    <handle-map :is-show="isShowMap" @close="closeMap" />
+  </div>
+</template>
+<script>
+import handleMap from '@/components/Common/Map'
+export default {
+  components: {
+    handleMap
+  },
+  mixins,
+  props: {
+    isShow: Boolean,
+    curObj: Object
+  },
+  inject: ['parentData'],
+  data() {
+    return {
+      isShowMap: false,
+      formData: [],
+      loading: true,
+      cObj: {},
+      metroName: ''
+    }
+  },
+  watch: {
+    isShow: function(val) {
+      if (val) {
+        if (this.curObj.id) {
+          this.$api.other.admmetroinfodetail({
+            id: this.curObj.id
+          }).then(res => {
+            this.cObj = {...res}
+            this.getDef()
+          })
+        } else {
+          this.getDef()
+        }
+      }
+    },
+  },
+  methods: {
+    openMap() { // 定位
+      this.isShowMap = true
+      const pointObj = {
+        latitude: this.cObj.latitude || '',
+        longitude: this.cObj.longitude || '',
+      }
+      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
+    },
+    getDef(pObj) {
+      let params = { ...this.cObj, ...pObj }
+      let nArr = []
+      if (params.metro_line) {
+        const mtArr = this.$dictData.metro_type || []
+        mtArr.forEach(item => {
+          if ((item.option1).indexOf(params.metro_line) > -1) {
+            nArr.push(item)
+          }
+        })
+      }
+      this.formData = [
+        { label: '线路', key: 'metro_line', class: 'c-2', type: 'select', options: this.$dictData.metro_line, rules: 1, changeHandle: this.metroLineChange},
+        { label: '站名', key: 'metro_type', class: 'c-2', type: 'select', options: nArr, rules: 1, changeHandle: this.metroTypeChange},
+        { label: '排序', key: 'sort'},
+      ]
+      this.setDefaultValue(params)
+    },
+    metroTypeChange (val, item, op) {
+     this.metroName = op.key
+    },
+    metroLineChange (val) {
+      this.getDef({metro_line: val, metro_type: ''})
+    },
+    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
+            let apiStr = 'admmetroinfoadd'
+            if (newForm.id) {
+              apiStr = 'admmetroinfoedit'
+            }
+            newForm.metro_name = this.metroName
+            newForm.longitude = this.cObj.longitude
+            newForm.latitude = this.cObj.latitude
+            if (!newForm.longitude) return this.$msgw('请选择经度!')
+            else if (!newForm.latitude) return this.$msgw('请选择纬度!')
+            this.$api.other[apiStr](newForm).then(data => {
+              this.$msgs(newForm.id ? '编辑成功' : '新增成功')
+              this.$emit('close', newForm)
+              this.getDef({sort: Number(newForm.sort)+1})
+            })
+          }
+        })
+      } else {
+        this.$emit('close')
+        this.cObj = {}
+        this.setDefaultValue()
+      }
+    },
+  }
+}
+</script>
+<style lang="scss" scoped>
+@import '../../../../styles/libEdit.scss';
+.lib-edit {
+  padding-top: 0;
+  ::v-deep .el-form-item {
+    margin-bottom: 10px;
+  }
+  ::v-deep .el-date-editor.el-input {
+    width: 100%;
+  }
+}
+::v-deep .img-upload {
+  width: 182px;
+  height: 110px;
+  overflow: hidden;
+  .icon {
+    width: 180px;
+    height: 100px;
+    line-height: 100px;
+  }
+  .img {
+    width: 180px;
+    height: 110px;
+  }
+}
+
+
+.scoped-other-form {
+  .map-btn{
+    display: inline-block;
+    vertical-align: bottom;
+    height: 36px;
+  }
+  .scoped-item-two {
+    .el-input {
+      display: inline-block;
+      vertical-align: bottom;
+      width: 140px;
+      margin: 0 10px;
+    }
+  }
+}
+</style>

+ 31 - 0
src/views/metro/components/searchForm/Index.vue

@@ -0,0 +1,31 @@
+<template>
+  <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>
+</template>
+<script>
+export default {
+  props: {
+    listLoading: Boolean
+  },
+  inject: ['parentData'],
+  data() {
+    return {
+      searchData: [
+        { label: '线路', key: 'metro_line', type: 'select', class: 'c-3', options: this.$dictData.metro_line },
+        { label: '站名', key: 'metro_name', class: 'c-3' },
+      ]
+    }
+  },
+  methods: {
+    searchHandle() {
+      const oldform = this.$refs.ruleForm.baseForm
+      const newForm = { ...oldform }
+      this.$emit('change', newForm)
+    }
+  }
+}
+</script>

+ 102 - 0
src/views/metro/index.vue

@@ -0,0 +1,102 @@
+<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/Index'
+import PopupEdit from './components/popup/IndexEdit'
+import baseTable from '_m/baseTable.js'
+export default {
+  name: 'index',
+  components: {
+    SearchForm,
+    PopupEdit,
+  },
+  provide() {
+    return {
+      parentData: this
+    }
+  },
+  mixins: [baseTable],
+  data() {
+    return {
+      apiStr: 'other.admmetroinfolist',
+      searchForm: null,
+      isDtlShow: false,
+      curObj: {},
+    }
+  },
+  computed: {
+    tableData2() {
+      const arr = [...this.tableData,]
+      arr.map(item => {})
+      return arr
+    }
+  },
+  created() {},
+  mounted() {
+    this.listConfig = {
+      rows: [
+        { label: '排序', prop: 'sort' },
+        { label: '线路', prop: 'metro_line', type: 'flag', flags: arrToObj(this.$dictData.metro_line) }, 
+        { label: '站名', prop: 'metro_name' },
+        { 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.other.admmetroinfodel({
+          id: row.id,
+        }).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>