7 Commits

33 changed files with 5030 additions and 3853 deletions

252
components/change-table.vue Normal file
View File

@@ -0,0 +1,252 @@
<template>
<view>
<up-popup :show="show" mode="center" @close="close">
<view class="bg-fff u-p-30 box">
<scroll-view direction="vertical" scroll-y style="max-height: 80vh;">
<view class="u-flex gap-20">
<view>转桌到</view>
<view>
<chooseTable v-model="form.mewTable"></chooseTable>
</view>
</view>
<view class="u-flex gap-20 u-m-t-32 u-col-baseline">
<view>转入类型</view>
<up-radio-group v-model="form.type" placement="column">
<up-radio label="转桌(可将部分商品转入)" :name="1" :key="1"></up-radio>
<up-radio label="并桌(并台会将全部购物车商品转入)" :name="2" :key="2"></up-radio>
</up-radio-group>
</view>
<template v-if="form.type==1">
<view class=" u-m-t-32 ">
<view class="u-m-b-24">购物车商品</view>
<goodsTable :data="nowCartData" :columns="columnsCheck1" row-key="id"
@selection-change="handleSelectionChange($event,'now')"></goodsTable>
<!-- <u-table2 :data="nowCartData" :columns="columnsCheck1" row-key="id"
@selection-change="handleSelectionChange($event,'now')" /> -->
</view>
<view class=" u-m-t-50 ">
<view class="u-m-b-24">历史订单商品</view>
<view v-for="(order,orderIndex) in goodsList" class="u-m-t-32" :key="index">
<view>{{ orderIndex }}次下单</view>
<goodsTable :data="order" :columns="columnsCheck" row-key="id"
@selection-change="handleSelectionChange($event,'old')" />
<!-- <u-table2 :data="order" :columns="columnsCheck" row-key="id"
@selection-change="handleSelectionChange($event,'old')" /> -->
</view>
</view>
</template>
</scroll-view>
<view class="u-flex gap-20 u-p-t-30">
<view class="u-flex-1">
<my-button type="default" @click="close">取消</my-button>
</view>
<view class="u-flex-1">
<my-button @click="confirm">确认</my-button>
</view>
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
import goodsTable from './goods-table.vue'
import {
reactive,
ref,
watch
} from 'vue';
import chooseTable from './choose-table.vue'
import {
mergeOrder
} from '@/http/api/order/order.js'
const show = defineModel(false)
const allChecked = ref(false)
const props = defineProps({
goodsList: {},
order: {
id: ''
},
nowCartData: []
})
watch(() => props.nowCartData, (newval) => {
console.log('props.nowCartData', props.nowCartData)
}, {
deep: true
})
function close() {
console.log('close');
form.mewTable = {id: ''}
show.value = false
}
const form = reactive({
mewTable: {
id: ''
},
type: 1,
now: [],
old: []
})
const columnsCheck = ref([
// 复选框列
{
type: 'selection',
width: '50px'
},
// 普通列
{
title: '商品',
key: 'productName'
},
{
title: '数量',
key: 'num'
}
]);
const columnsCheck1 = ref([
// 复选框列
{
type: 'selection',
width: '50px'
},
// 普通列
{
title: '商品',
key: 'name'
},
{
title: '数量',
key: 'number'
}
]);
const handleSelectionChange = (selection, key) => {
console.log('handleSelectionChange', selection);
if (key === 'old') {
form.old = selection
}
if (key === 'now') {
form.now = selection
}
};
const emits = defineEmits('update', 'confirm')
function confirm() {
if (!form.mewTable.id) {
return uni.showToast({
title: '请选择目标台桌',
icon: 'none'
})
}
if (form.type == 1) {
if (form.old.length <= 0 && form.now.length <= 0) {
return uni.showToast({
title: '请选择转桌商品',
icon: 'none'
})
}
}
if (form.type == 2) {
if (props.nowCartData.length <= 0) {
mergeOrder({
allMerge: 1,
sourceOrderId: props.order ? props.order.id : '',
targetTableCode: form.mewTable.tableCode,
detailIds: Object.entries(props.goodsList).reduce((prve, cur) => {
prve.push(...cur.map(v => v.id))
return prve
}, [])
}).then(res => {
uni.showToast({
title: '转桌成功',
icon: 'none'
})
emits('update', 1)
close()
})
} else {
emits('confirm', {
targetTableCode: form.mewTable.tableCode,
old: {
allMerge: 1,
sourceOrderId: props.order ? props.order.id : '',
targetTableCode: form.mewTable.tableCode,
detailIds: Object.entries(props.goodsList).reduce((prve, cur) => {
prve.push(...cur.map(v => v.id))
return prve
}, [])
},
now: {
allMerge: 1,
cart_id: props.nowCartData.map(v => v.id)
}
})
close()
}
return
}
console.log(form);
let allOldLen = 0;
for (let key in props.goodsList) {
allOldLen += props.goodsList[key].length
}
const allMerge = form.old.length === allOldLen ? 1 : 0
if (props.nowCartData.length <= 0) {
mergeOrder({
allMerge,
sourceOrderId: props.order ? props.order.id : '',
targetTableCode: form.mewTable.tableCode,
detailIds: form.old.map(v => v.id)
}).then(res => {
uni.showToast({
title: '转桌成功',
icon: 'none'
})
emits('update', allMerge)
close()
})
} else {
emits('confirm', {
targetTableCode: form.mewTable.tableCode,
old: {
allMerge,
sourceOrderId: props.order ? props.order.id : '',
targetTableCode: form.mewTable.tableCode,
detailIds: form.old.map(v => v.id)
},
now: {
allMerge: props.nowCartData.length == form.now.length,
cart_id: form.now.map(v => v.id)
}
})
close()
}
}
</script>
<style scoped>
.box {
width: 690rpx;
border-radius: 18rpx;
}
</style>

152
components/choose-table.vue Normal file
View File

@@ -0,0 +1,152 @@
<template>
<view>
<view class="u-flex input-box u-row-between" @click="openPopup">
<template v-if="!modelValue||!modelValue.id">
<text class="color-999">请选择转桌到</text>
<up-icon name="arrow-down" color="#999"></up-icon>
</template>
<template v-else>
<text class="color-333">{{modelValue.name}}</text>
<up-icon name="arrow-down" color="#999"></up-icon>
</template>
</view>
<up-popup :show="show" mode="bottom">
<view class="box bg-fff u-p-30">
<up-search v-model="query.name" @search="search" @clear="search" @custom="search"></up-search>
<scroll-view direction="vertical" scroll-y style="max-height: 50vh;">
<view class="u-m-t-30 list">
<view class="item" v-for="(item,index) in list" :key="index" :class="{active:selIndex==index}"
@click="selIndex=index">
<text> {{item.name}}</text>
</view>
</view>
<up-loadmore status="nomore"></up-loadmore>
</scroll-view>
</view>
<view class="u-flex gap-20 u-p-l-30 u-p-r-30 u-p-b-30">
<view class="u-flex-1">
<my-button type="default" @click="close">取消</my-button>
</view>
<view class="u-flex-1">
<my-button @click="confirm">确认</my-button>
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted
} from 'vue';
import {
onLoad
} from '@dcloudio/uni-app'
import {
getShopTable
} from '@/http/api/table.js'
const modelValue = defineModel({
default:{id:''}
})
const list = ref([])
const show = ref(false)
const selIndex = ref(-1)
function close() {
show.value = false
selIndex.value = -1;
}
function confirm() {
if (selIndex.value < 0) {
return uni.showToast({
title: '请选择桌台',
icon: 'none'
})
}
modelValue.value = list.value[selIndex.value]
console.log('selIndex.value', selIndex.value );
console.log('modelValue.value ', modelValue.value );
close()
}
const query = reactive({
page: 1,
size: 999,
// status: 'idle',
name: ''
})
/**
* 获取桌台列表
*/
async function getTable() {
let res = await getShopTable(query)
list.value = res.records
}
function search() {
selIndex.value = -1;
getTable()
}
function openPopup() {
const index = list.value.findIndex(v => v.id === modelValue.value.id)
if (index != -1) {
selIndex.value = index
}
show.value = true
}
onMounted(() => {
getTable()
})
</script>
<style lang="scss" scoped>
.input-box {
padding: 20rpx 20rpx;
border-radius: 8rpx;
border: 1px solid #dedede;
min-width: 300rpx;
}
.box {
border-radius: 18rpx;
}
.list {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-gap: 20rpx;
.item {
margin-bottom: 24rpx;
padding: 20rpx 40rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 6rpx;
border: 1px solid #dedede;
transition: all .3s ease-in-out;
&.active {
border-color: $my-main-color;
background-color: $my-main-color;
color: #fff;
}
}
}
</style>

156
components/goods-table.vue Normal file
View File

@@ -0,0 +1,156 @@
<template>
<view class="table u-font-28">
<!-- 表头根据 columns 渲染 + 全选框 -->
<view class="u-flex u-row-between no-wrap title">
<!-- 全选框 -->
<view class="table-th">
<up-checkbox @change="handleSelectAll" usedAlone v-model:checked="internalAllChecked" shape="square"
:size="20" />
</view>
<!-- 动态列标题 -->
<view class="table-th" v-for="col in columns" :key="col.key" :style="col.style || {}">
{{ col.title }}
</view>
</view>
<!-- 有数据 渲染列表 -->
<template v-if="internalData.length > 0">
<view @click="handleRowCheck(item)" class="u-m-t-12 u-flex u-p-24 u-row-between row"
v-for="(item, index) in internalData" :key="item.id || index" row-key="id">
<view class="table-td">
<up-checkbox @change="handleRowCheck(item)" usedAlone v-model:checked="item._checked" shape="square" :size="20"></up-checkbox>
</view>
<view class="table-td" v-for="col in columns" :key="col.key" :style="col.style || {}">
<slot v-if="col.slot" :name="col.slot" :row="item" />
<template v-else>{{ item[col.key] }}</template>
</view>
</view>
</template>
<!-- 无数据 显示暂无数据 -->
<view v-else class="empty-text u-p-t-40 u-p-b-40 u-text-center">
暂无数据
</view>
</view>
</template>
<script setup>
import {
ref,
computed,
watch
} from 'vue';
// 完全对齐 u-table2 的 props
const props = defineProps({
data: {
type: Array,
default: () => []
},
columns: {
type: Array,
default: () => []
},
rowKey: {
type: String,
default: 'id'
}
});
// 抛出和 u-table2 一样的 selection-change 事件
const emits = defineEmits(['selection-change']);
// 内部数据(增加选中状态 _checked
const internalData = ref([]);
// 全选状态
const internalAllChecked = ref(false);
// 监听外部 data 变化,自动注入选中状态
watch(
() => props.data,
(val) => {
internalData.value = val.map(item => ({
...item,
_checked: item._checked || false
}));
}, {
immediate: true,
deep: true
}
);
// 全选切换
function handleSelectAll() {
internalAllChecked.value = !internalAllChecked.value
const checked = internalAllChecked.value;
internalData.value = internalData.value.map(item => {
item._checked = checked;
return item;
})
console.log('internalData.value', internalData.value);
emitChange();
}
// 行选中切换
function handleRowCheck(row) {
row._checked = !row._checked;
emitChange();
}
// 抛出选中结果(和 u-table2 行为一致)
function emitChange() {
const selectedRows = internalData.value.filter(item => item._checked);
emits('selection-change', selectedRows);
}
// 监听所有行选中状态,自动更新全选框
watch(
() => internalData.value,
() => {
const total = internalData.value.length;
const checkedCount = internalData.value.filter(i => i._checked).length;
internalAllChecked.value = total > 0 && checkedCount === total;
}, {
deep: true
}
);
</script>
<style lang="scss">
.table {
background: #f9f9f9;
border-radius: 8rpx;
overflow: hidden;
.title {
padding: 12rpx 24rpx;
background: #aebad2;
border-radius: 8rpx 8rpx 0 0;
color: #fff;
}
.table-th,
.table-td {
flex: 1;
text-align: center;
}
.row {
cursor: pointer;
}
.row:nth-of-type(2n + 1) {
background: #f0f0f0;
}
// 空数据样式
.empty-text {
font-size: 28rpx;
color: #999;
}
}
</style>

View File

@@ -8,9 +8,9 @@
:height="height"
:maxCount="maxCount"
>
<template #default v-if="$slots.default">
<!-- <template #default v-if="$slots.default">
<slot></slot>
</template>
</template> -->
</up-upload>
</template>

View File

@@ -1,5 +1,5 @@
//当前环境 test,prod
export const ENV = 'prod'
export const ENV = 'test'
export const ENV_BASE_URL = {
java: {
prod: 'https://cashier.sxczgkj.com/',

2
data/icon.js Normal file
View File

@@ -0,0 +1,2 @@
// static/coupon/qrcode.svg
export const qrcode = 'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/6/7070aa441e4e4126b0bba32502a3521e.svg'

View File

@@ -14,6 +14,16 @@ export function categoryPage(data, urlType = 'product') {
}
})
}
/**
* 获取分类详情
* @returns
*/
export function getCategoryDetail(id, urlType = 'product') {
return request({
url: `${urlType}/admin/prod/category/`+id,
method: "GET",
})
}
/**
* 分类添加

View File

@@ -14,7 +14,19 @@ export function getConsPage(data, urlType = 'product') {
}
})
}
/**
* 耗材库存列表接口
* @returns
*/
export function getConsStock(data, urlType = 'product') {
return request({
url: `${urlType}/admin/product/cons/consStock`,
method: "GET",
data: {
...data
}
})
}
/**
* 获取耗材列表
* @returns

16
http/api/order/order.js Normal file
View File

@@ -0,0 +1,16 @@
import http from "@/http/http.js";
const request = http.request;
const urlType = "order";
export function mergeOrder(data) {
return request({
url: urlType + '/admin/order/mergeOrder',
method: "POST",
data: {
...data,
},
});
}

View File

@@ -13,15 +13,22 @@
</view>
<view class="">
<uni-forms-item label="分类名称" required name="name">
<uni-easyinput padding-none :placeholderStyle="'font-size:28rpx;'"
:inputBorder="false" v-model="category.name" placeholder="输入分类名称" />
<uni-easyinput padding-none :placeholderStyle="'font-size:28rpx;'" :inputBorder="false"
v-model="category.name" placeholder="输入分类名称" />
</uni-forms-item>
</view>
<view class="">
<uni-forms-item label="退菜是否退库存" required name=" refundMode">
<up-radio-group v-model="category.refundMode" placement="row">
<up-radio v-for="(item, index) in refundModes" :key="index" :label="item.name"
:name="item.value" activeColor="rgb(49, 138, 254)"></up-radio>
</up-radio-group>
</uni-forms-item>
</view>
<template v-if="option.type==='edit'">
<uni-forms-item label="排序" required name="sort">
<uni-easyinput padding-none :placeholderStyle="'font-size:28rpx;'"
:inputBorder="false" v-model="category.sort" type="number"
placeholder="排序越小越靠前" />
<uni-easyinput padding-none :placeholderStyle="'font-size:28rpx;'" :inputBorder="false"
v-model="category.sort" type="number" placeholder="排序越小越靠前" />
</uni-forms-item>
</template>
<uni-forms-item label="">
@@ -34,7 +41,7 @@
</uni-forms-item>
</view>
</uni-forms>
</view>
@@ -42,23 +49,44 @@
<button class="save-btn" hover-class="btn-hover-class" @click="save">保存</button>
</view>
</view>
</view>
</template>
<script setup>
import { reactive, ref } from 'vue';
import {
reactive,
ref
} from 'vue';
import go from '@/commons/utils/go.js';
import infoBox from '@/commons/utils/infoBox.js';
import mySwitch from '@/components/my-components/my-switch'
import myUploadFile from '@/components/my-components/my-upload-file'
import { onLoad, onReady } from '@dcloudio/uni-app';
import { addCategory, putCategory } from '@/http/api/cateGory.js'
import {
onLoad,
onReady
} from '@dcloudio/uni-app';
import {
addCategory,
putCategory
} from '@/http/api/cateGory.js'
const refundModes = [{
name: "退菜退库存",
value: 1
},
{
name: "仅退菜不退库存",
value: 2
},
{
name: "每次询问-退菜后弹窗提示",
value: 3
},
]
// 构造分类的基础数据
const category = reactive({
name: '',
@@ -96,7 +124,7 @@
title: option.type === 'add' ? '添加分类' : '编辑分类'
})
})
/**
* 校验是否有值
* @param {Object} obj
@@ -121,6 +149,7 @@
}
}
}
function validateFunc(key, value) {
if (validateFuncObj.hasOwnProperty(key)) {
const func = validateFuncObj[key]
@@ -137,7 +166,7 @@
resultArr = resultArr.filter(v => !v.pass)
return resultArr
}
/**
* 图片选择
* @param {Object} val
@@ -147,7 +176,7 @@
function onfileChange(val, data, key) {
data[key] = val
}
/**
* 保存
*/
@@ -157,7 +186,7 @@
const formRules = {}
const result = []
result.push(...returnValidateResult(category))
if (result.length) {
return infoBox.showToast(result[0].errMeessage)
}
@@ -178,7 +207,7 @@
uni.$emit('update:pageCategoryIndex')
go.back()
}, 500);
}
</script>

View File

@@ -18,6 +18,12 @@
<view>预警值</view>
<view><input type="number" placeholder="请输入预警值" v-model="datas.form.conWarning" name="" id="" /></view>
</view>
<view>
<view>是否检测耗材</view>
<up-switch size="20" :inactive-value="0" :active-value="1" v-model="datas.form.isStock"></up-switch>
</view>
<view v-if="!datas.form.id" style="justify-content: space-between">
<view>耗材类型</view>
<view style="width: 54%" @tap="datas.show = !datas.show">
@@ -55,7 +61,8 @@
<view class="label">默认入库单位</view>
<view class="ipt">
<u-radio-group v-model="datas.form.defaultUnit">
<u-radio :name="item" :label="item" v-for="(item, index) in unitList" :key="index"></u-radio>
<u-radio :name="item" :label="item" v-for="(item, index) in unitList"
:key="index"></u-radio>
</u-radio-group>
</view>
</view>
@@ -63,226 +70,252 @@
</view>
</template>
<view class="bottombutton">
<up-button type="primary" style="background-color: #318afe; color: #fff" @tap="sumbit" :plain="true" text="保存"></up-button>
<up-button type="primary" style="background-color: #318afe; color: #fff" @tap="sumbit" :plain="true"
text="保存"></up-button>
</view>
<up-picker :show="datas.show" :columns="datas.typeList" keyName="name" @cancel="datas.show = false" @confirm="confirmConsGroup"></up-picker>
<up-picker :show="datas.show" :columns="datas.typeList" keyName="name" @cancel="datas.show = false"
@confirm="confirmConsGroup"></up-picker>
<!-- 消息提示 -->
<up-toast ref="uToastRef"></up-toast>
<u-picker :show="unitShow" :columns="unitList"></u-picker>
</template>
<script setup>
import { ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import {
ref,
reactive
} from 'vue';
import {
onLoad
} from '@dcloudio/uni-app';
import { getConsGrpupList, addCons, editCons } from '@/http/api/cons.js';
import {
getConsGrpupList,
addCons,
editCons
} from '@/http/api/cons.js';
let datas = reactive({
show: false,
form: {
conUnit: '',
conName: '',
price: '',
conWarning: 999,
consGroupId: null,
conUnitTwo: '', // 第二单位
conUnitTwoConvert: '', // 第二单位转换数量
defaultUnit: 2
},
consGroupName: '',
typeList: []
});
onLoad((options) => {
if (options && options.item) {
let obj = JSON.parse(decodeURIComponent(options.item));
datas.form = obj;
unitList.value = [];
if (datas.form.conUnit !== '') {
unitList.value.push(datas.form.conUnit);
}
if (datas.form.conUnitTwo !== '') {
unitList.value.push(datas.form.conUnitTwo);
}
console.log('datas.form', datas.form);
console.log('unitList.value', unitList.value);
} else {
gettbConsTypeList();
}
uni.setNavigationBarTitle({
title: !datas.form.id ? '添加耗材' : '编辑耗材'
let datas = reactive({
show: false,
form: {
conUnit: '',
conName: '',
price: '',
conWarning: 999,
consGroupId: null,
conUnitTwo: '', // 第二单位
conUnitTwoConvert: '', // 第二单位转换数量
defaultUnit: '',
isStock: 1,
},
consGroupName: '',
typeList: []
});
});
/**
* 获取耗材类别
*/
let gettbConsTypeList = () => {
getConsGrpupList({
page: 1,
size: 30
}).then((res) => {
datas.typeList = [res];
onLoad((options) => {
if (options && options.item) {
let obj = JSON.parse(decodeURIComponent(options.item));
datas.form = obj;
unitList.value = [];
if (datas.form.conUnit !== '') {
unitList.value.push(datas.form.conUnit);
}
if (datas.form.conUnitTwo !== '') {
unitList.value.push(datas.form.conUnitTwo);
}
console.log('datas.form', datas.form);
console.log('unitList.value', unitList.value);
} else {
gettbConsTypeList();
}
uni.setNavigationBarTitle({
title: !datas.form.id ? '添加耗材' : '编辑耗材'
});
});
};
function confirmConsGroup(e) {
datas.show = false;
datas.form.consGroupId = e.value[0].id;
datas.consGroupName = e.value[0].name;
}
/**
* 获取耗材类别
*/
let gettbConsTypeList = () => {
getConsGrpupList({
page: 1,
size: 30
}).then((res) => {
datas.typeList = [res];
});
};
let sumbit = async () => {
let conUnitdata = datas.form.conUnit.replace(/(^\s*)|(\s*$)/g, '');
if (!conUnitdata) {
uni.$utils.showToast('单位不能为空');
return;
function confirmConsGroup(e) {
datas.show = false;
datas.form.consGroupId = e.value[0].id;
datas.consGroupName = e.value[0].name;
}
if (!datas.form.price) {
uni.$utils.showToast('价格不能为空');
return;
}
if (!datas.form.consGroupId) {
uni.$utils.showToast('耗材类型不能为空');
return;
}
if (!datas.form.id) {
await addCons({ ...datas.form });
} else {
await editCons({ ...datas.form });
}
uni.navigateBack();
};
// 显示选择单位
const unitShow = ref(false);
// 单位列表
const unitList = ref([]);
let sumbit = async () => {
let conUnitdata = datas.form.conUnit.replace(/(^\s*)|(\s*$)/g, '');
if (!conUnitdata) {
uni.$utils.showToast('单位不能为空');
return;
}
if (!datas.form.price) {
uni.$utils.showToast('价格不能为空');
return;
}
if (!datas.form.consGroupId) {
uni.$utils.showToast('耗材类型不能为空');
return;
}
if (!datas.form.id) {
await addCons({
...datas.form
});
} else {
await editCons({
...datas.form
});
}
uni.navigateBack();
};
// 显示选择单位
const unitShow = ref(false);
// 单位列表
const unitList = ref([]);
</script>
<style>
page {
background-color: #f9f9f9;
}
page {
background-color: #f9f9f9;
}
</style>
<style scoped lang="less">
.topTitle {
font-weight: 400;
font-size: 32rpx;
color: #333333;
margin: 32rpx 28rpx;
}
.topTitle {
font-weight: 400;
font-size: 32rpx;
color: #333333;
margin: 32rpx 28rpx;
}
.addConsumables {
width: 694rpx;
background: #ffffff;
border-radius: 18rpx 18rpx 18rpx 18rpx;
margin: 32rpx;
padding: 24rpx;
box-sizing: border-box;
.addConsumables {
width: 694rpx;
background: #ffffff;
border-radius: 18rpx 18rpx 18rpx 18rpx;
margin: 32rpx;
padding: 24rpx;
box-sizing: border-box;
> view {
> view {
width: 646rpx;
height: 84rpx;
background: #fcfcfc;
border: 2rpx solid #f9f9f9;
margin-top: 32rpx;
.df;
> view:first-child {
width: 190rpx;
>view {
>view {
width: 646rpx;
height: 84rpx;
line-height: 84rpx;
// text-align: left;
padding-left: 24rpx;
background: #f9f9f9;
border-radius: 8rpx 0rpx 0rpx 8rpx;
background: #fcfcfc;
border: 2rpx solid #f9f9f9;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 32rpx;
color: #333333;
margin-top: 32rpx;
.df;
>view:first-child {
width: 240rpx;
height: 84rpx;
line-height: 84rpx;
// text-align: left;
padding-left: 24rpx;
background: #f9f9f9;
border-radius: 8rpx 0rpx 0rpx 8rpx;
border: 2rpx solid #f9f9f9;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 32rpx;
color: #333333;
}
}
}
}
}
.bottombutton {
margin-top: 84rpx;
padding: 0 24rpx;
.bottombutton {
margin-top: 84rpx;
padding: 0 24rpx;
> button {
width: 530rpx;
height: 80rpx;
border-radius: 56rpx 56rpx 56rpx 56rpx;
}
}
.status {
margin: 0 32rpx;
position: absolute;
// top: 100%;
left: 0;
right: 0;
z-index: 10;
background-color: #fff;
}
.df() {
display: flex;
align-items: center;
}
.tips-wrap {
--pColor: #e6a23c;
--iColor: #fdf6ec;
padding: 0 28upx;
.content {
display: flex;
align-items: center;
padding: 28upx;
background-color: var(--iColor);
.info {
display: flex;
flex-direction: column;
padding-left: 10px;
gap: 8upx;
.t1 {
font-size: 32upx;
color: var(--pColor);
}
.t2 {
font-size: 24upx;
color: var(--pColor);
}
>button {
width: 530rpx;
height: 80rpx;
border-radius: 56rpx 56rpx 56rpx 56rpx;
}
}
}
.form-wrap {
padding: 28upx 28upx 0;
.form {
padding: 28upx;
.status {
margin: 0 32rpx;
position: absolute;
// top: 100%;
left: 0;
right: 0;
z-index: 10;
background-color: #fff;
border-radius: 16upx;
}
.row {
height: 84upx;
.df() {
display: flex;
gap: 20upx;
align-items: center;
background-color: #fcfcfc;
padding: 0 20upx;
&:not(:last-child) {
margin-bottom: 28upx;
}
.label {
font-size: 32upx;
color: #333;
}
.ipt {
flex: 1;
}
.tips-wrap {
--pColor: #e6a23c;
--iColor: #fdf6ec;
padding: 0 28upx;
.content {
display: flex;
align-items: center;
padding: 28upx;
background-color: var(--iColor);
.info {
display: flex;
flex-direction: column;
padding-left: 10px;
gap: 8upx;
.t1 {
font-size: 32upx;
color: var(--pColor);
}
.t2 {
font-size: 24upx;
color: var(--pColor);
}
}
}
}
}
</style>
.form-wrap {
padding: 28upx 28upx 0;
.form {
padding: 28upx;
background-color: #fff;
border-radius: 16upx;
}
.row {
height: 84upx;
display: flex;
gap: 20upx;
align-items: center;
background-color: #fcfcfc;
padding: 0 20upx;
&:not(:last-child) {
margin-bottom: 28upx;
}
.label {
font-size: 32upx;
color: #333;
}
.ipt {
flex: 1;
}
}
}
</style>

View File

@@ -11,26 +11,26 @@
</view>
<view>
<view> <text style="color: red;">*</text> 入库时间 </view>
<view >
<up-datetime-picker
hasInput
v-model="datas.form.inOutDate"
mode="date"
></up-datetime-picker>
<view>
<up-datetime-picker hasInput v-model="datas.form.inOutDate" mode="date"></up-datetime-picker>
</view>
</view>
<view>
<view> <text style="color: red;">*</text> 入库数量 </view>
<view> <input type="number" placeholder="请输入数量" v-model="datas.form.bodyList.inOutNumber" @change="datas.form.bodyList.inOutNumber = $utils.isNumber(datas.form.bodyList.inOutNumber)" name="" id=""> </view>
<view> <input type="number" placeholder="请输入数量" v-model="datas.form.bodyList.inOutNumber"
@change="datas.form.bodyList.inOutNumber = $utils.isNumber(datas.form.bodyList.inOutNumber)"
name="" id=""> </view>
</view>
<view>
<view> <text style="color: red;">*</text>单价 </view>
<view> <input type="number" placeholder="请输入单价(元)" v-model="datas.form.bodyList.purchasePrice" @change="datas.form.bodyList.purchasePrice = $utils.isMoney(datas.form.bodyList.purchasePrice)" name="" id=""> </view>
<view> <input type="number" placeholder="请输入单价(元)" v-model="datas.form.bodyList.purchasePrice"
@change="datas.form.bodyList.purchasePrice = $utils.isMoney(datas.form.bodyList.purchasePrice)"
name="" id=""> </view>
</view>
<view style="justify-content: space-between;">
<view> 单位 </view>
<view> <input type="text" placeholder="请输入单位" v-model="datas.form.bodyList.conUnit" name="" id=""> </view>
<view> <input type="text" placeholder="请输入单位" v-model="datas.form.bodyList.conUnit" name="" id="">
</view>
</view>
<view>
<view> 应付金额 </view>
@@ -43,7 +43,8 @@
<view style="justify-content: space-between;align-items: center;">
<view> 供应商 </view>
<picker @change="changeNowStatusIndex" :value="nowStatusIndex" :range="datas.status">
<view class="color-333" style="height: 84rpx;line-height: 84rpx;">{{datas.status[nowStatusIndex]}}</view>
<view class="color-333" style="height: 84rpx;line-height: 84rpx;">{{datas.status[nowStatusIndex]}}
</view>
</picker>
<uni-icons type="bottom" size="16"></uni-icons>
<view style="color: #318AFE;width: 80rpx;text-align: center;" @tap="toggle"> 新增 </view>
@@ -57,21 +58,32 @@
<up-button type="primary" style="background-color: #318AFE;color: #fff;width: 100%!important;" @tap="sumbit"
:plain="true" text="保存"></up-button>
</view>
<!-- 消息提示 -->
<up-toast ref="uToastRef"></up-toast>
</template>
<script setup>
import { ref, computed, reactive } from 'vue';
import { onShow, onLoad } from '@dcloudio/uni-app';
import {
ref,
computed,
reactive
} from 'vue';
import {
onShow,
onLoad
} from '@dcloudio/uni-app';
import go from '@/commons/utils/go.js';
import dayjs from 'dayjs';
import { getVendorPage } from '@/http/api/vendor.js';
import { consStockIn } from '@/http/api/cons.js';
import {
getVendorPage
} from '@/http/api/vendor.js';
import {
consStockIn
} from '@/http/api/cons.js';
let showStatus = ref(false)
let datas = reactive({
show: false,
@@ -89,13 +101,13 @@
},
item: ""
})
onLoad((options) => {
console.log(options)
datas.item = JSON.parse(options.item)
datas.form = Object.assign(datas.form, datas.item)
// 单位列表
datas.unitList = [ datas.form.conUnit, datas.form.conUnitTwo]
datas.unitList = [datas.form.conUnit, datas.form.conUnitTwo]
datas.form.bodyList.unit = datas.form.defaultUnit
datas.form.bodyList.conName = datas.form.conName
datas.form.bodyList.unitName = datas.form.unitName
@@ -107,7 +119,7 @@
function toggle() {
go.to('PAGES_ADD_SUPPLIER')
}
/**
* 获取供应商列表
*/
@@ -122,9 +134,9 @@
})
})
}
let nowStatusIndex = ref(0)
/**
* 入库时间
* @param {Object} i
@@ -132,7 +144,7 @@
function inOutDateChange(i) {
datas.inOutDate = dayjs(datas.form.inOutDate).format('YYYY-MM-DD')
}
/**
* 供应商选择
* @param {Object} i
@@ -153,14 +165,15 @@
uni.$utils.showToast("请输入必填项")
return
}
datas.form.bodyList.conId = datas.item.id
datas.form.bodyList = [datas.form.bodyList]
datas.form.inOutDate = dayjs(datas.form.inOutDate).format('YYYY-MM-DD')
consStockIn({
...datas.form,
// 供应商id
vendorId: datas.list[nowStatusIndex.value].id,
vendorId: datas.list[nowStatusIndex.value]?datas.list[nowStatusIndex.value].id:'',
amountPayable: datas.form.bodyList[0].inOutNumber * datas.form.bodyList[0].purchasePrice,
}).then(res => {
uni.$utils.showToast("保存成功")
@@ -168,7 +181,7 @@
go.back()
}, 1000)
})
},1000)
}, 1000)
// 获取供应商
const statusHeight = computed(() => {
return 30 * datas.status.length + 14 + 'px'
@@ -194,9 +207,11 @@
list-style: none;
padding: 0;
}
::v-deep.u-input{
border: none!important;
::v-deep.u-input {
border: none !important;
}
.status {
margin: 0 32rpx;
position: absolute;

View File

@@ -31,7 +31,7 @@
<view> 领券后{{ item.validDays }}天过期 </view>
</view>
<view class="JQclass">
<image :src="'/static/coupon/qrcode.svg'" mode="scaleToFill" />
<image :src="qrcode" mode="scaleToFill" />
</view>
</view>
<view class="couponContentListcontent2">
@@ -69,6 +69,7 @@
</template>
<script setup>
import {qrcode} from '@/data/icon.js'
import { reactive, ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import go from '@/commons/utils/go.js'

View File

@@ -42,6 +42,7 @@ async function getProductListAjax() {
mask: true
});
const res = await getProductList();
console.log('res',res);
list.value = res;
} catch (error) {
console.log(error);

File diff suppressed because it is too large Load Diff

View File

@@ -145,7 +145,7 @@
let obj = pageData.types.find(item=> item.value == e)
return obj.name
}
let selArr=[]
getGoods()
/**
* 获取商品列表
@@ -200,7 +200,6 @@
const show = ref(props.modelValue)
let selArr=[]
let $selGoodsMap={}
async function open(arr) {

View File

@@ -1,6 +1,7 @@
<template>
<view>
<view class="default-box-padding bg-fff border-r-18">
<view class="font-bold u-m-b-32">绑定耗材</view>
<view class="u-flex u-row-between">
<view>商品名称</view>
</view>
@@ -38,14 +39,14 @@
</view>
<view class="u-flex u-m-t-16 u-font-24" v-if="item.stockNumber">
<view class="xuhao">
</view>
<view class="u-flex u-flex-1 u-p-l-32 gap-20">库存{{item.stockNumber}}
{{item.conUnit}}
</view>
</view>
</view>
</view>
</view>
<view class="u-flex">
@@ -53,17 +54,34 @@
<up-icon :size="18" color="#318AFE" name="plus-circle-fill"></up-icon>
<view class="u-m-l-16">添加耗材</view>
</view>
</view>
</view>
</view>
<view class="default-box-padding bg-fff border-r-18 u-flex u-row-between u-m-t-32">
<view>当某个耗材的使用库存不足时商品自动售罄</view>
<view class="default-box-padding bg-fff border-r-18 u-m-t-32">
<view class="up-border-bottom u-p-b-32">
<view class="u-flex u-row-between ">
<view class="font-bold"> 自动售罄</view>
<up-switch :size="16" v-model="isAutoSoldStock" :inactive-value="0" :active-value="1"></up-switch>
</view>
<view class=" u-m-t-10">当某个耗材的使用库存不足时商品自动售罄</view>
</view>
<view class=" u-p-t-32">
<view class="">
<view class="font-bold u-m-b-16"> 退菜是否退库存</view>
<up-radio-group v-model="refundMode">
<up-radio v-for="(item,index) in tuiStockTypes" :key="index" :label="item.label"
:name="item.key"></up-radio>
</up-radio-group>
<view class="color-red u-m-t-10">当前店铺退菜退库存规则{{nowRefundRule}}</view>
</view>
</view>
</view>
<view class="bottom">
<my-button type="primary" shape="circle" font-weight="700" @click="save">保存</my-button>
<my-button type="primary" shape="circle" font-weight="700" @click="save">保存</my-button>
<my-button bgColor="#F9F9F9" shape="circle" color="#999" @click="cancel">取消</my-button>
</view>
@@ -72,16 +90,43 @@
</template>
<script setup>
import { ref, reactive, watch, computed, onMounted } from 'vue';
import {
ref,
reactive,
watch,
computed,
onMounted
} from 'vue';
import infoBox from '@/commons/utils/infoBox.js'
import chooseHaocai from './choose-haocai.vue';
import chooseDanwei from './choose-danwei.vue';
import { hasPermission } from '@/commons/utils/hasPermission.js';
import { getConsList } from '@/http/api/cons.js';
import { productBindCons } from '@/http/api/product.js';
import {
hasPermission
} from '@/commons/utils/hasPermission.js';
import {
getConsList
} from '@/http/api/cons.js';
import {
productBindCons
} from '@/http/api/product.js';
const tuiStockTypes = ref([{
label: '退菜退库存',
key: 1
},
{
label: '仅退菜不退库存',
key: 2
},
{
label: '每次询问-退菜后弹窗提示,可手动选择',
key: 3
},
])
const isAutoSoldStock=defineModel('isAutoSoldStock',0)
const refundMode=defineModel('refundMode',1)
const emits = defineEmits(['cancel', 'updateGoods'])
const props = defineProps({
@@ -91,27 +136,36 @@
return {
consList: [],
skuList: [],
type: ''
type: '',
isAutoSoldStock:0,
isRefundStock:1,
}
}
}
})
const pageData = reactive({
isBindGuige: false, //是否绑定至规格
const shopInfo=uni.getStorageSync('shopInfo')
const nowRefundRule=computed(()=>{
if(!shopInfo||!shopInfo.refundMode){
return ''
}
return shopInfo.refundMode==1?'跟随商品分类':'跟随单商品'
})
const pageData = reactive({
isBindGuige: false, //是否绑定至规格
})
let haoCaiList = ref([])
let $haocaiMap = reactive({})
const skuList = ref(props.goods.skuList)
const consList = ref(props.goods.consList||[])
const consList = ref(props.goods.consList || [])
watch(() => props.goods.consList, (newval) => {
consList.value = newval
})
watch(() => props.goods.skuList, (newval) => {
skuList.value = newval
})
onMounted(() => {
init()
})
@@ -126,16 +180,16 @@
}
haoCaiList.value = res
})
}
/**
* 取消耗材绑定
*/
function cancel() {
emits('cancel')
}
/**
* 耗材选择
* @param {Object} newval
@@ -157,7 +211,7 @@
surplusStock: ''
})
}
/**
* 删除商品耗材
* @param {Object} index
@@ -207,7 +261,6 @@
emits('updateGoods')
infoBox.showToast('修改成功')
}
</script>
<style lang="scss" scoped>

View File

@@ -0,0 +1,11 @@
<template>
<view>
<view></view>
</view>
</template>
<script setup>
</script>
<style lang="scss" scoped>
</style>

View File

@@ -31,7 +31,7 @@
<view class="u-flex u-row-between">
<view>上传图片</view>
</view>
<view class="u-m-t-16">
<view class="u-m-t-16" >
<my-up-upload :maxCount="1" :multiple="false" v-model="form.coverImg"></my-up-upload>
</view>
</view>

View File

@@ -6,10 +6,10 @@
<text class="">排序</text>
<text class="u-m-l-20">{{data.sort}}</text>
</view>
<view class="color-333 u-m-l-42 u-flex">
<!-- <view class="color-333 u-m-l-42 u-flex">
<text class="stock u-m-l-4">库存:{{data.stockNumber}}</text>
<up-icon @click="editStock" name="edit-pen" :size="16" :color="$utils.ColorMain"></up-icon>
</view>
</view> -->
</view>
<view>
<!-- <text class="u-font-28 color-666" @click="changePrice">改价</text> -->

View File

@@ -103,7 +103,7 @@
import {
getHistoryOrder
} from '@/http/api/order.js';
import tableStatus from './tableStatus'
const pageData = reactive({
statusShow: false,
hasAjax: false,
@@ -121,7 +121,8 @@
key: '',
label: '全部'
},
...uni.$utils.objToArrary(uni.$dict.tableStatus)
// ...uni.$utils.objToArrary(uni.$dict.tableStatus)
...tableStatus
]
],
statusName: '全部',
@@ -188,8 +189,9 @@
* @param {Object} e
*/
function confirmStatus(e) {
console.log('---',e);
pageData.statusShow = false;
pageData.query.status = e.value[0].key;
pageData.query.status = e.value[0].type;
pageData.statusName = e.value[0].label;
getTable();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,9 @@
<up-image :src="data.coverImg" mode="aspectFill" :width="img.width" :height="img.height"></up-image>
<view class="info u-flex u-row-between u-col-top u-flex-col">
<view class="limit-discount" v-if="is_time_discount">限时折扣</view>
<view class="nowStockerNumber" v-if="data.isAutoSoldStock&&nowStockerNumber<=10&&nowStockerNumber>0">
剩余库存{{nowStockerNumber}}
</view>
<view>
<view>
<text class="up-line-1">{{ data.name }}</text>
@@ -32,7 +34,7 @@
<image src="/pagesCreateOrder/static/images/icon-reduce.svg" class="icon" mode="">
</image>
</view>
<view class="u-font-32" >
<view class="u-font-32">
{{ data.chooseNumber.toFixed(2) }}
</view>
@@ -56,7 +58,7 @@
<view class="isSellout" v-else-if="data.isSoldStock == 1">
<image class="isSellout_icon" src="/pagesCreateOrder/static/images/no-sold.svg" mode=""></image>
</view>
<view class="isSellout" v-else-if="data.isStock == 1 && data.stockNumber <= 0">
<view class="isSellout" v-else>
<image class="isSellout_icon" src="/pagesCreateOrder/static/images/no-stock.svg" mode=""></image>
</view>
</template>
@@ -107,6 +109,10 @@
return {};
},
},
consStockList: {
type: Array,
default:[]
}
});
//判断是否是时间折扣商品
@@ -156,12 +162,54 @@
return false;
}
return (
(item.isStock == 1 && item.stockNumber <= 0) ||
!consStockisFull(item) ||
item.isSoldStock == 1 ||
item.isSale == 0 ||
!isProductAvailable(item.days, item.startTime, item.endTime)
);
});
const stockNumber=computed(()=>{
})
// 1. 筛选匹配的耗材列表,增加对应商品数量
const conslist=computed(()=>{
if(props.consStockList.length<=0){
return []
}
return props.consStockList.filter(v => {
return props.data.consList.find(i =>{
return i.consInfoId == v.consId
});
}).map(v=>{
const cItem=props.data.consList.find(c=>c.consInfoId==v.consId)
const goodsNumber=Math.floor(v.stockNumber/cItem.surplusStock)
console.log('props.data',props.data.name);
console.log('goodsNumber',goodsNumber);
return {
...v,
goodsNumber
}
}).sort((a,b)=>{
return a.goodsNumber-b.goodsNumber
})
})
const nowStockerNumber=computed(()=>{
return conslist.value[0]?conslist.value[0].goodsNumber:9999
})
function consStockisFull(item) {
if(!item.isAutoSoldStock){
return true
}
// 4. 判断:最小库存 > 每份消耗库存 → 返回 true否则 false
if (nowStockerNumber.value>=1) {
return true;
} else {
return false;
}
}
// 判断商品是否在可售时间内
function isProductAvailable(sellDaysStr, startTimeStr, endTimeStr) {
// 将后端返回的字符串转换为数组
@@ -306,4 +354,14 @@
color: rgba(255, 255, 255, 0.8);
text-decoration: line-through;
}
.nowStockerNumber{
position: absolute;
left: 24rpx;
bottom: 80rpx;
background-color: rgba(255, 255, 255, .8);
color: red;
padding: 4rpx 8rpx;
font-size: 24rpx;
border-radius: 4rpx ;
}
</style>

View File

@@ -36,9 +36,7 @@
</view>
</scroll-view>
<scroll-view :scroll-top="data.scrollRightTop" scroll-y scroll-with-animation class="right-box"
@scroll="rightScroll"
@scrolltoupper="scrolltoupper"
>
@scroll="rightScroll" @scrolltoupper="scrolltoupper">
<view class="page-view u-p-l-24">
<view class="list-tight-top">
<template v-if="lingshi.show">
@@ -62,7 +60,7 @@
<view class="item-container">
<view class="thumb-box" v-for="(goodsItem, goodsIndex) in item.foods" :key="goodsIndex">
<list-goods-item :limitTimeDiscount="data.limitTimeDiscount"
@chooseGuige="chooseGuige($event, index)"
:consStockList="consStockList" @chooseGuige="chooseGuige($event, index)"
@add="goodsUpdate($event, index, true)"
@reduce="goodsUpdate($event, index, false)" @tapweigh="tapweigh($event, index)"
:index="goodsIndex" :data="goodsItem"></list-goods-item>
@@ -81,8 +79,8 @@
<view class="u-flex u-m-t-20 u-flex-wrap u-row-between">
<view class="u-m-b-30" v-for="(goodsItem, goodsIndex) in searchResult" :key="goodsIndex">
<list-goods-item :img="{ width: '330rpx', height: '330rpx' }"
:limitTimeDiscount="data.limitTimeDiscount"
@chooseGuige="chooseGuige(goodsItem.goodsIndex, goodsItem.index)"
:consStockList="consStockList" :limitTimeDiscount="data.limitTimeDiscount"
@chooseGuige="chooseGuige(goodsItem.goodsIndex, goodsItem.index)"
@add="searchGoodsUpdate(goodsItem, goodsIndex, true)"
@reduce="searchGoodsUpdate(goodsItem, goodsIndex, false)"
@tapweigh="tapweigh(goodsItem.goodsIndex, goodsItem.index)"
@@ -98,8 +96,7 @@
<view class="bottom w-full">
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :table="data.table"
:data="cars" :orderInfo="data.orderInfo" :limitTimeDiscount="data.limitTimeDiscount"
@changeNumber="goodsChangeNumber"
@clear="cleaCart"></my-car>
@changeNumber="goodsChangeNumber" @clear="cleaCart"></my-car>
</view>
<!-- 套餐选择规格 -->
<taocanModel ref="taocanModelRef" @confirm="taocanConfirm" :goodsData="selGoods"></taocanModel>
@@ -115,9 +112,10 @@
<text>历史订单</text>
<text class="num">{{ data.historyOrderNum }}</text>
</view>
<!-- 修改购物车数量 -->
<popupChangeNumber v-model="popupChangeNumberData.show" :goods="popupChangeNumberData.data" @confirm="carsNumberChange"></popupChangeNumber>
<popupChangeNumber v-model="popupChangeNumberData.show" :goods="popupChangeNumberData.data"
@confirm="carsNumberChange"></popupChangeNumber>
</view>
</template>
<script setup>
@@ -144,12 +142,12 @@
stickCount
} from '@/http/api/product/stick.js'
import popupChangeNumber from './components/popup-change-number.vue'
const popupChangeNumberData=reactive({
show:false,
data:null
const popupChangeNumberData = reactive({
show: false,
data: null
})
import guigeModel from "./components/guige";
import taocanModel from "./components/taocanModel.vue";
import weighItem from "./components/weigh.vue";
@@ -174,8 +172,8 @@
limitTimeDiscount
} from "@/http/api/market/limitTimeDiscount.js";
provide("yskUtils", yskUtils);
const shopInfo = reactive({}) ;
Object.assign(shopInfo,uni.getStorageSync("shopInfo"))
const shopInfo = reactive({});
Object.assign(shopInfo, uni.getStorageSync("shopInfo"))
provide("shopInfo", uni.getStorageSync("shopInfo"));
import {
@@ -196,6 +194,9 @@
cancelOrder,
rmPlaceOrder,
} from "@/http/api/order.js";
import {
getConsStock
} from '@/http/api/cons.js'
const modal = reactive({
key: "",
@@ -293,7 +294,7 @@
})
);
}
// init()
xiadanClick();
@@ -349,6 +350,24 @@
let $originGoods = [];
let $category = [];
const consStockList = ref([])
function getCons() {
return new Promise((resolve, reject) => {
try {
getConsStock({
shopId: uni.getStorageSync("shopInfo").id
}).then(res => {
consStockList.value = res || []
console.log('consStockList', consStockList.value);
resolve()
})
} catch (err) {
reject()
}
})
}
async function init() {
if (option.type == "add") {
setTabBar($category, $originGoods, []);
@@ -356,7 +375,7 @@
let shopInfoRes = await getShopInfo({
id: uni.getStorageSync("shopInfo").id
});
Object.assign(shopInfo,shopInfoRes)
Object.assign(shopInfo, shopInfoRes)
uni.setStorageSync("shopInfo", shopInfoRes);
// 获取分类数据
let categoryRes = await categoryPage({
@@ -364,6 +383,8 @@
size: 300
});
$category = categoryRes.records;
// 获取耗材数据
await getCons()
// 获取商品数据
const goodsRes = await getGoods();
const goods = goodsRes.filter((v) => {
@@ -387,6 +408,8 @@
initCart();
}
const allHistoryOrder = ref([])
/**
* 获取订单详情
*/
@@ -409,13 +432,13 @@
console.log("data.historyOrder===", data.historyOrder);
let allHistoryOrder = data.historyOrder.map((item) => {
allHistoryOrder.value = data.historyOrder.map((item) => {
return [...item.info];
});
}).flat();
// console.log('allHistoryOrder===', allHistoryOrder.flat());
data.historyOrderNum = 0;
allHistoryOrder.flat().map((item) => {
allHistoryOrder.value.map((item) => {
data.historyOrderNum += item.num;
});
// console.log('data.historyOrderNum===', data.historyOrderNum);
@@ -741,7 +764,22 @@
}
// initCart()
}
// 封装成 Promise 的确认弹窗
const showConfirmModal = (title, content) => {
return new Promise((resolve) => {
uni.showModal({
title: title,
content: content,
showCancel: true,
cancelText: '取消添加',
confirmText: '继续',
success(res) {
// 确认返回 true取消/关闭返回 false
resolve(res.confirm === true);
}
});
});
};
/**
* 菜品操作
* @param {Object} foodsindex
@@ -800,6 +838,34 @@
//更新
let cartItem = cars[goodsInCarIndex];
let number = isAdd ? cartItem.number + 1 : +cartItem.number - 1;
if (isAdd) {
if (allHistoryOrder.value.find(v => v.productId == $goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜品名称:《' + $goods.name + '》'
);
if (!isConfirm) {
return
}
}else{
if (number == 2) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'购物车已有该商品,请确认是否重复',
'菜品名称:《' + $goods.name + '》'
);
if (!isConfirm) {
return
}
}
}
}
if (!isAdd) {
if (number === 0 || number < suitNum) {
//移除
@@ -828,6 +894,7 @@
data.isGoodsAdd = false;
setSearchGoods(searchGoodsIndex, number);
} else {
// 不影响之前的代码 称重suit单独处理
if ($goods.type == "weight" && showCurrentInput) {
suitNum = showCurrentInput;
@@ -839,6 +906,16 @@
return;
}
}
if (allHistoryOrder.value.find(v => v.productId == $goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜品名称:《' + $goods.name + '》'
);
if (!isConfirm) {
return
}
}
// 套餐和单规格
if ($goods.groupType != 1) {
//增加
@@ -858,17 +935,17 @@
return;
}
}
function goodsChangeNumber(e){
function goodsChangeNumber(e) {
console.log(e);
popupChangeNumberData.data=e;
popupChangeNumberData.show=true
popupChangeNumberData.data = e;
popupChangeNumberData.show = true
}
/**
* socket通知购物车商品数量修改处理
*/
@@ -937,8 +1014,7 @@
tabbarItem.foods.find((v) => v.id == e.goods.product_id);
}
});
$sku = !e.goods.product_id ?
{
$sku = !e.goods.product_id ? {
suitNum: 1
} :
$goods.skuList.find((v) => v.id == e.goods.sku_id);
@@ -1018,13 +1094,22 @@
* @param {Object} skuList
*/
function returnSelGoodsSkuList(selectSpecInfo) {
// 👇 修复:如果是字符串,转成对象
if (typeof selectSpecInfo === 'string') {
selectSpecInfo = JSON.parse(selectSpecInfo);
}
let specInfo = [];
console.log('selectSpecInfo', selectSpecInfo);
for (var key in selectSpecInfo) {
console.log('key', key); // 现在会正确打印:口味、汤
specInfo.push({
name: key,
value: selectSpecInfo[key],
});
}
let result = specInfo.map((v, index) => {
return {
...v,
@@ -1062,9 +1147,30 @@
} = res;
let carGoods = cars[index];
let cartId = carGoods.id;
let newNumber = carGoods.number * 1 + suitNum;
let suitNum = goods.skuList[0].suitNum || 1;
let newNumber = carGoods.number * 1 + suitNum;
if (allHistoryOrder.value.find(v => v.productId == goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜品名称:《' + goods.name + '》'
);
if (!isConfirm) {
return
}
}else{
if (newNumber == 2 && carGoods.number < newNumber) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'购物车已有该商品,请确认是否重复?',
'菜品名称:《' + goods.name + '》'
);
if (!isConfirm) {
return
}
}
}
editCart({
id: cartId,
number: newNumber,
@@ -1079,6 +1185,17 @@
);
data.isGoodsAdd = false;
} else {
if (allHistoryOrder.value.find(v => v.productId == goods.id)) {
// 等待用户点击
const isConfirm = await showConfirmModal(
'该商品已下单过,请确认是否重复',
'菜品名称:《' + goods.name + '》'
);
if (!isConfirm) {
return
}
}
//添加
editCart({
number: suitNum,
@@ -1106,8 +1223,7 @@
return carsGoods.sku_id == sku_id && carsGoods.product_id == product_id;
});
const carGoods = cars[goodsInCarIndex];
return carGoods ?
{
return carGoods ? {
index: goodsInCarIndex,
carGoods,
} :
@@ -1359,39 +1475,39 @@
function toStick() {
uni.chooseImage({
count: 1, //默认9
sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
sourceType: ["album", "camera "],
success: async function (res) {
uni.showLoading({
title: "上传中",
});
console.log(res);
const fileRes = await stickCount(res.tempFiles[0]);
console.log(fileRes)
uni.hideLoading();
if (fileRes) {
uni.setStorageSync('stickData',{
table:data.table,
orderInfo:data.orderInfo,
limitTimeDiscount:data.limitTimeDiscount
})
go.to("PAGES_CREATE_ORDER_STICK", {
tableCode: data.table.tableCode,
number:fileRes,
isCreateOrderToDetail:isCreateOrderToDetail.value,
count: 1, //默认9
sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
sourceType: ["album", "camera "],
success: async function(res) {
uni.showLoading({
title: "上传中",
});
} else {
uni.showToast({
title: "上传失败",
icon: "none",
});
}
},
console.log(res);
const fileRes = await stickCount(res.tempFiles[0]);
console.log(fileRes)
uni.hideLoading();
if (fileRes) {
uni.setStorageSync('stickData', {
table: data.table,
orderInfo: data.orderInfo,
limitTimeDiscount: data.limitTimeDiscount
})
go.to("PAGES_CREATE_ORDER_STICK", {
tableCode: data.table.tableCode,
number: fileRes,
isCreateOrderToDetail: isCreateOrderToDetail.value,
});
} else {
uni.showToast({
title: "上传失败",
icon: "none",
});
}
},
});
}
/**
@@ -1425,7 +1541,7 @@
* @param {Object} index
*/
async function swichMenu(index) {
if (data.arr.length !=data.tabbar.length) {
if (data.arr.length != data.tabbar.length) {
await getMenuItemTop();
}
if (index == data.current) return;
@@ -1438,10 +1554,10 @@
// data.current = index;
// leftMenuStatus(index);
// });
data.scrollRightTop = data.arr[index] + data.topZhanwei;
console.log('scrollRightTop',data.scrollRightTop );
console.log('scrollRightTop', data.scrollRightTop);
data.current = index;
leftMenuStatus(index);
}
@@ -1518,29 +1634,29 @@
arr.push(rect.top - rects[0].top);
});
data.arr = arr;
console.log('每一项高度',data.arr);
console.log('每一项高度', data.arr);
resolve();
})
.exec();
});
}
function scrolltoupper(){
function scrolltoupper() {
data.current = 0;
}
/**
* 右边菜单滚动
* @param {Object} e
*/
async function rightScroll(e) {
data.oldScrollTop = e.detail.scrollTop;
if(e.detail.scrollTop<=0||e.detail.scrollTop<data.arr[1]){
if (e.detail.scrollTop <= 0 || e.detail.scrollTop < data.arr[1]) {
data.current = 0;
isTabClickOver = true;
return
return
}
if (data.arr.length == 0) {
await getMenuItemTop();

View File

@@ -1,65 +1,87 @@
<template>
<my-model title="退菜" ref="model" @close="onModelClose" @open="onModelOpen">
<template #desc>
<view class="u-p-30 u-text-left">
<view>
{{data.productName}}
</view>
<view class="u-flex u-m-t-32" :class="{'gray':data.productId=='-999'}">
<up-number-box :min="0" :max="maxNum" :buttonSize="44" v-model="number" integer
:disabled="data.productId=='-999'">
<template #minus>
<view class="minus number-box-btn"></view>
</template>
<template #input>
<view class="u-flex-1 u-row-center u-text-center input">
<up-input :disabled="data.productId=='-999'" @change="parseIntNumber($event,false)"
@blur="parseIntNumber($event,true)" v-model="number" border="none"
type="digit"></up-input>
</view>
</template>
<template #plus>
<view class="plus number-box-btn">
<up-icon v-if="data.productId=='-999'" name="plus" color="#ccc" size="16"
bold></up-icon>
<up-icon v-else name="plus" color="#999" size="16" bold></up-icon>
</view>
</template>
</up-number-box>
</view>
<view class="u-m-t-32">
<view class="u-font-24">
<text class="color-999">退菜理由</text>
<text class="color-red">*</text>
<view>
<my-model title="退菜" ref="model" @close="onModelClose" @open="onModelOpen">
<template #desc>
<view class="u-p-30 u-text-left">
<view>
{{data.productName}}
</view>
<view class="u-flex u-flex-wrap u-m-t-24">
<view class="u-flex u-m-r-16 u-m-b-16" v-for="(item,index) in tags" :key="index">
<up-tag @click="changeTagSel(item)" :text="item.label" plain borderColor="#E6FOFF"
color="#318AFE" v-if="item.checked"> </up-tag>
<up-tag @click="changeTagSel(item)" borderColor="#E5E5E5" color="#666" :text="item.label"
plain v-else> </up-tag>
<view class="u-flex u-m-t-32" :class="{'gray':data.productId=='-999'}">
<up-number-box :min="0" :max="maxNum" :buttonSize="44" v-model="number" integer
:disabled="data.productId=='-999'">
<template #minus>
<view class="minus number-box-btn"></view>
</template>
<template #input>
<view class="u-flex-1 u-row-center u-text-center input">
<up-input :disabled="data.productId=='-999'" @change="parseIntNumber($event,false)"
@blur="parseIntNumber($event,true)" v-model="number" border="none"
type="digit"></up-input>
</view>
</template>
<template #plus>
<view class="plus number-box-btn">
<up-icon v-if="data.productId=='-999'" name="plus" color="#ccc" size="16"
bold></up-icon>
<up-icon v-else name="plus" color="#999" size="16" bold></up-icon>
</view>
</template>
</up-number-box>
</view>
<view class="u-m-t-32">
<view class="u-font-24">
<text class="color-999">退菜理由</text>
<text class="color-red">*</text>
</view>
<view class="u-flex u-flex-wrap u-m-t-24">
<view class="u-flex u-m-r-16 u-m-b-16" v-for="(item,index) in tags" :key="index">
<up-tag @click="changeTagSel(item)" :text="item.label" plain borderColor="#E6FOFF"
color="#318AFE" v-if="item.checked"> </up-tag>
<up-tag @click="changeTagSel(item)" borderColor="#E5E5E5" color="#666"
:text="item.label" plain v-else> </up-tag>
</view>
</view>
<view class="u-m-t-24">
<up-textarea v-model="form.note" placeholder="备注"></up-textarea>
</view>
</view>
<view class="u-m-t-24">
<up-textarea v-model="form.note" placeholder="备注"></up-textarea>
</view>
</template>
<template #btn>
<view class="u-p-t-18 u-p-l-30 u-p-r-30 u-p-b-10">
<my-button box-shadow shape="circle" @tap="confirm">确认退菜</my-button>
<view class="u-m-t-10">
<my-button @tap="onModelClose" shape="circle" bgColor="#fff" type="cancel"
box-shadow>取消</my-button>
</view>
</view>
</view>
</template>
<template #btn>
<view class="u-p-t-18 u-p-l-30 u-p-r-30 u-p-b-10">
<my-button box-shadow shape="circle" @tap="confirm">确认退菜</my-button>
<view class="u-m-t-10">
<my-button @tap="onModelClose" shape="circle" bgColor="#fff" type="cancel" box-shadow>取消</my-button>
</template>
</my-model>
<up-modal :show="confirmModal.show" title="提示" @close="confirmModalClose" @cancel="confirmModalClose"
@confirm="confirmModalConfirm" showCancelButton>
<view>
<view>
<up-radio-group v-model="confirmModal.selRefundStock">
<up-radio v-for="(item,index) in confirmModal.refundStocks" :key="index" :label="item.name"
:name="item.key"></up-radio>
</up-radio-group>
</view>
</view>
</up-modal>
</view>
</template>
</my-model>
</template>
<script setup>
import { reactive, ref, watch } from 'vue';
import {
reactive,
ref,
watch
} from 'vue';
import infoBox from '@/commons/utils/infoBox.js'
const emits = defineEmits(['update:show', 'confirm'])
const props = defineProps({
@@ -76,6 +98,22 @@
default: false
}
})
const confirmModal = reactive({
show: false,
selRefundStock: false,
refundStocks: [{
name: '已上菜(仅退菜不退库存)',
key: false
}, {
name: '未上菜(退菜后退库存)',
key: true,
}]
})
function confirmModalClose() {
confirmModal.show = false
confirmModal.selRefundStock = false
}
const form = reactive({
note: ''
})
@@ -83,7 +121,7 @@
let modelShow = ref(props.show)
let number = ref(0)
let maxNum = ref(0)
const tags = ref([{
label: "点错",
checked: false
@@ -109,14 +147,14 @@
close()
}
})
function parseIntNumber(val, isNow) {
console.log(val)
let newval = val * 1
if (newval > props.data.num - props.data.returnNum) {
newval = props.data.num - props.data.returnNum
}
if (isNow) {
number.value = newval * 1
return
@@ -129,7 +167,7 @@
function changeTagSel(item) {
item.checked = !item.checked
}
function toggleModelShow(show) {
modelShow.value = show ? true : false
}
@@ -157,11 +195,51 @@
})
form.note = ''
}
import {
getProductDetail
} from '@/http/api/product.js'
import {
getCategoryDetail
} from '@/http/api/cateGory.js'
async function getGoodsCategory(goods) {
const res = await getProductDetail(goods.productId)
if (res) {
console.log('res', res);
const res1 = await getCategoryDetail(res.categoryId)
return res1
}
uni.showToast({
title: '获取该商品信息数据失败',
icon: 'none'
})
return null
}
function confirmModalConfirm() {
refundGoods()
confirmModalClose()
}
function refundGoods() {
const selTag = tags.value.filter(item => item.checked).map(item => item.label).join(",")
const note = selTag + (form.note.length > 0 ? "," + form.note : "");
let par = {
orderId: props.data.orderId,
refundAmount: number.value * props.data.unitPrice,
refundReason: note,
refundStock: confirmModal.selRefundStock,
refundDetails: [{
id: props.data.id,
returnAmount: number.value * props.data.unitPrice,
num: number.value,
}],
}
emits('confirm', par)
}
/**
* 确认退菜
*/
function confirm() {
async function confirm() {
const selTag = tags.value.filter(item => item.checked).map(item => item.label).join(",")
const note = selTag + (form.note.length > 0 ? "," + form.note : "");
console.log({
@@ -171,17 +249,22 @@
if (!note) {
return infoBox.showToast("请输入退菜原因");
}
let par = {
orderId: props.data.orderId,
refundAmount: number.value * props.data.unitPrice,
refundReason: note,
refundDetails: [{
id: props.data.id,
returnAmount: number.value * props.data.unitPrice,
num: number.value,
}],
const shopInfo = uni.getStorageSync('shopInfo')
if (shopInfo.refundMode == 1) {
const res = await getGoodsCategory(props.data)
if (res.refundMode === 3) {
confirmModal.show = true
return
}
}
emits('confirm', par)
if (shopInfo.refundMode == 2) {
const res = await getProductDetail(props.data.productId)
if (res.refundMode === 3) {
confirmModal.show = true
return
}
}
refundGoods()
}
</script>

View File

@@ -23,10 +23,15 @@
</template>
<template v-else>
<template v-if="orderDetail.info.status=='unpaid'">
<view class="u-flex-1">
<my-button @tap="diancan" color="#fff" bgColor="rgb(57,53,52)" borderRadius="100rpx 0 0 100rpx" fontWeight="700"
shape="circle" plain type="primary">加菜</my-button>
</view>
<view class="u-flex-1" style="border-right: 1px solid #fff;">
<my-button @tap="transformTable" borderRadius="0 0 0 0" shape="circle" fontWeight="700"
type="primary">转桌</my-button>
</view>
<view class="u-flex-1">
<my-button @tap="toPay" borderRadius="0 100rpx 100rpx 0" shape="circle" fontWeight="700"
type="primary">结账</my-button>
@@ -37,6 +42,10 @@
</view>
<tuicai-vue @confirm="tuicaiConfirm" v-model:show="tuicai.show" :data="tuicai.selGoods"></tuicai-vue>
<changeTable v-model="changeTableShow" :nowCartData="[]" :goodsList="orderDetail.info?orderDetail.info.detailMap:[]" :order="orderDetail.info"
@update="changeTableUpdate"
></changeTable>
</view>
</template>
@@ -60,6 +69,12 @@
import { shopUserDetail } from '@/http/api/shopUser.js'
import { getShopInfo } from '@/http/api/shop.js'
import changeTable from '@/components/change-table.vue'
const changeTableShow=ref(false)
function transformTable(){
changeTableShow.value=true
}
const tuicai = reactive({
show: false,
isSeatFee: false,
@@ -128,6 +143,8 @@
item.unitPrice = uni.$utils.isGoodsPrice(item,user.value)
})
})
console.log('orderDetail.goodsList',orderDetail.goodsList);
console.log('orderDetail.info',orderDetail.info);
orderDetail.info = res
}
@@ -316,7 +333,13 @@
})
}
function changeTableUpdate(allMerge){
if(allMerge===1){
uni.navigateBack()
}else{
getOrderDetail()
}
}
</script>
<style lang="scss" scoped>

View File

@@ -12,7 +12,8 @@
</view>
<view class="u-flex">
<view>
<text :class="[data.status]">{{$dict.getDiceName(data.status,'orderStatus')}}{{data.refundType?'['+$dict.getDiceName(data.refundType,'refundType')+']':''}}</text>
<text
:class="[data.status]">{{$dict.getDiceName(data.status,'orderStatus')}}{{data.refundType?'['+$dict.getDiceName(data.refundType,'refundType')+']':''}}</text>
</view>
<view class="line"></view>
<view class=" color-main">
@@ -33,13 +34,18 @@
<view class="" v-for="(item,index) in data.goods" :key="index">
<view class="u-flex u-row-between u-col-top u-m-t-32" v-if="item.productId!=-999">
<view>
<view class=""> {{item.productName}}</view>
<view class="">
<text>{{item.productName}}</text>
</view>
<view class="color-999 u-font-24 u-m-t-8">
{{item.skuName}}
</view>
</view>
<view class="u-flex u-flex-1 u-row-right" style="align-items: center;">
<view style="margin-right: 10rpx;">×{{item.num}}</view>
<view style="margin-right: 10rpx;">
<text>×{{item.num}}</text>
<text class="color-red u-m-l-10 font-bold" v-if="item.returnNum">(退{{item.returnNum}})</text>
</view>
<view class="u-text-right u-relative" :style="computedPriceStyle()">
<text>{{item.unitPrice}}</text>
</view>
@@ -56,7 +62,7 @@
<view class="no-wrap u-m-r-32">打包费</view>
<view>{{data.packFee||0}}</view>
</view>
<view style="height: 32rpx;" ></view>
<view style="height: 32rpx;"></view>
<view class="u-flex u-row-between u-col-top" v-if="data.seatInfo&&data.seatInfo.priceAmount>0">
<view class="no-wrap u-m-r-32">{{data.seatInfo.productName}}</view>
<view>{{data.seatInfo.priceAmount}}</view>
@@ -98,8 +104,13 @@
</template>
<script setup>
import { computed, reactive, ref, watch } from 'vue';
import {
computed,
reactive,
ref,
watch
} from 'vue';
import dayjs from 'dayjs';
import go from '@/commons/utils/go.js'
@@ -126,8 +137,8 @@
let $goodsMap = {}
let goosZhonglei = ref(0)
let goodsNumber = ref(0)
let originAmount = computed(()=>{
let total=0;
let originAmount = computed(() => {
let total = 0;
for (let i in props.data.goods) {
const goods = props.data.goods[i]
if ($goodsMap.hasOwnProperty(goods.productId)) {
@@ -142,17 +153,17 @@
return total
})
const priceSize = 9
let minWidth=ref(36)
let minWidth = ref(36)
function computedPriceStyle() {
return {
'min-width':minWidth.value + 'px'
'min-width': minWidth.value + 'px'
}
}
function goodsMapInit() {
}
goodsMapInit()
watch(() => props.data.goods.length, (newval) => {

View File

@@ -392,7 +392,6 @@ async function init() {
}
Object.assign(order, orderRes);
pageData.goodsList = objToArrary(orderRes.detailMap);
// console.log("order===",order)
// console.log("pageData.user===",pageData.user)
// 获取用户信息
@@ -412,6 +411,7 @@ async function init() {
}
pageData.seatNum = order.seatNum;
seatFeeConfig.personCount = order.seatNum;
console.log('seatFeeConfig',seatFeeConfig);
}
/**
@@ -464,7 +464,7 @@ const pointDeductionRule = reactive({
const seatFeeConfig = reactive({
pricePerPerson: pageData.shopInfo.tableFee || 0,
personCount: 0, //就餐人数
isEnabled: !pageData.shopInfo.isTableFee
isEnabled: !pageData.shopInfo.isTableFee,
});
//使用积分数量
const userPoints = ref(0);
@@ -517,7 +517,7 @@ const orderExtraConfig = computed(() => {
memberDiscountRate: 1,
newUserDiscount: newUserDiscount.value,
fullReductionActivities: fullReductionActivities.value,
currentDinnerType: options.dinnerType,
currentDinnerType: options.dinnerType||order.dineMode,
isFreeDine: false, //霸王餐
freeDineConfig: freeDineConfig.value,
limitTimeDiscount: order.limitRate,
@@ -528,7 +528,7 @@ const orderExtraConfig = computed(() => {
const orderCostSummary = computed(() => {
const costSummary = yskUtils.OrderPriceCalculator.calculateOrderCostSummary(
pageData.goodsList,
options.dinnerType,
(options.dinnerType||order.dineMode),
selCoupon.value,
activityList.value,
orderExtraConfig.value,
@@ -633,6 +633,7 @@ watch(
);
function getPayParam() {
const dinnerType=options.dinnerType||order.dineMode
let params = {
shopId: uni.getStorageSync('shopInfo').id || '',
orderId: order.id,
@@ -646,7 +647,7 @@ function getPayParam() {
roundAmount: 0, //抹零金额 减免多少钱
pointsDiscountAmount: orderCostSummary.value.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
pointsNum: orderCostSummary.value.pointUsed, //(扣除各类折扣 enable_deduction后使用)
seatNum: options.dinnerType == 'dine-in' ? seatFeeConfig.personCount : 0, //用餐人数
seatNum: dinnerType == 'dine-in' ? seatFeeConfig.personCount : 0, //用餐人数
newCustomerDiscountAmount: orderCostSummary.value.newUserDiscount, //新客立减
newCustomerDiscountId: orderCostSummary.value.newUserDiscount > 0 ? newUserDiscountRes.value.id : '',

View File

@@ -2,16 +2,19 @@
<view class="min-page bg-gray u-p-30">
<view class="bg-fff u-p-l-30 u-p-r-30 ">
<view class="myTabs u-m-t-20">
<my-tabs :list="pageData.tabsList" :modelValue="pageData.tabsIndex" :textKey="'label'" @change="tabsChange"></my-tabs>
<my-tabs :list="pageData.tabsList" :modelValue="pageData.tabsIndex" :textKey="'label'"
@change="tabsChange"></my-tabs>
</view>
</view>
<view v-if="pageData.tabsIndex == 2" class="bg-fff u-p-24 border-r-12 u-flex u-row-between" style="margin-top: 30rpx;">
<up-input type="digit" placeholder="请输入退款金额" @change="parseIntNumber($event)" border="surround" v-model="pageData.modify" >
<view v-if="pageData.tabsIndex == 2" class="bg-fff u-p-24 border-r-12 u-flex u-row-between"
style="margin-top: 30rpx;">
<up-input type="digit" placeholder="请输入退款金额" @change="parseIntNumber($event)" border="surround"
v-model="pageData.modify">
<template #prefix>
<up-text text="¥" margin="0 3px 0 0" type="tips" ></up-text>
</template>
</up-input>
<up-text text="¥" margin="0 3px 0 0" type="tips"></up-text>
</template>
</up-input>
</view>
<view class="u-m-t-24 u-font-24 u-font-24">
<text class="color-red">*</text>
@@ -27,7 +30,7 @@
</view>
<template v-if="item.productId=='-999'">
<view class="u-flex">
<view class="color-red" >{{item.priceAmount}}</view>
<view class="color-red">{{item.priceAmount}}</view>
<view class="u-flex u-m-l-32 u-col-center">
<view class="u-m-l-28 u-m-r-28">x{{item.number}}</view>
</view>
@@ -47,33 +50,33 @@
</view>
</view>
<template v-if="!option.userCouponId">
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between" >
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between">
<view>支付金额</view>
<view>
{{to2(orderDetail.info.payAmount)}}
</view>
</view>
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between" >
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between">
<view>剩余可退金额</view>
<view class="color-red">
{{to2(orderDetail.info.payAmount - orderDetail.info.refundAmount)}}
</view>
</view>
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between" >
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between">
<view>退款金额</view>
<view class="color-red">
{{to2(pageData.tabsIndex == 1 ? alltuikuanPrice : (pageData.tabsIndex == 2 ? pageData.modify : tuikuanPrice))}}
</view>
</view>
</template>
<!-- <view class="bg-fff u-p-24 border-r-12 u-m-t-32">
<view>退回优惠券</view>
<view class="u-font-24 color-999 u-m-t-16" v-if="!option.userCouponId">
该订单未使用优惠券
</view>
</view> -->
<view class="bg-fff u-p-24 border-r-12 u-m-t-32">
<view>
<text class="color-red">*</text>
@@ -96,35 +99,67 @@
:color="$utils.ColorMain"></up-button>
</view>
<confirmRefundPopup ref="refundPopup" />
<up-modal :show="confirmModal.show" title="提示" @close="confirmModalClose" @cancel="confirmModalClose"
@confirm="confirmModalConfirm" showCancelButton>
<view>
<view>
<up-radio-group v-model="confirmModal.selRefundStock">
<up-radio v-for="(item,index) in confirmModal.refundStocks" :key="index" :label="item.name"
:name="item.key"></up-radio>
</up-radio-group>
</view>
</view>
</up-modal>
</view>
</template>
<script setup>
import { computed, reactive, ref, watch } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import {
computed,
reactive,
ref,
watch
} from 'vue';
import {
onLoad,
onShow
} from '@dcloudio/uni-app';
import confirmRefundPopup from './components/confirmRefundPopup.vue';
import {hasPermission} from '@/commons/utils/hasPermission.js'
import { refundOrder } from '@/http/api/order.js'
import { mathFloorPrice } from '@/commons/utils/goodsUtil.js'
import {
hasPermission
} from '@/commons/utils/hasPermission.js'
import {
refundOrder
} from '@/http/api/order.js'
import {
mathFloorPrice
} from '@/commons/utils/goodsUtil.js'
let note = ref('')
const tuikuan = reactive({
list: ['点错', '数量点错', '客人要求', '协商退费'],
sel: -1
})
const pageData = reactive({
tabsList: [
{label: '部分退款', value: 0},
{label: '全部退款', value: 1},
{label: '自定义退款', value: 2},
tabsList: [{
label: '部分退款',
value: 0
},
{
label: '全部退款',
value: 1
},
{
label: '自定义退款',
value: 2
},
],
tabsIndex: 0,
modify: '',
})
const option=reactive({
productId:'-999'
const option = reactive({
productId: '-999'
})
const orderDetail = reactive({
goodsList: [],
@@ -134,46 +169,47 @@
}
})
const refundPopup = ref(null);
onLoad((opt) => {
orderDetail.info = JSON.parse(opt.orderInfo)
orderDetail.goodsList = JSON.parse(opt.goodsList)
option.productId = orderDetail.goodsList[0].productId
option.orderId = orderDetail.goodsList[0].orderId
})
/**
* tabs切换
* @param {Object} i
*/
function tabsChange(i) {
pageData.tabsIndex = pageData.tabsList[i].value
if( pageData.tabsIndex == 0){ // 部分退款
if (pageData.tabsIndex == 0) { // 部分退款
orderDetail.goodsList.map(v => {
v.number = '0.00'
})
}
if( pageData.tabsIndex == 1){ // 全部退款
if (pageData.tabsIndex == 1) { // 全部退款
orderDetail.goodsList.map(v => {
v.number = v.num.toFixed(2)
})
}
if( pageData.tabsIndex == 2){ // 自定义退款
if (pageData.tabsIndex == 2) { // 自定义退款
orderDetail.goodsList.map(v => {
v.number = '0.00'
})
}
}
function changeTuiKuanSel(i) {
tuikuan.sel = i
}
function parseIntNumber (e) {
if ( e > (orderDetail.info.payAmount - orderDetail.info.refundAmount) ) {
setTimeout(()=>{
function parseIntNumber(e) {
if (e > (orderDetail.info.payAmount - orderDetail.info.refundAmount)) {
setTimeout(() => {
pageData.modify = (orderDetail.info.payAmount - orderDetail.info.refundAmount).toFixed(2)
},100)
}
}, 100)
}
}
/**
* 菜品总数量
@@ -183,7 +219,7 @@
return prve + cur.num * 1
}, 0)
})
/**
* 退款菜品总数量
*/
@@ -192,49 +228,49 @@
return prve + cur.number * 1
}, 0)
})
/**
* 退款总金额
*/
*/
const tuikuanPrice = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
const n= mathFloorPrice(cur.number * cur.unitPrice,cur)
const n = mathFloorPrice(cur.number * cur.unitPrice, cur)
return (parseFloat(prve) + parseFloat(n)).toFixed(2)
}, 0)
})
/**
* 剩余退款金额
*/
*/
const surplusRefundPrice = computed(() => {
return orderDetail.info.payAmount - orderDetail.goodsList.reduce((prve, cur) => {
const n = parseFloat( mathFloorPrice(cur.refundNum * cur.unitPrice,cur))
return (parseFloat(prve) + parseFloat(n)).toFixed(2)*1
const n = parseFloat(mathFloorPrice(cur.refundNum * cur.unitPrice, cur))
return (parseFloat(prve) + parseFloat(n)).toFixed(2) * 1
}, 0)
})
/**
* 退款总金额
*/
*/
const alltuikuanPrice = computed(() => {
return orderDetail.info.payAmount - orderDetail.goodsList.reduce((prve, cur) => {
const n = parseFloat( mathFloorPrice(cur.refundNum * cur.unitPrice,cur))
return (parseFloat(prve) + parseFloat(n)).toFixed(2)*1
const n = parseFloat(mathFloorPrice(cur.refundNum * cur.unitPrice, cur))
return (parseFloat(prve) + parseFloat(n)).toFixed(2) * 1
}, 0)
})
function to2(n) {
return Number(n).toFixed(2);
}
function changeItem(item, step) {
if( item.num <= 0){
if (item.num <= 0) {
return
}
if(item.productId=='-999'){
if (item.productId == '-999') {
return
}
if( pageData.tabsIndex != 0) {
if (pageData.tabsIndex != 0) {
return;
}
let newval = item.number * 1 + step * 1;
@@ -249,65 +285,126 @@
item.number = newval.toFixed(2);
pageData.tabsIndex = totalNumber.value == tuikuanNumber.value ? 1 : 0;
}
/**
* 确认退款
*/
let params;
async function tuikuanConfirm() {
const canTuikuan=await hasPermission('允许退款')
if(!canTuikuan){
const canTuikuan = await hasPermission('允许退款')
if (!canTuikuan) {
return uni.$utils.showToast('您没有退款权限')
}
if (pageData.tabsIndex != 2&&tuikuanNumber.value <= 0) {
if (pageData.tabsIndex != 2 && tuikuanNumber.value <= 0) {
return uni.$utils.showToast('退款商品数量不能为0')
}
const selTag=tuikuan.list[tuikuan.sel]
const noteResult=`${selTag?selTag:''}${note.value?(','+note.value):''}`
const selTag = tuikuan.list[tuikuan.sel]
const noteResult = `${selTag?selTag:''}${note.value?(','+note.value):''}`
if (!noteResult) {
return uni.$utils.showToast('请输入或选择退款原因!')
}
params = {
orderId: option.orderId,
refundReason: noteResult,
refundDetails: orderDetail.goodsList.filter(v=>v.number*1).map(v=>{
refundStock: confirmModal.selRefundStock,
refundDetails: orderDetail.goodsList.filter(v => v.number * 1).map(v => {
return {
id:v.id,
id: v.id,
returnAmount: v.number * 1 * v.unitPrice,
num: v.number * 1
}
})
}
if( pageData.tabsIndex == 2){
if (pageData.tabsIndex == 2) {
params.modify = true
params.refundAmount = (pageData.modify*1).toFixed(2)
params.refundAmount = (pageData.modify * 1).toFixed(2)
} else {
params.modify = false
params.refundAmount = pageData.tabsIndex == 1 ? alltuikuanPrice.value : tuikuanPrice.value
}
if ( pageData.tabsIndex == 2 && params.refundAmount > orderDetail.info.payAmount){
if (pageData.tabsIndex == 2 && params.refundAmount > orderDetail.info.payAmount) {
return uni.$utils.showToast('退款金额不能大于付款金额!')
}
if( uni.getStorageSync("shopInfo").isReturnPwd == 1){
if (uni.getStorageSync("shopInfo").isReturnPwd == 1) {
refundPopup.value.open(params.refundAmount, refundPost);
return;
}
refundPost()
refundPost()
}
async function refundPost (payPassword) {
if( payPassword ){
import {
getProductList,
getCategoryList
} from '@/http/api/product.js'
const confirmModal = reactive({
show: false,
selRefundStock: false,
payPassword: '',
refundStocks: [{
name: '已上菜(仅退菜不退库存)',
key: false
}, {
name: '未上菜(退菜后退库存)',
key: true,
}]
})
function confirmModalClose() {
confirmModal.show = false
confirmModal.selRefundStock = false
confirmModal.payPassword = ''
}
function confirmModalConfirm() {
refundSubmit(confirmModal.payPassword)
confirmModalClose()
}
async function refundSubmit(payPassword) {
if (payPassword) {
params.pwd = payPassword
}
params.refundStock = confirmModal.selRefundStock
await refundOrder(params)
uni.$utils.showToast('退款请求提交成功')
setTimeout(()=>{
uni.navigateBack({delta:1})
},500)
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 500)
}
async function refundPost(payPassword) {
confirmModal.payPassword = confirmModal.payPassword
const shopInfo = uni.getStorageSync('shopInfo')
if (pageData.tabsIndex != 2) {
if (shopInfo.refundMode == 1) {
const res = await getCategoryList()
for (let goods of res) {
if (goods.refundMode == 3) {
confirmModal.show = true
return
}
}
}
if (shopInfo.refundMode == 2) {
const res = await getProductList()
for (let goods of res) {
console.log(goods);
if (goods.refundMode == 3) {
confirmModal.show = true
return
}
}
}
}
refundSubmit(payPassword)
}
</script>
<style lang="scss" scoped>

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24.1" height="24.1" viewBox="0 0 24.1 24.1"><defs><style>.a{fill:#333;}</style></defs><path class="a" d="M179.826,184.148v-2.183h-2.231v2.185Zm3.33,0a1,1,0,0,0,.993-.993v-1.192h-2.139v2.183m-13.222-21.914v6.555h-6.555v-6.555h6.555m1.192-2.185h-8.938a1,1,0,0,0-.993.993v8.938a1,1,0,0,0,.993.993h8.938a1,1,0,0,0,.993-.993v-8.938a1,1,0,0,0-.993-.993Zm-4.469,5.462-1.092,0a1.092,1.092,0,1,0,1.092-1.092A1.092,1.092,0,0,0,164.419,165.512Zm17.545-3.277v6.555H175.41v-6.555h6.555m1.192-2.185h-8.938a1,1,0,0,0-.993.993v8.938a1,1,0,0,0,.993.993h8.938a1,1,0,0,0,.993-.993v-8.938a1,1,0,0,0-.993-.993Zm-4.469,5.462-1.092,0a1.092,1.092,0,1,0,1.092-1.092A1.092,1.092,0,0,0,177.595,165.512Zm-8.806,9.9v6.555h-6.555V175.41h6.555m1.192-2.185h-8.938a1,1,0,0,0-.993.993v8.938a1,1,0,0,0,.993.993h8.938a1,1,0,0,0,.993-.993v-8.938a1,1,0,0,0-.993-.993Zm-4.469,5.462-1.092,0a1.092,1.092,0,1,0,1.092-1.092A1.092,1.092,0,0,0,164.419,178.688Zm18.737-5.462h-1.218v4.37h-2.185v-4.37h-5.535a1,1,0,0,0-.993.993v8.938a1,1,0,0,0,.993.993h1.192V177.6h2.185v2.185h6.555v-5.562A1,1,0,0,0,183.156,173.225Z" transform="translate(-160.049 -160.05)"/></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1 +0,0 @@
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 195 60"><defs><style>.cls-1{fill:url(#未命名的渐变_2);}.cls-2{fill:url(#未命名的渐变_2-2);}.cls-3{fill:url(#未命名的渐变_2-3);}.cls-4{fill:url(#未命名的渐变_2-4);}</style><linearGradient id="未命名的渐变_2" x1="0.64" y1="28.6" x2="37.23" y2="28.6" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#238ffc"/><stop offset="1" stop-color="#1a66ff"/></linearGradient><linearGradient id="未命名的渐变_2-2" x1="41.89" y1="28.6" x2="77.05" y2="28.6" xlink:href="#未命名的渐变_2"/><linearGradient id="未命名的渐变_2-3" x1="81.86" y1="28.83" x2="118.14" y2="28.83" xlink:href="#未命名的渐变_2"/><linearGradient id="未命名的渐变_2-4" x1="123.38" y1="28.67" x2="157.74" y2="28.67" xlink:href="#未命名的渐变_2"/></defs><path class="cls-1" d="M.64,46.58h.48v.31H.64ZM15.2,10.3h6.67c.31,1.48.46,2.28.46,2.38h14.9V16H29.79l-.33,1.28c-.1.31-.37,1.3-.79,3H33a3.25,3.25,0,0,1,3.17,2.22,3.8,3.8,0,0,1,.15,1.12V39.76q0,4.76-2.07,7.13H28.05a10.71,10.71,0,0,0,1.89-6.33V25A1.39,1.39,0,0,0,29,23.77a.69.69,0,0,0-.49-.16H8.25V46.89H2.07V20.27H9.5c-.63-2.64-1-4.06-1.1-4.27H1V12.68H15.69Zm3.17,15.05-3,6.34H9l3.17-6.34Zm-7.74,7h5.85v7.92h5.24V37.39A1.65,1.65,0,0,0,21.23,36,1.82,1.82,0,0,0,20,35.65H17.58V32.33H24.4a3.25,3.25,0,0,1,3.32,3.16v8.08H10.63ZM15.05,16l1.28,4.27h5.54L23.12,16Zm4.75,9.35H26c.11,0,.42.58.95,1.74l2.22,4.6H22.82L22,30Z"/><path class="cls-2" d="M55.84,10.3h6.64c0,.11.43,1.16,1.28,3.17h9.81a2.91,2.91,0,0,1,2.53,1.1A2.52,2.52,0,0,1,76.89,16v7.92c0,1.69.06,4.38.16,8.08H50.91v4.29a22.27,22.27,0,0,1-1.25,8.07c-.33.84-.7,1.68-1.13,2.53H41.89q2.37-4,2.38-10.6V13.47h6.64V28.83H70.25V18.22a1.45,1.45,0,0,0-1.43-1.43H52V13.47h4.91C56.2,11.46,55.84,10.41,55.84,10.3Z"/><path class="cls-3" d="M96.6,15.21h6.8v16h14.74v3.33H103.4V46.89H96.6V34.53H81.86V31.2H96.6ZM83.45,10.76h33.11v3.35H83.45Zm1.1,6.83h6.82l3,10.14H87.71c-.1,0-.2-.27-.3-.79S86.35,23.39,84.55,17.59Zm24.24,0h6.65l-3.17,10.14h-6.65Z"/><path class="cls-4" d="M135.41,10.46q-4.75,9.2-5.06,10l-.15.15c0,.53.31.89.94,1.1h17.28l1.4,3.32H126.24c-1.48,0-2.39-.53-2.71-1.58a1.41,1.41,0,0,1-.15-.62,8.64,8.64,0,0,1,1.27-3.65q.16-.48,4.12-8.71ZM124.48,27.24h6.66V43.72H149V32.15a1.46,1.46,0,0,0-1.1-1.58H132.4V27.24h20.13a3,3,0,0,1,2.84,1.92,2.63,2.63,0,0,1,.33,1.25V46.89H124.48Zm26.93-15.68,1,2.07q5.06,10.94,5.36,11.39H151.1q-.32-.46-6.34-13.29v-.17Z"/></svg>

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -1,30 +0,0 @@
<svg width="750" height="1624" viewBox="0 0 750 1624" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_530_174)">
<rect width="750" height="1624" fill="white"/>
<rect width="750" height="398" fill="url(#paint0_linear_530_174)"/>
<g clip-path="url(#clip1_530_174)">
<path d="M446.619 -69C388.364 -39.9258 273.972 31.5229 282.446 84.7239C293.038 151.225 415.806 129.54 537.612 116.529C659.417 103.518 661.343 148.334 577.09 261.097C492.837 373.86 613.68 393.617 787 317.478" stroke="url(#paint1_linear_530_174)" stroke-opacity="0.1" stroke-width="50"/>
</g>
<rect opacity="0.1" width="750" height="1624" fill="url(#paint2_linear_530_174)"/>
</g>
<defs>
<linearGradient id="paint0_linear_530_174" x1="375" y1="398" x2="375" y2="6.81275e-06" gradientUnits="userSpaceOnUse">
<stop stop-color="#2A95F8" stop-opacity="0"/>
<stop offset="1" stop-color="#215CF5" stop-opacity="0.07"/>
</linearGradient>
<linearGradient id="paint1_linear_530_174" x1="787" y1="363" x2="281.535" y2="-68.4548" gradientUnits="userSpaceOnUse">
<stop stop-color="#76DEFF" stop-opacity="0.5"/>
<stop offset="1" stop-color="#003AAD"/>
</linearGradient>
<linearGradient id="paint2_linear_530_174" x1="375" y1="1624" x2="375" y2="3.81125e-06" gradientUnits="userSpaceOnUse">
<stop stop-color="white"/>
<stop offset="1" stop-color="#339DFF"/>
</linearGradient>
<clipPath id="clip0_530_174">
<rect width="750" height="1624" fill="white"/>
</clipPath>
<clipPath id="clip1_530_174">
<rect width="750" height="398" fill="white"/>
</clipPath>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB