Commit 609232f9 by xinlaa

素材文本接口对接等

1 parent 6688dd84
...@@ -33,7 +33,7 @@ coverUrl:封面本地资源文件 ...@@ -33,7 +33,7 @@ coverUrl:封面本地资源文件
} }
*/ */
export function add(data) { export function add(data) {
return request({ url: service, method: 'post', params: data }) return request({ url: service, method: 'post', data })
} }
/** /**
...@@ -73,7 +73,26 @@ export function upload(data) { ...@@ -73,7 +73,26 @@ export function upload(data) {
return request({ return request({
url: config.services.wecom + '/upload', url: config.services.wecom + '/upload',
method: 'post', method: 'post',
params: data, data,
})
}
/**
* 素材移动分组
* @param {*} data
* {
* categoryId 选择移动的分组类目id
* materials // 移动的素材ids,逗号分隔
* }
*/
export function moveGroup(categoryId, materials) {
return request({
url: service + '/resetCategory',
method: 'post',
data: {
categoryId,
materials,
},
}) })
} }
......
...@@ -6,6 +6,11 @@ import { ...@@ -6,6 +6,11 @@ import {
updateTree, updateTree,
addTree, addTree,
removeTree, removeTree,
getDetail,
add,
update,
remove,
moveGroup,
} from '@/api/material' } from '@/api/material'
export default { export default {
name: 'MaPage', name: 'MaPage',
...@@ -16,6 +21,11 @@ export default { ...@@ -16,6 +21,11 @@ export default {
type: String, type: String,
default: '0', default: '0',
}, },
// 选中的素材ids
selected: {
type: [Array, String],
default: '',
},
}, },
data() { data() {
return { return {
...@@ -33,18 +43,20 @@ export default { ...@@ -33,18 +43,20 @@ export default {
// 树props // 树props
treeProps: { treeProps: {
children: 'children', children: 'children',
label: 'label', label: 'name',
}, },
treeForm: {}, // 树表格 treeForm: {}, // 树表格
treeDialogVisible: false, // 树表格对话框显隐 treeDialogVisible: false, // 树表格对话框显隐
group: [], // 选择的分组
group: '', // 选择的分组
groupDialogVisible: false, // 移动分组对话框 groupDialogVisible: false, // 移动分组对话框
// 分组props // 分组props
groupProps: { groupProps: {
expandTrigger: 'hover', // expandTrigger: 'hover',
checkStrictly: true, checkStrictly: true,
children: 'children', children: 'children',
label: 'label', label: 'name',
value: 'id',
emitPath: false, emitPath: false,
}, },
...@@ -52,7 +64,7 @@ export default { ...@@ -52,7 +64,7 @@ export default {
form: {}, // 素材表单 form: {}, // 素材表单
dialogVisible: false, // 素材表格对话框显隐 dialogVisible: false, // 素材表格对话框显隐
// 表单校验 // 表单校验
rules: { rules: Object.freeze({
content: [{ required: true, message: '不能为空', trigger: 'blur' }], content: [{ required: true, message: '不能为空', trigger: 'blur' }],
materialUrl: [{ required: true, message: '不能为空', trigger: 'blur' }], materialUrl: [{ required: true, message: '不能为空', trigger: 'blur' }],
materialName: [ materialName: [
...@@ -60,7 +72,7 @@ export default { ...@@ -60,7 +72,7 @@ export default {
], ],
digest: [{ required: true, message: '不能为空', trigger: 'blur' }], digest: [{ required: true, message: '不能为空', trigger: 'blur' }],
coverUrl: [{ required: true, message: '不能为空', trigger: 'blur' }], coverUrl: [{ required: true, message: '不能为空', trigger: 'blur' }],
}, }),
} }
}, },
watch: {}, watch: {},
...@@ -83,7 +95,7 @@ export default { ...@@ -83,7 +95,7 @@ export default {
this.loading = true this.loading = true
getList(this.query) getList(this.query)
.then(({ rows, total }) => { .then(({ rows, total }) => {
this.userList = rows this.list = rows
this.total = +total this.total = +total
this.loading = false this.loading = false
this.$emit('listChange', this.list) this.$emit('listChange', this.list)
...@@ -106,23 +118,21 @@ export default { ...@@ -106,23 +118,21 @@ export default {
treeEdit(data, type) { treeEdit(data, type) {
this.treeForm = Object.assign( this.treeForm = Object.assign(
{}, {},
type ? data : { parentId: data.id || '0' } type ? data : { parentId: data.id || '0', mediaType: this.type }
) )
this.treeDialogVisible = true this.treeDialogVisible = true
}, },
// 类目树节点提交 // 类目树节点提交
treeSubmit() { treeSubmit() {
this.treeForm.id ;(this.treeForm.id ? updateTree : addTree)(this.treeForm)
? 'updateTree' .then(() => {
: 'addTree'(this.treeForm) this.msgSuccess('操作成功')
.then(() => { this.treeDialogVisible = false
this.msgSuccess('操作成功') this.getTree()
this.treeDialogVisible = false })
this.getTree() .catch(() => {
}) this.treeDialogVisible = false
.catch(() => { })
this.treeDialogVisible = false
})
}, },
// 类目树节点删除 // 类目树节点删除
treeRemove(id) { treeRemove(id) {
...@@ -139,7 +149,10 @@ export default { ...@@ -139,7 +149,10 @@ export default {
}, },
// 素材添加/编辑 // 素材添加/编辑
edit(data, type) { edit(data, type) {
this.form = Object.assign({}, data || { _new: true }) this.form = Object.assign(
{},
data || { categoryId: this.query.categoryId, _new: true }
)
this.dialogVisible = true this.dialogVisible = true
// type || !data ? (this.disabled = false) : (this.disabled = true) // type || !data ? (this.disabled = false) : (this.disabled = true)
}, },
...@@ -148,13 +161,11 @@ export default { ...@@ -148,13 +161,11 @@ export default {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
let form = JSON.parse(JSON.stringify(this.form)) let form = JSON.parse(JSON.stringify(this.form))
form.department += '' ;(form.id ? update : add)(form)
form.isLeaderInDept += ''
api[form._new ? 'addUser' : 'updateUser'](form)
.then(() => { .then(() => {
this.msgSuccess('操作成功') this.msgSuccess('操作成功')
this.dialogVisible = false this.dialogVisible = false
this.getList(!this.form.id && 1) this.getList()
}) })
.catch(() => { .catch(() => {
this.dialogVisible = false this.dialogVisible = false
...@@ -164,18 +175,25 @@ export default { ...@@ -164,18 +175,25 @@ export default {
}, },
// 素材删除 // 素材删除
remove(id) { remove(id) {
// const operIds = id || this.ids + ""; const Ids = id || this.selected
this.$confirm('是否确认删除吗?', '警告', { this.$confirm('是否确认删除吗?', '警告', {
type: 'warning', type: 'warning',
}) })
.then(function() { .then(function() {
return remove(id) return remove(Ids)
}) })
.then(() => { .then(() => {
this.getList() this.getList()
this.msgSuccess('删除成功') this.msgSuccess('删除成功')
}) })
}, },
moveGroup() {
moveGroup(this.group, this.selected).then(() => {
this.getList()
this.msgSuccess('操作成功')
this.groupDialogVisible = false
})
},
}, },
} }
</script> </script>
...@@ -184,46 +202,45 @@ export default { ...@@ -184,46 +202,45 @@ export default {
<div class="page"> <div class="page">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="6" :xs="24"> <el-col :span="6" :xs="24">
<div class="head-container"> <div>
<el-button slot="reference" type="primary" @click="treeEdit({}, 0)" <el-button slot="reference" type="primary" @click="treeEdit({}, 0)"
>添加分类</el-button >添加分类</el-button
> >
</div> </div>
<div class="head-container"> <div class="mt20">
<!-- :filter-node-method="filterNode" --> <!-- :filter-node-method="filterNode" -->
<el-tree <el-tree
ref="tree"
:data="treeData" :data="treeData"
:props="treeProps" :props="treeProps"
:expand-on-click-node="false" :expand-on-click-node="false"
ref="tree" highlight-current
default-expand-all default-expand-all
@node-click="handleNodeClick" @node-click="handleNodeClick"
/> >
<div class="custom-tree-node" slot-scope="{ node, data }"> <div class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ node.label }}</span> <span>{{ node.label }}</span>
<span class="fr"> <span class="fr">
<i <i
class="el-icon-edit" class="el-icon-edit"
title="编辑" title="编辑"
v-hasPermi="['contacts:organization:editDep']" @click.stop="treeEdit(data, 1)"
v-if="node.level !== 1" ></i>
@click.stop="treeEdit(data, 1)" <i
></i> class="el-icon-plus"
<i title="添加子分类"
class="el-icon-plus" v-hasPermi="['contacts:organization:addDep']"
title="添加子分类" @click.stop="treeEdit(data, 0)"
v-hasPermi="['contacts:organization:addDep']" ></i>
@click.stop="treeEdit(data, 0)" <i
></i> class="el-icon-minus"
<i title="删除"
class="el-icon-minus" v-hasPermi="['contacts:organization:removeDep']"
title="删除" @click.stop="treeRemove(data.id)"
v-hasPermi="['contacts:organization:removeDep']" ></i>
v-if="node.level !== 1" </span>
@click.stop="treeRemove(data.id)" </div>
></i> </el-tree>
</span>
</div>
</div> </div>
</el-col> </el-col>
...@@ -243,7 +260,9 @@ export default { ...@@ -243,7 +260,9 @@ export default {
style="width: 300px;" style="width: 300px;"
/> />
<el-button class="ml10" @click="getList(1)">搜索</el-button> <el-button class="ml10" @click="getList(1)">搜索</el-button>
<el-button @click="remove">删除</el-button> <el-button @click="remove" :disabled="selected.length"
>删除</el-button
>
<el-popover placement="top" width="260" v-model="groupDialogVisible"> <el-popover placement="top" width="260" v-model="groupDialogVisible">
<div>选择分组</div> <div>选择分组</div>
<div style="position: relative; margin: 10px 0;"> <div style="position: relative; margin: 10px 0;">
...@@ -257,14 +276,13 @@ export default { ...@@ -257,14 +276,13 @@ export default {
<el-button size="mini" @click="groupDialogVisible = false" <el-button size="mini" @click="groupDialogVisible = false"
>取消</el-button >取消</el-button
> >
<el-button <el-button type="primary" size="mini" @click="moveGroup"
type="primary"
size="mini"
@click="groupDialogVisible = false"
>确定</el-button >确定</el-button
> >
</div> </div>
<el-button slot="reference" class="ml10">移动分组</el-button> <el-button slot="reference" class="ml10" :disabled="selected.length"
>移动分组</el-button
>
</el-popover> </el-popover>
<div class="fr"> <div class="fr">
...@@ -424,4 +442,13 @@ export default { ...@@ -424,4 +442,13 @@ export default {
</div> </div>
</template> </template>
<style lang="scss" scoped></style> <style lang="scss" scoped>
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
</style>
<script> <script>
import MaPage from '@/views/material/components/MaPage' import MaPage from '@/views/material/components/MaPage'
import {} from '@/api/material'
export default { export default {
components: { MaPage }, components: { MaPage },
...@@ -19,16 +18,14 @@ export default { ...@@ -19,16 +18,14 @@ export default {
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map((item) => item.userId) this.ids = selection.map((item) => item.id) + ''
this.single = selection.length != 1
this.multiple = !selection.length
}, },
}, },
} }
</script> </script>
<template> <template>
<MaPage ref="page" type="4" @listChange="listChange"> <MaPage ref="page" type="4" @listChange="listChange" :selected="ids">
<el-table <el-table
class="mt20" class="mt20"
:data="list" :data="list"
...@@ -38,15 +35,10 @@ export default { ...@@ -38,15 +35,10 @@ export default {
<el-table-column <el-table-column
label="文本内容" label="文本内容"
align="center" align="center"
prop="userName" prop="content"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
/> />
<el-table-column <el-table-column label="创建时间" align="center" prop="createTime">
label="创建时间"
align="center"
prop="createTime"
width="160"
>
<!-- <template slot-scope="scope"> <!-- <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> --> </template> -->
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!