Commit 5eeed9cf by xinla

智能表单

1 parent afb7fb8b
Showing 64 changed files with 2996 additions and 132 deletions
...@@ -3,7 +3,7 @@ import { dataURLtoFile } from '@/utils/common' ...@@ -3,7 +3,7 @@ import { dataURLtoFile } from '@/utils/common'
const service = window.CONFIG.services.system const service = window.CONFIG.services.system
export function upload (data) { export function upload(data) {
return request({ return request({
url: service + '/file/upload', url: service + '/file/upload',
method: 'POST', method: 'POST',
...@@ -19,7 +19,7 @@ export function upload (data) { ...@@ -19,7 +19,7 @@ export function upload (data) {
name=文件名称,带后缀 name=文件名称,带后缀
} }
*/ */
export function download (url, name) { export function download(url, name) {
return ( return (
window.lwConfig.DOMAIN + window.lwConfig.DOMAIN +
window.CONFIG.services.system + window.CONFIG.services.system +
...@@ -34,7 +34,7 @@ export function download (url, name) { ...@@ -34,7 +34,7 @@ export function download (url, name) {
"dataURL": 本地文件(base64) "dataURL": 本地文件(base64)
} }
*/ */
export function uploadDataURL (dataURL) { export function uploadDataURL(dataURL) {
const data = new window.FormData() const data = new window.FormData()
const f = dataURLtoFile(dataURL) const f = dataURLtoFile(dataURL)
data.append('file', f) data.append('file', f)
...@@ -48,9 +48,51 @@ export function uploadDataURL (dataURL) { ...@@ -48,9 +48,51 @@ export function uploadDataURL (dataURL) {
} }
// 省市区 级联数据 // 省市区 级联数据
export function getProCityList (data) { export function getProCityList(data) {
return request({ return request({
url: service + '/system/area/list', url: service + '/system/area/list',
params: data params: data,
})
}
/**
* 获取微信授权链接
* @param {*} redirectUrl 回调跳转地址
* @returns
*/
export function getWxRedirect(redirectUrl = location.href) {
return request({
url: service + '/auth/wxRedirect',
method: 'get',
params: {
redirectUrl,
},
})
}
/**
* 微信获取token接口
* @param {*} code 是 code码 必填
* @param {*} openId 否 微信用户ID 非必填
* @returns
*/
export function wxLogin(code, openId) {
return request({
url: service + '/auth/wxLogin',
method: 'get',
params: {
code,
openId,
},
})
}
/**
* 获取微信授权用户信息
* @param {*} openId
*/
export function getWechatUserInfo() {
return request({
url: service + `/system/user/getWxInfo`,
}) })
} }
import request from '@/utils/request'
import { dataURLtoFile } from '@/utils/common'
const service = window.CONFIG.services.system + window.CONFIG.services.wecom + '/form'
//查询省市区
// export function treelist(data) {
// return request({
// url: service + '/treelist' + data,
// method: 'get',
// data,
// })
// }
//图片上传
// export function uploadFile(dataURL) {
// const data = new window.FormData()
// const f = dataURLtoFile(dataURL)
// data.append('file', f)
// // console.log('基础参数',f)
// console.log('基础参数1', data)
// return request({
// url: service + '/common/uploadFile2Cos',
// method: 'post',
// processData: false,
// data,
// })
// }
// 新增表单
export function insertInfoToSurvey(data) {
return request({
url: service + '/survey/add',
method: 'post',
data,
})
}
// 表单
export function surveyList(data) {
return request({
url: service + '/survey/list',
method: 'GET',
params: data,
})
}
// 删除表单列表
export function deleteInfoToSurvey(ids) {
return request({
url: service + '/survey/delete/' + ids,
method: 'DELETE',
})
}
// 获取表单问卷列表/表单详情
export function selectInfoToSurvey(id) {
return request({
url: service + '/survey/getInfo/' + id,
method: 'GET',
})
}
// 提交问卷
export function submitForm(data) {
return request({
url: service + '/answer/add',
method: 'post',
data,
})
}
// 判断用户是否填写表单
export function isCompleteSurvey(data) {
return request({
url: service + '/answer/isCompleteSurvey',
method: 'post',
data,
})
}
//提交用户填写表单
export function insertPieValue(data) {
return request({
url: service + '/statistic/insertPieValue',
method: 'post',
data,
})
}
// 更改表单状态
export function updateSurveyStatus(data) {
return request({
url: service + '/survey/updateStatus',
method: 'put',
data,
})
}
//获取微信用户信息
export function getAccessToken(data) {
return request({
url: service + '/Statistics/getAccessToken' + data,
method: 'get',
data,
})
}
//转移分组
export function updateSurveyGroup(data) {
return request({
url: service + '/updateSurveyGroup',
method: 'post',
data,
})
}
////////统计
//获取统计基本信息
export function selectStatistics(data) {
return request({
url: service + '/statistic/getStatistics',
method: 'get',
params: data,
})
}
//折现统计图
export function lineChart(data) {
return request({
url: service + '/statistic/lineChart',
method: 'post',
data,
})
}
//数据报表
export function StatisticsDataList(data) {
return request({
url: service + '/statistic/dataList',
method: 'post',
data,
})
}
//更改表单
export function updateInfoToSurvey(data) {
return request({
url: service + '/survey/update',
method: 'put',
data,
})
}
//数据统计数据
export function selectAnswerInfo(data) {
return request({
url: service + '/answer/getAnswerList',
method: 'post',
data,
})
}
//扇形统计图
export function pieChart(data) {
return request({
url: service + '/statistic/pieChart',
method: 'post',
data,
})
}
/**
* 数据报表导出
* @param {*} data
{
"belongId": "25",
"type": "",
"dataSource": "cillum consectetur",
"startDate": "1992-07-12",
"endDate": "2012-02-24"
}
* @returns
*/
export function overviewExport(data) {
return request({
url: service + '/statistic/data/export',
method: 'post',
data,
})
}
//智能表单答案统计 参数同上
export function answerExport(data) {
return request({
url: service + '/statistic/answer/export',
method: 'get',
params: data,
responseType: 'blob',
})
}
//用户统计报表导出 参数同上
export function userExport(data) {
return request({
url: service + '/statistic/user/export',
method: 'post',
data,
})
}
//用户统计
export function statisticsCustomer(data) {
return request({
url: service + '/statistic/customer',
method: 'post',
data,
})
}
//省市联动统计
export function areaStatistic(data) {
return request({
url: service + '/statistic/areaStatistic',
method: 'post',
data,
})
}
/**
* 智能表单站点统计
* @param {*} data
* {
* belongId: this.formId,
dataSource: this.dataSource,
* }
* @returns
*/
export function siteStas(data) {
return request({
url: service + '/statistic/siteStas',
method: 'post',
data,
})
}
import router from './router' import router from './router'
import store from './store' import store from './store'
import { Message } from 'element-ui' import { Message } from 'element-ui'
import NProgress from 'nprogress' // import NProgress from 'nprogress'
// import 'nprogress/nprogress.css' // import 'nprogress/nprogress.css'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
// NProgress.configure({ showSpinner: false }) // NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/authRedirect', '/bind', '/register', '/test'] const whiteList = ['/authRedirect', '/bind', '/test'] // 不管有没有token都可直接进入的页面路径
const noLoginList = ['/login', '/register'] // 没有token才能进入的页面
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
// debugger
// NProgress.start() // NProgress.start()
if (getToken()) { // 无需检测token的, 不管有没有token都可直接进入
if (whiteList.includes(to.path) || to.meta.isNoLogin) {
next()
} else if (getToken()) {
/* has token*/ /* has token*/
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }) next({ path: '/' })
...@@ -61,16 +63,13 @@ router.beforeEach((to, from, next) => { ...@@ -61,16 +63,13 @@ router.beforeEach((to, from, next) => {
next() next()
} }
} }
} else { } else if (noLoginList.includes(to.path)) {
// 没有token // 没有token才能进入的页面
if (whiteList.indexOf(to.path) !== -1 || to.meta.isNoLogin) {
// 在免登录白名单,直接进入
next() next()
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
// NProgress.done() // NProgress.done()
} }
}
}) })
router.afterEach(() => { router.afterEach(() => {
......
...@@ -30,8 +30,46 @@ import visitor from '@/layout/visitor' ...@@ -30,8 +30,46 @@ import visitor from '@/layout/visitor'
} }
*/ */
// 公共路由 // 开发路由,总后台配置完菜单务必删除,只在开发环境生效
export const constantRoutes = [ const devRoutes = [
{
path: '/smartForms',
component: Layout,
hidden: true,
meta: {
title: '商品中心',
},
children: [
{
path: 'list',
component: (resolve) => require(['@/views/drainageCode/smartForms/index'], resolve),
meta: {
title: '商品管理',
activeMenu: '/commodityCenter/commodityManage',
breadcrumb: true,
},
},
{
path: 'add',
component: (resolve) => require(['@/views/drainageCode/smartForms/add'], resolve),
meta: {
title: '商品管理',
activeMenu: '/commodityCenter/commodityManage',
breadcrumb: true,
},
},
{
path: 'smartFormStatistics',
component: (resolve) =>
require(['@/views/drainageCode/smartForms/statistics/index'], resolve),
meta: {
title: '商品管理',
activeMenu: '/commodityCenter/commodityManage',
breadcrumb: true,
},
},
],
},
{ {
path: '/commodityCenter', path: '/commodityCenter',
component: Layout, component: Layout,
...@@ -63,6 +101,19 @@ export const constantRoutes = [ ...@@ -63,6 +101,19 @@ export const constantRoutes = [
}, },
], ],
}, },
]
// 公共路由
export const constantRoutes = [
{
path: '/formsDetail', // 智能表单填写
component: (resolve) => require(['@/views/drainageCode/smartForms/build/formsDetail'], resolve),
hidden: true,
meta: {
title: '填写表单',
isNoLogin: true,
},
},
{ {
path: '/drainageCode/qrCode', path: '/drainageCode/qrCode',
component: Layout, component: Layout,
...@@ -131,5 +182,6 @@ export default new Router({ ...@@ -131,5 +182,6 @@ export default new Router({
// mode: process.env.VUE_APP_ENV === 'test' ? 'hash' : 'history', // history 下 element ui 存在bug // mode: process.env.VUE_APP_ENV === 'test' ? 'hash' : 'history', // history 下 element ui 存在bug
// base: window.lwConfig.BASE_URL, // base: window.lwConfig.BASE_URL,
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes, routes:
process.env.NODE_ENV !== 'development' ? constantRoutes : constantRoutes.concat(devRoutes),
}) })
...@@ -79,23 +79,21 @@ export function diffDate(startDate, endDate) { ...@@ -79,23 +79,21 @@ export function diffDate(startDate, endDate) {
} }
const start = new Date(startDate) const start = new Date(startDate)
const end = new Date(endDate) const end = new Date(endDate)
const diff = (end - start)/1000 const diff = (end - start) / 1000
console.log(diff) console.log(diff)
const days = parseInt(diff/86400) const days = parseInt(diff / 86400)
const hours = parseInt(diff/3600)-24*days const hours = parseInt(diff / 3600) - 24 * days
const minutes = parseInt(diff%3600/60) const minutes = parseInt((diff % 3600) / 60)
const seconds = parseInt(diff%60) const seconds = parseInt(diff % 60)
if (hours) { if (hours) {
return (hours + 'h' + minutes + 'm' + seconds + 's') return hours + 'h' + minutes + 'm' + seconds + 's'
} }
if (minutes) { if (minutes) {
return (minutes + 'm' + seconds + 's') return minutes + 'm' + seconds + 's'
} }
return seconds + 's' return seconds + 's'
} }
/** /**
* @param {string} url * @param {string} url
* @returns {Object} * @returns {Object}
...@@ -513,109 +511,226 @@ export function uuid(before = '', after = '') { ...@@ -513,109 +511,226 @@ export function uuid(before = '', after = '') {
// 微信表情包匹配 // 微信表情包匹配
export const emotion = [ export const emotion = [
"[微笑]", '[微笑]',
"[撇嘴]", '[撇嘴]',
"[色]", '[色]',
"[发呆]", '[发呆]',
"[得意]", '[得意]',
"[流泪]", '[流泪]',
"[害羞]", '[害羞]',
"[闭嘴]", '[闭嘴]',
"[睡]", '[睡]',
"[大哭]", '[大哭]',
"[尴尬]", '[尴尬]',
"[发怒]", '[发怒]',
"[调皮]", '[调皮]',
"[呲牙]", '[呲牙]',
"[惊讶]", '[惊讶]',
"[难过]", '[难过]',
"[酷]", '[酷]',
"[冷汗]", '[冷汗]',
"[抓狂]", '[抓狂]',
"[吐]", '[吐]',
"[偷笑]", '[偷笑]',
"[可爱]", '[可爱]',
"[白眼]", '[白眼]',
"[傲慢]", '[傲慢]',
"[饥饿]", '[饥饿]',
"[困]", '[困]',
"[惊恐]", '[惊恐]',
"[流汗]", '[流汗]',
"[憨笑]", '[憨笑]',
"[大兵]", '[大兵]',
"[奋斗]", '[奋斗]',
"[咒骂]", '[咒骂]',
"[疑问]", '[疑问]',
"[嘘]", '[嘘]',
"[晕]", '[晕]',
"[折磨]", '[折磨]',
"[衰]", '[衰]',
"[骷髅]", '[骷髅]',
"[敲打]", '[敲打]',
"[再见]", '[再见]',
"[擦汗]", '[擦汗]',
"[抠鼻]", '[抠鼻]',
"[鼓掌]", '[鼓掌]',
"[糗大了]", '[糗大了]',
"[坏笑]", '[坏笑]',
"[左哼哼]", '[左哼哼]',
"[右哼哼]", '[右哼哼]',
"[哈欠]", '[哈欠]',
"[鄙视]", '[鄙视]',
"[委屈]", '[委屈]',
"[快哭了]", '[快哭了]',
"[阴险]", '[阴险]',
"[亲亲]", '[亲亲]',
"[吓]", '[吓]',
"[可怜]", '[可怜]',
"[菜刀]", '[菜刀]',
"[西瓜]", '[西瓜]',
"[啤酒]", '[啤酒]',
"[篮球]", '[篮球]',
"[乒乓]", '[乒乓]',
"[咖啡]", '[咖啡]',
"[饭]", '[饭]',
"[猪头]", '[猪头]',
"[玫瑰]", '[玫瑰]',
"[凋谢]", '[凋谢]',
"[示爱]", '[示爱]',
"[爱心]", '[爱心]',
"[心碎]", '[心碎]',
"[蛋糕]", '[蛋糕]',
"[闪电]", '[闪电]',
"[炸弹]", '[炸弹]',
"[刀]", '[刀]',
"[足球]", '[足球]',
"[瓢虫]", '[瓢虫]',
"[便便]", '[便便]',
"[月亮]", '[月亮]',
"[太阳]", '[太阳]',
"[礼物]", '[礼物]',
"[拥抱]", '[拥抱]',
"[强]", '[强]',
"[弱]", '[弱]',
"[握手]", '[握手]',
"[胜利]", '[胜利]',
"[抱拳]", '[抱拳]',
"[勾引]", '[勾引]',
"[拳头]", '[拳头]',
"[差劲]", '[差劲]',
"[爱你]", '[爱你]',
"[NO]", '[NO]',
"[OK]", '[OK]',
"[爱情]", '[爱情]',
"[飞吻]", '[飞吻]',
"[跳跳]", '[跳跳]',
"[发抖]", '[发抖]',
"[怄火]", '[怄火]',
"[转圈]", '[转圈]',
"[磕头]", '[磕头]',
"[回头]", '[回头]',
"[跳绳]", '[跳绳]',
"[挥手]", '[挥手]',
"[激动]", '[激动]',
"[街舞]", '[街舞]',
"[献吻]", '[献吻]',
"[左太极]", '[左太极]',
"[右太极]" '[右太极]',
] ]
// 获取微信用户授权登录用户信息
import { wxLogin, getWechatUserInfo, getWxRedirect } from '@/api/common'
import { setToken, removeToken } from '@/utils/auth'
export async function getWechatAuthUserInfo(appId) {
let userinfo = sessionStorage.getItem('userinfo')
//取缓存中的用户信息
if (userinfo) {
try {
userinfo = JSON.parse(userinfo)
} catch (error) {
// alert(error)
}
return userinfo
}
//缓存中没有用户信息,进入授权流程
// let appId = 'wxa57479bcd3f15461'
// let appId = window.lwConfig.WX_APPID // 微信公众号id
// let appId = 'wxa57479bcd3f15461' // 公众号appid
let code = getQueryValue('code') //是否存在code
// let query = param2Obj() //
// let { code, appId, secret } = query
let local = window.location.origin.includes('localhost')
? 'http://h5.linkwechat.cn/test.html'
: window.location.href
if (!code) {
//不存在就打开上面的地址进行授权
let url = ''
if (appId) {
url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${encodeURIComponent(
local
)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
} else {
url = (await getWxRedirect()).data
}
window.location.href = url
// return new Promise(() => { })
// window.location.href =
// `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`;
}
try {
// let { data } = await getUserOpenid({ code, appId, secret })
if (code) {
let { data: dataLogin } = await wxLogin(code)
setToken(dataLogin.access_token)
let { data: dataUser } = await getWechatUserInfo()
removeToken()
sessionStorage.setItem('userinfo', JSON.stringify(dataUser))
return dataUser
}
} catch (error) {
// alert(JSON.stringify(error))
return Promise.reject()
}
}
// stime 开始时间 etime 结束时间 currentTime指定日期
export function compareTime(stime, etime, currentTime) {
let startTime = tranDate(stime)
let endTime = tranDate(etime)
let thisDate = currentTime || new Date()
let time =
thisDate.getFullYear() +
'-' +
(thisDate.getMonth() + 1) +
'-' +
thisDate.getDate() +
' ' +
thisDate.getHours() +
':' +
thisDate.getMinutes()
let nowTime = tranDate(time)
if (nowTime < startTime) {
return 'before'
} else if (nowTime > endTime) {
return 'after'
} else {
return 'middle'
}
}
function tranDate(time) {
return new Date(time.replace(/-/g, '/')).getTime()
}
// 获取本机公网ip
export function getIP() {
return new Promise(function (resolve, reject) {
let script = document.createElement('script')
script.setAttribute('charset', 'utf-8')
script.setAttribute('type', 'text/javascript')
script.setAttribute('src', 'https://pv.sohu.com/cityjson?ie=utf-8')
document.getElementsByTagName('head')[0].appendChild(script)
script.onload = function () {
document.getElementsByTagName('head')[0].removeChild(script)
resolve(returnCitySN['cip'])
}
script.onerror = function () {
document.getElementsByTagName('head')[0].removeChild(script)
reject('')
}
})
}
import { getProCityList } from '@/api/common'
// import { treeToArray } from './common'
// 获取省市区树形数据
export async function getProvinceCityTree() {
let area = window.sessionStorage.getItem('provinceCityTree')
if (area) {
area = JSON.parse(area)
} else {
area = (await getProCityList()).data
window.sessionStorage.setItem('provinceCityTree', JSON.stringify(area))
}
return area
}
<template>
<div>
<el-dialog
v-bind="$attrs"
width="500px"
:close-on-click-modal="false"
:modal-append-to-body="false"
v-on="$listeners"
@open="onOpen"
@close="onClose"
>
<el-row :gutter="15">
<el-form
ref="elForm"
:model="formData"
:rules="rules"
size="medium"
label-width="100px"
>
<el-col :span="24">
<el-form-item label="生成类型" prop="type">
<el-radio-group v-model="formData.type">
<el-radio-button
v-for="(item, index) in typeOptions"
:key="index"
:label="item.value"
:disabled="item.disabled"
>
{{ item.label }}
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="showFileName" label="文件名" prop="fileName">
<el-input v-model="formData.fileName" placeholder="请输入文件名" clearable />
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer">
<el-button @click="close">
取消
</el-button>
<el-button type="primary" @click="handelConfirm">
确定
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
inheritAttrs: false,
props: ['showFileName'],
data() {
return {
formData: {
fileName: undefined,
type: 'file'
},
rules: {
fileName: [{
required: true,
message: '请输入文件名',
trigger: 'blur'
}],
type: [{
required: true,
message: '生成类型不能为空',
trigger: 'change'
}]
},
typeOptions: [{
label: '页面',
value: 'file'
}, {
label: '弹窗',
value: 'dialog'
}]
}
},
computed: {
},
watch: {},
mounted() {},
methods: {
onOpen() {
if (this.showFileName) {
this.formData.fileName = `${+new Date()}.vue`
}
},
onClose() {
},
close(e) {
this.$emit('update:visible', false)
},
handelConfirm() {
this.$refs.elForm.validate(valid => {
if (!valid) return
this.$emit('confirm', { ...this.formData })
this.close()
})
}
}
}
</script>
<script>
import draggable from 'vuedraggable'
import render from './generator/render'
const components = {
itemBtns(h, element, index, parent) {
const { copyItem, deleteItem } = this.$listeners
return [
<span
class='drawing-item-copy ssc'
title='复制'
onClick={(event) => {
copyItem(element, parent)
event.stopPropagation()
}}>
<i class='el-icon-copy-document' />
</span>,
<span
class='drawing-item-delete ssc'
title='删除'
onClick={(event) => {
deleteItem(index, parent)
event.stopPropagation()
}}>
<i class='el-icon-delete' />
</span>,
]
},
}
const layouts = {
colFormItem(h, element, index, parent) {
const { activeItem } = this.$listeners
console.log('element.formId', element.formId)
let className =
this.activeId === element.formId ? 'drawing-item active-from-item' : 'drawing-item'
//只是用顶部样式
this.formConf.labelPosition = 'top'
if (this.formConf.unFocusedComponentBorder) className += ' unfocus-bordered'
return (
<el-col
span={element.span}
class={className}
nativeOnClick={(event) => {
activeItem && activeItem(element)
event.stopPropagation()
}}>
<el-form-item
label-width={element.labelWidth ? `${element.labelWidth}px` : null}
label={element.label}
required={element.required}>
<div class={element.captions ? 'elementCaptions' : ''}>{element.captions}</div>
<div class={element.formCodeId == 4 ? 'flexC' : ''}>
<div class={element.formCodeId == 4 ? 'right10 width200' : ''}>
<div>{element.url}</div>
<div
// 无图片时,占位提示
domPropsInnerHTML={
element.formCodeId == 1 && !element.src
? '<div class="no-image">请在右侧控件设置中添加需要展示的图片</div>'
: ''
}></div>
<div class={element.formCodeId == '1' && !element.src ? 'nullC' : ''}>
<render
key={element.renderKey}
conf={element}
onInput={(event) => {
this.$set(element, 'defaultValue', event)
}}
/>
</div>
</div>
<div class={element.formCodeId == 4 ? 'elementInputNum' : 'nullC'}>
<div class={element.unit ? '' : 'nullC'}>{element.unit}</div>
</div>
</div>
</el-form-item>
{components.itemBtns.apply(this, arguments)}
</el-col>
)
},
rowFormItem(h, element, index, parent) {
const { activeItem } = this.$listeners
const className =
this.activeId === element.formId ? 'drawing-row-item active-from-item' : 'drawing-row-item'
let child = renderChildren.apply(this, arguments)
if (element.type === 'flex') {
child = (
<el-row type={element.type} justify={element.justify} align={element.align}>
{child}
</el-row>
)
}
return (
<el-col span={element.span}>
<el-row
gutter={element.gutter}
class={className}
nativeOnClick={(event) => {
activeItem && activeItem(element)
event.stopPropagation()
}}>
<span class='component-name'>{element.componentName}</span>
<draggable
list={element.children}
animation={340}
group='componentsGroup'
class='drag-wrapper'>
{child}
</draggable>
{components.itemBtns.apply(this, arguments)}
</el-row>
</el-col>
)
},
}
function renderChildren(h, element, index, parent) {
console.log('1')
if (!Array.isArray(element.children)) return null
return element.children.map((el, i) => {
const layout = layouts[el.layout]
if (layout) {
return layout.call(this, h, el, i, element.children)
}
return layoutIsNotFound()
})
}
function layoutIsNotFound() {
throw new Error(`没有与${this.element.layout}匹配的layout`)
}
export default {
components: {
render,
draggable,
},
props: ['element', 'index', 'drawingList', 'activeId', 'formConf'],
render(h) {
const layout = layouts[this.element.layout]
if (layout) {
return layout.call(this, h, this.element, this.index, this.drawingList)
}
return layoutIsNotFound()
},
}
</script>
<style lang="scss" scoped>
$selectedColor: #f6f7ff;
$lighterBlue: #409eff;
.drawing-item {
position: relative;
cursor: move;
&.unfocus-bordered:not(.activeFromItem) > div:first-child {
border: 1px dashed #ccc;
}
.el-form-item {
padding: 12px 10px;
}
}
.drawing-row-item {
position: relative;
cursor: move;
box-sizing: border-box;
border: 1px dashed #ccc;
border-radius: 3px;
padding: 0 2px;
margin-bottom: 15px;
.drawing-row-item {
margin-bottom: 2px;
}
.el-col {
margin-top: 22px;
}
.el-form-item {
margin-bottom: 0;
}
.drag-wrapper {
min-height: 80px;
}
&.active-from-item {
border: 1px dashed $lighterBlue;
}
.component-name {
position: absolute;
top: 0;
left: 0;
font-size: 12px;
color: #bbb;
display: inline-block;
padding: 0 6px;
}
}
.drawing-item,
.drawing-row-item {
&:hover {
& > .el-form-item {
background: $selectedColor;
border-radius: 6px;
}
& > .drawing-item-copy,
& > .drawing-item-delete {
display: initial;
}
}
& > .drawing-item-copy,
& > .drawing-item-delete {
display: none;
position: absolute;
top: -10px;
width: 22px;
height: 22px;
line-height: 22px;
text-align: center;
border-radius: 50%;
font-size: 12px;
border: 1px solid;
cursor: pointer;
z-index: 1;
}
& > .drawing-item-copy {
right: 56px;
border-color: $lighterBlue;
color: $lighterBlue;
background: #fff;
&:hover {
background: $lighterBlue;
color: #fff;
}
}
& > .drawing-item-delete {
right: 24px;
border-color: #f56c6c;
color: #f56c6c;
background: #fff;
&:hover {
background: #f56c6c;
color: #fff;
}
}
}
.active-from-item {
& > .el-form-item {
background: $selectedColor;
border-radius: 6px;
}
& > .drawing-item-copy,
& > .drawing-item-delete {
display: initial;
}
& > .component-name {
color: $lighterBlue;
}
}
::v-deep .no-image {
color: #666;
line-height: 80px;
}
.el-image {
display: block;
}
.nullC {
display: none;
}
.flexC {
display: flex;
}
.width200 {
width: 200px !important;
}
.right10 {
margin-right: 10px;
}
</style>
<template>
<div class="icon-dialog">
<el-dialog
v-bind="$attrs"
width="980px"
:modal-append-to-body="false"
v-on="$listeners"
@open="onOpen"
@close="onClose"
>
<div slot="title">
选择图标
<el-input
v-model="key"
size="mini"
:style="{ width: '260px' }"
placeholder="请输入图标名称"
prefix-icon="el-icon-search"
clearable
/>
</div>
<ul class="icon-ul">
<li
v-for="icon in iconList"
:key="icon"
:class="active === icon ? 'active-item' : ''"
@click="onSelect(icon)"
>
<i :class="icon" />
<div>{{ icon }}</div>
</li>
</ul>
</el-dialog>
</div>
</template>
<script>
import iconList from './generator/icon.json'
const originList = iconList.map((name) => `el-icon-${name}`)
export default {
inheritAttrs: false,
props: ['current'],
data() {
return {
iconList: originList,
active: null,
key: '',
}
},
watch: {
key(val) {
if (val) {
this.iconList = originList.filter((name) => name.indexOf(val) > -1)
} else {
this.iconList = originList
}
},
},
methods: {
onOpen() {
this.active = this.current
this.key = ''
},
onClose() {},
onSelect(icon) {
this.active = icon
this.$emit('select', icon)
this.$emit('update:visible', false)
},
},
}
</script>
<style lang="scss" scoped>
.icon-ul {
margin: 0;
padding: 0;
font-size: 0;
li {
list-style-type: none;
text-align: center;
font-size: 14px;
display: inline-block;
width: 16.66%;
box-sizing: border-box;
height: 108px;
padding: 15px 6px 6px 6px;
cursor: pointer;
overflow: hidden;
&:hover {
background: #f2f2f2;
}
&.active-item {
background: #e1f3fb;
color: #7a6df0;
}
> i {
font-size: 30px;
line-height: 50px;
}
}
}
.icon-dialog {
::v-deep .el-dialog {
border-radius: 8px;
margin-bottom: 0;
margin-top: 4vh !important;
display: flex;
flex-direction: column;
max-height: 92vh;
overflow: hidden;
box-sizing: border-box;
.el-dialog__header {
padding-top: 14px;
}
.el-dialog__body {
margin: 0 20px 20px 20px;
padding: 0;
overflow: auto;
}
}
}
</style>
<template>
<div>
<el-dialog
v-bind="$attrs"
:close-on-click-modal="false"
:modal-append-to-body="false"
v-on="$listeners"
@open="onOpen"
@close="onClose"
>
<el-row :gutter="0">
<el-form
ref="elForm"
:model="formData"
:rules="rules"
size="small"
label-width="100px"
>
<el-col :span="24">
<el-form-item
label="选项名"
prop="label"
>
<el-input
v-model="formData.label"
placeholder="请输入选项名"
clearable
/>
</el-form-item>
</el-col>
<!-- <el-col :span="24">
<el-form-item
label="选项值"
prop="value"
>
<el-input
v-model="formData.value"
placeholder="请输入选项值"
clearable
>
<el-select
slot="append"
v-model="dataType"
:style="{width: '100px'}"
>
<el-option
v-for="(item, index) in dataTypeOptions"
:key="index"
:label="item.label"
:value="item.value"
:disabled="item.disabled"
/>
</el-select>
</el-input>
</el-form-item>
</el-col> -->
</el-form>
</el-row>
<div slot="footer">
<el-button
type="primary"
@click="handelConfirm"
>
确定
</el-button>
<el-button @click="close">
取消
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { isNumberStr } from '@/utils/index'
export default {
components: {},
inheritAttrs: false,
props: [],
data() {
return {
id: 100,
formData: {
label: undefined,
value: undefined
},
rules: {
label: [
{
required: true,
message: '请输入选项名',
trigger: 'blur'
}
],
value: [
{
required: true,
message: '请输入选项值',
trigger: 'blur'
}
]
},
dataType: 'string',
dataTypeOptions: [
{
label: '字符串',
value: 'string'
},
{
label: '数字',
value: 'number'
}
]
}
},
computed: {},
watch: {
// eslint-disable-next-line func-names
// 'formData.value': function (val) {
// this.dataType = isNumberStr(val) ? 'number' : 'string';
// },
'formData.label':function(val){
this.formData.value=this.formData.label
}
},
created() {},
mounted() {},
methods: {
onOpen() {
this.formData = {
label: undefined,
value: undefined
}
},
onClose() {},
close() {
this.$emit('update:visible', false)
},
handelConfirm() {
this.$refs.elForm.validate(valid => {
if (!valid) return
if (this.dataType === 'number') {
this.formData.value = parseFloat(this.formData.value)
}
this.formData.id = this.id++
this.$emit('commit', this.formData)
this.close()
})
}
}
}
</script>
const styles = {
'el-rate': '.el-rate{display: inline-block; vertical-align: text-top;}',
'el-upload': '.el-upload__tip{line-height: 1.2;}'
}
function addCss(cssList, el) {
const css = styles[el.tag]
css && cssList.indexOf(css) === -1 && cssList.push(css)
if (el.children) {
el.children.forEach(el2 => addCss(cssList, el2))
}
}
export function makeUpCss(conf) {
const cssList = []
conf.fields.forEach(el => addCss(cssList, el))
return cssList.join('\n')
}
// 默认表单配置项
export default [
{
formCodeId: 11,
label: '姓名',
//文字说明
captions: '',
tag: 'el-input',
tagIcon: 'input',
layout: 'colFormItem',
placeholder: '请输入你的名字',
defaultValue: undefined,
span: 24,
labelWidth: null,
style: { width: '100%' },
clearable: true,
prepend: '',
append: '',
'prefix-icon': '',
'suffix-icon': '',
maxlength: null,
'show-word-limit': true,
readonly: false,
disabled: false,
required: true,
regList: [],
changeTag: true,
},
{
formCodeId: 5,
layout: 'colFormItem',
tagIcon: 'phone',
label: '手机号',
//文字说明
captions: '',
tag: 'el-input',
placeholder: '请输入手机号',
defaultValue: '',
span: 24,
style: { width: '100%' },
clearable: true,
prepend: '',
append: '',
'prefix-icon': '',
'suffix-icon': '',
maxlength: 11,
'show-word-limit': true,
change: 'change',
readonly: false,
disabled: false,
required: true,
changeTag: true,
regList: [
{
pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
message: '手机号格式错误',
},
],
},
]
["platform-eleme","eleme","delete-solid","delete","s-tools","setting","user-solid","user","phone","phone-outline","more","more-outline","star-on","star-off","s-goods","goods","warning","warning-outline","question","info","remove","circle-plus","success","error","zoom-in","zoom-out","remove-outline","circle-plus-outline","circle-check","circle-close","s-help","help","minus","plus","check","close","picture","picture-outline","picture-outline-round","upload","upload2","download","camera-solid","camera","video-camera-solid","video-camera","message-solid","bell","s-cooperation","s-order","s-platform","s-fold","s-unfold","s-operation","s-promotion","s-home","s-release","s-ticket","s-management","s-open","s-shop","s-marketing","s-flag","s-comment","s-finance","s-claim","s-custom","s-opportunity","s-data","s-check","s-grid","menu","share","d-caret","caret-left","caret-right","caret-bottom","caret-top","bottom-left","bottom-right","back","right","bottom","top","top-left","top-right","arrow-left","arrow-right","arrow-down","arrow-up","d-arrow-left","d-arrow-right","video-pause","video-play","refresh","refresh-right","refresh-left","finished","sort","sort-up","sort-down","rank","loading","view","c-scale-to-original","date","edit","edit-outline","folder","folder-opened","folder-add","folder-remove","folder-delete","folder-checked","tickets","document-remove","document-delete","document-copy","document-checked","document","document-add","printer","paperclip","takeaway-box","search","monitor","attract","mobile","scissors","umbrella","headset","brush","mouse","coordinate","magic-stick","reading","data-line","data-board","pie-chart","data-analysis","collection-tag","film","suitcase","suitcase-1","receiving","collection","files","notebook-1","notebook-2","toilet-paper","office-building","school","table-lamp","house","no-smoking","smoking","shopping-cart-full","shopping-cart-1","shopping-cart-2","shopping-bag-1","shopping-bag-2","sold-out","sell","present","box","bank-card","money","coin","wallet","discount","price-tag","news","guide","male","female","thumb","cpu","link","connection","open","turn-off","set-up","chat-round","chat-line-round","chat-square","chat-dot-round","chat-dot-square","chat-line-square","message","postcard","position","turn-off-microphone","microphone","close-notification","bangzhu","time","odometer","crop","aim","switch-button","full-screen","copy-document","mic","stopwatch","medal-1","medal","trophy","trophy-1","first-aid-kit","discover","place","location","location-outline","location-information","add-location","delete-location","map-location","alarm-clock","timer","watch-1","watch","lock","unlock","key","service","mobile-phone","bicycle","truck","ship","basketball","football","soccer","baseball","wind-power","light-rain","lightning","heavy-rain","sunrise","sunrise-1","sunset","sunny","cloudy","partly-cloudy","cloudy-and-sunny","moon","moon-night","dish","dish-1","food","chicken","fork-spoon","knife-fork","burger","tableware","sugar","dessert","ice-cream","hot-water","water-cup","coffee-cup","cold-drink","goblet","goblet-full","goblet-square","goblet-square-full","refrigerator","grape","watermelon","cherry","apple","pear","orange","coffee","ice-tea","ice-drink","milk-tea","potato-strips","lollipop","ice-cream-square","ice-cream-round"]
\ No newline at end of file \ No newline at end of file
import { isArray } from 'util'
import { exportDefault, titleCase } from '@/utils/index'
import { trigger } from './config'
const units = {
KB: '1024',
MB: '1024 / 1024',
GB: '1024 / 1024 / 1024'
}
let confGlobal
const inheritAttrs = {
file: '',
dialog: 'inheritAttrs: false,'
}
export function makeUpJs(conf, type) {
confGlobal = conf = JSON.parse(JSON.stringify(conf))
const dataList = []
const ruleList = []
const optionsList = []
const propsList = []
const methodList = mixinMethod(type)
const uploadVarList = []
conf.fields.forEach(el => {
buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList)
})
const script = buildexport(
conf,
type,
dataList.join('\n'),
ruleList.join('\n'),
optionsList.join('\n'),
uploadVarList.join('\n'),
propsList.join('\n'),
methodList.join('\n')
)
confGlobal = null
return script
}
function buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList) {
buildData(el, dataList)
buildRules(el, ruleList)
if (el.options && el.options.length) {
buildOptions(el, optionsList)
if (el.dataType === 'dynamic') {
const model = `${el.vModel}Options`
const options = titleCase(model)
buildOptionMethod(`get${options}`, model, methodList)
}
}
if (el.props && el.props.props) {
buildProps(el, propsList)
}
if (el.action && el.tag === 'el-upload') {
uploadVarList.push(
`${el.vModel}Action: '${el.action}',
${el.vModel}fileList: [],`
)
methodList.push(buildBeforeUpload(el))
if (!el['auto-upload']) {
methodList.push(buildSubmitUpload(el))
}
}
if (el.children) {
el.children.forEach(el2 => {
buildAttributes(el2, dataList, ruleList, optionsList, methodList, propsList, uploadVarList)
})
}
}
function mixinMethod(type) {
const list = []; const
minxins = {
file: confGlobal.formBtns ? {
submitForm: `submitForm() {
this.$refs['${confGlobal.formRef}'].validate(valid => {
if(!valid) return
// TODO 提交表单
})
},`,
resetForm: `resetForm() {
this.$refs['${confGlobal.formRef}'].resetFields()
},`
} : null,
dialog: {
onOpen: 'onOpen() {},',
onClose: `onClose() {
this.$refs['${confGlobal.formRef}'].resetFields()
},`,
close: `close() {
this.$emit('update:visible', false)
},`,
handelConfirm: `handelConfirm() {
this.$refs['${confGlobal.formRef}'].validate(valid => {
if(!valid) return
this.close()
})
},`
}
}
const methods = minxins[type]
if (methods) {
Object.keys(methods).forEach(key => {
list.push(methods[key])
})
}
return list
}
function buildData(conf, dataList) {
if (conf.vModel === undefined) return
let defaultValue
if (typeof (conf.defaultValue) === 'string' && !conf.multiple) {
defaultValue = `'${conf.defaultValue}'`
} else {
defaultValue = `${JSON.stringify(conf.defaultValue)}`
}
dataList.push(`${conf.vModel}: ${defaultValue},`)
}
function buildRules(conf, ruleList) {
if (conf.vModel === undefined) return
const rules = []
if (trigger[conf.tag]) {
if (conf.required) {
const type = isArray(conf.defaultValue) ? 'type: \'array\',' : ''
let message = isArray(conf.defaultValue) ? `请至少选择一个${conf.vModel}` : conf.placeholder
if (message === undefined) message = `${conf.label}不能为空`
rules.push(`{ required: true, ${type} message: '${message}', trigger: '${trigger[conf.tag]}' }`)
}
if (conf.regList && isArray(conf.regList)) {
conf.regList.forEach(item => {
if (item.pattern) {
rules.push(`{ pattern: ${eval(item.pattern)}, message: '${item.message}', trigger: '${trigger[conf.tag]}' }`)
}
})
}
ruleList.push(`${conf.vModel}: [${rules.join(',')}],`)
}
}
function buildOptions(conf, optionsList) {
if (conf.vModel === undefined) return
if (conf.dataType === 'dynamic') { conf.options = [] }
const str = `${conf.vModel}Options: ${JSON.stringify(conf.options)},`
optionsList.push(str)
}
function buildProps(conf, propsList) {
if (conf.dataType === 'dynamic') {
conf.valueKey !== 'value' && (conf.props.props.value = conf.valueKey)
conf.labelKey !== 'label' && (conf.props.props.label = conf.labelKey)
conf.childrenKey !== 'children' && (conf.props.props.children = conf.childrenKey)
}
const str = `${conf.vModel}Props: ${JSON.stringify(conf.props.props)},`
propsList.push(str)
}
function buildBeforeUpload(conf) {
const unitNum = units[conf.sizeUnit]; let rightSizeCode = ''; let acceptCode = ''; const
returnList = []
if (conf.fileSize) {
rightSizeCode = `let isRightSize = file.size / ${unitNum} < ${conf.fileSize}
if(!isRightSize){
this.$message.error('文件大小超过 ${conf.fileSize}${conf.sizeUnit}')
}`
returnList.push('isRightSize')
}
if (conf.accept) {
acceptCode = `let isAccept = new RegExp('${conf.accept}').test(file.type)
if(!isAccept){
this.$message.error('应该选择${conf.accept}类型的文件')
}`
returnList.push('isAccept')
}
const str = `${conf.vModel}BeforeUpload(file) {
${rightSizeCode}
${acceptCode}
return ${returnList.join('&&')}
},`
return returnList.length ? str : ''
}
function buildSubmitUpload(conf) {
const str = `submitUpload() {
this.$refs['${conf.vModel}'].submit()
},`
return str
}
function buildOptionMethod(methodName, model, methodList) {
const str = `${methodName}() {
// TODO 发起请求获取数据
this.${model}
},`
methodList.push(str)
}
function buildexport(conf, type, data, rules, selectOptions, uploadVar, props, methods) {
const str = `${exportDefault}{
${inheritAttrs[type]}
components: {},
props: [],
data () {
return {
${conf.formModel}: {
${data}
},
${conf.formRules}: {
${rules}
},
${uploadVar}
${selectOptions}
${props}
}
},
computed: {},
watch: {},
created () {},
mounted () {},
methods: {
${methods}
}
}`
return str
}
import { makeMap } from '@/utils/index'
import { getProvinceCityTree } from '@/utils/index'
// 参考https://github.com/vuejs/vue/blob/v2.6.10/src/platforms/web/server/util.js
const isAttr = makeMap(
'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' +
'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' +
'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' +
'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
'target,title,type,usemap,value,width,wrap'
)
function vModel(self, dataObject, defaultValue) {
console.log('defaultValue111', defaultValue)
console.log('dataObject', dataObject)
console.log('self', self)
if (dataObject.props.formCodeId == 5 || dataObject.props.formCodeId == 625) {
if (defaultValue) {
console.log('(/(^[1-9]d*$)/.test(defaultValue))', /(^[1-9]\d*$)/.test(defaultValue))
if (/(^[1-9]\d*$)/.test(defaultValue)) {
} else {
defaultValue = defaultValue.replace(/[^\d]/g, '')
}
}
}
if (dataObject.props.precision) {
var pointIndex = String(defaultValue).indexOf('.')
if (pointIndex > 0 && defaultValue.length - pointIndex > dataObject.props.precision + 1) {
defaultValue = Number(defaultValue).toFixed(dataObject.props.precision)
}
}
// if(defaultValue>dataObject.attrs.max){
// dataObject.props.value = dataObject.attrs.max
// }else if(defaultValue<dataObject.attrs.min){
// dataObject.props.value = dataObject.attrs.min
// }else{
// dataObject.props.value = defaultValue
// }
console.log('dataObject.props', dataObject.props)
dataObject.props.value = defaultValue
dataObject.on.input = (val) => {
self.$emit('input', val)
}
}
const componentChild = {
'el-input': {
prepend(h, conf, key) {
return <template slot='prepend'>{conf[key]}</template>
},
append(h, conf, key) {
return <template slot='append'>{conf[key]}</template>
},
},
'el-select': {
options(h, conf, key) {
const list = []
conf.options.forEach((item) => {
list.push(
<el-option label={item.label} value={item.value} disabled={item.disabled}></el-option>
)
})
return list
},
},
'el-radio-group': {
options(h, conf, key) {
const list = []
conf.options.forEach((item) => {
if (conf.optionType === 'button')
list.push(<el-radio-button label={item.value}>{item.label}</el-radio-button>)
else
list.push(
<el-radio label={item.value} border={conf.border}>
{item.label}
</el-radio>
)
})
return list
},
},
'el-checkbox-group': {
options(h, conf, key) {
const list = []
conf.options.forEach((item) => {
if (conf.optionType === 'button') {
list.push(<el-checkbox-button label={item.value}>{item.label}</el-checkbox-button>)
} else {
list.push(
<el-checkbox label={item.value} border={conf.border}>
{item.label}
</el-checkbox>
)
}
})
return list
},
},
'el-upload': {
'list-type': (h, conf, key) => {
const list = []
if (conf['list-type'] === 'picture-card') {
list.push(<i class='el-icon-plus'></i>)
} else {
list.push(
<el-button size='small' type='primary' icon='el-icon-upload'>
{conf.buttonText}
</el-button>
)
}
if (conf.showTip) {
list.push(
<div slot='tip' class='el-upload__tip'>
只能上传不超过 {conf.fileSize}
{conf.sizeUnit} 的{conf.accept}文件
</div>
)
}
return list
},
},
}
export default {
render(h) {
const dataObject = {
attrs: {},
props: {},
on: {},
style: {},
}
const confClone = JSON.parse(JSON.stringify(this.conf))
const children = []
const childObjs = componentChild[confClone.tag]
if (childObjs) {
Object.keys(childObjs).forEach((key) => {
const childFunc = childObjs[key]
if (confClone[key]) {
children.push(childFunc(h, confClone, key))
}
})
}
console.log('confClone', confClone.formCodeId)
Object.keys(confClone).forEach((key) => {
const val = confClone[key]
if (confClone.layout != 'rowFormItem') {
vModel(this, dataObject, confClone.defaultValue)
}
if (key === 'style') {
Object.assign(dataObject[key], val)
} else if (!isAttr(key)) {
dataObject.props[key] = val
} else {
dataObject.attrs[key] = val
}
})
// 配置省市区数据首次懒加载
if (confClone.formCodeId == 9) {
dataObject.props.props = {
value: 'id',
label: 'name',
lazy: true,
lazyLoad(node, resolve) {
if (node.level == 0) {
getProvinceCityTree().then((data) => {
resolve(data)
})
} else {
if (node.level == 2) {
node.data.children.forEach((e) => (e.leaf = true))
}
resolve([])
}
},
}
}
return h(this.conf.tag, dataObject, children)
},
props: ['conf'],
}
<template>
<div class="Channels_add_form4_qd">
<div v-show="false" ref="ewmTAddEwm"></div>
<div class="add_form4_qd_ul" style="height: 50px">
<div class="add_form4_qd_li1 add_form4_qd_li">渠道</div>
<div class="add_form4_qd_li22 add_form4_qd_li">二维码</div>
<div class="add_form4_qd_li2 add_form4_qd_li">渠道标识</div>
<div class="add_form4_qd_li3 add_form4_qd_li">操作</div>
</div>
<div class="add_form4_qd_ul" v-for="(item, index) in ChannelsList" :key="index">
<div class="add_form4_qd_li1 add_form4_qd_li">
<div style="display: flex; justify-content: center; :flex ; justify-content: center">
<el-input
style="width: 80%"
type="text"
placeholder="请输入渠道标识"
v-model="ChannelsList[index]"
/>
</div>
</div>
<div class="add_form4_qd_li22 add_form4_qd_li">
<!-- <img style="height:80px;" :src="eImgList[index]" alt=""> -->
<el-popover placement="bottom" trigger="hover" v-if="eImgList[index]">
<el-image slot="reference" :src="eImgList[index]" class="code-image--small"></el-image>
<el-image :src="eImgList[index]" class="code-image"> </el-image>
</el-popover>
</div>
<div class="add_form4_qd_li2 add_form4_qd_li">
{{ baseFormUrl4 + '&dataSource=' }}{{ channelsPathList[index] }}<label for=""></label>
</div>
<div
class="add_form4_qd_li3 add_form4_qd_li"
style="display: flex; align-items: center; justify-content: space-around"
>
<div
style="display: flex; color: #2c8cf0; cursor: pointer; flex: 1; justify-content: center"
type="button"
class="copy-btn"
:data-clipboard-text="baseFormUrl4 + '&dataSource=' + channelsPathList[index]"
>
复制
</div>
<div
@click="btnDownload(index)"
style="color: #2c8cf0; cursor: pointer; flex: 1"
class="copy-btn"
>
下载二维码
</div>
</div>
</div>
</div>
</template>
<script>
import QRCode from 'qrcodejs2'
import { selectInfoToSurvey } from '@/api/drainageCode/smartForms.js'
export default {
props: ['FormIdY'],
data() {
return {
eImgList: [],
formId: '1551375031790080000',
ChannelsList: '',
channelsPathList: '',
baseFormUrl4: '',
}
},
mounted() {
this.clipboard = new this.ClipboardJS('.copy-btn')
this.formId = this.FormIdY
this.selectInfoToSurvey()
},
destroyed() {
this.clipboard.destroy()
},
methods: {
btnDownload(index) {
console.log('this.$refs.qrCodeUrl', this.$refs.ewmTAddEwm.childNodes[index * 2 + 1].src)
this.downloadFile('表单二维码', this.$refs.ewmTAddEwm.childNodes[index * 2 + 1].src)
//创建一个具有指定的命名空间URI和限定名称的元素
// var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
// save_link.href = data;
// save_link.download = filename;
// // 绑定下载事件
// var event = document.createEvent('MouseEvents');
// event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
// save_link.dispatchEvent(event);
},
//base64转blob
base64ToBlob(code) {
let parts = code.split(';base64,')
let contentType = parts[0].split(':')[1]
let raw = window.atob(parts[1])
let rawLength = raw.length
let uInt8Array = new Uint8Array(rawLength)
for (let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i)
}
return new Blob([uInt8Array], { type: contentType })
},
//下载
downloadFile(fileName, content) {
let aLink = document.createElement('a')
let blob = this.base64ToBlob(content) //new Blob([content]);
let evt = document.createEvent('HTMLEvents')
evt.initEvent('click', true, true) //initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
aLink.download = fileName
aLink.href = URL.createObjectURL(blob)
// aLink.dispatchEvent(evt);
aLink.click()
},
//获取详情
selectInfoToSurvey() {
let that = this
if (!this.formId) {
return
}
selectInfoToSurvey(this.formId).then((response) => {
that.baseFormUrl4 = window.lwConfig.DOMAIN + '/#/formsDetail?id=true&formId=' + that.formId
if (response.data.channelsName) {
that.ChannelsList = response.data.channelsName.split(',')
that.channelsPathList = response.data.channelsPath.split(',')
for (let i = 0; i < that.channelsPathList.length; i++) {
//生成各渠道二维码
var childs = this.$refs.ewmTAddEwm.childNodes
for (let q = childs.length - 1; q >= 0; q--) {
this.$refs.ewmTAddEwm.removeChild(childs[q])
}
let rwmNum = 0
for (let w = 0; w < this.ChannelsList.length; w++) {
console.log(
'二维码转换内容',
that.baseFormUrl4 + '&dataSource=' + that.channelsPathList[w]
)
var qrcode = new QRCode(this.$refs.ewmTAddEwm, {
text: that.baseFormUrl4 + '&dataSource=' + that.channelsPathList[w], // 需要转换为二维码的内容
width: 150,
height: 150,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: QRCode.CorrectLevel.H,
})
rwmNum = w
}
setTimeout(function () {
console.log('that.$refs.ewmTAddEwm.childNodes', that.$refs.ewmTAddEwm.childNodes)
console.log('that.ChannelsList', that.ChannelsList)
that.eImgList = []
for (let i = 0; i < that.$refs.ewmTAddEwm.childNodes.length / 2; i++) {
that.eImgList[i] = that.$refs.ewmTAddEwm.childNodes[i * 2 + 1].src
}
}, 500)
}
}
})
},
},
}
</script>
<style lang="scss" scoped>
.code-image {
width: 200px;
height: 200px;
}
.code-image--small {
width: 80px;
height: 80px;
}
.Channels_add_form4_qd {
margin-bottom: 30px;
width: 1000px;
border: 1px solid #e6e6e6;
.add_form4_qd_ul {
box-sizing: border-box;
overflow: hidden;
flex-shrink: 0;
display: flex;
height: 100px;
.add_form4_qd_li {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
border: 1px solid #e6e6e6;
}
.add_form4_qd_li1 {
width: 160px;
}
.add_form4_qd_li2 {
flex: 1;
line-height: initial;
}
.add_form4_qd_li22 {
width: 220px;
}
.add_form4_qd_li3 {
width: 180px;
}
}
}
.add_form4_qd_li {
display: flex;
flex-shrink: 0;
}
</style>
<script>
const chinaJson = require('./jsonData/china.json')
export default {
render: function (createElement) {
return createElement('div', {
attrs: {
id: 'main',
},
style: {
height: '550px',
width: '800px',
margin: 'auto',
},
})
},
watch: {
Datas() {
this.initEchart()
},
},
props: ['Datas'],
data() {
return {
dataList: [
{ name: '南海诸岛' },
{ ename: 'beijing', name: '北京' },
{ ename: 'tianjin', name: '天津' },
{ ename: 'shanghai', name: '上海' },
{ ename: 'chongqing', name: '重庆' },
{ ename: 'hebei', name: '河北' },
{ ename: 'henan', name: '河南' },
{ ename: 'yunnan', name: '云南' },
{ ename: 'liaoning', name: '辽宁' },
{ ename: 'heilongjiang', name: '黑龙江' },
{ ename: 'hunan', name: '湖南' },
{ ename: 'anhui', name: '安徽' },
{ ename: 'shandong', name: '山东' },
{ ename: 'xinjiang', name: '新疆' },
{ ename: 'jiangsu', name: '江苏' },
{ ename: 'zhejiang', name: '浙江' },
{ ename: 'jiangxi', name: '江西' },
{ ename: 'hubei', name: '湖北' },
{ ename: 'guangxi', name: '广西' },
{ ename: 'gansu', name: '甘肃' },
{ ename: 'shanxi', name: '山西' },
{ ename: 'neimenggu', name: '内蒙古' },
{ ename: 'shanxi1', name: '陕西' },
{ ename: 'jilin', name: '吉林' },
{ ename: 'fujian', name: '福建' },
{ ename: 'guizhou', name: '贵州' },
{ ename: 'guangdong', name: '广东' },
{ ename: 'qinghai', name: '青海' },
{ ename: 'xizang', name: '西藏' },
{ ename: 'sichuan', name: '四川' },
{ ename: 'ningxia', name: '宁夏' },
{ ename: 'hainan', name: '海南' },
{ name: '台湾' },
{ ename: 'xianggang', name: '香港' },
{ ename: 'aomen', name: '澳门' },
],
}
},
methods: {
initEchart() {
let that = this
console.log('this.Datas', this.Datas.data)
console.log('this.dataList', this.dataList)
let dataList = this.dataList
let max = 0
for (let i = 0; i < dataList.length; i++) {
for (let q = 0; q < this.Datas.data.length; q++) {
if (this.Datas.data[q].name.substring(0, 2) == dataList[i].name.substring(0, 2)) {
dataList[i].value = this.Datas.data[q].value
console.log(' dataList[i].value', dataList[i].value)
if (dataList[i].value > max) {
max = dataList[i].value
}
break
}
}
}
max = max + 5
const _this = this
var myChart = this.$echarts.init(document.getElementById('main'))
this.$echarts.registerMap('china', chinaJson)
var option = {
tooltip: {
//数据格式化
formatter: function (params, callback) {
return params.seriesName + '<br />' + params.name + ':' + params.value
},
},
visualMap: {
min: 0,
max: max,
left: 'left',
top: 'bottom',
inRange: {
color: ['#e0ffff', 'blue'], //取值范围的颜色
},
show: true, //图注
},
geo: {
map: 'china', //引入地图数据
roam: false, //不开启缩放和平移
zoom: 1, //视角缩放比例
label: {
normal: {
show: true,
fontSize: '10',
color: 'rgba(0,0,0,0.7)',
},
},
itemStyle: {
normal: {
borderColor: 'rgba(0, 0, 0, 0.2)',
},
emphasis: {
//高亮的显示设置
areaColor: 'skyblue', //鼠标选择区域颜色
shadowOffsetX: 0,
shadowOffsetY: 0,
shadowBlur: 20,
borderWidth: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
},
},
// 鼠标悬浮提示框
series: [
{
name: '省份',
type: 'map',
geoIndex: 0,
data: this.dataList,
},
],
}
myChart.setOption(option)
myChart.on('click', function (params) {
if (!params.data.ename) {
alert('暂无' + params.name + '地图数据')
return
}
that.$emit('Fparams', params)
// _this.$router.push({
// path: "/province",
// query: { provinceName: params.data.ename, province: params.name },
// });
})
},
},
mounted() {
this.initEchart()
},
}
</script>
<template>
<div>
<!-- <div @click="goBack()">返回</div> -->
<div :id="id" class="provinceCharts"></div>
</div>
</template>
<script>
import { areaStatistic } from '@/api/drainageCode/smartForms.js'
export default {
name: 'province',
props: ['params'],
data() {
return {
baseListMap: '',
id: 'echarts_' + new Date().getTime() + Math.floor(Math.random() * 1000),
echartObj: null,
option: {
title: {
text: '',
top: '8%',
left: '8%',
textStyle: {
fontSize: 14,
fontWeight: 300,
color: '#000',
},
},
tooltip: {
padding: 0,
// 数据格式化
formatter: function (params, callback) {
return params.name + ':' + (params.value || 0)
},
},
legend: {
orient: 'vertical',
top: '9%',
left: '5%',
icon: 'circle',
data: [],
selectedMode: 'single',
selected: {},
itemWidth: 12,
itemHeight: 12,
itemGap: 30,
inactiveColor: '#b6d7ff',
textStyle: {
color: '#ec808d',
fontSize: 14,
fontWeight: 300,
padding: [0, 0, 0, 15],
},
},
visualMap: {
min: 0,
max: 500,
left: 'left',
top: 'bottom',
text: ['高', '低'], // 取值范围的文字
inRange: {
color: ['#e0ffff', 'blue'], // 取值范围的颜色
},
show: true, // 图注
},
geo: {
map: '',
roam: false, // 不开启缩放和平移
zoom: 0.6, // 视角缩放比例
label: {
normal: {
show: true,
fontSize: 10,
color: '#000',
},
emphasis: {
show: true,
color: 'blue',
},
},
itemStyle: {
normal: {
borderColor: 'rgba(0, 0, 0, 0.2)',
},
emphasis: {
areaColor: 'skyblue', // 鼠标选择区域颜色
shadowOffsetX: 0,
shadowOffsetY: 0,
shadowBlur: 20,
borderWidth: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
},
left: '5%',
right: '5%',
top: '5%',
bottom: '5%',
},
series: [
{
name: '省份数据',
type: 'map',
geoIndex: 0, // 不可缺少,否则无tooltip 指示效果
data: [],
},
],
provinceJSON: {},
provinceName: '',
},
}
},
mounted() {
this.init()
// this.initDate();
this.resizeListener()
},
methods: {
init() {
this.areaStatisticF()
},
// 地图
areaStatisticF() {
let that = this
let data = {
formId: this.params.formId,
areaType: 2,
parentCode: this.params.parentCode,
}
areaStatistic(data).then((res) => {
console.log('地图统计图返回值', res)
that.baseListMap = res.data
that.option.series[0].data = that.baseListMap[0].data
let max = 0
for (let i = 0; i < that.baseListMap[0].data.length; i++) {
if (that.baseListMap[0].data[i].value > max) {
max = that.baseListMap[0].data[i].value
}
}
max = max + 5
that.option.visualMap.max = max
console.log('that.option', that.option)
that.$forceUpdate()
that.initDate()
// that.baseList= res.data;
})
},
initDate() {
console.log('this.params', this.params)
const provinceName = this.params.ename
const province = this.params.name
this.provinceName = provinceName
this.provinceJSON = require('./jsonData/' + provinceName)
this.option.title.text = province
this.option.geo.map = province
this.echartObj = this.$echarts.init(document.getElementById(this.id))
this.$echarts.registerMap(province, this.provinceJSON)
this.echartObj.setOption(this.option)
// this.echartObj.on("click", (params) => {
// this.$router.push({
// path: "/city",
// query: { city: params.name },
// });
// });
},
resizeListener() {
window.addEventListener('resize', () => {
if (this.echartObj && this.echartObj.resize) {
this.echartObj.resize()
}
})
},
goBack() {
this.$router.go(-1)
},
},
}
</script>
<style lang="scss">
.provinceCharts {
height: 400px;
width: 600px;
margin: auto;
}
</style>
<script>
import * as echarts from 'echarts'
import { echartColors } from '@/utils/index'
import merge from 'lodash.merge'
export default {
// 折线图
name: 'ChartLine',
components: {},
props: {
Data: {
type: Object,
default: null,
},
series: {
type: Array,
default: () => [120, 132, 101, 134, 90, 230, 210],
},
// 自定义图表配置项,使用loadsh.merge(origin, option)和原有的配置进行覆盖合并
// loadsh.merge: https://www.html.cn/doc/lodash/#_mergeobject-sources
option: {
type: Object,
default: null,
},
},
data() {
return {}
},
computed: {},
watch: {
series() {
this.$nextTick(() => {
this.drawChart()
})
},
},
created() {},
mounted() {
this.drawChart()
},
methods: {
drawChart() {
console.log('this.Data', this.Data)
this.myChart = echarts.init(this.$refs.chart)
let option
let series = []
let dateLe = []
// for(let i=0;this.Data.data.length;i++){
// }
option = {
legend: [
{
data: this.Data.optionss,
x: 'center',
y: 'bottom',
},
],
tooltip: {
trigger: 'item',
},
series: [
{
type: 'pie',
radius: '50%',
data: this.Data.data,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
normal: {
label: {
show: true,
formatter: '{d}%',
},
labelLine: { show: true },
},
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
},
},
],
}
this.option && merge(option, this.option)
option && this.myChart.setOption(option)
new ResizeObserver((entries) => {
this.myChart.resize()
}).observe(this.$refs.chart)
},
},
}
</script>
<template>
<div v-if="series && series.length" ref="chart" class="chart-line chart" key="1"></div>
<div v-else class="chart-line chart" key="2"><div class="cc">暂无数据</div></div>
</template>
<style lang="scss" scoped>
.chart {
position: relative;
height: 100%;
min-width: 400px;
min-height: 400px;
}
</style>
<template>
<div class="search">
<div class="item">
<el-button-group>
<el-button size="mini" @click="setType(1)" :type="active === 1 ? 'primary' : ''"
>近一周</el-button
>
<el-button size="mini" @click="setType(2)" :type="active === 2 ? 'primary' : ''"
>近一月</el-button
>
<el-button size="mini" @click="setType(3)" :type="active === 3 ? 'primary' : ''"
>自定义</el-button
>
</el-button-group>
</div>
<div class="item" v-if="active === 3">
<el-date-picker
style="width: 250px"
@change="setTime"
size="mini"
clearable
v-model="value"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
</div>
<div class="item" v-if="showScene">
<!-- <el-select size="mini" v-model="data." placeholder="请选择场景" clearable>
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select> -->
<el-select size="mini" @change="submit()" v-model="data.dataSource" placeholder="请选择渠道">
<el-option
v-for="(item, index) in sceneList.channelsName"
:key="index"
:value="item"
:label="item"
></el-option>
</el-select>
</div>
<!-- <div class="item" v-if="showMember">
<el-select size="mini" v-model="data.openKfIds" @change="setMemeber" clearable placeholder="请选择客服">
<el-option value="" label="全部客服"></el-option>
<el-option v-for="(data, index) in customerList" :key="index" :value="data.openKfId" :label="data.name"></el-option>
</el-select>
</div>
<div class="item" v-if="showMember">
<el-select size="mini" v-model="data.userIds" @change="selectMember" clearable placeholder="请选择接待员工">
<el-option value="" label="全部员工"></el-option>
<el-option v-for="item in manList" :key="item.value" :label="item.userName" :value="item.userId">
</el-option>
</el-select>
</div> -->
</div>
</template>
<script>
import moment from 'moment'
// import { getList } from '@/api/drainageCode/customerService.js'
import { selectInfoToSurvey } from '@/api/drainageCode/smartForms.js'
export default {
name: 'search-title',
props: {
showScene: {
type: Boolean,
default: false,
},
showMember: {
type: Boolean,
default: false,
},
id: {
type: String,
default: '',
},
},
data() {
return {
active: 1,
value: [],
options: [{ value: 10, label: '1123' }],
value2: [],
data: {
startDate: '',
endDate: '',
},
sceneList: [],
customerList: [],
manList: [],
}
},
methods: {
setMemeber(e) {
if (e) {
this.data.userIds = ''
this.customerList.forEach((dd) => {
if (dd.openKfId === e) {
this.manList = dd.userIdList
}
})
} else {
this.manList = []
this.data.userIds = ''
}
this.submit()
},
selectMember(e) {
this.submit()
},
submit() {
this.$emit('search', this.data)
this.$forceUpdate()
},
setTime(e) {
if (e) {
this.data.startDate = moment(e[0]).format('YYYY-MM-DD')
this.data.endDate = moment(e[1]).format('YYYY-MM-DD')
} else {
this.data.startDate = ''
this.data.endDate = ''
}
this.submit()
},
setType(type) {
this.active = type
if (type === 1) {
const weekStart = moment().subtract(6, 'days').format('YYYY-MM-DD')
const weekEnd = moment().format('YYYY-MM-DD')
this.data.startDate = weekStart
this.data.endDate = weekEnd
this.data.type = 'week'
delete this.data.startDate
delete this.data.endDate
this.submit()
} else if (type === 2) {
this.data.endDate = moment().format('YYYY-MM-DD')
this.data.startDate = moment().subtract(29, 'days').format('YYYY-MM-DD')
this.data.type = 'month'
delete this.data.startDate
delete this.data.endDate
this.submit()
} else if (type == 3) {
this.data.type = 'customization'
}
},
},
created() {
if (this.showScene) {
selectInfoToSurvey(this.id).then((dd) => {
this.sceneList = dd.data || { channelsName: '' }
this.sceneList.channelsName = this.sceneList.channelsName.split(',')
this.data.dataSource = this.sceneList.channelsName[0]
this.$emit('search', this.data)
})
}
// if (this.showMember) {
// getList().then((res) => {
// this.customerList = res.rows
// })
// }
this.setType(1)
},
}
</script>
<style lang="scss" scoped>
.search {
display: flex;
align-items: center;
.item {
margin-right: 20px;
}
}
</style>
{"type":"FeatureCollection","features":[{"id":"820001","geometry":{"type":"Polygon","coordinates":["@@LADC^umZ@DONWEBDCLHBH@DFBBNA"],"encodeOffsets":[[116285,22746]]},"properties":{"cp":[113.5528956,22.20787],"name":"花地瑪堂區","childNum":1}},{"id":"820002","geometry":{"type":"Polygon","coordinates":["@@MK@CA@AAGDEB@NVFHE"],"encodeOffsets":[[116281,22734]]},"properties":{"cp":[113.5489608,22.1992075],"name":"花王堂區","childNum":1}},{"id":"820003","geometry":{"type":"Polygon","coordinates":["@@EGOB@DNLHE@C"],"encodeOffsets":[[116285,22729]]},"properties":{"cp":[113.5501828,22.19372083],"name":"望德堂區","childNum":1}},{"id":"820004","geometry":{"type":"Polygon","coordinates":["@@ŸYIPEL@JFCBBFADHDBBFDHIJJEFDPCHHlY"],"encodeOffsets":[[116313,22707]]},"properties":{"cp":[113.5536475,22.18853944],"name":"大堂區","childNum":1}},{"id":"820005","geometry":{"type":"Polygon","coordinates":["@@JICGAECACGEBAAEDP^"],"encodeOffsets":[[116266,22728]]},"properties":{"cp":[113.5419278,22.18736806],"name":"風順堂區","childNum":1}},{"id":"820006","geometry":{"type":"Polygon","coordinates":["@@ ZNWRquZCBCC@AEA@@ADCDCAACEAGBQ@IN"],"encodeOffsets":[[116265,22694]]},"properties":{"cp":[113.5587044,22.15375944],"name":"嘉模堂區","childNum":1}},{"id":"820007","geometry":{"type":"Polygon","coordinates":["@@MOIAIEI@@GE@AAUCBdCFIFR@HAFBBDDBDCBCDB@BFDDC"],"encodeOffsets":[[116316,22676]]},"properties":{"cp":[113.5695992,22.13663],"name":"路氹填海區","childNum":1}},{"id":"820008","geometry":{"type":"Polygon","coordinates":["@@DKMMa_GC_COD@dVDBBF@@HJ@JFJBNP"],"encodeOffsets":[[116329,22670]]},"properties":{"cp":[113.5599542,22.12348639],"name":"聖方濟各堂區","childNum":1}}],"UTF8Encoding":true}
\ No newline at end of file \ No newline at end of file
<template>
<div style="padding-bottom: 30px">
<div>
<div class="g-card g-pad20">
<div class="data-content">
<div class="search-content">
<search-title
:id="$route.query.id"
:showScene="true"
@search="getTableFn"
></search-title>
<el-button type="primary" size="mini" @click="exportFn" v-loading="exportLoading"
>导出Excel</el-button
>
</div>
<!-- <div v-if="tableList&&tableList.length!=0">
{{tableList[0].answer}}
</div> -->
<div v-if="tableList" class="table-content">
<el-table v-loading="loading1" :data="tableList" style="width: 100%">
<!-- <el-table-column label="日期" align="center" min-width="100" show-overflow-tooltip >
<template slot-scope="{ row }">
<div style="display: flex;justify-content:center;">{{row.updateTime.substring(0,10)}}</div>
</template>
</el-table-column> -->
<el-table-column label="序号" width="50" align="center">
<template slot-scope="scope">
{{ scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column label="日期" align="center" min-width="100" show-overflow-tooltip>
<template slot-scope="{ row }">
{{ row.createTime }}
</template>
</el-table-column>
<el-table-column
label="用户姓名"
align="center"
min-width="100"
show-overflow-tooltip
>
<template slot-scope="{ row }">
{{ row.name }}
</template>
</el-table-column>
<el-table-column label="渠道" align="center" min-width="100" show-overflow-tooltip>
<template slot-scope="{ row }">
{{ dataSource }}
</template>
</el-table-column>
<el-table-column
label="用户手机号"
align="center"
min-width="100"
show-overflow-tooltip
>
<template slot-scope="{ row }">
{{ row.mobile }}
</template>
</el-table-column>
<el-table-column label="openId" align="center" min-width="100" show-overflow-tooltip>
<template slot-scope="{ row }">
<div v-if="row.openId">{{ row.openId }}</div>
<div v-if="!row.openId">无</div>
</template>
</el-table-column>
<el-table-column label="unionId" align="center" min-width="100" show-overflow-tooltip>
<template slot-scope="{ row }">
<div v-if="row.unionId">{{ row.unionId }}</div>
<div v-if="!row.unionId">无</div>
</template>
</el-table-column>
<el-table-column
label="是否是企业用户"
align="center"
min-width="100"
show-overflow-tooltip
>
<template slot-scope="{ row }">
<div v-if="row.isOfficeCustomer">是</div>
<div v-if="!row.isOfficeCustomer">否</div>
</template>
</el-table-column>
<!-- <el-table-column label="总访问数" align="center" min-width="100" prop="visitTotalCnt" show-overflow-tooltip />
<el-table-column label="总访问用户" align="center" prop="consultTotalCnt" min-width="100" show-overflow-tooltip></el-table-column>
<el-table-column label="有效收集量" align="center" prop="EffectiveCollectionQuantity" min-width="100" show-overflow-tooltip></el-table-column>
<el-table-column label="收集量" align="center" prop="CollectionQuantity" min-width="100" show-overflow-tooltip></el-table-column>
<el-table-column label="平均完成时间" align="center" prop="average" min-width="100" show-overflow-tooltip></el-table-column> -->
</el-table>
<div class="bottom">
<pagination
:total="total"
:page.sync="query.pageNum"
:limit.sync="query.pageSize"
@pagination="getTableChangeSize(query.pageNum, query.pageSize)"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { statisticsCustomer, userExport } from '@/api/drainageCode/smartForms.js'
import SearchTitle from '../components/SearchTitle.vue'
export default {
props: ['formId'],
components: {
SearchTitle,
},
data() {
return {
loading1: false,
total: 0,
baseList: '',
query: {
pageSize: 10,
pageNum: 1,
},
tableList: [],
exportLoading: false,
dataSource: '默认渠道',
}
},
methods: {
exportFn() {
let that = this
this.$confirm('确认导出吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
this.exportLoading = true
let data = this.tableSearch
console.log('data', data)
if (!data.dataSource) {
return
}
data.belongId = this.$route.query.id
userExport(data)
.then((res) => {
console.log('数据报表导出返回值', res)
this.download(res.data)
})
.catch((error) => {
console.error(error)
})
.finally(() => {
that.exportLoading = false
})
// delete data.pageNum
// delete data.pageSize
// that.dataSource = data.dataSource
// statisticsCustomer(data).then((res) => {
// console.log('用户统计数据返回值', res)
// let b = []
// if (res.data && res.data.length) {
// that.tableList = []
// for (let i = 0; i < res.data.length; i++) {
// b.push(res.data[i].data)
// console.log('b', b)
// }
// that.tableList = b
// that.total = Number(res.data[0].total)
// } else {
// that.tableList = []
// }
// console.log('that.tableList', that.tableList)
// // this.tableList = res.data.xAxis.data.length
// that.loading1 = false
// let data = []
// for (let i = 0; i < that.tableList.length; i++) {
// let isOfficeCustomer = '否'
// if (that.tableList[i].isOfficeCustomer) {
// isOfficeCustomer = '是'
// }
// let a = {
// createTime: that.tableList[i].createTime,
// dataSource: that.dataSource,
// isOfficeCustomer: isOfficeCustomer,
// mobile: that.tableList[i].mobile,
// unionId: that.tableList[i].unionId,
// openId: that.tableList[i].openId,
// }
// data.push(a)
// }
// console.log('that.tableList', that.tableList)
// console.log('data', JSON.stringify(data))
// userExport(data)
// .then((res) => {
// console.log('数据报表导出返回值', res)
// download(res.msg)
// })
// .catch((error) => {
// console.error(error)
// })
// .finally(() => {
// that.exportLoading = false
// })
// })
})
},
getTableChangeSize(a, b) {
console.log('a', a, b)
let that = this
this.loading1 = true
let data = this.tableSearch
console.log('data', data)
if (!data.dataSource) {
that.loading1 = false
return
}
data.pageNum = a
data.pageSize = b
that.dataSource = data.dataSource
statisticsCustomer(data).then((res) => {
console.log('用户统计数据返回值', res)
let b = []
if (res.data && res.data.length) {
that.tableList = []
for (let i = 0; i < res.data.length; i++) {
b.push(res.data[i].data)
console.log('b', b)
}
that.tableList = b
that.total = Number(res.data[0].total)
} else {
that.tableList = []
}
console.log('that.tableList', that.tableList)
// this.tableList = res.data.xAxis.data.length
that.loading1 = false
})
},
getTableFn(data) {
let that = this
this.loading1 = true
data.belongId = this.$route.query.id
// getTableTotal(Object.assign({}, this.query, data)).then(res => {
// this.tableList = res.rows
// this.total = Number(res.total)
// this.loading = false
// })
if (!data.dataSource) {
that.loading1 = false
return
}
this.tableSearch = data
that.dataSource = data.dataSource
that.getTableChangeSize(1, 10)
},
},
mounted() {},
}
</script>
<style lang="scss" scoped>
.dataStatistics_optionGraph_ul {
margin-top: 30px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.dataStatistics_optionGraph_li {
margin-bottom: 10px;
width: 49.6%;
background-color: #fff;
padding: 30px;
}
}
.data-content {
margin-top: 10px;
.chart-content {
margin-top: 10px;
.my_button {
float: right;
}
.column {
display: flex;
.column-item {
flex: 1;
}
}
}
.search-content {
display: flex;
justify-content: space-between;
}
.table-content {
margin-top: 10px;
}
}
</style>
<template>
<div>
<div class="overview_header">
<div class="overView_header_left">
<div style="display: flex; align-items: center">
<div>ID: {{ baseList.id }}</div>
<div class="surveyState">
<div v-if="baseList.surveyState == 0">未发布</div>
<div v-if="baseList.surveyState == 1">收集中</div>
<div v-if="baseList.surveyState == 2">已暂停</div>
<div v-if="baseList.surveyState == 3">已结束</div>
<div v-if="baseList.surveyState == 4">未收集</div>
</div>
</div>
<div style="font-size: 16px; font-weight: 700; margin-top: 10px">
{{ baseList.surveyName }}
</div>
</div>
<div class="overView_header_right">
<div>
开始时间:<span v-if="baseList.timingStart">{{ baseList.timingStart }}</span
><span v-if="!baseList.timingStart">不限</span>
</div>
<div style="margin-top: 10px">
结束时间:<span v-if="baseList.timingEnd">{{ baseList.timingEnd }}</span
><span v-if="!baseList.timingEnd">不限</span>
</div>
</div>
</div>
<el-tabs v-model="activeName">
<el-tab-pane label="统计概览" name="first">
<Overview v-if="activeName === 'first'" />
</el-tab-pane>
<el-tab-pane label="数据统计" name="second">
<DataStatistics :formId="baseList.id" v-if="activeName === 'second'" />
</el-tab-pane>
<el-tab-pane label="用户统计" name="three" show-overflow-tooltip>
<span slot="label">
用户统计
<el-popover width="250" trigger="hover" placement="top-start">
<p>暂时仅支持微信用户</p>
<i slot="reference" class="el-icon-question" style="color: black"></i>
</el-popover>
</span>
<UserStatistics :formId="baseList.id" v-if="activeName === 'three'" />
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { selectInfoToSurvey } from '@/api/drainageCode/smartForms.js'
import Overview from './Overview.vue'
import DataStatistics from './DataStatistics.vue'
import UserStatistics from './UserStatistics.vue'
// import Search from "./search.vue"
export default {
// name: 'customer-service-statistics',
components: {
Overview,
DataStatistics,
UserStatistics,
},
data() {
return {
baseList: {},
activeName: 'first',
}
},
methods: {
selectInfoToSurvey() {
selectInfoToSurvey(this.$route.query.id).then((res) => {
this.baseList = res.data || {}
})
},
},
created() {
this.selectInfoToSurvey()
// this.$store.dispatch(
// 'app/setBusininessDesc',
// `
// <div>渠道场景与客服维度相关数据统计与分析</div>
// `
// )
},
}
</script>
<style lang="scss" scoped>
.overview_header {
margin-bottom: 10px;
display: flex;
justify-content: space-between;
width: 100%;
border-radius: 5px;
background-color: #fff;
padding: 20px;
box-sizing: border-box;
}
.surveyState {
margin-left: 30px;
padding: 5px 10px;
border-radius: 5px;
background-color: #f1f1f1;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!