浅谈对象数据赋值问题---我遇到的一个坑
今天在做一个大型网站表格导入的时候,我踩了一个坑,让宝宝我好忧伤,感觉智商的倒退
看到这个数据重复的问题,还以为我没错,结果狠狠打脸啊,伤心的不要不要的
话不多说,上代码,看看我的问题,以后要少犯类似的问题
<html>
<head>
<meta charset="utf-8">
<title>活动管理</title>
<link rel="stylesheet" type="text/css" href="{{PATH_TML}}activity/css/iview.css">
<script type="text/javascript" src="{{PATH_TML}}activity/js/vue.min.js"></script>
<script type="text/javascript" src="{{PATH_TML}}activity/js/iview.min.js"></script>
<link rel="stylesheet" type="text/css" href="{{PATH_TML}}activity/css/public.css">
<script src="{{PATH_TML}}activity/js/jquery-1.8.3.min.js"></script>
<script src="{{PATH_TML}}activity/js/activity-public.js"></script>
<script src="{{PATH_TML}}activity/js/jquery-3.2.1.min.js"></script>
<!-- 导入excel -->
<script src="{{PATH_TML}}activity/js/xlsx.core.min.js"></script>
<script src="/common/layui/layui.js"></script>
<!-- <script src="{{PATH_TML}}activity/js/Blob.js"></script>
<script src="{{PATH_TML}}activity/js/Export2Excel.js"></script> -->
<!-- 引入页面 -->
<!--<script src='js/public.js'></script>-->
<style>
[v-cloak] {
display: none !important;
}
.ivu-select {
margin: 0 auto;
}
</style>
</head>
<body>
<!-- 主题内容 -->
<div id="app" v-cloak>
<!-- 左边导航 -->
<#include#>activity/left_nav.html</#include#>
<!-- 右边内容 -->
<div class='right-content' style="flex:1">
<!-- 头部导航栏 -->
<#include#>activity/header.html</#include#>
<!-- content -->
<div class='content main'>
<!-- 打开页面选择器 -->
<div class="tag-nav-wrapper m-activity-detail">
<#include#>activity/activity_right.html</#include#>
<!-- 主题内容 -->
<div class="content-wrapper ivu-layout-content">
<div class="ivu-card ivu-card-bordered">
<div class="ivu-card-body">
<span id='mainContent' class="ivu-card">
<!--筛选按钮-->
<i-form ref="formValidate" class="shaixuan-form" inline>
<form-item>
<i-input
v-model='search_status=="is_audit"?(search_context==1?"审核通过":search_context==2?"待审核":"审核拒绝"):search_context'
:disabled='search_disabled'>
<i-select slot="prepend" style="width: 80px" @on-change='searchChange'>
<i-option value="name" key='name'>姓名</i-option>
<i-option value="telphone" key='telphone'>手机号</i-option>
<i-option value="success" key='success'>通过</i-option>
<i-option value="fail" key='success'>拒绝</i-option>
<i-option value="await" key='await'>待审核</i-option>
</i-select>
<i-button slot="append" icon="ios-search" @click='searchHandler'></i-button>
</i-input>
</form-item>
<form-item>
<i-button type="primary" @click='exportExcel("current")'>导出当前页</Button>
</form-item>
<form-item>
<i-button type="primary" @click='exportExcel("all")'>导出全部</Button>
</form-item>
<form-item v-if='activity_info.model_type=="qinshang"'>
<a href="javascript:;" class="file">导入表格
<input type="file" οnchange="importXlsx(this)" id="rcDialogTitle0">
</a>
</form-item>
<form-item v-if='activity_info.model_type=="qinshang"'>
<i-button type="primary" @click='other_enroll=true'>替他人报名</Button>
</form-item>
<form-item v-if='activity_info.model_type=="qinshang"'>
<a href="javascript:;" class="file">表格报名
<input type="file" οnchange="importEnroll(this)" id="rcDialogTitle0">
</a>
</form-item>
<form-item>
<i-button type="primary" @click='showGroup'>创建分组</Button>
</form-item>
</i-form>
<!-- -->
<!--表格-->
<i-table ref="tables" editable searchable search-place="top" v-model="tableData" :columns="columns"
:data="tableData" :loading="loading" id='active-detail'>
</i-table>
<!-- 替他人报名 模态框 -->
<Modal v-model="other_enroll">
<p slot="header" class="import-tables">
替他人报名
</p>
<div>
<i-form :model="enroll" :label-width="80">
<form-item label="姓名" prop="name">
<i-input v-model="enroll.name" placeholder=""></i-input>
</form-item>
<form-item label="手机号" prop="telphone">
<i-input v-model="enroll.telphone" placeholder=""></i-input>
</form-item>
<form-item label="单位及职务" prop="position_info">
<i-input v-model="enroll.extends.position_info" placeholder=""></i-input>
</form-item>
<form-item label="性别" prop="sex">
<Radio-group v-model="enroll.extends.sex">
<Radio label="男"></Radio>
<Radio label="女"></Radio>
</Radio-group>
</form-item>
<form-item label="证件类型" prop="credentials_type">
<Radio-group v-model="enroll.extends.credentials_type">
<Radio label="身份证"></Radio>
<Radio label="护照"></Radio>
</Radio-group>
</form-item>
<form-item :label="enroll.extends.credentials_type" prop="card_type">
<i-input v-model="enroll.extends.credentials_number" placeholder=""></i-input>
</form-item>
<form-item label="参加考察活动" prop="enroll">
<i-switch v-model="enroll.extends.has_project" />
</form-item>
<form-item label="在陕有投资" prop="is_part_in_third_silk_conference">
<i-switch v-model="enroll.extends.is_part_in_third_silk_conference" />
</form-item>
<form-item label="大会接机" prop="card_type">
<i-switch v-model="enroll.extends.is_meet_plane" />
</form-item>
<form-item label="接机信息" prop="card_type" v-if='enroll.extends.is_meet_plane'>
<i-input v-model="enroll.extends.flight_info" placeholder="" type='textarea'></i-input>
</form-item>
</i-form>
</div>
<div slot="footer">
<i-button type="warning" @click='other_enroll=false'>取消</i-button>
<i-button type="primary" @click='otherEnroll'>添加</i-button>
</div>
</Modal>
<!-- 模态框 -->
<Modal v-model="is_apply" width="520">
<p slot="header">
<span class="ant-modal-title" id="rcDialogTitle0">报名人信息审核</span>
</p>
<div style="text-align:center" v-if='activity_info.model_type=="qinshang"'>
<div class="ant-modal-body">
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;">
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">姓名:
</div>
<div class="ant-col-14">{{model_show.name}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;">
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">联系方式:
</div>
<div class="ant-col-14">{{model_show.telphone}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.extends!=null'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">性别:
</div>
<div class="ant-col-14">{{model_show.extends.sex==3?'男':model_show.extends.sex==2?'女':'未知'}}
</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.model_type=="qinshang"'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">所属公司及职务:
</div>
<div class="ant-col-14">{{model_show.extends.position_info}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.model_type!="qinshang"'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">所属公司:
</div>
<div class="ant-col-14">{{model_show.company}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.model_type!="qinshang"'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">所属职务:
</div>
<div class="ant-col-14">{{model_show.position}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.extends!=null'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">身份证:
</div>
<div class="ant-col-14">{{model_show.extends.credentials_number}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.extends!=null'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">
是否参加考察活动:
</div>
<div class="ant-col-14">不参加</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.extends!=null'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">
是否在陕有投资项目:
</div>
<div class="ant-col-14">{{model_show.has_project!=null?model_show.has_project:'没有'}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.extends!=null'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">
是否需要大会接机:
</div>
<div class="ant-col-14">{{model_show.flight_info!=null?model_show.flight_info:'不需要'}}</div>
</div>
</div>
</div>
<div style="text-align:center" v-if='activity_info.model_type==""'>
<div class="ant-modal-body">
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;">
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">姓名:
</div>
<div class="ant-col-14">{{model_show.name}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;">
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">联系方式:
</div>
<div class="ant-col-14">{{model_show.telphone}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;">
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">所属公司:
</div>
<div class="ant-col-14">{{model_show.company}}</div>
</div>
<div class="ant-row" style="margin-bottom: 10px; font-size: 16px;"
v-if='model_show.model_type!="qinshang"'>
<div class="ant-col-10"
style="text-align: right; padding-right: 10px; color: rgba(138, 137, 137, 0.65);">所属职务:
</div>
<div class="ant-col-14">{{model_show.poistion}}</div>
</div>
</div>
</div>
<div slot="footer">
<!-- is_audit 1:通过 2:未审核 3:拒绝 -->
<i-button @click='applyActivity(1)'>取 消</i-button>
<i-button type="error" @click='applyActivity(2)'>拒 绝</i-button>
<i-button type="success" @click='applyActivity(3)'>通 过</i-button>
</div>
</Modal>
<!-- 导出表格模态框 -->
<!-- -->
<div>
<div id="myDiv" style="text-align:center;display:none">
<table id="tableExcel" width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="30">序号</td>
<td width="78"> 姓名</td>
<td width="78">性别</td>
<td width="78">证件类型</td>
<td width="78">证件号</td>
<td width="78">单位及职务</td>
<td width="78">是否参加高新区考察</td>
<td width="78">是否在陕有投资项目</td>
<td width="78">接机信息</td>
<td width="78">联系电话</td>
<td width="78">报名时间</td>
<td width="78">票务信息</td>
<td width="78">是否签到</td>
<td width="78" v-for='item in table_title'>{{item}}</td>
</tr>
<tr v-for='item in exprot_data'>
<td width="78">{{item.id}}</td>
<td width="78">{{item.name}}</td>
<td width="78">
{{item.qinshang==null?'-':item.qinshang.sex==1?'未知':item.qinshang.sex==2?'女':item.qinshang.sex==3?'男':'-'}}
</td>
<td width="78">{{item.qinshang==null?'-':item.qinshang.credentials_type==1?'身份证':'-'}}
</td>
<td width="78">
{{item.qinshang==null?'-':item.qinshang.credentials_number!=null?item.qinshang.credentials_number:'-'}}
</td>position_info
<td width="78">{{item.qinshang==null ? '-':item.qinshang.position_info}}</td>
<td width="78">{{item.qinshang==null ? '-':item.qinshang.is_observe==2 ? '不考察' : '考察'}}
</td>
<td width="78">{{item.qinshang==null ? '-':item.qinshang.has_project == 2 ? '没有' : '有'}}
</td>
<td width="78">
{{item.qinshang==null ? '-':item.qinshang.flight_info!=null?item.qinshang.flight_info:'-'}}
</td>
<td width="78">{{item.telphone==null?'-':item.telphone}}</td>
<td width="78">{{item.created_at==null?'-':item.created_at}}</td>
<td width="78">{{item.ticket_num==null?'-':item.ticket_num}}</td>
<td width="78">{{item.is_attend == 2 ? '尚未参加' : '已参加'}}</td>
<td width="78" v-for='indexs in item.extend'>{{indexs}}</td>
</tr>
</table>
</div>
</div>
<!-- 导入表格模态框 -->
<Modal v-model="import_tables" width='1200'>
<p slot="header" class="import-tables" style="height:45px;">
</p>
<div style="text-align:center">
<div id="myDivs">
<table id="importExcels" width="100%" border="1" cellspacing="0" cellpadding="0">
</table>
</div>
</div>
<div slot="footer">
<i-button type="warning">取消</i-button>
<i-button type="primary" @click='importExcelMethods'>导 入 数 据</i-button>
</div>
</Modal>
<!-- 创建分组模态框 -->
<Modal v-model="create_group" @on-cancel="getSelect">
<p slot="header" class="ant-modal-title">
创建分组
</p>
<div>
<div v-for='item in group_list' style="display:flex;margin-bottom:10px" v-if='item.value!=0'>
<i-input v-model='item.label' style="width:320px;margin-right:10px"></i-input>
<i-button icon="ios-create-outline" type="dashed" @click="editGroup(item)"
style="margin-right:10px">编辑
</i-button>
<i-button icon="ios-trash-outline" type="dashed" @click="deleteGroup(item)">删除</i-button>
</div>
<p
style="border-bottom: 1px solid #ccc;color: #333;font-size: 14px;font-weight: 600;padding-bottom: 5px;padding-top: 10px;">
添加分组
</p>
<div style="display:flex;margin-top:10px;margin-bottom:10px">
<i-input v-model='group_label' style="width:400px;margin-right:10px"></i-input>
<i-button icon="ios-add" type="dashed" @click="addGroup">添加</i-button>
</div>
</div>
<div slot="footer">
<i-button type="primary" @click='backGroup'>返回</i-button>
</div>
</Modal>
<Modal v-model="choose_group">
<p slot="header" class="ant-modal-title">
选择分组
</p>
<div>
<Tag v-for="item in current_group" closable :key="item" :name="item"
:type="item.is_default==true?'success':''" class="group-li">
<div @click='changeGroup(item)'> {{ item.label }}</div>
</Tag>
</li>
</div>
<div slot="footer">
<i-button type="primary" @click='choose_group=false'>返回</i-button>
</div>
</Modal>
<Page :total="pages.total" style="margin-top:10px;text-align: right" prev-text="上一页" next-text="下一页"
@on-change='pagesList' />
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 底部数据 -->
<!-- <footer class='footer'>
</footer> -->
</div>
<!-- 导出excel -->
<script src="{{PATH_TML}}activity/js/table.js"></script>
<script>
// 导入文件获取数据
let xlsxData = []
function importXlsx(e) {
const files = e.files;
let i, f;
for (i = 0, f = files[i]; i != files.length; ++i) {
let reader = new FileReader();
let name = f.name;
reader.onload = function (e) {
let data = e.target.result;
let workbook = XLSX.read(data, {
type: typeof FileReader !== "undefined" && (FileReader.prototype || {}).readAsBinaryString ?
'binary' : 'array'
});
for (let sheet in workbook.Sheets) {
if (workbook.Sheets.hasOwnProperty(sheet)) {
fromTo = workbook.Sheets[sheet]['!ref'];
xlsxData = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
if (xlsxData.length != 0) {
app.importTableReq(xlsxData)
}
}
}
}
reader.readAsBinaryString(f);
}
}
function importEnroll(e) {
const files = e.files;
let i, f;
for (i = 0, f = files[i]; i != files.length; ++i) {
let reader = new FileReader();
let name = f.name;
reader.onload = function (e) {
let data = e.target.result;
let workbook = XLSX.read(data, {
type: typeof FileReader !== "undefined" && (FileReader.prototype || {}).readAsBinaryString ?
'binary' : 'array'
});
var enrollData = []
for (let sheet in workbook.Sheets) {
if (workbook.Sheets.hasOwnProperty(sheet)) {
fromTo = workbook.Sheets[sheet]['!ref'];
enrollData = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
if (enrollData.length != 0) {
console.log(enrollData)
var sendData = {
name: '',
telphone: '',
extends: {
sex: '',
position_info: '',
has_project: '',
is_meet_plane: '',
flight_info: '',
lis_part_in_third_silk_conference: '',
credentials_type: '身份证',
credentials_number: '',
}
}
for (var i in enrollData) {
sendData = {
name: '',
telphone: '',
extends: {
sex: '',
position_info: '',
has_project: '',
is_meet_plane: '',
flight_info: '',
lis_part_in_third_silk_conference: '',
credentials_type: '',
credentials_number: '',
}
}
for (var j in enrollData[i]) {
switch (j) {
case '姓名':
sendData.name = enrollData[i][j];
break;
case '联系电话':
sendData.telphone = enrollData[i][j];
break;
case '性别':
sendData.extends.sex = enrollData[i][j];
break;
case '单位及职务':
sendData.extends.position_info = enrollData[i][j];
break;
case '证件类型':
sendData.extends.credentials_type = enrollData[i][j];
break;
case '证件号':
sendData.extends.credentials_number = enrollData[i][j];
break;
case '是否在陕有投资项目':
sendData.extends.has_project = enrollData[i][j] == '有' ? true : enrollData[i][j] == '没有' ? false : 0;
break;
// case '是否在陕有投资项目':
// sendData.extends.lis_part_in_third_silk_conference = enrollData[i][j] == '有' ? true : false;
// break;
case '接机信息':
sendData.extends.flight_info = enrollData[i][j];
break;
}
sendData.extends.is_meet_plane = true
}
app._data.enroll = sendData
app.tableImportTable()
}
app.getSelect()
}
}
}
}
reader.readAsBinaryString(f);
}
}
var activity_id = window.location.href.split('/')[6]
var app = new Vue({
el: '#app',
data: {
left_info: 'dark',
activity_path: activity_path,
qrCodeShow: false,
is_apply: false,
model_show: {},
columns: [],
tableData: [],
ticket_select: [],
export_tables: false,
exprot_data: [],
import_tables: false,
xlsxData: xlsxData,
search_context: '',
search_status: '',
search_disabled: false,
create_group: false,
group_list: [],
group_label: '',
activity_id: activity_id,
loading: true,
pages: [],
go_nav: 'index',
table_title: [],
activity_info: {},
group: [],
choose_group: false,
current_group: [],
other_enroll: false,
enroll: {
activity_id: activity_id,
name: '',
telphone: '',
ticket_id: [],
num: [],
extends: {
sex: '男',
birthday: '',
photo: '',
position_info: '',
is_observe: '',
has_project: '',
is_meet_plane: '',
flight_info: '',
lis_part_in_third_silk_conference: '',
credentials_type: '身份证',
credentials_number: '',
credentials_photo: ''
}
}
},
methods: {
// 导入数据
importTableReq(xlsxData) {
$.ajax({
url: api_domain + 'activity/enroll/import',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: {
data: xlsxData,
active_id: activity_id
}, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code == 200) {
layui.use('layer', function () {
var layer = layui.layer;
layer.msg('导入成功', {
time: 1500
});
})
if (res.data[0].fail > 0) {
this.$Notice.info({
title: '导入错误数据',
top: 200,
desc: res.data[0].fail_id + '数据导入错误',
duration: 0
});
}
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
},
// 表格导入报名
tableImportTable() {
var sendData = {
activity_id: activity_id,
name: this.enroll.name,
telphone: $.trim(this.enroll.telphone),
ticket_id: [this.activity_info.tickets[0].weid],
num: [1],
is_owner: 1,
extends: {
sex: $.trim(this.enroll.extends.sex) == '男' ? 3 : $.trim(this.enroll.extends.sex) == '女' ? 2 : 1,
birthday: '',
photo: '',
position_info: this.enroll.extends.position_info,
is_observe: 1,
has_project: this.enroll.extends.has_project == true ? 2 : this.enroll.extends.has_project == false ? 1 : 0,//没有:1,有:2,其他:0
is_meet_plane: this.enroll.extends.is_meet_plane == true ? 1 : 2,
flight_info: this.enroll.extends.flight_info,
// is_part_in_third_silk_conference: this.enroll.extends.is_part_in_third_silk_conference == true ? 2 : 1,
credentials_type: $.trim(this.enroll.extends.credentials_type) == '身份证' ? 1 : $.trim(this.enroll.extends.credentials_type) == '护照' ? 2 : '',
credentials_number: this.enroll.extends.credentials_number,
credentials_photo: '',
}
}
console.log(sendData,this.enroll.telphone)
$.ajax({
url: api_domain + 'activity/enroll/store',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData,
//执行成功的回调函数
success: (res) => {
this.enroll = {
activity_id: activity_id,
name: '',
telphone: '',
ticket_id: [],
num: [],
extends: {
sex: '男',
birthday: '',
photo: '',
position_info: '',
is_observe: '',
has_project: '',
is_meet_plane: '',
flight_info: '',
lis_part_in_third_silk_conference: '',
credentials_type: '身份证',
credentials_number: '',
credentials_photo: ''
}
}
if (res.code == 200) {
this.other_enroll = false
} else {
console.log(sendData.telphone + res.message)
this.$Message.error(res.message)
this.$Notice.open({
title: '提示',
desc: sendData.telphone + res.message,
duration: 0
});
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
},
// 其他人报名
otherEnroll() {
console.log(this.enroll, '获取数据')
if (this.enroll.telphone == '') {
this.$Message.error('请输入电话号码')
} else {
this.$Modal.confirm({
title: '请确定电话号码',
content: this.enroll.telphone,
cancelText: '取消',
onOk: (res) => {
this.tableImportTable()
},
onCancel: () => {
this.$Modal.remove()
}
});
}
},
// 选择分组
chooseGroup(index) {
this.choose_group = true
var group = this.group_list
var current = this.tableData[index].person_label
for (var i in group) {
group[i].is_default = false
}
for (var i in group) {
for (var j in current) {
if (group[i].value == current[j].label_id) {
group[i].is_default = true
}
}
group[i].enroll_id = this.tableData[index].enroll_id
}
this.current_group = group
},
// 获取活动信息
getActivityInfo() {
$.ajax({
url: api_domain + 'activity/panel/activity/detail',
type: 'GET',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: {
activity_id: this.activity_id
}, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code == 200) {
this.activity_info = res.data
} else {
this.$Message.error(res.message)
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
},
// 页面跳转
goToNavPage(e) {
window.location.href = all_domian + pages_index + '/weadm/activity/' + this.activity_id + '/' + e
},
// 分组返回
backGroup() {
this.create_group = false
this.getSelect()
},
// 创建分组
showGroup() {
this.create_group = true
},
addGroup() {
let that = this
if (this.group_label == '') {
this.$Message.error('请输入分组名称');
} else {
var sendData = {
activity_id: this.activity_id,
title: this.group_label
}
$.ajax({
url: api_domain + 'activity/panel/label/add',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code == 200) {
this.$Message.success('添加成功')
this.group_label = ''
that.getSelect()
} else {
this.$Message.error(res.message)
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
}
},
editGroup(res) {
let that = this
this.$Modal.confirm({
title: '您确定要修改此分组名称吗?',
loading: true,
onOk: () => {
this.$Modal.remove();
var sendData = {
activity_id: this.activity_id,
title: res.label,
label_id: res.value
}
$.ajax({
url: api_domain + 'activity/panel/label/edit',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code == 200) {
this.$Message.success('修改成功')
this.group_label = ''
that.getSelect()
} else {
this.$Message.error(res.message)
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
}
});
},
deleteGroup(res) {
let that = this
this.$Modal.confirm({
title: '您确定要删除此分组吗?',
loading: true,
onOk: () => {
this.$Modal.remove();
var sendData = {
activity_id: this.activity_id,
label_id: res.value
}
$.ajax({
url: api_domain + 'activity/panel/label/destroy',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code == 200) {
this.$Message.success('删除成功')
this.group_label = ''
that.getSelect()
} else {
this.$Message.error(res.message)
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
}
});
},
// 修改搜索状态
searchChange(e) {
switch (e) {
case 'name':
this.search_disabled = false, this.search_status = 'name', this.search_context = '';
break;
case 'telphone':
this.search_disabled = false, this.search_status = 'telphone', this.search_context = '';
break;
case 'success':
this.search_disabled = true, this.search_status = "is_audit", this.search_context = 1;
break;
case 'fail':
this.search_disabled = true, this.search_status = "is_audit", this.search_context = 3;
break;
case 'await':
this.search_disabled = true, this.search_status = "is_audit", this.search_context = 2;
break;
}
},
// 搜索验证状态
vail_search() {
if (this.search_status == '') {
layui.use('layer', function () {
var layer = layui.layer;
layer.msg('请输入搜索状态', {
time: 1500
});
})
return false
} else if (this.search_context == '') {
layui.use('layer', function () {
var layer = layui.layer;
layer.msg('请输入搜索内容', {
time: 1500
});
})
return false
}
return true
},
// 搜索内容
searchHandler() {
if (this.vail_search()) {
var sendData = {
page: 1,
limit: 10,
value: this.search_context,
key: this.search_status,
activity_id: activity_id
}
this.getData(sendData)
}
},
// 分页列表
pagesList(e) {
if (e > this.pages.last_page || e <= 0) {
return false
} else {
var sendData = {
page: e,
limit: 10,
value: this.search_context,
key: this.search_status,
activity_id: activity_id
}
this.getData(sendData)
}
},
// 导出表格
exportTable(e) {
if (e == 'current') {
var sendData = {
activity_id: activity_id,
page: this.pages.current_page,
// start:'',
// end:'',
// is_audit:''
}
}
if (e == 'all') {
var sendData = {
activity_id: activity_id,
page: "all",
order_by: 'audit_at'
// start:'',
// end:'',
// is_audit:''
}
}
$.ajax({
url: api_domain + 'activity/enroll/export',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code == 200) {
var table_title = []
for (var i in res.data.data) {
var extend = []
if (res.data.data[i].qinshang != null) {
var f = res.data.data[i].qinshang.credentials_number.substring(0, 6) + ' '
var s = res.data.data[i].qinshang.credentials_number.substring(6, 14) + ' '
var t = res.data.data[i].qinshang.credentials_number.substring(14, 18) + ' '
res.data.data[i].qinshang.credentials_number = f + s + t
}
if (res.data.data[i].extends != '') {
res.data.data[i].extends = JSON.parse(res.data.data[i].extends)
for (var j in res.data.data[i].extends) {
if (table_title.indexOf(j) == -1) {
table_title.push(j)
}
extend.push(res.data.data[i].extends[j])
}
res.data.data[i].extend = extend
extend = []
}
}
this.table_title = table_title
this.exprot_data = res.data.data
this.$Spin.show();
setTimeout(() => {
this.$Spin.hide();
this.exportExcelMethods()
}, 10000);
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
},
//展示导出表格模态框
exportExcel(e) {
// this.export_tables = true
// 添加数据
this.exportTable(e)
},
// 导出表格数据
exportExcelMethods() {
$("#tableExcel").table2excel({
exclude: ".noExl",
name: "Excel Document Name",
filename: activity_id + new Date().getTime() + ".xls",
exclude_img: true,
exclude_links: true,
exclude_inputs: true
});
},
//展示导出表格模态框
importExcel() {
this.import_tables = true
},
// 导入表格方法
importExcelMethods() { },
// 审核活动
applyActivity(status) {
// status 1 取消 2 拒绝 3 通过
if (status === 1) {
this.is_apply = false
} else {
var status = status
var res = {
order: status == 3 ? 'allow' : 'deny',
enroll_id: this.model_show.weid,
// activity_id: window.location.href.split('?')[1].split('=')[1]
}
let that = this
$.ajax({
url: api_domain + 'activity/enroll/audit',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: res, //使用变量sendData
//执行成功的回调函数
success: (res) => {
that.is_apply = false
if (res.code !== 200) {
layui.use('layer', function () {
var layer = layui.layer;
layer.msg(res.message, {
time: 1500
});
})
return false
} else {
layui.use('layer', function () {
var layer = layui.layer;
layer.msg('修改成功', {
time: 1500
})
var sendData = {
page: that.pages.current_page,
limit: 10,
name: '',
telphone: '',
activity_id: activity_id
}
that.getData(sendData)
})
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
}
},
// 展示模态框
showModel(res) {
let that = this
$.ajax({
url: api_domain + 'activity/panel/enroll/enroll_detail',
type: 'GET',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: res, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code !== 200) return false
that.is_apply = true
that.model_show = res.data
that.model_show.model_type = res.data.activity.model_type
},
//执行失败或错误的回调函数
error: (data) => { }
})
},
// 修改分组
changeGroup(res) {
console.log(res, '123456')
let that = this
var sendData = {
enroll_id: res.enroll_id,
label_id: res.value,
activity_id: this.activity_id
}
$.ajax({
url: api_domain + 'activity/panel/label/add_person',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code !== 200) return false
layui.use('layer', function () {
var layer = layui.layer;
layer.msg('修改成功', {
time: 1500
});
})
this.choose_group = false
that.getSelect()
},
//执行失败或错误的回调函数
error: (data) => { }
})
},
// 渲染列表
setColumns() {
var columns = [{
title: '序号',
key: 'id',
align: 'center',
editable: true
}, {
title: '报名人员',
align: 'center',
key: 'number',
render: (h, params) => {
return h('div', [
h('div', {
props: {
type: 'name'
},
style: {
display: 'block',
fontSize: '14px',
}
}, params.row.name),
h('div', {
props: {
type: 'position'
},
style: {
display: 'block',
fontSize: '14px'
}
}, params.row.position),
h('div', {
props: {
type: 'phone'
},
style: {
display: 'block',
fontSize: '14px'
}
}, params.row.phone),
]);
},
editable: true
}, {
title: '票务信息',
align: 'center',
key: 'ticket_info',
editable: true
},
{
title: '分组',
align: 'center',
key: 'values',
render: (h, params) => {
var arr = params.row.person_label
console.log(arr)
return h('div', arr.map(function (item, index) {
if (item.weid != '-1') {
var li = item.label_id
return h('Tag', {
style: {
marginRight: '5px',
color: '#ccc'
},
props: {
closable: true
},
on: {
'on-close': () => {
app.deletePersonGroup(params.row.person_label[index].weid)
}
}
}, app._data.group[li].title)
} else {
return h('Button', {
style: {
marginRight: '5px',
color: '#ccc'
},
props: {
icon: "ios-add",
size: "small"
},
on: {
click: () => {
app.chooseGroup(params.index)
},
},
}, '添加')
}
}))
}
},
{
title: '审核',
align: 'center',
key: 'status',
// need_audit 1 需要审核 2 不需要你审核
// status 1 报名完成且通过审核 2 报名未完成 (待支付) 3 待审核
render: (h, params) => {
if (params.row.need_audit == 2) {
return h('div', [
h('div', {
props: {
type: 'primary',
size: 'default',
color: '#ccc'
},
}, '无需审核')
]);
} else {
if (params.row.status == 1) {
return h('div', [
h('Button', {
props: {
type: 'success',
size: 'default',
width: "120px"
},
style: {
cursor: 'no-drop'
},
}, '通过')
]);
}
if (params.row.status == 2) {
return h('div', [
h('Button', {
props: {
type: 'warning',
size: 'default'
},
}, '待支付')
]);
}
if (params.row.status == 3 && params.row.audit == 2) {
return h('div', [
h('Button', {
props: {
type: 'warning',
size: 'default',
},
on: {
click: () => {
var sendData = {
enroll_id: params.row.enroll_id,
activity_id: params.row.activity_id
}
app.showModel(sendData)
}
}
}, '待审核')
]);
}
if (params.row.status == 3 && params.row.audit == 3) {
return h('div', [
h('Button', {
props: {
type: 'error',
size: 'default',
width: "120px"
},
style: {
cursor: 'no-drop'
},
on: {
click: () => {
var sendData = {
enroll_id: params.row.enroll_id,
activity_id: params.row.activity_id
}
// app.showModel(sendData)
}
}
}, '拒绝')
]);
}
}
},
editable: true
},
{
title: '签到',
align: 'center',
key: 'sign',
editable: true
}
]
this.columns = columns
},
// 删除个人分组
deletePersonGroup(res) {
render: (h) => {
return h('Input', {
props: {
value: this.value,
autofocus: true,
placeholder: 'Please enter your name...'
},
on: {
input: (val) => {
this.value = val;
}
}
})
}
console.log(res, '123456')
let that = this
this.$Modal.confirm({
title: '您确定要删除此分组吗?',
okText: '删除',
loading: true,
onOk: () => {
this.$Modal.remove();
var sendData = {
weid: res,
activity_id: this.activity_id,
}
$.ajax({
url: api_domain + 'activity/panel/label/delete_person',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code == 200) {
var sendData = {
page: that.pages.current_page,
limit: 10,
name: '',
telphone: '',
activity_id: activity_id
}
that.getData(sendData)
} else {
}
},
//执行失败或错误的回调函数
error: (data) => { }
})
}
})
},
// 获取分组
getSelect() {
let that = this
$.ajax({
url: api_domain + 'activity/panel/label/lists',
type: 'GET',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: {
activity_id: activity_id
}, //使用变量sendData
//执行成功的回调函数
success: (res) => {
if (res.code !== 200) return false
var data = res.data
var val = []
var group = []
for (var i in data) {
val[i] = {
value: data[i].weid,
label: data[i].title
}
group[data[i].weid] = data[i]
}
that.ticket_select = val
that.group_list = val
group.push({
weid: -1
})
that.group = group
if (that.pages.current_page) {
var page = that.pages.current_page
} else {
var page = 1
}
var sendData = {
page: page,
limit: 10,
name: '',
telphone: '',
activity_id: activity_id
}
that.getData(sendData)
},
//执行失败或错误的回调函数
error: (data) => { }
})
},
// 获取数据
getData(sendData) {
this.setColumns(sendData.activity_id)
let that = this
this.loading = true
$.ajax({
url: api_domain + 'activity/enroll/export',
type: 'POST',
headers: {
"token": plats_token //此处放置请求到的用户token
},
dataType: 'json',
cache: false,
async: true,
data: sendData, //使用变量sendData
//执行成功的回调函数
success: function (res) {
if (res.code !== 200) return false
var tables = []
var data = res.data.data
for (var i in res.data.data) {
data[i].person_label.push({
weid: '-1'
})
tables[i] = {
id: data[i].id,
number: '8',
name: data[i].name,
position: data[i].qinshang == null ? '' : data[i].qinshang.position_info,
phone: data[i].telphone,
ticket_info: data[i].ticket_num,
values: that.ticket_select,
label_id: data[i].person_label == null ? '' : data[i].person_label.label_id,
status: data[i].status,
need_audit: data[i].activity.need_audit,
audit: data[i].is_audit,
person_label: data[i].person_label,
group: that.group,
// audit: 1,
is_apply: false,
sign: data[i].ticket_hold == null ? '' : data[i].ticket_hold.status == 1 ?
'未签到' : data[
i].ticket_hold.status == 2 ? '已签到' : '',
enroll_id: data[i].weid,
activity_id: sendData.activity_id,
}
}
that.loading = false
that.tableData = tables
var pages_list = []
for (var i = 1; i <= Math.ceil(res.data.total / 10); i++) {
pages_list.push(i)
}
res.data.pages_list = pages_list
that.pages = res.data
that.loading = false
},
//执行失败或错误的回调函数
error: function (data) { }
})
},
},
mounted() {
let that = this;
this.$nextTick(function () {
this.activity_id = activity_id
this.go_nav = window.location.href.split('/')[7]
this.getActivityInfo()
this.getSelect()
})
}
})
</script>
</body>
</html>
就因为没加这行代码,导致我2000人的报名数据直接崩塌,哎,以后要谨记。。。。
浅谈对象数据赋值问题---我遇到的一个坑相关推荐
- 浅谈对象的深拷贝和浅拷贝
浅谈对象的深拷贝和浅拷贝 一.为什么使用对象的拷贝? 1.在普通数据类型赋值 let a=10let b=aa=20console.log(a)//a=20console.log(a)//b=10 因 ...
- 浅谈导航数据中POI搜索技术原理
浅谈导航数据中POI搜索技术原理之一 王健 导航技术的应用已经成为现在生活中重要组成部分,为我们的生活提供了极大的便利.基本都有这样生活的体验,搜索自己位置附近的银行网点.餐馆.那么这些POI是如何快 ...
- 浅谈大数据:如何成为大数据企业?
文章讲的是 浅谈大数据:如何成为大数据企业, 1.什么叫大数据? "大数据"是"数据化"趋势下的必然产物!数据化最核心的理念是:"一切都被记录,一切都 ...
- 在layui中使用ajax传值给后台,浅谈layui 数据表格前后台传值的问题
1.1查询 layui.use('table', function() { var table = layui.table; table.render({ elem : '#demo', url : ...
- java list数组排序_浅谈对象数组或list排序及Collections排序原理
常需要对list进行排序,小到List,大到对自定义的类进行排序.不需要自行归并或堆排序.简单实现一个接口即可. 本文先会介绍利用Collections对List进行排序,继而讲到Collection ...
- 浅谈大数据的标签管理
最近参与了一个大数据的项目,是涉及标签管理方面的内容,使我这个初涉入大数据领域的人获益匪浅. 标签,也可以叫做Tag,最早出现于2005年(注1),随着Web2.0的Blog应用被广泛使用开来.标签也 ...
- 张晓波:浅谈大数据应用的知与行|V课堂第82期
2017年8月26日,<中国大数据应用蓝皮书>的发布引起了大数据领域的政产学界领导.顶尖学者的强烈关注.在全球化的新阶段,面对互联的新世界,大数据如何不断创造新模式.新生态和新时代? 第8 ...
- 大数据审计的发展_浅谈大数据时代下审计工作的发展方向
浅谈大数据时代下审计工作的发展方向 李寒梅 [摘 要] [ 摘 要 ] 随着信息化水平不断提升,企业的审计工作需要处理海量的数 据,而利用常规软件难以对海量数据进行处理,这就需要应用大数据技术.审 计 ...
- 浅谈大规模k8s集群关于events的那些坑
浅谈大规模k8s集群关于events的那些坑 背景 一.用户通过kubectl list event 二.kubernetes-dashboard list events 三.直接在集群中list e ...
最新文章
- php 最大数字,PHP 计算至少是其他数字两倍的最大数的实现代码
- slider使用TickPlacement获得游标效果
- 物联网-移远M26模块MQTT开发(AT命令)
- 硬件基础知识---(12) PCB的生产流程
- SDUT 1149 勾股定理第一弹 勾股数
- Java初级程序员学习路线→中高级程序员
- 便捷的收集数据工具—Sniffer嗅探器
- 服务器怒稳定进不了某个网址,登录服务器的一瞬间,让我感觉自己再也不是“菊外人”...
- JSON数据中带有HTML标签解决方法
- go 并发goroutines,channal
- 为什么要努力读书学习,一位清华妈妈总结了7条,太到位了
- jQuery二维码生成
- spark convert RDD[Map] to DataFrame
- python定义单位矩阵_python 实现一个反向单位矩阵示例
- Micropython史上最友好的编辑器,小巧精悍
- HTML5《汉堡小店》游戏截图
- 甲骨文中国裁员,N+6赔偿……部分员工抗议
- iperf 安卓 灌包命令_iperf灌包
- 《东周列国志》第七回 公孙阏争车射考叔 公子翚献谄贼隐公
- WINDOWS 屏幕测试 RGB_TEST