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: {
// 添加标签显隐 // 添加标签显隐
...@@ -14,18 +14,17 @@ export default { ...@@ -14,18 +14,17 @@ export default {
// type: String, // type: String,
// default: '', // default: '',
// }, // },
// 素材类型 0:'文本', 1:'图片'
type: { type: {
type: String | Number, type: String | Number,
default: '0' default: '4'
}, },
// 显示哪些素材类型标签 // 显示哪些素材类型标签
showArr: { showArr: {
type: Array, type: Array,
default: () => [0, 1] default: () => []
} }
}, },
data() { data () {
return { return {
text: {}, text: {},
image: {}, image: {},
...@@ -34,70 +33,58 @@ export default { ...@@ -34,70 +33,58 @@ export default {
}, },
watch: {}, watch: {},
computed: { computed: {
title () {
const titleMap = {
4: '文本',
0: '图片',
7: '图文',
8: '小程序'
}
return titleMap[this.type] || '素材'
},
Pvisible: { Pvisible: {
get() { get () {
return this.visible return this.visible
}, },
set(val) { set (val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
} }
}, },
Ptype: { Ptype: {
get() { get () {
return this.type return this.type
}, },
set(val) { set (val) {
this.$emit('update:type', val) this.$emit('update:type', val)
} }
} }
}, },
created() {}, created () { },
mounted() {}, mounted () { },
methods: { methods: {
submit() { submit () {
this.Pvisible = false this.Pvisible = false
this.$emit('success', this.text, this.image, this.file) this.$emit('success', this.selectedData)
}, },
changeText(data) { onChange (data) {
this.text = data this.selectedData = 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 { .mr30 {
margin-right: 30px; 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, // 遮罩层
// 查询条件 // 查询条件
...@@ -40,31 +40,35 @@ export default { ...@@ -40,31 +40,35 @@ export default {
} }
}, },
watch: { watch: {
radio(val) { radio (val) {
this.$emit('change', val) this.$emit('change', val)
},
type (val) {
this.query.mediaType = this.type
this.query.pageNum = 1
this.list = []
this.getList()
} }
}, },
computed: {}, computed: {
created() {
},
created () {
this.query.mediaType = this.type this.query.mediaType = this.type
this.getTree()
this.getList() this.getList()
}, },
mounted() {}, mounted () { },
methods: { methods: {
// 获取类目树
getTree() {
getTree(this.type).then(({ data }) => {
this.treeData = data
})
},
// 获取素材列表 // 获取素材列表
getList(page) { getList (page) {
page && (this.query.pageNum = page) page && (this.query.pageNum = page)
this.loading = true this.loading = true
getList(this.query) getList(this.query)
.then(({ rows, total }) => { .then(({ rows, total }) => {
this.list = rows this.list = rows.map(i => {
i.checked = false
return i
})
this.total = +total this.total = +total
this.loading = false this.loading = false
this.$emit('listChange', this.list) this.$emit('listChange', this.list)
...@@ -72,61 +76,68 @@ export default { ...@@ -72,61 +76,68 @@ export default {
.catch(() => { .catch(() => {
this.loading = false 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> </template>
</el-table-column> </el-table-column>
<el-table-column prop="content"> </el-table-column>
</el-table> <!-- 文本 -->
<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>
</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-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 {
max-width: 100%;
height: 160px;
border-radius: 8px; border-radius: 8px;
border: 1px solid #e6ebf5; border: 1px solid #e6ebf5;
} justify-content: center;
}
.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!