bill_lai 5 年之前
父節點
當前提交
c53b70720b

+ 1 - 1
src/page/List/GeoList.tsx

@@ -15,7 +15,7 @@ export default function GeoList({ className }: any) {
     transformUrl: '/vector/command/geojson/',
     judgeUrl: '/vector/command/judge/coord/',
     ItemFn (model: Model) {
-      if (model.status === 8) {
+      if (model.status === 8 || model.status === 10 || model.status === 11 || model.status === 12) {
         return <Link to={"/style/" + model.id}>编辑样式</Link>
       }
     },

+ 1 - 1
src/page/List/GrentOper.tsx

@@ -137,7 +137,7 @@ export default function Grent({ setItemStaus, modelDispatch, referData, delHandl
             {api.judge && ((model.status === 2 || model.status === 9) && Jude)}
             {api.transform && ((model.status === 3 || model.status === 7) && Tran)}
             {api.section && (model.status === 4 && Sect)}
-            {api.transfer && (model.status === 5 && Tf)}
+            {api.transfer && (model.status === 5 || model.status === 8 || model.status === 11 || model.status === 10 || model.status === 12 && Tf)}
             <b onClick={() => delHandle(model)} style={{ cursor: 'pointer' }}>删除</b>
             {privItem && privItem(model)}
           </Fragment>

+ 6 - 1
src/page/List/ListState/action.ts

@@ -25,6 +25,9 @@ export const updateItemAction = (dispatch: Function, item: Model): Model => {
  * 7: 坐标转换失败
  * 8: 服务已发布
  * 9:判断中
+ * 10: 发布失败
+ * 11: 修改样式
+ * 12: 样式修改失败
  */
 function getStateLocal(item: any) {
   const map : {[key: string]: Array<string>} = {
@@ -38,7 +41,9 @@ function getStateLocal(item: any) {
     '7': ['geojsonPath'],
     '8': ['slicePath', 'geojsonPath', 'coordStrictPath', 'unZipPath', 'uploadPath'],
     '9': ['slicePath', 'geojsonPath', 'coordStrictPath', 'unZipPath', 'uploadPath'],
-    '10': ['slicePath', 'geojsonPath', 'coordStrictPath', 'unZipPath', 'uploadPath']
+    '10': ['slicePath', 'geojsonPath', 'coordStrictPath', 'unZipPath', 'uploadPath'],
+    '11': ['slicePath', 'geojsonPath', 'coordStrictPath', 'unZipPath', 'uploadPath'],
+    '12': ['slicePath', 'geojsonPath', 'coordStrictPath', 'unZipPath', 'uploadPath']
   }
 
   let key = map[item.status].find(key => item[key])

+ 20 - 6
src/page/StyleEdit/index.tsx

@@ -3,7 +3,8 @@ import { RouteComponentProps } from 'react-router'
 import { reducer, initialState, getLayersAction, updateLayerAction, saveLayersAction, Item } from './reducer'
 import VectorShow from '../components/VectorShow'
 
-type Attr = 'lineColor' | 'lineWidth' | 'fillColor'
+type Attr = 'lineColor' | 'lineWidth' | 'fillColor' | 'show'
+type EvAttr = 'value' | 'checked'
 
 function StyleEdit(props: RouteComponentProps) {
   let [state, dispatch] = useReducer(reducer, initialState)
@@ -15,8 +16,8 @@ function StyleEdit(props: RouteComponentProps) {
   useEffect(() => { getLayersAction(dispatch, params.id) }, [params.id])
   useEffect(() => { layer || setLayer(layers[0]) }, [layer, layers])
 
-  const changeHandle = (attr: Attr) => (ev: React.ChangeEvent<HTMLInputElement>) => {
-    updateLayerAction(dispatch, layer, { ...style, [attr]: ev.target.value })
+  const changeHandle = (attr: Attr, evAttr: EvAttr = 'value') => (ev: React.ChangeEvent<HTMLInputElement>) => {
+    updateLayerAction(dispatch, layer, { ...style, [attr]: ev.target[evAttr] })
   }
   const saveHandle = () => { saveLayersAction(style, params.id) }
   const verctorInfo = style && { ...style, url: style.getUrl }
@@ -28,9 +29,22 @@ function StyleEdit(props: RouteComponentProps) {
       </select>
       {style && (
         <Fragment>
-          <input type="color" value={style.fillColor} onChange={changeHandle('fillColor')} />
-          <input type="color" value={style.lineColor} onChange={changeHandle('lineColor')} />
-          <input type="number" value={style.lineWidth} onChange={changeHandle('lineWidth')} />
+          <div>
+            <label>填充颜色</label>
+            <input type="color" value={style.fillColor} onChange={changeHandle('fillColor')} />
+          </div>
+          <div>
+            <label>线条颜色</label>
+            <input type="color" value={style.lineColor} onChange={changeHandle('lineColor')} />
+          </div>
+          <div>
+            <label>线条厚度</label>
+            <input type="number" value={style.lineWidth} onChange={changeHandle('lineWidth')} />
+          </div>
+          <div>
+            <label>是否显示</label>
+            <input type="checkbox" checked={style.show} onChange={changeHandle('show', 'checked')} />
+          </div>
           <button onClick={saveHandle}>保存</button>
         </Fragment>
       )}

+ 3 - 1
src/page/StyleEdit/reducer.ts

@@ -7,6 +7,8 @@ export const UPDATELAYER = Symbol('update_layer')
 export const DELLAYER = Symbol('del_layer')
 export const LOADLAYERS = Symbol('load_layers')
 
+const PREV = process.env.NODE_ENV === 'development' ? '/test/a' : '/a'
+
 export interface Item extends LayerStyle {
   show: boolean,
   url: string,
@@ -101,7 +103,7 @@ export const getLayersAction = async (dispatch: Dispatch, id: number) => {
     lat: Number(data.latitude),
     lng: Number(data.longitude),
     url: layer.url,
-    getUrl: path.join('/test/a', layer.url, '/{z}/{x}/{y}.pbf')
+    getUrl: path.join(PREV, layer.url, '/{z}/{x}/{y}.pbf')
   }
 
   addLayerAction(dispatch, layer.name, style)

+ 6 - 4
src/page/components/VectorShow/index.tsx

@@ -22,7 +22,8 @@ interface Props extends LayerStyle {
   url: string,
   lng: number,
   lat: number,
-  height: number
+  height: number,
+  show: boolean
 }
 
 interface State {
@@ -56,13 +57,14 @@ class VectorView extends React.Component<Props, State> {
     if (this.clipLayer) {
       this.state.viewer.imageryLayers.remove(this.clipLayer, true)
     }
+    if (!this.props.show) return;
 
-    this.clipLayer = createMVTWithStyle(Cesium, ol, {
+    let layer = createMVTWithStyle(Cesium, ol, {
       url: this.props.url,
       style: createStyle(this.props)
     }) as any;
 
-    this.state.viewer.imageryLayers.addImageryProvider(this.clipLayer);
+    this.clipLayer = this.state.viewer.imageryLayers.addImageryProvider(layer);
   }
 
   componentDidMount () {
@@ -85,7 +87,7 @@ class VectorView extends React.Component<Props, State> {
 
   componentWillUnmount() {
     if (this.state.viewer) {
-      this.state.viewer.imageryLayers.remove(this.clipLayer, true)
+      this.clipLayer && this.state.viewer.imageryLayers.remove(this.clipLayer, true)
       this.state.viewer.destroy()
     }
   }

+ 3 - 1
src/page/components/item/index.tsx

@@ -21,7 +21,9 @@ const StatusMap : any = {
   '7': '坐标转换失败',
   '8':' 服务已发布',
   '9': '判断中',
-  '10': '发布失败'
+  '10': '发布失败',
+  '11': '待修改样式',
+  '12': '样式修改失败'
 }
 
 function Item(props: ItemProps | Header) : ReactElement {

+ 1 - 1
src/setupProxy.js

@@ -15,7 +15,7 @@ module.exports = app => {
   app.use(
     proxy('/test', {
       // target: 'http://192.168.0.10:8082',
-      target: 'http://map.4dage.com',
+      target: 'http://39.108.123.31:8082',
       changeOrigin: true,
       pathRewrite: {
         "^/test": "/"