Files
app-govern/pages/gc/new.vue
2023-04-12 09:10:35 +08:00

168 lines
5.2 KiB
Vue

<template>
<Cn-page :loading='loading'>
<view slot='body'>
<view class='new'>
<view class="content">
<uni-forms :label-width="80">
<uni-forms-item label="工程名称">
<uni-easyinput type="number" v-model="formData.name" placeholder="请输入工程名称" />
</uni-forms-item>
<uni-forms-item label="位置">
<view style="display:flex;">
<uni-easyinput :clearable="false" type="textarea" autoHeight v-model="formData.area"
placeholder="请输入位置信息" />
<uni-icons type="location" color="#007aff" size="26" class="ml20"
@click="chooseLocation"></uni-icons>
</view>
</uni-forms-item>
<uni-forms-item label="描述">
<uni-easyinput type="textarea" autoHeight v-model="formData.description"
placeholder="请输入工程描述" />
</uni-forms-item>
</uni-forms>
</view>
<view class="btn-wrap">
<view class="btn-wrap-item" @click="submit"> 提交 </view>
</view>
</view>
</view>
</Cn-page>
</template>
<script>
import { addAppProject } from '../../common/api/project'
// import area from '../../common/js/area.json'
export default {
data () {
return {
loading: false,
formData: {
area: "",
files: [],
description: '',
projectType: '1',
name: '',
userId: '123456',
lat: '2',
lng: '3'
},
TypeRange: [
{
text: '监测',
value: '1'
},
{
text: '用能',
value: '2'
}
]
}
},
onLoad () {
uni.getLocation({
type: 'wgs84',
success: function (res) {
console.log(res);
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
}
});
// console.log(area);
},
methods: {
select (e) {
console.log(e);
},
chooseLocation () {
uni.chooseLocation({
success: function (res) {
this.address = res.name
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
}
});
},
async submit () {
if (!this.formData.name) {
this.$util.toast('请输入工程名称')
return
}
if (!this.formData.projectType) {
this.$util.toast('请选择工程类别')
return
}
if (!this.formData.area) {
this.$util.toast('请输入区域信息')
return
}
if (!this.formData.description) {
this.$util.toast('请输入工程描述')
return
}
if (!this.formData.files.length) {
this.$util.toast('请上传拓扑图')
return
}
let arr = []
for (let i = 0; i < this.formData.files.length; i++) {
let item = this.formData.files[i]
arr.push({
name: 'files',
url: item.url
})
}
let data = JSON.parse(JSON.stringify(this.formData))
delete data.files
addAppProject(data, arr).then(res => {
console.log(res)
this.$util.toast('工程创建成功')
// setTimeout(() => {
// uni.navigateBack({ delta: 1 })
// }, 1500);
})
}
}
}
</script>
<style lang='scss'>
.new {
padding: 34rpx;
.content {
.content-des {
font-size: 28rpx;
color: #666;
margin-bottom: 20rpx;
}
margin-bottom: 20rpx;
padding: 34rpx;
background: $uni-theme-white;
border-radius: 12rpx;
}
.btn-wrap {
margin-top: 40rpx;
display: flex;
align-items: center;
justify-content: space-between;
.btn-wrap-item {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
background: $uni-theme-blue;
color: #fff;
height: 80rpx;
border-radius: 12rpx;
}
}
}
/deep/ .uni-drawer__content {
width: 100vw !important;
}
</style>