ServiceItemsList.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <script setup lang="ts">
  2. import type { SystemItemModel, SystemIteQuery } from '@/model/care.model';
  3. import ServiceDetail from './ServiceDetail.vue';
  4. import AddItems from './addItems.vue';
  5. import seeHealthEvaluation from './seeHealthEvaluation.vue';
  6. import HealthEvaluation from './HealthEvaluation.vue';
  7. // 接口数据
  8. import { pageConfirmedCpMethod, deleteConfirmedCpMethod } 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 VxeGridInstance, type VxeGridListeners, type VxeGridProps, VxeUI } from 'vxe-pc-ui';
  12. const model = shallowRef<SystemIteQuery>();
  13. const searchFormProps = reactive<VxeFormProps<SystemIteQuery>>({
  14. titleWidth: 100,
  15. titleAlign: 'right',
  16. titleColon: true,
  17. data: {},
  18. items: [
  19. {
  20. field: 'institutionName',
  21. title: '机构名称',
  22. span: 6,
  23. itemRender: { name: 'VxeInput', props: { placeholder: '请输入' } },
  24. },
  25. {
  26. field: 'name',
  27. title: '项目名称',
  28. span: 6,
  29. itemRender: { name: 'VxeInput', props: { placeholder: '请输入' } },
  30. },
  31. {
  32. field: 'conditioningProgramType',
  33. title: '方案类型',
  34. span: 6,
  35. itemRender: { name: 'VxeInput', props: { placeholder: '请输入' } },
  36. },
  37. {
  38. span: 6,
  39. itemRender: {
  40. name: 'VxeButtonGroup',
  41. options: [
  42. { name: 'submits', type: 'submit', content: '查询', status: 'primary' },
  43. { name: 'reset', type: 'reset', content: '清空', status: 'warning' },
  44. { name: 'add', content: '新增', status: 'primary' },
  45. ],
  46. events: {
  47. click(slotParams, { name }) {
  48. if (name === 'add') {
  49. // 新增
  50. editConfirmed();
  51. }
  52. },
  53. },
  54. },
  55. },
  56. ],
  57. });
  58. const searchFormEmits: VxeFormListeners<SystemIteQuery> = {
  59. // 查询随访计划
  60. submit({ data }) {
  61. model.value = { ...data };
  62. },
  63. // 重置
  64. reset({ data }) {
  65. model.value = { ...data };
  66. },
  67. };
  68. const gridRef = ref<VxeGridInstance<SystemItemModel>>();
  69. const gridOptions = reactive<VxeGridProps<SystemItemModel>>({
  70. id: 'tag-list',
  71. border: true,
  72. showOverflow: true,
  73. height: 'auto',
  74. autoResize: true,
  75. syncResize: true,
  76. scrollY: { enabled: true, gt: 0 },
  77. toolbarConfig: {
  78. custom: true,
  79. zoom: true,
  80. slots: {
  81. // buttons: 'handle',
  82. tools: 'toolbar-extra',
  83. },
  84. },
  85. columnConfig: {
  86. resizable: true,
  87. },
  88. customConfig: {
  89. storage: true,
  90. },
  91. columns: [
  92. { field: 'name', title: '项目名称' },
  93. { field: 'conditioningProgramType', title: '方案类型' },
  94. { field: 'cpFixedPricingRule.unitPrice', title: '单价(元)', slots: { default: 'unitPriceCell' } },
  95. { field: 'cpFixedPricingRule.pricingUnit', title: '计价单位' },
  96. { field: 'cpFixedPricingRule.convertDose', title: '计价说明', slots: { default: 'convertDoseCell' } },
  97. { field: 'conditioningProgramSupplierName', title: '供应商' },
  98. { field: 'institutionName', title: '机构名称' },
  99. {
  100. field: 'action',
  101. title: '操作',
  102. align: 'center',
  103. width: 150,
  104. showOverflow: false,
  105. cellRender: {
  106. name: 'VxeButtonGroup',
  107. props: {
  108. mode: 'text',
  109. },
  110. options: [
  111. { content: '查看', status: 'primary', name: 'seeDetail' },
  112. { content: '编辑', status: 'primary', name: 'editConfirmed' },
  113. { content: '删除', status: 'primary', name: 'deleteConfirmed' },
  114. ],
  115. events: {
  116. click({ row, rowIndex }, { name }) {
  117. let method;
  118. if (name === 'seeDetail') {
  119. method = seeDetail;
  120. } else if (name === 'editConfirmed') {
  121. method = editConfirmed;
  122. } else if (name === 'deleteConfirmed') {
  123. method = deleteConfirmed;
  124. }
  125. method?.(row, rowIndex);
  126. },
  127. },
  128. },
  129. },
  130. ],
  131. data: [],
  132. });
  133. const gridEvents: VxeGridListeners = {};
  134. const {
  135. loading,
  136. page,
  137. pageSize,
  138. total,
  139. onSuccess,
  140. replace,
  141. refresh,
  142. remove,
  143. send: sendRefresh,
  144. } = usePagination((page, size) => pageConfirmedCpMethod(page, size, model.value), {
  145. initialData: { data: [], total: 0 },
  146. initialPage: 1,
  147. initialPageSize: 100,
  148. watchingStates: [model],
  149. immediate: true,
  150. });
  151. onSuccess(({ data: { data } }) => {
  152. gridRef.value?.loadData(data);
  153. });
  154. onMounted(() => {
  155. model.value = toRaw(searchFormProps.data);
  156. });
  157. function deleteConfirmed(model: SystemItemModel, index: number) {
  158. const { name } = model;
  159. VxeUI.modal.confirm({
  160. title: `删除项目`,
  161. content: `确认要删除 ${name} 项目吗?`,
  162. showClose: false,
  163. onConfirm() {
  164. deleteConfirmedCpMethod(model).then(() => {
  165. notification.success({
  166. message: `删除项目: ${name}`,
  167. description: '操作成功',
  168. });
  169. refresh(page.value);
  170. });
  171. },
  172. });
  173. }
  174. function editConfirmed(model?: SystemItemModel, index?: number) {
  175. const addType = `itemsList`;
  176. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  177. VxeUI.modal.open({
  178. title: model?.conditioningProgramType ?? '项目',
  179. height: 400,
  180. width: 750,
  181. id: `health-consultation-modal`,
  182. remember: true,
  183. storage: true,
  184. slots: {
  185. default() {
  186. return h(HealthEvaluation, <any>{
  187. data: {
  188. ...model,
  189. addType,
  190. },
  191. onSubmit(data: SystemItemModel) {
  192. refresh(page.value);
  193. VxeUI.modal.close(`health-consultation-modal`);
  194. },
  195. });
  196. },
  197. },
  198. });
  199. } else {
  200. VxeUI.modal.open({
  201. title: model?.id ? `编辑项目` : `新增项目`,
  202. height: 800,
  203. width: 850,
  204. // position: {
  205. // top: Math.min(100, window.innerHeight * 0.1),
  206. // },
  207. escClosable: true,
  208. destroyOnClose: true,
  209. id: `add-items-modal`,
  210. remember: true,
  211. storage: true,
  212. slots: {
  213. default() {
  214. return h(AddItems, <any>{
  215. data: { ...model, addType },
  216. onSubmit(data: SystemItemModel) {
  217. refresh(page.value);
  218. VxeUI.modal.close(`add-items-modal`);
  219. },
  220. });
  221. },
  222. },
  223. });
  224. }
  225. }
  226. function seeDetail(model?: SystemItemModel, index?: number) {
  227. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  228. VxeUI.modal.open({
  229. title: model?.conditioningProgramType,
  230. height: 500,
  231. width: 750,
  232. id: `see-health-evaluation-modal`,
  233. remember: true,
  234. storage: true,
  235. slots: {
  236. default() {
  237. return h(seeHealthEvaluation, <any>{
  238. data: model,
  239. });
  240. },
  241. },
  242. });
  243. } else {
  244. VxeUI.modal.open({
  245. title: '查看',
  246. height: 800,
  247. width: 950,
  248. escClosable: true,
  249. destroyOnClose: true,
  250. id: `service-detail-modal`,
  251. remember: true,
  252. storage: true,
  253. slots: {
  254. default() {
  255. return h(ServiceDetail, <any>{
  256. data: model,
  257. onSubmit(data: SystemItemModel) {
  258. refresh(page.value);
  259. VxeUI.modal.close(`service-detail-modal`);
  260. },
  261. });
  262. },
  263. },
  264. });
  265. }
  266. }
  267. defineExpose({
  268. send: sendRefresh,
  269. });
  270. </script>
  271. <template>
  272. <div class="page-container flex flex-col">
  273. <header class="flex-none mt-4">
  274. <vxe-form v-bind="searchFormProps" v-on="searchFormEmits"></vxe-form>
  275. </header>
  276. <main class="flex-auto overflow-hidden">
  277. <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading">
  278. <template #unitPriceCell="{ row }">
  279. {{ row.pricingType === '1' ? `` : row.cpFixedPricingRule?.unitPrice }}
  280. </template>
  281. <template #convertDoseCell="{ row }">
  282. {{
  283. row.pricingType === '1'
  284. ? `当"穴位/经络/部位 ≤${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  285. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[0]?.price || 0 : 0}元,
  286. 当"穴位/经络/部位 >${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  287. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.price || 0 : 0}元`
  288. : ''
  289. }}
  290. </template>
  291. <template #toolbar-extra>
  292. <vxe-button style="margin-right: 12px" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
  293. </template>
  294. </vxe-grid>
  295. </main>
  296. <footer class="flex-none">
  297. <vxe-pager
  298. v-model:current-page="page"
  299. v-model:page-size="pageSize"
  300. :total="total"
  301. :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
  302. />
  303. </footer>
  304. </div>
  305. </template>
  306. <style scoped lang="scss">
  307. .page-container {
  308. height: 100%;
  309. display: flex;
  310. flex-direction: column;
  311. }
  312. </style>