diff --git a/src/api/product/index.ts b/src/api/product/index.ts index 49178e4..a8865b3 100644 --- a/src/api/product/index.ts +++ b/src/api/product/index.ts @@ -41,6 +41,24 @@ const AuthAPI = { method: "delete", }); }, + // 退款退回 + refundToStock(data: any) { + return request({ + url: `${baseURL}/refundToStock`, + method: "post", + data, + }); + }, + + // 耗材列表 + productcons(params: any) { + return request({ + url: `/product/admin/product/cons/page`, + method: "get", + params + }); + }, + // 上下架 onOff(data: any) { return request({ @@ -79,6 +97,14 @@ const AuthAPI = { data, }); }, + // 商品-绑定耗材 + bind(data: any) { + return request({ + url: `${baseURL}/bind`, + method: "post", + data, + }); + }, // 库存预警 stockWarning(data: any) { return request({ diff --git a/src/views/product/index.vue b/src/views/product/index.vue index f040394..c216a92 100644 --- a/src/views/product/index.vue +++ b/src/views/product/index.vue @@ -34,15 +34,17 @@ @@ -70,7 +72,7 @@ - + @@ -83,6 +85,56 @@ + + + + + {{ haocaiData.name }} + + + + + + + + + + + + + + + + + + + + + @@ -99,7 +151,6 @@ import editModalConfig from "./indexconfig/edit"; import searchConfig from "./indexconfig/search"; import MyDialog from "@/components/mycomponents/myDialog.vue"; import Statistics from "./indexconfig/statistics.vue"; -import { Search } from '@element-plus/icons-vue' const { searchRef, contentRef, @@ -115,6 +166,15 @@ const { } = usePage(); const router = useRouter(); let gongjiData = ref({}); +const myDialogRef = ref(null); +const route = useRoute(); +const myDialogRefbaosun = ref(null); +const myDialogRefhaocai = ref(null); +let haocaiData = ref({}); +let options = ref([]); +const form = reactive({ + warnLine: "", +}); let datas = reactive({ number: 0, remark: "", @@ -125,8 +185,18 @@ function newHandleQueryClick(e: IObject | undefined) { contentRef.value?.fetchPageData({ ...e, ...filterParams }, true); getTongji(e); } -function editOpen() { - +function editOpen(item: any) { + haocaiData.value = item + if (haocaiData.value.consList.length == 0) { + let items = { + "productId": item.id, + "consInfoId": "", + "surplusStock": '0' + } + haocaiData.value.consList.push(items) + } + handleResetClick() + myDialogRefhaocai.value.open(); } // 重置 function handleResetClick2(queryParams: IObject) { @@ -141,9 +211,7 @@ function getTongji(params: IObject | undefined) { gongjiData.value = res }); } -const form = reactive({ - warnLine: "", -}); + // 新增 async function handleAddClick() { router.push({ name: "addgoods" }); @@ -151,7 +219,15 @@ async function handleAddClick() { // 加载上级规格下拉数据源 // addModalConfig.formItems[2]!.attrs!.data = await UserAPI.getPage({ name: "" }); // 加载角色下拉数据源 - // addModalConfig.formItems[4]!.options = await RoleAPI.getOptions(); +} +// 生成新商品绑定耗材关系项 +function createItem(val: IObject) { + let item = { + "productId": val.productId, + "consInfoId": "", + "surplusStock": '' + } + haocaiData.value.consList.push(item) } // 上架 function handleSwitchChange(data: any) { @@ -171,13 +247,18 @@ function handleSwitchChangeTwo(data: any) { }; UserAPI.markIsSoldOut(obj); } +// 退款退回 +async function handleSwitchhaocai(row: IObject) { + let res = await UserAPI.refundToStock({ isReturn: row, id: haocaiData.value.id }) + ElMessage.success('成功') + // myDialogRefhaocai.value.close() +} // 编辑 async function handleEditClick(row: IObject) { router.push({ name: "addgoods", query: { goods_id: row.id } }); } -const myDialogRef = ref(null); -const myDialogRefbaosun = ref(null); + // 其他工具栏 function handleToolbarClick(name: string) { console.log(name); @@ -192,11 +273,27 @@ async function confirm() { myDialogRef.value.close(); } +// 商品选择耗材 +function selectionChange(e, row) { + let item = options.value.find(item => item.id == e) + row.name = item.conName + row.conUnit = item.conUnit +} async function confirmbaosun() { let res = await UserAPI.reportDamage(datas) ElMessage.success("成功"); myDialogRefbaosun.value.close(); } +async function confirmhaocai() { + let obj = { + consList: haocaiData.value.consList, + id: haocaiData.value.id + } + let res = await UserAPI.bind(obj) + ElMessage.success("成功"); + handleResetClick() + myDialogRefhaocai.value.close(); +} // 商品规格 function typeFilter(item: any) { if (item == "single") { @@ -218,11 +315,35 @@ async function handleOperatClick(data: IOperatData) { } -const route = useRoute(); onMounted(() => { console.log(route.query); if (route.query.id) { contentRef.value?.fetchPageData({ id: route.query.id }); } + // 获取耗材列表 + gethaocaiList() }); +async function gethaocaiList() { + let res = await UserAPI.productcons({ id: route.query.id }) + options.value = res.records +} + \ No newline at end of file