hospitalIndex.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter"
  4. :leave-active-class="proxy?.animate.searchAnimate.leave">
  5. <div v-show="showSearch" class="mb-[10px]">
  6. <el-card shadow="hover">
  7. <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px">
  8. <el-form-item label="推荐时间:">
  9. <el-date-picker v-model="queryParams.dateRange" type="daterange" range-separator="-"
  10. start-placeholder="开始日期" end-placeholder="结束日期" />
  11. </el-form-item>
  12. <el-form-item label="看诊类型:">
  13. <el-select v-model="queryParams.type" class="spec-unit-select">
  14. <el-option v-for="dict in treatment_user_type" :key="dict.value" :label="dict.label"
  15. :value="dict.value" />
  16. </el-select>
  17. </el-form-item>
  18. <br />
  19. <el-form-item>
  20. <el-input v-model="queryParams.searchValue" placeholder="门诊号/住院号/医生" style="width: 240px" clearable />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  24. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. </el-card>
  28. </div>
  29. </transition>
  30. <el-card shadow="never">
  31. <template #header>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button type="primary" plain icon="Plus" @click="emit('addHospital')"
  35. v-hasPermi="['patients:hospitalMealPlan:add']">新增院内膳食</el-button>
  36. </el-col>
  37. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  38. </el-row>
  39. </template>
  40. <el-table v-loading="loading" border :data="mealPlanList" @selection-change="handleSelectionChange">
  41. <el-table-column type="selection" width="55" align="center" />
  42. <el-table-column label="推荐时间" width="200px" align="center" prop="createTime" />
  43. <el-table-column label="看诊类型" width="100px" align="center" prop="type">
  44. <template #default="scope">
  45. <span>{{ getDictLabel(treatment_user_type, scope.row.type) || '--' }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="门诊/住院号" width="200px" align="center" prop="outpatientNo" />
  49. <el-table-column label="处方状态" width="100px" align="center" prop="status">
  50. <template #default="scope">
  51. <span>{{ getDictLabel(payment_status, scope.row.status) || '--' }}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="推荐医生" width="150px" align="center" prop="createByUser" />
  55. <el-table-column label="操作" width="200px" align="center" class-name="small-padding fixed-width">
  56. <template #default="scope">
  57. <el-tooltip content="详情">
  58. <el-button link type="primary" icon="View" @click="handleView(scope.row)">详情</el-button>
  59. </el-tooltip>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
  64. v-model:limit="queryParams.pageSize" @pagination="getList" />
  65. </el-card>
  66. </div>
  67. </template>
  68. <script setup name="MealPlan" lang="ts">
  69. import { listMealPlan, getMealPlan, delMealPlan, addMealPlan, updateMealPlan } from '@/api/patients/hospitalMealPlan';
  70. import { MealPlanVO, MealPlanQuery, MealPlanForm } from '@/api/patients/hospitalMealPlan/types';
  71. import { useHospitalStore } from '@/store/modules/hospital';
  72. const useStore = useHospitalStore();
  73. const { setHospitalList, hospitalList } = useStore;
  74. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  75. const { treatment_user_type, payment_status } = toRefs<any>(proxy?.useDict('treatment_user_type', 'payment_status'));
  76. const mealPlanList = ref<MealPlanVO[]>([]);
  77. const buttonLoading = ref(false);
  78. const loading = ref(true);
  79. const showSearch = ref(true);
  80. const ids = ref<Array<string | number>>([]);
  81. const single = ref(true);
  82. const multiple = ref(true);
  83. const total = ref(0);
  84. const emit = defineEmits(['change', 'addHospital', 'back']);
  85. const queryFormRef = ref<ElFormInstance>();
  86. const mealPlanFormRef = ref<ElFormInstance>();
  87. const dialog = reactive<DialogOption>({
  88. visible: false,
  89. title: ''
  90. });
  91. const props = defineProps({
  92. patientInfo: {
  93. type: Object,
  94. required: true,
  95. default: () => ({
  96. id: '',
  97. name: '',
  98. age: '',
  99. gender: ''
  100. })
  101. }
  102. });
  103. const initFormData: MealPlanForm = {
  104. id: undefined,
  105. type: props.patientInfo.type,
  106. patientId: props.patientInfo.id,
  107. outpatientNo: props.patientInfo.outpatientNo,
  108. deptId: props.patientInfo.deptId,
  109. recommendStartDate: undefined,
  110. recommendEndDate: undefined,
  111. totalPrice: undefined,
  112. status: undefined,
  113. remark: undefined,
  114. mealRecipeList: []
  115. };
  116. const data = reactive<PageData<MealPlanForm, MealPlanQuery>>({
  117. form: { ...initFormData },
  118. queryParams: {
  119. pageNum: 1,
  120. pageSize: 10,
  121. type: undefined,
  122. patientId: props.patientInfo.id,
  123. outpatientNo: undefined,
  124. deptId: undefined,
  125. dateRange: [],
  126. searchValue: undefined,
  127. params: {}
  128. },
  129. rules: {
  130. id: [{ required: true, message: '主键不能为空', trigger: 'blur' }],
  131. patientId: [{ required: true, message: '患者ID不能为空', trigger: 'blur' }]
  132. }
  133. });
  134. const { queryParams, form, rules } = toRefs(data);
  135. /** 查询院内膳食主列表 */
  136. const getList = async () => {
  137. loading.value = true;
  138. const res = await listMealPlan(queryParams.value);
  139. mealPlanList.value = res.rows;
  140. setHospitalList(mealPlanList.value);
  141. total.value = res.total;
  142. loading.value = false;
  143. };
  144. // 字典label工具
  145. function getDictLabel(dictList: any[], value: string) {
  146. if (!dictList || !Array.isArray(dictList)) return value || '--';
  147. const found = dictList.find((item) => item.value === value);
  148. return found ? found.label : value || '--';
  149. }
  150. /** 取消按钮 */
  151. const cancel = () => {
  152. reset();
  153. dialog.visible = false;
  154. };
  155. /** 表单重置 */
  156. const reset = () => {
  157. form.value = { ...initFormData };
  158. mealPlanFormRef.value?.resetFields();
  159. queryParams.value.dateRange = undefined;
  160. queryParams.value.type = undefined;
  161. queryParams.value.searchValue = undefined;
  162. queryParams.value.pageNum = 1;
  163. queryParams.value.pageSize = 10;
  164. };
  165. /** 搜索按钮操作 */
  166. const handleQuery = () => {
  167. queryParams.value.pageNum = 1;
  168. getList();
  169. };
  170. const handleView = async (row?: MealPlanVO) => {
  171. emit('change', 'hospitalIndex', row);
  172. };
  173. /** 重置按钮操作 */
  174. const resetQuery = () => {
  175. queryFormRef.value?.resetFields();
  176. queryParams.value.dateRange = undefined;
  177. queryParams.value.type = undefined;
  178. queryParams.value.searchValue = undefined;
  179. queryParams.value.pageNum = 1;
  180. queryParams.value.pageSize = 10;
  181. handleQuery();
  182. };
  183. /** 多选框选中数据 */
  184. const handleSelectionChange = (selection: MealPlanVO[]) => {
  185. ids.value = selection.map((item) => item.id);
  186. single.value = selection.length != 1;
  187. multiple.value = !selection.length;
  188. };
  189. /** 新增按钮操作 */
  190. const handleAdd = () => {
  191. reset();
  192. dialog.visible = true;
  193. dialog.title = '添加院内膳食';
  194. };
  195. //
  196. const handleDetail = (row?: MealPlanVO) => {
  197. console.log('row', JSON.stringify(row));
  198. };
  199. /** 修改按钮操作 */
  200. const handleUpdate = async (row?: MealPlanVO) => {
  201. reset();
  202. const _id = row?.id || ids.value[0];
  203. const res = await getMealPlan(_id);
  204. Object.assign(form.value, res.data);
  205. dialog.visible = true;
  206. dialog.title = '修改院内膳食';
  207. };
  208. /** 提交按钮 */
  209. const submitForm = (mealPlanForm) => {
  210. form.value.recommendStartDate = mealPlanForm.mealTimeRange[0];
  211. form.value.recommendEndDate = mealPlanForm.mealTimeRange[1];
  212. form.value.totalPrice = mealPlanForm.totalPrice;
  213. form.value.mealRecipeList = mealPlanForm.mealRecipeList;
  214. addMealPlan(form.value).finally(() => (buttonLoading.value = false));
  215. getList();
  216. mealPlanFormRef.value?.validate(async (valid: boolean) => {
  217. if (true) {
  218. form.value.recommendStartDate = mealPlanForm.mealTimeRange[0];
  219. form.value.recommendEndDate = mealPlanForm.mealTimeRange[1];
  220. form.value.mealRecipeList = mealPlanForm.mealRecipeList;
  221. buttonLoading.value = true;
  222. if (form.value.id) {
  223. await updateMealPlan(form.value).finally(() => (buttonLoading.value = false));
  224. } else {
  225. await addMealPlan(form.value).finally(() => (buttonLoading.value = false));
  226. }
  227. proxy?.$modal.msgSuccess('操作成功');
  228. dialog.visible = false;
  229. await getList();
  230. }
  231. });
  232. };
  233. /** 删除按钮操作 */
  234. const handleDelete = async (id?: number) => {
  235. const _ids = id;
  236. await proxy?.$modal.confirm('是否确认作废院内膳食主编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
  237. await delMealPlan(_ids);
  238. proxy?.$modal.msgSuccess('作废成功');
  239. emit('back', 'hospitalIndex');
  240. await getList();
  241. };
  242. defineExpose({ submitForm, handleDelete });
  243. onMounted(() => {
  244. getList();
  245. });
  246. </script>