初始上传

This commit is contained in:
2026-04-04 17:27:12 +08:00
parent 4d80d28eb4
commit b7e11774ee
11191 changed files with 1588469 additions and 0 deletions

View File

@@ -0,0 +1,379 @@
<template>
<base-page>
<view class="common-wrap common-form body-overhide">
<view class="common-title">电子秤设置</view>
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
电子秤名称
</label>
<view class="form-input-inline"><input type="text" v-model="formData.name" class="form-input" /></view>
<text class="form-word-aux"></text>
</view>
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
秤类型
</label>
<view class="form-input-inline border-none">
<view class="scale-type">
<view :class="{ active: formData.type == 'barcode' }" @click="formData.type = 'barcode'">条码秤</view>
<view :class="{ active: formData.type == 'cashier' }" @click="formData.type = 'cashier'">收银秤</view>
</view>
</view>
</view>
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
电子秤品牌
</label>
<view class="form-input-inline border-none">
<uni-data-select v-model="formData.brand" :localdata="brandList" label=""></uni-data-select>
</view>
</view>
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
电子秤型号
</label>
<view class="form-input-inline border-none">
<uni-data-select v-model="formData.model" :localdata="modelList"></uni-data-select>
</view>
</view>
<view class="common-form-item">
<label class="form-label">通讯方式</label>
<view class="form-inline">
<radio-group @change="networkTypeChange" class="form-radio-group">
<label class="radio form-radio-item">
<radio value="tcp" :checked="formData.network_type == 'tcp'" />
TCP
</label>
<label class="radio form-radio-item">
<radio value="serialport" :checked="formData.network_type == 'serialport'" />
串口
</label>
</radio-group>
</view>
</view>
<view class="scale-tips" v-if="formData.brand == 'dahua' && formData.model == 'TM'">
<view>使用大华电子秤前需先配置一下电子秤条码格式配置方式为</view>
<view>
使用大华电子秤厂官方提供的大华电子秤上位机软件TMA4.0连接到设备后打开基础设置 -> 系统参数设置条码格式为 FFWWWWWNNNNNC
FFWWWWWNNNNNEEEEEC设置好之后点击下载下载成功之后即配置完成
</view>
</view>
<view class="scale-tips" v-if="formData.brand == 'aclas' && formData.model == 'LS'">
<view>使用顶尖电子秤需将电子秤默认条码类型配置为7 或者 87</view>
</view>
<view v-show="formData.network_type == 'tcp'">
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
设备ip地址
</label>
<view class="form-input-inline">
<input type="text" v-model="formData.config.ip" class="form-input" />
</view>
<text class="form-word-aux"></text>
</view>
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
设备端口号
</label>
<view class="form-input-inline">
<input type="text" v-model="formData.config.port" class="form-input" />
</view>
<text class="form-word-aux"></text>
</view>
</view>
<view v-show="formData.network_type == 'serialport'">
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
串口名称
</label>
<view class="form-input-inline">
<input type="text" v-model="formData.config.serialport" class="form-input" />
</view>
<text class="form-word-aux"></text>
</view>
<view class="common-form-item">
<label class="form-label">
<text class="required">*</text>
串口波特率
</label>
<view class="form-input-inline">
<input type="text" v-model="formData.config.baudrate" class="form-input" />
</view>
<text class="form-word-aux"></text>
</view>
</view>
<view class="common-btn-wrap">
<button type="primary" class="screen-btn" @click="saveFn">保存</button>
<button type="default" class="screen-btn" @click="back">返回</button>
</view>
</view>
</base-page>
</template>
<script>
import uniDataSelect from '@/components/uni-data-select/uni-data-select.vue';
import {
getScaleDetail,
getScaleBrand,
addScale,
editScale
} from '@/api/scale.js'
export default {
components: {
uniDataSelect
},
data() {
return {
brandList: [],
modelList: [],
formData: {
type: 'barcode',
name: "",
brand: "",
model: "",
config: {
ip: '',
port: '',
serialport: '',
baudrate: ''
},
network_type: 'tcp'
},
flag: false,
scaleId: 0,
scaleBrand: {}
};
},
async onLoad(option) {
await this.getScaleBrandFn();
if (option.scale_id) {
this.scaleId = option.scale_id;
this.getDetailFn();
}
},
onShow() {},
watch: {
'formData.brand': {
handler: function(nval) {
if (nval) {
let modelList = this.scaleBrand[nval].model_list
this.modelList = Object.keys(modelList).map(key => {
return {
value: key,
text: modelList[key].model_name
}
})
if (this.formData.model && !Object.keys(modelList).includes(this.formData.model)) this.formData
.model = '';
} else {
this.formData.model = '';
this.modelList = []
}
},
immediate: true
}
},
methods: {
async getScaleBrandFn() {
if (!this.addon.includes('scale')) {
this.$util.showToast({
title: '未安装电子秤插件'
});
return;
}
let res = await getScaleBrand()
if (res.code == 0) {
this.scaleBrand = res.data
let brandList = [];
Object.keys(this.scaleBrand).forEach(key => {
brandList.push({
text: this.scaleBrand[key].brand_name,
value: key
})
})
this.brandList = brandList
}
},
bradnChange(e) {
this.formData.model = e.detail.value;
},
selectBrand(e) {
this.formData.brand = e;
},
saveFn() {
if (!this.addon.includes('scale')) {
this.$util.showToast({
title: '未安装电子秤插件'
});
return;
}
if (this.check()) {
if (this.flag) return false;
this.flag = true;
let data = this.$util.deepClone(this.formData)
data.config = JSON.stringify(this.formData.config)
data.scale_id = this.scaleId
let action = '';
if (this.scaleId) {
action = editScale(data)
} else {
action = addScale(data)
}
action.then(res => {
this.flag = false;
this.$util.showToast({
title: res.message
});
if (res.code >= 0) {
setTimeout(() => {
this.$util.redirectTo('/pages/scale/list');
}, 1500);
}
});
}
},
back() {
this.$util.redirectTo('/pages/scale/list');
},
check() {
if (!this.formData.name) {
this.$util.showToast({
title: '请输入电子秤名称'
});
return false;
}
if (!this.formData.model) {
this.$util.showToast({
title: '请选择电子秤型号'
});
return false;
}
if (this.formData.network_type == 'tcp') {
if (!this.formData.config.ip) {
this.$util.showToast({
title: '请输入设备IP地址'
});
return false;
}
if (!this.formData.config.port) {
this.$util.showToast({
title: '请输入设备端口号'
});
return false;
}
}
if (this.formData.network_type == 'serialport') {
if (!this.formData.config.serialport) {
this.$util.showToast({
title: '请输入串口名称'
});
return false;
}
if (!this.formData.config.baudrate) {
this.$util.showToast({
title: '请输入串口波特率'
});
return false;
}
}
return true;
},
getDetailFn() {
if (!this.addon.includes('scale')) {
this.$util.showToast({
title: '未安装电子秤插件'
});
return;
}
getScaleDetail({
"scale_id": this.scaleId
}).then(res => {
if (res.code >= 0) {
if (res.data) {
this.formData = res.data
}
}
})
},
networkTypeChange(e) {
this.formData.network_type = e.detail.value
}
}
};
</script>
<style lang="scss" scoped>
.common-wrap {
padding: 30rpx;
background-color: #fff;
@extend %body-overhide;
}
.common-title {
font-size: 0.18rem;
margin-bottom: 0.2rem;
}
.scale-type {
display: flex;
align-items: center;
view {
width: 1rem;
height: 0.35rem;
line-height: 0.35rem;
text-align: center;
font-size: 0.14rem;
border: 0.01rem solid #e6e6e6;
border-left-width: 0;
transition: all 0.3s;
cursor: pointer;
&:hover,
&.active {
border-color: $primary-color;
color: $primary-color;
background-color: var(--primary-color-light-9);
box-shadow: -0.01rem 0 0 0 $primary-color;
}
&:first-child {
border-left-width: 0.01rem;
box-shadow: none;
}
}
}
.border-none {
border: none !important;
}
/deep/ .uni-select {
border-radius: 0;
}
.scale-tips {
display: inline-block;
padding: .1rem;
border-radius: .05rem;
color: $primary-color !important;
border: .01rem solid $primary-color !important;
background-color: var(--primary-color-light-9) !important;
margin-left: 1.1rem;
margin-bottom: 0.1rem;
}
</style>

View File

@@ -0,0 +1,239 @@
<template>
<base-page>
<view class="scalelist">
<view class="scalelist-box">
<view class="scalelist-left">
<view class="scale-title">
电子秤
<text class="iconfont icongengduo1"></text>
</view>
<view class="scale-list-wrap">
<block v-if="list.length > 0">
<scroll-view scroll-y="true" class="scale-list-scroll all-scroll" @scrolltolower="getList">
<view class="item" @click="scaleSelect(item, index)" v-for="(item, index) in list" :key="index" :class="index == selectScaleKeys ? 'itemhover' : ''">
<view class="item-right w-full">
<view class="flex justify-between w-full">
<view class="scale-name">{{ item.name }}<text class="scale-type-tag">{{ item.type == 'cashier' ? '收银秤': '条码秤' }}</text></view>
<view class="flex items-center" v-if="item.connect_status">
<text class="status-icon success"></text>已连接
</view>
<view class="flex items-center" v-else>
<text class="status-icon fail"></text>未连接
</view>
</view>
<view class="scale-money">{{ item.brand_name }}-{{ item.model_name }}</view>
</view>
</view>
</scroll-view>
</block>
<view class="notYet" v-else-if="!one_judge && list.length == 0">暂无电子秤</view>
</view>
<view class="add-printer">
<button type="default" class="primary-btn" @click="addScale">添加电子秤</button>
</view>
</view>
<view class="scalelist-right" v-show="!one_judge">
<view class="scale-title">电子秤详情</view>
<view class="scale-information">
<block v-if="JSON.stringify(detail) != '{}'">
<view class="title">基本信息</view>
<view class="information-box">
<view class="box-left">
<view class="information">
<view>电子秤名称</view>
<view>{{ detail.name }}</view>
</view>
<view class="information">
<view>电子秤类型</view>
<view>{{ detail.type == 'cashier' ? '收银秤' : '条码秤' }}</view>
</view>
<view class="information">
<view>电子秤品牌</view>
<view>{{ detail.brand_name }}</view>
</view>
<view class="information">
<view>电子秤型号</view>
<view>{{ detail.model_name }}</view>
</view>
</view>
</view>
</block>
<block v-else>
<image class="cart-empty" src="@/static/cashier/cart_empty.png" mode="widthFix"/>
</block>
</view>
<view class="button-box" v-if="JSON.stringify(detail) != '{}'">
<button class="default-btn" @click="$refs.deletePop.open()">删除</button>
<button class="default-btn" @click="editScale(detail.scale_id)">修改</button>
</view>
</view>
</view>
</view>
<!-- 删除 -->
<uni-popup ref="deletePop" type="center">
<view class="confirm-pop">
<view class="title">确定要删除吗</view>
<view class="btn">
<button type="primary" class="default-btn btn save" @click="$refs.deletePop.close()">取消</button>
<button type="primary" class="primary-btn btn" @click="deleteScaleFn(detail.scale_id)">确定</button>
</view>
</view>
</uni-popup>
</base-page>
</template>
<script>
import {
getScaleList,
getScaleDetail,
deleteScale
} from '@/api/scale.js'
var self;
export default {
data() {
return {
selectScaleKeys: 0,
search_text: '',
page: 1,
// 每次返回数据数
page_size: 8,
// 第一次请求列表做详情渲染判断
one_judge: true,
//详情数据
detail: {},
brandList: {
yilianyun: '易联云',
'365': '365'
},
flag: false,
template: {},
list: [],
connectSuccess: []
};
},
onLoad() {
// 初始化请求打印机列表数据
this.getList();
self = this;
},
methods: {
switchStoreAfter() {
this.page = 1;
this.list = [];
this.detail = {};
this.one_judge = false;
this.getList()
},
getList() {
if (!this.addon.includes('scale')) {
this.$util.showToast({
title: '未安装电子秤插件'
});
return;
}
getScaleList({
page: this.page,
page_size: this.page_size,
}).then(res => {
if (res.data.list.length == 0 && this.one_judge) {
this.detail = {};
this.one_judge = false;
}
if (res.code >= 0 && res.data.list.length != 0) {
this.page += 1;
if (this.list.length == 0) {
this.list = res.data.list;
} else {
this.list = this.list.concat(res.data.list);
}
// 检测设备是否连接
this.checkConnect();
//初始时加载一遍详情数据
if (this.one_judge) {
this.getDetailFn(this.list[0].scale_id);
}
}
})
},
scaleSelect(item, keys) {
this.selectScaleKeys = keys;
this.getDetailFn(item.scale_id);
},
addScale() {
this.$util.redirectTo('/pages/scale/add');
},
editScale(scale_id) {
this.$util.redirectTo('/pages/scale/add', {
scale_id: scale_id
});
},
getDetailFn(scale_id) {
getScaleDetail({
scale_id
}).then(res => {
if (res.code == 0) {
this.detail = res.data;
this.one_judge = false;
}
})
},
deleteScaleFn(scale_id) {
if (this.flag) return;
this.flag = true;
deleteScale({scale_id}).then(res => {
this.flag = false;
if (res.code >= 0) {
this.page = 1;
this.list = [];
this.one_judge = true;
this.$refs.deletePop.close()
this.getList();
} else {
this.$util.showToast({
title: res.message
});
}
})
},
checkConnect() {
if (typeof window.POS_DATA_CALLBACK == 'function') delete window.POS_DATA_CALLBACK;
/**
* 商品同步数据回调
* @param {Object} text
*/
window.POS_DATA_CALLBACK = function (text) {
let data = text.split(':');
let index = parseInt(data[0]);
switch (data[1]) {
case 'PingWeigher':
self.$set(self.list[index], 'connect_status', parseInt(data[3]));
break;
}
};
try {
let weigher = this.list.map(item => {
item.config = typeof item.config == 'string' ? JSON.parse(item.config) : scale.config;
return item
});
this.$pos.send('PingWeigher', JSON.stringify({
weigher
}));
} catch (e) {
}
}
}
};
</script>
<style scoped lang="scss">
@import './public/css/scale.scss';
</style>

View File

@@ -0,0 +1,356 @@
.scalelist {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
.scalelist-box {
width: 100%;
height: 100%;
background: #ffffff;
display: flex;
.scalelist-left {
width: 5rem;
height: 100%;
border-right: 0.01rem solid #e6e6e6;
box-sizing: border-box;
display: flex;
flex-direction: column;
.notYet {
color: #e6e6e6;
font-size: 0.4rem;
margin-top: 3rem;
text-align: center;
}
.add-printer {
padding: 0.24rem 0.2rem;
background: #fff;
button {
height: .4rem;
line-height: .4rem;
}
}
.scale-title {
text-align: center;
line-height: 0.6rem;
font-size: 0.18rem;
font-weight: 500;
height: 0.6rem;
border-bottom: 0.01rem solid #e6e6e6;
box-sizing: border-box;
position: relative;
.icongengduo1 {
position: absolute;
top: 50%;
right: 0.2rem;
transform: translateY(-50%);
font-size: 0.3rem;
color: $primary-color;
}
}
.scale-list-wrap {
flex: 1;
height: 0;
}
.scale-list-scroll {
width: 100%;
height: 100%;
.itemhover {
background: var(--primary-color-light-9);
}
.item {
width: 100%;
display: flex;
align-items: center;
padding: 0.2rem;
box-sizing: border-box;
border-bottom: 0.01rem solid #e6e6e6;
image {
width: 0.7rem;
height: 0.7rem;
margin-right: 0.1rem;
}
.item-right {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 0.6rem;
.scale-name {
font-size: 0.16rem;
}
.scale-money {
font-size: 0.14rem;
}
}
}
}
}
.scalelist-right {
width: 0;
flex: 1;
height: 100%;
border-right: 0.01rem solid #e6e6e6;
box-sizing: border-box;
position: relative;
.scale-title {
text-align: center;
line-height: 0.6rem;
font-size: 0.18rem;
font-weight: 500;
height: 0.6rem;
border-bottom: 0.01rem solid #e6e6e6;
box-sizing: border-box;
position: relative;
.icongengduo1,.iconguanbi1 {
position: absolute;
top: 50%;
right: 0.2rem;
transform: translateY(-50%);
font-size: 0.3rem;
color: $primary-color;
cursor: pointer;
}
}
.scale-information {
width: 100%;
padding: 0.2rem 0.2rem 0.88rem 0.2rem;
box-sizing: border-box;
height: calc(100% - 0.6rem);
overflow: auto;
position: relative;
.title {
font-size: 0.18rem;
margin-bottom: 0.32rem;
}
.title2 {
margin-bottom: 0.35rem;
}
.information-box {
display: flex;
justify-content: space-between;
.box-left {
width: 5rem;
.information {
width: 100%;
padding-left: 0.1rem;
box-sizing: border-box;
display: flex;
align-items: center;
margin-bottom: 0.15rem;
view {
color: #303133;
font-size: 0.14rem;
}
view:nth-child(1) {
width: 1.3rem;
margin-right: 0.16rem;
text-align: right;
}
view:nth-child(2) {
width: 74%;
margin-right: 0.23rem;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
.information:last-child {
margin-bottom: 0.35rem;
}
}
.scale-img {
width: 1.5rem;
height: 1.5rem;
}
}
.table {
width: 100%;
height: 2.6rem;
box-sizing: border-box;
.table-all {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0.38rem;
box-sizing: border-box;
.table-td {
font-size: 0.14rem;
text-align: left;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
}
.table-th {
height: 0.56rem;
background: #f7f8fa;
}
.table-tb {
width: 100%;
height: calc(100% - 0.56rem);
.table-tr {
height: 0.7rem;
border-bottom: 0.01rem solid #e6e6e6;
box-sizing: border-box;
.table-td {
image {
width: 0.5rem;
height: 0.5rem;
}
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
}
}
}
}
}
}
}
view {
color: #303133;
}
/deep/ .uni-scroll-view::-webkit-scrollbar {
width: 0.05rem;
height: 0.3rem;
}
/deep/ .uni-scroll-view::-webkit-scrollbar-thumb {
border-radius: 0.1rem;
box-shadow: inset 0 0 0.05rem rgba(0, 0, 0, 0.2);
background: rgba(193, 193, 193, 1);
}
.scale-information::-webkit-scrollbar {
width: 0.05rem;
height: 0.3rem;
}
.scale-information::-webkit-scrollbar-thumb {
border-radius: 0.1rem;
box-shadow: inset 0 0 0.05rem rgba(0, 0, 0, 0.2);
background: rgba(193, 193, 193, 1);
}
.button-box {
position: absolute;
width: 100%;
right: 0;
bottom: 0;
background-color: #fff;
display: flex;
align-items: center;
justify-content: flex-end;
padding: 0.24rem 0.2rem;
box-sizing: border-box;
button {
min-width: 0.9rem;
height: 0.4rem;
line-height: 0.4rem;
margin: 0;
margin-left: 0.1rem;
}
}
.cart-empty {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 2.1rem;
}
.form-content {
margin-top: 0.2rem;
.form-item {
margin-bottom: 0.1rem;
display: flex;
.form-label {
width: 1.3rem;
text-align: right;
padding-right: 0.1rem;
box-sizing: border-box;
height: 0.32rem;
line-height: 0.32rem;
.required {
color: red;
margin-right: 0.03rem;
}
}
.form-inline {
width: 2.4rem;
line-height: 0.32rem;
margin-right: 0.1rem;
box-sizing: border-box;
.form-input {
border-width: 0.01rem;
border-style: solid;
background-color: #fff;
color: rgba(0, 0, 0, 0.85);
border-radius: 0.02rem;
padding-left: 0.1rem;
height: 0.32rem;
line-height: 0.32rem;
font-size: 0.14rem;
border-color: #e6e6e6;
}
.form-textarea {
border-width: 0.01rem;
border-style: solid;
background-color: #fff;
color: rgba(0, 0, 0, 0.85);
border-radius: 0.02rem;
padding-left: 0.1rem;
line-height: 0.32rem;
font-size: 0.14rem;
border-color: #e6e6e6;
height: 1rem;
}
button {
width: calc(50% - 0.05rem);
display: inline-block;
margin-right: 0.1rem;
&:nth-child(2) {
margin-right: 0;
}
}
}
}
}
.order-type{
margin-right: 0.1rem;
}
.status-icon {
width: .05rem;
height: .05rem;
border-radius: 50%;
margin-right: .05rem;
&.success {
background: limegreen;
}
&.fail {
background: red;
}
}
.scale-type-tag {
border: 0.01rem solid $primary-color;
color: $primary-color;
background-color: #fff;
border-radius: 0.02rem;
width: -webkit-fit-content;
width: fit-content;
padding: 0.01rem 0.05rem;
margin-left: 0.10rem
}