新建工成

This commit is contained in:
仲么了
2023-04-12 18:39:52 +08:00
parent d6b2c98d1f
commit ff2fd537ec
11 changed files with 1105 additions and 1071 deletions

View File

@@ -5,15 +5,16 @@
<view class="content">
<uni-forms :label-width="80">
<uni-forms-item label="工程名称">
<uni-easyinput type="number" v-model="formData.name" placeholder="请输入工程名称" />
<uni-easyinput type="text" v-model="formData.name" placeholder="请输入工程名称" />
</uni-forms-item>
<uni-forms-item label="位置">
<view style="display:flex;">
<!-- <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>
</view> -->
<uni-data-picker :localdata="localdata" @change="areaChange"> </uni-data-picker>
</uni-forms-item>
<uni-forms-item label="描述">
<uni-easyinput type="textarea" autoHeight v-model="formData.description"
@@ -29,35 +30,22 @@
</Cn-page>
</template>
<script>
import { addAppProject } from '../../common/api/project'
// import area from '../../common/js/area.json'
import { addEngineering } from '../../common/api/gc'
import area from '../../common/js/area.json'
export default {
data () {
data() {
return {
localdata: area,
loading: false,
formData: {
area: "",
files: [],
description: '',
projectType: '1',
name: '',
userId: '123456',
lat: '2',
lng: '3'
city: "",
description: "",
name: "",
province: "",
},
TypeRange: [
{
text: '监测',
value: '1'
},
{
text: '用能',
value: '2'
}
]
}
},
onLoad () {
onLoad() {
uni.getLocation({
type: 'wgs84',
success: function (res) {
@@ -69,10 +57,15 @@ export default {
// console.log(area);
},
methods: {
select (e) {
areaChange(e) {
console.log(e);
this.formData.province = e.detail.value[0].value
this.formData.city = e.detail.value[1].value
},
select(e) {
console.log(e);
},
chooseLocation () {
chooseLocation() {
uni.chooseLocation({
success: function (res) {
@@ -84,43 +77,26 @@ export default {
}
});
},
async submit () {
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('请输入区域信息')
if (!this.formData.province) {
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 => {
addEngineering(this.formData).then(res => {
console.log(res)
this.$util.toast('工程创建成功')
// setTimeout(() => {
// uni.navigateBack({ delta: 1 })
// }, 1500);
setTimeout(() => {
uni.navigateBack({ delta: 1 })
}, 1500);
})
}
}