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