getAttributeMainList.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import Vue from 'vue'
  2. export default function getAttributeMainList (payload = {}, option = {}) {
  3. return new Promise(async (resolve, reject) => {
  4. // 表格项
  5. const columns = {
  6. name: {
  7. title: '属性名称',
  8. key: 'name',
  9. align: 'center',
  10. },
  11. spec_number: {
  12. title: '规格数量',
  13. key: 'spec_number',
  14. align: 'center',
  15. },
  16. parameter_number: {
  17. title: '参数数量',
  18. key: 'parameter_number',
  19. align: 'center',
  20. },
  21. }
  22. const actions = [
  23. {
  24. title: '添加',
  25. action: 'goAttributeMain',
  26. props: {
  27. type: 'primary',
  28. },
  29. },
  30. ]
  31. // 表格扩展(数据操作)
  32. const columnsExtra = [
  33. {
  34. nodeType: 'action',
  35. payload: {
  36. title: '查看',
  37. list: [
  38. {
  39. title: '规格列表',
  40. action: 'goAttributeList',
  41. actionOption: {
  42. type: 0,
  43. },
  44. props: {
  45. loading: false,
  46. },
  47. },
  48. {
  49. title: '参数列表',
  50. action: 'goAttributeList',
  51. actionOption: {
  52. type: 1,
  53. },
  54. props: {
  55. loading: false,
  56. },
  57. },
  58. ],
  59. },
  60. },
  61. {
  62. nodeType: 'action',
  63. payload: {
  64. title: '操作',
  65. list: [
  66. {
  67. title: '编辑',
  68. action: 'goAttributeMain',
  69. props: {
  70. loading: false,
  71. },
  72. },
  73. {
  74. title: '删除',
  75. action: 'deleteAttributeMain',
  76. },
  77. ],
  78. },
  79. },
  80. ]
  81. try {
  82. const { data, extra, meta } = await Vue.http.get('/product/attribute/category')
  83. const response = {
  84. filters: [],
  85. actions,
  86. data,
  87. columns: extra.columns
  88. .map(key => columns[key])
  89. .filter(Boolean)
  90. .concat(columnsExtra),
  91. page: meta.pagination,
  92. }
  93. resolve(response)
  94. } catch (e) {
  95. reject(e)
  96. }
  97. })
  98. }