systemService.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. toolbarConfig: {
  83. custom: true,
  84. zoom: true,
  85. slots: {
  86. tools: 'toolbar-extra',
  87. },
  88. },
  89. columnConfig: {
  90. resizable: true,
  91. },
  92. customConfig: {
  93. storage: true,
  94. },
  95. columns: [
  96. { type: 'seq', width: 70, fixed: 'left' },
  97. { field: 'name', title: '服务包名称' },
  98. { field: 'conditioningWrapPatientMatchRule.diagnoseDiseaseNames', title: '专病' },
  99. { field: 'conditioningWrapPatientMatchRule.diagnoseSyndromeNames', title: '证型' },
  100. { field: 'conditioningWrapPatientMatchRule.constitutionGroupNames', title: '体质' },
  101. { field: 'createBy', title: '创建者' },
  102. { field: 'createTime', title: '创建时间' },
  103. {
  104. field: 'action',
  105. title: '操作',
  106. align: 'center',
  107. width: 150,
  108. showOverflow: false,
  109. cellRender: {
  110. name: 'VxeButtonGroup',
  111. props: {
  112. mode: 'text',
  113. },
  114. options: [
  115. { content: '详情', status: 'primary', name: 'seeInstitution' },
  116. { content: '编辑', status: 'primary', name: 'editSystemService' },
  117. { content: '删除', status: 'primary', name: 'deleteSystemService' },
  118. ],
  119. events: {
  120. click({ row, rowIndex }, { name }) {
  121. let method;
  122. if (name === 'editSystemService') {
  123. method = editSystemService;
  124. } else if (name === 'deleteSystemService') {
  125. method = deleteSystemService;
  126. } else if (name === 'seeInstitution') {
  127. method = seeInstitution;
  128. }
  129. method?.(row, rowIndex);
  130. },
  131. },
  132. },
  133. },
  134. ],
  135. data: [],
  136. });
  137. const gridEvents: VxeGridListeners = {};
  138. const { loading, page, pageSize, total, onSuccess, replace, refresh, remove } = usePagination((page, size) => getSystemCpListMethod(page, size, model.value), {
  139. initialData: { data: [], total: 0 },
  140. initialPage: 1,
  141. initialPageSize: 100,
  142. watchingStates: [model],
  143. immediate: true,
  144. });
  145. onSuccess(({ data: { data } }) => {
  146. gridRef.value?.loadData(data);
  147. loading.value = false;
  148. });
  149. onBeforeMount(async () => {
  150. if (model.value?.id) {
  151. model.value = { ...model.value };
  152. }
  153. });
  154. onMounted(() => {
  155. model.value = toRaw(searchFormProps.data);
  156. });
  157. function deleteSystemService(model: SystemCwModel, index: number) {
  158. const { name } = model;
  159. VxeUI.modal.confirm({
  160. title: `删除系统服务`,
  161. content: `确认要删除 ${name} 系统服务吗?`,
  162. showClose: false,
  163. onConfirm() {
  164. deleteSystemCwMethod(model).then(() => {
  165. notification.success({
  166. message: `删除系统服务: ${name}`,
  167. description: '操作成功',
  168. });
  169. refresh(page.value);
  170. });
  171. },
  172. });
  173. }
  174. function seeInstitution(model?: SystemCwModel, index?: number) {
  175. const types = 'system';
  176. VxeUI.modal.open({
  177. id: 'servicePackageDetail-modal',
  178. title: '系统服务',
  179. // height: 700,
  180. // width: 1000,
  181. height: window.innerHeight,
  182. width: window.innerWidth,
  183. escClosable: true,
  184. destroyOnClose: true,
  185. slots: {
  186. default() {
  187. return h(ServicePackageDetail, <any>{
  188. data: { ...model, types },
  189. });
  190. },
  191. },
  192. });
  193. }
  194. function editSystemService(model?: SystemCwModel, index?: number) {
  195. const types = 'system';
  196. VxeUI.modal.open({
  197. id: 'edit-system-service-modal',
  198. title: model?.id ? `修改系统服务` : `新增系统服务`,
  199. // height: 700,
  200. // width: 1200,
  201. height: window.innerHeight,
  202. width: window.innerWidth,
  203. // position: {
  204. // top: Math.min(100, window.innerHeight * 0.1),
  205. // },
  206. escClosable: true,
  207. destroyOnClose: true,
  208. slots: {
  209. default() {
  210. return h(EditSystemService, <any>{
  211. data: { ...model, types },
  212. onSubmitSubmit(data: SystemCwModel) {
  213. refresh(page.value);
  214. VxeUI.modal.close(`edit-system-service-modal`);
  215. },
  216. });
  217. },
  218. },
  219. });
  220. }
  221. </script>
  222. <template>
  223. <div class="page-container flex flex-col">
  224. <header class="flex-none mt-4">
  225. <vxe-form v-bind="searchFormProps" v-on="searchFormEmits"></vxe-form>
  226. </header>
  227. <main class="flex-auto overflow-hidden">
  228. <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading">
  229. <template #toolbar-extra>
  230. <vxe-button style="margin-right: 12px;" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
  231. </template>
  232. </vxe-grid>
  233. </main>
  234. <footer class="flex-none">
  235. <vxe-pager
  236. v-model:current-page="page"
  237. v-model:page-size="pageSize"
  238. :total="total"
  239. :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
  240. />
  241. </footer>
  242. </div>
  243. </template>
  244. <style scoped lang="scss">
  245. .page-container {
  246. padding: 0 24px;
  247. max-height: var(--page-main-container);
  248. }
  249. </style>