systemService.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <script setup lang="ts">
  2. import { ref } from 'vue';
  3. import Institution from '@/components/institution.vue';
  4. import EditSystemService from '@/service/EditSystemService.vue';
  5. import type { SystemCwModel, SystemCwQuery } from '@/model/care.model';
  6. import ServicePackageDetail from '@/service/ServicePackageDetail.vue';
  7. // 接口数据
  8. import { getSystemCpListMethod, deleteSystemCwMethod } from '@/request/api/care.api';
  9. import { usePagination, useRequest } from 'alova/client';
  10. import { notification } from 'ant-design-vue';
  11. import { type VxeFormListeners, type VxeFormProps, type VxeCardInstance, type VxeCardListeners, type VxeCardProps, VxeUI } from 'vxe-pc-ui';
  12. const model = shallowRef<SystemCwQuery>();
  13. const searchFormProps = reactive<VxeFormProps<SystemCwQuery>>({
  14. titleWidth: 100,
  15. titleAlign: 'right',
  16. titleColon: true,
  17. data: {},
  18. items: [
  19. {
  20. field: 'name',
  21. title: '服务包名称',
  22. span: 5,
  23. itemRender: { name: 'VxeInput', props: { placeholder: '请输入' } },
  24. },
  25. {
  26. field: 'diagnoseDiseaseName',
  27. title: '专病',
  28. span: 5,
  29. itemRender: { name: 'VxeInput', props: { placeholder: '请输入' } },
  30. },
  31. {
  32. field: 'diagnoseSyndromeName',
  33. title: '证型',
  34. span: 5,
  35. itemRender: { name: 'VxeInput', props: { placeholder: '请输入' } },
  36. },
  37. {
  38. field: 'constitutionGroupName',
  39. title: '体质',
  40. span: 5,
  41. itemRender: { name: 'VxeInput', props: { placeholder: '请输入' } },
  42. },
  43. {
  44. span: 4,
  45. itemRender: {
  46. name: 'VxeButtonGroup',
  47. options: [
  48. { name: 'submits', type: 'submit', content: '查询', status: 'primary' },
  49. { name: 'reset', type: 'reset', content: '清空' },
  50. { name: 'add', content: '新增', status: 'primary' },
  51. ],
  52. events: {
  53. click(slotParams, { name }) {
  54. if (name === 'add') {
  55. // 新增
  56. editSystemService();
  57. }
  58. },
  59. },
  60. },
  61. },
  62. ],
  63. });
  64. const searchFormEmits: VxeFormListeners<SystemCwQuery> = {
  65. submit({ data }) {
  66. model.value = { ...data };
  67. },
  68. // 重置
  69. reset({ data }) {
  70. model.value = { ...data };
  71. },
  72. };
  73. const gridRef = ref<VxeGridInstance<SystemCwModel>>();
  74. const gridOptions = reactive<VxeGridProps<SystemCwModel>>({
  75. id: 'tag-list',
  76. border: true,
  77. showOverflow: true,
  78. height: 'auto',
  79. autoResize: false,
  80. syncResize: true,
  81. scrollY: { enabled: true, gt: 0 },
  82. columnConfig: {
  83. resizable: true,
  84. },
  85. customConfig: {
  86. storage: true,
  87. },
  88. columns: [
  89. { type: 'seq', width: 70, fixed: 'left' },
  90. { field: 'name', title: '服务包名称' },
  91. { field: 'diagnoseDiseaseNames', title: '专病' },
  92. { field: 'diagnoseSyndromeNames', title: '证型' },
  93. { field: 'constitutionGroupNames', title: '体质' },
  94. { field: 'createBy', title: '创建者' },
  95. { field: 'createTime', title: '创建时间' },
  96. {
  97. title: '操作',
  98. align: 'center',
  99. width: 150,
  100. showOverflow: false,
  101. cellRender: {
  102. name: 'VxeButtonGroup',
  103. props: {
  104. mode: 'text',
  105. },
  106. options: [
  107. { content: '详情', status: 'primary', name: 'seeInstitution' },
  108. { content: '编辑', status: 'primary', name: 'editSystemService' },
  109. { content: '删除', status: 'primary', name: 'deleteSystemService' },
  110. ],
  111. events: {
  112. click({ row, rowIndex }, { name }) {
  113. let method;
  114. if (name === 'editSystemService') {
  115. method = editSystemService;
  116. } else if (name === 'deleteSystemService') {
  117. method = deleteSystemService;
  118. } else if (name === 'seeInstitution') {
  119. method = seeInstitution;
  120. }
  121. method?.(row, rowIndex);
  122. },
  123. },
  124. },
  125. },
  126. ],
  127. data: [],
  128. });
  129. const gridEvents: VxeGridListeners = {};
  130. const { loading, page, pageSize, total, onSuccess, replace, refresh, remove } = usePagination((page, size) => getSystemCpListMethod(page, size, model.value), {
  131. initialData: { data: [], total: 0 },
  132. initialPage: 1,
  133. initialPageSize: 100,
  134. watchingStates: [model],
  135. immediate: true,
  136. });
  137. onSuccess(({ data: { data } }) => {
  138. gridRef.value?.loadData(data);
  139. loading.value = false;
  140. });
  141. onBeforeMount(async () => {
  142. if (model.value?.id) {
  143. model.value = { ...model.value };
  144. }
  145. });
  146. onMounted(() => {
  147. model.value = toRaw(searchFormProps.data);
  148. });
  149. function deleteSystemService(model: SystemCwModel, index: number) {
  150. const { name } = model;
  151. VxeUI.modal.confirm({
  152. title: `删除系统服务`,
  153. content: `确认要删除 ${name} 系统服务吗?`,
  154. showClose: false,
  155. onConfirm() {
  156. deleteSystemCwMethod(model).then(() => {
  157. notification.success({
  158. message: `删除系统服务: ${name}`,
  159. description: '操作成功',
  160. });
  161. refresh(page.value);
  162. });
  163. },
  164. });
  165. }
  166. function seeInstitution(model?: SystemCwModel, index?: number) {
  167. const types = 'institution';
  168. VxeUI.modal.open({
  169. id: 'servicePackageDetail-modal',
  170. title: '系统服务',
  171. height: 700,
  172. width: 1000,
  173. escClosable: true,
  174. destroyOnClose: true,
  175. slots: {
  176. default() {
  177. return h(ServicePackageDetail, <any>{
  178. data: { ...model, types },
  179. });
  180. },
  181. },
  182. });
  183. }
  184. function editSystemService(model?: SystemCwModel, index?: number) {
  185. const types = 'system';
  186. VxeUI.modal.open({
  187. id: 'edit-system-service-modal',
  188. title: model?.id ? `修改系统服务` : `新增系统服务`,
  189. height: 700,
  190. width: 1200,
  191. // position: {
  192. // top: Math.min(100, window.innerHeight * 0.1),
  193. // },
  194. escClosable: true,
  195. destroyOnClose: true,
  196. slots: {
  197. default() {
  198. return h(EditSystemService, <any>{
  199. data: { ...model, types },
  200. onSubmitSubmit(data: SystemCwModel) {
  201. refresh(page.value);
  202. VxeUI.modal.close(`edit-system-service-modal`);
  203. },
  204. });
  205. },
  206. },
  207. });
  208. }
  209. </script>
  210. <template>
  211. <div class="page-container flex flex-col">
  212. <header class="flex-none mt-4">
  213. <vxe-form v-bind="searchFormProps" v-on="searchFormEmits"></vxe-form>
  214. </header>
  215. <main class="flex-auto overflow-hidden">
  216. <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading"> </vxe-grid>
  217. </main>
  218. <footer class="flex-none">
  219. <vxe-pager
  220. v-model:current-page="page"
  221. v-model:page-size="pageSize"
  222. :total="total"
  223. :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
  224. />
  225. </footer>
  226. </div>
  227. </template>
  228. <style scoped lang="scss">
  229. .page-container {
  230. padding: 0 24px;
  231. max-height: var(--page-main-container);
  232. }
  233. </style>