wenlele 1 year ago
parent
commit
0c147b854f
  1. 14
      api/app/lib/controllers/data/road.js
  2. 4
      weapp/src/app.config.js
  3. 35
      weapp/src/packages/maintenanceSpotCheck/components/skeleton/index.jsx
  4. 43
      weapp/src/packages/maintenanceSpotCheck/components/skeleton/index.scss
  5. 46
      weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx
  6. 38
      weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx
  7. 125
      weapp/src/packages/patrol/index.jsx
  8. 2
      weapp/src/pages/user/index.jsx

14
api/app/lib/controllers/data/road.js

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const roadKeyMap = require('./road.json') const roadKeyMap = require('./road.json')
async function importIn (ctx) { async function importIn(ctx) {
// 数据导入 // 数据导入
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -32,7 +32,7 @@ async function importIn (ctx) {
} }
} }
async function get (ctx) { async function get(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { codePrefix, level, road, sectionStart, sectionEnd, alterId } = ctx.query; const { codePrefix, level, road, sectionStart, sectionEnd, alterId } = ctx.query;
@ -86,14 +86,14 @@ async function get (ctx) {
} }
} }
async function getRoadSection (ctx) { async function getRoadSection(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { level, road, sectionStart, sectionEnd } = ctx.query; const { level, road, sectionStart, sectionEnd } = ctx.query;
let findOption = { let findOption = {
where: {}, where: {},
order: [['id', 'DESC']], order: [['id', 'DESC']],
attributes: ['id', 'routeName', 'startingPlaceName', 'stopPlaceName', 'routeCode', 'sectionNo'] attributes: ['id', 'routeName', 'startingPlaceName', 'stopPlaceName', 'routeCode', 'sectionNo', 'level']
} }
if (level) { if (level) {
@ -129,7 +129,7 @@ async function getRoadSection (ctx) {
} }
} }
async function edit (ctx) { async function edit(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const data = ctx.request.body; const data = ctx.request.body;
@ -155,7 +155,7 @@ async function edit (ctx) {
} }
} }
async function del (ctx) { async function del(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { roadId } = ctx.params; const { roadId } = ctx.params;
@ -176,7 +176,7 @@ async function del (ctx) {
} }
} }
async function getVillageList (ctx) { async function getVillageList(ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { } = ctx.query; const { } = ctx.query;

4
weapp/src/app.config.js

@ -51,7 +51,7 @@ export default {
] ]
}, },
usingComponents: { usingComponents: {
'chart-wx': 'components/wx-chart/chart', // 'chart-wx': 'components/wx-chart/chart',
"van-icon": "components/vant-weapp/icon/index", "van-icon": "components/vant-weapp/icon/index",
"van-dropdown-menu": "components/vant-weapp/dropdown-menu/index", "van-dropdown-menu": "components/vant-weapp/dropdown-menu/index",
"van-dropdown-item": "components/vant-weapp/dropdown-item/index", "van-dropdown-item": "components/vant-weapp/dropdown-item/index",
@ -60,7 +60,7 @@ export default {
"van-row": "components/vant-weapp/row/index", "van-row": "components/vant-weapp/row/index",
"van-col": "components/vant-weapp/col/index", "van-col": "components/vant-weapp/col/index",
"van-transition": "components/vant-weapp/transition/index", "van-transition": "components/vant-weapp/transition/index",
"ec-canvas": "components/ec-canvas/ec-canvas" // "ec-canvas": "components/ec-canvas/ec-canvas"
} }
} }

35
weapp/src/packages/maintenanceSpotCheck/components/skeleton/index.jsx

@ -0,0 +1,35 @@
/*
* 骨架屏
*/
import React from 'react'
import { View } from '@tarojs/components'
import './index.scss'
export default function Skeleton(props) {
const { length } = props
const render = () => {
let node = []
for (let i = 0; i < length; i++) {
node.push(
<View className='skeleton'>
<View className='ul'>
<View className='li' />
<View className='li' />
<View className='li' />
<View className='li' />
<View className='li' />
<View className='li' />
</View>
</View>
)
}
return node
}
return (
<View>
{render()}
</View>
)
}

43
weapp/src/packages/maintenanceSpotCheck/components/skeleton/index.scss

@ -0,0 +1,43 @@
.screen-root {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
margin-top: 20vh;
}
.ul {
background-color: #fff;
margin: 0 auto;
padding: 20px;
width: 90vw;
}
.li {
background-image: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
width: 100%;
height: 0.9rem;
list-style: none;
background-size: 400% 100%;
margin-top: 0.9rem;
background-position: 100% 50%;
animation: skeleton-loading 1.4s ease infinite;
}
.li:first-child {
width: 38%;
}
.li:last-child {
width: 61%;
}
@keyframes skeleton-loading {
0% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}

46
weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import Taro, { useRouter } from '@tarojs/taro' import Taro, { useRouter } from '@tarojs/taro'
import { View, Text, Picker, } from '@tarojs/components' import { View, Text, Picker, Input } from '@tarojs/components'
import { AtButton, AtIcon, } from 'taro-ui' import { AtButton, AtIcon, } from 'taro-ui'
import request from '@/services/request' import request from '@/services/request'
import { roadSpotChange, roadUrl } from '@/services/api' import { roadSpotChange, roadUrl } from '@/services/api'
@ -77,18 +77,23 @@ function Index() {
[key]: value [key]: value
} }
let routeName = []
let routeCode = [] let routeCode = []
let sectionNo = [] let sectionNo = []
let data = [...road] let data = [...road]
data.forEach(v => { if (key == 'routeName') {
if (v.routeName && !routeName.includes(v.routeName)) { // routeName
routeName.push(v.routeName) let routeName = []
road.forEach(item => {
if (item.routeName && !routeName.includes(item.routeName)) {
routeName.push(item.routeName)
}
})
if (value) {
routeName = routeName.filter(item => item.indexOf(value) > -1)
} }
}); setNameList(routeName)
if (key == 'routeName') {
nextValue.routeCode = '' nextValue.routeCode = ''
nextValue.sectionNo = '' nextValue.sectionNo = ''
data?.forEach(v => { data?.forEach(v => {
@ -115,8 +120,6 @@ function Index() {
setNoList(sectionNo) setNoList(sectionNo)
} }
setNameList(routeName)
if (nextValue?.routeName) { if (nextValue?.routeName) {
setRouteCodeDisabled(false) setRouteCodeDisabled(false)
} else { } else {
@ -181,16 +184,23 @@ function Index() {
<View className='cell'> <View className='cell'>
<View className='title'><Text className='star'>*</Text>路线名称</View> <View className='title'><Text className='star'>*</Text>路线名称</View>
<View className='content'> <View className='content'>
<Picker <View className='picker'>
mode='selector'
range={nameList} <Input
onChange={e => handleCheckChange(nameList[e.detail.value], 'routeName')} type='text'
> placeholder='输入关键字筛选'
<View className='picker'> border={false}
<View>{checked.routeName || '请选择'}</View> value={checked.routeName}
onInput={e => handleCheckChange(e.detail.value, 'routeName')}
/>
<Picker
mode='selector'
range={nameList}
onChange={e => handleCheckChange(nameList[e.detail.value], 'routeName')}
>
<AtIcon className='arrow' value='chevron-down' size='20' color='#999' /> <AtIcon className='arrow' value='chevron-down' size='20' color='#999' />
</View> </Picker>
</Picker> </View>
<AtIcon <AtIcon
value='close-circle' value='close-circle'
size='20' size='20'

38
weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx

@ -3,6 +3,7 @@ import Taro, { useRouter, useDidShow } from '@tarojs/taro'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import { AtButton, AtSearchBar } from 'taro-ui' import { AtButton, AtSearchBar } from 'taro-ui'
import { NoData } from '@/components/index' import { NoData } from '@/components/index'
import Skeleton from '../components/skeleton'
import moment from 'moment' import moment from 'moment'
import request from '@/services/request' import request from '@/services/request'
import { getRoadSpotDetail } from '@/services/api' import { getRoadSpotDetail } from '@/services/api'
@ -14,6 +15,7 @@ function Index() {
const [keyword, setKeyword] = useState('') const [keyword, setKeyword] = useState('')
const [roadDetailList, setRoadDetailList] = useState([]) const [roadDetailList, setRoadDetailList] = useState([])
const [isNoData, setIsNoData] = useState(false)
useDidShow(() => { useDidShow(() => {
getDetail() getDetail()
@ -29,21 +31,17 @@ function Index() {
} else { } else {
Taro.showToast({ title: '获取详情失败', icon: 'error' }) Taro.showToast({ title: '获取详情失败', icon: 'error' })
} }
if (res.data?.length) {
setIsNoData(false)
} else {
setIsNoData(true)
}
}) })
} }
} }
return (<View className='page'> const renderList = () => {
<AtSearchBar return roadDetailList.length ? roadDetailList.map(item => <View key={item.id} className='card'>
placeholder='道路名称关键字'
showActionButton
value={keyword}
onChange={v => setKeyword(v)}
onActionClick={getDetail}
/>
<View className='top flex'>抽查日期{moment(spotItem.date).format('YYYY-MM-DD')}</View>
{roadDetailList.length ? roadDetailList.map(item => <View key={item.id} className='card'>
<View className='item'>道路类型{item.road?.level ? (item.road?.level + '道') : '--'}</View> <View className='item'>道路类型{item.road?.level ? (item.road?.level + '道') : '--'}</View>
<View className='item'>路线名称{item.road?.routeName || '--'}</View> <View className='item'>路线名称{item.road?.routeName || '--'}</View>
<View className='item at-row'> <View className='item at-row'>
@ -70,7 +68,23 @@ function Index() {
>调整</AtButton> >调整</AtButton>
</View> </View>
</View> </View>
</View>) : <View style={{ paddingTop: 100 }}><NoData /></View>} </View>) : <Skeleton length={3} />
}
const renderNoData = () => {
return <View style={{ marginTop: 100 }}><NoData /></View>
}
return (<View className='page'>
<AtSearchBar
placeholder='道路名称关键字'
showActionButton
value={keyword}
onChange={v => setKeyword(v)}
onActionClick={getDetail}
/>
<View className='top flex'>抽查日期{moment(spotItem.date).format('YYYY-MM-DD')}</View>
{isNoData ? renderNoData() : renderList()}
</View>) </View>)
} }

125
weapp/src/packages/patrol/index.jsx

@ -206,6 +206,23 @@ const Index = () => {
const [appointUser, setAppointUser] = useState(null) // userListindex const [appointUser, setAppointUser] = useState(null) // userListindex
const [handleAdvice, setHandleAdvice] = useState('') // const [handleAdvice, setHandleAdvice] = useState('') //
const [roadTypeList, setRoadTypeList] = useState([
{
value: '县',
text: '县道',
checked: true
},
{
value: '乡',
text: '乡道',
checked: false
},
{
value: '村',
text: '村道',
checked: false
},
]);
const [routeNameList, setRouteNameList] = useState([]); const [routeNameList, setRouteNameList] = useState([]);
const [routeCodeList, setRouteCodeList] = useState([]); const [routeCodeList, setRouteCodeList] = useState([]);
const [sectionNoList, setSectionNoList] = useState([]); const [sectionNoList, setSectionNoList] = useState([]);
@ -328,7 +345,19 @@ const Index = () => {
setHandleCenter(data.handleContent) setHandleCenter(data.handleContent)
} }
setIsBeforeReport(dayjs(data.time).diff('2023-08-03 00:00:00', 'h') < 0) setIsBeforeReport(dayjs(data.time).diff('2023-08-03 00:00:00', 'h') < 0)
//
let items = roadTypeList
const head = data.codeRoad?.slice(0, 1)
const level = head
? head === 'X'
? '县' : head === 'Y'
? '乡' : '村'
: ''
for (let i = 0, len = items.length; i < len; ++i) {
items[i].checked = items[i].value === (data.road_?.level || level)
}
setRoadTypeList(items)
//
setRoadChecked({ setRoadChecked({
routeName: data.road, routeName: data.road,
routeCode: data.codeRoad, routeCode: data.codeRoad,
@ -378,6 +407,7 @@ const Index = () => {
}) })
} }
}) })
//
request.get(getRoadSection()).then(res => { request.get(getRoadSection()).then(res => {
Taro.hideLoading() Taro.hideLoading()
if (res.statusCode == 200 || res.statusCode == 204) { if (res.statusCode == 200 || res.statusCode == 204) {
@ -390,12 +420,13 @@ const Index = () => {
let routeCode = [] let routeCode = []
let sectionNo = [] let sectionNo = []
const selLevel = roadTypeList.find(item => item.checked).value
data.forEach(item => { data.forEach(item => {
nextSourceRoadStartSel.push(item.startingPlaceName) nextSourceRoadStartSel.push(item.startingPlaceName)
nextSourceRoadEndSel.push(item.stopPlaceName) nextSourceRoadEndSel.push(item.stopPlaceName)
nextCodeRoadSel.push(item.routeCode) nextCodeRoadSel.push(item.routeCode)
if (item.routeName && !routeName.includes(item.routeName)) { if (item.routeName && !routeName.includes(item.routeName) && item.level === selLevel) {
routeName.push(item.routeName) routeName.push(item.routeName)
} }
if (item.routeCode && !routeCode.includes(item.routeCode)) { if (item.routeCode && !routeCode.includes(item.routeCode)) {
@ -726,22 +757,28 @@ const Index = () => {
} }
} }
const handleRoadCheckChange = (value, key) => { const handleRoadCheckChange = (value, key, typeList = roadTypeList) => {
let nextValue = { let nextValue = {
...roadChecked, ...roadChecked,
[key]: value [key]: value
} }
let routeName = []
let routeCode = [] let routeCode = []
let sectionNo = [] let sectionNo = []
let data = [...roadList] let data = roadList.filter(r => r.level === typeList.find(t => t.checked).value)
data.forEach(v => {
if (v.routeName && !routeName.includes(v.routeName)) {
routeName.push(v.routeName)
}
});
if (key == 'routeName') { if (key == 'routeName') {
// routeName
let routeName = []
data.forEach(item => {
if (item.routeName && !routeName.includes(item.routeName)) {
routeName.push(item.routeName)
}
})
if (value) {
routeName = routeName.filter(item => item.indexOf(value) > -1)
}
setRouteNameList(routeName)
nextValue.routeCode = '' nextValue.routeCode = ''
nextValue.sectionNo = '' nextValue.sectionNo = ''
data?.forEach(v => { data?.forEach(v => {
@ -768,8 +805,6 @@ const Index = () => {
setSectionNoList(sectionNo) setSectionNoList(sectionNo)
} }
setRouteNameList(routeName)
if (nextValue?.routeName) { if (nextValue?.routeName) {
setRouteCodeDisabled(false) setRouteCodeDisabled(false)
} else { } else {
@ -1039,24 +1074,58 @@ const Index = () => {
} }
}) })
} }
function roadTypeChange(e) {
let items = roadTypeList
for (let i = 0, len = items.length; i < len; ++i) {
items[i].checked = items[i].value === e.detail.value
}
handleRoadCheckChange('', 'routeName', items)
setRoadTypeList(items)
}
return ( return (
<View className='patrol'> <View className='patrol'>
{ {
isPatrol || isAnomaly ? <> isPatrol || isAnomaly ? <>
<View className='code-choice'>
<Text style={{ color: 'red' }}>*&nbsp;</Text>道路类型
<View className='radio-list'>
<RadioGroup onChange={roadTypeChange}>
{roadTypeList.map((item, i) => {
return <Radio
className='radio'
color='#2579C7'
value={item.value}
checked={item.checked}
disabled={isView}
>{item.text}</Radio>
})}
</RadioGroup>
</View>
</View>
<View className='code-choice'> <View className='code-choice'>
<Text style={{ color: 'red' }}>*&nbsp;</Text>路线名称 <Text style={{ color: 'red' }}>*&nbsp;</Text>路线名称
<View className='select-box'> <View className='select-box'>
<Picker <View className='picker'>
mode='selector' <Input
range={routeNameList} style={{ textAlign: 'right' }}
onChange={e => handleRoadCheckChange(routeNameList[e.detail.value], 'routeName')} type='text'
disabled={isView} placeholder='输入关键字筛选'
> border={false}
<View className='picker'> value={roadChecked.routeName}
<View>{roadChecked.routeName || '请选择路线名称'}</View> onInput={e => handleRoadCheckChange(e.detail.value, 'routeName')}
disabled={isView}
/>
<Picker
mode='selector'
range={routeNameList}
onChange={e => handleRoadCheckChange(routeNameList[e.detail.value], 'routeName')}
disabled={isView}
>
<AtIcon className='arrow' value='chevron-down' size='20' color='#999' /> <AtIcon className='arrow' value='chevron-down' size='20' color='#999' />
</View> </Picker>
</Picker> </View>
{!isView && <AtIcon {!isView && <AtIcon
value='close-circle' value='close-circle'
size='20' size='20'
@ -1109,18 +1178,6 @@ const Index = () => {
/>} />}
</View> </View>
</View> </View>
<View className='code-choice'>
<Text style={{ color: 'red' }}>*&nbsp;</Text>道路类型
<Input
style={{ width: '30%' }}
type='text'
value={isView && isBeforeReport
? projectType
: roadCodeHead === 'X' ? '县道' : roadCodeHead === 'Y' ? '乡道' : '村道'}
onInput={() => { }}
disabled={true}
/>
</View>
</> : '' </> : ''
} }

2
weapp/src/pages/user/index.jsx

@ -11,8 +11,6 @@ import moreImg from '../../static/img/my/more.svg';
import pswdImg from '../../static/img/my/pswd.svg'; import pswdImg from '../../static/img/my/pswd.svg';
import reportImg from '../../static/img/my/report.svg'; import reportImg from '../../static/img/my/report.svg';
import Common from '../../components/echartForWx/common'; //
const { webUrl } = cfg; const { webUrl } = cfg;
const Index = ({ ...props }) => { const Index = ({ ...props }) => {

Loading…
Cancel
Save