123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- import Vue from 'vue'
- export default function getCommentList (payload = {}, option = {}) {
- return new Promise(async (resolve, reject) => {
- // 筛选项
- const filters = {
- shop_id: {
- type: 'input',
- title: '商家',
- key: 'shop_id',
- props: {
- placeholder: '请选择商家',
- filterable: true,
- clearable: true,
- },
- },
- star: {
- type: 'select',
- title: '星级',
- key: 'star',
- props: {
- placeholder: '评价星级',
- filterable: true,
- clearable: true,
- },
- option: {
- list: [],
- },
- },
- username: {
- type: 'input',
- title: '用户昵称',
- key: 'username',
- props: {
- placeholder: '用户昵称',
- clearable: true,
- },
- },
- keyword: {
- type: 'input',
- title: '关键词',
- key: 'keyword',
- props: {
- placeholder: '评价关键词/上架名称',
- clearable: true,
- },
- },
- }
- // 操作项
- const actions = []
- const sortActions = []
- // 表格项
- // "sale_name"
- const columns = {
- username: {
- title: '用户昵称',
- key: 'username',
- align: 'center',
- width: 100,
- },
- product_name: {
- title: '上架名称',
- key: 'product_name',
- align: 'center',
- width: 80,
- },
- shop_name: {
- title: '所属商家',
- key: 'shop_name',
- align: 'center',
- width: 80,
- },
- category_name1: {
- title: '一级分类',
- key: 'category_name1',
- align: 'center',
- },
- category_name2: {
- title: '二级分类',
- key: 'category_name2',
- align: 'center',
- },
- category_name3: {
- title: '三级分类',
- key: 'category_name3',
- align: 'center',
- },
- star: {
- nodeType: 'rating',
- payload: {
- title: '评价',
- key: 'star',
- width: 200,
- props: {
- disabled: true,
- },
- },
- },
- content: {
- title: '评论内容',
- key: 'content',
- align: 'center',
- },
- purchase_no: {
- title: '订单号',
- key: 'purchase_no',
- align: 'center',
- },
- created_at: {
- title: '评价时间时间',
- key: 'created_at',
- align: 'center',
- },
- }
- const sortColumns = {}
- // 表格扩展(数据操作)
- const columnsExtra = {}
- const sortColumnsExtra = {}
- try {
- const isSort = option.type === 'sort'
- if (isSort) payload.per_page = 1000
- const { data, extra, meta } = await Vue.http.get('/product/comment', {
- params: payload,
- })
- const response = {
- filters: isSort ? [] : extra.filters.map(key => filters[key]).filter(Boolean),
- actions: isSort ? sortActions : actions,
- data: data,
- columns: extra.columns
- .map(key => (isSort ? sortColumns : columns)[key])
- .filter(Boolean)
- .concat(isSort ? sortColumnsExtra : columnsExtra),
- page: isSort ? {} : meta.pagination,
- title: '评价列表',
- }
- resolve(response)
- } catch (e) {
- reject(e)
- }
- })
- }
|