1111 <span >添加地点</span >
1212 </p >
1313 <div style =" text-align :center " >
14- <Input class =" addPointModal-input" v-model =" model[0]" placeholder =" 地点名称" style =" width : 300px " ></Input ><br >
15- <Input class =" addPointModal-input" v-model =" model[1]" placeholder =" 经度" style =" width : 300px " ></Input ><br >
16- <Input class =" addPointModal-input" v-model =" model[2]" placeholder =" 纬度" style =" width : 300px " ></Input ><br >
14+ <Input class =" addPointModal-input" v-model =" model[0]" placeholder =" 地点名称" style =" width : 300px " @on-blur =" getLocation" ></Input ><br >
15+ <Input v-if =" !hasGetLocation" class =" addPointModal-input" v-model =" model[1]" placeholder =" 经度" style =" margin-top :18px ;width : 300px " ></Input ><br >
16+ <Input v-if =" hasGetLocation" class =" addPointModal-input" :value =" model[1]" style =" width : 300px " ></Input ><br >
17+ <Input v-if =" !hasGetLocation" class =" addPointModal-input" v-model =" model[2]" placeholder =" 纬度" style =" width : 300px " ></Input ><br >
18+ <Input v-if =" hasGetLocation" class =" addPointModal-input" :value =" model[2]" style =" margin-bottom :18px ;width : 300px " ></Input ><br >
1719 <DatePicker class =" addPointModal-input" @on-change =" getDate($event)" type =" date" placeholder =" 选择日期" style =" width : 300px " ></DatePicker >
1820 </div >
1921 </Modal >
@@ -44,20 +46,43 @@ export default {
4446 ' ' ,
4547 ' '
4648 ],
47- showModal: false
49+ showModal: false ,
50+ hasGetLocation: false
4851 }
4952 },
50- computed: mapState ({
51- excelData : state => state .excel .excelData ,
52- countAlias: ' excelData' ,
53- userId : state => state .userInfo .userInfo .objectId || storage .get (' userId' ),
54- countAlias: ' userId'
55- }),
53+ computed: {
54+ ... mapState ({
55+ excelData : state => state .excel .excelData ,
56+ countAlias: ' excelData' ,
57+ userId : state => state .userInfo .userInfo .objectId || storage .get (' userId' ),
58+ countAlias: ' userId'
59+ }),
60+ },
5661 methods: {
5762 ... mapActions ({
5863 addExcelData: ' addExcelData' ,
5964 setExcelData: ' setExcelData'
6065 }),
66+ getLocation () {
67+ if (this .model [0 ] !== ' ' ) {
68+ this .$Spin .show ()
69+ ajax .get ({
70+ url: url .GETLOCATION_CHINA ,
71+ data: {
72+ address: this .model [0 ],
73+ output: ' json' ,
74+ ak: ' O9WWqYCWQ0d0N1KI85Blg7X2fSBsxOAs' ,
75+ callback: ' showLocation'
76+ }
77+ }).then (data => {
78+ console .log (data)
79+ this .model [1 ] = data .result .location .lng
80+ this .model [2 ] = data .result .location .lat
81+ this .hasGetLocation = true
82+ this .$Spin .hide ()
83+ })
84+ }
85+ },
6186 addPoint () {
6287 if (this .model [0 ] === ' ' || this .model [1 ] === ' ' || this .model [2 ] === ' ' || this .model [3 ] === ' ' )
6388 this .$Message .error (' 输入不能为空' )
@@ -74,6 +99,8 @@ export default {
7499 }
75100 else
76101 this .addExcelData (this .model )
102+ this .model = [' ' , ' ' , ' ' , ' ' ]
103+ this .hasGetLocation = false
77104 let updateMapDate = new Date (_ .now ()).toLocaleString ()
78105 ajax .post ({
79106 url: url .ASYNC_UPLOAD ,
@@ -113,7 +140,7 @@ export default {
113140
114141<style lang="less" scoped>
115142@import ' ../../assets/my-theme/custom.less' ;
116- .addPointModal-input {
117- margin-bottom : 12 px ;
143+ .addPointModal-input_1 {
144+ margin-bottom : 18 px ;
118145 }
119146 </style >
0 commit comments