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

步进器小数点

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