import Vue from 'vue' export default function getAttributeMainList (payload = {}, option = {}) { return new Promise(async (resolve, reject) => { // 表格项 const columns = { name: { title: '属性名称', key: 'name', align: 'center', }, spec_number: { title: '规格数量', key: 'spec_number', align: 'center', }, parameter_number: { title: '参数数量', key: 'parameter_number', align: 'center', }, } const actions = [ { title: '添加', action: 'goAttributeMain', props: { type: 'primary', }, }, ] // 表格扩展(数据操作) const columnsExtra = [ { nodeType: 'action', payload: { title: '查看', list: [ { title: '规格列表', action: 'goAttributeList', actionOption: { type: 0, }, props: { loading: false, }, }, { title: '参数列表', action: 'goAttributeList', actionOption: { type: 1, }, props: { loading: false, }, }, ], }, }, { nodeType: 'action', payload: { title: '操作', list: [ { title: '编辑', action: 'goAttributeMain', props: { loading: false, }, }, { title: '删除', action: 'deleteAttributeMain', }, ], }, }, ] try { const { data, extra, meta } = await Vue.http.get('/product/attribute/category') const response = { filters: [], actions, data, columns: extra.columns .map(key => columns[key]) .filter(Boolean) .concat(columnsExtra), page: meta.pagination, } resolve(response) } catch (e) { reject(e) } }) }