|
@@ -0,0 +1,241 @@
|
|
|
+<template>
|
|
|
+ <div class="manage-root discount-rules">
|
|
|
+ <Header />
|
|
|
+ <div class="manage-root-contain">
|
|
|
+ <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
|
|
|
+ <div class="manage-root-contain-right">
|
|
|
+ <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
|
|
|
+ <div class="create-bottom">
|
|
|
+ <h3>折扣规则</h3>
|
|
|
+ <ul>
|
|
|
+ <li v-for="(item,index) in rule_list" :key="index">
|
|
|
+ <el-input
|
|
|
+ class="rule-item"
|
|
|
+ placeholder=""
|
|
|
+ v-model="item.buy_count"
|
|
|
+ @input="handleInput(item,'buy_count')">
|
|
|
+ <template slot="append">期</template>
|
|
|
+ </el-input>
|
|
|
+ <el-input
|
|
|
+ class="rule-item"
|
|
|
+ placeholder=""
|
|
|
+ v-model="item.discount"
|
|
|
+ @input="handleInputLittle(item,'discount')"
|
|
|
+ @blur="handleInputLittleBlur(item,'discount')">
|
|
|
+ <template slot="append">折</template>
|
|
|
+ </el-input>
|
|
|
+ <i class="el-icon-delete" @click="handleDelete(index)"></i>
|
|
|
+ </li>
|
|
|
+ <a @click="handleAdd">增加折扣</a>
|
|
|
+ </ul>
|
|
|
+ <el-button type="primary" @click="onSubmit()" size="small" :loading="loading">保存</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
|
|
|
+//例如:import 《组件名称》from ‘《组件路径》';
|
|
|
+import Header from "../../components/Header.vue";
|
|
|
+import NavMenu from "../../components/NavMenu.vue"
|
|
|
+import Breadcrumb from '../../components/Breadcrumb.vue';
|
|
|
+import { getLogin } from "@/api/ajax";
|
|
|
+
|
|
|
+export default {
|
|
|
+ //import引入的组件需要注入到对象中才能使用
|
|
|
+ components: { Header, NavMenu, Breadcrumb },
|
|
|
+ props: {},
|
|
|
+ data() {
|
|
|
+ //这里存放数据
|
|
|
+ return {
|
|
|
+ activeMenuIndex: "discount_setting",
|
|
|
+ breadcrumbList:[
|
|
|
+ {
|
|
|
+ icon:'setting',
|
|
|
+ url:'',
|
|
|
+ text:''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ icon:'',
|
|
|
+ url:'',
|
|
|
+ notLink: true,
|
|
|
+ text:'系统配置'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ icon:'',
|
|
|
+ url:'',
|
|
|
+ text:'折扣规则'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ loading: false,
|
|
|
+ rule_list: [
|
|
|
+ {
|
|
|
+ buy_count: null,
|
|
|
+ discount: null
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //计算属性 类似于data概念
|
|
|
+ computed: {
|
|
|
+
|
|
|
+ },
|
|
|
+ //监控data中数据变化
|
|
|
+ watch: {
|
|
|
+
|
|
|
+ },
|
|
|
+ //方法集合
|
|
|
+ methods: {
|
|
|
+ handleInput(item,fild){
|
|
|
+ let value=item[fild].replace(/^(0+)|[^0-9]+/g,'')
|
|
|
+ item[fild] = value!==''?Number(value):null
|
|
|
+ },
|
|
|
+ handleInputLittle(item,fild){
|
|
|
+ let value=item[fild]
|
|
|
+ value = value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
|
|
|
+ value = value.replace(/^\./g, ""); //验证第一个字符是数字而不是
|
|
|
+ value = value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
|
|
|
+ value = value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
|
|
|
+ value = value.replace(/^(\-)*(\d+)\.(\d).*$/, '$1$2.$3'); //只能输入一个小数
|
|
|
+ item[fild] = value
|
|
|
+ },
|
|
|
+ handleInputLittleBlur(item,fild){
|
|
|
+ let value=item[fild].toString()
|
|
|
+ if(value){
|
|
|
+ let list = value.split('.')
|
|
|
+ if(list[0]>=10){
|
|
|
+ this.$message.warning('折扣不能大于10')
|
|
|
+ list[0]=list[0].substring(list[0].length-1)
|
|
|
+ }
|
|
|
+ item[fild]=parseFloat(list[0]+(list[1]?'.'+list[1]:''))
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 提交表单
|
|
|
+ onSubmit(){
|
|
|
+ if(this.rule_list.length===0||this.rule_list[this.rule_list.length-1].buy_count&&this.rule_list[this.rule_list.length-1].discount){
|
|
|
+ this.loading = true
|
|
|
+ let MethodName = "/OrgServer/Manager/SysConfigManager/SetSysConfig_DiscountRule";
|
|
|
+ let data = {
|
|
|
+ rule_list: this.rule_list
|
|
|
+ }
|
|
|
+ getLogin(MethodName, data)
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status===1){
|
|
|
+ this.loading = false
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ }
|
|
|
+ }).catch((res) =>{
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.$message.warning('请填写完整')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 得到配置信息
|
|
|
+ getInfo(){
|
|
|
+ let MethodName = "/OrgServer/Manager/SysConfigManager/GetSysConfig_DiscountRule";
|
|
|
+ getLogin(MethodName, {})
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status===1){
|
|
|
+ if(res.rule_list.length>0){
|
|
|
+ this.rule_list = res.rule_list
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch((res) =>{
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleDelete(index){
|
|
|
+ this.rule_list.splice(index, 1);
|
|
|
+ },
|
|
|
+ handleAdd(){
|
|
|
+ if(this.rule_list.length===0||this.rule_list[this.rule_list.length-1].buy_count&&this.rule_list[this.rule_list.length-1].discount){
|
|
|
+ this.rule_list.push({
|
|
|
+ buy_count: null,
|
|
|
+ discount: null
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.$message.warning('请填写完整')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //生命周期 - 创建完成(可以访问当前this实例)
|
|
|
+ created() {
|
|
|
+ this.getInfo()
|
|
|
+ },
|
|
|
+ //生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
+ mounted() {
|
|
|
+
|
|
|
+ },
|
|
|
+ //生命周期-创建之前
|
|
|
+ beforeCreated() { },
|
|
|
+ //生命周期-挂载之前
|
|
|
+ beforeMount() { },
|
|
|
+ //生命周期-更新之前
|
|
|
+ beforUpdate() { },
|
|
|
+ //生命周期-更新之后
|
|
|
+ updated() { },
|
|
|
+ //生命周期-销毁之前
|
|
|
+ beforeDestory() { },
|
|
|
+ //生命周期-销毁完成
|
|
|
+ destoryed() { },
|
|
|
+ //如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
+ activated() { }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+/* @import url(); 引入css类 */
|
|
|
+.create-bottom{
|
|
|
+ padding: 40px 40px;
|
|
|
+ margin-top: 16px;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 4px;
|
|
|
+ height: calc(100vh - 140px);
|
|
|
+ overflow: auto;
|
|
|
+ h3{
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: 500;
|
|
|
+ line-height: 28px;
|
|
|
+ margin: 0 0 28px 0;
|
|
|
+ color: #1D2129;
|
|
|
+ }
|
|
|
+ ul{
|
|
|
+ list-style: none;
|
|
|
+ padding: 0;
|
|
|
+ li{
|
|
|
+ margin-bottom: 8px;
|
|
|
+ }
|
|
|
+ .el-icon-delete{
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ a{
|
|
|
+ color: #175DFF;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 22px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.discount-rules{
|
|
|
+ .rule-item{
|
|
|
+ width: 100px;
|
|
|
+ margin-right: 8px;
|
|
|
+ .el-input-group__append{
|
|
|
+ border: none;
|
|
|
+ border-left: 1px solid #E5E6EB;
|
|
|
+ background: #F2F3F5;
|
|
|
+ padding: 0 10px;
|
|
|
+ }
|
|
|
+ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
|
|
|
+ -webkit-appearance: none !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|