index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <script setup lang="ts">
  2. import { onMounted, ref } from "vue";
  3. import {
  4. merchantUserInfoDetail,
  5. merchantUserInfoupdateAllocationStatus
  6. } from "@/api/childAccount";
  7. import { useUserStoreHook } from "@/store/modules/user";
  8. import { ElMessage, ElMessageBox } from "element-plus";
  9. const allocationStatus = ref();
  10. const loading = ref(false);
  11. onMounted(async () => {
  12. getStatus();
  13. });
  14. const getStatus = () => {
  15. loading.value = true;
  16. merchantUserInfoDetail(useUserStoreHook().admUserId)
  17. .then(res => {
  18. allocationStatus.value = res.data.receiveStatus;
  19. })
  20. .finally(() => {
  21. loading.value = false;
  22. });
  23. };
  24. const handleChangeStatus = () => {
  25. ElMessageBox.confirm("确定要修改接单状态吗?", "提示", {
  26. confirmButtonText: "确定",
  27. cancelButtonText: "取消",
  28. type: "warning"
  29. })
  30. .then(async () => {
  31. loading.value = true;
  32. let params = {
  33. allocationStatus: allocationStatus.value,
  34. ids: [useUserStoreHook().admUserId]
  35. };
  36. let res = await merchantUserInfoupdateAllocationStatus(params);
  37. if (res.code === 0) {
  38. ElMessage.success("操作成功");
  39. } else {
  40. ElMessage.error(res.msg);
  41. allocationStatus.value = !allocationStatus.value;
  42. }
  43. loading.value = false;
  44. })
  45. .catch(() => {
  46. allocationStatus.value = !allocationStatus.value;
  47. });
  48. };
  49. </script>
  50. <template>
  51. <el-switch
  52. v-model="allocationStatus"
  53. :loading="loading"
  54. inline-prompt
  55. active-text="接单中"
  56. inactive-text="已停止接单"
  57. @change="handleChangeStatus"
  58. />
  59. </template>
  60. <style scoped lang="scss"></style>