Commit 5e601931 by xinla

Merge branch 'develop'

2 parents 25fd8d2b 202fcf19
import request from '@/utils/request'
const service = window.CONFIG.services.system + window.CONFIG.services.wecom + '/agent'
const serviceMsg = service + '/msg'
// 应用管理
/**
* 列表
* @param {*} params
*/
export function getList() {
return request({
url: service + '/list',
})
}
/**
* 删除
* @param {*} params
*/
export function remove(id) {
return request({
url: service + `/delete/${id}`,
method: 'delete',
})
}
/**
* 添加应用
* @param {*} data
{
"agentId": "应用ID",
"secret": "应用密钥"
}
* @returns
*/
export function add(data) {
return request({
url: service + '/pull',
method: 'post',
data,
})
}
/**
* 编辑应用信息
* @param {*} data
{
description:'', // string 企业应用详情
homeUrl:'', // string 应用主页url
logoUrl:'', // string 企业应用头像
name:'', // string 企业应用名称
redirectDomain:'', // string 企业应用可信域名
}
* @returns
*/
export function update(data) {
return request({
url: service + `/update/${data.id}`,
method: 'PUT',
data,
})
}
// 应用消息
export const appMsg = {
/**
* 获取历史消息列表
* @param {*} params
{
endTime:'', // string date-time 发送结束时间
startTime:'', // string date-time 发送开始时间
status:'',// integer int32状态
title:'', // string 标题
}
*/
getList(params) {
return request({
url: service + '/list',
params,
})
},
/**
* 应用消息详情
* @param {*} id
*/
getDetail(id) {
return request({
url: service + `/get/${id}`,
})
},
/**
* 撤销应用消息
* @param {*} id
*/
revoke(id) {
return request({
url: service + `/revoke/${id}`,
})
},
/**
* 新增应用消息
* @param {*} data
{
agentId:'', // integer int32 应用ID
planSendTime: '', // string date-time 计划时间
scopeType:'', // integer int32 范围类型 1-全部 2-自定义
sendTime: '', // string date-time 发送时间
sendType:'', // integer int32 发送方式 1-立即发送 2-定时发送
title: '', // string 消息标题
toParty: '', // string 示例值 接收消息的部门
toTag: '', // string 示例值 接收消息的标签
toUser: '', // string 示例值 接收消息的成员
WeMessageTemplate:{
appId: '', // string 小程序appid(可以在微信公众平台上查询),必须是关联到企业的小程序应用
content: '', // string 文本内容(文本消息必传)
description: '', // string 消息的描述(视频、文本卡片、图文 必传)
linkUrl: '', // string 点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https) (文本卡片、图文 必传)
mediaId: '', // string 素材id(语音、视频、文件 必传)
msgType: '', // string 消息类型 文本:text, 图片:image, 语音:voice, 视频:video, 文件:file, 文本卡片:textcard, 图文:news, 图文消息:link, 小程序:miniprogram
picUrl: '', // string 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150。(文本卡片、图文 必传)
title: '', // string 消息的标题(视频、文本卡片、图文 必传)
}
}
*/
add(data) {
return request({
url: serviceMsg + '/add',
method: 'post',
data,
})
},
// 保存应用消息 data同上
save(data) {
return request({
url: serviceMsg + '/save',
method: 'post',
data,
})
},
// 修改应用消息 data同上
update(data) {
return request({
url: service + `/update/${data.id}`,
method: 'PUT',
data,
})
},
/**
* 删除
* @param {*} id
*/
remove(id) {
return request({
url: service + `/delete/${id}`,
method: 'delete',
})
},
}
...@@ -32,44 +32,25 @@ import visitor from '@/layout/visitor' ...@@ -32,44 +32,25 @@ import visitor from '@/layout/visitor'
// 开发路由,总后台配置完菜单务必删除或注释,只在开发环境生效 // 开发路由,总后台配置完菜单务必删除或注释,只在开发环境生效
const devRoutes = [ const devRoutes = [
// { {
// path: '/smartForms', path: '/internalCollaborate',
// component: Layout, component: Layout,
// hidden: true, hidden: true,
// meta: { meta: {
// title: '商品中心', title: '应用管理',
// }, },
// children: [ children: [
// { {
// path: 'list', path: 'list',
// component: (resolve) => require(['@/views/drainageCode/smartForms/index'], resolve), component: (resolve) => require(['@/views/internalCollaborate/appManage'], resolve),
// meta: { meta: {
// title: '商品管理', title: '',
// activeMenu: '/commodityCenter/commodityManage', activeMenu: '/commodityCenter/commodityManage',
// breadcrumb: true, 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,
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* 通用js方法封装处理,挂载到 Vue.prototype * 通用js方法封装处理,挂载到 Vue.prototype
*/ */
const baseURL = window.lwConfig.BASE_API const baseURL = window.lwConfig.BASE_API
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import axios from 'axios' import axios from 'axios'
// 日期格式化 // 日期格式化
export function parseTime(time, pattern) { export function parseTime(time, pattern) {
if (arguments.length === 0 || !time) { if (arguments.length === 0 || !time) {
return null return null
} }
...@@ -47,17 +47,17 @@ ...@@ -47,17 +47,17 @@
return value || 0 return value || 0
}) })
return time_str return time_str
} }
// 表单重置 // 表单重置
export function resetForm(refName) { export function resetForm(refName) {
if (this.$refs[refName]) { if (this.$refs[refName]) {
this.$refs[refName].resetFields() this.$refs[refName].resetFields()
} }
} }
// 添加日期范围 // 添加日期范围
export function addDateRange(params, dateRange) { export function addDateRange(params, dateRange) {
var search = params var search = params
search.beginTime = '' search.beginTime = ''
search.endTime = '' search.endTime = ''
...@@ -66,10 +66,10 @@ ...@@ -66,10 +66,10 @@
search.endTime = this.dateRange[1] search.endTime = this.dateRange[1]
} }
return search return search
} }
// 回显数据字典 // 回显数据字典
export function selectDictLabel(datas, value) { export function selectDictLabel(datas, value) {
var actions = [] var actions = []
Object.keys(datas).some((key) => { Object.keys(datas).some((key) => {
if (datas[key].dictValue == '' + value) { if (datas[key].dictValue == '' + value) {
...@@ -78,10 +78,10 @@ ...@@ -78,10 +78,10 @@
} }
}) })
return actions.join('') return actions.join('')
} }
// 回显数据字典(字符串数组) // 回显数据字典(字符串数组)
export function selectDictLabels(datas, value, separator) { export function selectDictLabels(datas, value, separator) {
var actions = [] var actions = []
var currentSeparator = undefined === separator ? ',' : separator var currentSeparator = undefined === separator ? ',' : separator
var temp = value.split(currentSeparator) var temp = value.split(currentSeparator)
...@@ -93,10 +93,10 @@ ...@@ -93,10 +93,10 @@
}) })
}) })
return actions.join('').substring(0, actions.join('').length - 1) return actions.join('').substring(0, actions.join('').length - 1)
} }
// 通用下载方法 系统内部 // 通用下载方法 系统内部
export function download(fileName) { export function download(fileName) {
axios({ axios({
method: 'GET', method: 'GET',
url: baseURL + '/common/download?fileName=' + encodeURI(fileName) + '&delete=' + true, url: baseURL + '/common/download?fileName=' + encodeURI(fileName) + '&delete=' + true,
...@@ -117,10 +117,10 @@ ...@@ -117,10 +117,10 @@
dom.parentNode.removeChild(dom) dom.parentNode.removeChild(dom)
window.URL.revokeObjectURL(url) window.URL.revokeObjectURL(url)
}) })
} }
// 通用下载方法 网络文件路径 // 通用下载方法 网络文件路径
export function downloadNet(url, fileName) { export function downloadNet(url, fileName) {
axios({ axios({
method: 'GET', method: 'GET',
url: baseURL + '/common/download/url?url=' + url, url: baseURL + '/common/download/url?url=' + url,
...@@ -141,10 +141,10 @@ ...@@ -141,10 +141,10 @@
dom.parentNode.removeChild(dom) dom.parentNode.removeChild(dom)
window.URL.revokeObjectURL(url) window.URL.revokeObjectURL(url)
}) })
} }
// 字符串格式化(%s ) // 字符串格式化(%s )
export function sprintf(str) { export function sprintf(str) {
var args = arguments, var args = arguments,
flag = true, flag = true,
i = 1 i = 1
...@@ -157,24 +157,24 @@ ...@@ -157,24 +157,24 @@
return arg return arg
}) })
return flag ? str : '' return flag ? str : ''
} }
// 转换字符串,undefined,null等转化为"" // 转换字符串,undefined,null等转化为""
export function praseStrEmpty(str) { export function praseStrEmpty(str) {
if (!str || str == 'undefined' || str == 'null') { if (!str || str == 'undefined' || str == 'null') {
return '' return ''
} }
return str return str
} }
/** /**
* 数组构造树型结构数据 * 数组构造树型结构数据
* @param {Array} data 数据源 * @param {Array} data 数据源
* @param {*} id id字段 默认 'id' * @param {*} id id字段 默认 'id'
* @param {*} parentId 父节点字段 默认 'parentId' * @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children' * @param {*} children 孩子节点字段 默认 'children'
*/ */
export function handleTree(data, id, parentId, children) { export function handleTree(data, id, parentId, children) {
id = id || 'id' id = id || 'id'
parentId = parentId || 'parentId' parentId = parentId || 'parentId'
children = children || 'children' children = children || 'children'
...@@ -200,19 +200,21 @@ ...@@ -200,19 +200,21 @@
} }
}) })
return result return result
} }
/** /**
* 树转数组 * 树转数组
* @param {*} tree * @param {*} tree
* @param {*} children 孩子节点字段 默认 'children' * @param {*} children 孩子节点字段 默认 'children'
* @param {Function} callback 回调函数 * @param {Function} callback 回调函数
* @returns {Array} * @returns {Array}
*/ */
export function treeToArray(tree = [], children = 'children', callback) { export function treeToArray(tree = [], children = 'children', callback) {
let result = [] let result = []
let level = 0
function dg(obj) { function dg(obj) {
callback && callback(obj, result) callback && callback(obj, result, level)
++level
if (obj[children]) { if (obj[children]) {
result.push(...obj[children]) result.push(...obj[children])
obj[children].forEach((e) => { obj[children].forEach((e) => {
...@@ -220,6 +222,7 @@ ...@@ -220,6 +222,7 @@
}) })
// delete obj.children // delete obj.children
} }
--level
} }
if (Array.isArray(tree)) { if (Array.isArray(tree)) {
result.push(...tree) result.push(...tree)
...@@ -229,13 +232,13 @@ ...@@ -229,13 +232,13 @@
dg(tree) dg(tree)
} }
return result return result
} }
/** /**
* dataURL转化为File对象 * dataURL转化为File对象
* @param {*} dataURL 本地数据 base64 * @param {*} dataURL 本地数据 base64
*/ */
export function dataURLtoFile(dataURL) { export function dataURLtoFile(dataURL) {
const arr = dataURL.split(',') const arr = dataURL.split(',')
const mime = arr[0].match(/:(.*?);/)[1] const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1]) const bstr = atob(arr[1])
...@@ -246,10 +249,10 @@ ...@@ -246,10 +249,10 @@
n -= 1 // to make eslint happy n -= 1 // to make eslint happy
} }
return new File([u8arr], '', { type: mime }) return new File([u8arr], '', { type: mime })
} }
// FormData 格式转化 // FormData 格式转化
export function toFormData(val) { export function toFormData(val) {
let formData = new FormData() let formData = new FormData()
for (let i in val) { for (let i in val) {
isArray(val[i], i) isArray(val[i], i)
...@@ -281,5 +284,4 @@ ...@@ -281,5 +284,4 @@
} }
} }
return formData return formData
}
\ No newline at end of file \ No newline at end of file
}
<script>
import { getList, update, add, remove } from '@/api/internalCollaborate/appManage'
// import clipboard from "clipboard";
export default {
components: {},
props: {},
data() {
return {
query: {
// pageNum: 1,
// pageSize: 10,
// name: '',
},
// dateRange: [], // 添加日期
// total: 0,
form: {},
list: [],
dialogVisible: false,
disabled: false,
loading: false,
rules: Object.freeze({
agentId: [{ required: true, message: '必填项', trigger: 'blur' }],
secret: [{ required: true, message: '必填项', trigger: 'blur' }],
name: [{ required: true, message: '必填项', trigger: 'blur' }],
description: [{ required: true, message: '必填项', trigger: 'blur' }],
logoUrl: [{ required: true, message: '必填项', trigger: 'change' }],
}),
// status: ['正常', '停用'],
// dialogVisibleSelectMaterial: false,
}
},
watch: {},
computed: {},
created() {
this.getList()
this.$store.dispatch(
'app/setBusininessDesc',
`<div>企业微信自建应用管理,支持通过应用发送应用消息</div> `,
)
},
mounted() {
// new clipboard(".copy-btn");
},
methods: {
getList(page) {
// if (this.dateRange) {
// this.query.beginTime = this.dateRange[0]
// this.query.endTime = this.dateRange[1]
// } else {
// this.query.beginTime = ''
// this.query.endTime = ''
// }
// page && (this.query.pageNum = page)
this.loading = true
getList()
.then(({ data, total }) => {
this.list = data
})
.finally(() => {
this.loading = false
})
},
edit(data, type) {
this.form = Object.assign({}, data || {})
this.dialogVisible = true
type || !data ? (this.disabled = false) : (this.disabled = true)
},
submit() {
this.$refs['form'].validate((valid) => {
if (valid) {
;(this.form.id ? update : add)(this.form)
.then(() => {
this.msgSuccess('操作成功')
this.dialogVisible = false
this.getList()
// this.getList(!this.form.id && 1)
})
.catch(() => {
this.dialogVisible = false
})
}
})
},
/** 删除按钮操作 */
remove(id) {
// const operIds = id || this.ids + ''
this.$confirm('是否确认删除?该操作不可撤销,请谨慎操作。', {
title: '警告',
type: 'warning',
})
.then(function () {
return remove(id)
})
.then(() => {
this.getList()
this.msgSuccess('删除成功')
})
},
// goRoute(id, path) {
// this.$router.push({
// path: 'taskAev',
// query: { id },
// })
// },
// 选择素材确认按钮
// submitSelectMaterial(text, image, file) {
// this.form.logoMediaid = image.id
// this.form.squareLogoUrl = image.materialUrl
// this.dialogVisibleSelectMaterial = false
// },
},
}
</script>
<template>
<div>
<ul v-loading="loading" class="list-wrap">
<li v-for="(item, index) of list" :key="index" class="list">
<div class="flex">
<el-image :src="item.logoUrl" fit="fit"></el-image>
<div class="">
<div class="title blod toe">{{ item.name }}</div>
<div class="desc mt10">
{{ item.description }}
</div>
</div>
</div>
<div class="flex aic mt10">
<div class="list-label">AgentId</div>
{{ item.agentId }}
</div>
<div class="flex aic mt10">
<div class="list-label">可见范围</div>
<!-- <div class="flex">
<div v-for="(item, index) of item.allowPartys.split(',')" :key="index">
<i class="el-icon-folder-opened" v-if="item"></i>{{ item }}
</div>
</div> -->
<TagEllipsis :list="item.allowPartyName.split(',')"></TagEllipsis>
</div>
<div class="list-action fr">
<!-- <el-button type="text">发送消息</el-button>
<el-button type="text">历史消息</el-button> -->
<el-button type="text" @click="edit(item)">编辑</el-button>
<el-button type="text" @click="remove(item.id)">删除</el-button>
</div>
</li>
<li class="list flex aic cp" style="justify-content: center" @click="edit()">
<div class="ac theme">
<i class="el-icon-plus"></i>
添加应用
</div>
</li>
</ul>
<el-dialog
:title="form.id ? '编辑' : '添加'"
:visible.sync="dialogVisible"
:close-on-click-modal="false"
width="580px">
<el-form ref="form" label-position="right" :model="form" :rules="rules" label-width="80px">
<!-- 添加 -->
<template v-if="!form.id">
<el-form-item label="应用ID" prop="agentId">
<el-input
v-model="form.agentId"
:disabled="!!form.id"
placeholder="请输入应用 AgentId"></el-input>
<div class="dialog-tip">如何获取:企微后台->应用管理->自建应用详情->AgentId</div>
</el-form-item>
<el-form-item label="应用密钥" prop="secret">
<el-input v-model="form.secret" placeholder="请输入应用 Secret"></el-input>
<div class="dialog-tip">如何获取:企微后台->应用管理->自建应用详情->Secret</div>
</el-form-item>
</template>
<!-- 编辑 -->
<template v-if="form.id">
<el-form-item label="应用名称" prop="name">
<el-input
v-model="form.name"
maxlength="16"
show-word-limit
placeholder="请输入应用名称"></el-input>
</el-form-item>
<el-form-item label="应用描述" prop="description">
<el-input
type="textarea"
v-model="form.description"
maxlength="60"
show-word-limit
placeholder="请输入应用描述"></el-input>
</el-form-item>
<el-form-item label="应用头像" prop="logoUrl">
<upload class="image-uploader" :fileUrl.sync="form.logoUrl" type="0"></upload>
</el-form-item>
</template>
<!-- <el-row :gutter="10">
<el-col :span="4">
<div class="avatar-wrap ac" @click="dialogVisibleSelectMaterial = true">
<img class="avatar" v-if="form.squareLogoUrl" :src="form.squareLogoUrl" />
<i v-else class="el-icon-plus avatar-uploader-icon cc"></i>
</div>
</el-col>
<el-col :span="20">
<el-form-item label="应用Id" prop="agentId">
<el-input
v-model="form.agentId"
:disabled="!!form.id"
placeholder="请输入应用Id"></el-input>
</el-form-item>
<el-form-item label="应用Secret" prop="agentSecret">
<el-input
:disabled="!!form.id"
v-model="form.agentSecret"
placeholder="请输入应用Secret"></el-input>
</el-form-item>
<el-form-item label="可见范围" v-if="form.id">
<div class="flex">
<div v-for="(item, index) of form.allowPartys.split(',')" :key="index">
<i class="el-icon-folder-opened" v-if="item"></i>{{ item }}
</div>
<div v-for="(item, index) of form.allowUserinfos.split(',')" :key="'1' + index">
<i class="el-icon-s-custom" v-if="item"></i>{{ item }}
</div>
</div>
</el-form-item>
</el-col>
</el-row> -->
</el-form>
<div slot="footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submit">确 定</el-button>
</div>
</el-dialog>
<!-- 选择素材弹窗 -->
<!-- <SelectMaterial
:visible.sync="dialogVisibleSelectMaterial"
type="1"
:showArr="[1]"
@success="submitSelectMaterial"
>
</SelectMaterial> -->
</div>
</template>
<style lang="scss" scoped>
.theme {
color: $blue;
}
.list-wrap {
display: flex;
flex-wrap: wrap;
line-height: 20px;
.list {
width: 33%;
padding: 20px 20px 10px;
border: 1px solid #eee;
margin: 0 20px 20px 0;
background: #fff;
border-radius: 6px;
.el-image {
margin-right: 10px;
width: 80px;
height: 80px;
flex: none;
border: 1px solid #eee;
border-radius: 5px;
background: #eee;
}
.title {
font-size: 16px;
}
.desc {
color: #ddd;
word-break: break-all;
}
.list-label {
color: #888;
width: 90px;
}
}
}
.dialog-tip {
color: #888;
font-size: 12px;
}
// .avatar-wrap {
// position: relative;
// width: 120px;
// height: 120px;
// border: 1px solid #eee;
// border-radius: 5px;
// }
// .avatar {
// width: 100%;
// }
// .avatar-uploader-icon {
// font-size: 28px;
// color: #ddd;
// }
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!