ServiceItemsList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. toolbarConfig: {
  117. custom: true,
  118. zoom: true,
  119. slots: {
  120. // buttons: 'handle',
  121. tools: 'toolbar-extra',
  122. },
  123. },
  124. columnConfig: {
  125. resizable: true,
  126. },
  127. customConfig: {
  128. storage: true,
  129. },
  130. columns: [
  131. { field: 'name', title: '项目名称' },
  132. { field: 'conditioningProgramType', title: '方案类型' },
  133. { field: 'isForWrapCell', title: '项目应用', slots: { default: 'isForWrapCell' } },
  134. { field: 'cpFixedPricingRule.unitPrice', title: '单价(元)', slots: { default: 'unitPriceCell' } },
  135. { field: 'cpFixedPricingRule.pricingUnit', title: '计价单位' },
  136. { field: 'cpFixedPricingRule.convertDose', title: '计价说明', slots: { default: 'convertDoseCell' } },
  137. { field: 'conditioningProgramSupplierName', title: '供应商' },
  138. { field: 'institutionName', title: '机构名称' },
  139. {
  140. field: 'action',
  141. title: '操作',
  142. align: 'center',
  143. width: 150,
  144. showOverflow: false,
  145. cellRender: {
  146. name: 'VxeButtonGroup',
  147. props: {
  148. mode: 'text',
  149. },
  150. options: [
  151. { content: '查看', status: 'primary', name: 'seeDetail' },
  152. { content: '编辑', status: 'primary', name: 'editConfirmed' },
  153. { content: '删除', status: 'primary', name: 'deleteConfirmed' },
  154. ],
  155. events: {
  156. click({ row, rowIndex }: any, { name }: any) {
  157. let method;
  158. if (name === 'seeDetail') {
  159. method = seeDetail;
  160. } else if (name === 'editConfirmed') {
  161. method = editConfirmed;
  162. } else if (name === 'deleteConfirmed') {
  163. method = deleteConfirmed;
  164. }
  165. method?.(row, rowIndex);
  166. },
  167. },
  168. },
  169. },
  170. ],
  171. data: [],
  172. });
  173. const gridEvents: VxeGridListeners = {};
  174. const {
  175. loading,
  176. page,
  177. pageSize,
  178. total,
  179. onSuccess,
  180. replace,
  181. refresh,
  182. remove,
  183. send: sendRefresh,
  184. } = usePagination((page, size) => pageConfirmedCpMethod(page, size, model.value), {
  185. initialData: { data: [], total: 0 },
  186. initialPage: 1,
  187. initialPageSize: 100,
  188. watchingStates: [model],
  189. immediate: true,
  190. });
  191. onSuccess((res: any) => {
  192. gridRef.value?.loadData(res?.data?.data ?? []);
  193. });
  194. onMounted(() => {
  195. onSearch(toRaw(searchFormProps.data) as any);
  196. });
  197. function deleteConfirmed(model: SystemItemModel, index: number) {
  198. const { name } = model;
  199. VxeUI.modal.confirm({
  200. title: `删除项目`,
  201. content: `确认要删除 ${name} 项目吗?`,
  202. showClose: false,
  203. onConfirm() {
  204. deleteConfirmedCpMethod(model).then(() => {
  205. notification.success({
  206. message: `删除项目: ${name}`,
  207. description: '操作成功',
  208. });
  209. refresh(page.value);
  210. });
  211. },
  212. });
  213. }
  214. function editConfirmed(model?: SystemItemModel, index?: number) {
  215. const addType = `itemsList`;
  216. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  217. VxeUI.modal.open({
  218. title: model?.conditioningProgramType ?? '项目',
  219. height: 400,
  220. width: 750,
  221. id: `health-consultation-modal`,
  222. remember: true,
  223. storage: true,
  224. slots: {
  225. default() {
  226. return h(HealthEvaluation, <any>{
  227. data: {
  228. ...model,
  229. addType,
  230. },
  231. onSubmit(data: SystemItemModel) {
  232. refresh(page.value);
  233. VxeUI.modal.close(`health-consultation-modal`);
  234. },
  235. });
  236. },
  237. },
  238. });
  239. } else {
  240. VxeUI.modal.open({
  241. title: model?.id ? `编辑项目` : `新增项目`,
  242. height: 800,
  243. width: 850,
  244. // position: {
  245. // top: Math.min(100, window.innerHeight * 0.1),
  246. // },
  247. escClosable: true,
  248. destroyOnClose: true,
  249. id: `add-items-modal`,
  250. remember: true,
  251. storage: true,
  252. slots: {
  253. default() {
  254. return h(AddItems, <any>{
  255. data: { ...model, addType },
  256. onSubmit(data: SystemItemModel) {
  257. refresh(page.value);
  258. VxeUI.modal.close(`add-items-modal`);
  259. },
  260. });
  261. },
  262. },
  263. });
  264. }
  265. }
  266. function seeDetail(model?: SystemItemModel, index?: number) {
  267. if (model?.name === '健康咨询' || model?.name === '健康评估') {
  268. VxeUI.modal.open({
  269. title: model?.conditioningProgramType,
  270. height: 500,
  271. width: 750,
  272. id: `see-health-evaluation-modal`,
  273. remember: true,
  274. storage: true,
  275. slots: {
  276. default() {
  277. return h(seeHealthEvaluation, <any>{
  278. data: model,
  279. });
  280. },
  281. },
  282. });
  283. } else {
  284. const addType = 'itemsList';
  285. VxeUI.modal.open({
  286. title: '查看',
  287. height: 800,
  288. width: 950,
  289. escClosable: true,
  290. destroyOnClose: true,
  291. id: `service-detail-modal`,
  292. remember: true,
  293. storage: true,
  294. slots: {
  295. default() {
  296. return h(ServiceDetail, <any>{
  297. data: {
  298. ...model,
  299. addType,
  300. },
  301. onSubmit(data: SystemItemModel) {
  302. refresh(page.value);
  303. VxeUI.modal.close(`service-detail-modal`);
  304. },
  305. });
  306. },
  307. },
  308. });
  309. }
  310. }
  311. defineExpose({
  312. send: sendRefresh,
  313. });
  314. </script>
  315. <template>
  316. <div class="page-container flex flex-col">
  317. <header class="flex-none mt-4">
  318. <vxe-form v-bind="searchFormProps" v-on="searchFormEmits"></vxe-form>
  319. </header>
  320. <main class="flex-auto overflow-hidden">
  321. <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading">
  322. <template #isForWrapCell="{ row }">
  323. {{
  324. (() => {
  325. const isWrap = row.isForWrap === 'Y';
  326. const isInfer = row.isForInfer === 'Y';
  327. if (isWrap && isInfer) {
  328. return '服务包项目;调理方案项目';
  329. } else if (isWrap) {
  330. return '服务包项目';
  331. } else if (isInfer) {
  332. return '调理方案项目';
  333. } else {
  334. return '';
  335. }
  336. })()
  337. }}
  338. </template>
  339. <template #unitPriceCell="{ row }">
  340. {{ row.pricingType === '1' ? `` : row.cpFixedPricingRule?.unitPrice }}
  341. </template>
  342. <template #convertDoseCell="{ row }">
  343. {{
  344. row.pricingType === '1'
  345. ? `当"穴位/经络/部位 ≤${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  346. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[0]?.price || 0 : 0}元,
  347. 当"穴位/经络/部位 >${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  348. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.price || 0 : 0}元`
  349. : ''
  350. }}
  351. </template>
  352. <template #toolbar-extra>
  353. <vxe-button style="margin-right: 12px" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
  354. </template>
  355. </vxe-grid>
  356. </main>
  357. <footer class="flex-none">
  358. <vxe-pager
  359. v-model:current-page="page"
  360. v-model:page-size="pageSize"
  361. :total="total"
  362. :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
  363. />
  364. </footer>
  365. </div>
  366. </template>
  367. <style scoped lang="scss">
  368. .page-container {
  369. height: 100%;
  370. display: flex;
  371. flex-direction: column;
  372. }
  373. </style>