Commit 3765eaa7 authored by 刘文虎's avatar 刘文虎

步进器小数点

parent 9edeca16
;(function() {
let NODE_ENV = 'prod' // dev:开发环境 | test:测试环境 | prod:生产环境
let NODE_ENV = 'test' // dev:开发环境 | test:测试环境 | prod:生产环境
let ENV_VAR = null
let VERSION = 'v1.0.15'
if (process.env.NODE_ENV === 'development') {
......
......@@ -2,18 +2,25 @@
<u-popup v-model="show" border-radius="24" safe-area-inset-bottom mode="bottom" :mask-close-able="true" @close="close">
<view class="unit-popup">
<view class="unit-popup-top">
<text>{{form.uid?'编辑明细':'添加明细'}}</text>
<view class="close" @click="close">
<u-icon name="close" class="unit-popup-top-right"></u-icon>
</view>
<text>{{ form.uid ? '编辑明细' : '添加明细' }}</text>
<view class="close" @click="close"><u-icon name="close" class="unit-popup-top-right"></u-icon></view>
</view>
<view class="cell-particular">
<view class="part-view">
<view class="item-view">
<view class="label-view">收费项</view>
<view class="value-view charge-view">
<u-input type="text" :clearable="false" :custom-style="customStyle" cursor-spacing='50' :placeholder-style="placeholderStyle" v-model="form.name" placeholder="填写费用名称" @blur="leaveInput"
@focus="getHeight" />
<u-input
type="text"
:clearable="false"
:custom-style="customStyle"
cursor-spacing="50"
:placeholder-style="placeholderStyle"
v-model="form.name"
placeholder="填写费用名称"
@blur="leaveInput"
@focus="getHeight"
/>
<ab-button content="常用" :customStyle="customStyleUnit" @click="chooseCharge"></ab-button>
</view>
</view>
......@@ -23,15 +30,7 @@
<view class="label-view">数量</view>
<view class="value-view number-view">
<!-- <u-number-box :min="1" color="#cccccc" size="28" v-model="form.number" bg-color="#ffffff"></u-number-box> -->
<number-box
theme-colors="#02A074"
inputHeight="40"
:min="0"
:max="99999999"
:positiveInteger="false"
size="28"
v-model="form.number"
></number-box>
<number-box theme-colors="#02A074" inputHeight="40" :min="0" :max="99999999" :positiveInteger="false" size="28" v-model="form.number"></number-box>
<view class="unit-view">
<u-input
type="text"
......@@ -40,7 +39,7 @@
:placeholder-style="placeholderStyle"
v-model="form.unit"
placeholder="填写单位,如箱"
cursor-spacing='50'
cursor-spacing="50"
@blur="leaveInput"
@focus="getHeight"
/>
......@@ -60,23 +59,19 @@
:placeholder-style="placeholderStyle"
v-model="form.unitPrice"
placeholder="填写单价费用"
cursor-spacing='50'
cursor-spacing="50"
@blur="leaveInput"
@focus="getHeight"
/>
</view>
</view>
<view class="item-view" >
<view class="item-view">
<view class="label-view">
<text class="label-view-label">
总价:
</text>
<text class="label-view-total">¥{{total}}</text>
<text class="label-view-label">总价:</text>
<text class="label-view-total">¥{{ total }}</text>
</view>
<!-- <view class="value-view" :style="{ 'padding-bottom': height + 'px' }"> -->
<view class="value-view">
<ab-button content="保存明细" :disabled="disabled" :customStyle="customStyleSubmit" @click="submit"></ab-button>
</view>
<view class="value-view"><ab-button content="保存明细" :disabled="disabled" :customStyle="customStyleSubmit" @click="submit"></ab-button></view>
</view>
</view>
</view>
......@@ -85,36 +80,35 @@
</template>
<script>
import { formatCount,random_string } from '@/utils/common.js';
import { formatCount, random_string } from '@/utils/common.js';
import AbButton from '@/components/common/ab-button.vue';
export default {
components: {
AbButton,
},
props: {
AbButton
},
props: {},
data() {
return {
show: false,
formatCount,
height:0,
height: 0,
placeholderStyle: 'color:#ccc;font-size:28rpx;font-weight: bold;',
customStyle: {
fontSize: '28rpx',
textAlign: 'right',
fontWeight: 'bold'
},
form:{
form: {
name: '',
number: 1,
unit: '',
unitPrice: '',
unitPrice: ''
},
defaultInfo:{
defaultInfo: {
name: '',
number: 1,
unit: '',
unitPrice: '',
unitPrice: ''
},
customStyleUnit: {
'margin-left': '24rpx',
......@@ -122,29 +116,29 @@ export default {
height: '40rpx',
'font-size': '20rpx',
background: 'transparent',
'border-radius':' 8rpx',
border:' 2rpx solid #02A074',
color: '#02A074',
'border-radius': ' 8rpx',
border: ' 2rpx solid #02A074',
color: '#02A074'
},
customStyleSubmit:{
customStyleSubmit: {
width: '240rpx',
height: '96rpx',
'font-size': '32rpx',
'font-size': '32rpx'
},
rules:[
rules: [
{
value:"name",
label:"请输入收费项"
value: 'name',
label: '请输入收费项'
},
{
value:"number",
label:"请输入数量"
value: 'number',
label: '请输入数量'
},
{
value:"unitPrice",
label:"请输入单价"
},
],
value: 'unitPrice',
label: '请输入单价'
}
]
};
},
computed: {
......@@ -158,61 +152,79 @@ export default {
}
return total;
},
disabled(){
let flag=false
this.rules.map(item=>{
if(!this.form[item.value]){
flag=true
disabled() {
let flag = false;
this.rules.map(item => {
if (!this.form[item.value]) {
flag = true;
}
})
});
return flag;
}
},
created() {
uni.$on('charge-selected', res => {
var form = JSON.parse(res || {})
this.form.unit = form.unit
this.form.name = form.serviceName
});
var form = JSON.parse(res || {});
this.form.unit = form.unit;
this.form.name = form.serviceName;
});
},
destroyed() {
uni.$off('charge-selected')
uni.$off('charge-selected');
},
methods: {
open(detail) {
if(detail&&detail.uid){
this.form={
if (detail && detail.uid) {
this.form = {
...detail
}
};
}
this.show = true;
},
close() {
this.show = false;
this.$nextTick(()=>{
this.form={
this.$nextTick(() => {
this.form = {
...this.defaultInfo
}
})
};
});
},
handleCheck(item) {
this.$emit('change', item.value);
this.close();
},
submit(){
for (let i =0;i<this.rules.length;i++) {
if(!this.form[this.rules[i].value]){
this.showToast(this.rules[i].label)
return false
keepTwoDecimalFull(num) {
var result = parseFloat(num);
if (isNaN(result)) {
return false;
}
result = Math.round(num * 100) / 100;
var s_x = result.toString();
var pos_decimal = s_x.indexOf('.');
if (pos_decimal < 0) {
pos_decimal = s_x.length;
s_x += '.';
}
while (s_x.length <= pos_decimal + 2) {
s_x += '0';
}
return s_x;
},
submit() {
for (let i = 0; i < this.rules.length; i++) {
if (!this.form[this.rules[i].value]) {
this.showToast(this.rules[i].label);
return false;
}
}
if(!this.form.uid){
this.form.uid=random_string()
if (!this.form.uid) {
this.form.uid = random_string();
}
this.form.total=this.total
console.log(this.form)
this.$emit("submit",this.form)
this.close()
this.form.number = parseFloat(this.keepTwoDecimalFull(this.form.number));
this.form.total = this.total;
console.log(this.form);
this.$emit('submit', this.form);
this.close();
},
//离开输入框触发
leaveInput(e) {
......@@ -240,18 +252,17 @@ export default {
}
},
chooseUnit() {
this.$emit("openUnit",this.form.unit)
this.$emit('openUnit', this.form.unit);
},
chooseCharge() {
this.$u.route({
url: '/pages/maintain-bill/charges',
type: 'navigateTo',
params: {
}
});
this.$u.route({
url: '/pages/maintain-bill/charges',
type: 'navigateTo',
params: {}
});
},
handleChangeUnit(e){
this.form.unit=e
handleChangeUnit(e) {
this.form.unit = e;
}
}
};
......@@ -268,7 +279,7 @@ export default {
font-weight: bold;
color: #333333;
line-height: 32rpx;
.close{
.close {
width: 56rpx;
height: 56rpx;
display: flex;
......@@ -283,7 +294,7 @@ export default {
}
.cell-particular {
position: relative;
.part-view {
position: relative;
background-color: #ffffff;
......@@ -299,11 +310,11 @@ export default {
color: #8d8d8d;
flex-shrink: 0;
}
.label-view-label{
.label-view-label {
font-weight: bold;
}
.label-view-total{
color: #FC524D;
.label-view-total {
color: #fc524d;
font-weight: bold;
font-size: 40rpx;
}
......@@ -316,13 +327,13 @@ export default {
display: flex;
justify-content: flex-end;
align-items: center;
}
.number-view{
}
.number-view {
display: flex;
align-items: center;
}
.unit-view {
border-left: 1rpx solid #F6F7FA;
border-left: 1rpx solid #f6f7fa;
margin-left: 20rpx;
padding-left: 24rpx;
width: 320rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment