Ver Fonte

2024-12-6

cmy há 3 meses atrás
pai
commit
00cdb01234

+ 18 - 0
src/api/system/serviceLabel.js

@@ -31,3 +31,21 @@ export function  SystemServiceLabelDel(data = {}) {
   });
 }
 
+// 激活码列表
+export function  codeList(data = {}) {
+  return request({
+    url: '/systemv1/code/list',
+    method: 'post',
+    data : data
+  });
+}
+
+// 添加激活码
+export function  codeAdd(data = {}) {
+  return request({
+    url: '/systemv1/code/add',
+    method: 'post',
+    data : data
+  });
+}
+

+ 291 - 0
src/components/system/showTemplate/code.vue

@@ -0,0 +1,291 @@
+<template>
+	<div>
+		<i-page-header class="product_tabs" title="模版激活码">
+		</i-page-header>
+		<Card :bordered="false" dis-hover class="ivu-mt">
+			<div class="fx-r" style="padding: 20px 0;">
+				<el-select v-model="detial.status" @change="tapSeach" placeholder="请选择是否显示">
+					<el-option label="全部" value=""></el-option>
+					<el-option label="待使用" value="0"></el-option>
+					<el-option label="已使用" value="1"></el-option>
+					<el-option label="已失效" value="-1"></el-option>
+				</el-select>
+
+				<div class="fx-g1"></div>
+				<el-button type="danger" style="margin-left: 6px;" @click="tapAdd">添加激活码</el-button>
+			</div>
+			<el-table :data="detial.data" v-loading="detial.loading" :stripe="true" :border="true">
+				<el-table-column prop="id" label="ID" width="80" align="center">
+				</el-table-column>
+				<el-table-column prop="code" label="激活码">
+				</el-table-column>
+				<el-table-column prop="status" label="绑定模版" align="left">
+					<template slot-scope="scope">
+						{{isTemplate(scope.row.show_template_id)}}(ID:{{scope.row.show_template_id}})
+					</template>
+				</el-table-column>
+				<el-table-column prop="status" label="状态" width="80">
+					<template slot-scope="scope">
+						<span v-if="scope.row.status==0">待使用</span>
+						<span v-else-if="scope.row.status==1">已使用</span>
+						<!-- <span v-else-if="scope.row.status==-1">已失效</span> -->
+					</template>
+				</el-table-column>
+				<!-- <el-table-column  align="center" label="操作"     prop="handle" width="150">
+	  	    <template slot-scope="scope">
+	  			<div><el-button plain size="mini" @click="tapEdit(scope.row)">编辑</el-button></div>
+	  	    </template>
+	  	</el-table-column> -->
+			</el-table>
+			<div class="acea-row row-right page">
+				<Page :total="detial.pageCount" show-elevator show-total @on-change="tapPage"
+					:page-size="detial.pageSize" />
+			</div>
+		</Card>
+		<Modal v-model="dialogVisible" :title="title" @on-cancel="editClose">
+			<el-form ref="form" :model="form" label-width="120px">
+				<el-form-item label="模版ID" prop="show_template_id" :rules="[{ required: true, message: '请输入模版ID'}]">
+					<el-select v-model="form.show_template_id" placeholder="请选择是否显示">
+						<el-option v-for="ls in modelList" :label="ls.title" :value="ls.id"></el-option>
+					</el-select>
+				</el-form-item>
+				<el-form-item label="数量" prop="num" :rules="[{ required: true, message: '请输入生成数量'}]">
+					<el-input placeholder="请输入要生成的数量" v-model="form.num"></el-input>
+				</el-form-item>
+			</el-form>
+			<span slot="footer" class="dialog-footer">
+				<el-button @click="dialogVisible = false">取 消</el-button>
+				<el-button type="primary" @click="subAdmin">确 定</el-button>
+			</span>
+		</Modal>
+
+	</div>
+</template>
+
+<script>
+	import IPageHeader from "@/layouts/system/page-header/index";
+	import {
+		mapState,
+		mapActions
+	} from 'vuex';
+	import UiUpload from "@/ui/upload/index";
+	import Setting from "@/setting";
+	import util from "@/libs/util";
+	import {
+		codeList,
+		codeAdd,
+		SystemServiceLabelDel
+	} from "../../../api/system/serviceLabel";
+	import {
+		SystemShowTemplateList
+	} from "../../../api/system/showTemplate";
+	export default {
+		name: "codeList",
+		components: {
+			UiUpload,
+			IPageHeader
+		},
+		data() {
+			return {
+				title: "添加激活码",
+				dialogVisible: false,
+				upHeaders: {},
+				upUrl: "",
+				detial: {
+					data: [],
+					title: "",
+					status: "",
+					page: 1,
+					loading: true,
+					pageSize: 0,
+					pageCount: 0,
+				},
+				form: {
+					num: 1,
+					show_template_id: '',
+				},
+				// 模版列表
+				modelList: []
+			}
+		},
+		mounted() {
+			this.initView();
+			this.SystemShowTemplateList()
+		},
+		methods: {
+			isTemplate(id){
+				for(let i = 0; i < this.modelList.length; i++) {
+					let item = this.modelList[i]
+					if(item.id ==id){
+						return item.title
+					}
+				}
+				return "模版已失效"
+			},
+			SystemShowTemplateList() {
+				SystemShowTemplateList({
+						is_hot: "",
+						is_recommend: "",
+						page: 1,
+						status: "",
+						time: "",
+						title: ""
+					})
+					.then(res => {
+						this.modelList = res.data.list;
+					})
+					.catch(err => {});
+			},
+			initView: function() {
+				var upHeaders = {};
+				this.upUrl = Setting.apiBaseURL + "/systemv1/upload/index";
+				const token = this.$utils.util.cookies.get('system_token');
+				if (token) {
+					upHeaders['SYSTEM-ACC-TOKEN'] = token;
+				}
+				this.upHeaders = upHeaders;
+				this.getData();
+			},
+
+
+			/**
+			 * 获取数据
+			 */
+			getData: function() {
+				var data = {};
+				this.detial.loading = true;
+				data.page = this.detial.page;
+				data.title = this.detial.title;
+				data.status = this.detial.status;
+				codeList(data)
+					.then(res => {
+						this.detial.loading = false;
+						this.detial.data = res.data.list;
+						this.detial.pageSize = res.data.pageSize;
+						this.detial.pageCount = res.data.pageCount;
+					})
+					.catch(err => {
+						this.detial.loading = false;
+						this.$alert('网络繁忙,加载失败,请稍等片刻在尝试!', '系统提示');
+					});
+
+			},
+			//搜索栏目
+			tapSeach: function() {
+				this.detial.page = 1;
+				this.getData();
+			},
+
+			//关闭
+			editClose: function() {
+				this.dialogVisible = false;
+			},
+			/**
+			 * 添加分类
+			 */
+			tapAdd: function(sassid) {
+				this.dialogVisible = true;
+				this.$refs['form'].resetFields();
+				this.form = this.$utils.resetFields(this.form, {
+					status: 0,
+					seq: 0
+				});
+			},
+
+			/**
+			 * 分页
+			 */
+			tapPage: function(index) {
+				this.page.page = index;
+				this.getData();
+			},
+			/**
+			 * 修改数据
+			 */
+			subAdmin: function(e) {
+				this.$refs['form'].validate((valid) => {
+					if (valid) {
+						let loading = this.$loading("提交数据中...");
+						var data = {};
+						for (var i in this.form) {
+							data[i] = this.form[i];
+						}
+						data['data'] = JSON.stringify(this.dataAr);
+						codeAdd(data)
+							.then(res => {
+								loading.close();
+								if (res.code == 200) {
+									this.dialogVisible = false;
+									this.$Message.success("操作成功");
+									this.getData();
+								} else {
+									this.$alert(res.msg, '系统提示');
+								}
+							})
+							.catch(err => {
+								loading.close();
+								this.$alert("网络繁忙,加载失败,请稍等片刻在尝试!", '系统提示');
+							});
+					}
+				});
+			},
+			/**
+			 * 上传文件
+			 * @param res
+			 */
+			onUpload: function(res) {
+				if (res.code == -1) {
+					Notice.error({
+						title: "系统提示",
+						content: res.msg
+					});
+				} else {
+					this.form.img = res.data.img;
+				}
+			},
+			tapEdit: function(row) {
+				this.form = JSON.parse(JSON.stringify(row));
+				this.dialogVisible = true;
+				this.title = "编辑标签";
+			},
+			// 删除
+			tapDel(row) {
+				this.$confirm('此操作将永久删除该标签, 是否继续?', '提示', {
+					confirmButtonText: '确定',
+					cancelButtonText: '取消',
+					type: 'warning'
+				}).then(() => {
+					this.$utils.loading(this, "删除数据中...");
+					SystemServiceLabelDel({
+							id: row.id
+						})
+						.then(res => {
+							this.$utils.loadingClose();
+							this.loading = true;
+							if (res.code == 200) {
+								this.getData();
+							} else {
+								this.$alert(res.msg);
+							}
+						})
+						.catch(err => {
+							this.$utils.loadingClose();
+							this.$alert("网络繁忙,加载失败,请稍等片刻在尝试!", '系统提示');
+						});
+				}).catch((e) => {});
+			},
+		}
+	}
+</script>
+<style scoped>
+	.platform-img {
+		width: 20px;
+		height: 20px;
+		background: #f2f2f2;
+		margin-right: 4px;
+	}
+
+	.platform-img img {
+		width: 100%;
+	}
+</style>

+ 9 - 0
src/router/routes.js

@@ -166,6 +166,15 @@ const system = [{
 				},
 				component: () => import('@/components/system/showTemplate/list')
 			},
+			{
+				path: '/system/showTemplate/code',
+				name: 'system_showTemplate_code',
+				meta: {
+					title: '模版激活码',
+					auth: true
+				},
+				component: () => import('@/components/system/showTemplate/code')
+			},
 			{
 				path: '/system/showTemplate/serviceType',
 				name: 'system_showTemplate_serviceType',