优化打印机配置

This commit is contained in:
gyq
2026-04-22 10:09:50 +08:00
parent e2338b3888
commit 6d09813aa4
16 changed files with 612 additions and 67 deletions

View File

@@ -7,8 +7,8 @@ VITE_APP_BASE_API=/dev-api
# 接口地址
# VITE_APP_API_URL=https://tapi.cashier.sxczgkj.cn/ # 测试
VITE_APP_API_URL=https://cashier.sxczgkj.com/ # 正式
# VITE_APP_API_URL=http://192.168.1.42/ # 本地
# VITE_APP_API_URL=https://cashier.sxczgkj.com/ # 正式
VITE_APP_API_URL=http://192.168.1.42/ # 本地
VITE_APP_API_PHP_URL=http://192.168.1.42:8000 #php抖音美团测试环境
VITE_APP_API_PHP_IMPORT_URL=http://192.168.1.42:8789 #本地php批量导入
# VITE_APP_API_PHP_IMPORT_URL=https://diftcs.sxczgkj.com #本地线上php批量导入

View File

@@ -89,6 +89,22 @@ const OrderApi = {
responseType: 'blob'
});
},
// 打印经营日报
printDayReport(params: any) {
return request<any>({
url: `${Order_BaseUrl}/admin/finance/printDayReport`,
method: "get",
params
});
},
// 打印日结单
printDaySettle(params: any) {
return request<any>({
url: `${Order_BaseUrl}/admin/finance/printDaySettle`,
method: "get",
params
});
},
};
export default OrderApi;

View File

@@ -28,6 +28,14 @@ const Api = {
responseType: 'blob'
});
},
// 商品报表打印
print(params: any) {
return request<any>({
url: `${baseURL}/print`,
method: "get",
params
});
},
};
export default Api;

View File

@@ -0,0 +1,120 @@
<template>
<el-dialog title="打印确认" width="400px" v-model="showDayBusiness">
<div class="business_wrap">
<div class="title">
<el-text>请选择要打印的日期</el-text> <el-text type="danger">周期最长为7天</el-text>
</div>
<div class="row">
<el-date-picker v-model="printDayBusinessParams.date" type="daterange" start-placeholder="开始日期"
end-placeholder="结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD" :disabled-date="disabledDate"
@change="handleDateChange" clearable />
</div>
<div class="business_tips">
<el-text type="info">若数据过多打印时间会比较长请耐心等待</el-text>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="showDayBusiness = false"> </el-button>
<el-button type="primary" @click="confirmHandle" :loading="printDayBusinessLoading"> </el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import dayjs from "dayjs";
import { ref, onMounted } from "vue";
import { ElMessage } from 'element-plus'
const props = defineProps({
title: {
type: String,
default: '经营日报'
}
})
const showDayBusiness = ref(false)
const emits = defineEmits(['success'])
// 打印参数
const printDayBusinessParams = ref({
date: [],
})
const printDayBusinessLoading = ref(false)
// 取消
const confirmHandle = () => {
// 校验日期
if (!printDayBusinessParams.value.date || printDayBusinessParams.value.date.length !== 2) {
ElMessage.warning('请选择日期范围')
return
}
showDayBusiness.value = false
emits('success', { date: printDayBusinessParams.value.date })
}
// 日期禁用规则:只能选昨天及更早,不能选未来
const disabledDate = (time) => {
const yesterday = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
return dayjs(time).isAfter(yesterday)
}
// 日期选择后校验区间长度不能超过7天
const handleDateChange = (val) => {
if (!val || val.length !== 2) return
const [start, end] = val
const days = dayjs(end).diff(start, 'day') + 1 // 包含起止日
if (days > 7) {
ElMessage.warning('日期范围最多只能选择7天')
printDayBusinessParams.value.date = [] // 清空选择
}
}
// 判断当前时间 是否在 00:00 ~ 05:20 之间
const time = ref(['00:00', '05:20'])
const isInTimeRange = () => {
const now = dayjs()
const startTime = dayjs(time.value[0], 'HH:mm')
const endTime = dayjs(time.value[1], 'HH:mm')
return now.isAfter(startTime) && now.isBefore(endTime)
}
// 打开弹窗
const show = () => {
if (isInTimeRange()) {
ElMessage.warning(`当前时间不能打印${props.title},打印时间:${time.value[0]}点至${time.value[1]}`)
return
}
showDayBusiness.value = true
}
// 暴露方法
defineExpose({ show })
// 初始化默认选中昨天
onMounted(() => {
const yesterday = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
printDayBusinessParams.value.date = [yesterday, yesterday]
})
</script>
<style scoped lang="scss">
.business_wrap {
.title {
display: flex;
gap: 6px;
align-items: center;
}
.row {
padding-top: 14px;
}
.business_tips {
padding-top: 6px;
display: flex;
justify-content: center;
}
}
</style>

View File

@@ -39,7 +39,7 @@ export const useUserStore = defineStore("user", () => {
setRefreshToken(token);
localStorage.setItem("shopId", "" + data.shopInfo.id);
localStorage.setItem("branch_shopId", data.shopInfo.id)
resolve();
resolve(data);
})
.catch((error) => {
reject(error);

View File

@@ -10,6 +10,8 @@
<el-form-item>
<el-button type="primary" icon="Search" :loading="loading" @click="handleQuery">查询</el-button>
<el-button @click="handleReset" icon="Refresh" :loading="loading">重置</el-button>
<el-button icon="Printer" @click="printBusinessDialogRef.show()">经营日报</el-button>
<el-button icon="Printer" @click="printBusinessDialogRef2.show()">日结单</el-button>
</el-form-item>
</el-form>
<el-form inline>
@@ -359,6 +361,8 @@
</div>
</div>
</div>
<printBusinessDialog ref="printBusinessDialogRef" @success="printHandle" />
<printBusinessDialog ref="printBusinessDialogRef2" @success="printHandle2" />
</template>
<script setup>
@@ -366,6 +370,46 @@ import dayjs from "dayjs";
import { ref, onMounted } from "vue";
import OrderApi from "@/api/order/order";
import { downloadFile, multiplyAndFormat } from '@/utils'
import printBusinessDialog from "@/components/printBusinessDialog.vue";
const printBusinessDialogRef = ref(null)
// 打印经营日报回调
async function printHandle(res) {
try {
const shopStaff = JSON.parse(localStorage.getItem('shopStaff')) || { name: '' }
const shopName = localStorage.getItem('shopName')
await OrderApi.printDayReport({
beginDate: res.date[0],
endDate: res.date[1],
rangeType: 'CUSTOM',
shopId: localStorage.getItem('shopId') || '',
operator: shopStaff.name || shopName
})
ElMessage.success('打印成功')
} catch (error) {
console.log(error);
}
}
const printBusinessDialogRef2 = ref(null)
// 打印日结单回调
async function printHandle2(res) {
try {
const shopStaff = JSON.parse(localStorage.getItem('shopStaff')) || { name: '' }
const shopName = localStorage.getItem('shopName')
await OrderApi.printDaySettle({
beginDate: res.date[0],
endDate: res.date[1],
rangeType: 'CUSTOM',
shopId: localStorage.getItem('shopId') || '',
operator: shopStaff.name || shopName
})
ElMessage.success('打印成功')
} catch (error) {
console.log(error);
}
}
const queryForm = ref({
queryDate: dayjs().format('YYYY-MM-DD'), // 查询日期 yyyy-MM-dd

View File

@@ -44,6 +44,7 @@
<span v-if="!downloadLoading">导出Excel</span>
<span v-else>下载中...</span>
</el-button>
<el-button icon="Printer" :loading="printLoading" @click="$refs.printBusinessDialogRef.show()">打印</el-button>
<importData :type="7" @close="getTableData" />
</el-form-item>
</el-form>
@@ -185,6 +186,7 @@
@current-change="paginationChange" @size-change="sizeChange"
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<printBusinessDialog ref="printBusinessDialogRef" title="商品报表" @success="printBusinessConfirm" />
</div>
</template>
@@ -197,9 +199,10 @@ import ShopApi from "@/api/account/shop";
import dayjs from "dayjs";
import { downloadFile, multiplyAndFormat } from "@/utils/index";
import { formatDateRange } from './utils/index.js'
import printBusinessDialog from '@/components/printBusinessDialog.vue';
export default {
components: { importData },
components: { importData, printBusinessDialog },
data() {
return {
multiplyAndFormat,
@@ -233,7 +236,8 @@ export default {
// dayjs(time):将原生 Date 转为 dayjs 对象
// isAfter判断目标日期是否在今天之后
return dayjs(time).isAfter(dayjs().startOf('day'));
}
},
printLoading: false
};
},
filters: {
@@ -255,6 +259,34 @@ export default {
this.geiShopList();
},
methods: {
// 确认打印
printBusinessConfirm(res) {
this.printHandle(res.date)
},
// 打印
async printHandle(date) {
try {
const shopStaff = JSON.parse(localStorage.getItem('shopStaff')) || { name: '' }
const shopName = localStorage.getItem('shopName')
this.printLoading = true
await saleSummaryApi.print({
beginDate: date[0],
endDate: date[1],
categoryId: this.query.prodCategoryId,
productName: this.query.productName,
shopId: this.shopId,
rangeType: this.timeValue,
operator: shopStaff.name || shopName
})
ElMessage.success('操作成功')
} catch (error) {
console.log(error);
}
this.printLoading = false
},
/**
* 获取分店列表
*/

View File

@@ -2,7 +2,6 @@ import printerApi, { type addRequest } from "@/api/account/printer";
import { options } from './config'
import type { IModalConfig } from "@/components/CURD/types";
import { c } from "vite/dist/node/moduleRunnerTransport.d-CXw_Ws6P";
const modalConfig: IModalConfig<addRequest> = {
pageName: "sys:user",
@@ -17,7 +16,7 @@ const modalConfig: IModalConfig<addRequest> = {
formAction: function (data) {
let obj = { ...data }
console.log("打印类型", data);
obj.printType = data.printType.join(',')
// obj.printType = data.printType.join(',')
obj.categoryIds = JSON.stringify(data.categoryIdsArr)
obj.categoryList = JSON.stringify(data.categoryIdsArr)
if (data.classifyPrint == 0) {
@@ -90,7 +89,7 @@ const modalConfig: IModalConfig<addRequest> = {
{
type: "select",
label: "打印类型",
prop: "subType",
prop: "printType",
rules: [{ required: false, message: "请选择打印类型", trigger: "blur" }],
attrs: {
placeholder: "请选择打印类型",
@@ -108,7 +107,7 @@ const modalConfig: IModalConfig<addRequest> = {
{
type: "select",
label: "打印机品牌",
prop: "contentType",
prop: "brand",
rules: [{ required: true, message: "请选择打印机品牌", trigger: "blur" }],
attrs: {
placeholder: "请选择打印机品牌",
@@ -144,27 +143,27 @@ const modalConfig: IModalConfig<addRequest> = {
label: "",
initialValue: []
},
{
type: "radio",
label: "打印数量",
prop: "printQty",
prop: "printNum",
options: options.printQty,
initialValue: options.printQty[0].value
},
{
type: "radio",
label: "打印方式",
prop: "printMethod",
prop: "kitchenPrintMode",
options: options.printMethod,
initialValue: options.printMethod[0].value
},
{
type: "checkbox",
type: "custom",
label: "打印类型",
prop: "printType",
prop: "printContentType",
options: options.printType,
initialValue: options.printType.map(v => v.value)
initialValue: options.printType.map(v => v.value),
slotName: 'printTypeSlot'
},
{
label: "打印机状态",

View File

@@ -59,8 +59,8 @@ const contentConfig: IContentConfig<getListRequest> = {
label: "状态",
align: "center",
prop: "status",
templet: "switch",
slotName: "status",
templet: "custom",
slotName: "status"
},
{ label: "创建时间", align: "center", prop: "createTime" },
// {

View File

@@ -160,11 +160,11 @@ const modalConfig: IModalConfig<editRequest> = {
initialValue: options.printMethod[0].value
},
{
type: "checkbox",
type: "custom",
label: "打印类型",
prop: "printType",
options: options.printType,
initialValue: options.printType.map(v => v.value)
prop: "printContentType",
options: '',
initialValue: ''
},
{
label: "打印机状态",

View File

@@ -2,30 +2,18 @@
<div class="app-container">
<!-- 列表 -->
<!-- 搜索 -->
<page-search
ref="searchRef"
:search-config="searchConfig"
@query-click="handleQueryClick"
@reset-click="handleResetClick"
/>
<page-search ref="searchRef" :search-config="searchConfig" @query-click="handleQueryClick"
@reset-click="handleResetClick" />
<!-- 列表 -->
<page-content
ref="contentRef"
: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">
<page-content ref="contentRef" :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">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
</el-tag>
</template>
</template> -->
<template #contentType="scope">
{{ scope.row.contentType == "yxyPrinter" ? "云想印" : "飞鹅" }}
</template>
@@ -38,6 +26,10 @@
<template #gender="scope">
<DictLabel v-model="scope.row[scope.prop]" code="gender" />
</template>
<template #status="scope">
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0"
@click="statusChange($event, scope.row)"></el-switch>
</template>
<template #operate="scope">
<div v-if="scope.row.connectionType != 'USB'">
<el-button @click="handleEditClick(scope.row)" icon="Edit" type="primary" link>
@@ -55,10 +47,21 @@
</page-content>
<!-- 新增 -->
<page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
<!-- <page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
<template #gender="scope">
<Dict v-model="scope.formData[scope.prop]" code="gender" />
</template>
<template #printTypeSlot="scope">
<div class="row" v-for="(item, index) in printTypeList" :key="index">
<div class="title">{{ item.label }}</div>
<div class="cont">
<el-checkbox-group v-model="item.values" @change="printTypeChange($event, index, scope)">
<el-checkbox :label="item.label" :value="item.value" v-for="item in item.list"
:key="item.value"></el-checkbox>
</el-checkbox-group>
</div>
</div>
</template>
<template #classifyPrintData="scope">
<template v-if="scope.formData.classifyPrint == 1">
<el-checkbox-group v-model="scope.formData.categoryIdsArr">
@@ -68,17 +71,24 @@
</el-checkbox-group>
</template>
</template>
</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">
<Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" />
</template>
<template #printTypeSlot="scope">
<div class="row" v-for="(item, index) in printTypeList" :key="index">
<div class="title">{{ item.label }}</div>
<div class="cont">
<el-checkbox-group v-model="item.values" @change="printTypeChange($event, index, scope)">
<el-checkbox :label="item.label" :value="item.value" v-for="item in item.list"
:key="item.value"></el-checkbox>
</el-checkbox-group>
</div>
</div>
</template>
<template #classifyPrintData="scope">
<template v-if="scope.formData.classifyPrint == 1">
<el-checkbox-group v-model="scope.formData.categoryIdsArr">
@@ -88,11 +98,103 @@
</el-checkbox-group>
</template>
</template>
</page-modal>
</page-modal> -->
<el-dialog :title="form.id ? '编辑打印机' : '添加打印机'" width="800px" v-model="visible" @closed="dialogClosed"
@open="dialogOpen">
<div style="height: 60vh;overflow-y: auto;" ref="formDivRef">
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="设备名称" prop="name">
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
</el-form-item>
<el-form-item label="设备类型">
<el-radio-group v-model="form.connectionType">
<el-radio-button label="USB" value="USB"></el-radio-button>
<el-radio-button label="云打印" value="云打印"></el-radio-button>
<el-radio-button label="局域网" value="局域网"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="小票类型">
<el-radio-group v-model="form.printType">
<el-radio-button label="标签" value="label"></el-radio-button>
<el-radio-button label="小票" value="cash"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="打印机品牌" prop="brand">
<el-radio-group v-model="form.brand">
<el-radio-button label="飞鹅"></el-radio-button>
<el-radio-button label="云想印"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="ip地址/MAC地址" prop="address">
<el-input v-model="form.address" placeholder="请输入ip地址/MAC地址"></el-input>
</el-form-item>
<el-form-item label="端口" prop="port">
<el-input v-model="form.port" placeholder="请输入端口"></el-input>
</el-form-item>
<el-form-item label="小票尺寸" prop="receiptSize">
<el-radio-group v-model="form.receiptSize">
<el-radio-button label="58mm"></el-radio-button>
<el-radio-button label="80mm"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="打印数量" prop="printNum">
<el-input-number v-model="form.printNum" :step="1" :min="1"></el-input-number>
</el-form-item>
<el-form-item label="打印内容" prop="printContentType">
<div class="row" v-for="(item, index) in printTypeList" :key="index">
<div class="title">{{ item.label }}</div>
<div class="cont">
<el-checkbox-group v-model="item.values" @change="printTypeChange($event, index)">
<el-checkbox :label="item.label" :value="item.value" v-for="item in item.list"
:key="item.value"></el-checkbox>
</el-checkbox-group>
</div>
</div>
</el-form-item>
<!-- <el-form-item label="打印模式" prop="kitchenPrintMode">
<el-radio-group v-model="form.kitchenPrintMode">
<el-radio-button label="整单" value="all"></el-radio-button>
<el-radio-button label="单个" value="only"></el-radio-button>
</el-radio-group>
<el-text type="info" style="margin-left: 14px;">仅针对厨房制作单的打印</el-text>
</el-form-item> -->
<el-form-item label="分类打印">
<div class="column">
<div style="display: flex;align-items: center;">
<el-radio-group v-model="form.classifyPrint">
<el-radio-button label="所有" value="0"></el-radio-button>
<el-radio-button label="部分分类" value="1" v-if="printTypeList[1].values.length > 0"></el-radio-button>
</el-radio-group>
<el-text type="info" style="margin-left: 14px;">仅针对厨房制作单的打印</el-text>
</div>
<template v-if="form.classifyPrint == 1">
<el-checkbox-group v-model="form.categoryIds">
<el-checkbox v-for="item in PrinterTypeList" :value="item.id" :label="item.name"></el-checkbox>
</el-checkbox-group>
</template>
</div>
</el-form-item>
<el-form-item label="媒体音量">
<el-switch v-model="form.volumeSwitch" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item label="启用状态">
<el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="visible = false"> </el-button>
<el-button type="primary" :loading="loading" @click="submitHandle"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import _ from 'lodash'
import UserAPI from "@/api/account/printer";
import type { IObject, IOperatData } from "@/components/CURD/types";
import usePage from "@/components/CURD/usePage";
@@ -100,6 +202,166 @@ import addModalConfig from "./config/add";
import contentConfig from "./config/content";
import editModalConfig from "./config/edit";
import searchConfig from "./config/search";
import { options } from './config/config'
import printerApi, { type addRequest } from "@/api/account/printer";
const printTypeList = ref([
{
label: '前台',
values: [],
list: [
{ label: '客看单', value: 'GUEST_ORDER' },
{ label: '预结算单', value: 'PRE_ORDER' },
{ label: '结算单', value: 'ORDER' },
{ label: '退菜单', value: 'RETURN_ORDER' },
{ label: '退款单', value: 'REFUND_ORDER' },
]
},
{
label: '后厨',
values: [],
list: [
{ label: '后厨-整单', value: 'ALL_KITCHEN' },
{ label: '后厨-分单', value: 'ONLY_KITCHEN' },
{ label: '后厨-退菜单', value: 'REFUND_KITCHEN' },
]
},
{
label: '其它',
values: [],
list: [
{ label: '交班单', value: 'HANDOVER' },
{ label: '排队取号', value: 'CALL' },
{ label: '储值单', value: 'RECHARGE' },
{ label: '入库单', value: 'STOCK' },
{ label: '盘点单', value: 'STOCK_CHECK' },
{ label: '商品报表', value: 'PRODUCT_REPORT' },
{ label: '经营日报', value: 'DAY_REPORT' },
{ label: '日结单', value: 'DAY_ORDER' },
]
}
])
const loading = ref(false)
const visible = ref(false)
const formRef = ref(null)
const obj = {
id: '',
name: '', // 设备名称
connectionType: '云打印', // 连接方式 USB、云打印、局域网
printType: 'cash', // 打印类型 label标签 cash小票
brand: '', // 打印机品牌 飞鹅/云想印
address: '', // ip地址/MAC地址
port: '', // 端口
receiptSize: '58mm', // 小票尺寸 58mm 80mm
printNum: 1, // 打印数量
printContentType: '', // 打印内容
kitchenPrintMode: 'all', // 打印模式(厨房打印菜品) all整单 /only单个
classifyPrint: '0', // 分类打印 0-所有 1-部分分类
categoryIds: [], // 分类Id
status: 1, // 0 禁用 1启用
volumeSwitch: 1, // 媒体声音开关 0关1开
}
const form = ref({ ...obj })
const rules = {
name: [
{
required: true,
message: '请输入设备名称',
trigger: 'blur'
}
],
brand: [
{
required: true,
message: '请选择打印机品牌',
trigger: 'change'
}
],
printNum: [
{
required: true,
message: '请选择打印数量',
trigger: 'change'
}
],
// kitchenPrintMode: [
// {
// required: true,
// message: '请选择打印模式',
// trigger: 'change'
// }
// ]
}
function dialogClosed() {
formRef.value.resetFields()
form.value = { ...obj }
}
const formDivRef = ref(null)
async function dialogOpen() {
await nextTick()
if (formDivRef.value) {
// console.log('开始滚动到顶部')
formDivRef.value.scrollTop = 0
}
}
// 打印类型切换
function printTypeChange(e, index, scope) {
if (index == 1 && printTypeList.value[index].values.length == 0) {
form.value.categoryList = []
}
let arr = []
printTypeList.value.forEach(item => {
arr.push(...item.values)
})
form.value.printContentType = arr.join(',')
}
function submitHandle() {
console.log('submitHandle===', form.value);
formRef.value.validate(async valid => {
try {
if (valid) {
loading.value = true
const data = { ...form.value }
data.categoryIds = form.value.categoryIds.join(',')
if (form.value.id) {
await printerApi.edit(data)
} else {
await printerApi.add(data)
}
ElMessage.success(form.value.id ? '编辑成功' : '添加成功')
visible.value = false
handleQueryClick();
}
} catch (error) {
console.log(error);
}
setTimeout(() => {
loading.value = false
}, 300);
})
}
// 更改状态
async function statusChange(e, data) {
try {
await printerApi.edit({
id: data.id,
status: data.status
});
handleQueryClick();
} catch (error) {
console.log(error);
}
}
const {
searchRef,
@@ -138,27 +400,41 @@ function handdeleteevent(item) {
}
// 新增
async function handleAddClick() {
addModalRef.value?.setModalVisible();
// addModalRef.value?.setModalVisible();
visible.value = true
}
// 编辑
async function handleEditClick(row: IObject) {
editModalRef.value?.handleDisabled(false);
editModalRef.value?.setModalVisible();
// 根据id获取数据进行填充
let data = await UserAPI.get(row.id);
data.printType = data.printType.split(",");
form.value = { ...row }
visible.value = true
if (data.categoryIds) {
data.categoryIdsArr = JSON.parse(data.categoryIds);
} else {
data.categoryIdsArr = [];
}
console.log(data.categoryIdsArr);
console.log(data);
form.value.categoryIds = form.value.categoryIds.split(',')
data.classifyPrint = data.classifyPrint * 1;
const printContentTypes = row.printContentType.split(',')
printTypeList.value.forEach(val => {
val.values = _.map(
_.filter(val.list, item => printContentTypes.includes(item.value)),
'value'
);
})
editModalRef.value?.setFormData(data);
// editModalRef.value?.handleDisabled(false);
// editModalRef.value?.setModalVisible();
// // 根据id获取数据进行填充
// let data = await UserAPI.get(row.id);
// data.printType = data.printType.split(",");
// if (data.categoryIds) {
// data.categoryIdsArr = JSON.parse(data.categoryIds);
// } else {
// data.categoryIdsArr = [];
// }
// console.log(data.categoryIdsArr);
// console.log(data);
// data.classifyPrint = data.classifyPrint * 1;
// editModalRef.value?.setFormData(data);
}
// 其他工具栏
function handleToolbarClick(name: string) {

View File

@@ -198,6 +198,12 @@ function handleLogin() {
userStore
.login(user)
.then(async (res) => {
console.log('login===', res);
localStorage.setItem('shopStaff', JSON.stringify(res.shopStaff))
const token = getToken();
console.log("token", token);
$douyin_checkIn({

View File

@@ -15,7 +15,11 @@
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
</el-tag>
</template>
<template #refundMode="scope">
<!-- <el-switch v-model="scope.row[scope.prop]" :active-value="1" :inactive-value="0"
@click="isRefundStockChange($event, scope)" /> -->
<el-text>{{ returnLabel(scope.row[scope.prop]) }}</el-text>
</template>
<template #slotNameimage="scope">
<el-image v-if="scope.row.pic" :src="scope.row.pic" lazy style="width: 40px; height: 40px" />
<div v-else></div>
@@ -68,6 +72,17 @@ import editModalConfig from "./categoryconfig/edit";
import searchConfig from "./categoryconfig/search";
import { isSyncStatus, downloadFile } from "@/utils/index";
const options = ref([
{ label: "退菜退库存", value: 1 },
{ label: "仅退菜不退库存", value: 2 },
{ label: "每次询问-退菜后弹窗提示,可手动选择", value: 3 },
])
function returnLabel(value: number) {
const option = options.value.find((option) => option.value === value);
return option ? option.label : "未知";
}
const {
searchRef,
contentRef,
@@ -106,6 +121,16 @@ async function handleExportClick() {
}
}
// 退菜是否退库存开关切换
async function isRefundStockChange(e: any, scope: any) {
try {
await UserAPI.update(scope.row);
} catch (error) {
console.log(error);
ElMessage.error("操作失败");
}
}
// 新增
async function handleAddClick() {
addModalRef.value?.setModalVisible();

View File

@@ -77,6 +77,13 @@ const contentConfig: IContentConfig<UserPageQuery> = {
templet: "switch",
slotName: "status",
},
{
label: "退菜是否退库存",
align: "center",
prop: "refundMode",
templet: "custom",
slotName: "refundMode",
},
{
label: "操作",
align: "center",

View File

@@ -43,8 +43,9 @@
</template>
<template #tuikuantuihui="scope">
<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>
<!-- <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> -->
<el-text>{{ returnLabel(scope.row[scope.prop]) }}</el-text>
</template>
<template #sellOut="scope">
<el-switch v-model="scope.row[scope.prop]" :active-value="1" :inactive-value="0"
@@ -210,6 +211,17 @@ import TableFour from './indexconfig/TableFour.vue'
const myDialogRefRecord = ref(null)
const refoundModeOptions = ref([
{ label: "退菜退库存", value: 1 },
{ label: "仅退菜不退库存", value: 2 },
{ label: "每次询问-退菜后弹窗提示,可手动选择", value: 3 },
])
function returnLabel(value: number) {
const option = refoundModeOptions.value.find((option) => option.value == value);
return option ? option.label : "未知";
}
let dataAll = reactive({
dataList: [],
tableData: [],

View File

@@ -131,7 +131,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
{
label: "退菜是否退库存",
align: "center",
prop: "isRefundStock",
prop: "refundMode",
templet: "custom",
slotName: "tuikuantuihui",
},