feat: 打印机、商品列表的问题修改

This commit is contained in:
duan 2025-03-25 15:40:11 +08:00
parent 48a4424d3f
commit 88e26bb9d4
12 changed files with 134 additions and 359 deletions

View File

@ -37,6 +37,17 @@ const API = {
params: { id }
});
},
// 获取商品分类
getPrinterType(params: any) {
return request<any>({
url: `/product/admin/prod/category/page`,
method: "get",
params: {
page: 1, size: 20
}
});
},
}
export default API;
export interface getListRequest {

View File

@ -1,20 +1,9 @@
<template>
<!-- drawer -->
<template v-if="modalConfig.component === 'drawer'">
<el-drawer
v-model="modalVisible"
:append-to-body="true"
v-bind="modalConfig.drawer"
@close="handleCloseModal"
>
<el-drawer v-model="modalVisible" :append-to-body="true" v-bind="modalConfig.drawer" @close="handleCloseModal">
<!-- 表单 -->
<el-form
ref="formRef"
label-width="auto"
v-bind="modalConfig.form"
:model="formData"
:rules="formRules"
>
<el-form ref="formRef" label-width="auto" v-bind="modalConfig.form" :model="formData" :rules="formRules">
<el-row :gutter="20">
<template v-for="item in formItems" :key="item.prop">
<template v-if="item.type === 'title'">
@ -26,12 +15,7 @@
<template v-if="item.tips" #label>
<span>
{{ item.label }}
<el-tooltip
placement="bottom"
effect="light"
:content="item.tips"
:raw-content="true"
>
<el-tooltip placement="bottom" effect="light" :content="item.tips" :raw-content="true">
<el-icon style="vertical-align: -0.15em" size="16">
<QuestionFilled />
</el-icon>
@ -106,12 +90,7 @@
</template>
<!-- 自定义 -->
<template v-else-if="item.type === 'custom'">
<slot
:name="item.slotName ?? item.prop"
:prop="item.prop"
:formData="formData"
:attrs="item.attrs"
/>
<slot :name="item.slotName ?? item.prop" :prop="item.prop" :formData="formData" :attrs="item.attrs" />
</template>
</el-form-item>
</el-col>
@ -134,26 +113,13 @@
</template>
<!-- dialog -->
<template v-else>
<el-dialog
v-model="modalVisible"
:align-center="true"
:append-to-body="true"
width="70vw"
v-bind="modalConfig.dialog"
style="padding-right: 0"
@close="handleCloseModal"
>
<el-dialog v-model="modalVisible" :align-center="true" :append-to-body="true" width="70vw"
v-bind="modalConfig.dialog" style="padding-right: 0" @close="handleCloseModal">
<!-- 滚动 -->
<el-scrollbar max-height="60vh">
<!-- 表单 -->
<el-form
ref="formRef"
label-width="auto"
v-bind="modalConfig.form"
style="padding-right: var(--el-dialog-padding-primary)"
:model="formData"
:rules="formRules"
>
<el-form ref="formRef" label-width="auto" v-bind="modalConfig.form"
style="padding-right: var(--el-dialog-padding-primary)" :model="formData" :rules="formRules">
<el-row :gutter="20">
<template v-for="item in formItems" :key="item.prop">
<template v-if="item.type === 'title'">
@ -167,12 +133,7 @@
<template v-if="item.tips" #label>
<span>
{{ item.label }}
<el-tooltip
placement="bottom"
effect="light"
:content="item.tips"
:raw-content="true"
>
<el-tooltip placement="bottom" effect="light" :content="item.tips" :raw-content="true">
<el-icon style="vertical-align: -0.15em" size="16">
<QuestionFilled />
</el-icon>
@ -181,11 +142,7 @@
</template>
<!-- Input 输入框 -->
<template v-if="item.type === 'input' || item.type === undefined">
<el-input
v-model="formData[item.prop]"
v-bind="item.attrs"
:disabled="item.disabled"
/>
<el-input v-model="formData[item.prop]" v-bind="item.attrs" :disabled="item.disabled" />
</template>
<!-- textarea 输入框 -->
<template v-else-if="item.type === 'textarea'">
@ -257,12 +214,8 @@
</template>
<!-- 自定义 -->
<template v-else-if="item.type === 'custom'">
<slot
:name="item.slotName ?? item.prop"
:prop="item.prop"
:formData="formData"
:attrs="item.attrs"
/>
<slot :name="item.slotName ?? item.prop" :prop="item.prop" :formData="formData"
:attrs="item.attrs" />
</template>
</el-form-item>
</el-col>

View File

@ -16,10 +16,14 @@ const modalConfig: IModalConfig<addRequest> = {
formAction: function (data) {
let obj = { ...data }
obj.printType = data.printType.join(',')
obj.categoryIds = JSON.stringify(data.categoryIdsArr)
obj.categoryList = JSON.stringify(data.categoryIdsArr)
// obj.categoryIds = '[' + data.categoryIdsArr.join(',') + ']'
return printerApi.add(obj);
},
beforeSubmit(data) {
console.log("提交之前处理", data);
},
formItems: [
{
@ -128,6 +132,14 @@ const modalConfig: IModalConfig<addRequest> = {
options: options.classifyPrint,
initialValue: options.classifyPrint[0].value
},
{
type: "custom",
slotName: 'classifyPrintData',
prop: "categoryIdsArr",
label: "",
initialValue: []
},
{
type: "radio",
label: "打印数量",

View File

@ -19,8 +19,8 @@ export const options: optionObject = {
],
classifyPrint: [
{ label: "所有", value: 0 },
{ label: "部分分类", value: 1 },
{ label: "部分商品", value: 2 },
{ label: "部分分类(仅打印制作单[厨房]", value: 1 },
// { label: "部分商品", value: 2 },
],
printQty: [
{ label: "顾客+商家[2张] ", value: 'c1m1^2' },

View File

@ -24,6 +24,14 @@ const contentConfig: IContentConfig<getListRequest> = {
deleteAction: function (id) {
return printerApi.delete(id)
},
modifyAction(data) {
// 模拟发起网络请求修改字段
return printerApi.edit({
id: data.id,
status: data.status
});
},
importsAction(data) {
// 模拟导入数据
console.log("importsAction", data);
@ -31,9 +39,9 @@ const contentConfig: IContentConfig<getListRequest> = {
},
exportsAction: async function (params) {
// 模拟获取到的是全量数据
const res = await printerApi.getPage(params);
console.log("exportsAction", res.list);
return res.list;
// const res = await printerApi.getPage(params);
// console.log("exportsAction", res.list);
// return res.list;
},
pk: "id",
toolbar: [
@ -54,15 +62,26 @@ const contentConfig: IContentConfig<getListRequest> = {
slotName: "status",
},
{ label: "创建时间", align: "center", prop: "createTime" },
// {
// label: "操作",
// align: "center",
// fixed: "right",
// width: 280,
// templet: "tool",
// operat: ["edit", "delete"],
// watch: () => { }
// },
{
label: "操作",
align: "center",
fixed: "right",
width: 280,
templet: "tool",
operat: ["edit", "delete"],
},
width: 150,
templet: "custom",
slotName: 'operate'
}
],
};
export default contentConfig;

View File

@ -16,6 +16,8 @@ const modalConfig: IModalConfig<editRequest> = {
formAction: function (data) {
let obj = { ...data }
obj.printType = data.printType.join(',')
obj.categoryIds = JSON.stringify(data.categoryIdsArr)
obj.categoryList = JSON.stringify(data.categoryIdsArr)
return printerApi.edit(obj);
},
beforeSubmit(data) {
@ -128,6 +130,16 @@ const modalConfig: IModalConfig<editRequest> = {
options: options.classifyPrint,
initialValue: options.classifyPrint[0].value
},
{
type: "custom",
slotName: 'classifyPrintData',
prop: "categoryIdsArr",
label: "",
},
{
type: "radio",
label: "打印数量",
@ -149,6 +161,7 @@ const modalConfig: IModalConfig<editRequest> = {
options: options.printType,
initialValue: options.printType.map(v => v.value)
},
{
label: "打印机状态",
prop: "status",

View File

@ -1,285 +0,0 @@
<template>
<div class="printerStyle">
<search @queryClick="handleQuery" />
<content :tableData="datas.tableData" @addClick="handleAdd" />
<!-- 新增 -->
<page-modal ref="addModalRef" :modal-config="addmodalConfig" @submit-click="handleSubmitClick">
<template #gender="scope">
<Dict v-model="scope.formData[scope.prop]" code="gender" />
</template>
</page-modal>
</div>
</template>
<script setup>
import search from "./config/search.vue";
import content from "./config/content.vue";
import UserAPI from "@/api/system/user";
let datas = reactive({
query: {
name: "",
type: "",
},
tableData: [],
});
// -
function handleQuery(d) {
datas.query = d;
getlist();
}
onMounted(() => {
getlist();
});
function getlist() {
console.log(datas.query, "获取列表");
}
let addModalRef = ref(null)
//
const addmodalConfig = {
pageName: "sys:user",
dialog: {
title: "新增打印机",
width: 800,
draggable: true,
},
form: {
labelWidth: 100,
},
formAction: UserAPI.add,
beforeSubmit(data) {
console.log("提交之前处理", data);
},
formItems: [
// {
// label: "",
// prop: "username",
// rules: [{ required: true, message: "", trigger: "blur" }],
// type: "input",
// attrs: {
// placeholder: "",
// },
// col: {
// xs: 24,
// sm: 12,
// },
// },
// {
// label: "",
// prop: "nickname",
// rules: [{ required: true, message: "", trigger: "blur" }],
// type: "input",
// attrs: {
// placeholder: "",
// },
// col: {
// xs: 24,
// sm: 12,
// },
// },
{
label: "打印机品牌",
prop: "deptId",
// rules: [{ required: true, message: "", trigger: "blur" }],
type: "tree-select",
attrs: {
placeholder: "请选择打印机品牌",
data: [],
filterable: true,
"check-strictly": true,
"render-after-expand": false,
},
},
{
type: "custom",
label: "性别",
prop: "gender",
initialValue: 1,
},
{
label: "角色",
prop: "roleIds",
rules: [{ required: true, message: "用户角色不能为空", trigger: "blur" }],
type: "select",
attrs: {
placeholder: "请选择",
multiple: true,
},
options: [],
initialValue: [],
},
{
type: "input",
label: "手机号码",
prop: "mobile",
rules: [
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur",
},
],
attrs: {
placeholder: "请输入手机号码",
maxlength: 11,
},
},
{
label: "邮箱",
prop: "email",
rules: [
{
pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/,
message: "请输入正确的邮箱地址",
trigger: "blur",
},
],
type: "input",
attrs: {
placeholder: "请输入邮箱",
maxlength: 50,
},
},
{
label: "状态",
prop: "status",
type: "radio",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
{ label: "禁用2", value: 3 },
],
initialValue: 1,
}, {
label: "状态",
prop: "status2",
type: "checkbox",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
{ label: "禁用2", value: 3 },
],
initialValue: 1,
},
],
};
function handleAdd() {
addModalRef.value?.setModalVisible();
}
//
function handleSubmitClick(data) {
console.log(data)
}
// import { devices, models, subTypes } from './devices'
// import addDevice from './components/addDevice'
// import { tbPrintMachineGet, switchtbPrintMachine, delTableHandle } from '@/api/devices'
// import dayjs from 'dayjs'
// export default {
// components: {
// addDevice
// },
// data() {
// return {
// query: {
// name: '',
// type: ''
// },
// devices,
// tableData: {
// data: [],
// page: 0,
// size: 10,
// loading: false,
// total: 0
// }
// }
// },
// filters: {
// devicesName(value) {
// if (value == 'yxyPrinter') {
// return ''
// } else if (value == 'fePrinter') ''
// // const item=devices.find(item => item.value == value)
// // return item?item.name:''
// },
// modelsName(value) {
// const item = models.find(item => item.value == value)
// return item ? item.name : ''
// },
// subTypesName(value) {
// if (value == "label") return ''
// else if (value == 'kitchen') return ''
// else if (value == 'cash') return ''
// },
// timeFilter(s) {
// return dayjs(s).format('YYYY-MM-DD HH:mm:ss')
// }
// },
// mounted() {
// this.getTableData()
// },
// methods: {
// toUrl(item) {
// this.$router.push({ path: '/devices/details', query: { id: item.id } })
// },
// //
// async statusChange(e, row) {
// try {
// this.tableData.loading = true
// const data = { ...row }
// data.status = e
// if (data.id) {
// delete data.createdAt
// delete data.updatedAt
// }
// await switchtbPrintMachine(data)
// this.getTableData()
// } catch (error) {
// console.log(error)
// this.tableData.loading = false
// }
// },
// //
// resetHandle() {
// this.query.name = ''
// this.query.type = ''
// this.getTableData()
// },
// //
// paginationChange(e) {
// this.tableData.page = e - 1
// this.getTableData()
// },
// //
// async delTableHandle(item) {
// const res = await delTableHandle(item)
// this.getTableData()
// },
// //
// async getTableData() {
// this.tableData.loading = true
// try {
// const res = await tbPrintMachineGet({
// name: this.query.name,
// shopId: localStorage.getItem('shopId'),
// contentType: this.query.type,
// sort: '',
// })
// this.tableData.loading = false
// this.tableData.data = res
// this.tableData.total = res.length
// } catch (error) {
// console.log(error)
// }
// }
// }
// }
</script>
<style scoped lang="scss">
.printerStyle {
padding: 20px;
background-color: #fff;
}
</style>

View File

@ -20,13 +20,22 @@
<template #subType="scope">
{{ scope.row.subType == 'label' ? "标签" : "小票" }}
</template>
<template #caozuo="scope">
{{ scope }}
</template>
<template #gender="scope">
<DictLabel v-model="scope.row[scope.prop]" code="gender" />
</template>
<template #mobile="scope">
<template #operate="scope">
<div v-if="scope.row.connectionType != 'USB'">
<el-button @click="handleEditClick(scope.row)" icon="Edit" type="primary" link>编辑</el-button>
<el-button @click="handdeleteevent(scope.row)" icon="Delete" type="danger" link>删除</el-button>
</div>
</template>
<!-- <template #mobile="scope">
<el-text>{{ scope.row[scope.prop] }}</el-text>
<copy-button v-if="scope.row[scope.prop]" :text="scope.row[scope.prop]" style="margin-left: 2px" />
</template>
</template> -->
</page-content>
<!-- 新增 -->
@ -34,6 +43,15 @@
<template #gender="scope">
<Dict v-model="scope.formData[scope.prop]" code="gender" />
</template>
<template #classifyPrintData="scope">
<template v-if="scope.formData.classifyPrint == 1">
<el-checkbox-group v-model="scope.formData.categoryIdsArr">
<template v-for="col in PrinterTypeList" :key="col">
<el-checkbox :value="col.id * 1" :label="col.name" />
</template>
</el-checkbox-group>
</template>
</template>
</page-modal>
<!-- 编辑 -->
@ -41,6 +59,15 @@
<template #gender="scope">
<Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" />
</template>
<template #classifyPrintData="scope">
<template v-if="scope.formData.classifyPrint == 1">
<el-checkbox-group v-model="scope.formData.categoryIdsArr">
<template v-for="col in PrinterTypeList" :key="col">
<el-checkbox :value="col.id * 1" :label="col.name" />
</template>
</el-checkbox-group>
</template>
</template>
</page-modal>
</div>
</template>
@ -68,7 +95,28 @@ const {
handleSearchClick,
handleFilterChange,
} = usePage();
onMounted(() => {
getPrinterType();
});
let PrinterTypeList = ref([])
//
async function getPrinterType() {
let res = await UserAPI.getPrinterType();
PrinterTypeList.value = res.records
}
function handdeleteevent(item) {
ElMessageBox.confirm("确认删除?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(function () {
contentConfig.deleteAction(item.id).then(() => {
ElMessage.success("删除成功");
handleQueryClick();
});
});
}
//
async function handleAddClick() {
addModalRef.value?.setModalVisible();
@ -80,6 +128,10 @@ async function handleEditClick(row: IObject) {
// id
let data = await UserAPI.get(row.id);
data.printType = data.printType.split(',');
if (data.categoryIds) {
data.categoryIdsArr = JSON.parse(data.categoryIds)
}
data.classifyPrint = data.classifyPrint * 1;
editModalRef.value?.setFormData(data);

View File

@ -16,7 +16,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
pageSize: 20,
pageSizes: [10, 20, 30, 50],
},
indexActionData: { name: "", orderBy: "name asc" },
indexActionData: { name: "", orderBy: "" },
indexAction: function (params) {
return UserAPI.getPage(params);
},

View File

@ -160,7 +160,7 @@
<el-input v-model="ruleForm.weight" placeholder="">
<template #append>千克</template>
</el-input>
<div style="color: #999;">用于快递或配送运费计重</div>
<!-- <div style="color: #999;">用于快递或配送运费计重</div> -->
</div>
</el-col>
</el-form-item>

View File

@ -16,7 +16,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
pageSize: 20,
pageSizes: [10, 20, 30, 50],
},
indexActionData: { name: "", orderBy: "name asc" },
indexActionData: { name: "", orderBy: "" },
indexAction: function (params) {
return UserAPI.getPage(params);
},

View File

@ -15,7 +15,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
pageSize: 20,
pageSizes: [10, 20, 30, 50],
},
indexActionData: { name: "", orderBy: "name asc" },
indexActionData: { name: "", orderBy: "" },
indexAction: function (params) {
return UserAPI.getPage(params);
},