123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- import { ref } from 'vue';
- import { store } from '@/store';
- import { useAsRouter } from './useAsRouter'
- import dayjs, { Dayjs } from 'dayjs';
- import 'dayjs/locale/zh-cn';
- dayjs.locale('zh-cn');
- import { message } from 'ant-design-vue';
- import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
- import { Modal } from 'ant-design-vue';
-
-
-
- interface CommonInterface {
- model ?: CommonType.ModelType,
- page ?: CommonType.PageType
- search ?: CommonType.SearchType
- table ?: CommonType.TableType
- delParam ?: CommonType.DeleteType,
-
- }
-
- export const useCommon = () => {
- const { routerTo, routerCur, routerArrayCur } = useAsRouter();
- let commomParams = ref<CommonInterface>({
- model: {
- title: '',
- okText: '提交',
- resetText: '重置',
- cancelText: '取消',
- },
-
- page: {
- current: 1,
- pageSize: 1,
- total: 10,
- pageSizeOptions: ['10', '20', '30', '40'],
- hideOnSinglePage: false,
- showSizeChanger: true
- },
-
- search: {
- page: 1,
- pagesize: 10,
- sort: 'id',
- sortby: 'desc',
- keyword: ''
- },
-
- table: {
- data: [],
- columns: [],
- },
-
- delParam: {
- id: 0
- },
-
-
-
- // // MENU
- // openSubMenu: [],
- // menuList: [],
-
- })
-
- let openAddModel = ref<Boolean>(store.state.openAddModel);
- let openOtherModel_1 = ref<Boolean>(store.state.openOtherModel_1);
- let openSearchModel = ref<Boolean>(store.state.openSearchModel); // 搜索
- let editModel = ref<Boolean>(store.state.show_edit);
-
-
- // 点击菜单获取路由
- const onMenu = (path) => {
- routerTo(path);
- };
-
- // Modal
- const hideModal = () => {
- store.commit('getOpenModel', {
- openAddModel: false
- })
- }
-
- // 打开添加/编辑对话框
- const showModal = () => {
- store.commit('getOpenModel', {
- openAddModel: true
- })
- };
-
- const showOtherModal1 = () => {
- store.commit('getOpenMoreModel', {
- openOtherModel_1: true
- })
- };
-
- const hideOtherModal1 = () => {
- store.commit('getOpenMoreModel', {
- openOtherModel_1: false
- })
- }
-
- // 打开搜索
- const showSearch = () => {
- store.commit('getSearchModel', {
- openSearchModel: true
- })
- };
-
- const hideSearch = () => {
- store.commit('getSearchModel', {
- openSearchModel: false
- })
- }
-
- // 编辑
- const showEdit = () => {
- store.commit('getShowEdit', {
- show_edit: true
- })
- };
-
- const hideEdit = () => {
- store.commit('getShowEdit', {
- show_edit: false
- })
- }
-
- // 富文本全局
- let richOption = ref<Object>({
- debug: 'info',
- modules: {
-
- },
- placeholder: '请输入文字'
- });
-
- // 禁止使用日期
- const disabledDate = (val : Dayjs) => {
- return val && val < dayjs().endOf('day');
- };
-
- const disabledDateFront = (val : Dayjs) => {
- return val && val > dayjs().endOf('day');
- };
-
- // 照片前缀
- const imageprefix : string = 'https://admin1.jcjob.cn/img/'
- // const imageprefix : string = 'https://rcsc-test.jcjob.cn/img/'
-
-
-
- return {
- store,
- commomParams,
- openAddModel,
- onMenu,
- hideModal,
- showModal,
- openOtherModel_1,
- showOtherModal1,
- hideOtherModal1,
- dayjs,
- richOption,
- message,
- disabledDate,
- disabledDateFront,
- imageprefix,
- openSearchModel,
- showSearch,
- hideSearch,
- showEdit,
- hideEdit,
- ExclamationCircleOutlined,
- Modal,
- editModel
- }
- }
|