ServiceItemsList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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: { types: ['1'] as any, status: '0' as any },
  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: any, { name }: any) {
  48. if (name === 'add') {
  49. // 新增
  50. editConfirmed();
  51. }
  52. },
  53. },
  54. },
  55. },
  56. { field: 'types', title: '项目应用', span: 6, itemRender: {
  57. name: 'VxeCheckboxGroup',
  58. options: [
  59. { label: '服务包项目', value: '1' },
  60. { label: '调理方案项目', value: '2' },
  61. ],
  62. events: {
  63. change(value: { data: SystemIteQuery }) { onSearch(value.data) },
  64. },
  65. }
  66. },
  67. {
  68. field: 'status',
  69. title: '启用状态',
  70. span: 6,
  71. itemRender: {
  72. name: 'VxeRadioGroup',
  73. options: [
  74. { label: '启用', value: '0' },
  75. { label: '停用', value: '1' },
  76. ],
  77. props: {
  78. strict: false,
  79. },
  80. },
  81. },
  82. ],
  83. });
  84. const searchFormEmits: VxeFormListeners<SystemIteQuery> = {
  85. // 查询随访计划
  86. submit({ data }) {
  87. onSearch(data);
  88. },
  89. // 重置
  90. reset({ data }) {
  91. onSearch(data);
  92. },
  93. };
  94. function onSearch(data: SystemIteQuery) {
  95. const types: string[] = (data as any).types?.length ? (data as any).types : ['1'];
  96. const status: string = (data as any).status ?? '0';
  97. const isForWrap: SystemIteQuery['isForWrap'] = types.includes('1') ? 'Y' : null;
  98. const isForInfer: SystemIteQuery['isForInfer'] = types.includes('2') ? 'Y' : null;
  99. model.value = { ...data, types: [...types] as any, status: status as any, isForWrap, isForInfer };
  100. nextTick(() => {
  101. (searchFormProps.data as any)!.types = [...types];
  102. (searchFormProps.data as any)!.status = status;
  103. (searchFormProps.data as any)!.isForInfer = isForInfer;
  104. (searchFormProps.data as any)!.isForWrap = isForWrap;
  105. })
  106. }
  107. const gridRef = ref<VxeGridInstance<SystemItemModel>>();
  108. const gridOptions = reactive<VxeGridProps<SystemItemModel>>({
  109. id: 'tag-list',
  110. border: true,
  111. showOverflow: true,
  112. height: 'auto',
  113. autoResize: true,
  114. syncResize: true,
  115. scrollY: { enabled: true, gt: 0 },
  116. rowConfig: {
  117. isHover: true,
  118. isCurrent: true,
  119. },
  120. toolbarConfig: {
  121. custom: true,
  122. zoom: true,
  123. slots: {
  124. // buttons: 'handle',
  125. tools: 'toolbar-extra',
  126. },
  127. },
  128. columnConfig: {
  129. resizable: true,
  130. },
  131. customConfig: {
  132. storage: true,
  133. },
  134. columns: [
  135. { type: 'seq', title: '序号', width: 80 },
  136. { field: 'name', title: '项目名称' },
  137. { field: 'conditioningProgramType', title: '方案类型' },
  138. { field: 'isForWrapCell', title: '项目应用', slots: { default: 'isForWrapCell' } },
  139. { field: 'cpFixedPricingRule.unitPrice', title: '单价(元)', slots: { default: 'unitPriceCell' } },
  140. { field: 'cpFixedPricingRule.pricingUnit', title: '计价单位', slots: { default: 'pricingUnitCell' } },
  141. { field: 'cpFixedPricingRule.convertDose', title: '计价说明', slots: { default: 'convertDoseCell' } },
  142. { field: 'conditioningProgramSupplierName', title: '供应商' },
  143. { field: 'institutionName', title: '机构名称' },
  144. {
  145. field: 'action',
  146. title: '操作',
  147. align: 'center',
  148. width: 150,
  149. showOverflow: false,
  150. cellRender: {
  151. name: 'VxeButtonGroup',
  152. props: {
  153. mode: 'text',
  154. },
  155. options: [
  156. { content: '查看', status: 'primary', name: 'seeDetail' },
  157. { content: '编辑', status: 'primary', name: 'editConfirmed' },
  158. { content: '删除', status: 'primary', name: 'deleteConfirmed' },
  159. ],
  160. events: {
  161. click({ row, rowIndex }: any, { name }: any) {
  162. let method;
  163. if (name === 'seeDetail') {
  164. method = seeDetail;
  165. } else if (name === 'editConfirmed') {
  166. method = editConfirmed;
  167. } else if (name === 'deleteConfirmed') {
  168. method = deleteConfirmed;
  169. }
  170. method?.(row, rowIndex);
  171. },
  172. },
  173. },
  174. },
  175. ],
  176. data: [],
  177. });
  178. const gridEvents: VxeGridListeners = {};
  179. const {
  180. loading,
  181. page,
  182. pageSize,
  183. total,
  184. onSuccess,
  185. replace,
  186. refresh,
  187. remove,
  188. send: sendRefresh,
  189. } = usePagination((page, size) => pageConfirmedCpMethod(page, size, model.value), {
  190. initialData: { data: [], total: 0 },
  191. initialPage: 1,
  192. initialPageSize: 100,
  193. watchingStates: [model],
  194. immediate: true,
  195. });
  196. onSuccess((res: any) => {
  197. gridRef.value?.loadData(res?.data?.data ?? []);
  198. });
  199. onMounted(() => {
  200. onSearch(toRaw(searchFormProps.data) as any);
  201. });
  202. function deleteConfirmed(model: SystemItemModel, index: number) {
  203. const { name } = model;
  204. VxeUI.modal.confirm({
  205. title: `删除项目`,
  206. content: `确认要删除 ${name} 项目吗?`,
  207. showClose: false,
  208. onConfirm() {
  209. deleteConfirmedCpMethod(model).then(() => {
  210. notification.success({
  211. message: `删除项目: ${name}`,
  212. description: '操作成功',
  213. });
  214. refresh(page.value);
  215. });
  216. },
  217. });
  218. }
  219. function editConfirmed(model?: SystemItemModel, index?: number) {
  220. const addType = `itemsList`;
  221. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  222. VxeUI.modal.open({
  223. title: model?.conditioningProgramType ?? '项目',
  224. height: 400,
  225. width: 750,
  226. id: `health-consultation-modal`,
  227. remember: true,
  228. storage: true,
  229. slots: {
  230. default() {
  231. return h(HealthEvaluation, <any>{
  232. data: {
  233. ...model,
  234. addType,
  235. },
  236. onSubmit(data: SystemItemModel) {
  237. refresh(page.value);
  238. VxeUI.modal.close(`health-consultation-modal`);
  239. },
  240. });
  241. },
  242. },
  243. });
  244. } else {
  245. VxeUI.modal.open({
  246. title: model?.id ? `编辑项目` : `新增项目`,
  247. height: 1000,
  248. width: 900,
  249. escClosable: true,
  250. destroyOnClose: true,
  251. id: `add-items-modal`,
  252. remember: true,
  253. storage: true,
  254. slots: {
  255. default() {
  256. return h(AddItems, <any>{
  257. data: { ...model, addType },
  258. onSubmit(data: SystemItemModel) {
  259. refresh(page.value);
  260. VxeUI.modal.close(`add-items-modal`);
  261. },
  262. });
  263. },
  264. },
  265. });
  266. }
  267. }
  268. function seeDetail(model?: SystemItemModel, index?: number) {
  269. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  270. VxeUI.modal.open({
  271. title: model?.conditioningProgramType,
  272. height: 500,
  273. width: 750,
  274. id: `see-health-evaluation-modal`,
  275. remember: true,
  276. storage: true,
  277. slots: {
  278. default() {
  279. return h(seeHealthEvaluation, <any>{
  280. data: model,
  281. });
  282. },
  283. },
  284. });
  285. } else {
  286. const addType = 'itemsList';
  287. VxeUI.modal.open({
  288. title: '查看',
  289. height: 900,
  290. width: 1000,
  291. escClosable: true,
  292. destroyOnClose: true,
  293. id: `service-detail-modal`,
  294. remember: true,
  295. storage: true,
  296. slots: {
  297. default() {
  298. return h(ServiceDetail, <any>{
  299. data: {
  300. ...model,
  301. addType,
  302. },
  303. onSubmit(data: SystemItemModel) {
  304. refresh(page.value);
  305. VxeUI.modal.close(`service-detail-modal`);
  306. },
  307. });
  308. },
  309. },
  310. });
  311. }
  312. }
  313. defineExpose({
  314. send: sendRefresh,
  315. });
  316. </script>
  317. <template>
  318. <div class="page-container flex flex-col">
  319. <header class="flex-none mt-4">
  320. <vxe-form v-bind="searchFormProps" v-on="searchFormEmits"></vxe-form>
  321. </header>
  322. <main class="flex-auto overflow-hidden">
  323. <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading">
  324. <template #isForWrapCell="{ row }">
  325. {{
  326. (() => {
  327. const isWrap = row.isForWrap === 'Y';
  328. const isInfer = row.isForInfer === 'Y';
  329. if (isWrap && isInfer) {
  330. return '服务包项目;调理方案项目';
  331. } else if (isWrap) {
  332. return '服务包项目';
  333. } else if (isInfer) {
  334. return '调理方案项目';
  335. } else {
  336. return '';
  337. }
  338. })()
  339. }}
  340. </template>
  341. <template #pricingUnitCell="{ row }">
  342. {{ row.cpFixedPricingRule?.pricingUnit ? row.cpFixedPricingRule?.pricingUnit : '次' }}
  343. </template>
  344. <template #unitPriceCell="{ row }">
  345. {{ row.pricingType === '1' ? `` : row.cpFixedPricingRule?.unitPrice }}
  346. </template>
  347. <template #convertDoseCell="{ row }">
  348. {{
  349. row.pricingType === '1'
  350. ? `当"穴位/经络/部位 ≤${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  351. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[0]?.price || 0 : 0}元,
  352. 当"穴位/经络/部位 >${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  353. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.price || 0 : 0}元`
  354. : ''
  355. }}
  356. </template>
  357. <template #toolbar-extra>
  358. <vxe-button style="margin-right: 12px" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
  359. </template>
  360. </vxe-grid>
  361. </main>
  362. <footer class="flex-none">
  363. <vxe-pager
  364. v-model:current-page="page"
  365. v-model:page-size="pageSize"
  366. :total="total"
  367. :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
  368. />
  369. </footer>
  370. </div>
  371. </template>
  372. <style scoped lang="scss">
  373. .page-container {
  374. height: 100%;
  375. display: flex;
  376. flex-direction: column;
  377. }
  378. </style>