招聘网页
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

useCommon.ts 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import { ref } from 'vue';
  2. import { store } from '@/store';
  3. import { useAsRouter } from './useAsRouter'
  4. import dayjs, { Dayjs } from 'dayjs';
  5. import 'dayjs/locale/zh-cn';
  6. dayjs.locale('zh-cn');
  7. import { message } from 'ant-design-vue';
  8. import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  9. import { Modal } from 'ant-design-vue';
  10. interface CommonInterface {
  11. model ?: CommonType.ModelType,
  12. page ?: CommonType.PageType
  13. search ?: CommonType.SearchType
  14. table ?: CommonType.TableType
  15. delParam ?: CommonType.DeleteType,
  16. }
  17. export const useCommon = () => {
  18. const { routerTo, routerCur, routerArrayCur } = useAsRouter();
  19. let commomParams = ref<CommonInterface>({
  20. model: {
  21. title: '',
  22. okText: '提交',
  23. resetText: '重置',
  24. cancelText: '取消',
  25. },
  26. page: {
  27. current: 1,
  28. pageSize: 1,
  29. total: 10,
  30. pageSizeOptions: ['10', '20', '30', '40'],
  31. hideOnSinglePage: false,
  32. showSizeChanger: true
  33. },
  34. search: {
  35. page: 1,
  36. pagesize: 10,
  37. sort: 'id',
  38. sortby: 'desc',
  39. keyword: ''
  40. },
  41. table: {
  42. data: [],
  43. columns: [],
  44. },
  45. delParam: {
  46. id: 0
  47. },
  48. // // MENU
  49. // openSubMenu: [],
  50. // menuList: [],
  51. })
  52. let openAddModel = ref<Boolean>(store.state.openAddModel);
  53. let openOtherModel_1 = ref<Boolean>(store.state.openOtherModel_1);
  54. let openSearchModel = ref<Boolean>(store.state.openSearchModel); // 搜索
  55. let editModel = ref<Boolean>(store.state.show_edit);
  56. // 点击菜单获取路由
  57. const onMenu = (path) => {
  58. routerTo(path);
  59. };
  60. // Modal
  61. const hideModal = () => {
  62. store.commit('getOpenModel', {
  63. openAddModel: false
  64. })
  65. }
  66. // 打开添加/编辑对话框
  67. const showModal = () => {
  68. store.commit('getOpenModel', {
  69. openAddModel: true
  70. })
  71. };
  72. const showOtherModal1 = () => {
  73. store.commit('getOpenMoreModel', {
  74. openOtherModel_1: true
  75. })
  76. };
  77. const hideOtherModal1 = () => {
  78. store.commit('getOpenMoreModel', {
  79. openOtherModel_1: false
  80. })
  81. }
  82. // 打开搜索
  83. const showSearch = () => {
  84. store.commit('getSearchModel', {
  85. openSearchModel: true
  86. })
  87. };
  88. const hideSearch = () => {
  89. store.commit('getSearchModel', {
  90. openSearchModel: false
  91. })
  92. }
  93. // 编辑
  94. const showEdit = () => {
  95. store.commit('getShowEdit', {
  96. show_edit: true
  97. })
  98. };
  99. const hideEdit = () => {
  100. store.commit('getShowEdit', {
  101. show_edit: false
  102. })
  103. }
  104. // 富文本全局
  105. let richOption = ref<Object>({
  106. debug: 'info',
  107. modules: {
  108. },
  109. placeholder: '请输入文字'
  110. });
  111. // 禁止使用日期
  112. const disabledDate = (val : Dayjs) => {
  113. return val && val < dayjs().endOf('day');
  114. };
  115. const disabledDateFront = (val : Dayjs) => {
  116. return val && val > dayjs().endOf('day');
  117. };
  118. // 照片前缀
  119. const imageprefix : string = 'https://admin1.jcjob.cn/img/'
  120. // const imageprefix : string = 'https://rcsc-test.jcjob.cn/img/'
  121. return {
  122. store,
  123. commomParams,
  124. openAddModel,
  125. onMenu,
  126. hideModal,
  127. showModal,
  128. openOtherModel_1,
  129. showOtherModal1,
  130. hideOtherModal1,
  131. dayjs,
  132. richOption,
  133. message,
  134. disabledDate,
  135. disabledDateFront,
  136. imageprefix,
  137. openSearchModel,
  138. showSearch,
  139. hideSearch,
  140. showEdit,
  141. hideEdit,
  142. ExclamationCircleOutlined,
  143. Modal,
  144. editModel
  145. }
  146. }