hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<template>
  <div class='ins-report'>
    <div class="nav-link">
      <span><router-link to="/sa_ins_record">巡查记录</router-link></span>
      <span><router-link to="/sa_ins_work">安全工作记录</router-link></span>
      <span class="active"><router-link to="">安全隐患报告</router-link></span>
    </div>
    <v-header
      title="安全隐患报告"
      :bar="bar"
      search
      @on-search="onSearch"
    ></v-header>
    <div class="add">
      <button class="m_btn bgc_primary" @click="down()">批量下载</button>
      <button class="m_btn bgc_primary" @click="exports()">导出台账</button>
    </div>
    <div class="tab">
      <v-tool-table
        :trs="tr"
        :tds="tds"
        first
        firstWidth="50px"
      >
        <template v-slot:first-th>
          <div>
            <el-checkbox @change="cheAll" v-model="alls"></el-checkbox>
          </div>
        </template>
        <template v-slot:first-td="item">
          <div>
            <el-checkbox @change="change" v-model="item.scope.che"></el-checkbox>
          </div>
        </template>
        <template v-slot:type="{scope}">
             {{formatPatrol(scope)}}
        </template>
        <template v-slot:level="{scope}">
          <span v-if="scope.dangerLevel === '1'">红色预警</span>
          <span v-if="scope.dangerLevel === '2'">橙色预警</span>
          <span v-if="scope.dangerLevel === '3'">黄色预警</span>
          <span v-if="scope.dangerLevel === '4'">蓝色预警</span>
        </template>
        <template v-slot:status="{scope}">
          <span v-if="scope.status === '1'">待处理</span>
          <span v-if="scope.status === '2'">待整改</span>
          <span v-if="scope.status === '3'">已整改</span>
        </template>
        <template v-slot:btn="{scope}">
          <div class="table_flex">
            <span @click="appPath(`sa_ins_reports/${scope.id}`)">查看</span>
            <span v-if="scope.status === '1'" @click="onSend(scope)">待处理</span>
            <span @click="appPath(`sa_ins_work_edit/${scope.id}/report`)">编辑</span>
          </div>
        </template>
        <template v-slot:report>
          <div class="table_flex">
            <span>安全工作记录</span>
          </div>
        </template>
      </v-tool-table>
    </div>
    <div class="page">
      <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
    </div>
    <!-- 处理弹窗 -->
    <EditModel v-model="isShow" :item="editData" @change="isShow = false, editData = {}" @success="onEditSuccess" />
  </div>
</template>
 
<script>
import EditModel from "./components/EditModel.vue"
const queryOptions = [
  { label: "火灾隐患", value: 1 },
  { label: "汛情隐患", value: 2 },
  { label: "疫情隐患", value: 3 },
];
 
const status = [
  { label: "待处理", value: 1 },
  { label: "待整改", value: 2 },
  { label: "已整改", value: 3 },
]
 
export default {
  props: {},
  components: {EditModel},
  data() {
    return {
      bar: [
        { title: "人员", name: "patrolPerson" },
        { title: "巡查类型", name: "patrolType", type: "select",
          list: queryOptions
        },
        { title: "状态", name: "status", type: "select",
          list: status
        },
        { title: "巡查时间", name: "c", type: "times" },
      ],
      tr: [
        { text: "序号", val: "index" },
        { text: "安全隐患地址", val: "address" },
        { text: "隐患简述", val: "dagerDescription" },
        { text: "隐患类型",  val: "btn" , slot:"type"},
        { text: "状态", val: "btn" ,slot:"status"},
        { text: "风险等级", val: "btn" ,slot:"level"},
        { text: "巡查人员", val: "ppersonName" },
        { text: "联系电话", val: "ppersonPhone" },
        { text: "填报时间", val: "createAt" },
        { text: "备注", val: "remark" },
        { text: "整改人员", val: "dpersonName" },
        { text: "联系电话", val: "dpersonPhone" },
        { text: "整改时间", val: "rectifyTime" },
        { text: "操作", val: "btn" },
      ],
      tds: [],
      patrolAtBegin: "",
      patrolAtEnd: "",
      ids:[], //选中的id集合
      alls: false, //全选状态
      isShow:false,
      editData:{},
      loading:{},
      paged: { page: 0, total: 0, r: 0, limit: 10 }, //分页
    };
  },
 
  watch: {},
 
  inject: ["appPath"],
 
  mounted() {},
 
  methods: {
 
    onEditSuccess () {
      this.init();
    },
    
    formatPatrol (scope) {
      const patrolType = scope.patrolType ? scope.patrolType.split(',') : [];
      return patrolType.length ? patrolType.map(d => queryOptions.find(m => m.value === +d).label).join(',') : ''
    },
    
    init() {
     let params = {
        patrolAtBegin: this.patrolAtBegin,
        patrolAtEnd: this.patrolAtEnd,
        patrolPerson: this.patrolPerson,
        patrolType: this.patrolType,
        status: this.status,
        pageNum: this.paged.page,
        pageSize: this.paged.limit,
        selectPerson:1,
     }
      this.$api.post('patrolRecord/pageDangerReport', params, e => {
        this.paged.total = e.total
        this.tds = e.records
        this.tds.map((item,index) => {     
          item.index = index + 1;
          this.$set(item, 'che', false)
 
        })
      })
    },
 
    // 分页
    onPage (v) {
      if (v.page === this.paged.page && v.page && !v.reset) {
        return 0;
      }
      this.paged.page = v.page;
      this.paged.limit = v.limit;
      this.init();
    },
 
    // 监听时间选择范围
    onSearch(v) {
      console.log(v)
      if (v.c && v.c.length && v.c[1]) {
        v.patrolAtBegin = v.c[0];
        v.patrolAtEnd = v.c[1];
      } else {
        v.patrolAtBegin = "";
        v.patrolAtEnd = "";
      }
      this.patrolAtBegin = v.patrolAtBegin,
      this.patrolAtEnd = v.patrolAtEnd,
      this.patrolPerson = v.patrolPerson,
      this.patrolType = v.patrolType,
      this.status = v.status,
      this.paged.page = 1;
      this.init();
    },
 
   //导出
    exports(v) {
      if(!this.ids.length) {
        demo.toast("请勾选需要下载的内容");
        return  
      }
      
      let t = this
      console.log(t.ids)
      this.$api.post("patrolRecord/danger/export", t.ids, (e) => {
        console.log(e)
        window.location.href = e;
      });
    },
 
 
    onSend(e) {
      this.editData = e;
      this.isShow = true;
      // this.$store.dispatch("setFixed", {
      //   event: "add",
      //   data: {
      //     type: "sa-report",
      //     e,
      //   },
      //   time: Date.now(),
      // });
    },
 
    //下载模板
    down(v) {
        if(!this.ids.length) {
          demo.toast("请勾选需要下载的内容");
          return  
        }
      this.loading = this.$loading({
        lock: true,
        text: '下载中,请勿退出系统和关闭网络',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      let t = this
      this.$api.post("patrolRecord/export/DangerReport", t.ids, (e) => {
        window.location.href = e;
        this.loading.close();
      });
    },
    
    cheAll () {
      //全选
      this.tds.map(item => {
        item.che = this.alls
      })
      this.change()
    },
 
    change () {
      //单个选择
      this.ids = []
      this.tds.map(item => {
        if (item.che) {
          this.ids.push(item.id)
        } else {
          this.alls = false
        }
      })
    },
 
  },
 
};
</script>
<style lang='less' scoped>
    @media print {
        html, body {
            height: inherit; //  打印时显示多张
            width:1175px;  // 宽度,太宽会显示不全
        }
    }
  @page {margin:20mm 10mm;}   // 打印时边距
  
.ins-report {
  overflow-y: auto;
  .add,
  .tab,
  .page {
    margin-bottom: 10px;
  }
  .m_btn {
    min-width: 80px;
    margin-right: 10px;
  }
}
.nav-link {
  padding: 20px 0 10px 0;
  span {
    display:inline-block;
    width: 150px;
    height: 30px;
    border: 1px solid #DCDFE6;
    text-align: center;
    line-height: 30px;
    margin-right: 10px;
    a {
      color: #222;
    }
  }
  .active {
    border: 1px #409EFF solid;
    a {
      color: #409EFF;
    }
  }
}
</style>