| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <script setup lang="ts">
- import { onMounted, ref } from "vue";
- import {
- merchantUserInfoDetail,
- merchantUserInfoupdateAllocationStatus
- } from "@/api/childAccount";
- import { useUserStoreHook } from "@/store/modules/user";
- import { ElMessage, ElMessageBox } from "element-plus";
- const allocationStatus = ref();
- const loading = ref(false);
- onMounted(async () => {
- getStatus();
- });
- const getStatus = () => {
- loading.value = true;
- merchantUserInfoDetail(useUserStoreHook().admUserId)
- .then(res => {
- allocationStatus.value = res.data.receiveStatus;
- })
- .finally(() => {
- loading.value = false;
- });
- };
- const handleChangeStatus = () => {
- ElMessageBox.confirm("确定要修改接单状态吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(async () => {
- loading.value = true;
- let params = {
- allocationStatus: allocationStatus.value,
- ids: [useUserStoreHook().admUserId]
- };
- let res = await merchantUserInfoupdateAllocationStatus(params);
- if (res.code === 0) {
- ElMessage.success("操作成功");
- } else {
- ElMessage.error(res.msg);
- allocationStatus.value = !allocationStatus.value;
- }
- loading.value = false;
- })
- .catch(() => {
- allocationStatus.value = !allocationStatus.value;
- });
- };
- </script>
- <template>
- <el-switch
- v-model="allocationStatus"
- :loading="loading"
- inline-prompt
- active-text="接单中"
- inactive-text="已停止接单"
- @change="handleChangeStatus"
- />
- </template>
- <style scoped lang="scss"></style>
|