马宇豪
2024-11-26 bd19a941293d124d7c58c6d351e7e86c1fa15559
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
<template>
    <div class="home-container">
        <div style="height: 100%">
          <div class="homeCard">
            <div class="main-card">
            <el-row class="cardTop">
              <el-col :span="12" class="mainCardBtn">
                <el-button type="primary" icon="Plus" size="default" @click="openDialog('add',{})">新增</el-button>
              </el-col>
            </el-row>
            <el-table :data="reportData" style="width: 100%" height="calc(100% - 48px)" :header-cell-style="{ background: '#fafafa' }">
              <el-table-column prop="id" label="id" show-overflow-tooltip></el-table-column>
              <el-table-column prop="name" label="证书名称" show-overflow-tooltip></el-table-column>
              <el-table-column prop="cateName" label="分类名称" show-overflow-tooltip></el-table-column>
              <el-table-column prop="orgName" label="发证机构" show-overflow-tooltip></el-table-column>
              <el-table-column prop="pusTime" label="发证日期" show-overflow-tooltip></el-table-column>
              <el-table-column prop="effectiveTime" label="有效期至" show-overflow-tooltip></el-table-column>
              <el-table-column prop="dueTime" label="到期提醒时间" show-overflow-tooltip></el-table-column>
              <el-table-column prop="notifyUser" label="提醒人" show-overflow-tooltip></el-table-column>
              <el-table-column prop="cateType" label="分类标识" show-overflow-tooltip>
                <template #default="scope">
                  {{getTypeName(scope.row.cateType)}}
                </template>
              </el-table-column>
              <el-table-column prop="files" label="附件" show-overflow-tooltip>
                <template #default="scope">
                  <div v-if="scope.row.files && scope.row.files !== ''">
                    <el-image
                        v-for="(item,index) in scope.row.files.split(',')"
                        style="width: 50px; height: 50px"
                        :src="item"
                        fit="cover"
                        :preview-teleported= true
                    />
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="操作" width="140">
                  <template #default="scope">
                      <el-button size="small" text type="primary" @click="openDialog('update',scope.row)">重新上报</el-button>
                      <el-button style="color: red" size="small" text type="primary" @click="onRowDel(scope.row)">删除</el-button>
                  </template>
              </el-table-column>
            </el-table>
            <div class="pageBtn">
              <el-pagination @size-change="onHandleSizeChange" small="false" @current-change="onHandleCurrentChange" class="page-position" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="listQuery.pageIndex" background v-model:page-size="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination>
            </div>
            </div>
          </div>
        </div>
        <add-report ref="reportRef" @refresh="getData"></add-report>
    </div>
</template>
 
<script lang="ts">
import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue'
import { ElMessageBox, ElMessage } from 'element-plus'
import { Plus } from '@element-plus/icons-vue'
import addReport from "./components/addReport.vue"
import {judgeReportApi} from "/@/api/dataUpload/saftyBaseInfo/judgeReport";
interface TableDataState {
  reportData: [],
  listQuery: {
    searchParams: {}
    pageIndex: number
    pageSize: number
  }
  cateTypeList: Array<typeList>
  total: null | number
}
 
interface typeList{
  value: string
  label: string
}
 
export default defineComponent({
    name: 'cardInfo',
    components: {addReport },
    setup() {
      const reportRef= ref();
      const state = reactive<TableDataState>({
        reportData: [],
        listQuery: {
          searchParams: {},
          pageIndex: 1,
          pageSize: 10
        },
        total: null,
        cateTypeList: [
          {
            value: 'CATETYPE1',
            label: '营业执照'
          },
          {
            value: 'CATETYPE2',
            label: '安全生产许可证'
          },
          {
            value: 'CATETYPE3',
            label: '危险化学品登记证'
          },
          {
            value: 'CATETYPE4',
            label: '主要负责人考核合格证'
          },
          {
            value: 'CATETYPE5',
            label: '安全管理人员考核合格证'
          },
          {
            value: 'CATETYPE6',
            label: '特种作业人员操作证'
          },
          {
            value: 'CATETYPE0',
            label: '其他'
          }
        ]
      });
 
      // 页面加载时
      onMounted(() => {
        getData()
      });
 
      const getData = async ()=>{
        const res = await judgeReportApi().getCardList(state.listQuery)
        if(res.data.code == 200){
          state.reportData = res.data.data
          state.total = res.data.total
        }else{
          ElMessage({
            type: 'warning',
            message: res.data.msg
          })
        }
      }
 
      const openDialog=(type:string,data:object)=>{
        reportRef.value.open(type,data,state.cateTypeList)
      }
 
      const getTypeName = (type: string)=>{
        return state.cateTypeList.find(i=>i.value == type)?.label
      }
 
      // 删除用户
      const onRowDel = (row: Object) => {
          ElMessageBox.confirm(`此操作将永久删除:“${row.name}”,是否继续?`, '提示', {
              confirmButtonText: '确认',
              cancelButtonText: '取消',
              type: 'warning'
          })
              .then(async () => {
                const res = await judgeReportApi().delCard({ids: [row.id]})
                if(res.data.code == 200){
                  ElMessage({
                    type: 'success',
                    message: '删除成功'
                  })
                  await getData()
                }else{
                  ElMessage({
                    type: 'warning',
                    message: res.data.msg
                  })
                }
              })
              .catch(() => {});
      };
      // 分页改变
      const onHandleSizeChange = (val: number) => {
          state.listQuery.pageSize = val;
          getData()
      };
      // 分页改变
      const onHandleCurrentChange = (val: number) => {
          state.listQuery.pageIndex = val;
          getData()
      };
 
      return {
        reportRef,
        openDialog,
        getTypeName,
        getData,
        onRowDel,
        onHandleSizeChange,
        onHandleCurrentChange,
        ...toRefs(state)
      };
    }
});
</script>
<style lang="scss" scoped>
.home-container {
  height: calc(100vh - 144px);
  box-sizing: border-box;
  overflow: hidden;
  .demo-tabs {
    width: 100%;
    height: 100%;
 
    &::v-deep(.el-tabs__content) {
      height: calc(100% - 60px);
    }
 
    .el-tab-pane {
      height: 100%;
    }
  }
  .homeCard {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    background: #fff;
    border-radius: 4px;
 
    .main-card {
      width: 100%;
      height: 100%;
      .cardTop {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20px;
        .mainCardBtn {
          margin: 0;
        }
      }
      .pageBtn {
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: right;
 
        .demo-pagination-block + .demo-pagination-block {
          margin-top: 10px;
        }
        .demo-pagination-block .demonstration {
          margin-bottom: 16px;
        }
      }
    }
    &:last-of-type {
      height: calc(100% - 100px);
    }
  }
  .el-row {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
    .grid-content {
      align-items: center;
      min-height: 36px;
    }
 
    .topInfo {
      display: flex;
      align-items: center;
      font-size: 16px;
      font-weight: bold;
 
      & > div {
        white-space: nowrap;
        margin-right: 20px;
      }
    }
  }
  .el-card {
    border: 0;
  }
}
</style>