| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <script setup lang="ts">
- import { ref, reactive, shallowRef, onMounted } from 'vue';
- import SeeSatisfaction from '@/satisfaction/SeeQuestionnaire.vue';
- import type { SatisfactionSendRecordModel, SatisfactionSendRecordQuery } from '@/model/satisfaction.model';
- // 接口数据
- import { satisfactionSendRecordMethod } from '@/request/api/satisfaction.api';
- import { usePagination } from 'alova/client';
- import dayjs from 'dayjs';
- import { type VxeFormListeners, type VxeFormProps, type VxeGridInstance, type VxeGridListeners, type VxeGridProps, VxeUI } from 'vxe-pc-ui';
- const model = shallowRef<SatisfactionSendRecordQuery>();
- const searchFormProps = reactive<VxeFormProps<SatisfactionSendRecordQuery>>({
- titleWidth: 100,
- titleAlign: 'right',
- titleColon: true,
- data: { name: '' },
- items: [
- {
- field: 'name',
- title: '问卷名称',
- span: 6,
- itemRender: { name: 'VxeInput', props: { placeholder: '请输入满意度问卷名称' } },
- },
- {
- field: 'sendTime',
- title: '发送日期',
- span: 6,
- slots: {
- default: 'createTimes',
- },
- },
- {
- field: 'isFilled',
- title: '填写状态',
- span: 6,
- itemRender: {
- name: 'VxeRadioGroup',
- props: {
- options: [
- { label: '已填写', value: true },
- { label: '未填写', value: false },
- ],
- },
- },
- },
- {
- span: 6,
- itemRender: {
- name: 'VxeButtonGroup',
- options: [
- { name: 'submits', type: 'submit', content: '查询', status: 'primary' },
- { name: 'reset', type: 'reset', content: '重置', status: 'warning' },
- ],
- },
- },
- ],
- });
- const searchFormEmits: VxeFormListeners<SatisfactionSendRecordQuery> = {
- submit({ data }) {
- data.sendTimeStart = sendTimeStart.value ? dayjs(sendTimeStart.value).format('YYYY-MM-DD HH:mm') : '';
- data.sendTimeEnd = sendTimeEnd.value ? dayjs(sendTimeEnd.value).format('YYYY-MM-DD HH:mm') : '';
- onSearch(data);
- },
- // 重置
- reset({ data }) {
- sendTimeStart.value = '';
- sendTimeEnd.value = '';
- onSearch(data);
- },
- };
- function onSearch(data: SatisfactionSendRecordQuery) {
- model.value = { ...data };
- nextTick(() => {
- (searchFormProps.data as any)!.name = data.name;
- (searchFormProps.data as any)!.isFilled = data.isFilled;
- (searchFormProps.data as any)!.sendTimeStart = data.sendTimeStart;
- (searchFormProps.data as any)!.sendTimeEnd = data.sendTimeEnd;
- });
- }
- const gridRef = ref<VxeGridInstance<SatisfactionSendRecordModel>>();
- const gridOptions = reactive<VxeGridProps<SatisfactionSendRecordModel>>({
- id: 'tag-list',
- border: true,
- showOverflow: true,
- height: 'auto',
- autoResize: true,
- syncResize: true,
- scrollY: { enabled: true, gt: 0 },
- rowConfig: {
- isHover: true,
- isCurrent: true,
- },
- toolbarConfig: {
- custom: true,
- zoom: true,
- slots: {
- tools: 'toolbar-extra',
- },
- },
- columnConfig: {
- resizable: true,
- },
- customConfig: {
- storage: true,
- },
- columns: [
- { type: 'seq', width: 70, fixed: 'left' },
- { field: 'name', title: '问卷名称' },
- { field: 'patientName', title: '用户姓名' },
- { field: 'phone', title: '手机号码' },
- { field: 'score', title: '得分' },
- { field: 'sendTime', title: '发送时间' },
- { field: 'submitTime', title: '提交时间' },
- {
- field: 'action',
- title: '操作',
- align: 'center',
- width: 150,
- showOverflow: false,
- cellRender: {
- name: 'VxeButtonGroup',
- props: {
- mode: 'text',
- },
- options: [
- { content: '查看', status: 'primary', name: 'seeDetail' },
- ],
- events: {
- click({ row, rowIndex }: any, { name }: any) {
- let method;
- if (name === 'seeDetail') {
- method = seeDetail;
- }
- method?.(row, rowIndex);
- },
- },
- },
- },
- ],
- data: [],
- });
- const gridEvents: VxeGridListeners = {};
- const {
- loading,
- page,
- pageSize,
- total,
- onSuccess,
- replace,
- refresh,
- remove,
- send: sendRefresh,
- } = usePagination((page, size) => satisfactionSendRecordMethod(page, size, model.value), {
- initialData: { data: [], total: 0 },
- initialPage: 1,
- initialPageSize: 100,
- watchingStates: [model],
- immediate: true,
- });
- onSuccess((res: any) => {
- gridRef.value?.loadData(res?.data?.data ?? []);
- });
- onMounted(() => {
- onSearch(toRaw(searchFormProps.data) as any);
- });
- function seeDetail(model?: SatisfactionSendRecordModel, index?: number) {
- const type=1;
- VxeUI.modal.open({
- title: model?.name,
- fullscreen: true,
- escClosable: true,
- destroyOnClose: true,
- id: `see-satisfaction-modal`,
- remember: true,
- storage: true,
- slots: {
- default() {
- return h(SeeSatisfaction, <any>{
- data:{...model, type},
- });
- },
- },
- });
- }
- // 日期验证
- const sendTimeStart = ref<string>('');
- const sendTimeEnd = ref<string>('');
- // 禁用结束时间的日期(早于开始时间的日期)
- function disabledEndDate(current: any) {
- if (!sendTimeStart.value) return false;
- return current && current < dayjs(sendTimeStart.value);
- }
- defineExpose({
- send: sendRefresh,
- });
- </script>
- <template>
- <div class="page-container flex flex-col">
- <header class="flex-none mt-4">
- <vxe-form v-bind="searchFormProps" v-on="searchFormEmits">
- <template #createTimes>
- <div class="date-range-container">
- <a-date-picker v-model:value="sendTimeStart" placeholder="请选择开始日期" style="flex: 1" :show-time="{ format: 'HH:mm' }" />
- <span class="date-separator">至</span>
- <a-date-picker v-model:value="sendTimeEnd" placeholder="请选择结束日期" style="flex: 1" :disabledDate="disabledEndDate" :show-time="{ format: 'HH:mm' }" />
- </div>
- </template>
- </vxe-form>
- </header>
- <main class="flex-auto overflow-hidden">
- <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading">
- <template #conditioningProgramSupplierNameCell="{ row }">
- {{ row.conditioningProgramSupplierName == '0' ? '启用' : '禁用' }}
- </template>
- <template #toolbar-extra>
- <vxe-button style="margin-right: 12px" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
- </template>
- </vxe-grid>
- </main>
- <footer class="flex-none">
- <vxe-pager
- v-model:current-page="page"
- v-model:page-size="pageSize"
- :total="total"
- :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
- />
- </footer>
- </div>
- </template>
- <style scoped lang="scss">
- .page-container {
- height: 100%;
- display: flex;
- flex-direction: column;
- }
- .date-range-container {
- display: flex;
- align-items: center;
- gap: 12px;
- width: 100%;
- .vxe-input {
- flex: 1;
- min-width: 0;
- }
- .date-separator {
- color: #666;
- font-size: 14px;
- font-weight: 500;
- white-space: nowrap;
- padding: 0 8px;
- }
- }
- </style>
|