You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.6 KiB

/**
* 监管者
*/
import { ref } from 'vue';
import { defineStore } from 'pinia';
import http from '@/utils/http';
import * as urls from '@/config/urls';
import * as helpers from '@/utils/helpers';
export const useRegulatorStore = defineStore('regulator', () => {
const regulatorList = ref([]);
const regulatorExtra = ref({ total: null });
const regulatorQueries = ref({ page: 1, pageSize: 10, all: undefined, search: undefined });
function getRegulatorList(otherQueries = {}) {
return http.getInstance().get(urls.GET_REGULATOR_LIST, {
params: { ...regulatorQueries.value, ...otherQueries },
}).then(({ data }) => {
const { data: list, extra } = data;
regulatorList.value = list || [];
regulatorExtra.value = { ...regulatorExtra.value, ...(extra || {}) };
regulatorQueries.value = { ...regulatorQueries.value, ...otherQueries };
return data;
});
}
function createRegulator(formData = {}, { refreshList = false } = {}) {
const reqData = helpers.pick(formData, [
'phone',
'password',
]);
return http.getInstance().post(urls.CREATE_REGULATOR, reqData).then(({ data }) => {
if (refreshList) getRegulatorList();
return data;
});
}
return {
regulatorList,
regulatorQueries,
regulatorExtra,
getRegulatorList,
createRegulator,
// updateRegulator,
// deleteRegulator,
// updateRegulatorDisable,
};
});
export default null;