接口对接修改
This commit is contained in:
@@ -15,9 +15,6 @@
|
||||
<uni-forms-item label="项目名称">
|
||||
<uni-easyinput v-model="formData.name" placeholder="请输入项目名称" />
|
||||
</uni-forms-item>
|
||||
<!-- <uni-forms-item label="项目类别">
|
||||
<uni-data-select v-model="formData.projectType" :localdata="TypeRange"></uni-data-select>
|
||||
</uni-forms-item> -->
|
||||
<uni-forms-item label="区域">
|
||||
<view style="display: flex">
|
||||
<uni-easyinput
|
||||
@@ -27,15 +24,44 @@
|
||||
v-model="formData.area"
|
||||
placeholder="请输入区域信息"
|
||||
/>
|
||||
<uni-icons type="location" color="#007aff" size="26" class="ml20" @click="chooseLocation"></uni-icons>
|
||||
<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>
|
||||
<view class="temp-choose">
|
||||
<view class="temp-choose-title">从模版库选择拓扑图</view>
|
||||
<view class="temp-choose-content">
|
||||
<view class="temp-choose-content-item" v-for="(item, index) in formData.tempFiles">
|
||||
<image
|
||||
class="temp-choose-content-item-img"
|
||||
:src="item.filePath"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<view class="temp-choose-content-item-close" @click="deleteImg(index)">
|
||||
<uni-icons style="font-size: 18px" type="closeempty" color="#fff" size="20" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="temp-choose-content-item" @click="openTemp">
|
||||
<uni-icons type="plusempty" size="70" color="#f1f1f1"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<uni-file-picker
|
||||
v-model="formData.files"
|
||||
title="请上传拓扑图"
|
||||
title="从本地上传拓扑图"
|
||||
:sourceType="['album']"
|
||||
@select="select"
|
||||
></uni-file-picker>
|
||||
@@ -44,9 +70,34 @@
|
||||
<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 ref="showRight" mode="right" :mask-click="false">
|
||||
<uni-indexed-list
|
||||
:options="engineeringListFilter"
|
||||
:showSelect="false"
|
||||
@click="closeDrawer"
|
||||
></uni-indexed-list>
|
||||
</uni-drawer>
|
||||
<uni-popup ref="showTemp" type="bottom" :mask-click="false">
|
||||
<view class="popup-header">
|
||||
<view class="popup-header-title">模版库</view>
|
||||
<view class="popup-header-close" @click="closeTemp">
|
||||
<uni-icons type="closeempty" color="#111" size="20" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="temp-list">
|
||||
<view
|
||||
class="temp-list-item"
|
||||
:class="{
|
||||
'temp-list-item-active': formData.tempFiles.some((item2) => item2.id === item.id),
|
||||
}"
|
||||
v-for="(item, index) in tempList"
|
||||
@click="chooseTempItem(item)"
|
||||
>
|
||||
<image class="temp-list-item-img" :src="item.filePath" mode="aspectFill" />
|
||||
<view class="temp-list-item-name">{{ item.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
@@ -54,6 +105,7 @@
|
||||
<script>
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
import { addAppProject } from '../../common/api/project'
|
||||
import { getTopoTemplate } from '../../common/api/device'
|
||||
import { queryEngineering } from '@/common/api/engineering.js'
|
||||
export default {
|
||||
data() {
|
||||
@@ -64,29 +116,22 @@ export default {
|
||||
engineeringName: '',
|
||||
area: '',
|
||||
files: [],
|
||||
tempFiles: [],
|
||||
topoIds: [],
|
||||
description: '',
|
||||
projectType: '1',
|
||||
name: '',
|
||||
lat: '2',
|
||||
lng: '3',
|
||||
},
|
||||
TypeRange: [
|
||||
{
|
||||
text: '监测',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
text: '用能',
|
||||
value: '2',
|
||||
},
|
||||
],
|
||||
gcList: [],
|
||||
engineeringList: [],
|
||||
tempList: [],
|
||||
project: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
gcListFilter() {
|
||||
engineeringListFilter() {
|
||||
let result = []
|
||||
this.gcList.forEach((item) => {
|
||||
this.engineeringList.forEach((item) => {
|
||||
let arr = pinyin(item.name[0], { toneType: 'none', type: 'array' })
|
||||
let letter = arr[0][0].toUpperCase()
|
||||
console.log(letter)
|
||||
@@ -103,7 +148,16 @@ export default {
|
||||
return result
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
onLoad(options) {
|
||||
if (options.project) {
|
||||
this.project = JSON.parse(decodeURIComponent(options.project))
|
||||
console.log(this.project)
|
||||
for (let key in this.formData) {
|
||||
if (this.project[key]) {
|
||||
this.formData[key] = this.project[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
@@ -113,17 +167,37 @@ export default {
|
||||
},
|
||||
})
|
||||
queryEngineering().then((res) => {
|
||||
this.gcList = res.data
|
||||
this.engineeringList = res.data
|
||||
})
|
||||
getTopoTemplate().then((res) => {
|
||||
console.log(res)
|
||||
this.tempList = res.data
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
deleteImg(index) {
|
||||
this.formData.tempFiles.splice(index, 1)
|
||||
},
|
||||
chooseTempItem(item) {
|
||||
if (this.formData.tempFiles.some((item2) => item2.id === item.id)) {
|
||||
this.formData.tempFiles = this.formData.tempFiles.filter((item2) => item2.id !== item.id)
|
||||
} else {
|
||||
this.formData.tempFiles.push(item)
|
||||
}
|
||||
},
|
||||
closeTemp() {
|
||||
this.$refs.showTemp.close()
|
||||
},
|
||||
openTemp() {
|
||||
this.$refs.showTemp.open()
|
||||
},
|
||||
showDrawer() {
|
||||
this.$refs.showRight.open()
|
||||
},
|
||||
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.formData.engineeringId = this.engineeringList.find((item) => item.name === e.item.name).id
|
||||
this.$refs.showRight.close()
|
||||
},
|
||||
select(e) {
|
||||
@@ -148,10 +222,6 @@ export default {
|
||||
this.$util.toast('请输入项目名称')
|
||||
return
|
||||
}
|
||||
if (!this.formData.projectType) {
|
||||
this.$util.toast('请选择项目类别')
|
||||
return
|
||||
}
|
||||
if (!this.formData.area) {
|
||||
this.$util.toast('请输入区域信息')
|
||||
return
|
||||
@@ -160,35 +230,39 @@ export default {
|
||||
this.$util.toast('请输入项目描述')
|
||||
return
|
||||
}
|
||||
if (!this.formData.files.length) {
|
||||
this.$util.toast('请上传拓扑图')
|
||||
if (!this.formData.files.length && !this.formData.tempFiles.length) {
|
||||
this.$util.toast('请至少选择一张拓扑图')
|
||||
return
|
||||
}
|
||||
let arr = []
|
||||
for (let i = 0; i < this.formData.files.length; i++) {
|
||||
let item = this.formData.files[i]
|
||||
console.log(item);
|
||||
console.log(item)
|
||||
arr.push({
|
||||
name: 'files',
|
||||
uri: item.url,
|
||||
})
|
||||
}
|
||||
this.formData.topoIds = this.formData.tempFiles.map((item) => item.id)
|
||||
let data = JSON.parse(JSON.stringify(this.formData))
|
||||
delete data.files
|
||||
addAppProject(data, arr).then((res) => {
|
||||
|
||||
console.warn(res);
|
||||
console.warn(res)
|
||||
if (res.length === 1) {
|
||||
this.$util.toast(res[0].message)
|
||||
return
|
||||
}
|
||||
|
||||
console.log(res)
|
||||
this.$util.toast('项目创建成功')
|
||||
this.$util.prePage().store?.reload()
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}, 1500)
|
||||
let result = JSON.parse(res[1].data)
|
||||
if (result.code === 'A0000') {
|
||||
this.$util.toast('项目创建成功')
|
||||
this.$util.prePage().store?.reload()
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({ delta: 1 })
|
||||
}, 1500)
|
||||
} else {
|
||||
this.$util.toast(result.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
@@ -228,6 +302,79 @@ export default {
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
}
|
||||
.temp-choose {
|
||||
margin-bottom: 44rpx;
|
||||
.temp-choose-title {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
.temp-choose-content {
|
||||
margin-top: 20rpx;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 198rpx);
|
||||
grid-gap: 10rpx;
|
||||
.temp-choose-content-item {
|
||||
box-sizing: border-box;
|
||||
border: 1px #eee solid;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 198rpx;
|
||||
.temp-choose-content-item-img {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: skyblue;
|
||||
display: block;
|
||||
}
|
||||
.temp-choose-content-item-close {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
z-index: 2;
|
||||
height: 52rpx;
|
||||
width: 52rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.temp-list {
|
||||
box-sizing: border-box;
|
||||
width: 750rpx;
|
||||
height: 80vh;
|
||||
padding: 20rpx;
|
||||
overflow-y: scroll;
|
||||
background: #fff;
|
||||
|
||||
.temp-list-item {
|
||||
margin-bottom: 10rpx;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
border: 4px solid #f1f1f1;
|
||||
.temp-list-item-img {
|
||||
height: 280rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.temp-list-item-name {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
background: #fff;
|
||||
padding: 4rpx 8rpx;
|
||||
}
|
||||
&-active {
|
||||
border: 4rpx solid $uni-theme-blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .uni-drawer__content {
|
||||
|
||||
Reference in New Issue
Block a user