index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div class="p-4">
  3. <BasicTable @register="registerTable">
  4. <template #toolbar>
  5. <a-button
  6. type="primary"
  7. @click="handleCreate"
  8. v-if="getCheckPerm('application-add')"
  9. >新增</a-button
  10. >
  11. </template>
  12. <!-- , -->
  13. <template #action="{ record }">
  14. <TableAction
  15. :actions="[
  16. {
  17. label: '删除',
  18. ifShow: getCheckPerm('application-delete'),
  19. color: 'error',
  20. onClick:handDelconfirm.bind(null, record),
  21. },
  22. ]"
  23. />
  24. </template>
  25. </BasicTable>
  26. <DetailsModal @register="registerDetail" @ok="reload" />
  27. <!--<DelListModal @register="registerDelList" @reload="reload" /> -->
  28. </div>
  29. </template>
  30. <script lang="ts">
  31. import { defineComponent, computed, onMounted, ref, } from 'vue';
  32. import { BasicTable, useTable, BasicColumn, FormProps, TableAction } from '/@/components/Table';
  33. import { useMessage } from '/@/hooks/web/useMessage';
  34. import { useModal } from '/@/components/Modal';
  35. import { uploadApi } from '/@/api/sys/upload';
  36. import DetailsModal from './detailsModal.vue';
  37. import { buryPointList, buryPointDlt } from '/@/api/statistics/index';
  38. import { useI18n } from '/@/hooks/web/useI18n';
  39. import { RoleEnum } from '/@/enums/roleEnum';
  40. import { useGo } from '/@/hooks/web/usePage';
  41. import { Time } from '/@/components/Time';
  42. import { useUserStore } from '/@/store/modules/user';
  43. import { usePermissionStore } from '/@/store/modules/permission';
  44. export default defineComponent({
  45. components: {
  46. BasicTable,
  47. TableAction,
  48. Time,
  49. DetailsModal,
  50. // DelListModal,
  51. },
  52. setup() {
  53. const [register, { openModal }] = useModal();
  54. const surplusSubNum = ref({
  55. lookNum: 0,
  56. shotNum: 0,
  57. });
  58. const [registerDetail, { openModal: openDetaileModal }] = useModal();
  59. const [registerDelList, { openModal: openDelListeModal }] = useModal();
  60. const { createConfirm, createMessage } = useMessage();
  61. const permissionStore = usePermissionStore();
  62. const { getCheckPerm } = permissionStore;
  63. const userStore = useUserStore();
  64. // const { getCheckRole } = userStore;
  65. const roleList = computed(() => userStore.getRoleList);
  66. console.log('getRoleList', roleList);
  67. const go = useGo();
  68. const { t } = useI18n();
  69. onMounted(() => {
  70. // getNumByStaffData();
  71. });
  72. const columns: BasicColumn[] = [
  73. {
  74. title: '应用名称',
  75. dataIndex: 'applicationName',
  76. },
  77. {
  78. title: '应用key',
  79. dataIndex: 'applicationKey',
  80. },
  81. {
  82. title: '操作',
  83. align: 'center',
  84. dataIndex: '',
  85. flag:'ACTION',
  86. // ifShow: !getCheckRole('tourist'),
  87. slots: { customRender: 'action' },
  88. fixed: 'right',
  89. width: 150,
  90. },
  91. ];
  92. const searchForm: Partial<FormProps> = {
  93. labelWidth: 100,
  94. autoSubmitOnEnter:true,
  95. schemas: [
  96. {
  97. field: 'applicationName',
  98. label: '应用名称',
  99. component: 'Input',
  100. componentProps: {
  101. maxLength: 15,
  102. },
  103. colProps: {
  104. xl: 6,
  105. xxl: 6,
  106. },
  107. },
  108. ],
  109. };
  110. const [registerTable, { reload }] = useTable({
  111. title: '应用列表',
  112. api: buryPointList,
  113. columns: columns,
  114. useSearchForm: true,
  115. formConfig: searchForm,
  116. showTableSetting: true,
  117. tableSetting: { fullScreen: true },
  118. showIndexColumn: false,
  119. rowKey: 'id',
  120. fetchSetting: {
  121. pageField: 'pageNum',
  122. sizeField: 'pageSize',
  123. listField: 'list',
  124. totalField: 'total',
  125. },
  126. pagination: { pageSize: 20 },
  127. afterFetch: (T) => {
  128. return T;
  129. },
  130. bordered: true,
  131. sortFn: (sortInfo) => {
  132. let order = sortInfo.order && sortInfo.order.replace('end', '');
  133. return { ...sortInfo, sidx: sortInfo.field, order: order };
  134. },
  135. });
  136. function renderRoleType(type: number): string {
  137. switch (type) {
  138. case 0:
  139. return t('routes.staff.roleType.0');
  140. case 1:
  141. return t('routes.staff.roleType.1');
  142. default:
  143. return '';
  144. }
  145. }
  146. function renderStatus(type: number): string {
  147. switch (type) {
  148. case 1:
  149. return t('common.normal');
  150. case 0:
  151. return t('common.unNormal');
  152. default:
  153. return '';
  154. }
  155. }
  156. function handleOpenModal(record: Recordable) {
  157. openModal(true, record);
  158. }
  159. function handleCreate() {
  160. // if (
  161. // getCheckRole([RoleEnum.COMPANY_ADMIN]) &&
  162. // surplusSubNum.value.lookNum == 0 &&
  163. // surplusSubNum.value.shotNum == 0
  164. // ) {
  165. // return createMessage.error('新增失败,可添加员工数量为0个');
  166. // }
  167. openDetaileModal(true, {});
  168. }
  169. function handleEdit(record: Recordable) {
  170. openDetaileModal(true, {
  171. ...record,
  172. phone:record.userName,
  173. });
  174. }
  175. function handDelconfirm(record) {
  176. createConfirm({
  177. iconType: 'warning',
  178. title: '警告',
  179. content: `此操作将对${record.applicationName}进行删除, 是否继续?`,
  180. onOk: async () => {
  181. await buryPointDlt({ id: record.id });
  182. reload();
  183. createMessage.success(t('common.optSuccess'));
  184. },
  185. });
  186. }
  187. return {
  188. registerTable,
  189. registerDetail,
  190. registerDelList,
  191. openDelListeModal,
  192. createMessage,
  193. handDelconfirm,
  194. t,
  195. reload,
  196. go,
  197. renderRoleType,
  198. renderStatus,
  199. handleCreate,
  200. handleOpenModal,
  201. register,
  202. handleEdit,
  203. uploadApi: uploadApi as any,
  204. RoleEnum,
  205. surplusSubNum,
  206. getCheckPerm,
  207. };
  208. },
  209. });
  210. </script>