data.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
  2. import type { VbenFormSchema } from '#/adapter/form';
  3. import type { OnActionClickFn } from '#/adapter/vxe-table';
  4. import type { PersonnelQualificationModel } from '#/api/method/personnel-qualification';
  5. import { h } from 'vue';
  6. import {
  7. CERTIFICATE_NAME_OPTIONS,
  8. optionsPersonnelDecoctionCenterMethod,
  9. optionsPersonnelEnterpriseMethod,
  10. POSITION_OPTIONS,
  11. QUALIFICATION_STATUS_LABELS,
  12. QUALIFICATION_STATUS_OPTIONS,
  13. } from '#/api/method/personnel-qualification';
  14. import { maskIdNumber } from '#/utils/mask-id';
  15. export function usePersonnelQualificationSearchFormSchema(): VbenFormSchema[] {
  16. return [
  17. {
  18. component: 'ApiSelect',
  19. componentProps: {
  20. allowClear: true,
  21. api: optionsPersonnelEnterpriseMethod,
  22. class: 'w-full',
  23. labelField: 'label',
  24. showSearch: true,
  25. valueField: 'value',
  26. },
  27. fieldName: 'enterpriseId',
  28. label: '煎药企业',
  29. },
  30. {
  31. component: 'ApiSelect',
  32. componentProps: {
  33. allowClear: true,
  34. api: () => optionsPersonnelDecoctionCenterMethod(),
  35. class: 'w-full',
  36. labelField: 'label',
  37. showSearch: true,
  38. valueField: 'value',
  39. },
  40. dependencies: {
  41. componentProps: (values) => ({
  42. key: `decoction-center-${values.enterpriseId || 'all'}`,
  43. allowClear: true,
  44. api: () =>
  45. optionsPersonnelDecoctionCenterMethod(values.enterpriseId),
  46. class: 'w-full',
  47. labelField: 'label',
  48. showSearch: true,
  49. valueField: 'value',
  50. }),
  51. trigger: (_values, formApi) => {
  52. formApi.setFieldValue('decoctionCenterId', undefined);
  53. },
  54. triggerFields: ['enterpriseId'],
  55. },
  56. fieldName: 'decoctionCenterId',
  57. label: '煎药中心',
  58. },
  59. {
  60. component: 'Select',
  61. componentProps: {
  62. allowClear: true,
  63. options: POSITION_OPTIONS,
  64. placeholder: '请选择',
  65. },
  66. fieldName: 'position',
  67. label: '岗位',
  68. },
  69. {
  70. component: 'Select',
  71. componentProps: {
  72. allowClear: true,
  73. options: QUALIFICATION_STATUS_OPTIONS,
  74. placeholder: '请选择',
  75. },
  76. fieldName: 'qualificationStatus',
  77. label: '资质状态',
  78. },
  79. {
  80. component: 'Input',
  81. componentProps: {
  82. placeholder: '请输入',
  83. },
  84. fieldName: 'keyword',
  85. label: '姓名/工号',
  86. },
  87. ];
  88. }
  89. export function usePersonnelQualificationTableColumns(
  90. onActionClick?: OnActionClickFn<PersonnelQualificationModel.Personnel>,
  91. ): VxeTableGridOptions<PersonnelQualificationModel.Personnel>['columns'] {
  92. return [
  93. {
  94. field: 'enterpriseName',
  95. minWidth: 160,
  96. title: '煎药企业/医疗机构',
  97. },
  98. {
  99. field: 'decoctionCenterName',
  100. minWidth: 150,
  101. title: '所属煎药中心',
  102. },
  103. {
  104. field: 'name',
  105. minWidth: 90,
  106. title: '姓名',
  107. },
  108. {
  109. field: 'positions',
  110. minWidth: 110,
  111. slots: {
  112. default: ({ row }) => row.positions?.join('、') || '-',
  113. },
  114. title: '岗位',
  115. },
  116. {
  117. field: 'employeeNo',
  118. minWidth: 90,
  119. title: '工号',
  120. },
  121. {
  122. field: 'idNumber',
  123. minWidth: 150,
  124. slots: {
  125. default: ({ row }) => maskIdNumber(row.idNumber),
  126. },
  127. title: '身份证号',
  128. },
  129. {
  130. field: 'certificateNames',
  131. minWidth: 160,
  132. title: '证书名称',
  133. },
  134. {
  135. field: 'qualificationStatus',
  136. minWidth: 100,
  137. slots: {
  138. default: ({ row }) => {
  139. const label =
  140. QUALIFICATION_STATUS_LABELS[row.qualificationStatus] ?? '-';
  141. const isWarning =
  142. row.qualificationStatus === 'expired' ||
  143. row.qualificationStatus === 'expiring';
  144. return h(
  145. 'span',
  146. { style: isWarning ? { color: '#ff4d4f' } : undefined },
  147. label,
  148. );
  149. },
  150. },
  151. title: '资质状态',
  152. },
  153. {
  154. align: 'center',
  155. cellRender: {
  156. attrs: {
  157. nameField: 'name',
  158. nameTitle: '岗位人员',
  159. onClick: onActionClick,
  160. },
  161. name: 'CellOperation',
  162. options: [
  163. {
  164. code: 'certificate',
  165. style: { color: '#fa8c16' },
  166. text: '证书',
  167. },
  168. 'edit',
  169. 'delete',
  170. ],
  171. },
  172. field: 'operation',
  173. fixed: 'right',
  174. title: '操作',
  175. width: 160,
  176. },
  177. ];
  178. }
  179. export function createEmptyCertificate(): PersonnelQualificationModel.Certificate {
  180. return {
  181. attachments: [],
  182. expiryDate: '',
  183. id: '',
  184. longTerm: false,
  185. name: '',
  186. number: '',
  187. status: 'valid',
  188. type: '',
  189. };
  190. }
  191. export { CERTIFICATE_NAME_OPTIONS, POSITION_OPTIONS };