提交 0d90f9cf 编写于 作者: chendeli's avatar chendeli

merage

...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
import VHeader from './views/layout/header.vue' import VHeader from './views/layout/header.vue'
import VSlidebar from './views/layout/slidebar.vue' import VSlidebar from './views/layout/slidebar.vue'
import VFooter from './views/layout/footer.vue' import VFooter from './views/layout/footer.vue'
import { base64decode, isNotEmptyUtils, getUrlParamsMap } from "./utils/utils.js" import { base64decode, isNotEmptyUtils, getUrlParamsMap, ssoLogin } from "./utils/utils.js"
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters } from 'vuex'
import { getLoginUrl, getInnerLoginUrl } from './utils/index.js' import { getLoginUrl, getInnerLoginUrl } from './utils/index.js'
let vm = null let vm = null
...@@ -62,9 +62,10 @@ export default { ...@@ -62,9 +62,10 @@ export default {
let paramStr = href.substring(offset + 1, href.length) let paramStr = href.substring(offset + 1, href.length)
let pars = base64decode(paramStr) let pars = base64decode(paramStr)
let paramMap = getUrlParamsMap(pars, "&") let paramMap = getUrlParamsMap(pars, "&")
if (isNotEmptyUtils(paramMap["token"])) { if (isNotEmptyUtils(paramMap["token"]) && isNotEmptyUtils(paramMap["ssoOrigin"])) {
vm.token = paramMap["token"] vm.token = paramMap["token"]
localStorage.setItem('storageToken', vm.token) localStorage.setItem('storageToken', vm.token)
ssoLogin(href, paramMap)
//vm.$router.push({ path: 'home' }) //vm.$router.push({ path: 'home' })
} else { } else {
if(!localStorage.getItem('storageToken')) { if(!localStorage.getItem('storageToken')) {
......
...@@ -6,10 +6,13 @@ const blank = r => require.ensure([], () => r(require('../views/blank')), 'blank ...@@ -6,10 +6,13 @@ const blank = r => require.ensure([], () => r(require('../views/blank')), 'blank
const discuss = r => require.ensure([], () => r(require('../views/discuss/index.vue')), 'index') const discuss = r => require.ensure([], () => r(require('../views/discuss/index.vue')), 'index')
const creatDiscuss = r => require.ensure([], () => r(require('../views/discuss/add-edit.vue')), 'creatDiscuss') const creatDiscuss = r => require.ensure([], () => r(require('../views/discuss/add-edit.vue')), 'creatDiscuss')
const questionNaire = r => require.ensure([], () => r(require('../views/question-naire/question-list.vue')), 'questionNaire')
const topicList = r => require.ensure([], () => r(require('../views/topicManage/index.vue')), 'topicList') const topicList = r => require.ensure([], () => r(require('../views/topicManage/index.vue')), 'topicList')
const reportSet = r => require.ensure([], () => r(require('../views/report/reportSet.vue')), 'reportSet') const reportSet = r => require.ensure([], () => r(require('../views/report/reportSet.vue')), 'reportSet')
export default [{ export default [{
path: '/', path: '/',
component: App, component: App,
...@@ -18,8 +21,8 @@ export default [{ ...@@ -18,8 +21,8 @@ export default [{
path: '', path: '',
redirect: '/home' redirect: '/home'
},{ },{
path: '/index', path: '/questionNaire',
component: home component: questionNaire
},{ },{
path: '/home', path: '/home',
component: home component: home
...@@ -32,6 +35,10 @@ export default [{ ...@@ -32,6 +35,10 @@ export default [{
{ {
path: '/creat-discuss', path: '/creat-discuss',
component: creatDiscuss component: creatDiscuss
},
{
path: '/question-naire',
component: questionNaire
}, },
{ {
path: '/topic-list', path: '/topic-list',
...@@ -42,6 +49,5 @@ export default [{ ...@@ -42,6 +49,5 @@ export default [{
component: reportSet component: reportSet
}, },
] ]
}] }]
\ No newline at end of file
...@@ -6,14 +6,8 @@ ...@@ -6,14 +6,8 @@
// 分页大小 // 分页大小
export const PAGE_SIZE = 10 export const PAGE_SIZE = 10
// 添加动作常量 // 问卷--模板下载
export const ACTION_TYPE_ADD = 'ACTION_TYPE_ADD' export const QUESTION_UPLOAD_TEMPLATE = 'https://files.yunqueyi.com/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet/common/20190410160755914.xlsx'
// 修改动作常量
export const ACTION_TYPE_UPDATE = 'ACTION_TYPE_UPDATE'
// 删除动作常量
export const ACTION_TYPE_DELETE = 'ACTION_TYPE_DELETE'
/* 是否使用Mock数据 */ /* 是否使用Mock数据 */
export const IS_MOCK_DATAS = true export const IS_MOCK_DATAS = true
......
...@@ -152,6 +152,25 @@ const vueFilter = { ...@@ -152,6 +152,25 @@ const vueFilter = {
return '普通用户' return '普通用户'
} }
}, },
// 问卷
questionStatus: (value) => {
if(value == 1) {
return '下线'
}else {
return '上线'
}
},
modifyType: (value,data) => {
let userName = ''
for(let i=0; i < data.length;i++) {
if(value == data[i].id) {
userName = data[i].userName
break
}else {
userName = ''
}
}
return userName
}
} }
export default vueFilter export default vueFilter
\ No newline at end of file
...@@ -109,164 +109,6 @@ const doQiniuAction1 = (fileType) => { ...@@ -109,164 +109,6 @@ const doQiniuAction1 = (fileType) => {
}); });
}; };
/**
*
* @param self
* @param file
* @param filePath
* @param previewId
* @param progressId
* @returns {Promise}
*/
export const qiniuUpload = (self, file, filePath, previewId, progressId) => {
// var deferred = $q.defer();
return new Promise(function (resolve, reject) {
if (isEmptyUtils(file) || isEmptyUtils(filePath)) {
console.error('七牛上传失败:非法参数');
reject();
}
let key = filePath ? filePath : getFilePath(file);
//修改状态为上传
self.qiniuUploadStatus = true;
// let token = "BRVB4TpxVFA5Wo6lIpfltmWKOltzGar46tvC3BlR:UHn0LDElwjP4jEZTXdq_1qV6_hw=:eyJzY29wZSI6InBpY2EtdGVzdCIsInJldHVybkJvZHkiOiJ7XCJrZXlcIjpcIiQoa2V5KVwiLFwiaGFzaFwiOlwiJChldGFnKVwiLFwiYnVja2V0XCI6XCIkKGJ1Y2tldClcIixcImZzaXplXCI6JChmc2l6ZSksXCJmbmFtZVwiOiQoZm5hbWUpLFwiZXh0XCI6JChleHQpfSIsImRlYWRsaW5lIjoxNTI5NDk0MTc1fQ==";
doQiniuAction().then(function (token) {
let putExtra = {
fname: file.name, //原文件名
params: {}, //用来放置自定义变量
mimeType: mimeTypeArray || null //null || array,用来限制上传文件类型,为 null 时表示不对文件类型限制;限制类型放到数组里: ["image/png", "image/jpeg", "image/gif"]
};
let config = {
useCdnDomain: true, //表示是否使用 cdn 加速域名,为布尔值,true 表示使用,默认为 false。
region: null //选择上传域名区域;当为 null 或 undefined 时,自动分析上传域名区域
};
/*
* qiniu.upload 返回一个 observable 对象用来控制上传行为,observable 对像通过 subscribe 方法可以被 observer 所订阅,
* 订阅同时会开始触发上传,同时返回一个 subscription 对象,该对象有一个 unsubscribe 方法取消订阅,同时终止上传行为。
* */
let observable = qiniu.upload(file, key, token, putExtra, config);
/**
* 接收上传进度信息,res 参数是一个带有 total 字段的 object,包含loaded、total、percent三个属性,提供上传进
* total.loaded: number,已上传大小,单位为字节。
* total.total: number,本次上传的总量控制信息,单位为字节,注意这里的 total 跟文件大小并不一致。
* total.percent: number,当前上传进度,范围:0~100
* */
let next = function (res) {
//res值{"total":{"loaded":18184,"size":18185,"percent":99.99450096233159}}
//获取百分比进度
let progress = res.total.percent.toFixed(2);
self.uploadProgress = Number(progress);
console.log('Progress: ' + progress);
//如果有进度条
/*if (isNotEmptyUtils(progressId)) {
let obj = $("#" + progressId);
//开始上传时,显示进度条
if (isNotEmptyUtils(obj.parent())) {
//修改状态为上传
// status = true;
self.qiniuUploadStatus = true;
obj.parent().removeClass("hidden");
obj.fadeIn("fast");
}
obj.css("width", progress + '%');
obj.text(progress + '%');
//上传完成,2秒后淡出进度条
if (progress === "100.00") {
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = true;
obj.fadeOut(2000);
}
}*/
};
/**
* 接收上传完成后的后端返回信息,res 参数为一个 object, 为上传成功后后端返回的信息
* ,具体返回结构取决于后端sdk的配置,可参考上传策略(https://developer.qiniu.com/kodo/manual/1206/put-policy)
* */
let complete = function (res) {
console.log("七牛上传完成");
setTimeout(function(){
result.key = res.key;
result.path = '/' + res.key;
result.fullPath = domain + '/' + res.key + '?v=' + new Date().getTime();
result.size = res.fsize;
result.name = res.fname ;
result.ext = res.ext;
// deferred.resolve(result);
resolve(result);
// self.model.qCloudUrl = result.fullPath;
// $("#introVideoLecture").attr("src", self.model.qCloudUrl);
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = false;
if (isNotEmptyUtils(previewId)) {
let address = domain + result.path;
console.log('文件路径: ' + address);
//显示图片
let $img = $('<img>').attr("src", address);
let obj = $("#" + previewId);
obj.empty().append($img);
obj.css('max-width', '100%');
}
},2000);
};
/**
* 上传错误后触发,当不是 xhr 请求错误时,会把当前错误产生原因直接抛出,诸如 JSON 解析异常等;当产生 xhr 请求错误时,参数 err 为一个包含 code、message、isRequestError 三个属性的 object:
* err.isRequestError: 用于区分是否 xhr 请求错误;当 xhr 请求出现错误并且后端通过 HTTP 状态码返回了错误信息时,该参数为 true;否则为 undefined 。
* err.reqId: string,xhr请求错误的 X-Reqid。
* err.code: number,请求错误状态码,只有在 err.isRequestError 为 true 的时候才有效,可查阅码值对应说明。
* err.message: string,错误信息,包含错误码,当后端返回提示信息时也会有相应的错误信息。
* */
let error = function (err) {
//修改状态为非上传
// status = false;
self.qiniuUploadStatus = false
localStorage.removeItem('qiniuToken');
console.log("七牛上传失败,详细信息请参考:https://developer.qiniu.com/kodo/api/3928/error-responses");
//输出简略错误信息
if (err.isRequestError){
qiniuErrorCheck(err.code)
}else {
console.error(err);
}
/*modalClick("提示", "上传失败!", "确定", function () {
$('#model-modify').modal('hide');
}, "", null);*/
// deferred.reject(new Error('七牛上传失败'));
// return deferred.promise;
return reject(new Error('七牛上传失败'));
};
// 上传开始
subscription = observable.subscribe(next, error, complete);
});
// return deferred.promise;
});
};
/** /**
* 获取时间戳 * 获取时间戳
* @param {Date} [date]日期对象,为空时,返回当前时间戳 * @param {Date} [date]日期对象,为空时,返回当前时间戳
......
...@@ -440,7 +440,7 @@ export const ssoLogin = (href, paramMap) => { ...@@ -440,7 +440,7 @@ export const ssoLogin = (href, paramMap) => {
} }
} }
//获取用户系统信息 //获取用户系统信息
initEnvironment(); // initEnvironment();
} }
}; };
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
<!--导航--> <!--导航-->
<div class="user-info"> <div class="user-info">
<el-dropdown trigger="click" @command="handleCommand"> <el-dropdown trigger="click">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
{{'系统切换'}}<i class="el-icon-arrow-down el-icon--right"></i> {{'系统切换'}}<i class="el-icon-arrow-down el-icon--right"></i>
</span> </span>
...@@ -32,12 +32,14 @@ ...@@ -32,12 +32,14 @@
</template> </template>
<script> <script>
import { getLoginUrl,getInnerLoginUrl, getYunQueYiUrl } from '../../utils/index.js' import { getLoginUrl,getInnerLoginUrl, getYunQueYiUrl } from '../../utils/index.js'
import { logout, base64encode } from '../../utils/utils.js'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
let vm = null let vm = null
export default { export default {
props: { props: {
userName: { userName: {
type: String type: String,
default: ''
}, },
authList: { authList: {
type: Array type: Array
...@@ -61,11 +63,42 @@ export default { ...@@ -61,11 +63,42 @@ export default {
methods: { methods: {
handleCommand(command) { handleCommand(command) {
if (command === 'logout') { if (command === 'logout') {
let req = {
token: localStorage.getItem('storageToken')
}
vm.POST('/contents/login/log_out',req).then((res) => {
localStorage.removeItem('storageToken') localStorage.removeItem('storageToken')
window.location.href = getInnerLoginUrl() window.location.href = getInnerLoginUrl()
//logout()
})
} }
if(command === 'forward') { },
forward(obj) {
let self = this;
if (obj.systemNameAbbreviation.toLowerCase() === "sso") {
window.location.href = obj.domainName + "pica_index.html";
} else {
let req = {
system_type: obj.id
};
vm.POST('/contents/login/forward_page', req).then(function (data) {
let forwardData = JSON.parse(JSON.stringify(data.data));//通过这个实现深拷贝
let url = forwardData.picapMenuModels[0].url;
if (url.length > 1) {
// window.location.href = url;
} else {
url = forwardData.picapMenuModels[0].picapSecondMenus[0].url;
if (url.length > 1) {
// window.location.href = url;
} else {
url = forwardData.picapMenuModels[0].picapSecondMenus[0].picapThirdMenus[0].url;
}
}
let param = "token=" + localStorage.getItem("storageToken") + "&ssoOrigin=" + localStorage.getItem("ssoOrigin") + "&system_type=" + obj.id;
window.location.href = obj.domainName + url + "?" + base64encode(param);
}, function (error) {
errorResponseCheck(error, self);
});
} }
} }
} }
......
...@@ -44,13 +44,16 @@ export default { ...@@ -44,13 +44,16 @@ export default {
icon: 'el-icon-setting', icon: 'el-icon-setting',
index: 'discuss-list' index: 'discuss-list'
}, },
// { {
// title: '话题管理', title: '问卷管理',
// icon: 'el-icon-setting', icon: 'el-icon-setting',
// index: 'topic-list' index: 'question-naire'
// }, },
{
title: '举报管理',
icon: 'el-icon-setting',
index: 'report-set'
}
] ]
}, },
......
<template>
<div class="question-wrap">
<bread-crumb
:curmbFirst="curmbFirst"
:curmbSecond="curmbSecond">
</bread-crumb>
<div class="question-content screenSet" id="screenSet">
<el-row :gutter="30" class="row" type="flex" style="margin-top: 10px;">
<el-form ref="serchForm" :model="searchParam" label-width="75px" label-suffix=":" style="width:100%;">
<el-col :span="6">
<el-form-item label="问卷名称">
<el-input v-model="searchParam.name" size="mini" placeholder="请输入问卷名称"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="状态">
<el-select clearable v-model="searchParam.status" size="mini" placeholder="请选择问卷状态">
<el-option
v-for="(item,index) in statuSelect"
:key="index"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" style="text-align:right;padding:0 30px 15px 0;">
<el-button type="primary" size="small" @click="search(1)">查询</el-button>
<el-button type="default" size="small" @click="reseat">重置</el-button>
</el-col>
</el-form>
</el-row>
<el-button class="add-question" type="primary" size="small" @click="addQuestion">新增问卷</el-button>
<el-table
:data="tableData"
style="width: 100%" v-loading="loading">
<el-table-column prop="id" label="问卷编号" min-width="50" align="center"></el-table-column>
<el-table-column prop="name" label="问卷名称" min-width="100" align="center"></el-table-column>
<el-table-column label="最后修改人" min-width="50" align="center">
<template slot-scope="scope">
<span>{{ scope.row.modifiedId | modifyType(modifyArray) }}</span>
</template>
</el-table-column>
<el-table-column label="最后修改时间" min-width="100" align="center">
<template slot-scope="scope">
<span>{{ scope.row.modifiedTime | liveDateFilter }}</span>
</template>
</el-table-column>
<el-table-column label="问卷状态" min-width="80" align="center">
<template slot-scope="scope">
<span>{{ scope.row.status | questionStatus }}</span>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" min-width="200">
<template slot-scope="scope">
<el-button type="primary" size="small" @click="editQuestion(scope.row)">编辑</el-button>
<el-button type="primary" v-if="scope.row.status == 1" size="small" @click="onAndDownLine(scope.row)">上线</el-button>
<el-button type="primary" v-if="scope.row.status == 2" size="small" @click="onAndDownLine(scope.row)">下线</el-button>
<!-- <el-button type="primary" size="small" @click="reviewQuestion(scope.row)">查看题库</el-button> -->
</template>
</el-table-column>
<div slot="empty">
<div class="table-empty">
<img src="../../assets/image/no-content1.png" />
<p>没有查询到相关结果</p>
</div>
</div>
</el-table>
<!-- 分页 -->
<div class="pagination">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchParam.pageNo"
:page-sizes="[15, 30, 50, 100, 200, 500, 700, 1000, 1500, 2000]"
:page-size="searchParam.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="totalRows">
</el-pagination>
</div>
</div>
<!-- 问卷新增(编辑) -->
<el-dialog
class="img-edit"
:title="questionTitle"
:visible.sync="discussEditVisible"
:close-on-click-modal="false"
:close-on-press-escape="false">
<el-form ref="questionForm" :rules="rules" :model="questionEditList" label-width="220px" label-suffix=":" size="mini">
<el-form-item>
<el-radio-group v-model="questionEditList.showType" style="margin-left: -65px;">
<el-radio :label="1">单题显示</el-radio>
<el-radio :label="2">平铺显示</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="问卷标题" prop="name">
<el-input v-model="questionEditList.name" maxlength="10" placeholder="标题最多10字符" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="题库导入" prop="fileName">
<el-col :span="12">
<el-input class="form-input" :placeholder="excelFileName" v-model="fileName" disabled style="width: 99%;"/>
</el-col>
<el-col :span="10">
<el-upload
class="upload-demo"
style="display: inline-block;width: 80px;"
action="#"
accept=".xlsx"
:before-upload="beforeImport"
:limit="1">
<el-button type="primary" size="mini">导入题库</el-button>
</el-upload>
<el-button type="default" size="mini" @click="uploadTemplate">模板下载</el-button>
</el-col>
</el-form-item>
<el-form-item label="下一题按钮" v-if="questionEditList.showType == 1">
<div class="submit-btn" style="margin-right:20px;">
<p>置灰不可点</p>
<el-upload
v-model="questionEditList.nextDisableClickUrl"
class="avatar-uploader"
action="#"
:show-file-list="false"
:before-upload="beforeAvatarUpload_1">
<el-button size="mini" type="primary">上传</el-button>
</el-upload>
<div class="uploat-content">
<img v-if="questionEditList.nextDisableClickUrl" :src="questionEditList.nextDisableClickUrl" class="bg-img">
<img v-if="!questionEditList.nextDisableClickUrl" class="bg-img" src="https://files.yunqueyi.com/image/png/common/20190408164003674.png">
</div>
</div>
<div class="submit-btn">
<p>点亮可点</p>
<el-upload
v-model="questionEditList.nextClickUrl"
class="avatar-uploader"
action="#"
:show-file-list="false"
:before-upload="beforeAvatarUpload_2">
<el-button size="mini" type="primary">上传</el-button>
</el-upload>
<div class="uploat-content">
<img v-if="questionEditList.nextClickUrl" :src="questionEditList.nextClickUrl" class="bg-img">
<img v-if="!questionEditList.nextClickUrl" class="bg-img" src="https://files.yunqueyi.com/image/png/common/20190408164015812.png">
</div>
</div>
</el-form-item>
<el-form-item label="头部样式" v-if="questionEditList.showType == 2">
<el-radio-group v-model="questionEditList.headStyle">
<el-radio :label="1">文字</el-radio>
<el-radio :label="2">图片</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="副标题" v-if="questionEditList.showType == 2 && questionEditList.headStyle == 1">
<el-input v-model="questionEditList.subheading" maxlength="20" placeholder="副标题最多20字符" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="问卷导言" v-if="questionEditList.showType == 2">
<el-input v-model="questionEditList.questionIntro" maxlength="210" placeholder="最多210字符" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="问卷起始时间" v-if="questionEditList.showType == 2 && questionEditList.headStyle == 1">
<el-date-picker
type="datetime"
placeholder="开始时间"
v-model="questionEditList.startDate"
style="width: 181px;"
:picker-options="endDateOpt"
>
</el-date-picker>
<span>-</span>
<el-date-picker
type="datetime"
placeholder="结束时间"
v-model="questionEditList.endDate"
style="width: 181px;"
:picker-options="endDateOpt1"
default-time="23:59:59"
>
</el-date-picker>
</el-form-item>
<div v-if="questionEditList.showType == 2 && questionEditList.headStyle == 2">
<el-form-item class="submit-btn" label="头图">
<el-upload
v-model="questionEditList.headDiagramUrl"
class="avatar-uploader"
action="#"
:show-file-list="false"
:before-upload="beforeAvatarUpload_4">
<el-button class="head-btn" size="mini" type="primary">上传</el-button>
</el-upload>
<div class="uploat-content">
<img v-if="questionEditList.headDiagramUrl" :src="questionEditList.headDiagramUrl" class="head-bg-img">
<img v-if="!questionEditList.headDiagramUrl" class="head-bg-img" src="../../assets/image/default.png">
</div>
</el-form-item>
</div>
<el-form-item class="submit-btn" label="提交按钮">
<el-upload
v-model="questionEditList.submitButtomUrl"
class="avatar-uploader"
action="#"
:show-file-list="false"
:before-upload="beforeAvatarUpload_3">
<el-button size="mini" type="primary">上传</el-button>
</el-upload>
<div class="uploat-content">
<img v-if="questionEditList.submitButtomUrl" :src="questionEditList.submitButtomUrl" class="bg-img">
<img v-if="!questionEditList.submitButtomUrl" class="bg-img" src="https://files.yunqueyi.com/image/png/common/20190408164026451.png">
</div>
</el-form-item>
<el-form-item label="问卷填写完毕提示文案" prop="promptCopy">
<el-input v-model="questionEditList.promptCopy" maxlength="40" style="width: 300px;"></el-input>
<span style="font-size:12px;">标题最多40字符</span>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align:center;">
<el-button type="primary" size="small" @click="submitQuestion" style="width:120px;">提交</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import BreadCrumb from '../../components/breadcrumb.vue'
import * as commonUtil from '../../utils/utils'
import { getFilePath, doUpload } from '../../utils/qiniu-util'
import { QUESTION_UPLOAD_TEMPLATE } from '../../utils/constants'
let vm = null
export default {
components: {
BreadCrumb
},
data() {
return {
curmbFirst: '组件',
curmbSecond: '问卷管理',
questionTitle: '问卷新增/编辑',
discussEditVisible: false,
excelFileName: '',
fileName: '',
fileArray: [],
tableData: [],
totalRows: 0,
loading:false,
searchParam: {
name: '',
status: '',
pageSize: 15,
pageNo: 1
},
modifyArray: [],
questionEditList: {
id: '',
showType: 1,
name: '',
nextDisableClickUrl: '',
nextClickUrl: '',
submitButtomUrl: '',
promptCopy: '',
headDiagramUrl: '',
headStyle: 1,
subheading: '',
questionIntro: '',
startDate: '',
endDate: ''
},
endDateOpt: {
disabledData: (time) => {
if ( this.questionEditList.endDate != "" && this.questionEditList.endDate != null) {
return time.getTime() > new Date(this.questionEditList.startDate).getTime();
}
}
},
endDateOpt1: {
disabledDate: time => {
return (
time.getTime() < new Date(this.questionEditList.startDate).getTime()
);
}
},
rules: {
name: [
{ required: true, message: '请输入问卷标题', trigger: 'blur' }
],
promptCopy: [
{ required: true, message: '请输入问卷填写完毕提示文案', trigger: 'blur' }
]
},
statuSelect: [
{
label: '下线',
value: 1
},{
label: '上线',
value: 2
}
]
}
},
created() {
vm = this
vm.search()
vm.getAllModify()
},
// 挂载到Dom完成时
mounted: function() {
commonUtil.resizeHeight()
},
methods: {
// 查询
search(flag) {
if(flag) vm.searchParam.pageNo = 1
vm.GET('/campaign/adminQuestionnaire/queryList',vm.searchParam).then((res) => {
if(res.code == '000000') {
vm.tableData = res.data.questionnaireList
vm.totalRows = res.data.total
}
})
},
handleSizeChange(value) {
vm.searchParam.pageSize = value
vm.search()
},
handleCurrentChange(value) {
vm.searchParam.pageNo = value
vm.search()
},
reseat() {
vm.searchParam.name = ''
vm.searchParam.status = ''
vm.search()
},
// 获取所有修改人
getAllModify() {
vm.GET('/campaign/adminQuestionnaire/getAllUser').then((res) => {
if(res.code == '000000') {
vm.modifyArray = res.data
}
})
},
// 新增问卷
addQuestion() {
vm.discussEditVisible = true
if (vm.$refs.questionForm !== undefined) {
vm.$refs.questionForm.resetFields();
}
vm.questionEditList = Object.assign({},{
id: '',
showType: 1,
name: '',
nextDisableClickUrl: '',
nextClickUrl: '',
submitButtomUrl: '',
promptCopy: '',
headDiagramUrl: '',
headStyle: 1,
subheading: '',
questionIntro: '',
startDate: '',
endDate: ''
});
vm.fileName = ''
vm.fileArray = []
vm.excelFileName = ''
},
// 编辑
editQuestion(row) {
if (vm.$refs.questionForm !== undefined) {
vm.$refs.questionForm.resetFields();
}
vm.discussEditVisible = true
vm.excelFileName = ''
vm.fileName = ''
vm.fileArray = []
vm.GET('/campaign/adminQuestionnaire/getQuestionnaireById',{id:row.id}).then((res) => {
if(res.code == '000000') {
vm.questionEditList = Object.assign({},res.data)
}
})
},
// 上线/下线
onAndDownLine(row) {
let req = null
if(row.status == 1) {
req = {
id: row.id,
status: 2
}
} else {
req = {
id: row.id,
status: 1
}
}
vm.GET('/campaign/adminQuestionnaire/upperOrLowerShip',req).then((res) => {
if(res.code == '000000') {
vm.search()
}
})
},
// 导入题库
beforeImport(file) {
if (commonUtil.isEmptyUtils(file)) return;
let arr = file.type.split('/');
let ext = "." + arr[1];
let reader = new FileReader();
reader.onload = function (e) {
let fileJson = {
fileName: file.name,
file: e.target.result.substr(e.target.result.indexOf("base64,") + 7),
ext: ext
};
vm.fileArray = [{
base64: fileJson
}];
vm.fileName = file.name;
vm.excelFileName = file.name;
vm.$message.info('读取完毕');
};
reader.readAsDataURL(file);
},
// 模板下载
uploadTemplate() {
window.location.href = QUESTION_UPLOAD_TEMPLATE
},
// 置灰不可点图片上传
beforeAvatarUpload_1(file) {
if (commonUtil.isEmptyUtils(file)) return;
vm.imgDoUpload(file,1,50,750,100)
},
// 点亮图片上传
beforeAvatarUpload_2(file) {
if (commonUtil.isEmptyUtils(file)) return;
vm.imgDoUpload(file,2,50,750,100)
},
// 提交图片上传
beforeAvatarUpload_3(file) {
if (commonUtil.isEmptyUtils(file)) return;
vm.imgDoUpload(file,3,50,750,100)
},
// 头图图片上传
beforeAvatarUpload_4(file) {
if (commonUtil.isEmptyUtils(file)) return;
vm.imgDoUpload(file,4,100,750,468)
},
imgDoUpload(file,urlType,size,w,h) {
const isSize = file.size / 1024 < size;
if(!isSize) {
vm.$message.info('上传图片要小于' + size + 'k')
return;
}
var _img = new FileReader()
_img.readAsDataURL(file)
_img.onload = function(theFile) {
let image = new Image()
image.src = theFile.target.result
image.onload = function() {
let _this = this
if( _this.width != w || _this.height != h) {
vm.$message.info("上传图片尺寸应为"+ w +"*"+ h +",请重新上传")
}else {
vm.$message.info('开始上传');
doUpload(vm,file, getFilePath(file,null), 'preview4', 'progress1', 1).then(function (path) {
if(urlType == 1) {
vm.questionEditList.nextDisableClickUrl = path.fullPath
}else if(urlType == 2) {
vm.questionEditList.nextClickUrl = path.fullPath
}else if(urlType == 3) {
vm.questionEditList.submitButtomUrl = path.fullPath
}else {
vm.questionEditList.headDiagramUrl = path.fullPath
}
vm.$message.success('上传成功')
});
}
}
}
},
// 提交
submitQuestion() {
let req = {
model: vm.questionEditList,
fileArray: vm.fileArray
}
if(vm.questionEditList.showType == 1) { // 单题显示
vm.questionEditList.subheading = ''
vm.questionEditList.questionIntro = ''
vm.questionEditList.headDiagramUrl = ''
}else {
vm.questionEditList.nextDisableClickUrl = ''
vm.questionEditList.nextClickUrl = ''
if(vm.questionEditList.headStyle == 1) { // 文字
vm.questionEditList.headDiagramUrl = ''
}else {
vm.questionEditList.subheading = ''
vm.questionEditList.startDate = ''
vm.questionEditList.endDate = ''
}
}
if(!vm.questionEditList.id) {
if(commonUtil.isEmptyList(vm.fileArray)) {
vm.$message.info('请导入题库')
return
}
}
vm.$refs.questionForm.validate((valid) => {
if(valid) {
commonUtil.openLoading(vm)
vm.POST('/campaign/adminQuestionnaire/insertOrUpdateQuestionnaire',req).then((res) => {
commonUtil.closeLoading(vm)
if(res.code == '000000') {
vm.discussEditVisible = false
vm.search()
}else {
vm.$message.info(res.message)
}
})
}
})
}
}
}
</script>
<style lang="scss" scoped>
.question-wrap {
.question-content {
background: #fff;
.add-question {
float: right;
margin: 10px;
}
.table-empty {
img{
width: 100px;
}
p {
margin-top: -50px;
}
}
}
.submit-btn {
display: inline-block;
overflow: hidden;
p {
font-size: 12px;
}
.avatar-uploader {
float: right;
.el-button {
margin-left: 10px;
}
.head-btn {
margin-top: 48px !important;
}
}
.uploat-content {
float: left;
.bg-img {
width: 150px;
height: 30px;
}
.head-bg-img {
width: 80px;
height: 80px;
}
}
}
}
</style>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册