|
@@ -0,0 +1,249 @@
|
|
|
+<template>
|
|
|
+ <el-dialog :close-on-click-modal="false" title="编辑联盟卡信息" :visible.sync="editAllianceVisible" width="890px">
|
|
|
+ <div style="height: 500px; overflow: auto">
|
|
|
+ <el-form :rules="editAllianceRules" ref="formRef" :model="editAllianceForm" label-width="auto">
|
|
|
+ <el-form-item label="联盟卡名称" prop="name">
|
|
|
+ <el-input v-model="editAllianceForm.name"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="封面" prop="coverUrl">
|
|
|
+ <ImageUpload :limit="1" v-model="editAllianceForm.coverUrl"></ImageUpload>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="抵扣价格" prop="deductionPrice">
|
|
|
+ <el-input v-model="editAllianceForm.deductionPrice"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="发行张数" prop="receiptCount">
|
|
|
+ <el-input v-model="editAllianceForm.receiptCount"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="状态" prop="state">
|
|
|
+ <el-select style="width: 100%" v-model="editAllianceForm.state" placeholder="请选择状态">
|
|
|
+ <el-option label="审核中" :value="1"></el-option>
|
|
|
+ <el-option label="通过" :value="2"></el-option>
|
|
|
+ <el-option label="不通过" :value="3"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="联盟卡类型" prop="type">
|
|
|
+ <el-select style="width: 100%" v-model="editAllianceForm.type" placeholder="请选择联盟卡类型">
|
|
|
+ <el-option label="联盟卡" :value="1"></el-option>
|
|
|
+ <el-option label="会员卡" :value="2"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="是否发行" prop="isIssuance">
|
|
|
+ <el-select style="width: 100%" v-model="editAllianceForm.isIssuance" placeholder="请选择联盟卡是否发行">
|
|
|
+ <el-option label="未发行" :value="0"></el-option>
|
|
|
+ <el-option label="已发行" :value="1"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="到期时间" prop="expirationTime">
|
|
|
+ <el-date-picker style="width: 100%" v-model="editAllianceForm.expirationTime" type="datetime" placeholder="请选择到期时间"></el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="团长佣金" prop="headOfCommission">
|
|
|
+ <el-input v-model="editAllianceForm.headOfCommission"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="合伙人佣金" prop="partnerCommission">
|
|
|
+ <el-input v-model="editAllianceForm.partnerCommission"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="联盟卡分佣比例" prop="allianceCardCommissionRatio">
|
|
|
+ <el-input v-model="editAllianceForm.allianceCardCommissionRatio"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="权益信息" prop="statement">
|
|
|
+ <el-input type="textarea" v-model="editAllianceForm.statement"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="使用说明" prop="useInstructions">
|
|
|
+ <el-input type="textarea" v-model="editAllianceForm.useInstructions"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="editAllianceVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handleConfirm" :loading="loading">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import ImageUpload from '@/components/ImageUpload'
|
|
|
+import { editAlianceInfoApi } from '@/api/business'
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: { ImageUpload },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ editAllianceVisible: false,
|
|
|
+ loading: false,
|
|
|
+ baseInfo: {},
|
|
|
+ editAllianceForm: {
|
|
|
+ id: undefined,
|
|
|
+ name: '',
|
|
|
+ coverUrl: '',
|
|
|
+ purchasePrice: undefined,
|
|
|
+ deductionPrice: undefined,
|
|
|
+ receiptCount: undefined,
|
|
|
+ state: undefined,
|
|
|
+ type: undefined,
|
|
|
+ isIssuance: undefined,
|
|
|
+ expirationTime: '',
|
|
|
+ headOfCommission: undefined,
|
|
|
+ partnerCommission: undefined,
|
|
|
+ statement: '',
|
|
|
+ useInstructions: '',
|
|
|
+ allianceCardCommissionRatio: undefined
|
|
|
+ },
|
|
|
+
|
|
|
+ editAllianceRules: {
|
|
|
+ name: [{ required: true, message: '请填写联盟卡名称', trigger: 'blur' }],
|
|
|
+ deductionPrice: [
|
|
|
+ { required: true, message: '请填写抵扣价格', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ pattern: /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/,
|
|
|
+ message: '金额必须为正数且最多两位小数',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ receiptCount: [
|
|
|
+ { required: true, message: '请填写联盟卡发行张数', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (!Number.isInteger(value) || value <= 0) {
|
|
|
+ callback(new Error('必须是大于0的整数'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ state: [{ required: true, message: '请选择联盟卡状态', trigger: 'change' }],
|
|
|
+ type: [{ required: true, message: '请选择联盟卡类型', trigger: 'change' }],
|
|
|
+ isIssuance: [{ required: true, message: '请选择联盟卡是否发行', trigger: 'change' }],
|
|
|
+ expirationTime: [{ required: true, message: '请选择到期时间', trigger: 'change' }],
|
|
|
+ headOfCommission: [
|
|
|
+ { required: true, message: '请填写团长佣金', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ pattern: /^\d+(\.\d{1,2})?$/,
|
|
|
+ message: '金额格式不正确(最多两位小数)',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ partnerCommission: [
|
|
|
+ { required: true, message: '请填写合伙人佣金', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ pattern: /^\d+(\.\d{1,2})?$/,
|
|
|
+ message: '金额格式不正确(最多两位小数)',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ allianceCardCommissionRatio: [
|
|
|
+ { required: true, message: '请填写联盟卡分佣比例', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ // 首先确保值是有效的数值
|
|
|
+ value *= 1
|
|
|
+ if (isNaN(value)) {
|
|
|
+ callback(new Error('请输入有效数字'))
|
|
|
+ } else if (value < 0 || value >= 1) {
|
|
|
+ // 修改这里,确保范围在0-1之间
|
|
|
+ callback(new Error('分佣比例需在0-1之间, 不能为1'))
|
|
|
+ } else if (!/^\d+(\.\d{1,2})?$/.test(value)) {
|
|
|
+ callback(new Error('最多保留两位小数'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ statement: [{ required: true, message: '请填写权益信息', trigger: 'blur' }],
|
|
|
+ useInstructions: [{ required: true, message: '请填写使用说明', trigger: 'blur' }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ watch: {
|
|
|
+ editAllianceVisible(value) {
|
|
|
+ if (!value) {
|
|
|
+ this.reset()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ handleOpen(row) {
|
|
|
+ this.editAllianceVisible = true
|
|
|
+ this.editAllianceForm.name = row.name
|
|
|
+ this.editAllianceForm.id = row.id
|
|
|
+ this.editAllianceForm.coverUrl = row.coverUrl
|
|
|
+ this.editAllianceForm.purchasePrice = row.purchasePrice
|
|
|
+ this.editAllianceForm.deductionPrice = row.deductionPrice
|
|
|
+ this.editAllianceForm.receiptCount = row.receiptCount
|
|
|
+ this.editAllianceForm.state = row.state
|
|
|
+ this.editAllianceForm.type = row.type
|
|
|
+ this.editAllianceForm.isIssuance = row.isIssuance
|
|
|
+ this.editAllianceForm.expirationTime = row.expirationTime
|
|
|
+ this.editAllianceForm.headOfCommission = row.headOfCommission
|
|
|
+ this.editAllianceForm.partnerCommission = row.partnerCommission
|
|
|
+ this.editAllianceForm.statement = row.statement
|
|
|
+ this.editAllianceForm.useInstructions = row.useInstructions
|
|
|
+ this.editAllianceForm.allianceCardCommissionRatio = row.allianceCardCommissionRatio
|
|
|
+ },
|
|
|
+
|
|
|
+ async handleConfirm() {
|
|
|
+ try {
|
|
|
+ this.loading = true
|
|
|
+ await this.$refs.formRef.validate()
|
|
|
+ await editAlianceInfoApi(this.editAllianceForm)
|
|
|
+ this.$message.success('编辑成功')
|
|
|
+ this.$emit('refresh')
|
|
|
+ this.reset()
|
|
|
+ this.close()
|
|
|
+ } catch (error) {
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ reset() {
|
|
|
+ this.editAllianceForm = {
|
|
|
+ id: undefined,
|
|
|
+ name: '',
|
|
|
+ coverUrl: '',
|
|
|
+ purchasePrice: undefined,
|
|
|
+ deductionPrice: undefined,
|
|
|
+ receiptCount: undefined,
|
|
|
+ state: undefined,
|
|
|
+ type: undefined,
|
|
|
+ isIssuance: undefined,
|
|
|
+ expirationTime: '',
|
|
|
+ headOfCommission: undefined,
|
|
|
+ partnerCommission: undefined,
|
|
|
+ statement: '',
|
|
|
+ useInstructions: '',
|
|
|
+ allianceCardCommissionRatio: undefined
|
|
|
+ }
|
|
|
+ this.baseInfo = {}
|
|
|
+ },
|
|
|
+
|
|
|
+ close() {
|
|
|
+ this.editAllianceVisible = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+::v-deep .el-descriptions__header {
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
+</style>
|