创建项目接口修改
This commit is contained in:
@@ -1,93 +1,144 @@
|
||||
<template>
|
||||
<Cn-page :loading='loading'>
|
||||
<view slot='body'>
|
||||
<view class='new'>
|
||||
<Cn-page :loading="loading">
|
||||
<view slot="body">
|
||||
<view class="new">
|
||||
<view class="content">
|
||||
<uni-forms :label-width="80">
|
||||
<uni-forms-item label="工程名称">
|
||||
<uni-easyinput v-model="formData.engineeringName" placeholder="请输入项目名称" @click.native="showDrawer" :clearable="false" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="项目名称">
|
||||
<uni-easyinput type="number" v-model="formData.name" placeholder="请输入项目名称" />
|
||||
<uni-easyinput v-model="formData.name" placeholder="请输入项目名称" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="项目类别">
|
||||
<!-- <uni-forms-item label="项目类别">
|
||||
<uni-data-select v-model="formData.projectType" :localdata="TypeRange"></uni-data-select>
|
||||
</uni-forms-item>
|
||||
</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 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-easyinput type="textarea" autoHeight v-model="formData.description" placeholder="请输入项目描述" />
|
||||
</uni-forms-item>
|
||||
<uni-file-picker v-model="formData.files" title="请上传拓扑图" :sourceType="['album']"
|
||||
@select="select"></uni-file-picker>
|
||||
<uni-file-picker
|
||||
v-model="formData.files"
|
||||
title="请上传拓扑图"
|
||||
:sourceType="['album']"
|
||||
@select="select"
|
||||
></uni-file-picker>
|
||||
</uni-forms>
|
||||
</view>
|
||||
<view class="btn-wrap">
|
||||
<view class="btn-wrap-item" @click="submit"> 提交 </view>
|
||||
</view>
|
||||
<uni-drawer ref="showRight" mode="right" :mask-click="false" :width="375">
|
||||
<uni-indexed-list :options="gcListFilter" :showSelect="false" @click="closeDrawer"></uni-indexed-list>
|
||||
</uni-drawer>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
<script>
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
import { addAppProject } from '../../common/api/project'
|
||||
import { queryEngineering } from '@/common/api/gc.js'
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
formData: {
|
||||
area: "",
|
||||
engineeringId: '',
|
||||
engineeringName: '',
|
||||
area: '',
|
||||
files: [],
|
||||
description: '',
|
||||
projectType: '1',
|
||||
name: '',
|
||||
userId: '123456',
|
||||
lat: '2',
|
||||
lng: '3'
|
||||
lng: '3',
|
||||
},
|
||||
TypeRange: [
|
||||
{
|
||||
text: '监测',
|
||||
value: '1'
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
text: '用能',
|
||||
value: '2'
|
||||
}
|
||||
]
|
||||
value: '2',
|
||||
},
|
||||
],
|
||||
gcList: [],
|
||||
}
|
||||
},
|
||||
onLoad () {
|
||||
computed: {
|
||||
gcListFilter() {
|
||||
let result = []
|
||||
this.gcList.forEach((item) => {
|
||||
let arr = pinyin(item.name[0], { toneType: 'none', type: 'array' })
|
||||
let letter = arr[0][0].toUpperCase()
|
||||
console.log(letter)
|
||||
let index = result.findIndex((item) => item.letter === letter)
|
||||
if (index === -1) {
|
||||
result.push({
|
||||
letter,
|
||||
data: [item.name],
|
||||
})
|
||||
} else {
|
||||
result[index].data.push(item.name)
|
||||
}
|
||||
})
|
||||
return result
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
console.log(res);
|
||||
console.log('当前位置的经度:' + res.longitude);
|
||||
console.log('当前位置的纬度:' + res.latitude);
|
||||
}
|
||||
});
|
||||
console.log(res)
|
||||
console.log('当前位置的经度:' + res.longitude)
|
||||
console.log('当前位置的纬度:' + res.latitude)
|
||||
},
|
||||
})
|
||||
queryEngineering().then((res) => {
|
||||
this.gcList = res.data
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
select (e) {
|
||||
console.log(e);
|
||||
showDrawer() {
|
||||
this.$refs.showRight.open()
|
||||
},
|
||||
chooseLocation () {
|
||||
|
||||
closeDrawer(e) {
|
||||
console.log(e)
|
||||
this.formData.engineeringName = e.item.name
|
||||
this.formData.engineeringId = this.gcList.find((item) => item.name === e.item.name).id
|
||||
this.$refs.showRight.close()
|
||||
},
|
||||
select(e) {
|
||||
console.log(e)
|
||||
console.log(this.formData.files)
|
||||
this.formData.files = this.formData.files.concat(e.tempFiles)
|
||||
},
|
||||
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);
|
||||
}
|
||||
});
|
||||
console.log('位置名称:' + res.name)
|
||||
console.log('详细地址:' + res.address)
|
||||
console.log('纬度:' + res.latitude)
|
||||
console.log('经度:' + res.longitude)
|
||||
},
|
||||
})
|
||||
},
|
||||
async submit () {
|
||||
async submit() {
|
||||
console.log(this.formData)
|
||||
if (!this.formData.name) {
|
||||
this.$util.toast('请输入项目名称')
|
||||
return
|
||||
@@ -113,23 +164,23 @@ export default {
|
||||
let item = this.formData.files[i]
|
||||
arr.push({
|
||||
name: 'files',
|
||||
url: item.url
|
||||
url: item.url,
|
||||
})
|
||||
}
|
||||
let data = JSON.parse(JSON.stringify(this.formData))
|
||||
delete data.files
|
||||
addAppProject(data, arr).then(res => {
|
||||
addAppProject(data, arr).then((res) => {
|
||||
console.log(res)
|
||||
this.$util.toast('项目创建成功')
|
||||
// setTimeout(() => {
|
||||
// uni.navigateBack({ delta: 1 })
|
||||
// }, 1500);
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}, 1500);
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang='scss'>
|
||||
<style lang="scss">
|
||||
.new {
|
||||
padding: 34rpx;
|
||||
|
||||
@@ -168,4 +219,4 @@ export default {
|
||||
/deep/ .uni-drawer__content {
|
||||
width: 100vw !important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user