| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { ref } from 'vue';
- import { RobotType, getRobot, addRobot, editRobot, delRobot } from '@/api/push/push';
- import { useRequest } from 'vue-hooks-plus';
- export const usePush = () => {
- const robotPushList = ref<RobotType[]>([]);
- const total = ref(0);
- const page = ref(1);
- const size = ref(10);
- // 查询
- const robotSearch = () => {
- const params = {
- pageNumber: page.value,
- pageSize: size.value,
- };
- return getRobot(params).then((res) => {
- return res;
- });
- };
- const { loading, run: getRobotList } = useRequest(robotSearch, {
- manual: true,
- onSuccess: (res) => {
- robotPushList.value = [...res.records];
- total.value = res.totalRow;
- },
- });
- const robotAdd = (data: RobotType) => {
- return addRobot(data).then(() => {
- getRobotList();
- });
- };
- const robotDel = (id: number) => {
- return delRobot(id).then(() => {
- getRobotList();
- });
- };
- const robotEdit = (data: RobotType) => {
- return editRobot(data).then(() => {
- getRobotList();
- });
- };
- return {
- robotPushList,
- total,
- page,
- size,
- loading,
- robotSearch,
- getRobotList,
- robotAdd,
- robotDel,
- robotEdit,
- };
- };
- export default usePush;
|