Commit d804b6c6 by test

素材组件修复

1 parent e1d08cac
<script> <script>
import { getList } from '@/api/customer/tag' import { getList } from '@/api/customer/tag'
import list from './list' import list from './list'
export default { export default {
components: { list }, components: { list },
props: { props: {
// 添加标签显隐 // 添加标签显隐
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false
},
// title: {
// type: String,
// default: '',
// },
type: {
type: String | Number,
default: '4'
},
// 显示哪些素材类型标签
showArr: {
type: Array,
default: () => []
}
}, },
// title: { data () {
// type: String, return {
// default: '', text: {},
// }, image: {},
// 素材类型 0:'文本', 1:'图片' file: {}
type: { }
type: String | Number,
default: '0'
}, },
// 显示哪些素材类型标签 watch: {},
showArr: { computed: {
type: Array, title () {
default: () => [0, 1] const titleMap = {
} 4: '文本',
}, 0: '图片',
data() { 7: '图文',
return { 8: '小程序'
text: {}, }
image: {}, return titleMap[this.type] || '素材'
file: {} },
} Pvisible: {
}, get () {
watch: {}, return this.visible
computed: { },
Pvisible: { set (val) {
get() { this.$emit('update:visible', val)
return this.visible }
}, },
set(val) { Ptype: {
this.$emit('update:visible', val) get () {
return this.type
},
set (val) {
this.$emit('update:type', val)
}
} }
}, },
Ptype: { created () { },
get() { mounted () { },
return this.type methods: {
submit () {
this.Pvisible = false
this.$emit('success', this.selectedData)
}, },
set(val) { onChange (data) {
this.$emit('update:type', val) this.selectedData = data
} }
} }
},
created() {},
mounted() {},
methods: {
submit() {
this.Pvisible = false
this.$emit('success', this.text, this.image, this.file)
},
changeText(data) {
this.text = data
},
changeImage(data) {
this.image = data
}
} }
}
</script> </script>
<template> <template>
<el-dialog <el-dialog :title="`选择${title}`" :visible.sync="Pvisible" width="680px" append-to-body destroy-on-close>
title="选择素材"
:visible.sync="Pvisible"
width="680px"
append-to-body
:close-on-click-modal="false"
>
<div> <div>
<el-tabs v-model="Ptype"> <list v-if="showArr.length <= 1" :type="showArr[0] || type" @change="onChange"> </list>
<el-tab-pane name="0" v-if="showArr.includes(0)"> <el-tabs v-else-if="showArr.length > 1" v-model="Ptype">
<!-- <el-tab-pane name="0" v-if="showArr.includes(0)">
<span slot="label"> <i class="el-icon-date"></i> 文本 </span> <span slot="label"> <i class="el-icon-date"></i> 文本 </span>
<list type="4" @change="changeText"> </list> <list type="4" @change="onChange"> </list>
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="1" v-if="showArr.includes(1)"> <el-tab-pane name="1" v-if="showArr.includes(1)">
<span slot="label"> <i class="el-icon-date"></i> 图片 </span> <span slot="label"> <i class="el-icon-date"></i> 图片 </span>
<list type="0" @change="changeImage"> </list> <list type="0" @change="onChange"> </list>
</el-tab-pane>
<!-- <el-tab-pane name="2">
<span slot="label"> <i class="el-icon-date"></i> 文件 </span>
<list>
<el-table :data="list" style="width: 100%">
<el-table-column width="50">
<template slot-scope="scope">
<el-radio v-model="radio" :label="scope.row.id"></el-radio>
</template>
</el-table-column>
<el-table-column prop="content"> </el-table-column>
</el-table>
</list>
</el-tab-pane> --> </el-tab-pane> -->
</el-tabs> </el-tabs>
</div> </div>
...@@ -109,18 +96,18 @@ export default { ...@@ -109,18 +96,18 @@ export default {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.user-list { .user-list {
.el-row { .el-row {
line-height: 26px; line-height: 26px;
}
}
.mr30 {
margin-right: 30px;
} }
}
.mr30 {
margin-right: 30px;
}
/deep/.el-dialog__body { /deep/.el-dialog__body {
padding: 5px 20px; padding: 5px 20px;
height: 76vh; height: 76vh;
overflow: auto; overflow: auto;
} }
</style> </style>
<script> <script>
import { getTree, getList } from '@/api/material' import { getTree, getList } from '@/api/material'
export default { export default {
components: {}, components: {},
props: { props: {
type: { type: {
type: String, type: String | Number,
default: '4' default: '4'
} }
}, },
data() { data () {
return { return {
loading: true, // 遮罩层 loading: true, // 遮罩层
// 查询条件 // 查询条件
query: { query: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
categoryId: '', categoryId: '',
search: '', search: '',
mediaType: '4' mediaType: '4'
}, },
list: [], // 列表 list: [], // 列表
total: 0, // 总条数 total: 0, // 总条数
treeData: [], // 树 treeData: [], // 树
// 树props // 树props
treeProps: { treeProps: {
children: 'children', children: 'children',
label: 'name' label: 'name'
}, },
// 分组props // 分组props
groupProps: { groupProps: {
// expandTrigger: 'hover', // expandTrigger: 'hover',
checkStrictly: true, checkStrictly: true,
children: 'children', children: 'children',
label: 'name', label: 'name',
value: 'id', value: 'id',
emitPath: false emitPath: false
},
radio: ''
}
},
watch: {
radio (val) {
this.$emit('change', val)
}, },
radio: '' type (val) {
} this.query.mediaType = this.type
}, this.query.pageNum = 1
watch: { this.list = []
radio(val) { this.getList()
this.$emit('change', val) }
}
},
computed: {},
created() {
this.query.mediaType = this.type
this.getTree()
this.getList()
},
mounted() {},
methods: {
// 获取类目树
getTree() {
getTree(this.type).then(({ data }) => {
this.treeData = data
})
}, },
// 获取素材列表 computed: {
getList(page) {
page && (this.query.pageNum = page) },
this.loading = true created () {
getList(this.query) this.query.mediaType = this.type
.then(({ rows, total }) => { this.getList()
this.list = rows },
this.total = +total mounted () { },
this.loading = false methods: {
this.$emit('listChange', this.list) // 获取素材列表
}) getList (page) {
.catch(() => { page && (this.query.pageNum = page)
this.loading = false this.loading = true
}) getList(this.query)
.then(({ rows, total }) => {
this.list = rows.map(i => {
i.checked = false
return i
})
this.total = +total
this.loading = false
this.$emit('listChange', this.list)
})
.catch(() => {
this.loading = false
})
},
onRowClick (row, column, event) {
const evTarget = event.target.nodeName.toUpperCase(0)
if (evTarget == 'INPUT') {
return
}
const checked = row.checked
if (!checked) {
this.list.forEach(i => i.checked = false)
}
row.checked = !checked
this.$emit('change', row.checked ? row : null)
}
} }
} }
}
</script> </script>
<template> <template>
<div> <div>
<el-form ref="form" :model="query" label-width="70px"> <template v-if="type == 4">
<el-form-item label="选择分组"> <el-input v-model="query.search" class="ml10 mr10 mb20" style="width: 260px;" placeholder="请输入文本内容" @keydown.enter.native="getList(1)"></el-input>
<el-cascader </template>
v-model="query.categoryId"
:options="treeData"
:props="groupProps"
></el-cascader>
<el-input
v-model="query.search"
class="ml10 mr10"
style="width: 150px;"
@keydown.enter="getList(1)"
></el-input>
<el-button
v-hasPermi="['contacts:organization:query']"
icon="el-icon-search"
circle
@click="getList(1)"
></el-button>
<el-pagination
class="fr"
@current-change="getList"
:current-page="query.pageNum"
:page-size="query.pageSize"
layout="prev, pager, next"
:total="total"
></el-pagination>
</el-form-item>
</el-form>
<!-- <slot :list="list"></slot> -->
<!-- 文本 --> <!-- 文本 -->
<el-table <el-table v-loading="loading" :data="list" @row-click="onRowClick">
v-if="type == 4"
v-loading="loading"
:data="list"
:show-header="false"
>
<el-table-column width="30"> <el-table-column width="30">
<template slot-scope="scope"> <template slot-scope="{ row }">
<el-radio v-model="radio" :label="scope.row">'</el-radio> <el-radio v-model="row.checked" :label="true"></el-radio>
</template>
</el-table-column>
<!-- 文本 -->
<el-table-column v-if="type == 4" prop="content" label="文本内容"></el-table-column>
<!-- 图片 -->
<el-table-column label="图片" v-if="type == 0">
<template slot-scope="{ row }">
<div class="ma-img flex aic" :key="row.id">
<el-image fit class="img-li" :src="row.materialUrl" />
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="content"> </el-table-column> <el-table-column prop="materialUrl" v-if="type == 0" label="图片地址"></el-table-column>
<!-- 图文 -->
<template v-if="type == 7">
<el-table-column prop="materialName" label="图片标题"></el-table-column>
<el-table-column prop="content" label="图文链接"></el-table-column>
</template>
<!-- 小程序 -->
<template v-if="type == 8">
<el-table-column prop="materialName" label="小程序标题"></el-table-column>
<el-table-column prop="materialUrl" label="小程序AppID"></el-table-column>
</template>
<el-table-column prop="num" label="发送次数"></el-table-column>
<el-table-column prop="updateTime" label="最近更新时间"></el-table-column>
</el-table> </el-table>
<!-- 图片 --> <!--
<el-radio-group <el-radio-group
v-if="type == 0" v-if="type == 0"
v-loading="loading" v-loading="loading"
...@@ -148,26 +159,30 @@ export default { ...@@ -148,26 +159,30 @@ export default {
</div> </div>
</div> </div>
</el-radio> </el-radio>
</el-radio-group> </el-radio-group> -->
<el-pagination class="fr" @current-change="getList" :current-page="query.pageNum" :page-size="query.pageSize" layout="prev, pager, next" :total="total"></el-pagination>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
// .img-wrap { // .img-wrap {
// /deep/.el-radio__input { // /deep/.el-radio__input {
// position: absolute; // position: absolute;
// left: 50%; // left: 50%;
// top: 50%; // top: 50%;
// transform: translate(-50%, -50%); // transform: translate(-50%, -50%);
// } // }
// } // }
.ma-img { .ma-img {
width: 160px; width: 120px;
} height: 120px;
.img-li { border-radius: 8px;
max-width: 100%; border: 1px solid #e6ebf5;
height: 160px; justify-content: center;
border-radius: 8px; }
border: 1px solid #e6ebf5; .img-li {
} // max-width: 100%;
// height: 160px;
}
</style> </style>
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<div> <div>
<div> <div>
<el-form :model="query" label-position="left" ref="queryForm" :inline="true" label-width="100px" class="top-search"> <el-form :model="query" label-position="left" ref="queryForm" :inline="true" label-width="100px" class="top-search">
<el-form-item label="选择创建人" prop="creator"> <el-form-item label="选择创建人">
<el-input :value="query.creator" readonly @focus="dialogVisible = true" placeholder="请选择员工" /> <el-input :value="name" readonly @focus="dialogVisible = true" placeholder="请选择员工" />
</el-form-item> </el-form-item>
<el-form-item label="时间范围"> <el-form-item label="时间范围">
<el-date-picker v-model="value1" format="yyyy-MM-dd" @change="setTimeChange" type="daterange" range-separator="——" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker> <el-date-picker v-model="value1" format="yyyy-MM-dd" @change="setTimeChange" type="daterange" range-separator="——" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
value1: [], value1: [],
dialogVisible: false, dialogVisible: false,
userArray: [], userArray: [],
name: '',
query: { query: {
pageSize: 10, pageSize: 10,
pageNum: 1, pageNum: 1,
...@@ -136,10 +137,14 @@ ...@@ -136,10 +137,14 @@
getSelectUser (data) { getSelectUser (data) {
this.userArray = data this.userArray = data
this.query.creator = this.userArray.map(function (obj, index) { this.query.creator = this.userArray.map(function (obj, index) {
return obj.userId
}).join(",")
this.name = this.userArray.map(function (obj, index) {
return obj.name return obj.name
}).join(",") }).join(",")
}, },
resetQuery () { resetQuery () {
this.name = ''
this.query = { this.query = {
pageSize: 10, pageSize: 10,
pageNum: 1, pageNum: 1,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!