Commit d804b6c6 by test

素材组件修复

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