From 78044879ff5f5b5966d594b51e9568fd57ed0e8a Mon Sep 17 00:00:00 2001
From: quanyawei <401863037@qq.com>
Date: Thu, 21 Sep 2023 10:14:48 +0800
Subject: [PATCH] fix:政府站点修改

---
 src/views/device/govMonitorPoint.vue |  440 +++++++++++++++++++++---------------------------------
 1 files changed, 174 insertions(+), 266 deletions(-)

diff --git a/src/views/device/govMonitorPoint.vue b/src/views/device/govMonitorPoint.vue
index 1b10ca1..b848a5b 100644
--- a/src/views/device/govMonitorPoint.vue
+++ b/src/views/device/govMonitorPoint.vue
@@ -3,265 +3,109 @@
     <div class="tableList">
       <div class="tableListForm">
         <a-form-model layout="horizontal">
-          <a-row  :gutter="15">
+          <a-row :gutter="15">
             <a-col :span="5">
-              <a-button
-                  icon="plus"
-                  type="primary"
-                  @click="() => this.handleModalVisible(true)"
-                  style="margin-left: 25px;"
-              >������</a-button>
+              <a-button icon="plus" type="primary" @click="() => this.handleModalVisible(true)"
+                style="margin-left: 25px;">������</a-button>
             </a-col>
             <a-col :span="5" style="margin-left: 37%">
               <a-form-model-item :wrapperCol="wrapperCol">
-                <a-select
-                    placeholder="������������������"
-                    style="width: 240px;margin-top:4px"
-                    @change="handleChange"
-                    allow-clear
-                    show-search
-                >
-                  <a-select-option v-for="(item,index) in stationLevel" :key="index" :value="index">
+                <a-select placeholder="������������������" style="width: 240px;margin-top:4px" @change="handleChange" allow-clear
+                  show-search>
+                  <a-select-option v-for="(item, index) in stationLevel" :key="index" :value="index">
                     {{ item }}
                   </a-select-option>
                 </a-select>
               </a-form-model-item>
             </a-col>
-            <a-col :span="5" >
-              <a-form-model-item
-                  :wrapperCol="wrapperCol">
+            <a-col :span="5">
+              <a-form-model-item :wrapperCol="wrapperCol">
                 <a-input v-model="searchName" placeholder="���������������������" allow-clear />
               </a-form-model-item>
             </a-col>
           </a-row>
-        </a-form-model
-         >
+        </a-form-model>
       </div>
-      <av-standard-table
-          :dataSource="dataSource"
-          :columns="columns"
-          :loading="tableLoading"
-          :paginationProps="pagination"
-          @tableChange="handlerTableChange"
-      ></av-standard-table>
+      <av-standard-table :dataSource="dataSource" :columns="columns" :loading="tableLoading" :paginationProps="pagination"
+        @tableChange="handlerTableChange"></av-standard-table>
     </div>
-    <a-modal
-        title="������������������"
-        destroyOnClose
-        :visible="addShowOrHiddenFlag"
-        @ok="addOK"
-        @cancel="addCancel"
-        okText="������"
-    >
-      <a-form-model
-          style="margin-top: 8px"
-          :model="addForm"
-          :rules="rules"
-          ref="addRulesForm"
-      >
-        <a-form-model-item has-feedback
-                           :labelCol="{ span: 5 }"
-                           :wrapperCol="{ span: 15 }"
-                           label="������������"
-                           prop="guid">
-          <a-input
-              placeholder="���������������������"
-              type="string"
-              v-model="addForm.guid"
-          />
+    <a-modal title="������������������" destroyOnClose :visible="addShowOrHiddenFlag" @ok="addOK" @cancel="addCancel" okText="������">
+      <a-form-model style="margin-top: 8px" :model="addForm" :rules="rules" ref="addRulesForm">
+        <a-form-model-item has-feedback :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="������������" prop="guid">
+          <a-input placeholder="���������������������" type="string" v-model="addForm.guid" />
         </a-form-model-item>
-        <a-form-model-item has-feedback
-                           :labelCol="{ span: 5 }"
-                           :wrapperCol="{ span: 15 }"
-                           label="������"
-                           prop="name">
-          <a-input
-              placeholder="������������"
-              type="string"
-              v-model="addForm.name"
-          />
+        <a-form-model-item has-feedback :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="������" prop="name">
+          <a-input placeholder="������������" type="string" v-model="addForm.name" />
         </a-form-model-item>
 
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            prop="longitude"
-        >
-          <a-input
-              placeholder="���������������"
-              type="string"
-              v-model="addForm.longitude"
-          />
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������" prop="longitude">
+          <a-input placeholder="���������������" type="string" v-model="addForm.longitude" />
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            prop="latitude"
-        >
-          <a-input
-              placeholder="���������������"
-              type="string"
-              v-model="addForm.latitude"
-          />
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������" prop="latitude">
+          <a-input placeholder="���������������" type="string" v-model="addForm.latitude" />
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            has-feedback
-            prop="position"
-        >
-<!--            v-decorator="['position', { rules: [{ required: true, message: '������������������������'  }] }]"-->
-            <a-cascader :options="areaData" placeholder="������������" @change="positionLevel" labelInValue/>
+        <a-form-model-item :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="������" has-feedback prop="position">
+          <!--            v-decorator="['position', { rules: [{ required: true, message: '������������������������'  }] }]"-->
+          <a-cascader :options="areaData" placeholder="������������" @change="positionLevel" labelInValue />
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������������"
-            prop="stationLevel"
-        >
-          <a-select
-              placeholder="������������������"
-              type="string"
-              allow-clear
-              show-search
-              v-model="addForm.stationLevel"
-          >
-            <a-select-option v-for="(item,index) in stationLevel" :key="index" :value = 'index'>{{ item }}</a-select-option>
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������������"
+          prop="stationLevel">
+          <a-select placeholder="������������������" type="string" allow-clear show-search v-model="addForm.stationLevel">
+            <a-select-option v-for="(item, index) in stationLevel" :key="index" :value='index'>{{ item
+            }}</a-select-option>
           </a-select>
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            prop="desc"
-        >
-          <a-input
-              placeholder="������"
-              type="string"
-              v-model="addForm.desc"
-          />
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������" prop="desc">
+          <a-input placeholder="������" type="string" v-model="addForm.desc" />
         </a-form-model-item>
       </a-form-model>
     </a-modal>
-    <a-modal
-        title="������������������"
-        destroyOnClose
-        :visible="editShowOrHiddenFlag"
-        @ok="editSave"
-        @cancel="editCancel"
-        okText="������"
-    >
-      <a-form-model
-          style="margin-top: 8px"
-          :model="editForm"
-          :rules="rules"
-          ref="editRulesForm"
-      >
-        <a-form-model-item has-feedback
-                           :labelCol="{ span: 5 }"
-                           :wrapperCol="{ span: 15 }"
-                           label="������������"
-                           prop="guid">
-          <a-input
-              placeholder="���������������������"
-              type="string"
-              v-model="editForm.guid"
-          />
+    <a-modal title="������������������" destroyOnClose :visible="editShowOrHiddenFlag" @ok="editSave" @cancel="editCancel"
+      okText="������">
+      <a-form-model style="margin-top: 8px" :model="editForm" :rules="rules" ref="editRulesForm">
+        <a-form-model-item has-feedback :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="������������" prop="guid">
+          <a-input placeholder="���������������������" type="string" v-model="editForm.guid" />
         </a-form-model-item>
-        <a-form-model-item has-feedback
-                           :labelCol="{ span: 5 }"
-                           :wrapperCol="{ span: 15 }"
-                           label="������"
-                           prop="name">
-          <a-input
-              placeholder="������������"
-              type="string"
-              v-model="editForm.name"
-          />
+        <a-form-model-item has-feedback :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="������" prop="name">
+          <a-input placeholder="������������" type="string" v-model="editForm.name" />
         </a-form-model-item>
 
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            prop="longitude"
-        >
-          <a-input
-              placeholder="���������������"
-              type="string"
-              v-model="editForm.longitude"
-          />
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������" prop="longitude">
+          <a-input placeholder="���������������" type="string" v-model="editForm.longitude" />
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            prop="latitude"
-        >
-          <a-input
-              placeholder="���������������"
-              type="string"
-              v-model="editForm.latitude"
-          />
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������" prop="latitude">
+          <a-input placeholder="���������������" type="string" v-model="editForm.latitude" />
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            has-feedback
-            prop="position"
-        >
+        <a-form-model-item :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="������" has-feedback prop="position">
           <!--            v-decorator="['position', { rules: [{ required: true, message: '������������������������'  }] }]"-->
-          <a-cascader v-model="editForm.position" :options="areaData" placeholder="������������������"
-                      @change="positionLevel" labelInValue/>
+          <a-cascader v-model="editForm.position" :options="areaData" placeholder="������������������" @change="positionLevel"
+            labelInValue />
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������������"
-            prop="stationLevel"
-        >
-          <a-select
-              placeholder="������������������"
-              type="string"
-              allow-clear
-              show-search
-              v-model="editForm.stationLevel"
-          >
-            <a-select-option v-for="(item,index) in stationLevel" :key="index" :value = 'index'>{{ item }}</a-select-option>
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������������"
+          prop="stationLevel">
+          <a-select placeholder="������������������" type="string" allow-clear show-search v-model="editForm.stationLevel">
+            <a-select-option v-for="(item, index) in stationLevel" :key="index" :value='index'>{{ item
+            }}</a-select-option>
           </a-select>
         </a-form-model-item>
-        <a-form-model-item
-            :labelCol="{ span: 5 }"
-            has-feedback
-            :wrapperCol="{ span: 15 }"
-            label="������"
-            prop="desc"
-        >
-          <a-input
-              placeholder="������"
-              type="string"
-              v-model="editForm.desc"
-          />
+        <a-form-model-item :labelCol="{ span: 5 }" has-feedback :wrapperCol="{ span: 15 }" label="������" prop="desc">
+          <a-input placeholder="������" type="string" v-model="editForm.desc" />
+        </a-form-model-item>
+      </a-form-model>
+    </a-modal>
+    <a-modal title="������������������" destroyOnClose :visible="editSiteShowOrHiddenFlag" :rules="siteRules" @ok="editSiteSave"
+      @cancel="editSiteCancel" okText="������">
+      <a-form-model style="margin-top: 8px" :model="editSiteForm" ref="editSiteRulesForm">
+        <a-form-model-item has-feedback :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="������������" prop="guid">
+          <a-input placeholder="���������������������" type="string" v-model="editSiteForm.guid" />
         </a-form-model-item>
       </a-form-model>
     </a-modal>
   </a-card>
-
 </template>
 
 <script lang="tsx">
-import {Component, Vue, Watch} from "vue-property-decorator";
+import { Component, Vue, Watch } from "vue-property-decorator";
 import org from '@/util/org'
 import { get, post } from "@/util/request";
 @Component({
@@ -271,7 +115,7 @@
 export default class govMonitorPoint extends Vue {
   // ������������
   private wrapperCol: any = {
-    sm: {span: 16}//������������������������
+    sm: { span: 16 }//������������������������
   }
   // ������id������������
   private stationLevelId: any = ''
@@ -316,38 +160,46 @@
   // ���������������������������
   private tableLoading: boolean = false
   // ������
-  private dataSource: any[] =[]
+  private dataSource: any[] = []
   // ������������������������
   private addShowOrHiddenFlag: boolean = false
   // ������������������������
   private editShowOrHiddenFlag: boolean = false
+
+  private editSiteShowOrHiddenFlag: boolean = false
   // ������������������������
   private areaData: any = JSON.parse(JSON.stringify(org))
   // ���������������������������
   private rules: any = {
     guid: [
-      {required: true, message: '������������������������', trigger: ['change', 'blur']},
+      { required: true, message: '������������������������', trigger: ['change', 'blur'] },
     ],
     name: [
-      {required: true, message: '������������������', trigger: ['change', 'blur']},
+      { required: true, message: '������������������', trigger: ['change', 'blur'] },
     ],
     longitude: [
-      {required: true, message: '������������������', trigger: ['change', 'blur']},
+      { required: true, message: '������������������', trigger: ['change', 'blur'] },
     ],
     latitude: [
-      {required: true, message: '������������������', trigger: ['change', 'blur']},
+      { required: true, message: '������������������', trigger: ['change', 'blur'] },
     ],
     position: [
-      {required: true, message: '���������������������', trigger: ['change', 'blur']},
+      { required: true, message: '���������������������', trigger: ['change', 'blur'] },
     ],
     stationLevel: [
-      {required: true, message: '���������������������', trigger: ['change', 'blur']},
+      { required: true, message: '���������������������', trigger: ['change', 'blur'] },
+    ]
+  }
+  private siteRules: any = {
+    guid: [
+      { required: true, message: '������������������������', trigger: ['change', 'blur'] },
     ]
   }
   // ������������������
   private stationLevel: any = {}
   // ������������������������record
   private editBeforeRecord: any = null
+  private editBeforeSiteRecord: any = null
   // ������������������
   private addForm: any = {
     guid: '',
@@ -369,6 +221,11 @@
     stationLevel: undefined,
     desc: ''
   }
+  // ������������������
+  private editSiteForm: any = {
+    id: -1,
+    guid: ''
+  }
   // ������������
   private pagination: any = {
     total: 0,
@@ -380,7 +237,7 @@
   // ������������������������
   @Watch('searchName', {
     deep: true,
-    immediate:true
+    immediate: true
   })
   private watchName(newVal: string, oldVal: string) {
     this.searchName = newVal
@@ -398,7 +255,7 @@
     this.queryGovDatas()
   }
   //���������������������
-  private handleChange(selectedItems:any) {
+  private handleChange(selectedItems: any) {
     if (selectedItems) {
       this.stationLevelId = selectedItems
     } else {
@@ -411,28 +268,28 @@
   private positionLevel(val: any, selectedOptions: any) {
     if (selectedOptions && selectedOptions.length > 0) {
       this.addForm.position = selectedOptions
-    }else {
+    } else {
       this.addForm.position = undefined
     }
   }
   // ���������������������
   private selectDatas() {
     get("dict/data/query?type=stationLevel ", {}).then(res => {
-          if (res.data.code === 0) {
-            this.stationLevel = res.data.data
-          }
-        })
-        .catch(err => {
-          console.log(err);
-        });
+      if (res.data.code === 0) {
+        this.stationLevel = res.data.data
+      }
+    })
+      .catch(err => {
+        console.log(err);
+      });
   }
   // ������������������������
   private queryGovDatas() {
     get('govMonitorPoint/getGovMonitorPointByCondition', {
-        current: this.pagination.current,
-        size: this.pagination.pageSize,
-        name: this.searchName,
-        stationLevel: this.stationLevelId
+      current: this.pagination.current,
+      size: this.pagination.pageSize,
+      name: this.searchName,
+      stationLevel: this.stationLevelId
     }).then((res: any) => {
       if (res.data.code === 0) {
         this.pagination.total = res.data.data.totalNumber;
@@ -440,7 +297,7 @@
         const govDatas = res.data.data.govMonitorPointList
         if (govDatas.length > 0) {
           for (let i = 0; i < govDatas.length; i++) {
-            for (let j = 0; j <govDatas[i].position.length ; j++) {
+            for (let j = 0; j < govDatas[i].position.length; j++) {
               govDatas[i].stationLevelName = this.stationLevel[govDatas[i].stationLevel]
             }
           }
@@ -451,7 +308,7 @@
   }
   // ������������
   private handleModalVisible(flag: boolean) {
-     this.addShowOrHiddenFlag = flag
+    this.addShowOrHiddenFlag = flag
   }
   // ������������
   private addOK() {
@@ -504,7 +361,7 @@
     this.addShowOrHiddenFlag = false
   }
   // ������������
-  private editShow(flag:boolean, record: any) {
+  private editShow(flag: boolean, record: any) {
     this.editShowOrHiddenFlag = flag
     this.editBeforeRecord = record
     const positon = []
@@ -522,6 +379,54 @@
       desc: record.desc === undefined ? '' : record.desc
     }
   }
+  // ������������
+  private editSiteShow(flag: boolean, record: any) {
+    this.editSiteShowOrHiddenFlag = flag
+    this.editBeforeSiteRecord = record
+    const positon = []
+    positon.push(record.provinceCode)
+    positon.push(record.cityCode)
+    positon.push(record.areaCode)
+    this.editSiteForm = {
+      id: record.id,
+      guid: record.guid
+    }
+  }
+  // ������������������
+  private editSiteSave() {
+    this.$refs.editSiteRulesForm.validate((valid: any) => {
+      if (valid) {
+        const guid = this.editSiteForm.guid === this.editBeforeSiteRecord.guid ? null : this.editSiteForm.guid
+        if (!(guid)) {
+          this.$message.warning('������������')
+        } else {
+          get('govMonitorPoint/updateGuid', {
+            id: this.editSiteForm.id,
+            guid
+          }).then((res: any) => {
+            if (res.data.code === 0) {
+              this.$message.success(res.data.message)
+              this.editSiteForm = {
+                id: -1,
+                guid: ''
+              }
+              this.editSiteShowOrHiddenFlag = false
+              this.queryGovDatas()
+            } else {
+              this.$message.warning(res.data.message)
+            }
+          })
+        }
+      }
+    })
+  }
+  private editSiteCancel() {
+    this.editForm = {
+      id: -1,
+      guid: ''
+    }
+    this.editSiteShowOrHiddenFlag = false
+  }
   // ������������
   private editSave() {
     this.$refs.editRulesForm.validate((valid: any) => {
@@ -530,12 +435,12 @@
         const guid = this.editForm.guid === this.editBeforeRecord.guid ? null : this.editForm.guid
         const longitude = this.editForm.longitude === this.editBeforeRecord.longitude ? null : this.editForm.longitude
         const latitude = this.editForm.latitude === this.editBeforeRecord.latitude ? null : this.editForm.latitude
-        const position = (this.editForm.position[0] ===this.editBeforeRecord.provinceCode &&
-                          this.editForm.position[1] ===this.editBeforeRecord.cityCode &&
-                          this.editForm.position[2] ===this.editBeforeRecord.areaCode) ? null : this.editForm.position
+        const position = (this.editForm.position[0] === this.editBeforeRecord.provinceCode &&
+          this.editForm.position[1] === this.editBeforeRecord.cityCode &&
+          this.editForm.position[2] === this.editBeforeRecord.areaCode) ? null : this.editForm.position
         const stationLevel = this.editForm.stationLevel === this.editBeforeRecord.stationLevel ? null : this.editForm.stationLevel
         const desc = this.editBeforeRecord.desc === undefined ? (this.editForm.desc === '' ? null : this.editForm.desc) :
-                      this.editForm.desc === this.editBeforeRecord.desc ? null : this.editForm.desc
+          this.editForm.desc === this.editBeforeRecord.desc ? null : this.editForm.desc
         if (!(name || guid || longitude || latitude || position || stationLevel || desc)) {
           this.$message.warning('������������')
         } else {
@@ -546,8 +451,8 @@
             longitude,
             latitude,
             provinceCode: position === null ? null : position[0],
-            cityCode:  position === null ? null : position[1],
-            areaCode:  position === null ? null : position[2],
+            cityCode: position === null ? null : position[1],
+            areaCode: position === null ? null : position[2],
             stationLevel,
             desc
           }).then((res: any) => {
@@ -604,26 +509,29 @@
   // ������������������
   private opRender(text: string, record: any, index: number) {
     return (
-        <div>
-          <a onClick={() => this.editShow(true, record)}>
-            {" "}
-            ������{" "}
-          </a>
-          <a-divider type="vertical"/>
-          <a-popconfirm
-              title="������������������"
-              ok-text="������"
-              cancel-text="������"
-              onConfirm={() => this.delete(record)}
-          >
-            <a href="#">������</a>
-          </a-popconfirm>
-        </div>
+      <div>
+        <a onClick={() => this.editShow(true, record)}>
+          {" "}
+          ������{" "}
+        </a>
+        <a-divider type="vertical" />
+        <a-popconfirm
+          title="������������������"
+          ok-text="������"
+          cancel-text="������"
+          onConfirm={() => this.delete(record)}
+        >
+          <a href="#">������</a>
+        </a-popconfirm>
+        <a-divider type="vertical" />
+        <a onClick={() => this.editSiteShow(true, record)}>
+          {" "}
+          ������������������{" "}
+        </a>
+      </div>
     )
   }
 }
 </script>
 
-<style scoped>
-
-</style>
+<style scoped></style>

--
Gitblit v1.8.0