Commit 1cd0a5ee by xinlaa

新建群发页面各弹窗组件抽离等

1 parent 46db8d18
<script>
import { getList } from '@/api/customer/tag'
import list from './list'
export default {
components: { list },
props: {
// 添加标签显隐
visible: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '',
},
type: {
type: String,
default: '0',
},
},
data() {
return {
typeText: ['文本', '图片'],
}
},
watch: {
type(val) {
val === 'remove' && (this.removeTag = this.selected.slice())
},
},
computed: {
Pvisible: {
get() {
// this.getTree();
return this.visible
},
set(val) {
this.$emit('update:visible', val)
},
},
Ptype: {
get() {
// this.getTree();
return this.type
},
set(val) {
this.$emit('update:type', val)
},
},
},
created() {},
mounted() {},
methods: {
submit() {
this.Pvisible = false
this.$emit('success', this.Pselected)
},
},
}
</script>
<template>
<el-dialog
:title="`选择${typeText[Ptype]}素材`"
:visible.sync="Pvisible"
width="650px"
>
<div>
<el-tabs v-model="Ptype">
<el-tab-pane name="0">
<span slot="label"> <i class="el-icon-date"></i> 文本 </span>
<list type="4"> </list>
</el-tab-pane>
<el-tab-pane name="1">
<span slot="label"> <i class="el-icon-date"></i> 图片 </span>
<list type="0"> </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-tabs>
</div>
<div slot="footer">
<el-button @click="Pvisible = false">取 消</el-button>
<el-button type="primary" @click="submit">确 定</el-button>
</div>
</el-dialog>
</template>
<style lang="scss" scoped>
.user-list {
.el-row {
line-height: 26px;
}
}
.mr30 {
margin-right: 30px;
}
</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,
},
radio: '',
}
},
watch: {},
computed: {},
created() {
this.query.mediaType = this.type
this.getTree()
this.getList()
},
mounted() {},
methods: {
// 获取类目树
getTree() {
getTree(this.type).then(({ data }) => {
this.treeData = data
})
},
// 获取素材列表
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
})
},
},
}
</script>
<template>
<div>
<el-form ref="form" :model="query" label-width="80px">
<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>
<!-- <slot :list="list"></slot> -->
<!-- 文本 -->
<el-table v-if="type == 4" :data="list" :show-header="false">
<el-table-column width="30">
<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>
<!-- 图片 -->
<el-radio-group v-if="type == 0" class="img-wrap" v-model="radio">
<el-radio v-for="(item, index) in list" :label="item.id" :key="index">
<img class="img-li" :src="item.materialUrl" alt />
</el-radio>
</el-radio-group>
</div>
</template>
<style lang="scss" scoped>
.img-wrap {
/deep/.el-radio__input {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
// .img-li {
// width: 115px;
// height: 160px;
// }
</style>
...@@ -90,7 +90,7 @@ export default { ...@@ -90,7 +90,7 @@ export default {
<el-checkbox-group v-model="Pselected" v-if="type !== 'remove'"> <el-checkbox-group v-model="Pselected" v-if="type !== 'remove'">
<template v-for="(item, index) in list"> <template v-for="(item, index) in list">
<div <div
class="bfc-d" class="bfc-d mr30"
v-show="item.groupId === selectedGroup || !selectedGroup" v-show="item.groupId === selectedGroup || !selectedGroup"
:key="index" :key="index"
> >
...@@ -129,4 +129,7 @@ export default { ...@@ -129,4 +129,7 @@ export default {
line-height: 26px; line-height: 26px;
} }
} }
.mr30 {
margin-right: 30px;
}
</style> </style>
<script> <script>
import * as api from "@/api/organization"; import { getTree, getList } from '@/api/organization'
import { createUniqueString } from '@/utils'
export default { export default {
name: "SelectUser", name: 'SelectUser',
components: {}, components: {},
props: { props: {
// 添加标签显隐 // 添加标签显隐
...@@ -12,34 +12,40 @@ export default { ...@@ -12,34 +12,40 @@ export default {
}, },
title: { title: {
type: String, type: String,
default: "选择成员", default: '选择成员',
},
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
isOnlyLeaf: {
type: Boolean,
default: true,
}, },
}, },
data() { data() {
let isOnlyLeaf = this.isOnlyLeaf
return { return {
treeData: [], treeData: [],
userList: [], userList: [],
defaultProps: { defaultProps: {
label: "name", label: 'name',
children: "children", children: 'children',
disabled(data, node) { disabled(data, node) {
return !data.userId; return isOnlyLeaf && !data.userId
}, },
isLeaf(data, node) { isLeaf(data, node) {
return !!data.userId; return !!data.userId
}, },
}, },
}; }
}, },
watch: {}, watch: {},
computed: { computed: {
Pvisible: { Pvisible: {
get() { get() {
// this.getTree(); // this.getTree();
return this.visible; return this.visible
}, },
set(val) { set(val) {
this.$emit("update:visible", val); this.$emit('update:visible', val)
}, },
}, },
}, },
...@@ -48,36 +54,46 @@ export default { ...@@ -48,36 +54,46 @@ export default {
methods: { methods: {
loadNode(node, resolve) { loadNode(node, resolve) {
if (node.level === 0) { if (node.level === 0) {
this.userList = []; this.userList = []
api.getTree().then(({ data }) => { getTree().then(({ data }) => {
let _data = this.handleTree(data); data.forEach((element) => {
resolve(_data); element.key = createUniqueString()
})
let _data = this.handleTree(data)
console.log('d', data)
resolve(_data)
// api.getList({ department: _data[0].id }).then(({ rows, total }) => { // api.getList({ department: _data[0].id }).then(({ rows, total }) => {
// _data && rows.unshift(..._data); // _data && rows.unshift(..._data);
// resolve(rows); // resolve(rows);
// }); // });
}); })
} else { } else {
api.getList({ department: node.data.id }).then(({ rows, total }) => { getList({ department: node.data.id }).then(({ rows }) => {
node.data.children && rows.push(...node.data.children); rows.forEach((element) => {
resolve(rows); element.key = createUniqueString()
}); })
node.data.children && rows.push(...node.data.children)
resolve(rows)
})
} }
}, },
handleCheckChange(data, checked, indeterminate) { handleCheckChange(data, checked, indeterminate) {
checked checked
? this.userList.push(data) ? this.userList.push(data)
: this.userList.splice(this.userList.indexOf(data), 1); : this.userList.splice(this.userList.indexOf(data), 1)
// console.log(data, checked, indeterminate); // console.log(data, checked, indeterminate);
}, },
submit() { submit() {
this.Pvisible = false; this.Pvisible = false
this.$emit("success", this.userList); this.$emit('success', this.userList)
},
cancle(key) {
this.$refs.tree.setChecked(key, false)
}, },
}, },
}; }
</script> </script>
setChecked
<template> <template>
<el-dialog :title="title" :visible.sync="Pvisible"> <el-dialog :title="title" :visible.sync="Pvisible">
<el-row :gutter="20"> <el-row :gutter="20">
...@@ -87,14 +103,16 @@ export default { ...@@ -87,14 +103,16 @@ export default {
<!-- <div>部门架构</div> --> <!-- <div>部门架构</div> -->
<!-- :filter-node-method="filterNode" --> <!-- :filter-node-method="filterNode" -->
<el-tree <el-tree
v-if="Pvisible" node-key="key"
ref="tree" ref="tree"
lazy lazy
accordion
show-checkbox show-checkbox
check-on-click-node check-on-click-node
:expand-on-click-node="true" :expand-on-click-node="true"
:load="loadNode" :load="loadNode"
:props="defaultProps" :props="defaultProps"
:check-strictly="!isOnlyLeaf"
@check-change="handleCheckChange" @check-change="handleCheckChange"
></el-tree> ></el-tree>
</div> </div>
...@@ -104,7 +122,12 @@ export default { ...@@ -104,7 +122,12 @@ export default {
<el-row :gutter="10">选择人员列表</el-row> <el-row :gutter="10">选择人员列表</el-row>
<el-row v-for="(item, index) in userList" :key="index"> <el-row v-for="(item, index) in userList" :key="index">
<i class="el-icon-user-solid"></i> <i class="el-icon-user-solid"></i>
{{item.name}} {{ item.name }}
<i
class="el-icon-minus fr cp"
title="取消选择"
@click="cancle(item.key)"
></i>
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
......
...@@ -38,16 +38,19 @@ service.interceptors.response.use( ...@@ -38,16 +38,19 @@ service.interceptors.response.use(
if (code === 200) { if (code === 200) {
return res.data return res.data
} else if (code === 401) { } else if (code === 401) {
// MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { MessageBox.confirm(
// confirmButtonText: '重新登录', '登录状态已过期,您可以继续留在该页面,或者重新登录',
// cancelButtonText: '取消', '系统提示',
// type: 'warning' {
// } confirmButtonText: '重新登录',
// ).then(() => { cancelButtonText: '取消',
// store.dispatch('LogOut').then(() => { type: 'warning',
// location.href = '/index'; }
// }) ).then(() => {
// }) store.dispatch('LogOut').then(() => {
location.href = '/'
})
})
} else if (code === 500) { } else if (code === 500) {
Message({ Message({
message: msg, message: msg,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!