Procházet zdrojové kódy

新增 病案质控

yuwandanmian před 2 roky
rodič
revize
626bbfa092

+ 109 - 0
src/views/rule/case/components/SearchBox.vue

@@ -0,0 +1,109 @@
+<template>
+  <div class="app-container">
+    <el-form :inline="true" :model="data" class="demo-form-inline">
+      <el-form-item label="">
+        <el-input v-model="data.name" placeholder="请输入账号" />
+      </el-form-item>
+      <el-form-item label="">
+        <el-select v-model="data.dep_id" filterable clearable placeholder="请选择科室">
+          <el-option v-for="item of deportments" :key="item.id" :label="item.name" :value="item.id" />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="">
+        <el-input v-model="data.keyword" placeholder="请输入搜索条件" />
+      </el-form-item>
+      <el-form-item label="">
+        <el-date-picker
+          v-model="data.start_time"
+          type="date"
+          :picker-options="pickerOptions1"
+          placeholder="开始日期"
+        />
+      </el-form-item>
+      <el-form-item label="">
+        <el-date-picker
+          v-model="data.end_time"
+          type="date"
+          :picker-options="pickerOptions2"
+          placeholder="结束日期"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click="onSubmit">查询</el-button>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+
+<script>
+import { getDeportmentList } from '@/api/admin'
+export default {
+  props: {
+    data: {
+      type: Object,
+      default() {
+        return {
+          name: '',
+          dep_id: '',
+          start_time: '',
+          end_time: '',
+          keyword: ''
+        }
+      }
+    }
+  },
+  data() {
+    return {
+      pickerOptions1: {
+        disabledDate: (time) => {
+          if (this.data.end_time) {
+            return time.getTime() > new Date(this.data.end_time).getTime()
+          } else {
+            return time.getTime() > Date.now()
+          }
+        }
+      },
+      pickerOptions2: {
+        disabledDate: (time) => {
+          if (this.data.start_time) {
+            return time.getTime() < new Date(this.data.start_time).getTime()
+          } else {
+            return time.getTime() > Date.now()
+          }
+        }
+      },
+      deportments: []
+    }
+  },
+  created() {
+    this.getDeportmentList()
+  },
+  methods: {
+    onSubmit() {
+      console.log(this.data, 'this.data')
+      this.$emit('search')
+    },
+    getDeportmentList() {
+      getDeportmentList().then(res => {
+        console.log(res)
+        const { p } = res
+        if (Object.keys(p.list).length) {
+          for (const key in p.list) {
+            this.deportments.push({
+              id: key,
+              name: p.list[key]
+            })
+          }
+          console.log(this.deportments, 'this.deportments')
+        }
+      }).catch(error => {
+        console.log(error)
+      })
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 65 - 0
src/views/rule/case/components/TableBox.vue

@@ -0,0 +1,65 @@
+<template>
+  <div class="app-container">
+    <div class="btn-box">
+      <el-button type="primary" icon="el-icon-download" style="float: right; margin-bottom: 15px;" @click="onExcelDownload">导出</el-button>
+    </div>
+    <el-table
+      v-loading="loading"
+      :data="data"
+      style="width: 100%"
+    >
+      <el-table-column type="index" label="#" width="80" />
+      <el-table-column
+        prop="username"
+        label="账号"
+        width="180"
+      />
+      <el-table-column
+        prop="dep_name"
+        label="科室"
+        width="180"
+      />
+      <el-table-column
+        prop="content"
+        label="搜索条件"
+      />
+      <el-table-column
+        prop="created_at"
+        label="查询时间"
+        width="180"
+        align="right"
+      />
+    </el-table>
+  </div>
+</template>
+
+<script>
+
+export default {
+  props: {
+    data: {
+      type: Array,
+      default() {
+        return []
+      }
+    },
+    loading: {
+      type: Boolean,
+      default() {
+        return false
+      }
+    }
+  },
+  methods: {
+    onExcelDownload() {
+      this.$emit('download')
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.btn-box {
+  overflow: hidden;
+}
+</style>

+ 116 - 0
src/views/rule/case/index.vue

@@ -0,0 +1,116 @@
+<template>
+  <div>
+    <SearchBoxVue :data="searchData" @search="handleSearch" />
+    <TableBoxVue :loading="loading" :data="tableData" style="margin-top: -40px;" @download="handleDownLoad" />
+    <pagination
+      :auto-scroll="false"
+      :total="paginationData.total"
+      :page="paginationData.page"
+      :limit="paginationData.limit"
+      @pagination="handlePagination"
+    />
+  </div>
+</template>
+
+<script>
+import SearchBoxVue from './components/SearchBox.vue'
+import TableBoxVue from './components/TableBox.vue'
+import { userSearchLogExport } from '@/api/excel'
+import { userSearchLog } from '@/api/admin'
+import { dateFormat } from '@/filters/index'
+
+export default {
+  components: {
+    SearchBoxVue,
+    TableBoxVue
+  },
+  data() {
+    return {
+      loading: false,
+      searchData: {
+        name: '',
+        dep_id: '',
+        keyword: '',
+        start_time: '',
+        end_time: ''
+      },
+      tableData: [],
+      paginationData: {
+        total: 0,
+        page: 1,
+        limit: 10
+      }
+    }
+  },
+  created() {
+    this.getList()
+  },
+  methods: {
+    getList() {
+      const { name, dep_id, keyword, start_time, end_time } = this.searchData
+      const { page, limit } = this.paginationData
+      const params = {
+        name,
+        dep_id,
+        page,
+        limit,
+        keyword
+      }
+      params.start_time = start_time ? dateFormat(start_time, 'YYYYMMDD') : ''
+      params.end_time = end_time ? dateFormat(end_time, 'YYYYMMDD') : ''
+      this.loading = true
+      userSearchLog(params).then(res => {
+        const { p } = res
+        this.paginationData.total = p.count
+        this.tableData = p.list
+      }).catch(error => {
+        console.log(error)
+      }).finally(() => {
+        this.loading = false
+      })
+    },
+    handlePagination(param) {
+      this.paginationData.page = param.page
+      this.paginationData.limit = param.limit
+      this.getList()
+    },
+    handleSearch() {
+      this.paginationData.page = 1
+      this.getList()
+    },
+    handleDownLoad() {
+      const { name, dep_id, time, keyword } = this.searchData
+      const params = {
+        name,
+        dep_id,
+        keyword
+      }
+      if (time && time.length) {
+        params.start_time = time[0]
+        params.end_time = time[1]
+      }
+      userSearchLogExport(params).then(res => {
+        const content = res.data // 后台返回二进制数据
+        const blob = new Blob([content])
+        const fileName = `科研探索日志.csv`
+        if ('download' in document.createElement('a')) { // 非IE下载
+          const elink = document.createElement('a')
+          elink.download = fileName
+          elink.style.display = 'none'
+          elink.href = URL.createObjectURL(blob)
+          document.body.appendChild(elink)
+          elink.click()
+          URL.revokeObjectURL(elink.href) // 释放URL 对象
+          document.body.removeChild(elink)
+        } else { // IE10+下载
+          navigator.msSaveBlob(blob, fileName)
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>