ServiceItemsSystem.vue 9.7 KB

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