ServiceItemsSystem.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. field: 'action',
  129. title: '操作',
  130. align: 'center',
  131. width: 160,
  132. showOverflow: false,
  133. slots: { default: 'actionSlot' },
  134. },
  135. ],
  136. data: [],
  137. });
  138. const gridEvents: VxeGridListeners = {};
  139. const { loading, page, pageSize, total, onSuccess, replace, refresh, remove,send:sendRefresh } = usePagination((page, size) => pageSystemCpMethod(page, size, model.value), {
  140. initialData: { data: [], total: 0 },
  141. initialPage: 1,
  142. initialPageSize: 100,
  143. watchingStates: [model],
  144. immediate: true,
  145. });
  146. onSuccess(({ data: { data } }) => {
  147. gridRef.value?.loadData(data);
  148. });
  149. // const send = () => {
  150. // sendRefresh();
  151. // }
  152. onMounted(() => {
  153. model.value = toRaw(searchFormProps.data);
  154. });
  155. function deleteItems(model: SystemItemModel, index: number) {
  156. const { name } = model;
  157. VxeUI.modal.confirm({
  158. title: `删除项目`,
  159. content: `确认要删除 ${name} 项目吗?`,
  160. showClose: false,
  161. onConfirm() {
  162. deleteSystemCpMethod(model).then(() => {
  163. notification.success({
  164. message: `删除项目: ${name}`,
  165. description: '操作成功',
  166. });
  167. refresh(page.value);
  168. });
  169. },
  170. });
  171. }
  172. function seeItems(model?: SystemItemModel, index?: number) {
  173. console.log(model, 'model');
  174. if (model?.isErasable === 'N') {
  175. // 健康咨询 健康评估 查看
  176. VxeUI.modal.open({
  177. title: model?.conditioningProgramType,
  178. height: 500,
  179. width: 750,
  180. id: `see-health-evaluation-modal`,
  181. remember: true,
  182. storage: true,
  183. slots: {
  184. default() {
  185. return h(seeHealthEvaluation, <any>{
  186. data: model,
  187. });
  188. },
  189. },
  190. });
  191. } else {
  192. VxeUI.modal.open({
  193. title: '查看',
  194. height: 600,
  195. width: 850,
  196. position: {
  197. top: Math.min(100, window.innerHeight * 0.1),
  198. },
  199. escClosable: true,
  200. destroyOnClose: true,
  201. id: `service-detail-modal`,
  202. remember: true,
  203. storage: true,
  204. slots: {
  205. default() {
  206. return h(ServiceDetail, <any>{
  207. data: model,
  208. onSubmit(data: SystemItemModel) {
  209. refresh(page.value);
  210. VxeUI.modal.close(`service-detail-modal`);
  211. },
  212. });
  213. },
  214. },
  215. });
  216. }
  217. }
  218. function editItems(model?: SystemItemModel, index?: number) {
  219. console.log(model,"编辑项目")
  220. const addType = 'system';
  221. console.log(model, 'model');
  222. if (model?.isErasable === 'N') {
  223. console.log(model, '健康咨询和健康评估');
  224. // 健康咨询 健康评估 x显示
  225. VxeUI.modal.open({
  226. title: model?.conditioningProgramType ?? '项目',
  227. height: 400,
  228. width: 750,
  229. id: `health-consultation-modal`,
  230. remember: true,
  231. storage: true,
  232. slots: {
  233. default() {
  234. return h(HealthEvaluation, <any>{
  235. data: {
  236. ...model,
  237. addType,
  238. },
  239. onSubmit(data: SystemItemModel) {
  240. console.log(data, 'onChange');
  241. refresh(page.value);
  242. VxeUI.modal.close(`health-consultation-modal`);
  243. },
  244. });
  245. },
  246. },
  247. });
  248. } else {
  249. VxeUI.modal.open({
  250. title: model?.id ? `编辑项目` : `新增项目`,
  251. height: 700,
  252. width: 850,
  253. position: {
  254. top: Math.min(100, window.innerHeight * 0.1),
  255. },
  256. escClosable: true,
  257. destroyOnClose: true,
  258. id: `add-items-modal`,
  259. remember: true,
  260. storage: true,
  261. slots: {
  262. default() {
  263. return h(AddItems, <any>{
  264. data: {
  265. ...model,
  266. addType,
  267. },
  268. onSubmit(data: SystemItemModel) {
  269. refresh(page.value);
  270. VxeUI.modal.close(`add-items-modal`);
  271. },
  272. });
  273. },
  274. },
  275. });
  276. }
  277. }
  278. const selectedRows = ref<any[]>([]);
  279. const onCheckboxChange = (params: any) => {
  280. const { records } = params; // 当前选中的行数据
  281. selectedRows.value = records;
  282. };
  283. const onCheckboxAll = (params: any) => {
  284. const { records } = params; // 全选时选中的行数据
  285. selectedRows.value = records;
  286. };
  287. defineExpose({
  288. send: sendRefresh,
  289. })
  290. </script>
  291. <template>
  292. <div class="page-container flex flex-col">
  293. <header class="flex-none mt-4">
  294. <vxe-form v-bind="searchFormProps" v-on="searchFormEmits"></vxe-form>
  295. </header>
  296. <main class="flex-auto overflow-hidden">
  297. <vxe-grid ref="gridRef" v-bind="gridOptions" v-on="gridEvents" :loading="loading" @checkbox-change="onCheckboxChange" @checkbox-all="onCheckboxAll">
  298. <template #unitPriceCell="{ row }">
  299. <!-- {{ row.cpDynamicPricingRule }} -->
  300. {{ row.pricingType === '1' ? `` : row.cpFixedPricingRule?.unitPrice }}
  301. </template>
  302. <template #convertDoseCell="{ row }">
  303. {{
  304. row.pricingType === '1'
  305. ? `当"穴位/经络/部位 ≤${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  306. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[0]?.price || 0 : 0}元,
  307. 当"穴位/经络/部位 >${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.max || 0 : 0}个时,
  308. 单价为${row?.cpDynamicPricingRule ? row?.cpDynamicPricingRule[1]?.price || 0 : 0}元`
  309. : ''
  310. }}
  311. </template>
  312. <template #toolbar-extra>
  313. <vxe-button style="margin-right: 12px" icon="vxe-icon-repeat" circle @click="refresh(page)"></vxe-button>
  314. </template>
  315. <template #actionSlot="{ row, rowIndex }">
  316. <vxe-button mode="text" status="primary" @click="seeItems(row, rowIndex)">查看</vxe-button>
  317. <vxe-button mode="text" status="primary" @click="editItems(row, rowIndex)">编辑</vxe-button>
  318. <vxe-button mode="text" status="primary" @click="deleteItems(row, rowIndex)" v-if="row.isErasable === 'N' ? false : true">删除</vxe-button>
  319. </template>
  320. </vxe-grid>
  321. </main>
  322. <footer class="flex-none">
  323. <vxe-pager
  324. v-model:current-page="page"
  325. v-model:page-size="pageSize"
  326. :total="total"
  327. :layouts="['Home', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'End', 'Sizes', 'FullJump', 'Total']"
  328. />
  329. </footer>
  330. </div>
  331. </template>
  332. <style scoped lang="scss">
  333. .page-container {
  334. height: 100%;
  335. display: flex;
  336. flex-direction: column;
  337. }
  338. </style>