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({ 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(store.state.openAddModel); let openOtherModel_1 = ref(store.state.openOtherModel_1); let openSearchModel = ref(store.state.openSearchModel); // 搜索 let editModel = ref(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({ 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 } }