|
@@ -7,12 +7,18 @@
|
|
|
<el-button plain icon="Close" circle title="关闭" @click="close"></el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div>
|
|
|
- <span>检索依据:</span>
|
|
|
- <el-select v-model="params.method" style="width: 70px">
|
|
|
- <el-option v-for="item in allMethods" :key="item.code" :label="item.name" :value="item.code"></el-option> </el-select
|
|
|
- >
|
|
|
- <el-input ref="inputRef" v-model="params.content" style="width: 240px" clearable placeholder="请输入检索内容"></el-input>
|
|
|
+ <div style="display: flex;align-items: center;">
|
|
|
+ <div>检索依据:</div>
|
|
|
+ <div>
|
|
|
+ <el-select v-model="params.method" style="width: 70px">
|
|
|
+ <el-option v-for="item in allMethods" :key="item.code" :label="item.name" :value="item.code"></el-option> </el-select
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <el-input ref="inputRef" v-model="params.content"
|
|
|
+ style="width: 180px;margin-left: 4px"
|
|
|
+ clearable placeholder="请输入检索内容"></el-input>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="data-box">
|
|
|
<el-table ref="resultRef" :data="data.list" stripe height="360px" highlight-current-row @row-click="clickItem">
|
|
@@ -53,160 +59,142 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
+<script setup>
|
|
|
import { reactive, ref, watch } from 'vue'
|
|
|
import { searchFromServer } from '@/api/inpatient/dictionary'
|
|
|
import { diagTypes } from '@/data/index'
|
|
|
import Sleep from '@/utils/sleep'
|
|
|
|
|
|
-export default {
|
|
|
- props: {
|
|
|
- title: {
|
|
|
- type: String,
|
|
|
- required: true,
|
|
|
- },
|
|
|
- target: {
|
|
|
- type: String,
|
|
|
- required: true,
|
|
|
- },
|
|
|
- medType: {
|
|
|
- type: String,
|
|
|
- default: '',
|
|
|
- },
|
|
|
- showEmpDept: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
- showYbCode: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- }
|
|
|
+const props = defineProps({
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
},
|
|
|
- emits: ['close', 'clickItem'],
|
|
|
- setup(props, ctx) {
|
|
|
- const inputRef = ref(null)
|
|
|
- const resultRef = ref(null)
|
|
|
- const allMethods = [
|
|
|
- { code: 'alpha', name: '拼音' },
|
|
|
- { code: 'code', name: '编码' },
|
|
|
- { code: 'name', name: '名称' },
|
|
|
- ]
|
|
|
- const params = reactive({
|
|
|
- method: 'alpha',
|
|
|
- target: props.target,
|
|
|
- medType: props.medType,
|
|
|
- page: 1,
|
|
|
- pageSize: 10,
|
|
|
- content: '',
|
|
|
- })
|
|
|
- const data = reactive({
|
|
|
- list: [],
|
|
|
- totalSize: 0,
|
|
|
- })
|
|
|
+ target: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ medType: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
+ },
|
|
|
+ showEmpDept: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ showYbCode: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const emits = defineEmits(['close', 'clickItem'])
|
|
|
+
|
|
|
+const inputRef = ref(null)
|
|
|
+const resultRef = ref(null)
|
|
|
+const allMethods = [
|
|
|
+ { code: 'alpha', name: '拼音' },
|
|
|
+ { code: 'code', name: '编码' },
|
|
|
+ { code: 'name', name: '名称' },
|
|
|
+]
|
|
|
+const params = reactive({
|
|
|
+ method: 'alpha',
|
|
|
+ target: props.target,
|
|
|
+ medType: props.medType,
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ content: '',
|
|
|
+})
|
|
|
+const data = reactive({
|
|
|
+ list: [],
|
|
|
+ totalSize: 0,
|
|
|
+})
|
|
|
+
|
|
|
+const showDiagType = ref(false)
|
|
|
+const diagItem = reactive({
|
|
|
+ icdCode: null,
|
|
|
+ icdText: null,
|
|
|
+ diagType: null,
|
|
|
+})
|
|
|
|
|
|
- const showDiagType = ref(false)
|
|
|
- const diagItem = reactive({
|
|
|
- icdCode: null,
|
|
|
- icdText: null,
|
|
|
- diagType: null,
|
|
|
+const executeSearch = () => {
|
|
|
+ if (params.content.trim().length > 1) {
|
|
|
+ searchFromServer(params).then((res) => {
|
|
|
+ data.list = res.list
|
|
|
+ data.totalSize = res.totalSize
|
|
|
+ currentIndex.value = currentIndex.value > data.list.length - 1 ? data.list.length - 1 : currentIndex.value
|
|
|
+ resultRef.value.setCurrentRow(data.list[currentIndex.value])
|
|
|
})
|
|
|
+ } else {
|
|
|
+ data.list = []
|
|
|
+ data.totalSize = 0
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- const executeSearch = () => {
|
|
|
- if (params.content.trim().length > 1) {
|
|
|
- searchFromServer(params).then((res) => {
|
|
|
- data.list = res.list
|
|
|
- data.totalSize = res.totalSize
|
|
|
- currentIndex.value = currentIndex.value > data.list.length - 1 ? data.list.length - 1 : currentIndex.value
|
|
|
- resultRef.value.setCurrentRow(data.list[currentIndex.value])
|
|
|
- })
|
|
|
- } else {
|
|
|
- data.list = []
|
|
|
- data.totalSize = 0
|
|
|
- }
|
|
|
- }
|
|
|
+const currentIndex = ref(0)
|
|
|
+
|
|
|
+const handleCurrentChange = (val) => {
|
|
|
+ params.page = val
|
|
|
+ executeSearch()
|
|
|
+}
|
|
|
|
|
|
- const currentIndex = ref(0)
|
|
|
+const confirmDiaginfo = () => {
|
|
|
+ emits('clickItem', diagItem)
|
|
|
+}
|
|
|
|
|
|
- const handleCurrentChange = (val) => {
|
|
|
- params.page = val
|
|
|
- executeSearch()
|
|
|
- }
|
|
|
+const clickItem = (item) => {
|
|
|
+ if (props.target === 'diag' || props.target === 'injurydiag') {
|
|
|
+ diagItem.icdCode = item.code
|
|
|
+ diagItem.icdText = item.name
|
|
|
+ diagItem.diagType = '1'
|
|
|
+ showDiagType.value = true
|
|
|
+ } else {
|
|
|
+ emits('clickItem', item)
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- const confirmDiaginfo = () => {
|
|
|
- ctx.emit('clickItem', diagItem)
|
|
|
- }
|
|
|
+const close = () => {
|
|
|
+ emits('close')
|
|
|
+}
|
|
|
|
|
|
- const clickItem = (item) => {
|
|
|
- if (props.target === 'diag' || props.target === 'injurydiag') {
|
|
|
- diagItem.icdCode = item.code
|
|
|
- diagItem.icdText = item.name
|
|
|
- diagItem.diagType = '1'
|
|
|
- showDiagType.value = true
|
|
|
- } else {
|
|
|
- ctx.emit('clickItem', item)
|
|
|
- }
|
|
|
+watch(
|
|
|
+ () => params.content,
|
|
|
+ () => {
|
|
|
+ executeSearch()
|
|
|
}
|
|
|
+)
|
|
|
|
|
|
- const close = () => {
|
|
|
- ctx.emit('close')
|
|
|
- }
|
|
|
+onMounted(async () => {
|
|
|
+ await Sleep(100)
|
|
|
+ inputRef.value.focus()
|
|
|
|
|
|
- watch(
|
|
|
- () => params.content,
|
|
|
- () => {
|
|
|
- executeSearch()
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
- onMounted(async () => {
|
|
|
- await Sleep(100)
|
|
|
- inputRef.value.focus()
|
|
|
-
|
|
|
- document.onkeydown = (e) => {
|
|
|
- switch (e.code) {
|
|
|
- case 'ArrowUp':
|
|
|
- resultRef.value.setCurrentRow(data.list[currentIndex.value === 0 ? 0 : --currentIndex.value])
|
|
|
- return false
|
|
|
- case 'ArrowDown':
|
|
|
- resultRef.value.setCurrentRow(data.list[currentIndex.value === data.list.length - 1 ? data.list.length - 1 : ++currentIndex.value])
|
|
|
- return false
|
|
|
- case 'ArrowLeft':
|
|
|
- if (params.page > 1) {
|
|
|
- handleCurrentChange(params.page - 1)
|
|
|
- }
|
|
|
- return false
|
|
|
- case 'ArrowRight':
|
|
|
- if (params.page * params.pageSize < data.totalSize) {
|
|
|
- handleCurrentChange(params.page + 1)
|
|
|
- }
|
|
|
- return false
|
|
|
- case 'Enter':
|
|
|
- clickItem(data.list[currentIndex.value])
|
|
|
- break
|
|
|
- case 'Escape':
|
|
|
- close()
|
|
|
- break
|
|
|
+ document.onkeydown = (e) => {
|
|
|
+ switch (e.code) {
|
|
|
+ case 'ArrowUp':
|
|
|
+ resultRef.value.setCurrentRow(data.list[currentIndex.value === 0 ? 0 : --currentIndex.value])
|
|
|
+ return false
|
|
|
+ case 'ArrowDown':
|
|
|
+ resultRef.value.setCurrentRow(data.list[currentIndex.value === data.list.length - 1 ? data.list.length - 1 : ++currentIndex.value])
|
|
|
+ return false
|
|
|
+ case 'ArrowLeft':
|
|
|
+ if (params.page > 1) {
|
|
|
+ handleCurrentChange(params.page - 1)
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- return {
|
|
|
- inputRef,
|
|
|
- resultRef,
|
|
|
- data,
|
|
|
- params,
|
|
|
- allMethods,
|
|
|
- diagItem,
|
|
|
- diagTypes,
|
|
|
- showDiagType,
|
|
|
- confirmDiaginfo,
|
|
|
- executeSearch,
|
|
|
- handleCurrentChange,
|
|
|
- clickItem,
|
|
|
- close,
|
|
|
+ return false
|
|
|
+ case 'ArrowRight':
|
|
|
+ if (params.page * params.pageSize < data.totalSize) {
|
|
|
+ handleCurrentChange(params.page + 1)
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ case 'Enter':
|
|
|
+ clickItem(data.list[currentIndex.value])
|
|
|
+ break
|
|
|
+ case 'Escape':
|
|
|
+ close()
|
|
|
+ break
|
|
|
}
|
|
|
- },
|
|
|
-}
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|