xieqy 2 years ago
parent
commit
58d686d054

+ 32 - 0
src/directives.ts

@@ -109,3 +109,35 @@ Vue.directive('drag', {
     }
   }
 })
+//大屏浮动窗指令
+// v-Gpdrag 框拖动
+Vue.directive('Gpdrag', {
+  bind(el) {
+    const oDiv = el.querySelector('.header') // 当前元素
+    const dDiv = el
+    const self = this // 上下文
+    // 禁止选择网页上的文字
+    document.onselectstart = function () {
+      return false
+    }
+    oDiv.onmousedown = function (e) {
+      // 鼠标按下,计算当前元素距离可视区的距离
+      const disX = e.clientX - dDiv.offsetLeft
+      const disY = e.clientY - dDiv.offsetTop
+      document.onmousemove = function (e) {
+        // 通过事件委托,计算移动的距离
+        const l = e.clientX - disX
+        const t = e.clientY - disY
+        // 移动当前元素
+        dDiv.style.left = l + 'px'
+        dDiv.style.top = t + 'px'
+      }
+      document.onmouseup = function (e) {
+        document.onmousemove = null
+        document.onmouseup = null
+      }
+      // return false不加的话可能导致黏连,就是拖到一个地方时div粘在鼠标上不下来,相当于onmouseup失效
+      // return false
+    }
+  }
+})

+ 7 - 7
src/views/groupPage/components/ComCardBox.vue

@@ -59,13 +59,13 @@ export default class ComCardBox extends Vue {
       0 0,
       0 0,
       100% 0,
-      100% calc(100% - 0.208333rem /* 40/192 */),
-      calc(100% - 0.260417rem /* 50/192 */) 100%,
+      100% calc(100% - 0.234375rem /* 45/192 */),
+      calc(100% - 0.234375rem /* 45/192 */) 100%,
       0 100%,
       0 0,
       0 0
     );
-    background: linear-gradient(-39deg, $borderColor 0.161458rem /* 31/192 */, $backgroundColor 0) bottom right,
+    background: linear-gradient(-45deg, $borderColor 0.161458rem /* 31/192 */, $backgroundColor 0) bottom right,
       linear-gradient(45deg, $borderColor 0, $backgroundColor 0) bottom left,
       linear-gradient(135deg, $borderColor 0, $backgroundColor 0) top left,
       linear-gradient(-135deg, $borderColor 0, $backgroundColor 0) top right;
@@ -92,12 +92,12 @@ export default class ComCardBox extends Vue {
   }
   .box-outline {
     position: absolute;
-    top: 0.182292rem /* 35/192 */;
+    top: 0.520833rem /* 100/192 */;
     left: -0.026042rem /* 5/192 */;
-    height: calc(var(--height) - 0.15625rem /* 30/192 */);
+    height: calc(var(--height) - 0.494792rem /* 95/192 */);
     width: calc(var(--width) - 0.052083rem /* 10/192 */);
-    clip-path: polygon(10px 0, 0 0, 100% 0, 100% calc(100% - 25px), calc(100% - 30px) 100%, 0 100%, 0 0, 0 10px);
-    background: linear-gradient(-39deg, $borderColor 20px, transparent 0) bottom right,
+    clip-path: polygon(10px 0, 0 0, 100% 0, 100% calc(100% - 31px), calc(100% - 28px) 100%, 0 100%, 0 0, 0 10px);
+    background: linear-gradient(-45deg, $borderColor 20px, transparent 0) bottom right,
       linear-gradient(45deg, $borderColor 0, transparent 0) bottom left,
       linear-gradient(135deg, $borderColor 8px, transparent 0) top left,
       linear-gradient(-135deg, $borderColor 0, transparent 0) top right;

+ 1 - 1
src/views/groupPage/components/ComTreeList.vue

@@ -11,7 +11,7 @@
       size="small"
       :popper-append-to-body="false"
     >
-      <el-option :value="treeValue.id" :label="treeValue.label" style="max-width: 260px; height: auto; padding: 0">
+      <el-option :value="treeValue.id" :label="treeValue.label" style="height: auto; padding: 0">
         <el-tree
           :data="datas"
           :props="defaultProps"

+ 4 - 3
src/views/groupPage/districtPageModules/customTools/infoComponents/pipeInfo.vue

@@ -12,7 +12,7 @@
       <div class="content-item">
         <div class="name">(设计):</div>
         <div class="value">
-          {{ displayData.design.name }}<br />
+          {{ displayData.design.name || '无' }}<br />
           设计长度{{ displayData.design.total }}M, 管道部件{{ displayData.design.pipe }}个,管点部件{{
             displayData.design.node
           }}个
@@ -21,7 +21,7 @@
       <div class="content-item">
         <div class="name">(施工):</div>
         <div class="value">
-          {{ displayData.con.name }}<br />
+          {{ displayData.con.name || '无' }}<br />
           施工{{ displayData.con.pipeLen }}米,扫码{{ displayData.con.part }}个部件,扫码{{
             displayData.con.times
           }}次,上传{{ displayData.con.pictures }}张图片
@@ -30,7 +30,7 @@
       <div class="content-item">
         <div class="name">(监理):</div>
         <div class="value">
-          {{ displayData.spv.name }}<br />
+          {{ displayData.spv.name || '无' }}<br />
           监理{{ displayData.spv.pipeLen }}米,扫码{{ displayData.spv.part }}个部件,扫码{{
             displayData.spv.times
           }}次,上传{{ displayData.spv.pictures }}张图片
@@ -106,6 +106,7 @@ export default class pipeInfo extends Vue {
   width: 350px;
   height: auto;
   background: rgba(0, 0, 0, 0.6);
+  border: 2px solid #00437f;
   border-radius: 5px;
   color: white;
   position: absolute;

+ 1 - 1
src/views/groupPage/districtPageModules/customTools/infoComponents/projectInfo.vue

@@ -54,7 +54,7 @@ export default class projectInfo extends Vue {
   cardStyle: object = {
     '--height': '1.25rem ' /* 240/192 */, //高度
     '--width': '1.666667rem ' /* 320/192 */, //宽度
-    '--borderColor': 'rgba(25, 137, 252, 1)', //边框线颜色
+    '--borderColor': 'rgba(50,182,252,1)', //边框线颜色
     '--backgroundColor': 'rgba(2, 20, 37, 0.45)' //背景颜色
   }
   mounted() {

+ 86 - 32
src/views/groupPage/districtPageModules/customTools/projectPipeSpeedInfoCheck.vue

@@ -5,27 +5,29 @@
     enter-active-class="animate__zoomIn"
     leave-active-class="animate__zoomOut"
   >
-    <div class="widget-ProjectPipeSpeedInfoCheck" v-drag>
+    <div class="widget-ProjectPipeSpeedInfoCheck" v-Gpdrag>
       <div class="header">
         <span class="close">
           <i class="el-icon-close" @click="close()" />
         </span>
         <CommonTreeList :placeholder="'工程选择'" :prjId="45" @changeProjectName="prjChange($event)" />
-        <div class="title">日期:</div>
-        <el-date-picker
-          style="width: 220px"
-          :picker-options="pickerOptions"
-          v-model="dateValue"
-          type="datetimerange"
-          range-separator="-"
-          start-placeholder="开始日期"
-          end-placeholder="结束日期"
-          value-format="yyyy-MM-dd HH:mm:ss"
-          :default-time="['00:00:00', '23:59:59']"
-          size="mini"
-          @change="dateChange"
-        >
-        </el-date-picker>
+        <div style="display: flex; align-items: center">
+          <div class="title">日期:</div>
+          <el-date-picker
+            style="width: 220px"
+            :picker-options="pickerOptions"
+            v-model="dateValue"
+            type="datetimerange"
+            range-separator="-"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            :default-time="['00:00:00', '23:59:59']"
+            size="mini"
+            @change="dateChange"
+          >
+          </el-date-picker>
+        </div>
       </div>
       <div class="content">
         <template v-if="resultData.length > 0">
@@ -33,9 +35,18 @@
             <img class="operationBtn" :src="buttonImg" @click="play()" />
           </div>
           <div class="right">
-            <el-steps :active="active" finish-status="success">
+            <!-- <el-steps :active="active" finish-status="success">
               <el-step :title="item[0].split(' ')[0]" v-for="(item, index) in timeSteps" :key="index"></el-step>
-            </el-steps>
+            </el-steps> -->
+            <el-slider
+              v-model="active"
+              show-tooltip
+              :marks="marks"
+              :format-tooltip="sliderFormat"
+              :min="0"
+              :max="timeSteps.length - 1"
+              @change="sliderChange"
+            ></el-slider>
           </div>
         </template>
         <el-empty v-else description="暂无数据" :image-size="40" style="flex: 1"></el-empty>
@@ -111,6 +122,21 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
       }
     ]
   }
+  //防抖
+  timeout = null
+  //
+  get marks() {
+    let t = {}
+    t[0] = {
+      style: { color: '#1989FA', fontWeight: 'bold' },
+      label: `${moment(this.timeSteps[0][0]).format('YYYY-MM-DD')}`
+    }
+    t[this.timeSteps.length - 1] = {
+      style: { color: '#1989FA', fontWeight: 'bold' },
+      label: `${moment(this.timeSteps[this.timeSteps.length - 1][0]).format('YYYY-MM-DD')}`
+    }
+    return t
+  }
   //
   timeSteps: Array<Array<string>> = []
   //播放监听
@@ -132,6 +158,14 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
     gCustomDataSource = new Cesium.CustomDataSource('displaycontrol')
     this.viewer.dataSources.add(gCustomDataSource)
   }
+  //进度滑块提示信息
+  sliderFormat(e) {
+    return this.timeSteps.length > 0 && this.timeSteps[e] ? this.timeSteps[e][0] : e
+  }
+  //进度滑块改变
+  sliderChange() {
+    this.isPlaying = false
+  }
   //开始播放
   play() {
     this.isPlaying = !this.isPlaying
@@ -146,19 +180,29 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
       this.loopPlayback()
     }
   }
-  loopPlayback() {
-    //长度减一是因为timeSteps存储的是时间间隔
-    if (this.active > this.timeSteps.length - 1) {
-      this.active = 0
-    }
-    this.isShowCompletion = false
+  @Watch('active')
+  onChangeActiveMethod(n) {
     const data2 = {
       beginDate: this.timeSteps[this.active][0].replaceAll('-', ''),
       endDate: this.timeSteps[this.active][1].replaceAll('-', '')
     }
     this.clearSpeedInfos()
-    setTimeout(() => {
+    this.debounce(() => {
       this.initScanTimes(data2)
+    }, 1000)
+  }
+  //去抖延迟
+  debounce(fn, wait) {
+    if (this.timeout !== null) clearTimeout(this.timeout)
+    this.timeout = setTimeout(fn, wait)
+  }
+  loopPlayback() {
+    //长度减一是因为timeSteps存储的是时间间隔
+    if (this.active >= this.timeSteps.length - 1) {
+      this.active = 0
+    }
+    this.isShowCompletion = false
+    setTimeout(() => {
       this.active += 1
     }, 500)
   }
@@ -270,7 +314,7 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
           this.isShowCompletion = true
           return
         }
-        if (!this.isPlaying) {
+        if (!this.isPlaying && this.active == 0) {
           this.resultData = result.result
           this.timeDataAssembly(result.result)
         }
@@ -433,7 +477,7 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
     let width = 100
     canvas.width = width * ratio
     canvas.height = height * ratio
-    const fonttxt = '50px Arial'
+    const fonttxt = '50px Source Han Sans CN'
     var ctx = canvas.getContext('2d')
     //ctx.scale(ratio, ratio)
     var img = new Image()
@@ -441,7 +485,7 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
     img.onload = function () {
       ctx.lineWidth = 10
       ctx.strokeStyle = color
-      ctx.font = '24px Arial'
+      ctx.font = '24px Source Han Sans CN'
       const realWidth = ctx.measureText(options.text).width
       ctx.font = fonttxt
       width = ctx.measureText(options.text).width + 100
@@ -468,7 +512,7 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
           //scale:0.2,
           width: realWidth,
           height: realHeight,
-          scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 10100, 0.5),
+          // scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 10100, 0.5),
           verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
           horizontalOrigin: Cesium.HorizontalOrigin.CENTER
         }
@@ -568,6 +612,8 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
     border-bottom: 1px solid rgba(41, 177, 255, 0.3);
     display: flex;
     align-items: center;
+    justify-content: space-between;
+    padding-right: 0.15625rem /* 30/192 */;
     /deep/ .el-select {
       width: 100px;
       .el-input__inner {
@@ -625,6 +671,7 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
       cursor: pointer;
     }
     .title {
+      white-space: nowrap;
       font-family: Source Han Sans CN;
       font-size: 0.072917rem /* 14/192 */;
       color: #2ba7ff;
@@ -649,10 +696,11 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
     .right {
       width: calc(100% - 0.572917rem /* 110/192 */);
       height: 100%;
-      padding: 0.052083rem /* 10/192 */;
+      // padding: 0.052083rem /* 10/192 */;
+      margin: 0 0.260417rem /* 50/192 */;
       display: flex;
-      align-items: flex-end;
-      overflow-y: auto;
+      align-items: center;
+      justify-content: center;
       /deep/ .el-steps {
         width: 100%;
         .el-step__icon-inner {
@@ -695,6 +743,12 @@ export default class ProjectPipeSpeedInfoCheck extends Vue {
           white-space: nowrap;
         }
       }
+      /deep/ .el-slider {
+        width: 100%;
+        .el-slider__marks-text {
+          white-space: nowrap;
+        }
+      }
     }
   }
 }

+ 2 - 0
src/views/groupPage/districtPageModules/projectPanoramic/ProjectProgress.vue

@@ -385,6 +385,8 @@ export default class ProjectProgress extends Vue {
           right: 0;
           margin: 0 auto;
           width: 70%;
+          width: 55%;
+          height: 95%;
           // left: 0.041667rem /* 8/192 */;
           z-index: -1;
           // width: 0.46875rem /* 90/192 */;

+ 1 - 1
src/views/groupPage/index.vue

@@ -90,7 +90,7 @@ export default {
     }
     .el-select-dropdown__item.selected {
       color: #409eff;
-      font-weight: 700;
+      font-weight: 500;
     }
     .el-select-dropdown__item.hover,
     .el-select-dropdown__item:hover {

+ 2 - 2
src/views/groupPageDataManagement/IndexManagement/IndexForm.vue

@@ -25,7 +25,7 @@
               :disabled="disabled"
               :placeholder="`请选择${label}`"
               clearable
-              size="small"
+              size="medium"
               v-bind="rest"
             />
             <el-select
@@ -33,7 +33,7 @@
               v-model="formData[name]"
               filterable
               :placeholder="`请选择${label}`"
-              size="small"
+              size="medium"
               clearable
               v-bind="rest"
               @change="onChange"

+ 171 - 10
src/views/groupPageDataManagement/ProjectManagement/ProjectForm.vue

@@ -19,7 +19,7 @@
             <el-date-picker
               v-if="type === 'date'"
               v-model="formData[name]"
-              value-format="yyyy-MM-dd"
+              value-format="yyyy-MM-dd HH:mm:ss"
               format="yyyy-MM-dd"
               :disabled="disabled"
               :placeholder="`请选择${label}`"
@@ -70,23 +70,24 @@
                   clearable
               /></el-col>
               <el-col :span="8">
-                <el-button type="primary">图上选择</el-button>
+                <el-button type="primary" @click="selectCoord()">图上选择</el-button>
               </el-col>
             </el-form-item>
           </el-row>
           <el-row :gutter="15">
-            <el-form-item :key="'range'" :label="'工程范围'" :prop="'range'">
+            <el-form-item :key="'area'" :label="'工程面积(km²)'" :prop="'area'">
               <el-col :span="16">
                 <el-input
-                  v-model="formData['range']"
+                  v-model="formData['area']"
                   :type="'text'"
-                  :placeholder="`请输入经度`"
+                  :placeholder="`请绘制`"
+                  readonly
                   size="medium"
                   clearable
                 />
               </el-col>
               <el-col :span="4">
-                <el-button type="primary">图上绘制</el-button>
+                <el-button type="primary" @click="drawInMap()">图上绘制</el-button>
               </el-col>
             </el-form-item>
           </el-row>
@@ -100,6 +101,11 @@
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
 import { ElForm } from 'element-ui/types/form'
 import { IProject } from '../commonAPI/common'
+import * as turf from '@turf/turf'
+//地图变量
+const Cesium = (window as any).Cesium
+let handler = null
+let DrawHandler = null
 
 const getDefaultValue = (): Partial<IProject> => ({
   code: undefined,
@@ -107,7 +113,8 @@ const getDefaultValue = (): Partial<IProject> => ({
   levelname: undefined,
   longitude: undefined,
   latitude: undefined,
-  range: undefined
+  range: undefined,
+  area: undefined
 })
 
 @Component({ name: 'ProjectForm' })
@@ -118,6 +125,8 @@ export default class ProjectForm extends Vue {
     ...getDefaultValue()
   }
 
+  polygonDraw
+
   get listeners() {
     const { submit, ...rest } = this.$listeners
     return rest
@@ -127,9 +136,10 @@ export default class ProjectForm extends Vue {
     return [
       { label: '工程编号', name: 'code', disabled: true },
       { label: '工程名称', name: 'name', disabled: true },
-      { label: '工程类型', name: 'levelname' },
-      { label: '计划开始时间', name: 'planStart', type: 'date', style: 'width:100%' },
-      { label: '计划结束时间', name: 'planEnd', type: 'date', style: 'width:100%' }
+      { label: '工程类型', name: 'projectType', type: 'select' },
+      { label: '工程状态', name: 'projectStatus', type: 'select' },
+      { label: '计划开始时间', name: 'planBeginDate', type: 'date', style: 'width:100%' },
+      { label: '计划结束时间', name: 'planEndDate', type: 'date', style: 'width:100%' }
     ]
   }
 
@@ -153,6 +163,157 @@ export default class ProjectForm extends Vue {
     }
     this.formData = val.id ? { ...val } : { ...getDefaultValue() }
   }
+
+  //图上选择坐标
+  selectCoord() {
+    const viewer = (window as any).viewer
+    handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas)
+    const that = this
+    handler.setInputAction(function (event) {
+      let cartesian = viewer.camera.pickEllipsoid(event.position)
+      let cartographic = Cesium.Cartographic.fromCartesian(cartesian)
+      let lng = Cesium.Math.toDegrees(cartographic.longitude) // 经度
+      let lat = Cesium.Math.toDegrees(cartographic.latitude) // 纬度
+      let alt = cartographic.height // 高度,椭球面height永远等于0
+      let coordinate = {
+        longitude: Number(lng.toFixed(10)),
+        latitude: Number(lat.toFixed(10))
+        // altitude: Number(alt.toFixed(2))
+      }
+      that.formData.longitude = lng.toFixed(10)
+      that.formData.latitude = lat.toFixed(10)
+    }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
+  }
+  //图上绘制
+  drawInMap() {
+    this.drawPolygon()
+  }
+  //绘制工程范围
+  drawPolygon() {
+    this.clearDrawHandler()
+    this.clearDrawPolygon()
+    const viewer = (window as any).viewer
+    DrawHandler = new Cesium.ScreenSpaceEventHandler(viewer.canvas)
+    viewer.enableCursorStyle = false
+    viewer._element.style.cursor = ''
+    let isDrawing = false
+    let positions = []
+    let polygon = null
+    DrawHandler.setInputAction((e) => {
+      const position = viewer.scene.pickPosition(e.position)
+      if (!isDrawing) {
+        positions.push(position)
+        isDrawing = true
+      } else {
+        positions.push(position)
+      }
+    }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
+    DrawHandler.setInputAction((e) => {
+      if (isDrawing) {
+        const position = viewer.scene.pickPosition(e.endPosition)
+        if (positions.length === 1) {
+          positions.push(position)
+          polygon = viewer.entities.add({
+            polyline: {
+              show: new Cesium.CallbackProperty(() => {
+                return positions.length >= 2
+              }, false),
+              positions: new Cesium.CallbackProperty(() => {
+                if (positions.length < 3) {
+                  return positions
+                } else {
+                  const line = positions.map((item) => item)
+                  line.push(line[0])
+                  return line
+                }
+              }, false),
+              followSurface: false,
+              clampToGround: true,
+              material: Cesium.Color.DODGERBLUE,
+              width: 2.0
+            },
+            polygon: {
+              hierarchy: new Cesium.CallbackProperty(() => {
+                return new Cesium.PolygonHierarchy(positions)
+              }, false),
+              material: Cesium.Color.DEEPSKYBLUE.withAlpha(0.3),
+              perPositionHeight: false,
+              outline: true,
+              outlineColor: Cesium.Color.DODGERBLUE,
+              heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
+              outlineWidth: 1.0
+            }
+          })
+          this.polygonDraw = polygon
+        } else {
+          positions[positions.length - 1] = position
+        }
+      }
+    }, Cesium.ScreenSpaceEventType.MOUSE_MOVE)
+    DrawHandler.setInputAction((e) => {
+      if (!isDrawing) {
+        this.clearDrawHandler()
+        return
+      }
+      if (positions.length > 2) {
+        const position = viewer.scene.pickPosition(e.position)
+        if (Cesium.defined(polygon)) {
+          positions.push(position)
+        }
+        console.log('分区绘制', polygon, positions)
+        this.getArea(polygon)
+        isDrawing = false
+        this.clearDrawHandler()
+        viewer.enableCursorStyle = true
+      }
+    }, Cesium.ScreenSpaceEventType.RIGHT_CLICK)
+  }
+  /**
+   * 获取面积
+   */
+  getArea(polygon) {
+    const positions = polygon.polygon.hierarchy.getValue(Cesium.JulianDate.now())
+    const scopePositions = positions.positions.map((position) => {
+      const lonlat = Cesium.Cartographic.fromCartesian(position)
+      return { x: Cesium.Math.toDegrees(lonlat.longitude), y: Cesium.Math.toDegrees(lonlat.latitude) }
+    })
+    this.formData.range = JSON.stringify({ coordinates: scopePositions })
+    //面积计算
+    const newLonlat = scopePositions.map((item) => {
+      return [item.x, item.y]
+    })
+    newLonlat.push(newLonlat[0])
+    const turfpolygon = turf.polygon([newLonlat])
+    const area = (turf.area(turfpolygon) / 1000000).toFixed(2)
+    this.formData.area = area
+  }
+  //清除绘制
+  clearDrawPolygon() {
+    if (this.polygonDraw) {
+      ;(window as any).viewer.entities.remove(this.polygonDraw)
+      this.polygonDraw = null
+    }
+  }
+  //清除DrawHandler
+  clearDrawHandler() {
+    if (DrawHandler && !DrawHandler.isDestroyed()) {
+      DrawHandler.destroy()
+      DrawHandler = null
+    }
+  }
+  //清除handler
+  clearHandler() {
+    if (handler && !handler.isDestroyed()) {
+      handler.destroy()
+      handler = null
+    }
+  }
+  //事件清除
+  destroy() {
+    this.clearHandler()
+    this.clearDrawHandler()
+    this.clearDrawPolygon()
+  }
 }
 </script>
 <style lang="scss" scoped>

+ 34 - 7
src/views/groupPageDataManagement/ProjectManagement/widget.vue

@@ -15,6 +15,7 @@
       </template>
     </tf-table>
     <ProjectForm
+      ref="ProjectForm"
       v-if="visible"
       :visible.sync="visible"
       :loading="loading.add || loading.update"
@@ -28,10 +29,11 @@
 
 <script lang="ts">
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
+import { ElForm } from 'element-ui/types/form'
 import ActionHeader from '../components/ActionHeader.vue'
 import { PMTableColumns } from '../commonAPI/settings'
 import { ILoading } from '../commonAPI/common'
-import { getPbsListWithRange } from '../commonAPI/request'
+import { getPbsListWithRange, updatePbsList } from '../commonAPI/request'
 import ProjectForm from './ProjectForm.vue'
 //工程管理
 @Component({
@@ -39,6 +41,8 @@ import ProjectForm from './ProjectForm.vue'
   components: { ActionHeader, ProjectForm }
 })
 export default class IndexManagement extends Vue {
+  $refs!: { form: ElForm }
+
   visible: boolean = false
 
   isActive: boolean = false
@@ -51,18 +55,31 @@ export default class IndexManagement extends Vue {
 
   current: any = {}
 
+  @Watch('visible')
+  onChangeVisibleMethod(val) {
+    if (!val) {
+      this.$refs['ProjectForm'].destroy()
+    }
+  }
   get prjId() {
     return this.$store.getters['project/id'].projectId
   }
   mounted() {
     this.isActive = true
   }
-  onSearch(data) {
+  onSearch(data?) {
     this.loading.search = true
-    getPbsListWithRange({ prjId: this.prjId }).then((res) => {
-      this.tableData = res.result[0].structures.filter(
-        (item) => item.levelname !== '分部工程(专业)' && item.levelname !== '部件类型'
-      )
+    let params = {
+      name: data ? data.keyword : '',
+      prjId: this.prjId
+    }
+    getPbsListWithRange(params).then((res) => {
+      this.tableData = res.result[0].structures.map((item) => {
+        Object.keys(item).forEach((val) => {
+          item[val] = item[val] || '/'
+        })
+        return { ...item }
+      })
       this.loading.search = false
     })
   }
@@ -70,7 +87,17 @@ export default class IndexManagement extends Vue {
     this.current = { ...row }
     this.visible = true
   }
-  onSubmit() {}
+  onSubmit(row) {
+    updatePbsList(row).then((res) => {
+      if (res.code == 1) {
+        this.$message.success('修改成功')
+        this.visible = false
+        this.onSearch()
+      } else {
+        this.$message.warning('修改失败')
+      }
+    })
+  }
 }
 </script>
 

+ 3 - 0
src/views/groupPageDataManagement/commonAPI/common.ts

@@ -32,8 +32,11 @@ export interface IProject {
     id?: number,
     code: string,
     name: string,
+    planBeginDate: string,
+    planEndDate: string,
     levelname: string,
     longitude: string,
     latitude: string,
     range: string,
+    area: string
 }

+ 16 - 1
src/views/groupPageDataManagement/commonAPI/request.ts

@@ -27,10 +27,25 @@ export function getRequestResult(params) {
     return returnData
 }
 //带范围的工程结构树
+// export function getPbsListWithRange(params) {
+//     return request({
+//         url: '/tofly-sxgk/structure/listWithRange',
+//         method: 'get',
+//         params
+//     })
+// }
 export function getPbsListWithRange(params) {
     return request({
-        url: '/tofly-sxgk/structure/listWithRange',
+        url: '/tofly-sxgk/structure/structuredetailList',
         method: 'get',
         params
     })
+}
+//工程管理编辑
+export function updatePbsList(data) {
+    return request({
+        url: '/tofly-sxgk/structure/updata',
+        method: 'PUT',
+        data: data,
+    })
 }

+ 5 - 4
src/views/groupPageDataManagement/commonAPI/settings.ts

@@ -30,11 +30,12 @@ export const PMTableColumns: ColItem[] = [
     { type: 'index', label: '序号', width: '50px' },
     { prop: 'code', label: '工程编号' },
     { prop: 'name', label: '工程名称' },
-    { prop: 'levelname', label: '工程类型' },
-    { prop: '', label: '计划开始时间' },
-    { prop: '', label: '计划结束时间' },
+    { prop: 'projectType', label: '工程类型' },
+    { prop: 'projectStatus', label: '工程状态' },
+    { prop: 'planBeginDate', label: '计划开始时间' },
+    { prop: 'planEndDate', label: '计划结束时间' },
     { prop: 'longitude', label: '经度' },
     { prop: 'latitude', label: '纬度' },
-    { prop: 'range', label: '工程范围', ...elTableAlignLeft() },
+    { prop: 'area', label: '工程面积(km²)', ...elTableAlignLeft() },
     { prop: 'operation', label: '操作', _slot: true },
 ]