创建项目接口修改
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<div class="header-item-label">离线设备</div>
|
||||
</div>
|
||||
</div>
|
||||
<view style="padding:20rpx 20rpx 0">
|
||||
<view style="padding: 20rpx 20rpx 0">
|
||||
<Cn-grid title="常用功能">
|
||||
<Cn-grid-item src="/static/device2.png" text="设备注册" @click="registerDevice"></Cn-grid-item>
|
||||
<Cn-grid-item src="/static/gateway2.png" text="网关注册" @click="registerGateway"></Cn-grid-item>
|
||||
@@ -22,23 +22,31 @@
|
||||
</Cn-grid>
|
||||
</view>
|
||||
<view class="nav">
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectName }" @click="showDrawer">{{
|
||||
select.projectName || '工程' }} </view>
|
||||
<picker @change="projectNameChange" :value="select.projectNameIndex" :range="projectList" range-key="text">
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectName }">{{
|
||||
select.projectName || '项目' }} </view>
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.engineeringName }" @click="showDrawer"
|
||||
>{{ select.engineeringName || '工程' }}
|
||||
</view>
|
||||
<picker @change="projectNameChange" :value="select.projectNameIndex" :range="projectListFilter" range-key="text">
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectName }">{{ select.projectName || '项目' }} </view>
|
||||
</picker>
|
||||
<picker @change="projectTypeChange" :value="select.projectTypeIndex" :range="projectType" range-key="text">
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectType }">{{
|
||||
select.projectType || '类型' }} </view>
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectType }">{{ select.projectType || '类型' }} </view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="content device" :style="{ minHeight: minHeight }">
|
||||
<uni-card :title="item.name" :sub-title="item.project" :extra="item.type" padding="0"
|
||||
v-for="(item, index) in deviceListFilter" :key="index" @click="jump(item)" thumbnail="/static/device.png">
|
||||
<uni-card
|
||||
:title="item.equipmentName"
|
||||
:sub-title="item.projectName"
|
||||
:extra="item.projectType"
|
||||
padding="0"
|
||||
v-for="(item, index) in deviceListFilter"
|
||||
:key="index"
|
||||
@click="jump(item)"
|
||||
thumbnail="/static/device.png"
|
||||
>
|
||||
<!-- <text>{{ item.project }} {{ item.type }}</text> -->
|
||||
</uni-card>
|
||||
<uni-load-more status="nomore"></uni-load-more>
|
||||
<Cn-empty v-if="store.empty || deviceListFilter.length == 0"></Cn-empty>
|
||||
<uni-load-more v-if="deviceListFilter && deviceListFilter.length > 0" :status="store.status"></uni-load-more>
|
||||
</view>
|
||||
<uni-drawer ref="showRight" mode="right" :mask-click="false" :width="375">
|
||||
<uni-indexed-list :options="gcListFilter" :showSelect="false" @click="closeDrawer"></uni-indexed-list>
|
||||
@@ -46,10 +54,28 @@
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { pinyin } from 'pinyin-pro';
|
||||
import { queryEngineering } from '@/common/api/gc.js'
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
|
||||
export default {
|
||||
name: 'IndexGongCheng',
|
||||
props: {
|
||||
store: {
|
||||
type: Object,
|
||||
default: {},
|
||||
},
|
||||
projectList: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
projectType: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
gcList: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
@@ -58,53 +84,9 @@ export default {
|
||||
projectName: '',
|
||||
projectNameIndex: 0,
|
||||
projectType: '',
|
||||
projectTypeIndex: 0
|
||||
projectTypeIndex: 0,
|
||||
engineeringName: '',
|
||||
},
|
||||
projectType: [
|
||||
{
|
||||
text: '全部类型',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
text: '监测',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
text: '用能',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
text: '环境',
|
||||
value: 3
|
||||
},
|
||||
{
|
||||
text: '安防',
|
||||
value: 4
|
||||
},
|
||||
{
|
||||
text: '其他',
|
||||
value: 5
|
||||
}
|
||||
],
|
||||
projectList: [
|
||||
{
|
||||
text: '全部项目',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
text: 'XXX项目1',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
text: 'XXX项目2',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
text: 'XXX项目3',
|
||||
value: 1
|
||||
},
|
||||
|
||||
],
|
||||
navHeight: 0,
|
||||
minHeight: '',
|
||||
deviceList: [
|
||||
@@ -124,99 +106,83 @@ export default {
|
||||
name: '设备APF-3',
|
||||
des: '设备描述2',
|
||||
type: '用能',
|
||||
project: 'XXX项目2'
|
||||
project: 'XXX项目2',
|
||||
},
|
||||
{
|
||||
name: '设备DVR-1',
|
||||
des: '设备描述3',
|
||||
type: '监测',
|
||||
project: 'XXX项目3'
|
||||
}
|
||||
project: 'XXX项目3',
|
||||
},
|
||||
],
|
||||
gcList: [
|
||||
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
gcListFilter() {
|
||||
// [{
|
||||
// "letter": "A",
|
||||
// "data": [
|
||||
// "阿克苏机场",
|
||||
// "阿拉山口机场",
|
||||
// "阿勒泰机场",
|
||||
// "阿里昆莎机场",
|
||||
// "安庆天柱山机场",
|
||||
// "澳门国际机场"
|
||||
// ]
|
||||
// }, {
|
||||
// "letter": "B",
|
||||
// "data": [
|
||||
// "保山机场",
|
||||
// "包头机场",
|
||||
// "北海福成机场",
|
||||
// "北京南苑机场",
|
||||
// "北京首都国际机场"
|
||||
// ]
|
||||
// }]
|
||||
|
||||
let result = []
|
||||
this.gcList.forEach(item => {
|
||||
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)
|
||||
console.log(letter)
|
||||
let index = result.findIndex((item) => item.letter === letter)
|
||||
if (index === -1) {
|
||||
result.push({
|
||||
letter,
|
||||
data: [item.name]
|
||||
data: [item.name],
|
||||
})
|
||||
} else {
|
||||
result[index].data.push(item.name)
|
||||
}
|
||||
})
|
||||
return result
|
||||
|
||||
},
|
||||
deviceListFilter() {
|
||||
return this.deviceList.filter(item => {
|
||||
if (this.select.projectName) {
|
||||
return item.project === this.select.projectName
|
||||
} else if (this.select.projectType) {
|
||||
return item.type === this.select.projectType
|
||||
let arr = this.store.data
|
||||
if (this.select.projectName) {
|
||||
arr = arr.filter((item) => item.projectName === this.select.projectName)
|
||||
}
|
||||
if (this.select.projectType) {
|
||||
arr = arr.filter((item) => item.projectType === this.select.projectType)
|
||||
}
|
||||
if (this.select.engineeringName) {
|
||||
arr = arr.filter((item) => item.engineeringName === this.select.engineeringName)
|
||||
}
|
||||
return arr
|
||||
},
|
||||
projectListFilter() {
|
||||
return this.projectList.filter((item) => {
|
||||
if (this.select.engineeringName) {
|
||||
return item.engineeringName === this.select.engineeringName
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
showDrawer() {
|
||||
this.$refs.showRight.open();
|
||||
this.$refs.showRight.open()
|
||||
},
|
||||
closeDrawer(e) {
|
||||
console.log(e);
|
||||
|
||||
this.$refs.showRight.close();
|
||||
},
|
||||
submitFeedBack() { uni.navigateTo({ url: '/pages/home/feedback' }) },
|
||||
projectTypeChange(e) {
|
||||
// 重置name
|
||||
console.log(e)
|
||||
this.select.engineeringName = e.item.name
|
||||
this.select.projectName = ''
|
||||
this.select.projectNameIndex = 0
|
||||
|
||||
this.$refs.showRight.close()
|
||||
},
|
||||
submitFeedBack() {
|
||||
uni.navigateTo({ url: '/pages/home/feedback' })
|
||||
},
|
||||
projectTypeChange(e) {
|
||||
this.select.projectTypeIndex = e.detail.value
|
||||
if (e.detail.value === 0) {
|
||||
this.select.projectType = ''
|
||||
return
|
||||
}
|
||||
this.select.projectType = this.projectType[e.detail.value].text
|
||||
|
||||
|
||||
},
|
||||
projectNameChange(e) {
|
||||
console.log(e);
|
||||
console.log(e)
|
||||
// 重置type
|
||||
this.select.projectType = ''
|
||||
this.select.projectTypeIndex = 0
|
||||
@@ -238,57 +204,52 @@ export default {
|
||||
success: ({ confirm, cancel }) => {
|
||||
if (confirm) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/device/new'
|
||||
url: '/pages/device/new',
|
||||
})
|
||||
} else if (cancel) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/gateway/list'
|
||||
url: '/pages/gateway/list',
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
registerGateway() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/gateway/new'
|
||||
url: '/pages/gateway/new',
|
||||
})
|
||||
},
|
||||
navMenuClick(index) {
|
||||
this.navMenuActive = index
|
||||
},
|
||||
jump(item) {
|
||||
if (item.name.indexOf('APF') > -1) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/device/APF/detail'
|
||||
})
|
||||
} else if (item.name.indexOf('DVR') > -1) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/device/DVR/detail'
|
||||
})
|
||||
}
|
||||
},
|
||||
init(){
|
||||
queryEngineering().then(res => {
|
||||
this.gcList = res.data
|
||||
uni.navigateTo({
|
||||
url: '/pages/device/APF/detail',
|
||||
})
|
||||
}
|
||||
},
|
||||
init() {
|
||||
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.userInfo = uni.getStorageSync('userInfo')
|
||||
setTimeout(() => {
|
||||
this.init()
|
||||
// 获取nav高度
|
||||
uni.createSelectorQuery().select('.nav').boundingClientRect((rect) => {
|
||||
this.navHeight = rect.height
|
||||
// #ifdef H5
|
||||
this.minHeight = 'calc(100vh - env(safe-area-inset-bottom) - ' + (50 + this.navHeight) + 'px)'
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
this.minHeight = 'calc(100vh - ' + this.navHeight + 'px)'
|
||||
// #endif
|
||||
}).exec()
|
||||
}, 1000);
|
||||
}
|
||||
uni.createSelectorQuery()
|
||||
.select('.nav')
|
||||
.boundingClientRect((rect) => {
|
||||
this.navHeight = rect.height
|
||||
// #ifdef H5
|
||||
this.minHeight = 'calc(100vh - env(safe-area-inset-bottom) - ' + (50 + this.navHeight) + 'px)'
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
this.minHeight = 'calc(100vh - ' + this.navHeight + 'px)'
|
||||
// #endif
|
||||
})
|
||||
.exec()
|
||||
}, 1000)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang='scss'></style>
|
||||
<style lang="scss"></style>
|
||||
|
||||
Reference in New Issue
Block a user