diff --git a/api/app/lib/controllers/data/road.js b/api/app/lib/controllers/data/road.js
index 842c92b6..0060369b 100644
--- a/api/app/lib/controllers/data/road.js
+++ b/api/app/lib/controllers/data/road.js
@@ -1,7 +1,7 @@
'use strict';
const roadKeyMap = require('./road.json')
-async function importIn (ctx) {
+async function importIn(ctx) {
// 数据导入
try {
const models = ctx.fs.dc.models;
@@ -32,7 +32,7 @@ async function importIn (ctx) {
}
}
-async function get (ctx) {
+async function get(ctx) {
try {
const models = ctx.fs.dc.models;
const { level, road, sectionStart, sectionEnd } = ctx.query;
@@ -76,14 +76,14 @@ async function get (ctx) {
}
}
-async function getRoadSection (ctx) {
+async function getRoadSection(ctx) {
try {
const models = ctx.fs.dc.models;
const { level, road, sectionStart, sectionEnd } = ctx.query;
let findOption = {
where: {},
order: [['id', 'DESC']],
- attributes: ['id', 'routeName', 'startingPlaceName', 'stopPlaceName']
+ attributes: ['id', 'routeName', 'startingPlaceName', 'stopPlaceName', 'routeCode']
}
if (level) {
@@ -119,7 +119,7 @@ async function getRoadSection (ctx) {
}
}
-async function edit (ctx) {
+async function edit(ctx) {
try {
const models = ctx.fs.dc.models;
const data = ctx.request.body;
@@ -145,7 +145,7 @@ async function edit (ctx) {
}
}
-async function del (ctx) {
+async function del(ctx) {
try {
const models = ctx.fs.dc.models;
const { roadId } = ctx.params;
diff --git a/weapp/src/packages/components/inputPickers/index.jsx b/weapp/src/packages/components/inputPickers/index.jsx
new file mode 100644
index 00000000..94b865e1
--- /dev/null
+++ b/weapp/src/packages/components/inputPickers/index.jsx
@@ -0,0 +1,56 @@
+/*
+* 输入框筛选选择器
+*/
+import React, { useState, useEffect } from 'react'
+import { View, Picker, Image, Input, Text } from '@tarojs/components'
+import arrowIcon from '../../../static/img/patrol/arrow-down.svg'
+import './index.scss'
+
+export default function InputPicker(props) {
+ const { title, placeholder, selector, value, onInput, isView } = props
+ const [curSelector, setCurSelector] = useState([])
+
+ useEffect(() => {
+ setCurSelector(selector)
+ }, [])
+
+ useEffect(()=>{
+ handleInput({ detail: { value: value } })
+ },[value])
+
+ function handleInput({ detail: { value: v } }) {
+ onInput(v)
+ if (v) {
+ setCurSelector(selector.filter(item => item && item.includes(v)))
+ } else {
+ setCurSelector(selector)
+ }
+ }
+
+ const handlePickerChange = (e) => {
+ onInput(curSelector[e.detail.value])
+ }
+
+ return (
+
+
+ {title}
+
+
+ {
+ !isView &&
+
+
+
+ }
+
+ )
+}
diff --git a/weapp/src/packages/components/inputPickers/index.scss b/weapp/src/packages/components/inputPickers/index.scss
new file mode 100644
index 00000000..52649cdc
--- /dev/null
+++ b/weapp/src/packages/components/inputPickers/index.scss
@@ -0,0 +1,30 @@
+.input-picker {
+ display: flex;
+ justify-content: space-between;
+ height: 96px;
+ align-items: center;
+ background-color: #fff;
+ margin-bottom: 5px;
+
+ .input-box {
+ padding: 12px 0;
+ flex-grow: 1;
+ display: flex;
+ align-items: center;
+
+ .title {
+ margin-left: 12px;
+ }
+
+ .input {
+ margin-left: 20px;
+ flex-grow: 1;
+ }
+ }
+
+ .img {
+ width: 24px;
+ height: 14px;
+ margin: 0 30px;
+ }
+}
\ No newline at end of file
diff --git a/weapp/src/packages/patrol/index.jsx b/weapp/src/packages/patrol/index.jsx
index d7e752ae..a3dcccbb 100644
--- a/weapp/src/packages/patrol/index.jsx
+++ b/weapp/src/packages/patrol/index.jsx
@@ -3,6 +3,7 @@ import Taro, { useRouter } from '@tarojs/taro';
import { View, RadioGroup, Radio, Image, Input, Picker, Video } from '@tarojs/components';
import { AtButton, AtTextarea, AtImagePicker } from 'taro-ui';
import InputPicker from '../components/inputPicker';
+import InputPickers from '../components/inputPickers';
import VideoUpload from '../../components/uploads'
import request from '@/services/request';
import environment from '../../config';
@@ -49,6 +50,10 @@ const Index = () => {
const [sourceRoadStartSel, setSourceRoadStartSel] = useState([])
const [sourceRoadEndSel, setSourceRoadEndSel] = useState([])
+ const [codeRoadSel, setCodeRoadSel] = useState([])
+ const [roadList, setRoadList] = useState([])
+ const [codeRoad, setCodeRoad] = useState('')
+
const prjType =
isAnomaly ?
[
@@ -169,14 +174,18 @@ const Index = () => {
let nextSourceRoadSel = []
let nextSourceRoadStartSel = []
let nextSourceRoadEndSel = []
+ let nextCodeRoadSel = []
data.map(item => {
nextSourceRoadSel.push(item.routeName)
nextSourceRoadStartSel.push(item.startingPlaceName)
nextSourceRoadEndSel.push(item.stopPlaceName)
+ nextCodeRoadSel.push(item.routeCode)
})
setSourceRoadSel(nextSourceRoadSel)
setSourceRoadStartSel(nextSourceRoadStartSel)
setSourceRoadEndSel(nextSourceRoadEndSel)
+ setCodeRoadSel(nextCodeRoadSel)
+ setRoadList(data)
} else {
Taro.showToast({ title: res.data.message || '请求出错', icon: 'none' })
}
@@ -205,7 +214,7 @@ const Index = () => {
])
}, [reportType])
- function report () {
+ function report() {
if (!canReport) { return }
if (
(isPatrol && (!projectType || !road))
@@ -280,7 +289,7 @@ const Index = () => {
})
}
- function deleteReport () {
+ function deleteReport() {
Taro.showModal({
title: '提示',
content: '确定删除吗?',
@@ -307,7 +316,7 @@ const Index = () => {
})
}
- function handleInput ({ detail: { value } }, type) {
+ function handleInput({ detail: { value } }, type) {
switch (type) {
case 'roadSectionStart':
setRoadSectionStart(value)
@@ -339,15 +348,15 @@ const Index = () => {
}
}
- function handleTypeChange (e) {
+ function handleTypeChange(e) {
setReportType(e.detail.value)
}
- function handleImgChange (files, operationType, index, type) {
+ function handleImgChange(files, operationType, index, type) {
if (operationType === 'remove') {
setImg(false)
}
- function setImg (isAdd, url) {
+ function setImg(isAdd, url) {
switch (type) {
case 'scenePic':
let nextImg = sceneImg
@@ -434,12 +443,33 @@ const Index = () => {
}
}
- function handleImgClick (index, file) {
+ function handleImgClick(index, file) {
Taro.previewImage({
urls: [file.url] // 需要预览的图片http链接列表
})
}
+ useEffect(() => {
+ console.log(road, '所在道路的值');
+ let newRoadList = roadList.filter(e => e.routeName.match(road))
+ console.log(newRoadList, '过滤后的列表');
+ let codeRoadSel = []
+ if (newRoadList.length && road != '') {
+ newRoadList.forEach((e, index) => {
+ codeRoadSel.push(e.routeCode)
+ })
+ }
+ console.log(codeRoadSel, '最新的线路列表');
+ setCodeRoadSel(codeRoadSel)
+ if (codeRoadSel.length) {
+ setCodeRoad(codeRoadSel[0])
+ } else {
+ setCodeRoad('')
+ }
+ }, [road])
+ console.log(codeRoadSel, '线路编码');
+ console.log(sourceRoadSel, '所在道路');
+ console.log(roadList, '线路列表');
return (
{/* {
@@ -520,6 +550,18 @@ const Index = () => {
isView={isView}
/> : ''
}
+ {
+ isPatrol || isAnomaly ?
+ : ''
+ }
{
isPatrol || isAnomaly ?