123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <script setup lang="tsx">
- import { ContentWrap } from '@common/src/components/ContentWrap'
- import { Search } from '@common/src/components/Search'
- import { Table, TableColumn } from '@common/src/components/Table'
- import { BaseButton } from '@common/src/components/Button'
- import { useTable } from '@common/src/hooks/web/useTable'
- import { FormSchema } from '@common/src/components/Form'
- import { ref, unref, reactive } from 'vue'
- import { list, del } from '@/api/xxx'
- import { useRouter } from 'vue-router'
- const { push } = useRouter()
- const props = defineProps({
- tabName: {
- type: String,
- default: '1'
- }
- })
- const { tableRegister, tableState, tableMethods } = useTable({
- fetchDataApi: async () => {
- const { currentPage, pageSize } = tableState
- const res = await list({
- current: unref(currentPage),
- size: unref(pageSize),
- ...unref(searchParams)
- })
- return {
- list: res.data.list,
- total: res.data.totalCount
- }
- }
- })
- const { loading, dataList, total, currentPage, pageSize } = tableState
- const { getList } = tableMethods
- interface ISearch {
- caseId?: string
- userName?: string
- createTimeStart?: string
- createTimeEnd?: string
- }
- const searchParams = ref<ISearch>({})
- const setSearchParams = (params: any) => {
- searchParams.value = params
- if (params.time) {
- searchParams.value.createTimeStart = params.time[0]
- searchParams.value.createTimeEnd = params.time[1]
- }
- getList()
- }
- const searchSchema = reactive<FormSchema[]>([
- {
- field: 'caseId',
- label: '病例ID',
- component: 'Input',
- componentProps: {
- placeholder: '请输入'
- }
- },
- {
- field: 'userName',
- label: '对象名称',
- component: 'Input',
- componentProps: {
- placeholder: '请输入'
- }
- },
- {
- field: 'time',
- component: 'DatePicker',
- label: '创建时间段',
- componentProps: {
- type: 'datetimerange',
- ...window.dateRangeProps
- }
- }
- ])
- const tableColumns = reactive<TableColumn[]>([
- {
- field: 'index',
- label: '序号',
- type: 'index'
- },
- {
- field: 'caseId',
- label: '病例ID'
- },
- {
- field: 'userName',
- label: '对象名称'
- },
- {
- field: 'taskNo',
- label: '关联事件编号'
- },
- {
- field: 'createTime',
- label: '创建时间'
- },
- {
- field: 'action',
- width: '220px',
- label: '操作',
- slots: {
- default: (data: any) => {
- return (
- <>
- <BaseButton size="small" type="primary" onClick={() => action(data.row, 'detail')}>
- 查看详情
- </BaseButton>
- <BaseButton size="small" type="primary" onClick={() => action(data.row, 'edit')}>
- 编辑
- </BaseButton>
- <BaseButton size="small" type="danger" onClick={() => delData(data.row)}>
- 删除
- </BaseButton>
- </>
- )
- }
- }
- }
- ])
- const actionType = ref('')
- const AddAction = () => {
- actionType.value = 'add'
- push({
- path: '/survey-case-manage/write',
- query: {
- actionType: 'add',
- tabName: props.tabName
- }
- })
- }
- const delData = async (row) => {
- ElMessageBox.confirm('确认删除?', '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(async () => {
- await del({
- caseId: row?.caseId
- })
- getList()
- })
- }
- const action = (row, type: string) => {
- actionType.value = type
- if (type === 'edit') {
- push({
- path: '/survey-case-manage/write',
- query: {
- actionType: 'edit',
- caseId: row?.caseId
- }
- })
- } else {
- push({
- path: '/survey-case-manage/detail',
- query: {
- caseId: row?.caseId
- }
- })
- }
- }
- </script>
- <template>
- <ContentWrap>
- <Search :schema="searchSchema" @search="setSearchParams" @reset="setSearchParams" />
- <div class="mb-10px">
- <BaseButton type="primary" @click="AddAction">新增</BaseButton>
- </div>
- <Table
- v-model:pageSize="pageSize"
- v-model:currentPage="currentPage"
- :columns="tableColumns"
- :data="dataList"
- :loading="loading"
- :pagination="{
- total: total
- }"
- @register="tableRegister"
- />
- </ContentWrap>
- </template>
|