zhouwx
2024-08-02 62bde619a25f82ab153c71d4008024a043e075fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<template>
  <div class="inner">
    <a-row type="flex" justify="space-between" style="margin-bottom: 20px">
      <a-col :span="4">
        <a-button type="primary" @click="editData('add',{})">新增</a-button>
      </a-col>
      <a-col :span="20">
        <a-row type="flex" justify="end" :gutter="12">
<!--          <a-col :span="4">-->
<!--            <a-input v-model="search.searchParams.realName" placeholder="姓名" style="width: 100%"/>-->
<!--          </a-col>-->
<!--          <a-col :span="4">-->
<!--            <a-button type="primary" @click="getUserList">查询</a-button>-->
<!--            <a-button style="margin-left: 12px" @click="resetSearch">重置</a-button>-->
<!--          </a-col>-->
        </a-row>
      </a-col>
    </a-row>
    <div class="table-cont">
      <a-table :columns="columns" :data-source="tableData" :pagination="pagination" :rowKey="record=>record.id" bordered>
        <template #disasterType="type">
            {{ getRiskName(type) }}
        </template>
        <template #action="action,row">
          <a-button type="link" @click="editData('edit',row)" v-preventReClick="1500">编辑</a-button>
          <a-button type="link" class="delBtn" @click="delData(row)">删除</a-button>
        </template>
      </a-table>
    </div>
    <reaction-mod ref="reactRef" @refresh="getMeasureList()"></reaction-mod>
  </div>
</template>
 
<script>
import {getMeasure,addMeasure,delMeasure} from '@/api/new'
import {getUserInfo} from "@/util/storage"
import ReactionMod from "@/views/Admin/components/reactionMod";
import Cookies from "js-cookie";
 
export default {
  name: 'reactionManage',
  components: { ReactionMod },
  data () {
    return {
      unittype: null,
      search:{
        pageIndex: 1,
        pageSize: 10
      },
      columns:[
        {
          title: '所属灾种',
          dataIndex: 'disasterType',
          key: 'disasterType',
          scopedSlots: { customRender: 'disasterType' }
        },
        {
          title: '措施内容',
          dataIndex: 'measure',
          key: 'measure'
        },
        {
          title: '操作',
          width: '12%',
          key: 'action',
          scopedSlots: { customRender: 'action' }
        },
      ],
      riskOptions: [
        {
          name: '地震',
          value: 1
        },
        {
          name: '气象',
          value: 3
        },
        {
          name: '地质灾害',
          value: 4
        },
        {
          name: '水旱',
          value: 5
        },
        {
          name: '森林草原火灾',
          value: 6
        }
      ],
      tableData: [],
      pagination: {
        current: 1,
        defaultCurrent: 1,
        defaultPageSize: 10,
        total: 0,
        onChange: ( page, pageSize ) => this.onPageChange(page,pageSize),
        showTotal: total => `共 ${total} 条`
      }
    }
  },
  created() {
    const t = this
    t.unittype = getUserInfo().unittype
    t.getMeasureList()
  },
  methods:{
    async getMeasureList(){
      const t = this
      const res = await getMeasure(t.search)
      if(res.data.code == 100){
        t.tableData = res.data.data
        t.pagination.total = res.data.total
      }else{
        t.$message.warning(res.data.msg);
      }
    },
 
    getRiskName(type){
      return this.riskOptions.find(i=>i.value == type)?.name
    },
 
    async delData(row){
      const t = this
      this.$confirm({
        title: '提示',
        content: h => <div>是否删除该条响应措施?</div>,
        cancelText: '取消',
        okText: '确认',
        centered: true,
        onOk() {
          delMeasure(row.id).then(res=>{
            if(res.data.code == 100){
              t.$message.success('删除响应措施成功');
              t.getMeasureList()
            }else{
              t.$message.warning(res.data.msg);
            }
          })
        },
        onCancel() {
          console.log('Cancel');
        },
      });
    },
 
    resetSearch(){
      const t = this
      t.search = {
        pageIndex: 1,
        pageSize: 10
      }
      t.getMeasureList()
    },
 
    editData(type,data){
      const t = this
      t.$refs.reactRef.openDialog(type,data)
    },
 
    onPageChange(page, pageSize) {
      const t= this
      t.pagination.current = page
      t.search.pageIndex = page
      t.getMeasureList()
    }
  }
}
</script>
 
<style lang="less" scoped>
.delBtn{
  color: @danger
}
</style>