fix: 代码合并

This commit is contained in:
YeMingfei666 2025-04-22 10:14:05 +08:00
commit cfc925e55c
5 changed files with 243 additions and 91 deletions

View File

@ -2,14 +2,26 @@
<div class="app-container"> <div class="app-container">
<!-- 列表 --> <!-- 列表 -->
<!-- 搜索 --> <!-- 搜索 -->
<page-search ref="searchRef" :search-config="searchConfig" @query-click="newHandleQueryClick" <page-search
@reset-click="handleResetClick2" /> ref="searchRef"
:search-config="searchConfig"
@query-click="newHandleQueryClick"
@reset-click="handleResetClick2"
/>
<!-- 顶部数据 --> <!-- 顶部数据 -->
<Statistics :data="gongjiData"></Statistics> <Statistics :data="gongjiData"></Statistics>
<!-- 列表 --> <!-- 列表 -->
<page-content ref="contentRef" :content-config="contentConfig" @add-click="handleAddClick" <page-content
@edit-click="handleEditClick" @export-click="handleExportClick" @search-click="handleSearchClick" ref="contentRef"
@toolbar-click="handleToolbarClick" @operat-click="handleOperatClick" @filter-change="handleFilterChange"> :content-config="contentConfig"
@add-click="handleAddClick"
@edit-click="handleEditClick"
@export-click="handleExportClick"
@search-click="handleSearchClick"
@toolbar-click="handleToolbarClick"
@operat-click="handleOperatClick"
@filter-change="handleFilterChange"
>
<!-- <template #status="scope"> <!-- <template #status="scope">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'"> <el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }} {{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
@ -22,43 +34,67 @@
<DictLabel v-model="scope.row[scope.prop]" code="gender" /> <DictLabel v-model="scope.row[scope.prop]" code="gender" />
</template> </template>
<template #shangjia="scope"> <template #shangjia="scope">
<el-switch v-model="scope.row[scope.prop]" :active-value="1" :inactive-value="0" <el-switch
@click="handleSwitchChange(scope.row)"></el-switch> v-model="scope.row[scope.prop]"
:active-value="1"
:inactive-value="0"
@click="handleSwitchChange(scope.row)"
></el-switch>
</template> </template>
<template #isStock="scope">
<el-switch
disabled
v-model="scope.row[scope.prop]"
:active-value="1"
:inactive-value="0"
></el-switch>
</template>
<template #kucunedit="scope"> <template #kucunedit="scope">
<template v-if="scope.row.type != null"> <template v-if="scope.row.type != null">
{{ scope.row.stockNumber }} <el-icon @click="kucunedit(scope.row)" style="cursor: pointer;color: #4080ff;"> {{ scope.row.stockNumber }}
<el-icon @click="kucunedit(scope.row)" style="cursor: pointer; color: #4080ff">
<EditPen /> <EditPen />
</el-icon> </el-icon>
</template> </template>
</template> </template>
<template #tuikuantuihui="scope"> <template #tuikuantuihui="scope">
<el-switch v-if="!scope.row.productId" v-model="scope.row[scope.prop]" :active-value="1" :inactive-value="0" <el-switch
@click="handleSwitchhaocai(scope.row)"></el-switch> v-if="!scope.row.productId"
v-model="scope.row[scope.prop]"
:active-value="1"
:inactive-value="0"
@click="handleSwitchhaocai(scope.row)"
></el-switch>
</template> </template>
<template #sellOut="scope"> <template #sellOut="scope">
<el-switch v-model="scope.row[scope.prop]" :active-value="1" :inactive-value="0" <el-switch
@click="handleSwitchChangeTwo(scope.row)"></el-switch> v-model="scope.row[scope.prop]"
:active-value="1"
:inactive-value="0"
@click="handleSwitchChangeTwo(scope.row)"
></el-switch>
</template> </template>
<template #mobile="scope"> <template #mobile="scope">
<el-text>{{ scope.row[scope.prop] }}</el-text> <el-text>{{ scope.row[scope.prop] }}</el-text>
<copy-button v-if="scope.row[scope.prop]" :text="scope.row[scope.prop]" style="margin-left: 2px" /> <copy-button
v-if="scope.row[scope.prop]"
:text="scope.row[scope.prop]"
style="margin-left: 2px"
/>
</template> </template>
<template #consumables="scope"> <template #consumables="scope">
<template v-if="scope.row.type != null"> <template v-if="scope.row.type != null">
<span style="color: #4080ff;" v-if="scope.row.consName"> <span style="color: #4080ff" v-if="scope.row.consName">
{{ scope.row.consName }} {{ scope.row.consName }}
</span> </span>
<span v-else> <span v-else>绑定</span>
绑定 <el-icon @click="editOpen(scope.row)" style="cursor: pointer; color: #4080ff">
</span>
<el-icon @click="editOpen(scope.row)" style="cursor: pointer;color: #4080ff;">
<EditPen /> <EditPen />
</el-icon> </el-icon>
</template> </template>
</template> </template>
</page-content> </page-content>
<!-- 新增 --> <!-- 新增 -->
@ -69,7 +105,11 @@
</page-modal> </page-modal>
<!-- 编辑 --> <!-- 编辑 -->
<page-modal ref="editModalRef" :modal-config="editModalConfig" @submit-click="handleSubmitClick"> <page-modal
ref="editModalRef"
:modal-config="editModalConfig"
@submit-click="handleSubmitClick"
>
<template #gender="scope"> <template #gender="scope">
<Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" /> <Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" />
</template> </template>
@ -100,9 +140,11 @@
<!-- 耗材绑定 --> <!-- 耗材绑定 -->
<MyDialog ref="myDialogRefhaocai" @confirm="confirmhaocai" width="50%" title="耗材绑定"> <MyDialog ref="myDialogRefhaocai" @confirm="confirmhaocai" width="50%" title="耗材绑定">
<el-row> <el-row>
<el-col :span="12"> <el-form-item label="商品名"> <el-col :span="12">
<el-form-item label="商品名">
{{ haocaiData.name }} {{ haocaiData.name }}
</el-form-item></el-col> </el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<!-- <el-form-item label="退款退回库存"> <!-- <el-form-item label="退款退回库存">
<el-switch v-model="haocaiData.isRefundStock" :active-value="1" :inactive-value="0" <el-switch v-model="haocaiData.isRefundStock" :active-value="1" :inactive-value="0"
@ -114,15 +156,23 @@
<el-table-column label="序号" type="index" width="60"></el-table-column> <el-table-column label="序号" type="index" width="60"></el-table-column>
<el-table-column label="耗材名称" prop="consInfoId"> <el-table-column label="耗材名称" prop="consInfoId">
<template v-slot="scope"> <template v-slot="scope">
<el-select v-model="scope.row.consInfoId" reserve-keyword placeholder="请输入关键词" <el-select
@change="selectionChange($event, scope.row)"> v-model="scope.row.consInfoId"
<el-option v-for="item in options" :key="item.id" :label="item.conName" :value="item.id"> reserve-keyword
</el-option> placeholder="请输入关键词"
@change="selectionChange($event, scope.row)"
>
<el-option
v-for="item in options"
:key="item.id"
:label="item.conName"
:value="item.id"
></el-option>
</el-select> </el-select>
<!-- <div class="tips" v-if="scope.row.stockNumber">库存{{ scope.row.stockNumber }}</div> --> <!-- <div class="tips" v-if="scope.row.stockNumber">库存{{ scope.row.stockNumber }}</div> -->
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单位" prop="conUnit"> </el-table-column> <el-table-column label="单位" prop="conUnit"></el-table-column>
<el-table-column label="使用数量" prop="surplusStock" min-width="150px"> <el-table-column label="使用数量" prop="surplusStock" min-width="150px">
<template v-slot="scope"> <template v-slot="scope">
<el-input-number v-model="scope.row.surplusStock" :min="0" /> <el-input-number v-model="scope.row.surplusStock" :min="0" />
@ -131,13 +181,20 @@
<el-table-column label="操作" width="100"> <el-table-column label="操作" width="100">
<template v-slot="scope"> <template v-slot="scope">
<div class="table_btn_wrap"> <div class="table_btn_wrap">
<div class="btn sub" v-if="haocaiData.consList.length > 1" <div
@click="haocaiData.consList.splice(scope.$index, 1)"> class="btn sub"
v-if="haocaiData.consList.length > 1"
@click="haocaiData.consList.splice(scope.$index, 1)"
>
<el-icon> <el-icon>
<RemoveFilled /> <RemoveFilled />
</el-icon> </el-icon>
</div> </div>
<div class="btn add" v-if="scope.$index == haocaiData.consList.length - 1" @click="createItem(scope.row)"> <div
class="btn add"
v-if="scope.$index == haocaiData.consList.length - 1"
@click="createItem(scope.row)"
>
<el-icon> <el-icon>
<CirclePlusFilled /> <CirclePlusFilled />
</el-icon> </el-icon>
@ -162,13 +219,13 @@ import usePage from "@/components/CURD/usePage";
import { isSyncStatus } from "@/utils/index"; import { isSyncStatus } from "@/utils/index";
import addModalConfig from "./indexconfig/add"; import addModalConfig from "./indexconfig/add";
import contentConfig from "./indexconfig/content"; import contentConfig from "./indexconfig/content";
import MultiImageUpload from "@/components/Upload/MultiImageUpload.vue" import MultiImageUpload from "@/components/Upload/MultiImageUpload.vue";
import contentConfig2 from "./indexconfig/content2"; import contentConfig2 from "./indexconfig/content2";
import editModalConfig from "./indexconfig/edit"; import editModalConfig from "./indexconfig/edit";
import searchConfig from "./indexconfig/search"; import searchConfig from "./indexconfig/search";
import MyDialog from "@/components/mycomponents/myDialog.vue"; import MyDialog from "@/components/mycomponents/myDialog.vue";
import Statistics from "./indexconfig/statistics.vue"; import Statistics from "./indexconfig/statistics.vue";
import { min } from 'lodash'; import { min } from "lodash";
const { const {
searchRef, searchRef,
@ -192,24 +249,24 @@ const myDialogRefhaocai = ref(null);
const myDialogRefkucun = ref(null); const myDialogRefkucun = ref(null);
let haocaiData = ref({}); let haocaiData = ref({});
let options = ref([]); let options = ref([]);
let kucundata = ref(0) let kucundata = ref(0);
const form = reactive({ const form = reactive({
warnLine: "", warnLine: "",
}); });
let datas = reactive({ let datas = reactive({
number: 0, number: 0,
remark: "", remark: "",
images: [] images: [],
}); });
if (isSyncStatus()) { if (isSyncStatus()) {
contentConfig.toolbar[0].hidden = true contentConfig.toolbar[0].hidden = true;
contentConfig.toolbar[1].hidden = false contentConfig.toolbar[1].hidden = false;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = true contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = true;
} else { } else {
contentConfig.toolbar[0].hidden = false contentConfig.toolbar[0].hidden = false;
contentConfig.toolbar[1].hidden = true contentConfig.toolbar[1].hidden = true;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = false contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = false;
} }
onMounted(() => { onMounted(() => {
@ -218,8 +275,64 @@ onMounted(() => {
contentRef.value?.fetchPageData({ id: route.query.id }); contentRef.value?.fetchPageData({ id: route.query.id });
} }
// //
gethaocaiList() gethaocaiList();
});
if (isSyncStatus()) {
contentConfig.toolbar[0].hidden = true;
contentConfig.toolbar[1].hidden = false;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = true;
} else {
contentConfig.toolbar[0].hidden = false;
contentConfig.toolbar[1].hidden = true;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = false;
}
onMounted(() => {
console.log(route.query);
if (route.query.id) {
contentRef.value?.fetchPageData({ id: route.query.id });
}
//
gethaocaiList();
});
if (isSyncStatus()) {
contentConfig.toolbar[0].hidden = true;
contentConfig.toolbar[1].hidden = false;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = true;
} else {
contentConfig.toolbar[0].hidden = false;
contentConfig.toolbar[1].hidden = true;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = false;
}
onMounted(() => {
console.log(route.query);
if (route.query.id) {
contentRef.value?.fetchPageData({ id: route.query.id });
}
//
gethaocaiList();
});
if (isSyncStatus()) {
contentConfig.toolbar[0].hidden = true;
contentConfig.toolbar[1].hidden = false;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = true;
} else {
contentConfig.toolbar[0].hidden = false;
contentConfig.toolbar[1].hidden = true;
contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = false;
}
onMounted(() => {
console.log(route.query);
if (route.query.id) {
contentRef.value?.fetchPageData({ id: route.query.id });
}
//
gethaocaiList();
}); });
function newHandleQueryClick(e: IObject | undefined) { function newHandleQueryClick(e: IObject | undefined) {
const filterParams = contentRef.value?.getFilterParams(); const filterParams = contentRef.value?.getFilterParams();
@ -228,25 +341,28 @@ function newHandleQueryClick(e: IObject | undefined) {
} }
// //
function kucunedit(item) { function kucunedit(item) {
kucundata.value = item kucundata.value = item;
myDialogRefkucun.value.open() myDialogRefkucun.value.open();
} }
async function confirmkucun() { async function confirmkucun() {
let res = await UserAPI.modifyStock({ id: kucundata.value.id, stockNumber: kucundata.value.stockNumber }) let res = await UserAPI.modifyStock({
ElMessage.success('成功') id: kucundata.value.id,
myDialogRefkucun.value.close() stockNumber: kucundata.value.stockNumber,
});
ElMessage.success("成功");
myDialogRefkucun.value.close();
} }
function editOpen(item: any) { function editOpen(item: any) {
haocaiData.value = item haocaiData.value = item;
if (haocaiData.value.consList.length == 0) { if (haocaiData.value.consList.length == 0) {
let items = { let items = {
"productId": item.id, productId: item.id,
"consInfoId": "", consInfoId: "",
"surplusStock": '0' surplusStock: "0",
} };
haocaiData.value.consList.push(items) haocaiData.value.consList.push(items);
} }
handleResetClick() handleResetClick();
myDialogRefhaocai.value.open(); myDialogRefhaocai.value.open();
} }
// //
@ -254,12 +370,11 @@ function handleResetClick2(queryParams: IObject) {
const filterParams = contentRef.value?.getFilterParams(); const filterParams = contentRef.value?.getFilterParams();
contentRef.value?.fetchPageData({ ...queryParams, ...filterParams }, true); contentRef.value?.fetchPageData({ ...queryParams, ...filterParams }, true);
getTongji(queryParams); getTongji(queryParams);
} }
function getTongji(params: IObject | undefined) { function getTongji(params: IObject | undefined) {
UserAPI.statistics(params).then((res) => { UserAPI.statistics(params).then((res) => {
gongjiData.value = res gongjiData.value = res;
}); });
} }
@ -274,11 +389,11 @@ async function handleAddClick() {
// //
function createItem(val: IObject) { function createItem(val: IObject) {
let item = { let item = {
"productId": val.productId, productId: val.productId,
"consInfoId": "", consInfoId: "",
"surplusStock": '' surplusStock: "",
} };
haocaiData.value.consList.push(item) haocaiData.value.consList.push(item);
} }
// //
function handleSwitchChange(data: any) { function handleSwitchChange(data: any) {
@ -309,18 +424,18 @@ function handleSwitchChangethree(data: any) {
// 退退 // 退退
async function handleSwitchhaocai(row: IObject) { async function handleSwitchhaocai(row: IObject) {
let res = await UserAPI.refundToStock({ isReturn: row.isRefundStock, id: row.id }) let res = await UserAPI.refundToStock({ isReturn: row.isRefundStock, id: row.id });
ElMessage.success('成功') ElMessage.success("成功");
handleResetClick() handleResetClick();
// myDialogRefhaocai.value.close() // myDialogRefhaocai.value.close()
} }
// //
async function handleEditClick(row: IObject) { async function handleEditClick(row: IObject) {
try { try {
router.push({ name: "addgoods", query: { goods_id: row.id } }); router.push({ name: "addgoods", query: { goods_id: row.id } });
} catch (error) { } catch (error) {
ElMessage.error('没有编辑权限') ElMessage.error("没有编辑权限");
} }
} }
@ -331,25 +446,25 @@ async function handleToolbarClick(name: string) {
// ElMessage.success("1"); // ElMessage.success("1");
myDialogRef.value.open(); myDialogRef.value.open();
} }
if (name === "sync") { // if (name === "sync") {
let res = await UserAPI.sync() //
ElMessage.success('操作成功,数据正在后台同步中...') let res = await UserAPI.sync();
ElMessage.success("操作成功,数据正在后台同步中...");
} }
} }
async function confirm() { async function confirm() {
let res = await UserAPI.stockWarning(form.warnLine) let res = await UserAPI.stockWarning(form.warnLine);
ElMessage.success("成功"); ElMessage.success("成功");
myDialogRef.value.close(); myDialogRef.value.close();
} }
// //
function selectionChange(e, row) { function selectionChange(e, row) {
let item = options.value.find(item => item.id == e) let item = options.value.find((item) => item.id == e);
row.name = item.conName row.name = item.conName;
row.conUnit = item.conUnit row.conUnit = item.conUnit;
} }
async function confirmbaosun() { async function confirmbaosun() {
let res = await UserAPI.reportDamage(datas) let res = await UserAPI.reportDamage(datas);
ElMessage.success("成功"); ElMessage.success("成功");
myDialogRefbaosun.value.close(); myDialogRefbaosun.value.close();
contentRef.value?.fetchPageData(); contentRef.value?.fetchPageData();
@ -357,11 +472,11 @@ async function confirmbaosun() {
async function confirmhaocai() { async function confirmhaocai() {
let obj = { let obj = {
consList: haocaiData.value.consList, consList: haocaiData.value.consList,
id: haocaiData.value.id id: haocaiData.value.id,
} };
let res = await UserAPI.bind(obj) let res = await UserAPI.bind(obj);
ElMessage.success("成功"); ElMessage.success("成功");
handleResetClick() handleResetClick();
myDialogRefhaocai.value.close(); myDialogRefhaocai.value.close();
} }
// //
@ -380,16 +495,15 @@ function typeFilter(item: any) {
} }
// //
async function handleOperatClick(data: IOperatData) { async function handleOperatClick(data: IOperatData) {
datas.productId = data.row.id datas.productId = data.row.id;
myDialogRefbaosun.value.open(); myDialogRefbaosun.value.open();
datas.number = 1 datas.number = 1;
datas.remark = "" datas.remark = "";
} }
async function gethaocaiList() { async function gethaocaiList() {
let res = await UserAPI.productcons({ id: route.query.id }) let res = await UserAPI.productcons({ id: route.query.id });
options.value = res.records options.value = res.records;
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@ -402,11 +516,11 @@ async function gethaocaiList() {
font-size: 26px; font-size: 26px;
&.sub { &.sub {
color: #FF4D4F; color: #ff4d4f;
} }
&.add { &.add {
color: #52C41A; color: #52c41a;
} }
} }
} }

View File

@ -93,6 +93,13 @@ const contentConfig: IContentConfig<UserPageQuery> = {
// { label: "库存", align: "center", prop: "stockNumber" }, // { label: "库存", align: "center", prop: "stockNumber" },
{ label: "库存", align: "center", slotName: "kucunedit", templet: "custom", prop: "stockNumber" }, { label: "库存", align: "center", slotName: "kucunedit", templet: "custom", prop: "stockNumber" },
{ label: "耗材信息", align: "center", prop: "consName", slotName: "consumables", templet: "custom", }, { label: "耗材信息", align: "center", prop: "consName", slotName: "consumables", templet: "custom", },
{
label: "库存开关",
align: "center",
prop: "isStock",
templet: "custom",
slotName: "isStock",
},
{ {
label: "上架", label: "上架",
align: "center", align: "center",

View File

@ -207,7 +207,12 @@
</div> </div>
</div> </div>
<!-- 扫码 --> <!-- 扫码 -->
<scanPay ref="refScanPay" :order="orderInfo" @confirm="refScanPayConfirm"></scanPay> <scanPay
ref="refScanPay"
:order="orderInfo"
@confirm="refScanPayConfirm"
@paysuccess="paysuccess"
></scanPay>
<!-- 打折 --> <!-- 打折 -->
<discount ref="refDiscount" @confirm="discountConfirm"></discount> <discount ref="refDiscount" @confirm="discountConfirm"></discount>
<!-- 优惠券 --> <!-- 优惠券 -->
@ -591,12 +596,16 @@ async function payOrder(payType, isScan, guazhangren) {
} }
if (res) { if (res) {
clearTimeout(payTimer);
ElMessage.success("支付成功");
emits("paysuccess");
loading.close(); loading.close();
paysuccess();
} }
} }
function paysuccess() {
clearTimeout(payTimer);
ElMessage.success("支付成功");
emits("paysuccess");
}
// //
const discountAmount = computed(() => { const discountAmount = computed(() => {
const money = carts.goodsTotal - productCouponDiscountAmount.value; const money = carts.goodsTotal - productCouponDiscountAmount.value;

View File

@ -139,9 +139,20 @@ export default {
shopId: localStorage.getItem("shopId"), shopId: localStorage.getItem("shopId"),
orderId: this.order.id, orderId: this.order.id,
}); });
console.log(res);
// if (res == "done") {
// ElMessage({
// message: "",
// type: "success",
// });
// }
if (res != "unpaid") { if (res != "unpaid") {
console.log("已支付或取消");
this.close();
this.clear(); this.clear();
this.$emit("paySuccess"); if (res == "done") {
this.$emit("paysuccess");
}
} }
}, },
startGetOrderInfo() { startGetOrderInfo() {

View File

@ -859,7 +859,10 @@ function resetOldOrder() {
originAmount: 0, originAmount: 0,
}); });
} }
function refresh() { function refresh() {
console.log("index refresh");
carts.clearHistory();
resetOldOrder(); resetOldOrder();
showOrder.value = false; showOrder.value = false;
user.value = {}; user.value = {};
@ -871,6 +874,14 @@ function refresh() {
// router.go(0); // router.go(0);
// }, 1500); // }, 1500);
} }
watch(
() => carts.oldOrder.id,
(newval, oldval) => {
if (!newval && carts.isEmpty) {
showOrder.value = false;
}
}
);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>