index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="m-4 modals">
  3. <div>
  4. <XTTitle title="宣教记录" />
  5. <div class="flex items-center justify-between my-4">
  6. <XTTab
  7. type="record"
  8. :width="180"
  9. :selected="tabSelected"
  10. :data="typeOptions"
  11. @item-click="callTab"
  12. />
  13. <XTForm :form-data="formData" @change="callForm" />
  14. </div>
  15. </div>
  16. <BasicTable @register="registerTable">
  17. <template #bodyCell="{ column, record }">
  18. <template v-if="column.key === 'treatmentStage'">
  19. <span
  20. :class="['table-dot']"
  21. :style="{
  22. backgroundColor: formatDictPreColor(responseTypeOptions, record.treatmentStage),
  23. }"
  24. />
  25. <span> {{ formatDictValue(responseTypeOptions, record.treatmentStage) }}</span>
  26. </template>
  27. <!-- <template v-if="column.key === 'supplierCategory'">
  28. <span>
  29. {{ formatDictValue(responsesupplierCategoryOptions, record.supplierCategory) }}</span
  30. >
  31. </template> -->
  32. <template v-if="column.key === 'action'">
  33. <TableAction
  34. :actions="[
  35. {
  36. auth: 'biz:drug:edit',
  37. icon: 'icon-xt-details_delete_default|iconfont',
  38. tooltip: '删除',
  39. onClick: handleDelete.bind(null, record),
  40. },
  41. ]"
  42. />
  43. </template>
  44. </template>
  45. </BasicTable>
  46. </div>
  47. </template>
  48. <script lang="ts" setup>
  49. import { onBeforeMount, ref } from 'vue';
  50. import { BasicTable, useTable, TableAction } from '/@/components/TableCard';
  51. import { useMessage } from '/@/hooks/web/useMessage';
  52. import { formatDictValue, formatDictPreColor } from '/@/utils';
  53. import { columns } from './data';
  54. import { getrecordList, recordNumber, recordDel } from '/@/api/biz/mission/recordApi';
  55. import { listDictModel } from '/@/api/common';
  56. import { XTTitle } from '/@/components/XTTitle/index';
  57. import { XTTab } from '/@/components/XTTab/index';
  58. import { XTForm } from '/@/components/XTForm/index';
  59. // formdata
  60. const formData = [
  61. {
  62. name: 'shiftDate',
  63. componentType: 'RangePicker',
  64. format: 'YYYY-MM-DD',
  65. valueFormat: 'YYYY-MM-DD',
  66. placeholder: '请选择日期',
  67. width: 240,
  68. },
  69. {
  70. name: 'searchNames',
  71. componentType: 'Input',
  72. prefix: 'icon-xt-search',
  73. placeholder: '请输入宣教标题',
  74. width: 240,
  75. },
  76. ];
  77. // tab 切换选中
  78. const tabSelected = ref();
  79. // 操作名称
  80. const searchNames = ref('');
  81. const shiftDate = ref([]);
  82. const typeOptions = ref();
  83. const responseTypeOptions = ref();
  84. const responsesupplierCategoryOptions = ref();
  85. onBeforeMount(async () => {
  86. responseTypeOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
  87. responsesupplierCategoryOptions.value = await listDictModel({ dictCode: 'd' });
  88. getTab();
  89. });
  90. const { createMessage } = useMessage();
  91. // const tableSort = ref([
  92. // {
  93. // field: 'create_time',
  94. // direction: 'DESC',
  95. // },
  96. // ]) as any;
  97. const [registerTable, { reload, clearSelectedRowKeys }] = useTable({
  98. api: getrecordList,
  99. batchDelApi: recordDel,
  100. // batchExportApi: pharmaceuticalsExport,
  101. delAuthList: ['biz:consumable:remove'],
  102. rowKey: 'id',
  103. columns,
  104. showIndexColumn: true,
  105. bordered: true,
  106. actionColumn: {
  107. width: 200,
  108. title: '操作',
  109. dataIndex: 'action',
  110. },
  111. beforeFetch: handleBeforeFetch,
  112. });
  113. // 删除按钮事件
  114. async function handleDelete(record: Recordable) {
  115. if (record) {
  116. await recordDel(record.id);
  117. createMessage.success('删除成功!');
  118. clearSelectedRowKeys();
  119. await reload();
  120. await getTab();
  121. }
  122. }
  123. // 表格请求之前,对参数进行处理, 添加默认 排序
  124. async function handleBeforeFetch(params) {
  125. console.log('searchNames:::', searchNames.value);
  126. return {
  127. ...params,
  128. // orders: tableSort.value,
  129. name: searchNames.value == '' ? undefined : searchNames.value,
  130. status: tabSelected.value == '' ? undefined : tabSelected.value,
  131. time: shiftDate.value.length <= 0 ? undefined : shiftDate.value,
  132. };
  133. }
  134. async function getTab() {
  135. typeOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
  136. const typeNums = await recordNumber(); // 获取各类型数量
  137. let typeList = [];
  138. typeOptions.value.forEach(ele => {
  139. // 变量各类型放置对应数量
  140. let typeData = {};
  141. Object.keys(typeNums).forEach(numKey => {
  142. if (ele.value == numKey) {
  143. typeData = {
  144. key: ele.value,
  145. label: ele.label,
  146. value: typeNums[numKey],
  147. hasValue: true,
  148. prefixColor: ele.prefixColor,
  149. hasBracket: true,
  150. };
  151. typeList.push(typeData);
  152. }
  153. });
  154. });
  155. typeList = typeList.reverse();
  156. typeList.splice(0, 0, {
  157. key: '',
  158. label: '全部',
  159. value: typeNums.total,
  160. hasValue: true,
  161. hasBracket: true,
  162. });
  163. typeOptions.value = typeList;
  164. tabSelected.value = typeOptions.value[0].key;
  165. }
  166. // 选项卡组件回调
  167. async function callTab(data) {
  168. tabSelected.value = data.value;
  169. await reload();
  170. }
  171. // 查询组件回调
  172. async function callForm(data) {
  173. shiftDate.value = data.shiftDate ? data.shiftDate : '';
  174. searchNames.value = data.searchNames ? data.searchNames : '';
  175. console.log('callForm:::', searchNames.value);
  176. await reload();
  177. }
  178. </script>
  179. <style lang="less" scoped>
  180. .table-dot {
  181. display: inline-block;
  182. width: 10px;
  183. height: 10px;
  184. margin-right: 6px;
  185. border-radius: 50%;
  186. }
  187. ::v-deep(.ant-btn-link) {
  188. color: #3d4155;
  189. }
  190. .colUpdateAvatar {
  191. display: flex;
  192. justify-content: center;
  193. text-align: center;
  194. line-height: 28px;
  195. }
  196. .colImg {
  197. width: 28px;
  198. height: 28px;
  199. margin-right: 5px;
  200. }
  201. </style>