123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <template>
- <a-modal
- centered
- class="rechargeEdit-modal"
- :footer="null"
- :maskClosable="false"
- :title="itemSn?'编辑':'新增'"
- v-model="isShow"
- @cancel="isShow=false"
- :width="750">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="rechargeEdit-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol"
- >
- <a-form-model-item label="充值规则" prop="rechargeAmount">
- <div>
- 充值<a-input-number
- id="rechargeEdit-rechargeAmount"
- v-model.trim="form.rechargeAmount"
- style="width: 35%;margin:0 10px;"
- :min="0.01"
- :max="999999"
- :precision="2"
- :disabled="itemSn?true:false"
- placeholder="请输入"/>元,送<a-input-number
- id="rechargeEdit-giveAmount"
- v-model.trim="form.giveAmount"
- style="width: 35%;margin:0 10px;"
- :min="0.01"
- :max="999999"
- :precision="2"
- :disabled="itemSn?true:false"
- placeholder="请输入"/>元抵扣
- </div>
- </a-form-model-item>
- <a-form-model-item label="备注">
- <a-textarea
- :autosize="{minRows: 5, maxRows: 5}"
- id="rechargeEdit-remarks"
- :maxLength="50"
- v-model="form.remarks"
- placeholder="请输入易码通显示的充值备注(最多50个字符)"
- allowClear />
- </a-form-model-item>
- <div class="tipWord">注意:请设置【抵扣产品】</div>
- </a-form-model>
- <div class="btn-cont">
- <a-button type="primary" id="rechargeEdit-save" @click="handleSave">保存</a-button>
- <a-button id="rechargeEdit-cancel" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { rechargeRuleDetail, rechargeRuleCreate, rechargeRuleModify } from '@/api/rechargeRule'
- export default {
- name: 'RechargeEditModal',
- mixins: [commonMixin],
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- itemSn: {
- type: [Number, String],
- default: ''
- }
- },
- data () {
- return {
- spinning: false,
- isShow: this.openModal, // 是否打开弹框
- formItemLayout: {// form表单中label设置
- labelCol: { span: 3 },
- wrapperCol: { span: 18 }
- },
- // 提交数据
- form: {
- rechargeAmount: undefined, // 充值金额
- giveAmount: undefined, // 赠送金额
- remarks: undefined// 备注
- },
- // 必填项判断
- rules: {
- rechargeAmount: [{ required: true, message: '请输入充值金额', trigger: 'blur' }]
- }
- }
- },
- methods: {
- // 保存
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- if (!_this.form.giveAmount) {
- _this.$message.warning('请输入赠送金额')
- return
- }
- _this.spinning = true
- const ajaxName = _this.itemSn ? rechargeRuleModify : rechargeRuleCreate
- ajaxName(_this.form).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$emit('ok')
- setTimeout(function () {
- _this.isShow = false
- }, 300)
- }
- _this.spinning = false
- })
- } else {
- return false
- }
- })
- },
- // 获取详情
- getDetail () {
- const _this = this
- _this.spinning = true
- rechargeRuleDetail({ sn: _this.itemSn }).then(res => {
- if (res.status == 200) {
- _this.form = res.data
- }
- _this.spinning = false
- })
- },
- // 重置
- resetForm (obj) {
- this.form.rechargeAmount = undefined
- this.form.giveAmount = undefined
- this.form.remarks = undefined
- this.$refs.ruleForm.resetFields()
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.resetForm()
- }
- },
- itemSn (newValue, oldValue) {
- if (newValue) {
- this.getDetail()
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .rechargeEdit-modal{
- /deep/.ant-modal-body {
- padding: 40px 40px 24px;
- }
- .rechargeEdit-form{
- text-align: center;
- }
- .tipWord{
- margin:-10px 0 0 48px;
- color:gray;
- }
- .btn-cont {
- text-align: center;
- margin: 50px 0 10px;
- }
- }
- </style>
|