ServiceItemsList.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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: 'conditioningProgramSupplierId', title: '供应商' },
  98. { field: 'institutionName', title: '机构名称' },
  99. {
  100. title: '操作',
  101. align: 'center',
  102. width: 150,
  103. showOverflow: false,
  104. cellRender: {
  105. name: 'VxeButtonGroup',
  106. props: {
  107. mode: 'text',
  108. },
  109. options: [
  110. { content: '查看', status: 'primary', name: 'seeDetail' },
  111. { content: '编辑', status: 'primary', name: 'editConfirmed' },
  112. { content: '删除', status: 'primary', name: 'deleteConfirmed' },
  113. ],
  114. events: {
  115. click({ row, rowIndex }, { name }) {
  116. let method;
  117. if (name === 'seeDetail') {
  118. method = seeDetail;
  119. } else if (name === 'editConfirmed') {
  120. method = editConfirmed;
  121. } else if (name === 'deleteConfirmed') {
  122. method = deleteConfirmed;
  123. }
  124. method?.(row, rowIndex);
  125. },
  126. },
  127. },
  128. },
  129. ],
  130. data: [],
  131. });
  132. const gridEvents: VxeGridListeners = {};
  133. const {
  134. loading,
  135. page,
  136. pageSize,
  137. total,
  138. onSuccess,
  139. replace,
  140. refresh,
  141. remove,
  142. send: sendRefresh,
  143. } = usePagination((page, size) => pageConfirmedCpMethod(page, size, model.value), {
  144. initialData: { data: [], total: 0 },
  145. initialPage: 1,
  146. initialPageSize: 100,
  147. watchingStates: [model],
  148. immediate: true,
  149. });
  150. onSuccess(({ data: { data } }) => {
  151. gridRef.value?.loadData(data);
  152. });
  153. onMounted(() => {
  154. model.value = toRaw(searchFormProps.data);
  155. });
  156. function deleteConfirmed(model: SystemItemModel, index: number) {
  157. const { name } = model;
  158. VxeUI.modal.confirm({
  159. title: `删除项目`,
  160. content: `确认要删除 ${name} 项目吗?`,
  161. showClose: false,
  162. onConfirm() {
  163. deleteConfirmedCpMethod(model).then(() => {
  164. notification.success({
  165. message: `删除项目: ${name}`,
  166. description: '操作成功',
  167. });
  168. refresh(page.value);
  169. });
  170. },
  171. });
  172. }
  173. function editConfirmed(model?: SystemItemModel, index?: number) {
  174. const addType = `itemsList`;
  175. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  176. VxeUI.modal.open({
  177. title: model?.conditioningProgramType ?? '项目',
  178. height: 400,
  179. width: 750,
  180. id: `health-consultation-modal`,
  181. remember: true,
  182. storage: true,
  183. slots: {
  184. default() {
  185. return h(HealthEvaluation, <any>{
  186. data: {
  187. ...model,
  188. addType,
  189. },
  190. });
  191. },
  192. },
  193. });
  194. } else {
  195. VxeUI.modal.open({
  196. title: model?.id ? `编辑项目` : `新增项目`,
  197. height: 800,
  198. width: 850,
  199. position: {
  200. top: Math.min(100, window.innerHeight * 0.1),
  201. },
  202. escClosable: true,
  203. destroyOnClose: true,
  204. id: `add-items-modal`,
  205. remember: true,
  206. storage: true,
  207. slots: {
  208. default() {
  209. return h(AddItems, <any>{
  210. data: { ...model, addType },
  211. onSubmit(data: SystemItemModel) {
  212. refresh(page.value);
  213. VxeUI.modal.close(`add-items-modal`);
  214. },
  215. });
  216. },
  217. },
  218. });
  219. }
  220. }
  221. function seeDetail(model?: SystemItemModel, index?: number) {
  222. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  223. VxeUI.modal.open({
  224. title: model?.conditioningProgramType,
  225. height: 500,
  226. width: 750,
  227. id: `see-health-evaluation-modal`,
  228. remember: true,
  229. storage: true,
  230. slots: {
  231. default() {
  232. return h(seeHealthEvaluation, <any>{
  233. data: model,
  234. });
  235. },
  236. },
  237. });
  238. } else {
  239. VxeUI.modal.open({
  240. title: '查看',
  241. height: 600,
  242. width: 950,
  243. position: {
  244. top: Math.min(100, window.innerHeight * 0.1),
  245. },
  246. escClosable: true,
  247. destroyOnClose: true,
  248. id: `service-detail-modal`,
  249. remember: true,
  250. storage: true,
  251. slots: {
  252. default() {
  253. return h(ServiceDetail, <any>{
  254. data: model,
  255. onSubmit(data: SystemItemModel) {
  256. refresh(page.value);
  257. VxeUI.modal.close(`service-detail-modal`);
  258. },
  259. });
  260. },
  261. },
  262. });
  263. }
  264. }
  265. defineExpose({
  266. send: sendRefresh,
  267. });
  268. </script>
  269. <template>
  270. <div class="page-container flex flex-col">
  271. <header class="flex-none mt-4">
  272. <vxe-form v-bind="searchFormProps" v-on="searchFormEmits"></vxe-form>
  273. </header>
  274. <main class="flex-auto overflow-hidden">
  275. <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading">
  276. <template #unitPriceCell="{ row }">
  277. {{ row.pricingType === '1' ? `` : row.cpFixedPricingRule?.unitPrice }}
  278. </template>
  279. <template #convertDoseCell="{ row }">
  280. {{
  281. row.pricingType === '1'
  282. ? `当"穴位/经络/部位 ≤${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  283. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[0]?.price || 0 : 0}元,
  284. 当"穴位/经络/部位 >${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  285. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.price || 0 : 0}元`
  286. : ''
  287. }}
  288. </template>
  289. <template #toolbar-extra>
  290. <vxe-button style="margin-right: 12px" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
  291. </template>
  292. </vxe-grid>
  293. </main>
  294. <footer class="flex-none">
  295. <vxe-pager
  296. v-model:current-page="page"
  297. v-model:page-size="pageSize"
  298. :total="total"
  299. :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
  300. />
  301. </footer>
  302. </div>
  303. </template>
  304. <style scoped lang="scss">
  305. .page-container {
  306. height: 100%;
  307. display: flex;
  308. flex-direction: column;
  309. }
  310. </style>