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

11

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