edit.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <BasicModal
  3. @ok="handleSubmit"
  4. :destroyOnClose="true"
  5. :maskClosable="false"
  6. v-bind="$attrs"
  7. @register="registerModal"
  8. :title="getTitle"
  9. :width="1002"
  10. showFooter
  11. :defaultFullscreen="true"
  12. >
  13. <div>
  14. <div style="height: 112px">
  15. <Descriptions bordered>
  16. <Descriptions.Item label="年月">
  17. {{ modelRef?.year }}年{{ modelRef?.month }}月
  18. </Descriptions.Item>
  19. <Descriptions.Item label="时间">
  20. {{ formatToDate(modelRef?.startDate) }}~{{ formatToDate(modelRef?.endDate) }}
  21. </Descriptions.Item>
  22. <Descriptions.Item label="总课时">
  23. {{ modelRef?.allClassTime }}
  24. </Descriptions.Item>
  25. <Descriptions.Item label="总课时费(元)">
  26. {{ modelRef?.classTimeAmount }}
  27. </Descriptions.Item>
  28. <Descriptions.Item label="总外聘教师超课时费(元)">
  29. {{ modelRef?.beyondClassTimeAmount }}
  30. </Descriptions.Item>
  31. <Descriptions.Item label="总金额(元)">
  32. {{ modelRef?.totalAmount }}
  33. </Descriptions.Item>
  34. </Descriptions>
  35. </div>
  36. <div style="height: calc(100% - 112px)">
  37. <BasicTable @register="registerTable" :searchInfo="searchInfo">
  38. <template #toolbar>
  39. <a-button type="primary" @click="handelRefrresh" :disabled="modelRef?.status === 3">
  40. 刷新统计
  41. </a-button>
  42. <a-button type="primary" @click="handleWeight">权重设置</a-button>
  43. <a-button type="primary" @click="handleCost">费用设置</a-button>
  44. <a-button type="primary" @click="handleExport">导出</a-button>
  45. </template>
  46. <template #allClassTime="{ text, index }">
  47. <a-button type="link" @click="handelDetail(index)"> {{ text }}</a-button>
  48. </template>
  49. </BasicTable>
  50. </div>
  51. </div>
  52. <FormWeight @register="registerWeightModal" />
  53. <FormCost @register="registerCostModal" />
  54. <FormDetail @register="registerDetailModal" />
  55. </BasicModal>
  56. </template>
  57. <script setup lang="ts">
  58. import { ref, computed, unref, reactive } from 'vue';
  59. import { BasicModal, useModal, useModalInner } from '/@/components/Modal';
  60. import { formDetailSchema } from '../data.config';
  61. import {
  62. getClassTimeStatisticsInfo,
  63. getClassTimeStatisticsRecordExport,
  64. getClassTimeStatisticsRecordList,
  65. postClassTimeStatisticsChangeStatus,
  66. postClassTimeStatisticsRefreshStatistics,
  67. } from '/@/services/apis/ClassTimeStatisticsController';
  68. import { useTable, BasicTable } from '/@/components/Table';
  69. import { Descriptions } from 'ant-design-vue';
  70. import FormWeight from './weight.vue';
  71. import FormCost from './cost.vue';
  72. import { formatToDate } from '/@/utils/dateUtil';
  73. import FormDetail from './detail.vue';
  74. import { downloadByData } from '/@/utils/file/download';
  75. const isUpdate = ref(true);
  76. const modelRef = ref<Recordable>({});
  77. const searchInfo = reactive<Recordable>({});
  78. const emit = defineEmits(['success', 'register']);
  79. const [registerWeightModal, { openModal: openWeightModal }] = useModal();
  80. const [registerCostModal, { openModal: openCostModal }] = useModal();
  81. const [registerDetailModal, { openModal: openDetailModal }] = useModal();
  82. const [registerTable, { reload, getDataSource }] = useTable({
  83. api: getClassTimeStatisticsRecordList,
  84. title: '课时统计表',
  85. rowKey: 'id',
  86. columns: formDetailSchema,
  87. useSearchForm: false,
  88. showTableSetting: true,
  89. bordered: true,
  90. immediate: false,
  91. canResize: true,
  92. pagination: false,
  93. });
  94. const [registerModal, { closeModal, setModalProps }] = useModalInner(async (data) => {
  95. setModalProps({
  96. confirmLoading: true,
  97. okText: '锁定',
  98. cancelText: '关闭',
  99. okButtonProps: { disabled: data.baseData.status === 3 },
  100. });
  101. isUpdate.value = false;
  102. const resData = await getClassTimeStatisticsInfo({ id: data.baseData.id });
  103. modelRef.value = { ...resData };
  104. searchInfo.id = data.baseData.id;
  105. reload();
  106. setModalProps({ confirmLoading: false });
  107. });
  108. const getTitle = computed(() => (!unref(isUpdate) ? '统计明细' : '统计明细'));
  109. const handleSubmit = async () => {
  110. try {
  111. await postClassTimeStatisticsChangeStatus({ id: modelRef.value.id, status: 3 });
  112. closeModal();
  113. emit('success');
  114. } finally {
  115. setModalProps({ confirmLoading: false });
  116. }
  117. };
  118. const handleWeight = () => {
  119. openWeightModal(true, {
  120. isUpdate: true,
  121. baseData: {
  122. classTimeStatisticsId: unref(modelRef).id,
  123. jsonContent: unref(modelRef).weightSetJson,
  124. },
  125. });
  126. };
  127. const handleCost = () => {
  128. openCostModal(true, {
  129. isUpdate: false,
  130. baseData: {
  131. classTimeStatisticsId: unref(modelRef).id,
  132. jsonContent: unref(modelRef).costSetJson,
  133. },
  134. });
  135. };
  136. const handelDetail = (index) => {
  137. const data = getDataSource();
  138. openDetailModal(true, {
  139. isUpdate: false,
  140. baseData: {
  141. data,
  142. index,
  143. },
  144. });
  145. };
  146. const handelRefrresh = async () => {
  147. await postClassTimeStatisticsRefreshStatistics({ id: unref(modelRef).id });
  148. closeModal();
  149. emit('success');
  150. };
  151. const handleExport = async () => {
  152. downloadByData(
  153. (await getClassTimeStatisticsRecordExport({})).data,
  154. `课时统计表${formatToDate(new Date())}.xlsx`,
  155. );
  156. };
  157. </script>
  158. <style scoped lang="less"></style>