|
@@ -0,0 +1,334 @@
|
|
|
+<template>
|
|
|
+ <el-card shadow="always" style="overflow: auto;" :body-style="{ padding: '10px' }">
|
|
|
+ <template #header>
|
|
|
+ <div class="card-header">
|
|
|
+ <span>{{ props.primary ? '编辑' : '添加' }}非首充模板</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <el-form :model="dataForm" label-width="130px" ref="form" v-loading="loading" class="pr-6">
|
|
|
+ <el-form-item label="模板名称" prop="name"
|
|
|
+ :rules="[{ required: true, message: '模板名称必须填写' }, { max: 20, message: '至多输入20个字符', trigger: 'blur' }]">
|
|
|
+ <el-input class="item" v-model="dataForm.name" clearable />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="充值档位" prop="options" :rules="[{ required: true, message: '请添加充值档位' }]">
|
|
|
+ <div class="flex justify-start w-full" shadow="never">
|
|
|
+ <div class="mr-6" style="min-width:400px;">
|
|
|
+ <div class="pt-5 pl-2">
|
|
|
+ <Add @click="openGears(null, null)" />
|
|
|
+ </div>
|
|
|
+ <el-table :data="tableData" class="w-full mt-3" v-loading="loading">
|
|
|
+ <el-table-column prop="price" label="价格">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ scope.row.price }}元</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="sequence_text" label="位置" />
|
|
|
+ <el-table-column prop="type_name" label="挡位类型" />
|
|
|
+ <el-table-column prop="default_text" label="默认项">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ scope.row.is_default ? '默认项' : '非默认项' }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" size="small" @click="openGears(scope.$index, scope.row)">编辑</el-button>
|
|
|
+ <el-button link type="danger" size="small" @click.prevent="deleteRow(scope.$index)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <div class="device-wrap">
|
|
|
+ <div class="md-iphone-5 md-white-device">
|
|
|
+ <div class="md-body">
|
|
|
+ <div class="md-buttons"></div>
|
|
|
+ <div class="md-front-camera"></div>
|
|
|
+ <div class="md-top-speaker"></div>
|
|
|
+ <div class="md-screen">
|
|
|
+ <img src="@/assets/pay-config-bg.jpg" alt="" />
|
|
|
+ <div class="preview-list">
|
|
|
+ <div class="pay-item" v-for="(row, i) in tableData" :key="i"
|
|
|
+ :class="[row.is_default == 1 ? 'defalut' : '']">
|
|
|
+ <p>{{ row.price }}元</p>
|
|
|
+ <p v-show="row.given">多送{{ row.given }}看币</p>
|
|
|
+ <div class="tipss">{{ gearsName[row.type] }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <button class="md-home-button"></button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否为默认模板" prop="status" :rules="[{ required: true, message: '请设置是否为默认模板' }]"
|
|
|
+ v-if="!rolesIdentify.includes('optimizer')">
|
|
|
+ <el-switch v-model="dataForm.status" :active-value="1" :inactive-value="0" />
|
|
|
+ </el-form-item>
|
|
|
+ <div class="flex justify-start ml-9">
|
|
|
+ <el-button type="primary" size="default" @click="cancel">取消</el-button>
|
|
|
+ <el-button type="primary" @click="submitFormChange(form)">确认</el-button>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ <Dialog v-model="visibleGears" :title="title" width="40%" destroy-on-close>
|
|
|
+ <createGears @close="gearsClose" @success="success" :data="tableData" :primary="gearsData" />
|
|
|
+ </Dialog>
|
|
|
+ </el-card>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { onMounted, ref } from 'vue';
|
|
|
+import {
|
|
|
+ channelPaytemplateShow,
|
|
|
+ channelPaytemplateStore,
|
|
|
+ channelPaytemplateUpdate,
|
|
|
+ channelPaytemplateOptionTypeList
|
|
|
+} from '@/api/charge/index'
|
|
|
+import { FormInstance } from 'element-plus';
|
|
|
+import createGears from './createGears.vue';
|
|
|
+const rolesIdentify = inject('rolesIdentify')
|
|
|
+const visibleGears = ref(false)
|
|
|
+const dialogVisible = ref(true)
|
|
|
+const loading = ref(false)
|
|
|
+const gearsData = ref()
|
|
|
+const tableData = ref([])
|
|
|
+const form = ref()
|
|
|
+const emit = defineEmits(['close']);
|
|
|
+const dataForm = ref({ status: 1, type: 2 })
|
|
|
+
|
|
|
+const title = computed(() =>
|
|
|
+ gearsData.value ?
|
|
|
+ '编辑充值档位' : '添加充值档位'
|
|
|
+)
|
|
|
+
|
|
|
+const gearsName = ref({
|
|
|
+ FIRST_COIN: "首充",
|
|
|
+ COIN: "普通充值",
|
|
|
+ YEAR: "包年",
|
|
|
+ QUARTER: "包季",
|
|
|
+ MONTH: "包月",
|
|
|
+})
|
|
|
+
|
|
|
+const optionTypeList = ref([]);
|
|
|
+const props = defineProps({
|
|
|
+ primary: String | Number | Object,
|
|
|
+ api: String,
|
|
|
+});
|
|
|
+const filtersObj = ['MONTH', 'QUARTER', 'YEAR']
|
|
|
+
|
|
|
+const isShowKb = (e) => {
|
|
|
+ return filtersObj.includes(e.type)
|
|
|
+}
|
|
|
+const gearsClose = () => {
|
|
|
+ visibleGears.value = false
|
|
|
+}
|
|
|
+const openGears = (index: number | null, row: object) => {
|
|
|
+ if (row) {
|
|
|
+ gearsData.value = row
|
|
|
+ gearsData.value.index = index
|
|
|
+ visibleGears.value = true
|
|
|
+ } else {
|
|
|
+ if (tableData.value.length >= 6) return ElMessageBox.alert('当前充值档位位置已满')
|
|
|
+ gearsData.value = null
|
|
|
+ visibleGears.value = true
|
|
|
+ }
|
|
|
+}
|
|
|
+const deleteRow = (index: number) => {
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '确定要删除此条充值档位吗?',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ tableData.value.splice(index, 1)
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+
|
|
|
+ })
|
|
|
+}
|
|
|
+const success = (e) => {
|
|
|
+ console.log(e, 'successsuccesssuccess');
|
|
|
+ const data = {
|
|
|
+ ...e,
|
|
|
+ ...e.typeObj,
|
|
|
+ ...e.sequenceObj
|
|
|
+ };
|
|
|
+ if (e.index != undefined) {
|
|
|
+ tableData.value[e.index] = data
|
|
|
+ } else {
|
|
|
+ tableData.value.push(data)
|
|
|
+ }
|
|
|
+}
|
|
|
+const cancel = () => {
|
|
|
+ emit('close')
|
|
|
+}
|
|
|
+const submitFormChange = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ dataForm.value.options = tableData.value.map(el => {
|
|
|
+ return {
|
|
|
+ price: Number(el.price),
|
|
|
+ type: el.type,
|
|
|
+ given: Number(el.given),
|
|
|
+ sequence: el.sequence,
|
|
|
+ is_default: el.is_default
|
|
|
+ }
|
|
|
+ })
|
|
|
+ loading.value = true;
|
|
|
+ formEl
|
|
|
+ .validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ const params = {
|
|
|
+ name: dataForm.value.name,
|
|
|
+ status: dataForm.value.status,
|
|
|
+ options: JSON.stringify(dataForm.value.options),
|
|
|
+ type: dataForm.value.type,
|
|
|
+ }
|
|
|
+ console.log(params, 'paramsparams');
|
|
|
+ if (props.primary) {
|
|
|
+ channelPaytemplateUpdate(dataForm.value.id, params).then(res => {
|
|
|
+ loading.value = false;
|
|
|
+ ElMessage.success(res.message)
|
|
|
+ emit('close')
|
|
|
+ }).catch(e => {
|
|
|
+ loading.value = false;
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ channelPaytemplateStore(params).then(res => {
|
|
|
+ loading.value = false;
|
|
|
+ ElMessage.success(res.message)
|
|
|
+ emit('close')
|
|
|
+ }).catch(e => {
|
|
|
+ loading.value = false;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(() => { });
|
|
|
+}
|
|
|
+
|
|
|
+if (props.primary) {
|
|
|
+ console.log(props.primary, 'props.primary');
|
|
|
+ channelPaytemplateShow(props.primary).then(res => {
|
|
|
+ dataForm.value = res.data.template_info
|
|
|
+ console.log(res, 'channelPaytemplateShowchannelPaytemplateShow');
|
|
|
+ tableData.value = res.data.template_item_list
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ channelPaytemplateOptionTypeList().then(res => {
|
|
|
+ console.log(res);
|
|
|
+ optionTypeList.value = res.data
|
|
|
+
|
|
|
+ })
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style scoped lang="scss">
|
|
|
+.item {
|
|
|
+ width: 300px;
|
|
|
+}
|
|
|
+
|
|
|
+.type-wrapper {
|
|
|
+ width: 80%;
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ margin: 0 6px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.device-wrap {
|
|
|
+ width: 350px;
|
|
|
+ margin-left: 20px;
|
|
|
+ margin-top: 20px;
|
|
|
+
|
|
|
+ img {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ border-bottom-left-radius: 40px;
|
|
|
+ border-bottom-right-radius: 40px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .preview-list {
|
|
|
+ position: absolute;
|
|
|
+ top: 100px;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ padding: 15px;
|
|
|
+ padding-top: 30px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ flex-flow: row wrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .pay-item {
|
|
|
+ width: 46%;
|
|
|
+ margin-right: 4%;
|
|
|
+ height: 80px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ background: #e6e6e6;
|
|
|
+ border-radius: 10px;
|
|
|
+ position: relative;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ &.defalut {
|
|
|
+ border: 1px solid #fd555d;
|
|
|
+ }
|
|
|
+
|
|
|
+ .tipss {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ height: 20px;
|
|
|
+ line-height: 20px;
|
|
|
+ top: 0;
|
|
|
+ padding: 0 4px;
|
|
|
+ background-color: #fd555d;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:nth-child(2n) {
|
|
|
+ margin-right: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ p {
|
|
|
+ width: 100%;
|
|
|
+ line-height: 20px;
|
|
|
+ color: #000;
|
|
|
+ font-size: 12px;
|
|
|
+ text-align: center;
|
|
|
+
|
|
|
+ &:first-child {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: bold;
|
|
|
+
|
|
|
+ span {
|
|
|
+ display: inline-block;
|
|
|
+ padding: 0 2px;
|
|
|
+ background: #fd555d;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 10px;
|
|
|
+ margin-left: 5px;
|
|
|
+ vertical-align: top;
|
|
|
+ transform: scale(0.8);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ color: #666;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|