xieqy vor 3 Jahren
Ursprung
Commit
416722261d

+ 1 - 1
src/layout/components/FullPanels.vue

@@ -43,7 +43,7 @@ export default class FullPanels extends Vue {
   get editableTabsValue() {
     return this.$store.state.map.fullP_editableTabsValue
   }
-  @Watch('panels')
+  @Watch('panels',{immediate:true})
   panelsChange() {
     if (this.panels.length > 0) {
       if (this.panelVisible) return

+ 1 - 1
src/views/groupPage/districtPageModules/commonModules/PropertiesView.vue

@@ -61,7 +61,7 @@ export default class PropertiesView extends Vue {
   get isInitViewer() {
     return this.$store.state.bigScreen.isInitViewer
   }
-  @Watch('isInitViewer')
+  @Watch('isInitViewer',{immediate:true})
   onChangeViewMethod() {
     this.viewer = (window as any).viewer
   }

+ 1 - 1
src/views/groupPage/districtPageModules/commonModules/SearchBox.vue

@@ -126,7 +126,7 @@ export default class SearchBox extends Vue {
   get isInitViewer() {
     return this.$store.state.bigScreen.isInitViewer
   }
-  @Watch('isInitViewer')
+  @Watch('isInitViewer',{immediate:true})
   onChangeMethod() {
     this.viewer = (window as any).viewer
     this.init()

+ 1 - 1
src/views/groupPage/districtPageModules/commonModules/SectorToolbar.vue

@@ -436,7 +436,7 @@ export default class SectorToolbar extends Vue {
         this.propertiesViewCom.pipeUnitInfo('rect')
         break
       case 'component':
-        this.propertiesViewCom.pipeUnitInfo('component')
+        this.propertiesViewCom.activeViewComponent()
         break
       case 'clear':
         this.propertiesViewCom.destroyLastOperation()

+ 160 - 0
src/views/groupPageDataManagement/ForewarningManagement/ForewarningIndex/EditForm.vue

@@ -0,0 +1,160 @@
+<template>
+  <tf-dialog v-bind="$attrs" v-on="listeners" @submit="onSubmit" width="676px" top="7vh" v-if="$attrs.visible">
+    <el-row :gutter="15">
+      <el-col>
+        <el-form
+          class="form"
+          ref="form"
+          v-bind="{ labelWidth: 'auto', size: 'medium' }"
+          :model="formData"
+          :rules="rules"
+        >
+          <el-form-item
+            v-for="{ name, label, type, required, options, disabled, ...rest } of formItems"
+            :style="{ width: '50%', float: 'left' }"
+            :key="name"
+            :required="required"
+            :label="label"
+            :prop="name"
+            :class="{ fullWidth: name == 'dataSources' || name == 'linkedData' || name == 'explan' }"
+          >
+            <el-date-picker
+              v-if="type === 'date'"
+              v-model="formData[name]"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              format="yyyy-MM-dd"
+              :disabled="disabled"
+              :placeholder="`请选择${label}`"
+              clearable
+              size="medium"
+              v-bind="rest"
+            />
+            <el-select
+              v-else-if="type === 'select'"
+              v-model="formData[name]"
+              filterable
+              :placeholder="`请选择${label}`"
+              size="medium"
+              clearable
+              v-bind="rest"
+              style="width: 100%"
+            >
+              <el-option v-for="item in options" :key="item.id" :label="item.notes" :value="item.codeValue" />
+            </el-select>
+            <template v-else-if="type === 'switch'">
+              <el-radio v-model="formData[name]" label="是">是</el-radio>
+              <el-radio v-model="formData[name]" label="否">否</el-radio>
+            </template>
+            <el-input
+              v-else
+              v-model="formData[name]"
+              :type="type || 'text'"
+              :rows="2"
+              :disabled="disabled"
+              :placeholder="name === 'no' ? '系统自动添加' : `请输入${label}`"
+              size="medium"
+              clearable
+              v-bind="rest"
+            />
+          </el-form-item>
+        </el-form>
+      </el-col>
+    </el-row>
+  </tf-dialog>
+</template>
+
+<script lang="ts">
+import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
+import { ElForm } from 'element-ui/types/form'
+import { IFWIndex, IKeyCode } from '../../commonAPI/common'
+import { getByKeys } from '../../commonAPI/request'
+
+const getDefaultValue = (): Partial<IFWIndex> => ({
+  warningMethod: undefined,
+  warningType: undefined,
+  warningGroup: undefined,
+  warningIndexCode: undefined,
+  warningIndexName: undefined,
+  warningIndexShortName: undefined,
+  dataSources: undefined,
+  linkedData: undefined,
+  explan: undefined,
+  isEnable: undefined
+})
+
+@Component({ name: 'EditForm' })
+export default class EditForm extends Vue {
+  @Prop({ type: Object, default: () => ({}) }) data!: object
+  $refs!: { form: ElForm }
+  formData: Partial<IFWIndex> = {
+    ...getDefaultValue()
+  }
+  methods: IKeyCode[] = []
+
+  types: IKeyCode[] = []
+
+  mounted() {
+    this.getDictionaryValue()
+  }
+  get listeners() {
+    const { submit, ...rest } = this.$listeners
+    return rest
+  }
+
+  get formItems() {
+    return [
+      { label: '预警方式', name: 'warningMethod', type: 'select', required: true, options: this.methods },
+      { label: '预警类型', name: 'warningType', type: 'select', required: true, options: this.types },
+      { label: '预警分组', name: 'warningGroup', required: true },
+      { label: '预警指标代码', name: 'warningIndexCode', required: true },
+      { label: '预警指标名称', name: 'warningIndexName', required: true },
+      { label: '预警指标简称', name: 'warningIndexShortName', required: true },
+      { label: '数据来源', name: 'dataSources' },
+      { label: '关联数据', name: 'linkedData' },
+      { label: '说明', name: 'explan', type: 'textarea' },
+      { label: '是否启用', name: 'isEnable', type: 'switch', required: true }
+    ]
+  }
+
+  rules = {
+    warningMethod: [{ required: true, message: '请选择预警方式' }],
+    warningType: [{ required: true, message: '请选择预警类型' }],
+    warningGroup: [{ required: true, message: '请输入预警分组' }],
+    warningIndexCode: [{ required: true, message: '请输入预警指标代码' }],
+    warningIndexName: [{ required: true, message: '请输入预警指标名称' }],
+    warningIndexShortName: [{ required: true, message: '请输入预警指标简称' }],
+    isEnable: [{ required: true, message: '请选择是否启用' }]
+  }
+
+  onSubmit() {
+    this.$refs.form.validate((valid) => {
+      if (valid) {
+        const { ...rest } = this.formData
+        this.$emit('submit', { ...rest })
+      }
+    })
+  }
+
+  @Watch('data', { immediate: true })
+  setDefaultData(val: IFWIndex) {
+    for (const key in val) {
+      if (val[key] == '/') {
+        val[key] = ''
+      }
+    }
+    this.formData = val.id ? { ...val } : { ...getDefaultValue() }
+  }
+
+  async getDictionaryValue() {
+    let pM = await getByKeys({ keys: 'WARNING_METHOD' })
+    let pT = await getByKeys({ keys: 'WARNING_TYPE' })
+    this.methods = pM.result.WARNING_METHOD
+    this.types = pT.result.WARNING_TYPE
+  }
+}
+</script>
+<style lang="scss" scoped>
+.fullWidth {
+  width: 100% !important;
+}
+</style>

+ 29 - 12
src/views/groupPageDataManagement/ForewarningManagement/ForewarningIndex/widget.vue

@@ -14,42 +14,51 @@
         @export="onExport"
       />
     </template>
-    <tf-table :columns="tableCols" :data="tableData" v-loading="loading.search" @selection-change="onSelectionChange">
+    <tf-table
+      :columns="tableCols"
+      :data="tableData"
+      :pagination="pagination"
+      v-loading="loading.search"
+      @selection-change="onSelectionChange"
+      @page-change="onPageChange"
+    >
       <template v-slot:operation="{ row }">
         <el-button type="text" style="padding: 0" @click="editor(row)">编辑</el-button>
         <el-button type="text" style="padding: 0" @click="remove(row)">删除</el-button>
       </template>
     </tf-table>
-    <!-- <IndexForm
+    <EditForm
       :visible.sync="visible"
       :loading="loading.add || loading.update"
       :data="current"
       :title="`${current.id ? '编辑' : '新增'}`"
       @submit="onSubmit"
-    /> -->
+    />
   </tf-page>
 </template>
 
 <script lang="ts">
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
+import { getDefaultPagination } from '@/utils/constant'
+import { IPagination } from '@/api/common'
 import {
   getWarnIndexPage,
-  addIndexData,
-  editIndexData,
+  addWarnIndex,
+  editWarnIndex,
   deleteWarningIndexById,
   deleteWarningIndex
 } from '../../commonAPI/request'
 import ForewarningHeader from '../../components/ForewarningHeader.vue'
 import { IFWITableColumns } from '../../commonAPI/settings'
 import { ILoading, IForewarningSearchTerm } from '../../commonAPI/common'
-// import IndexForm from './IndexForm.vue'
+import EditForm from './EditForm.vue'
 import axios from '@/utils/request'
 const exporUrl = '/tofly-sxgk/warnIndexManage/exportExcel'
 const importUrl = '/tofly-sxgk/warnIndexManage/importExcel'
 //预警指标管理
 @Component({
   name: 'ForewarningIndex',
-  components: { ForewarningHeader }
+  components: { ForewarningHeader, EditForm }
 })
 export default class ForewarningIndex extends Vue {
   visible: boolean = false
@@ -58,6 +67,8 @@ export default class ForewarningIndex extends Vue {
 
   loading: ILoading = { search: false, add: false, update: false, delete: false, import: false, export: false }
 
+  pagination: IPagination = getDefaultPagination()
+
   term: IForewarningSearchTerm = { method: true, type: true, attention: false, edit: true }
 
   tableCols = IFWITableColumns
@@ -81,18 +92,25 @@ export default class ForewarningIndex extends Vue {
         warningType: data.type
       }
     }
+    params = { ...params, ...this.pagination }
     getWarnIndexPage(params).then((res) => {
       try {
-        this.tableData = res.result.map((item) => {
+        const { records, size, total, current } = res.result
+        this.tableData = records.map((item) => {
           Object.keys(item).forEach((val) => (item[val] = item[val] || '/'))
           return { ...item }
         })
+        this.pagination = { current, size, total }
       } catch (error) {
         console.log(error)
       }
       this.loading.search = false
     })
   }
+  onPageChange(pagination) {
+    this.pagination = { ...this.pagination, ...pagination }
+    this.onSearch()
+  }
   onAdd() {
     this.current = {}
     this.visible = true
@@ -120,11 +138,10 @@ export default class ForewarningIndex extends Vue {
 
   async onSubmit(data) {
     this.loading[data.id ? 'update' : 'add'] = true
-    data['isNew'] = data['isNew'] == '是' ? 1 : 0
-    data['source'] = '人工'
+    console.log(data)
     try {
-      const { result } = await (data.id ? editIndexData({ ...data }) : addIndexData({ ...data }))
-      this.$message[result ? 'success' : 'error'](`${data.id ? '修改' : '新增'}指标${result ? '成功!' : '失败!'}`)
+      const { result } = await (data.id ? editWarnIndex({ ...data }) : addWarnIndex({ ...data }))
+      this.$message[result ? 'success' : 'error'](`${data.id ? '修改' : '新增'}预警指标${result ? '成功!' : '失败!'}`)
       if (result) {
         this.visible = false
         this.onSearch()

+ 201 - 0
src/views/groupPageDataManagement/ForewarningManagement/ForewarningIndexThreshold/EditForm.vue

@@ -0,0 +1,201 @@
+<template>
+  <tf-dialog v-bind="$attrs" v-on="listeners" @submit="onSubmit" width="676px" top="7vh" v-if="$attrs.visible">
+    <el-row :gutter="15">
+      <el-col>
+        <el-form
+          class="form"
+          ref="form"
+          v-bind="{ labelWidth: 'auto', size: 'medium' }"
+          :model="formData"
+          :rules="rules"
+        >
+          <el-form-item
+            v-for="{ name, label, type, required, options, disabled, ...rest } of formItems"
+            :style="{ width: '50%', float: 'left' }"
+            :key="name"
+            :required="required"
+            :label="label"
+            :prop="name"
+            :class="{
+              fullWidth: fwList.includes(name)
+            }"
+          >
+            <el-date-picker
+              v-if="type === 'date'"
+              v-model="formData[name]"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              format="yyyy-MM-dd"
+              :disabled="disabled"
+              :placeholder="`请选择${label}`"
+              clearable
+              size="medium"
+              v-bind="rest"
+            />
+            <el-select
+              v-else-if="type === 'select'"
+              v-model="formData[name]"
+              filterable
+              :placeholder="`请选择${label}`"
+              size="medium"
+              clearable
+              v-bind="rest"
+              style="width: 100%"
+              :value-key="rest.valueKey"
+            >
+              <template v-if="name == 'concernExtent'"
+                ><el-option v-for="item in options" :key="item.id" :label="item.notes" :value="item.notes"
+              /></template>
+              <template v-else
+                ><el-option
+                  v-for="item in options"
+                  :key="item.id"
+                  :label="item.warningIndexName + '-' + item.warningIndexCode"
+                  :value="item"
+              /></template>
+            </el-select>
+            <template v-else-if="type === 'switch'">
+              <el-radio v-model="formData[name]" label="是">是</el-radio>
+              <el-radio v-model="formData[name]" label="否">否</el-radio>
+            </template>
+            <el-input
+              v-else
+              v-model="formData[name]"
+              :type="type || 'text'"
+              :rows="2"
+              :disabled="disabled"
+              :placeholder="name === 'no' ? '系统自动添加' : `请输入${label}`"
+              size="medium"
+              clearable
+              v-bind="rest"
+            />
+          </el-form-item>
+        </el-form>
+      </el-col>
+    </el-row>
+  </tf-dialog>
+</template>
+
+<script lang="ts">
+import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
+import { ElForm } from 'element-ui/types/form'
+import { IFWIndexThreshold, IKeyCode, IFWIndex } from '../../commonAPI/common'
+import { getByKeys, getWarnIndexList } from '../../commonAPI/request'
+
+const getDefaultValue = (): Partial<IFWIndexThreshold> => ({
+  warningIndexName: undefined,
+  indexParam: undefined,
+  thresholdCode: undefined,
+  unit: undefined,
+  specialValue: undefined,
+  flowe: undefined,
+  upper: undefined,
+  effectiveTime: undefined,
+  concernExtent: undefined,
+  warningLevel: undefined,
+  warningTipInfo: undefined,
+  detailInfo: undefined,
+  explain: undefined,
+  isEnable: undefined
+})
+
+@Component({ name: 'EditForm' })
+export default class EditForm extends Vue {
+  @Prop({ type: Object, default: () => ({}) }) data!: object
+  $refs!: { form: ElForm }
+  formData: Partial<IFWIndexThreshold> = {
+    ...getDefaultValue()
+  }
+
+  indicators: Partial<IFWIndex>[] = []
+
+  attention: IKeyCode[] = []
+
+  fwList = ['warningIndexName', 'effectiveTime', 'warningTipInfo', 'detailInfo', 'explain']
+
+  mounted() {
+    this.getDictionaryValue()
+  }
+  get listeners() {
+    const { submit, ...rest } = this.$listeners
+    return rest
+  }
+
+  get formItems() {
+    return [
+      {
+        label: '预警指标名称',
+        name: 'warningIndexName',
+        type: 'select',
+        required: true,
+        options: this.indicators,
+        valueKey: 'warningIndexName'
+      },
+      { label: '指标参数', name: 'indexParam', required: true },
+      { label: '预警阈值编码', name: 'thresholdCode', required: true },
+      { label: '单位', name: 'unit' },
+      { label: '特定值', name: 'specialValue' },
+      { label: '下限', name: 'flowe' },
+      { label: '上限', name: 'upper' },
+      { label: '有效时段', name: 'effectiveTime' },
+      { label: '关注程度', name: 'concernExtent', type: 'select', required: true, options: this.attention },
+      { label: '预警等级', name: 'warningLevel' },
+      { label: '预警提示信息', name: 'warningTipInfo', type: 'textarea', required: true },
+      { label: '详细信息', name: 'detailInfo', type: 'textarea' },
+      { label: '说明', name: 'explain', type: 'textarea' },
+      { label: '是否启用', name: 'isEnable', type: 'switch', required: true }
+    ]
+  }
+
+  rules = {
+    warningIndexName: [{ required: true, message: '请选择预警指标名称' }],
+    indexParam: [{ required: true, message: '请输入指标参数' }],
+    thresholdCode: [{ required: true, message: '请输入预警阈值编码' }],
+    concernExtent: [{ required: true, message: '请选择关注程度' }],
+    warningTipInfo: [{ required: true, message: '请输入预警提示信息' }],
+    isEnable: [{ required: true, message: '请选择是否启用' }]
+  }
+
+  onSubmit() {
+    this.$refs.form.validate((valid) => {
+      if (valid) {
+        if (this.formData.warningIndexName.constructor === Object) {
+          let data = this.formData.warningIndexName
+          Object.keys(data).forEach((key) => {
+            this.formData[key] = data[key]
+          })
+        }
+        this.$emit('submit', this.formData)
+      }
+    })
+  }
+
+  @Watch('data', { immediate: true })
+  setDefaultData(val: IFWIndexThreshold) {
+    for (const key in val) {
+      if (val[key] == '/') {
+        val[key] = ''
+      }
+    }
+    this.formData = val.id ? { ...val } : { ...getDefaultValue() }
+  }
+
+  async getDictionaryValue() {
+    let pT = await getByKeys({ keys: 'CONCERN_EXTENT' })
+    this.attention = pT.result.CONCERN_EXTENT
+    let res = await getWarnIndexList({})
+    this.indicators = res.result.map((item) => {
+      return {
+        warningIndexName: item.warningIndexName,
+        warningIndexCode: item.warningIndexCode,
+        warningType: item.warningType,
+        warningGroup: item.warningGroup
+      }
+    })
+  }
+}
+</script>
+<style lang="scss" scoped>
+.fullWidth {
+  width: 100% !important;
+}
+</style>

+ 38 - 22
src/views/groupPageDataManagement/ForewarningManagement/ForewarningIndexThreshold/widget.vue

@@ -14,42 +14,51 @@
         @export="onExport"
       />
     </template>
-    <tf-table :columns="tableCols" :data="tableData" v-loading="loading.search" @selection-change="onSelectionChange">
+    <tf-table
+      :columns="tableCols"
+      :data="tableData"
+      :pagination="pagination"
+      v-loading="loading.search"
+      @selection-change="onSelectionChange"
+      @page-change="onPageChange"
+    >
       <template v-slot:operation="{ row }">
         <el-button type="text" style="padding: 0" @click="editor(row)">编辑</el-button>
         <el-button type="text" style="padding: 0" @click="remove(row)">删除</el-button>
       </template>
     </tf-table>
-    <!-- <IndexForm
+    <EditForm
       :visible.sync="visible"
       :loading="loading.add || loading.update"
       :data="current"
       :title="`${current.id ? '编辑' : '新增'}`"
       @submit="onSubmit"
-    /> -->
+    />
   </tf-page>
 </template>
 
 <script lang="ts">
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
+import { getDefaultPagination } from '@/utils/constant'
+import { IPagination } from '@/api/common'
 import {
   getWarnIndexThresholdPage,
-  addIndexData,
-  editIndexData,
-  deleteIndexDataById,
-  deleteIndexData
+  addWarnIndexThreshold,
+  editWarnIndexThreshold,
+  deleteWarningIndexThresholdById,
+  deleteWarningIndexThreshold
 } from '../../commonAPI/request'
 import ForewarningHeader from '../../components/ForewarningHeader.vue'
 import { IFWITTableColumns } from '../../commonAPI/settings'
 import { ILoading, IForewarningSearchTerm } from '../../commonAPI/common'
-// import IndexForm from './IndexForm.vue'
+import EditForm from './EditForm.vue'
 import axios from '@/utils/request'
 const exporUrl = '/tofly-sxgk/indexThreshold/exportExcel'
 const importUrl = '/tofly-sxgk/indexThreshold/importExcel'
-//预警指标管理
+//预警指标阈值管理
 @Component({
   name: 'ForewarningIndexThreshold',
-  components: { ForewarningHeader }
+  components: { ForewarningHeader, EditForm }
 })
 export default class ForewarningIndexThreshold extends Vue {
   visible: boolean = false
@@ -58,6 +67,8 @@ export default class ForewarningIndexThreshold extends Vue {
 
   loading: ILoading = { search: false, add: false, update: false, delete: false, import: false, export: false }
 
+  pagination: IPagination = getDefaultPagination()
+
   term: IForewarningSearchTerm = { method: false, type: true, attention: true, edit: true }
 
   tableCols = IFWITTableColumns
@@ -77,22 +88,29 @@ export default class ForewarningIndexThreshold extends Vue {
     if (data) {
       params = {
         keyword: data.keyword,
-        warningMethod: data.method,
-        warningType: data.type
+        warningType: data.type,
+        concernExtent: data.attention
       }
     }
+    params = { ...params, ...this.pagination }
     getWarnIndexThresholdPage(params).then((res) => {
       try {
-        this.tableData = res.result.records.map((item) => {
+        const { records, size, total, current } = res.result
+        this.tableData = records.map((item) => {
           Object.keys(item).forEach((val) => (item[val] = item[val] || '/'))
           return { ...item }
         })
+        this.pagination = { current, size, total }
       } catch (error) {
         console.log(error)
       }
       this.loading.search = false
     })
   }
+  onPageChange(pagination) {
+    this.pagination = { ...this.pagination, ...pagination }
+    this.onSearch()
+  }
   onAdd() {
     this.current = {}
     this.visible = true
@@ -109,7 +127,7 @@ export default class ForewarningIndexThreshold extends Vue {
     })
     this.loading.delete = true
     try {
-      const { result } = await deleteIndexDataById({ id: row.id })
+      const { result } = await deleteWarningIndexThresholdById({ id: row.id })
       this.$message[result ? 'success' : 'error'](`删除指标${result ? '成功!' : '失败!'}`)
       result && this.onSearch()
     } catch (error) {
@@ -120,11 +138,9 @@ export default class ForewarningIndexThreshold extends Vue {
 
   async onSubmit(data) {
     this.loading[data.id ? 'update' : 'add'] = true
-    data['isNew'] = data['isNew'] == '是' ? 1 : 0
-    data['source'] = '人工'
     try {
-      const { result } = await (data.id ? editIndexData({ ...data }) : addIndexData({ ...data }))
-      this.$message[result ? 'success' : 'error'](`${data.id ? '修改' : '新增'}指标${result ? '成功!' : '失败!'}`)
+      const { result } = await (data.id ? editWarnIndexThreshold({ ...data }) : addWarnIndexThreshold({ ...data }))
+      this.$message[result ? 'success' : 'error'](`${data.id ? '修改' : '新增'}指标阈值${result ? '成功!' : '失败!'}`)
       if (result) {
         this.visible = false
         this.onSearch()
@@ -136,15 +152,15 @@ export default class ForewarningIndexThreshold extends Vue {
   }
 
   async onDelete(ids) {
-    await this.$confirm(`是否确认删除这${this.selected.length}项指标?`, '提示', {
+    await this.$confirm(`是否确认删除这${this.selected.length}项指标阈值?`, '提示', {
       confirmButtonText: '确定',
       cancelButtonText: '取消',
       type: 'warning'
     })
     this.loading.delete = true
     try {
-      const { result } = await deleteIndexData({ ids })
-      this.$message[result ? 'success' : 'error'](`删除指标${result ? '成功!' : '失败!'}`)
+      const { result } = await deleteWarningIndexThreshold({ ids })
+      this.$message[result ? 'success' : 'error'](`删除指标阈值${result ? '成功!' : '失败!'}`)
       result && this.onSearch()
     } catch (error) {
       console.log(error)
@@ -199,7 +215,7 @@ export default class ForewarningIndexThreshold extends Vue {
         const a = document.createElement('a')
         a.style.display = 'none'
         a.href = href // 指定下载链接
-        a.download = '指标数据.xls' // 指定下载文件名
+        a.download = '预警指标阈值数据.xls' // 指定下载文件名
         a.click()
         this.loading.export = false
       })

+ 16 - 65
src/views/groupPageDataManagement/ForewarningManagement/ForewarningInformation/widget.vue

@@ -8,43 +8,27 @@
         :loading="loading"
         :term="term"
         @search="onSearch"
-        @add="onAdd"
-        @del="onDelete"
         @import="onImport"
         @export="onExport"
       />
     </template>
     <tf-table :columns="tableCols" :data="tableData" v-loading="loading.search" @selection-change="onSelectionChange">
       <template v-slot:isShow="{ row }">
-        <el-switch v-model="row.isShow"> </el-switch>
+        <el-switch v-model="row.isShow" @change="changeInfo(row)"></el-switch>
       </template>
       <template v-slot:isValid="{ row }">
-        <el-switch v-model="row.isValid"> </el-switch>
+        <el-switch v-model="row.isValid" @change="changeInfo(row)"></el-switch>
       </template>
     </tf-table>
-    <!-- <IndexForm
-      :visible.sync="visible"
-      :loading="loading.add || loading.update"
-      :data="current"
-      :title="`${current.id ? '编辑' : '新增'}`"
-      @submit="onSubmit"
-    /> -->
   </tf-page>
 </template>
 
 <script lang="ts">
 import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
-import {
-  getWarnInfoPage,
-  addIndexData,
-  editIndexData,
-  deleteIndexDataById,
-  deleteIndexData
-} from '../../commonAPI/request'
+import { getWarnInfoPage, editWarnInfo } from '../../commonAPI/request'
 import ForewarningHeader from '../../components/ForewarningHeader.vue'
 import { IFWIFTableColumns } from '../../commonAPI/settings'
 import { ILoading, IForewarningSearchTerm } from '../../commonAPI/common'
-// import IndexForm from './IndexForm.vue'
 import axios from '@/utils/request'
 const exporUrl = '/tofly-sxgk/warningInfo/exportExcel'
 const importUrl = '/tofly-sxgk/warningInfo/importExcel'
@@ -79,15 +63,14 @@ export default class ForewarningInformation extends Vue {
     if (data) {
       params = {
         keyword: data.keyword,
-        warningMethod: data.method,
-        warningType: data.type
+        concernExtent: data.attention
       }
     }
     getWarnInfoPage(params).then((res) => {
       try {
         this.tableData = res.result.records.map((item) => {
           Object.keys(item).forEach((val) => (item[val] = item[val] || '/'))
-          return { ...item }
+          return { ...item, isShow: item.isShow == '0' ? true : false, isValid: item.isValid == '0' ? true : false }
         })
       } catch (error) {
         console.log(error)
@@ -95,37 +78,22 @@ export default class ForewarningInformation extends Vue {
       this.loading.search = false
     })
   }
-  onAdd() {
-    this.current = {}
-    this.visible = true
-  }
-  editor(row) {
-    this.current = { ...row }
-    this.visible = true
-  }
-  async remove(row) {
-    await this.$confirm(`是否确认删除此项指标?`, '提示', {
-      confirmButtonText: '确定',
-      cancelButtonText: '取消',
-      type: 'warning'
-    })
-    this.loading.delete = true
-    try {
-      const { result } = await deleteIndexDataById({ id: row.id })
-      this.$message[result ? 'success' : 'error'](`删除指标${result ? '成功!' : '失败!'}`)
-      result && this.onSearch()
-    } catch (error) {
-      console.log(error)
+
+  changeInfo(row) {
+    for (const key in row) {
+      if (row[key] == '/') {
+        row[key] = ''
+      }
     }
-    this.loading.delete = false
+    this.onSubmit(row)
   }
 
   async onSubmit(data) {
     this.loading[data.id ? 'update' : 'add'] = true
-    data['isNew'] = data['isNew'] == '是' ? 1 : 0
-    data['source'] = '人工'
+    data['isShow'] = data['isShow'] ? '0' : '1'
+    data['isValid'] = data['isValid'] ? '0' : '1'
     try {
-      const { result } = await (data.id ? editIndexData({ ...data }) : addIndexData({ ...data }))
+      const { result } = await (data.id ? editWarnInfo({ ...data }) : '')
       this.$message[result ? 'success' : 'error'](`${data.id ? '修改' : '新增'}指标${result ? '成功!' : '失败!'}`)
       if (result) {
         this.visible = false
@@ -137,23 +105,6 @@ export default class ForewarningInformation extends Vue {
     this.loading[data.id ? 'update' : 'add'] = false
   }
 
-  async onDelete(ids) {
-    await this.$confirm(`是否确认删除这${this.selected.length}项指标?`, '提示', {
-      confirmButtonText: '确定',
-      cancelButtonText: '取消',
-      type: 'warning'
-    })
-    this.loading.delete = true
-    try {
-      const { result } = await deleteIndexData({ ids })
-      this.$message[result ? 'success' : 'error'](`删除指标${result ? '成功!' : '失败!'}`)
-      result && this.onSearch()
-    } catch (error) {
-      console.log(error)
-    }
-    this.loading.delete = false
-  }
-
   onImport(data) {
     this.loading.import = true
     axios
@@ -200,7 +151,7 @@ export default class ForewarningInformation extends Vue {
         const a = document.createElement('a')
         a.style.display = 'none'
         a.href = href // 指定下载链接
-        a.download = '指标数据.xls' // 指定下载文件名
+        a.download = '预警信息.xls' // 指定下载文件名
         a.click()
         this.loading.export = false
       })

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

@@ -67,4 +67,36 @@ export interface IForewarningSearchTerm {
     type?: boolean,
     attention?: boolean,
     edit?: boolean
+}
+
+export interface IFWIndex {
+    id?: number,
+    warningMethod: string,
+    warningType: string,
+    warningGroup: string,
+    warningIndexCode: string,
+    warningIndexName: string,
+    warningIndexShortName: string,
+    dataSources: string,
+    linkedData: string,
+    explan: string,
+    isEnable: string,
+}
+
+export interface IFWIndexThreshold {
+    id?: number,
+    warningIndexName: string,
+    indexParam: string,
+    thresholdCode: string,
+    unit: string,
+    specialValue: string,
+    flowe: string,
+    upper: string,
+    effectiveTime: string,
+    concernExtent: string,
+    warningLevel: string,
+    warningTipInfo: string,
+    detailInfo: string,
+    explain: string,
+    isEnable: string,
 }

+ 65 - 2
src/views/groupPageDataManagement/commonAPI/request.ts

@@ -98,13 +98,37 @@ export function updatePbsList(data) {
 }
 // ======================================================================>
 //预警指标管理(列表查询)
-export function getWarnIndexPage(params) {
+export function getWarnIndexList(params) {
     return request({
         url: '/tofly-sxgk/warnIndexManage/list',
         method: 'get',
         params
     })
 }
+//预警指标管理(分页查询)
+export function getWarnIndexPage(params) {
+    return request({
+        url: '/tofly-sxgk/warnIndexManage/page',
+        method: 'get',
+        params
+    })
+}
+//新增预警指标
+export function addWarnIndex(data) {
+    return request({
+        url: '/tofly-sxgk/warnIndexManage',
+        method: 'post',
+        data
+    })
+}
+//修改预警指标
+export function editWarnIndex(data) {
+    return request({
+        url: '/tofly-sxgk/warnIndexManage',
+        method: 'put',
+        data
+    })
+}
 //预警指标管理(删除单个)
 export function deleteWarningIndexById(data) {
     return request({
@@ -129,6 +153,37 @@ export function getWarnIndexThresholdPage(params) {
         params
     })
 }
+//新增预警指标阈值
+export function addWarnIndexThreshold(data) {
+    return request({
+        url: '/tofly-sxgk/indexThreshold',
+        method: 'post',
+        data
+    })
+}
+//修改预警指标阈值
+export function editWarnIndexThreshold(data) {
+    return request({
+        url: '/tofly-sxgk/indexThreshold',
+        method: 'put',
+        data
+    })
+}
+//预警指标阈值管理(删除单个)
+export function deleteWarningIndexThresholdById(data) {
+    return request({
+        url: `/tofly-sxgk/indexThreshold/${data.id}`,
+        method: 'DELETE',
+    })
+}
+//预警指标阈值管理(批量删除)
+export function deleteWarningIndexThreshold(data) {
+    return request({
+        url: '/tofly-sxgk/indexThreshold/deleteByIds',
+        method: 'DELETE',
+        params: data
+    })
+}
 // ======================================================================>
 //预警信息管理(分页查询)
 export function getWarnInfoPage(params) {
@@ -137,4 +192,12 @@ export function getWarnInfoPage(params) {
         method: 'get',
         params
     })
-}
+}
+//修改预警指标阈值
+export function editWarnInfo(data) {
+    return request({
+        url: '/tofly-sxgk/warningInfo',
+        method: 'put',
+        data
+    })
+}