Commit 9f47ee90 authored by 黄奎's avatar 黄奎

11

parent e73b5eb3
......@@ -165,8 +165,8 @@
<text>数量</text>
</view>
<view class="inputBoxRight">
<input class="text-right" type="text" v-model="item.UserNum"
@input="checkInteger(item,'UserNum')" @change="getNum()" />
<input class="text-right" type="number" v-model="item.UserNum"
@input="handleInput($event, item, 'UserNum')" @blur="handleBlur(item, 'UserNum')" />
</view>
</view>
<view class="inputBox row justify-between">
......@@ -174,8 +174,8 @@
<text>金额</text>
</view>
<view class="inputBoxRight">
<input class="text-right" type="text" v-model="item.UnitPrice"
@input="changePrice($event,item,index,true)" />
<input class="text-right" type="number" v-model="item.UnitPrice" @input="handleInput($event, item, 'UnitPrice')"
@blur="handleBlur(item, 'UnitPrice')" />
</view>
</view>
<view class="inputBox row justify-between noBorder">
......@@ -220,7 +220,7 @@
import upload from "../upload";
import singleChoice from "../singleChoice";
export default {
props: ['data', 'optionList'],
props: ['data', 'dataIndex1', 'optionList'],
components: {
upload,
singleChoice,
......@@ -244,74 +244,53 @@
ReimIndex: 0,
ReimDatas: {},
BusList: [], //车信息
HotelOrderListReport: [], //酒店信息,合团
DiningList: [], //餐厅
ScenicList: [], //景点
OtherList: [], //其他订单信息
TipList: [], //小费收入
TeamList: [], //团费小计
SelfPlayingIncomeList: [], //自费收入
SelfPlayingExpendList: [], //自费支出
LeaderShopList: [], //购物报账
}
},
watch: {
data: {
dataIndex1: {
handler(newVal, oldVal) {
var newJson = JSON.parse(JSON.stringify(newVal));
console.log("newJson", newJson);
this.params = newJson;
this.BusList = this.params.BusList //车信息
this.dataIndex = this.params.dataIndex1;
this.getRenderingData()
this.getTotal()
if (oldVal != newVal) {
this.initData()
}
},
deep: true,
immediate: false
},
datas: {
handler(newVal, oldVal) {
//this.updateData()
this.getRenderingData();
},
deep: true,
immediate: false
}
},
mounted() {
this.initData();
},
methods: {
changePrice(e, item, index, isMinus) {
var value = e.detail.value;
var t = value.charAt(0);
value = value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
value = value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
value = value
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", ".");
value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
//如果第一位是负号,则允许添加 如果不允许添加负号 可以把这块注释掉
//是否允许负数
if (isMinus && t == '-') {
value = '-' + value;
}
if (value === '' || value === '.') {
value = 0;
}
item.UnitPrice = value;
this.$set(this.datas.ReimburseList.ReimburseDetailsList, index, item);
this.getNum();
// 在模板中的使用示例
handleInput(e, item, field) {
const value = e.detail.value;
console.log("handleInput",value)
const validValue = this.$utils.checkInteger(value,true);
// 更新数据
item[field] = validValue;
// 触发其他逻辑(如计算)
this.getTotal();
},
handleBlur(item, field) {
console.log("handleBlur",item[field])
const formattedValue = this.$utils.checkPrice(item[field],true);
// 更新数据
item[field] = formattedValue;
this.$set(item,field,formattedValue);
// 触发其他逻辑
this.getTotal();
},
getNum() {
//初始化数据
initData() {
var newJson = JSON.parse(JSON.stringify(this.data));
this.params = newJson;
this.BusList = this.params.BusList //车信息
this.dataIndex = this.params.dataIndex1;
this.getRenderingData();
this.getTotal();
},
getTotal() {
let total = 0;
console.log("getTotal", JSON.parse(JSON.stringify(this.datas.ReimburseList.ReimburseDetailsList)))
this.datas.ReimburseList.ReimburseDetailsList.forEach(x => {
total += x.UserNum * x.UnitPrice
})
......@@ -320,6 +299,7 @@
},
delInfor(index) {
this.datas.ReimburseList.ReimburseDetailsList.splice(index, 1)
this.getTotal()
},
delImg(index) {
this.datas.ReimburseList.VoucherPicList.splice(index, 1);
......@@ -336,8 +316,8 @@
},
getRenderingData() {
this.datas = this.BusList[this.dataIndex]
console.log("this.datas", this.datas);
if (this.datas.VoucherPicList == null) this.datas.VoucherPicList = []
if (!this.datas.VoucherPicList) this.datas.VoucherPicList = []
if (!this.datas.ReimburseList.ReimburseDetailsList) this.datas.ReimburseList.ReimburseDetailsList = []
this.ReimDatas = JSON.parse(JSON.stringify(this.datas.ReimburseList.ReimburseDetailsList[0]))
},
showOptionVisible(index) {
......@@ -366,12 +346,8 @@
current: src,
longPressActions: {
itemList: ["发送给朋友", "保存图片", "收藏"],
success: function(data) {
},
fail: function(err) {
},
success: function(data) {},
fail: function(err) {},
},
});
},
......@@ -387,7 +363,6 @@
UnitPrice: 0,
}
this.datas.ReimburseList.ReimburseDetailsList.push(JSON.parse(JSON.stringify(this.ReimDatas)))
},
onSuccess(infor) {
this.datas.ReimburseList.VoucherPicList.push({
......
......@@ -89,7 +89,7 @@
</headeDatas>
</view>
<!-- 车信息-->
<productInfor1 :data="params" v-show="params.type==1" @change="getNewData" :optionList="busTypeList">
<productInfor1 v-if="params.type==1" :data="params" :dataIndex1="params.dataIndex1" @change="getNewData" :optionList="busTypeList">
</productInfor1>
<!-- 酒店信息-->
<productInfor2 :data="params" v-if="params.type==2" @change="getNewData" :optionList="hotelTypeList">
......@@ -220,7 +220,7 @@
left: 0,
},
{
name: '购物报账',
name: '购物店/车购',
id: 10,
val: 'refs10',
left: 0,
......@@ -539,6 +539,11 @@
console.log("dmcstatistics_post_SetNewLeaderApplyList_V2",JSON.parse(JSON.stringify(res.data)));
if (res.resultCode == 1) {
this.loading = false
uni.showToast({
title: '操作成功!',
icon: 'success',
duration: 2000
});
uni.hideLoading()
this.init()
}
......
......@@ -7,7 +7,8 @@ function calcContentHeight(chaliang) {
})
return contentHeight
}
function SystemInfo() {//获取屏幕宽高
function SystemInfo() { //获取屏幕宽高
let SystemInfo = {}
uni.getSystemInfo({
success(res) {
......@@ -17,7 +18,8 @@ function SystemInfo() {//获取屏幕宽高
})
return SystemInfo
}
function getRect(selector) {//获取元素的信息
function getRect(selector) { //获取元素的信息
return new Promise((resolve) => {
let view = uni.createSelectorQuery().select(selector);
view.fields({
......@@ -29,18 +31,21 @@ function getRect(selector) {//获取元素的信息
}).exec();
})
}
function getretailer() {//判断是否是分销商
function getretailer() { //判断是否是分销商
let isdistributor = false
let mall_UserInfo = uni.getStorageSync("b2b_user");
//mall_UserInfo.customerType (1-直客,2-同行)
if (mall_UserInfo && mall_UserInfo.token && mall_UserInfo.customerType==2) {
if (mall_UserInfo && mall_UserInfo.token && mall_UserInfo.customerType == 2) {
isdistributor = true
}
return isdistributor
}
// #ifdef MP-ALIPAY
// 引入消息模板方法
const { requestSubscribeMessage } = requirePlugin("subscribeMsg");
const {
requestSubscribeMessage
} = requirePlugin("subscribeMsg");
//支付宝小程序订阅消息
function SubscribeMsgAli(cb) {
let idsArr = uni.getStorageSync("basedata")?.mall?.alimessage ?? [];
......@@ -167,23 +172,28 @@ function formatDates(date, fmt) {
}
return fmt;
};
function padLeftZero(str) {
return ('00' + str).substr(str.length);
}
function setAttatchParameter(vm){
function setAttatchParameter(vm) {
vm.$uiConfig.DIRECT_PARAMETER = ''
if(uni.getStorageSync('b2b_user')){
const {salesBaseInfo, erpBaseInfo} = uni.getStorageSync('b2b_user')
if(erpBaseInfo && erpBaseInfo.employeeId){
vm.$uiConfig.DIRECT_PARAMETER = '&direct_user_id='+erpBaseInfo.employeeId
}else if(salesBaseInfo && salesBaseInfo.employeeId){
vm.$uiConfig.DIRECT_PARAMETER = '&direct_user_id='+salesBaseInfo.employeeId
if (uni.getStorageSync('b2b_user')) {
const {
salesBaseInfo,
erpBaseInfo
} = uni.getStorageSync('b2b_user')
if (erpBaseInfo && erpBaseInfo.employeeId) {
vm.$uiConfig.DIRECT_PARAMETER = '&direct_user_id=' + erpBaseInfo.employeeId
} else if (salesBaseInfo && salesBaseInfo.employeeId) {
vm.$uiConfig.DIRECT_PARAMETER = '&direct_user_id=' + salesBaseInfo.employeeId
}
}
}
//获取几天后的日期
function GetDateFewFaysLater(Days){
function GetDateFewFaysLater(Days) {
let today = new Date()
let date2 = new Date(today);
......@@ -195,18 +205,18 @@ function GetDateFewFaysLater(Days){
const day = date.getDate();
return {
year: year,
month: month>9?month:'0'+month,
mm:month,
day: day>9?day:'0'+day,
dd:day,
month: month > 9 ? month : '0' + month,
mm: month,
day: day > 9 ? day : '0' + day,
dd: day,
date: `${year}-${month>9?month:'0'+month}-${day>9?day:'0'+day}`,
hour:date.getHours(),
minute:date.getMinutes(),
second:date.getSeconds()
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
}
function goZanYangUrl(){
function goZanYangUrl() {
uni.navigateToMiniProgram({
appId: 'wxacd9f8cc3480d29e',
path: `pages/index/index?jzTravelOpenId=${uni.getStorageSync('mall_UserInfo').OpenId}`, // 目标页面路径(可选)
......@@ -227,6 +237,47 @@ function goZanYangUrl(){
});
}
//验证只能输入2位小数【负数:isMinus传true】
function checkPrice(value, isMinus) {
console.log("checkPrice1", value);
var newValue = '';
if (value) {
newValue = value + '';
}
var t = newValue.length > 0 ? newValue[0] : '';
console.log("checkPrice2", newValue);
newValue = newValue.replace(/[^\d.]/g, ''); //清除“数字”和“.”以外的字符
newValue = newValue.replace(/\.{2,}/g, '.'); //只保留第一个. 清除多余的
newValue = newValue
.replace('.', "$#$")
.replace(/\./g, '')
.replace('$#$', '.');
newValue = newValue.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
//如果第一位是负号,则允许添加 如果不允许添加负号 可以把这块注释掉
//是否允许负数
if (isMinus && t == '-') {
newValue = '-' + newValue;
}
return newValue;
}
//验证只能输入整数【负数:isMinus传true】
function checkInteger(value, isMinus) {
console.log("checkInteger1", value)
var newValue = '';
if (value) {
newValue = value + '';
}
console.log("checkInteger2", newValue)
var t = newValue.length > 0 ? newValue[0] : '';
newValue = newValue.replace(/[^\d]/g, '');
//是否允许负数
if (isMinus && t == '-') {
newValue = '-' + newValue;
}
return newValue;
}
export default {
calcContentHeight,
SystemInfo,
......@@ -239,5 +290,7 @@ export default {
formatDates,
setAttatchParameter,
GetDateFewFaysLater,
goZanYangUrl
goZanYangUrl,
checkInteger,
checkPrice,
}
\ No newline at end of file
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