| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 | <!DOCTYPE html><html>	<head>		<title>客户账户-添加</title>		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">		<meta name="viewport"			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />		<!-- 所有的 css js 资源 -->		<link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">		<link rel="stylesheet" href="../../static/sa.css">		<script src="../../static/kj/vue.min.js"></script>		<script src="../../static/kj/element-ui/index.js"></script>		<script src="../../static/kj/httpVueLoader.js"></script>		<script src="../../static/kj/jquery.min.js"></script>		<script src="../../static/kj/layer/layer.js"></script>		<script src="../../static/sa.js"></script>		<script src="../../static/kj/upload-util.js"></script>		<script src="../../static/node_modules/crypto-js/crypto-js.js"></script>		<style type="text/css">			.c-panel .el-form .c-label {				width: 8em !important;			}			.c-panel .el-form .el-input,			.c-panel .el-form .el-textarea__inner {				width: 250px;			}			#ast .c-label:before {				content: '*';				color: red;			}		</style>	</head>	<body>		<div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">			<!-- ------- 内容部分 ------- -->			<div class="s-body">				<div class="c-panel" style="text-align:center; ">					<div class="c-title">充值</div>					<el-form v-if="m">						<!--                <sa-item type="text" name="主键" v-model="m.id" br></sa-item>-->						<!--                <sa-item type="text" name="客户id" v-model="m.customerId" br></sa-item>-->						<sa-item type="text" name="客户名称" v-model="m.customerName" :disabled="true" br></sa-item>						<sa-item type="text" name="客户余额" v-model="m.totalMoney" :disabled="true" br></sa-item>						<sa-item id="ast" type="text" name="充值金额" br>							<el-input v-model="m.preTopupMoney" placeholder="请输入金额" @change="computeChange">								<template slot="suffix">元</template>							</el-input>						</sa-item>						<sa-item type="text" name="优惠金额" br>							<el-input type="text" v-model="m.discountMoney" placeholder="请输入金额" @change="computeChange">								<template slot="suffix">元</template>							</el-input>						</sa-item>						<sa-item type="text" name="实收金额" br>							<el-input ref="totalTopupInp" type="text" v-model="m.totalTopup" :disabled="true">								<template slot="suffix">元</template>							</el-input>						</sa-item>						<sa-item type="enum" name="付款方式" br>							<el-select v-model="m.payingType">								<el-option label="请选择" v-for="(item,index) in payingTypeList" :key="item.id"									:label="item.name" :value="item.id">								</el-option>							</el-select>						</sa-item>						<sa-item type="textarea" name="充值说明" v-model="m.remark" :rows="2" br></sa-item>					</el-form>				</div>			</div>			<!-- ------- 底部按钮 ------- -->			<div class="s-foot">				<el-button type="primary" @click="ok()">确定</el-button>				<el-button @click="sa.closeCurrIframe()">取消</el-button>			</div>		</div>		<script>			var app = new Vue({				components: {					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')				},				el: '.vue-box',				data: {					id: sa.p('id', ''),					customerId: sa.p('customerId', 0), // 获取超链接中的id参数(0=添加,非0=修改)					m: null, // 实体对象					payingTypeList: [], //付款方式集合				},				methods: {					// 创建一个 默认Model					createModel: function() {						return {							id: '', // 主键							customerId: sa.p('customerId', ''), // 客户id							customerName: '',							totalMoney: '', // 总金额							preTopupMoney: '', //预充值金额							discountMoney: '', //优惠金额							totalTopup: '', //总计充值							payingType: '',							salt: '',							remark: '', // 备注						}					},					// 提交数据					ok: function() {						let that = this;						let m = {							...this.m						};						sa.checkNull(m.preTopupMoney, '预存金额不能为空!');						if (!this.computeChange()) {							return;						}						const key = 'h!f78tr#L3D$2Z0q';						m.salt = key.split("").reverse().join("");						m.totalTopup = this.encrypt(m.totalTopup, key);						m.discountMoney = this.encrypt(m.discountMoney, key);						m.preTopupMoney = this.encrypt(m.preTopupMoney, key);						m.id = sa.p('id', 0);						sa.ajax('/TbAccount/recharge2', sa.removeNull(m), function(res) {							layer.open({								content: '充值成功!', //内容区域								move: false, //是否可以拖动,默认可以拖动								btn: ['确定'],								btn1: function(index) {									//    layer.close(index);//关闭弹框									that.clean();								},								cancel: function() {									that.clean();								}							});						}.bind(this));					},					// 添加/修改 完成后的动作					clean: function() {						parent.app.f5(); // 刷新父页面列表						sa.closeCurrIframe(); // 关闭本页					},					getPayingType() {						sa.ajax('/TbAccount/getPayingType', function(res) {							this.payingTypeList = res.data;						}.bind(this))					},					computeChange(value) {						let preMoney = this.m.preTopupMoney;						let disMoney = this.m.discountMoney;						if (!disMoney) {							disMoney = 0;						}						if (isNaN(preMoney)) {							throw {								type: 'sa-error',								msg: "预充值金额必须是数字!"							};							return false;						}						if (isNaN(disMoney)) {							throw {								type: 'sa-error',								msg: "优惠金额必须是数字!"							};							return false;						}						if (preMoney.length > 1 && preMoney.substring(0, 1) == 0) {							throw {								type: 'sa-error',								msg: "请输入规范的数字,前面不要带零!"							};							return false;						}						if (disMoney.length > 1 && disMoney.substring(0, 1) == 0) {							throw {								type: 'sa-error',								msg: "请输入规范的数字,前面不要带零!"							};							return false;						}						if (!preMoney) {							return false;						}						preMoney = Number(preMoney);						disMoney = Number(disMoney);						if (preMoney <= 0) {							throw {								type: 'sa-error',								msg: "预存金额需大于零元!"							};							return false;						}						if (disMoney < 0) {							throw {								type: 'sa-error',								msg: "优惠金额不得低于零元!"							};							return false;						}						let totalM = preMoney - disMoney;						delete this.m.totalTopup;						this.$set(this.m, "totalTopup", totalM)						return true;					},					encrypt(word, keyStr) { // word, keyStr第一个参数是加密的字段名字  第二个是key值(16位)						if (!word) {							return;						}						if (typeof word === 'object') {							// 如果传入的data是json对象,先转义为json字符串							try {								word = JSON.stringify(word);							} catch (error) {								console.log('error:', error);							}						}						keyStr = keyStr || 'h!f78tr#L3D$2Z0q'; // 密文(密钥)						let key = CryptoJS.enc.Utf8.parse(keyStr);						let src = CryptoJS.enc.Utf8.parse(word);						let encrypted = CryptoJS.AES.encrypt(src, key, {							mode: CryptoJS.mode.ECB,							padding: CryptoJS.pad.Pkcs7						});						//  console.log(encrypted.toString())						return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);					},					decrypt(word, keyStr) {						if (!word) {							return;						}						keyStr = keyStr || 'h!f78tr#L3D$2Z0q';						let base64 = CryptoJS.enc.Base64.parse(word);						let src = CryptoJS.enc.Base64.stringify(base64);						let key = CryptoJS.enc.Utf8.parse(keyStr);						let decrypt = CryptoJS.AES.decrypt(src, key, {							mode: CryptoJS.mode.ECB,							padding: CryptoJS.pad.Pkcs7						});						//  let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);						return CryptoJS.enc.Utf8.stringify(decrypt).toString();					},				},				mounted: function() {					// 初始化数据					this.m = this.createModel();					this.m.customerId = this.customerId;					this.getPayingType();					sa.ajax('/TbAccount/getList', sa.removeNull(this.m), function(res) {						if (res.data && res.data.length == 1) {							this.m = res.data[0];							if (this.m.totalMoney) {								this.m.totalMoney = this.decrypt(this.m.totalMoney, this.m.salt);							} else {								this.m.totalMoney = 0;							}							this.$set(this.m, "discountMoney", 0);							this.$set(this.m, "payingType", 1);						} else {							sa.alert('未能查找到客户详细数据,窗口将在5秒后关闭!');							setTimeout(function() {								sa.closeCurrIframe()							}, 5000)						}					}.bind(this))				}			})		</script>	</body></html>
 |