index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <PageWrapper>
  3. <Card
  4. :bordered="false"
  5. :active-tab-key="activeKey"
  6. :tab-list="tabList"
  7. style="height: 800px"
  8. @tabChange="
  9. key => {
  10. activeKey = key;
  11. }
  12. "
  13. >
  14. <p :key="0" v-if="activeKey == 0">
  15. <Row>
  16. <Col :span="6">
  17. <Card title="病区属性" style="height: 680px">
  18. <template #extra
  19. ><Button
  20. shape="circle"
  21. v-auth="['bizSys:wardProperties:add']"
  22. @click="handleAddAttr"
  23. ><Icon icon="icon-plus|iconfont" :size="14" /></Button
  24. ></template>
  25. <Row>
  26. <div class="type-title">阴性</div>
  27. </Row>
  28. <Row v-for="item in attributeFeminineList" :key="item.key" style="margin: 4px 0">
  29. <Tag
  30. class="attrs"
  31. closable
  32. @close="handleDeleteAttr(item.key)"
  33. @click="handleSelectWard(item)"
  34. :value="item.key"
  35. >{{ item.label }}
  36. </Tag>
  37. </Row>
  38. <Row>
  39. <div class="type-title">阳性</div>
  40. </Row>
  41. <Row v-for="item in attributePositiveList" :key="item.key" style="margin: 4px 0">
  42. <Tag
  43. class="attrs"
  44. closable
  45. @close="handleDeleteAttr(item.key)"
  46. @click="handleSelectWard(item)"
  47. :value="item.key"
  48. >{{ item.label }}</Tag
  49. >
  50. </Row>
  51. </Card>
  52. </Col>
  53. <Col :span="1" />
  54. <Col :span="17">
  55. <Card title="病区信息" style="height: 680px">
  56. <template #extra
  57. ><Button shape="circle" v-auth="['bizSys:wardInfo:add']" @click="handleAddInfo"
  58. ><Icon icon="icon-plus|iconfont" :size="14" /></Button
  59. ></template>
  60. <BasicTable @register="registerTable">
  61. <template #bodyCell="{ column, record }">
  62. <template v-if="column.key === 'disable'">
  63. <Tag :color="formatDictColor(disableOptions, record.disable)">
  64. {{ formatDictValue(disableOptions, record.disable) }}
  65. </Tag>
  66. </template>
  67. <template v-if="column.key === 'action'">
  68. <TableAction
  69. :actions="[
  70. {
  71. auth: 'bizSys:wardInfo:edit',
  72. icon: 'icon-xt-details_edit_default|iconfont',
  73. tooltip: '编辑',
  74. onClick: handleEdit.bind(null, record),
  75. },
  76. {
  77. auth: 'bizSys:wardInfo:status',
  78. icon: 'icon-xt-details_delete_default|iconfont',
  79. tooltip: '停用',
  80. ifShow: record.disable == 0,
  81. popConfirm: {
  82. title: '是否确认停用',
  83. placement: 'left',
  84. confirm: handleChangeState.bind(null, record),
  85. },
  86. },
  87. {
  88. auth: 'bizSys:wardInfo:status',
  89. icon: 'icon-plus|iconfont',
  90. tooltip: '启用',
  91. label: '',
  92. ifShow: record.disable == 1,
  93. popConfirm: {
  94. title: '是否确认启用',
  95. placement: 'left',
  96. confirm: handleChangeState.bind(null, record),
  97. },
  98. },
  99. ]"
  100. />
  101. </template>
  102. </template>
  103. </BasicTable>
  104. </Card>
  105. </Col>
  106. </Row>
  107. </p>
  108. <p :key="1" v-else>
  109. <Row>
  110. <Col :span="6">
  111. <Card title="工作日配置" style="height: 680px">
  112. <template #extra
  113. ><Button shape="circle" v-auth="['bizSys:workday:edit']" @click="handleEditWorkDay">
  114. <Icon icon="icon-xt-details_edit_default|iconfont" :size="14" /></Button
  115. ></template>
  116. <Row v-for="(item, index) in workDays" :key="index">
  117. <div class="wrak-day">{{ item.label }}</div>
  118. </Row>
  119. </Card>
  120. </Col>
  121. <Col :span="1" />
  122. <Col :span="17">
  123. <Card title="班次配置" style="height: 680px">
  124. <template #extra
  125. ><Button v-auth="['bizSys:wardInfo:add']" @click="handleAddSailing" shape="circle"
  126. ><Icon icon="icon-xt-details_edit_default|iconfont" :size="14" /></Button
  127. ></template>
  128. <BasicTable @register="registerSailingsTable">
  129. <template #bodyCell="{ column, record }">
  130. <template v-if="column.key === 'disable'">
  131. <Tag :color="formatDictColor(disableOptions, record.disable)">
  132. {{ formatDictValue(disableOptions, record.disable) }}
  133. </Tag>
  134. </template>
  135. <template v-if="column.key === 'action'">
  136. <TableAction
  137. :actions="[
  138. {
  139. auth: 'bizSys:wardInfo:edit',
  140. icon: 'icon-xt-details_edit_default|iconfont',
  141. tooltip: '编辑',
  142. label: '',
  143. onClick: handleEdit.bind(null, record),
  144. },
  145. {
  146. auth: 'bizSys:wardInfo:status',
  147. icon: 'icon-minus-square|iconfont',
  148. tooltip: '停用',
  149. label: '',
  150. color: 'error',
  151. ifShow: record.disable == 0,
  152. popConfirm: {
  153. title: '是否确认停用',
  154. placement: 'left',
  155. confirm: handleChangeState.bind(null, record),
  156. },
  157. },
  158. {
  159. auth: 'bizSys:wardInfo:status',
  160. icon: 'icon-plus|iconfont',
  161. tooltip: '启用',
  162. label: '',
  163. ifShow: record.disable == 1,
  164. color: 'error',
  165. popConfirm: {
  166. title: '是否确认启用',
  167. placement: 'left',
  168. confirm: handleChangeState.bind(null, record),
  169. },
  170. },
  171. ]"
  172. />
  173. </template>
  174. </template>
  175. </BasicTable>
  176. </Card>
  177. </Col>
  178. </Row>
  179. </p>
  180. </Card>
  181. </PageWrapper>
  182. <WardTypeFormModal @register="registerWardTypeModal" @success="handleWardTypeSuccess" />
  183. <WardInfoFormModal @register="registerWardInfoModal" @success="handleWardInfoSuccess" />
  184. <WorkDayFormModal @register="registerWorkDayModal" @success="handleWorkDaySuccess" />
  185. <SailingEdit @register="registerSailingEditModal" @success="handleSailingSuccess" />
  186. </template>
  187. <script lang="ts" setup>
  188. import { onBeforeMount, ref } from 'vue';
  189. import { PageWrapper } from '/@/components/Page';
  190. import { Button, Card, Row, Col, Tag } from 'ant-design-vue';
  191. import Icon from '/@/components/Icon/src/Icon.vue';
  192. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  193. import { wardInfoColumns, sailingsColumns } from './data';
  194. import WardTypeFormModal from './wardTypeFormModal.vue';
  195. import WardInfoFormModal from './wardInfoFormModal.vue';
  196. import WorkDayFormModal from './workDayFormModal.vue';
  197. import SailingEdit from './sailingsEditFormModal.vue';
  198. import { getWardInfo, changeStatus } from '/@/api/biz/management/wardInfo';
  199. import { getAttrList, deleteWardType } from '/@/api/biz/management/wardType';
  200. import { getWorkingDay, getSailings } from '/@/api/biz/management/working';
  201. import { useModal } from '/@/components/Modal';
  202. import { listDictModel } from '/@/api/common';
  203. import { useMessage } from '/@/hooks/web/useMessage';
  204. import { formatDictColor, formatDictValue } from '/@/utils';
  205. const { createConfirm, createMessage } = useMessage();
  206. const tabList = ref([
  207. { key: 0, tab: '病区管理', type: 'WARD' },
  208. { key: 1, tab: '工作日班次', type: 'WORK' },
  209. ]);
  210. const activeKey = ref(0);
  211. const attributePositiveList = ref([]); // 阳性列表
  212. const attributeFeminineList = ref([]); // 阴性列表
  213. const workDays = ref([]);
  214. const disableOptions = ref();
  215. onBeforeMount(async () => {
  216. disableOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
  217. await getWardType();
  218. await getWordDay();
  219. });
  220. const [registerTable, { reload }] = useTable({
  221. api: getWardInfo,
  222. rowKey: 'id',
  223. columns: wardInfoColumns,
  224. showIndexColumn: false,
  225. formConfig: {
  226. labelWidth: 120,
  227. autoSubmitOnEnter: true,
  228. baseColProps: { xs: 24, sm: 12, md: 12, lg: 8 },
  229. resetButtonOptions: {
  230. preIcon: 'icon-delete|iconfont',
  231. },
  232. submitButtonOptions: {
  233. preIcon: 'icon-search|iconfont',
  234. },
  235. },
  236. useSearchForm: false,
  237. bordered: true,
  238. actionColumn: {
  239. width: 320,
  240. title: '操作',
  241. dataIndex: 'action',
  242. },
  243. beforeFetch: handleBeforeFetch,
  244. sortFn: handleSortFn,
  245. });
  246. const [registerSailingsTable, { reload: SailingsReload }] = useTable({
  247. api: getSailings,
  248. columns: sailingsColumns,
  249. showIndexColumn: false,
  250. formConfig: {
  251. labelWidth: 120,
  252. autoSubmitOnEnter: true,
  253. baseColProps: { xs: 24, sm: 12, md: 12, lg: 8 },
  254. },
  255. useSearchForm: false,
  256. bordered: true,
  257. });
  258. const [registerWardTypeModal, { openModal: openWardTypeModal }] = useModal();
  259. const [registerWardInfoModal, { openModal: openWardInfoModal }] = useModal();
  260. const [registerWorkDayModal, { openModal: openWorkDayModal }] = useModal();
  261. const [registerSailingEditModal, { openModal: openSailingModal }] = useModal();
  262. const tableSort = ref([
  263. {
  264. field: 'sort',
  265. direction: 'ASC',
  266. },
  267. ]);
  268. const selectType = ref();
  269. // 方法区
  270. // 获取病区信息前事件
  271. function handleBeforeFetch(params) {
  272. return { ...params, propertiesId: selectType.value, orders: tableSort.value };
  273. }
  274. function handleSortFn() {}
  275. // 打开新增属性方法
  276. function handleAddAttr() {
  277. openWardTypeModal(true, {
  278. isUpdate: false,
  279. });
  280. }
  281. // 打开删除属性方法
  282. async function handleDeleteAttr(id) {
  283. createConfirm({
  284. content: '你确定要删除?',
  285. iconType: 'warning',
  286. onOk: async () => {
  287. await deleteWardType([id]);
  288. createMessage.success('属性删除成功!');
  289. await getWardType();
  290. },
  291. onCancel: async () => {
  292. attributePositiveList.value = [];
  293. attributeFeminineList.value = [];
  294. await getWardType();
  295. },
  296. });
  297. }
  298. //打开新增病区信息方法
  299. function handleAddInfo() {
  300. openWardInfoModal(true, {
  301. isUpdate: false,
  302. });
  303. }
  304. //打开编辑工作日方法
  305. function handleEditWorkDay() {
  306. openWorkDayModal(true, {
  307. record: workDays.value,
  308. isUpdate: true,
  309. });
  310. }
  311. // 打开编辑病区信息方法
  312. function handleEdit(record: Recordable) {
  313. openWardInfoModal(true, {
  314. record,
  315. isUpdate: true,
  316. });
  317. }
  318. // 停用启用病区方法
  319. async function handleChangeState(record) {
  320. const notes = record.disable == 0 ? '停用' : '启用';
  321. await changeStatus(record.id);
  322. createMessage.success('病区' + notes + '成功!');
  323. reload();
  324. }
  325. // 保存成功回调事件
  326. async function handleWardTypeSuccess() {
  327. await getWardType();
  328. }
  329. function handleWardInfoSuccess() {
  330. reload();
  331. SailingsReload();
  332. }
  333. async function getWardType() {
  334. const attrList = await getAttrList();
  335. attributePositiveList.value = []; // 阳性列表
  336. attributeFeminineList.value = [];
  337. attrList.forEach(item => {
  338. if (item.positive) {
  339. attributePositiveList.value.push({ label: item.name, key: item.id });
  340. } else {
  341. attributeFeminineList.value.push({ label: item.name, key: item.id });
  342. }
  343. });
  344. }
  345. // 通过病区属性搜索病区信息
  346. function handleSelectWard(e) {
  347. selectType.value = e.key;
  348. reload();
  349. }
  350. // 获取工作日
  351. async function getWordDay() {
  352. const res = await getWorkingDay();
  353. const workDay = [];
  354. Object.keys(res).forEach((value, index) => {
  355. if (res[value]) {
  356. switch (value) {
  357. case 'monday': {
  358. workDay.push({
  359. name: value,
  360. key: index,
  361. value: res[value],
  362. label: '周一',
  363. });
  364. break;
  365. }
  366. case 'tuesday': {
  367. workDay.push({
  368. name: value,
  369. key: index,
  370. value: res[value],
  371. label: '周二',
  372. });
  373. break;
  374. }
  375. case 'wednesday': {
  376. workDay.push({
  377. name: value,
  378. key: index,
  379. value: res[value],
  380. label: '周三',
  381. });
  382. break;
  383. }
  384. case 'thursday': {
  385. workDay.push({
  386. name: value,
  387. key: index,
  388. value: res[value],
  389. label: '周四',
  390. });
  391. break;
  392. }
  393. case 'friday': {
  394. workDay.push({
  395. name: value,
  396. key: index,
  397. value: res[value],
  398. label: '周五',
  399. });
  400. break;
  401. }
  402. case 'saturday': {
  403. workDay.push({
  404. name: value,
  405. key: index,
  406. value: res[value],
  407. label: '周六',
  408. });
  409. break;
  410. }
  411. case 'sunday': {
  412. workDay.push({
  413. name: value,
  414. key: index,
  415. value: res[value],
  416. label: '周日',
  417. });
  418. break;
  419. }
  420. }
  421. }
  422. });
  423. workDays.value = workDay;
  424. }
  425. // 新增班次
  426. function handleAddSailing() {
  427. openSailingModal(true, {});
  428. }
  429. async function handleWorkDaySuccess() {
  430. await getWordDay();
  431. }
  432. async function handleSailingSuccess() {
  433. await SailingsReload();
  434. }
  435. </script>
  436. <style lang="less" scoped>
  437. ::v-deep(.ant-card-head) {
  438. background-color: #f6f8fa !important;
  439. }
  440. .type-title {
  441. font-size: 14px;
  442. font-weight: bold;
  443. color: #000a18;
  444. }
  445. .attrs {
  446. background: #fff !important;
  447. height: 32px !important;
  448. line-height: 32px !important;
  449. font-weight: 400 !important;
  450. color: #17233d !important;
  451. font-size: 14px !important;
  452. border-radius: 4px !important;
  453. border: 1px solid #c2ccd4 !important;
  454. }
  455. .wrak-day {
  456. width: 28px;
  457. height: 20px;
  458. margin-bottom: 20px;
  459. text-align: center;
  460. font-size: 14px;
  461. font-weight: 500;
  462. color: #000a18;
  463. line-height: 20px;
  464. }
  465. ::v-deep(.ant-btn-link) {
  466. color: rgb(61 65 85 / 100%);
  467. }
  468. </style>