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) } }) }