同步代码
This commit is contained in:
433
pagePrinter/add-printer/add-printer.vue
Normal file
433
pagePrinter/add-printer/add-printer.vue
Normal file
@@ -0,0 +1,433 @@
|
||||
<template>
|
||||
<view class="page-gray color-333 u-font-28">
|
||||
<view class="block">
|
||||
<!-- <up-popup :show="show" @close="close" @open="open"> -->
|
||||
<picker-item title="打印机品牌" required v-model="form.contentType" :modelValue="form.contentType"
|
||||
:list="brandt.list"></picker-item>
|
||||
<picker-item title="小票打印" required v-model="form.subType" :modelValue="form.subType"
|
||||
:list="receipt.list"></picker-item>
|
||||
<view class="u-p-b-14 u-m-b-24 border-bottom">
|
||||
<view class="title"><span style="color: red;">*</span>打印机名称</view>
|
||||
<view class="">
|
||||
<uni-easyinput :inputBorder="false" :padding-none="true" v-model="form.name"
|
||||
placeholder="设置打印机名称"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-b-14 u-m-b-24 border-bottom">
|
||||
<view class="title"><span style="color: red;">*</span>打印机编号</view>
|
||||
<view class="">
|
||||
<uni-easyinput :inputBorder="false" :padding-none="true" v-model="form.address"
|
||||
placeholder="设置打印机名称"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-b-14 u-m-b-24 border-bottom">
|
||||
<view class="title">打印机密钥</view>
|
||||
<view class="">
|
||||
<uni-easyinput :inputBorder="false" :padding-none="true" v-model="form.port"
|
||||
placeholder="设置打印机密钥"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title">小票尺寸</view>
|
||||
<view class="u-m-t-16">
|
||||
<radio-group class="u-flex u-flex-wrap" @change="sizeChange($event,'receiptSize')">
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="58mm" :checked="form.receiptSize == '58mm'" class="scale7" />
|
||||
<text>58mm</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="80mm" :checked="form.receiptSize == '80mm'" class="scale7" />
|
||||
<text>80mm</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title">分类打印 </view>
|
||||
<view class="u-m-t-16">
|
||||
<radio-group class="u-flex u-flex-wrap" @change="sizeChange($event,'classifyPrint')">
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="0" :checked="form.classifyPrint == '0'" class="scale7" />
|
||||
<text>打印所有</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="1" :checked="form.classifyPrint == '1'" class="scale7" />
|
||||
<text>部分分类(仅打印制作单[厨房])</text>
|
||||
</label>
|
||||
<!-- <label class="radio u-m-r-60">
|
||||
<radio value="2" :checked="form.classifyPrint == '2'" class="scale7" />
|
||||
<text>部分商品</text>
|
||||
</label> -->
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom" v-if="form.classifyPrint ==1">
|
||||
<view class="title">部分打印</view>
|
||||
<view class="u-m-t-16" style="display: flex;">
|
||||
<up-checkbox-group v-model="form.selectcheckbox">
|
||||
<up-checkbox v-for="item in partList" :key="item.id" :customStyle="{marginBottom: '8px'}"
|
||||
:label="item.name" :name="item.id" style="margin-right: 40rpx;font-size: 28rpx;">
|
||||
</up-checkbox>
|
||||
</up-checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title">桌台打印</view>
|
||||
<view class="u-m-t-16">
|
||||
<radio-group class="u-flex u-flex-wrap" @change="sizeChange($event,'tablePrint')">
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="0" :checked="form.tablePrint == '0'" class="scale7" />
|
||||
<text>打印所有</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="1" :checked="form.tablePrint == '1'" class="scale7" />
|
||||
<text>打印部分桌台</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title">打印数量</view>
|
||||
<view class="u-m-t-16">
|
||||
<radio-group class="u-flex u-flex-wrap" @change="sizeChange($event,'printQty')">
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="c1m1^2" :checked="form.printQty == 'c1m1^2'" class="scale7" />
|
||||
<text>顾客联+商家联「2张」</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="m1^1" :checked="form.printQty == 'm1^1'" class="scale7" />
|
||||
<text>只打印商家联「1张」</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="c1^1" :checked="form.printQty == 'c1^1'" class="scale7" />
|
||||
<text>只打印顾客联「1张」</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="c2m1^3" :checked="form.printQty == 'c2m1^3'" class="scale7" />
|
||||
<text>2张顾客联+1张商家联「3张」</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title">打印方式</view>
|
||||
<view class="u-m-t-16">
|
||||
<radio-group class="u-flex u-flex-wrap" @change="sizeChange($event,'printMethod')">
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="all" :checked="form.printMethod == 'all'" class="scale7" />
|
||||
<text>打印全部</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="one" :checked="form.printMethod == 'one'" class="scale7" />
|
||||
<text>仅打印制作单[厨房]</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="normal" :checked="form.printMethod == 'normal'" class="scale7" />
|
||||
<text>仅打印结账单[前台]</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title">打印类型</view>
|
||||
<view class="u-m-t-16" style="display: flex;">
|
||||
<up-checkbox-group v-model="form.printType">
|
||||
<up-checkbox :customStyle="{marginBottom: '8px'}" label="确认退款单" name="refund"
|
||||
style="margin-right: 40rpx;font-size: 28rpx;">
|
||||
</up-checkbox>
|
||||
<up-checkbox :customStyle="{marginBottom: '8px'}" label="交班单" name="handover"
|
||||
style="margin-right: 40rpx;font-size: 28rpx;">
|
||||
</up-checkbox>
|
||||
<up-checkbox :customStyle="{marginBottom: '8px'}" label="排队取号" name="queue"
|
||||
style="margin-right: 40rpx;font-size: 28rpx;">
|
||||
</up-checkbox>
|
||||
</up-checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title">打印单据</view>
|
||||
<view class="u-m-t-16">
|
||||
<radio-group class="u-flex u-flex-wrap" @change="sizeChange($event,'printReceipt')">
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="0" class="scale7" />
|
||||
<text>全部打印</text>
|
||||
</label>
|
||||
<label class="radio u-m-r-60">
|
||||
<radio value="1" :checked="form.printReceipt == '1'" class="scale7" />
|
||||
<text>仅厨房</text>
|
||||
</label><label class="radio u-m-r-60">
|
||||
<radio value="2" :checked="form.printReceipt == '2'" class="scale7" />
|
||||
<text>仅前台</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="u-p-b-24 u-flex u-row-between u-m-b-24 border-bottom">
|
||||
<view class="title">打印机状态</view>
|
||||
<view class="">
|
||||
<!-- <my-switch v-model="form.status"></my-switch> -->
|
||||
<my-switch v-model="form.status"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="u-p-b-24 u-flex u-row-between u-m-b-24 border-bottom">
|
||||
<view class="title">排序</view>
|
||||
<view class="">
|
||||
<uni-number-box v-model="form.sort"></uni-number-box>
|
||||
</view>
|
||||
</view> -->
|
||||
<!-- <view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title font-bold">商品分类</view>
|
||||
<view class="u-m-t-16 u-flex u-row-between " @click="categoryShow">
|
||||
<view class="color-333" v-if="form.sort">{{form.sort}}</view>
|
||||
<view class="color-999" v-else>请选择</view>
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view style="height: 60rpx;"></view>
|
||||
<view class="">
|
||||
<view class="btn">
|
||||
<my-button shape="circle" @click="save">保存</my-button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 消息提示 -->
|
||||
<up-toast ref="uToastRef"></up-toast>
|
||||
|
||||
<!-- 选择分类 -->
|
||||
<choose-category v-model="chooseCategoryShow"></choose-category>
|
||||
</view>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
devices,
|
||||
models,
|
||||
subTypes,
|
||||
brand,
|
||||
receipts,
|
||||
} from '@/pagePrinter/devices.js'
|
||||
import {
|
||||
onLoad,
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
computed,
|
||||
watch,
|
||||
onMounted,
|
||||
toRef,
|
||||
getCurrentInstance
|
||||
|
||||
} from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import pickerItem from './components/picker-item.vue';
|
||||
import myRadioGroup from './components/my-radio-group.vue';
|
||||
import * as Api from '@/http/yskApi/devices.js'
|
||||
import chooseCategory from './components/choose-category.vue';
|
||||
|
||||
//选择分类
|
||||
let chooseCategoryShow = ref(false)
|
||||
|
||||
function categoryShow() {
|
||||
chooseCategoryShow.value = true
|
||||
}
|
||||
// brand
|
||||
const brandt = reactive({
|
||||
list: brand,
|
||||
selIndex: '',
|
||||
})
|
||||
const refs = getCurrentInstance()
|
||||
// 小票
|
||||
const receipt = reactive({
|
||||
list: receipts,
|
||||
selIndex: '',
|
||||
})
|
||||
let userId = ref(null)
|
||||
//品牌
|
||||
const brands = reactive({
|
||||
list: devices,
|
||||
selIndex: '',
|
||||
})
|
||||
let partList = ref([])
|
||||
//设备尺寸
|
||||
const deciveSize = reactive({
|
||||
list: [{
|
||||
label: '58mm',
|
||||
value: '0'
|
||||
},
|
||||
{
|
||||
label: '80mm',
|
||||
value: '1'
|
||||
},
|
||||
],
|
||||
selIndex: 1
|
||||
})
|
||||
|
||||
let getlist = async () => {
|
||||
const res = await Api.tbShopCategoryget({
|
||||
shopId: uni.getStorageSync("shopId"),
|
||||
sort: "sort,desc",
|
||||
page: 0,
|
||||
size: 500
|
||||
})
|
||||
let arr = []
|
||||
res.content.forEach(ele => {
|
||||
arr.push({
|
||||
id: ele.id,
|
||||
name: ele.name
|
||||
})
|
||||
if (ele.childrenList.length > 0) {
|
||||
ele.childrenList.forEach(element => {
|
||||
arr.push({
|
||||
id: element.id,
|
||||
name: element.name
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
partList.value = arr
|
||||
}
|
||||
|
||||
function sizeChange(e, name) {
|
||||
form[name] = e.detail.value
|
||||
}
|
||||
//打印份数
|
||||
const printerNums = reactive({
|
||||
list: new Array(4).fill(1).map((v, index) => {
|
||||
return {
|
||||
label: index * 1 + 1 + '份',
|
||||
value: '' + index
|
||||
}
|
||||
}),
|
||||
selIndex: 0
|
||||
})
|
||||
//尾部留空
|
||||
const feets = ref([0, 1, 2, 3, 4, 5, 8].map(v => {
|
||||
return v + '行'
|
||||
}))
|
||||
let form = reactive({
|
||||
sort: "0",
|
||||
status: 1,
|
||||
connectionType: "network",
|
||||
printType: [],
|
||||
name: '',
|
||||
receiptSize: '58mm',
|
||||
classifyPrint: '0',
|
||||
printQty: 'm1^1',
|
||||
printType: ["refund", 'handover', 'queue'],
|
||||
printMethod: "all",
|
||||
selectcheckbox:[]
|
||||
|
||||
})
|
||||
async function save() {
|
||||
|
||||
// 效验
|
||||
if (!form.contentType || !form.subType || !form.name || !form.address) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请输入必填项",
|
||||
})
|
||||
return
|
||||
}
|
||||
if (form.classifyPrint == 1 && form.selectcheckbox.length == 0) {
|
||||
refs.ctx.$refs.uToastRef.show({
|
||||
type: 'default',
|
||||
message: "请选择部分分类",
|
||||
})
|
||||
return
|
||||
}
|
||||
// 部分分类处理
|
||||
if (form.classifyPrint == 1) {
|
||||
let idstr = ''
|
||||
let arr = []
|
||||
form.selectcheckbox.forEach(element => {
|
||||
idstr += element + ','
|
||||
arr.push(partList.value.filter(ele => ele.id == element)[0])
|
||||
})
|
||||
form.categoryIds = idstr.substring(0, idstr.length - 1)
|
||||
form.categoryList = JSON.stringify(arr)
|
||||
}
|
||||
if (userId.value) {
|
||||
delete form.createdAt
|
||||
delete form.updatedAt
|
||||
const res = await Api.tbPrintMachine({
|
||||
...form
|
||||
}, 'put')
|
||||
} else {
|
||||
const res = await Api.tbPrintMachine({
|
||||
...form
|
||||
})
|
||||
}
|
||||
go.back()
|
||||
// go.to('/pagePrinter/index/index')
|
||||
}
|
||||
// watch(() => form.config.model, (newval) => {
|
||||
// console.log(newval);
|
||||
// })
|
||||
// const option = reactive({})
|
||||
async function getdetails() {
|
||||
const res = await Api.printerd(userId.value)
|
||||
if (res.categoryIds) {
|
||||
let arr = res.categoryIds.split(',')
|
||||
let arrs = []
|
||||
arr.forEach(eles => {
|
||||
arrs.push(eles * 1)
|
||||
})
|
||||
res.selectcheckbox = arrs
|
||||
}
|
||||
form = Object.assign(form, res)
|
||||
form.printType = JSON.parse(form.printType)
|
||||
}
|
||||
onLoad((options) => {
|
||||
getlist()
|
||||
if (options.id) {
|
||||
// 有id是编辑,获取详情
|
||||
userId.value = options.id
|
||||
getdetails()
|
||||
} else {
|
||||
userId.value = null
|
||||
}
|
||||
// Object.assign(option, opt)
|
||||
})
|
||||
// show(()=>{
|
||||
// getlist()
|
||||
// })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-gray {
|
||||
padding: 32rpx 28rpx;
|
||||
}
|
||||
|
||||
.block {
|
||||
background-color: #fff;
|
||||
padding: 32rpx 24rpx;
|
||||
border-radius: 18rpx;
|
||||
margin-bottom: 32rpx;
|
||||
box-shadow: 0 0 5px #eee;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.radio {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.fixed_b {
|
||||
left: 30rpx;
|
||||
right: 30rpx;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 10rpx);
|
||||
/* #ifdef H5 */
|
||||
bottom: 30rpx;
|
||||
/* #endif */
|
||||
}
|
||||
</style>
|
||||
46
pagePrinter/add-printer/components/choose-category.vue
Normal file
46
pagePrinter/add-printer/components/choose-category.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<my-mask :show="modelValue">
|
||||
<view class="bg-fff content">
|
||||
<view class="u-flex u-row-between u-p-30">
|
||||
<view>选择分类</view>
|
||||
<view>
|
||||
<uni-icons @click="changeShow" type="closeempty"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" style="height: 70vh;">
|
||||
|
||||
</scroll-view>
|
||||
<view class="u-flex u-row-between gap-20 u-p-30">
|
||||
<view class="u-flex-1">
|
||||
<my-button type="cancel" @tap="changeShow">取消</my-button>
|
||||
</view>
|
||||
<view class="u-flex-1">
|
||||
<my-button>确定</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</my-mask>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props=defineProps({
|
||||
modelValue:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
})
|
||||
const emits=defineEmits(['update:modelValue'])
|
||||
function changeShow(isShow){
|
||||
const show=isShow?true:false
|
||||
emits('update:modelValue',show)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content{
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
70
pagePrinter/add-printer/components/my-radio-group.vue
Normal file
70
pagePrinter/add-printer/components/my-radio-group.vue
Normal file
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<radio-group class="u-flex u-flex-wrap" @change="change">
|
||||
<label class="radio u-m-r-60" v-for="(item,itemIndex) in list" :key="index">
|
||||
<radio :value="index" :checked="itemChecked(item,itemIndex)" class="scale7" />
|
||||
<text>{{item.label}}</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
rangeValue: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
rangeKey: {
|
||||
type: String,
|
||||
default: 'label'
|
||||
},
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '标题'
|
||||
},
|
||||
modelValue: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
function itemChecked(item,itemIndex){
|
||||
if(!props.rangeValue){
|
||||
return itemIndex==index.value
|
||||
}
|
||||
return item[props.rangeValue]=props.list[index.value][props.rangeKey]
|
||||
}
|
||||
function findIndex() {
|
||||
return props.list.findIndex(v => v[props.rangeValue] == props.modelValue)
|
||||
}
|
||||
|
||||
function findValue() {
|
||||
return props.list[index.value][props.rangeValue]
|
||||
}
|
||||
const computedIndex = props.rangeValue ? findIndex() : props.modelValue
|
||||
const index = ref(computedIndex)
|
||||
const emits = defineEmits(['update:modelValue'], )
|
||||
watch(() => index.value, (newval) => {
|
||||
const value = props.rangeValue ? findValue() : newval
|
||||
console.log(value);
|
||||
emits('update:modelValue', value)
|
||||
})
|
||||
|
||||
function change(e) {
|
||||
index.value = e.detail.value
|
||||
}
|
||||
const selText = computed(() => {
|
||||
const item = props.list[index.value]
|
||||
return item ? item[props.rangeKey] : ''
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
63
pagePrinter/add-printer/components/picker-item.vue
Normal file
63
pagePrinter/add-printer/components/picker-item.vue
Normal file
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title font-bold"> <text v-if="required" style="color: red;">*</text>{{title}}</view>
|
||||
<!-- <up-popup customStyle="overflow: hidden;" @change="change" :value="value" :range="list" range-key="name" round="20" mode="bottom">
|
||||
<view class="u-m-t-16 u-flex u-row-between ">
|
||||
<view class="color-333" v-if="selText">{{selText}}</view>
|
||||
<view class="color-999" v-else>请选择</view>
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
</view>
|
||||
</up-popup> -->
|
||||
<picker @change="change" range-key="name" :value="value" :range="list">
|
||||
<view class="u-m-t-16 u-flex u-row-between ">
|
||||
<view class="color-333" v-if="selText">{{selText}}</view>
|
||||
<view class="color-999" v-else>请选择</view>
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
const props = defineProps({
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '标题'
|
||||
},
|
||||
modelValue: {
|
||||
type: String,
|
||||
},
|
||||
required: {
|
||||
type: Boolean
|
||||
}
|
||||
})
|
||||
const index = ref(props.modelValue)
|
||||
const emits = defineEmits(['update:modelValue'], )
|
||||
const selText = computed(() => {
|
||||
const item = props.list.filter(ele => ele.value == props.modelValue)[0]
|
||||
if(!item){
|
||||
return ''
|
||||
}
|
||||
return item.name
|
||||
})
|
||||
|
||||
watch(() => index.value, (newval) => {
|
||||
emits('update:modelValue', props.list[newval].value)
|
||||
})
|
||||
|
||||
function change(e) {
|
||||
index.value = e.detail.value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
63
pagePrinter/devices.js
Normal file
63
pagePrinter/devices.js
Normal file
@@ -0,0 +1,63 @@
|
||||
export const brand = [{
|
||||
value: 'yxyPrinter',
|
||||
name: '云想印'
|
||||
},
|
||||
{
|
||||
value: 'fePrinter',
|
||||
name: '飞鹅'
|
||||
}
|
||||
]
|
||||
export const receipts = [{
|
||||
value: 'label',
|
||||
name: '标签'
|
||||
},
|
||||
{
|
||||
value: 'kitchen',
|
||||
name: '出品'
|
||||
},
|
||||
{
|
||||
value: 'cash',
|
||||
name: '小票'
|
||||
}
|
||||
]
|
||||
export const devices = [{
|
||||
value: 'printer',
|
||||
name: '本地'
|
||||
},
|
||||
{
|
||||
value: 'yxyPrinter',
|
||||
name: '云想印'
|
||||
},
|
||||
{
|
||||
value: 'fePrinter',
|
||||
name: '飞鹅'
|
||||
}
|
||||
]
|
||||
|
||||
export const models = [{
|
||||
value: 'normal',
|
||||
name: '普通出单'
|
||||
},
|
||||
{
|
||||
value: 'one',
|
||||
name: '一菜一品'
|
||||
},
|
||||
{
|
||||
value: 'category',
|
||||
name: '分类出单'
|
||||
}
|
||||
]
|
||||
|
||||
export const subTypes = [{
|
||||
value: 'kitchen',
|
||||
name: '出品'
|
||||
},
|
||||
{
|
||||
value: 'cash',
|
||||
name: '小票'
|
||||
},
|
||||
{
|
||||
value: 'label',
|
||||
name: '标签'
|
||||
}
|
||||
]
|
||||
154
pagePrinter/index/components/printer-item.vue
Normal file
154
pagePrinter/index/components/printer-item.vue
Normal file
@@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<view class="default-box-padding bg-fff u-font-28 border-r-12 box-shadow u-m-b-30">
|
||||
<view class="u-flex u-row-between u-p-b-24 border-bottom">
|
||||
<view class="u-flex">
|
||||
<!-- <text>{{ subTypesName(data.subType)}}</text> -->
|
||||
<text>{{ data.name}}</text>
|
||||
<text class="color-999 u-font-24">({{data.address}})</text>
|
||||
</view>
|
||||
<view class="u-flex u-col-center">
|
||||
<template v-if="data.status">
|
||||
<text class="online">在线,状态正常</text>
|
||||
</template>
|
||||
<template v-else>
|
||||
<image class="icon-warning" src="/pagePrinter/static/icon/icon-warning.svg" mode=""></image>
|
||||
<text class="leave u-m-l-10">离线</text>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="u-m-t-24">
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="u-flex u-col-center">
|
||||
<image class="icon" src="/pagePrinter/static/icon/icon-setting.svg" mode=""></image>
|
||||
<view class="color-666 u-m-l-10">是否启用</view>
|
||||
</view>
|
||||
<view>
|
||||
<my-switch v-model="data.status" @change="openDiscountChange"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32">
|
||||
<view class="u-flex u-col-center">
|
||||
<image class="icon" src="/pagePrinter/static/icon/icon-type.svg" mode=""></image>
|
||||
<view class="color-666 u-m-l-10">类型</view>
|
||||
</view>
|
||||
<view>
|
||||
{{subTypesName(data.subType)}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32">
|
||||
<view class="u-flex u-col-center">
|
||||
<image class="icon" src="/pagePrinter/static/icon/icon-category.svg" mode=""></image>
|
||||
<view class="color-666 u-m-l-10">分类</view>
|
||||
</view>
|
||||
<view>
|
||||
{{devicesName(data.contentType)}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-32 u-flex u-row-right gap-20">
|
||||
<my-button v-if="data.connectionType == 'network'" shape="circle" :width="140" :height="56"
|
||||
type="cancel" @tap="delTableHandleEvent()" plain>删除</my-button>
|
||||
<my-button v-if="data.connectionType == 'network'" shape="circle" @click="toUrl" :width="140"
|
||||
:height="56" plain>编辑</my-button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 删除弹窗 -->
|
||||
<my-model desc="确认删除?" ref="delModel" @confirm="delModelConfirm"></my-model>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
devices,
|
||||
models,
|
||||
subTypes
|
||||
} from '@/pagePrinter/devices.js'
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {
|
||||
shopConfigprinter,
|
||||
delTableHandle
|
||||
} from '@/http/yskApi/devices.js'
|
||||
import {
|
||||
getCurrentInstance
|
||||
} from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['init'])
|
||||
let toUrl = () => {
|
||||
go.to('PAGES_PRINTER_ADD', {
|
||||
id: props.data.id
|
||||
})
|
||||
}
|
||||
|
||||
function devicesName(value) {
|
||||
return devices.find(item => item.value == value).name
|
||||
}
|
||||
|
||||
function modelsName(value) {
|
||||
return models.find(item => item.value == value).name
|
||||
}
|
||||
|
||||
function subTypesName(value) {
|
||||
return subTypes.find(item => item.value == value).name
|
||||
}
|
||||
|
||||
function timeFilter(s) {
|
||||
return dayjs(s).format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
|
||||
async function openDiscountChange(d) {
|
||||
delete props.data.createdAt
|
||||
delete props.data.updatedAt
|
||||
const res = await shopConfigprinter({
|
||||
...props.data,
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
})
|
||||
emit('init', '')
|
||||
}
|
||||
const refs = getCurrentInstance()
|
||||
// 删除
|
||||
function delTableHandleEvent() {
|
||||
refs.ctx.$refs.delModel.open()
|
||||
}
|
||||
//删除分类确认
|
||||
async function delModelConfirm() {
|
||||
const res = await delTableHandle(props.data.id)
|
||||
emit('init', '')
|
||||
refs.ctx.$refs.delModel.close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid rgb(240, 240, 240);
|
||||
}
|
||||
|
||||
.box-shadow {
|
||||
box-shadow: 0 0 5px #eee;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: #0FC161;
|
||||
}
|
||||
|
||||
.leave {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.icon-warning {
|
||||
width: 34rpx;
|
||||
height: 30rpx;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
</style>
|
||||
175
pagePrinter/index/editPrinter.vue
Normal file
175
pagePrinter/index/editPrinter.vue
Normal file
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<view class="page-gray color-333 u-font-28">
|
||||
<view class="block">
|
||||
<picker-item title="打印机类型" v-model="brands.selIndex" rangeKey="name" :list="brands.list"></picker-item>
|
||||
<view class="u-p-b-14 u-m-b-24 border-bottom">
|
||||
<view class="title">设备号</view>
|
||||
<view class="">
|
||||
<uni-easyinput :inputBorder="false" :padding-none="true" v-model="form.form"
|
||||
placeholder="输入设备号"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="u-p-b-24 u-m-b-24 border-bottom">
|
||||
<view class="title font-bold">商品分类</view>
|
||||
<view class="u-m-t-16 u-flex u-row-between " @click="categoryShow">
|
||||
<view class="color-333" v-if="form.sort">{{form.sort}}</view>
|
||||
<view class="color-999" v-else>请选择</view>
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="height: 60rpx;"></view>
|
||||
<view class="">
|
||||
<view class="btn">
|
||||
<my-button shape="circle" @click="save">保存</my-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 选择分类 -->
|
||||
<choose-category v-model="chooseCategoryShow"></choose-category>
|
||||
</view>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
devices,
|
||||
models,
|
||||
subTypes
|
||||
} from '@/pagePrinter/devices.js'
|
||||
import {
|
||||
onLoad,
|
||||
onShow
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
ref,
|
||||
onBeforeUnmount,
|
||||
reactive,
|
||||
computed,
|
||||
watch
|
||||
} from 'vue';
|
||||
import go from '@/commons/utils/go.js';
|
||||
import pickerItem from '../add-printer/components/picker-item.vue'
|
||||
import myRadioGroup from '../add-printer/components/my-radio-group.vue';
|
||||
import * as Api from '@/http/yskApi/devices.js'
|
||||
import chooseCategory from '../add-printer/components/choose-category.vue';
|
||||
|
||||
//选择分类
|
||||
let chooseCategoryShow = ref(false)
|
||||
|
||||
function categoryShow() {
|
||||
chooseCategoryShow.value = true
|
||||
}
|
||||
|
||||
//品牌
|
||||
const brands = reactive({
|
||||
list: devices,
|
||||
brand:brand,
|
||||
selIndex: '',
|
||||
})
|
||||
|
||||
//设备尺寸
|
||||
const deciveSize = reactive({
|
||||
list: [{
|
||||
label: '58mm',
|
||||
value: '0'
|
||||
},
|
||||
{
|
||||
label: '80mm',
|
||||
value: '1'
|
||||
},
|
||||
],
|
||||
selIndex: 1
|
||||
})
|
||||
|
||||
function sizeChange(e) {
|
||||
deciveSize.selIndex = e.detail.value
|
||||
}
|
||||
|
||||
//打印份数
|
||||
const printerNums = reactive({
|
||||
list: new Array(4).fill(1).map((v, index) => {
|
||||
return {
|
||||
label: index * 1 + 1 + '份',
|
||||
value: '' + index
|
||||
}
|
||||
}),
|
||||
selIndex: 0
|
||||
})
|
||||
//尾部留空
|
||||
const feets = ref([0, 1, 2, 3, 4, 5, 8].map(v => {
|
||||
return v + '行'
|
||||
}))
|
||||
|
||||
const form = reactive({
|
||||
id: '',
|
||||
contentType: '',
|
||||
config: {
|
||||
width: '80mm', // 设备尺寸
|
||||
printerNum: 1, //打印份数
|
||||
categoryList: '', // 商品分类
|
||||
model: 'normal', // 出品模式,
|
||||
feet: '0',
|
||||
autoCut: 0
|
||||
},
|
||||
name: '',
|
||||
subType: 'kitchen', // 打印类型
|
||||
status: 0,
|
||||
sort: ''
|
||||
})
|
||||
|
||||
function save() {
|
||||
|
||||
}
|
||||
watch(() => form.config.model, (newval) => {
|
||||
console.log(newval);
|
||||
})
|
||||
|
||||
const option = reactive({})
|
||||
|
||||
onLoad((opt) => {
|
||||
console.log(opt);
|
||||
Object.assign(option, opt)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
})
|
||||
onShow(() => {})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-gray {
|
||||
padding: 32rpx 28rpx;
|
||||
}
|
||||
|
||||
.block {
|
||||
background-color: #fff;
|
||||
padding: 32rpx 24rpx;
|
||||
border-radius: 18rpx;
|
||||
margin-bottom: 32rpx;
|
||||
box-shadow: 0 0 5px #eee;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.radio {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.fixed_b {
|
||||
left: 30rpx;
|
||||
right: 30rpx;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 10rpx);
|
||||
/* #ifdef H5 */
|
||||
bottom: 30rpx;
|
||||
/* #endif */
|
||||
}
|
||||
</style>
|
||||
69
pagePrinter/index/index.vue
Normal file
69
pagePrinter/index/index.vue
Normal file
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<view class="min-page bg-gray u-p-30 u-flex u-flex-col ">
|
||||
<div class="w-full" v-for="item in pageData.list " :key="item.id">
|
||||
<printer-item :data="item" @init='init'></printer-item>
|
||||
</div>
|
||||
<view v-if="!pageData.list.length&&pageData.hasAjax">
|
||||
<my-img-empty ></my-img-empty>
|
||||
</view>
|
||||
<view style="height: 100rpx;"></view>
|
||||
<view class="fixed_b u-fixed">
|
||||
<my-button shape="circle" @tap="toAdd">
|
||||
<view>
|
||||
<text>+</text>
|
||||
<text>添加云打印机</text>
|
||||
</view>
|
||||
</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {
|
||||
onShow,
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
onMounted,
|
||||
reactive
|
||||
} from 'vue';
|
||||
import printerItem from './components/printer-item.vue';
|
||||
import * as Api from '@/http/yskApi/devices.js'
|
||||
const pageData = reactive({
|
||||
list: [],
|
||||
hasAjax:false,
|
||||
query: {
|
||||
sort: '',
|
||||
name: '',
|
||||
contentType: ''
|
||||
}
|
||||
})
|
||||
function toAdd(){
|
||||
go.to('PAGES_PRINTER_ADD',{
|
||||
a:1
|
||||
})
|
||||
}
|
||||
async function init() {
|
||||
const res =await Api.tbPrintMachineGet(pageData.query)
|
||||
pageData.hasAjax=true
|
||||
pageData.list = res
|
||||
// pageData.list = res.filter(v=>v.address)
|
||||
}
|
||||
onShow(()=>{
|
||||
init()
|
||||
})
|
||||
// onMounted(() => {
|
||||
// init()
|
||||
// })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.fixed_b{
|
||||
left: 110rpx;
|
||||
right: 110rpx;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 10rpx);
|
||||
/* #ifdef H5 */
|
||||
bottom: 30rpx;
|
||||
/* #endif */
|
||||
}
|
||||
</style>
|
||||
1
pagePrinter/static/icon/icon-category.svg
Normal file
1
pagePrinter/static/icon/icon-category.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12" viewBox="0 0 12 12"><defs><style>.a{fill:#ebd4d4;}.b{clip-path:url(#a);}.c{fill:#666;}</style><clipPath id="a"><circle class="a" cx="6" cy="6" r="6" transform="translate(94 212)"/></clipPath></defs><g class="b" transform="translate(-94 -212)"><path class="c" d="M71.825,64a.672.672,0,0,1,.711.711v.711h.711a.672.672,0,0,1,.711.711v4.98a.672.672,0,0,1-.711.711h-.711v1.423a.672.672,0,0,1-.711.711H66.134a.672.672,0,0,1-.711-.711V71.825h-.711A.672.672,0,0,1,64,71.114v-4.98a.672.672,0,0,1,.711-.711h.711v-.711A.672.672,0,0,1,66.134,64Zm0,5.691H66.134v3.557h5.691Zm1.423-3.557H64.711v4.98h.711V69.691a.672.672,0,0,1,.711-.711h5.691a.672.672,0,0,1,.711.711v1.423h.711Zm-.711.711v.711h-.711v-.711Zm-.711-2.134H66.134v.711h5.691Z" transform="translate(31.02 149.02)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 878 B |
1
pagePrinter/static/icon/icon-setting.svg
Normal file
1
pagePrinter/static/icon/icon-setting.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12" viewBox="0 0 12 12"><defs><style>.a{fill:#ebd4d4;}.b{clip-path:url(#a);}.c{fill:#666;}</style><clipPath id="a"><circle class="a" cx="6" cy="6" r="6" transform="translate(107 189)"/></clipPath></defs><g class="b" transform="translate(-107 -189)"><path class="c" d="M11.347,4.3c-.067-.354-.283-.583-.551-.583h-.058a1.4,1.4,0,0,1-1.4-1.4,1.6,1.6,0,0,1,.122-.535.736.736,0,0,0-.248-.89L9.192.875,7.77.085,7.752.077a.751.751,0,0,0-.3-.061.814.814,0,0,0-.579.236A2.054,2.054,0,0,1,5.764.873,2.058,2.058,0,0,1,4.648.241.814.814,0,0,0,4.065,0a.75.75,0,0,0-.3.059L3.751.066,2.279.875,2.261.887a.735.735,0,0,0-.25.889,1.585,1.585,0,0,1,.123.536,1.4,1.4,0,0,1-1.4,1.4H.672c-.267,0-.483.229-.55.583A7.288,7.288,0,0,0,0,5.421a7.287,7.287,0,0,0,.12,1.123c.067.354.283.583.551.583H.731a1.4,1.4,0,0,1,1.4,1.4,1.6,1.6,0,0,1-.122.535.737.737,0,0,0,.248.89l.017.012,1.4.78.018.008a.742.742,0,0,0,.3.061.8.8,0,0,0,.583-.246A2.053,2.053,0,0,1,5.7,9.91a2.071,2.071,0,0,1,1.14.673.8.8,0,0,0,.587.251h0a.741.741,0,0,0,.3-.059l.018-.008,1.446-.8.017-.012a.736.736,0,0,0,.249-.889,1.614,1.614,0,0,1-.123-.536,1.4,1.4,0,0,1,1.4-1.4H10.8c.268,0,.484-.229.551-.583a7.223,7.223,0,0,0,.12-1.123A7.259,7.259,0,0,0,11.347,4.3ZM4,10.006l-1.22-.682A2.331,2.331,0,0,0,2.94,8.53,2.208,2.208,0,0,0,.9,6.328a6.122,6.122,0,0,1-.094-.906A6.136,6.136,0,0,1,.9,4.515a2.207,2.207,0,0,0,2.038-2.2,2.33,2.33,0,0,0-.163-.792l1.3-.713h0a3.876,3.876,0,0,0,.493.418,2.1,2.1,0,0,0,1.2.454A2.106,2.106,0,0,0,6.95,1.234a3.857,3.857,0,0,0,.49-.41h0l1.252.7a2.332,2.332,0,0,0-.163.793,2.207,2.207,0,0,0,2.038,2.2,6.154,6.154,0,0,1,.094.907,6.13,6.13,0,0,1-.094.907,2.207,2.207,0,0,0-2.038,2.2,2.329,2.329,0,0,0,.163.793l-1.267.7a3.935,3.935,0,0,0-.495-.437A2.1,2.1,0,0,0,5.7,9.1a2.1,2.1,0,0,0-1.216.473A3.966,3.966,0,0,0,4,10.006ZM7.74,5.414a2.03,2.03,0,1,0-2.03,2.03A2.033,2.033,0,0,0,7.74,5.414ZM5.71,4.189A1.225,1.225,0,1,1,4.485,5.414,1.226,1.226,0,0,1,5.71,4.189Z" transform="translate(107.266 189.583)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
1
pagePrinter/static/icon/icon-type.svg
Normal file
1
pagePrinter/static/icon/icon-type.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12" viewBox="0 0 12 12"><defs><style>.a{fill:#ebd4d4;}.b{clip-path:url(#a);}.c{fill:#666;}</style><clipPath id="a"><circle class="a" cx="6" cy="6" r="6" transform="translate(92 207)"/></clipPath></defs><g class="b" transform="translate(-92 -207)"><g transform="translate(8.104 122.991)"><path class="c" d="M94.819,87.957,90.794,89.44a1.178,1.178,0,0,1-.8,0L85.816,87.96a.738.738,0,0,1,0-1.4l4.179-1.485a1.177,1.177,0,0,1,.8,0l4.025,1.483a.738.738,0,0,1,0,1.392Zm-.262-.713-4.025-1.483a.42.42,0,0,0-.284,0l-4.179,1.485a.014.014,0,0,0-.012.017.014.014,0,0,0,.012.017l4.179,1.485a.417.417,0,0,0,.284,0l4.025-1.483a.014.014,0,0,0,.012-.016.014.014,0,0,0-.012-.018Zm-8.742,5.4,4.421,1.6a.457.457,0,0,0,.315,0l4.259-1.6a.37.37,0,1,1,.262.692l-4.259,1.6a1.208,1.208,0,0,1-.422.076,1.2,1.2,0,0,1-.409-.072l-4.422-1.6a.37.37,0,1,1,.254-.695Z" transform="translate(-0.414)"/><path class="c" d="M89.978,501.885a1.2,1.2,0,0,1-.409-.072l-4.422-1.6a.37.37,0,1,1,.253-.7l4.421,1.6a.459.459,0,0,0,.315,0l4.259-1.6a.37.37,0,0,1,.262.692l-4.259,1.6a1.2,1.2,0,0,1-.421.077Z" transform="translate(0 -409.627)"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
1
pagePrinter/static/icon/icon-warning.svg
Normal file
1
pagePrinter/static/icon/icon-warning.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="17.37" height="15" viewBox="0 0 17.37 15"><defs><style>.a{fill:#ff9f2e;}</style></defs><path class="a" d="M104.051,176.877h17.37l-8.684-15Zm9.474-2.369h-1.579V172.93h1.579Zm0-3.157h-1.579v-3.158h1.579Z" transform="translate(-104.051 -161.877)"/></svg>
|
||||
|
After Width: | Height: | Size: 298 B |
Reference in New Issue
Block a user