index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div>
  3. <FullPage title='商品列表'
  4. :list='list'
  5. @init='init'
  6. :loading='loading'
  7. @searchData='init'
  8. @changePage='changePage'
  9. @changeSize='changeSize'
  10. :tableColums='tableColums'
  11. :tableData='tableData'
  12. :pageIndex='pageIndex'
  13. :total='total'>
  14. <div slot='titleButton'
  15. style="display:flex;">
  16. <Button v-if='persimissionData["新增商品"]||persimissionData.all'
  17. type="primary"
  18. ghost
  19. icon='md-add'
  20. @click="goPage(1)">新增商品</Button>
  21. </div>
  22. <div slot='navButton'>
  23. </div>
  24. <template slot='set'
  25. slot-scope='{row}'>
  26. <div class="table-set">
  27. <svg v-if='persimissionData["编辑"]||persimissionData.all'
  28. style="font-size:20px"
  29. color='#3764FF'
  30. @click="goPage(2,row)"
  31. class="icon icon-nav"
  32. aria-hidden="true">
  33. <use xlink:href="#iconbianji"></use>
  34. </svg>
  35. <svg v-if='persimissionData["详情"]||persimissionData.all'
  36. style="font-size:20px"
  37. color='green'
  38. @click="goPage(3,row)"
  39. class="icon icon-nav"
  40. aria-hidden="true">
  41. <use xlink:href="#iconxiangqing"></use>
  42. </svg>
  43. <svg v-if='persimissionData["删除"]||persimissionData.all'
  44. @click="delItems(row)"
  45. class="icon icon-nav"
  46. style="font-size:20px"
  47. color='red'
  48. aria-hidden="true">
  49. <use xlink:href="#iconshanchu"></use>
  50. </svg>
  51. </div>
  52. </template>
  53. </FullPage>
  54. </div>
  55. </template>
  56. <script>
  57. import { mapState } from 'vuex'
  58. export default {
  59. data () {
  60. return {
  61. list: [
  62. { title: '商品名称', name: 'Input', value: '', serverName: 'title', placeholder: '请输入物料分类名称' },
  63. ],
  64. tableColums: [
  65. { title: '序号', type: 'index', align: 'center', key: '', fixed: 'left', width: '100' },
  66. {
  67. title: '图片', align: 'center', key: 'img_url', minWidth: 100,
  68. render: (h, params) => {
  69. return h('img', {
  70. attrs: {
  71. src: params.row.img_url?this.$store.state.ip + params.row.img_url:'',
  72. style: 'max-width:50px;max-height:50px;position:relative;top:3px;'
  73. },
  74. props: {
  75. row: params.row
  76. }
  77. })
  78. }
  79. },
  80. { title: '商品名称', align: 'center', key: 'title', minWidth: 100 },
  81. { title: '通用商品价格', align: 'center', key: 'price', minWidth: 100 },
  82. { title: '操作', align: 'center', slot: 'set', width: '150', fixed: 'right' },
  83. ],
  84. tableData: [],
  85. pageIndex: 1,
  86. total: 0,
  87. pageSize: 10,
  88. proxyObj: {},
  89. loading: false,
  90. }
  91. },
  92. computed: {
  93. ...mapState(['persimissionData']),
  94. },
  95. methods: {
  96. init (row) {
  97. this.pageIndex = 1
  98. row.page_index = this.pageIndex;
  99. row.page_size = this.pageSize;
  100. this.proxyObj = row;
  101. this.getData(row)
  102. },
  103. getData (row) {
  104. this.loading = true;
  105. this.axios('/api/goods', { params: row }).then(res => {
  106. this.loading = false;
  107. this.tableData = res.data.data;
  108. this.total = res.data.total;
  109. })
  110. },
  111. changePage (e) {
  112. this.pageIndex = e;
  113. this.proxyObj.page_index = this.pageIndex;
  114. this.getData(this.proxyObj)
  115. },
  116. changeSize (e) {
  117. this.pageSize = e;
  118. this.proxyObj.page_size = this.page_size;
  119. this.getData(this.proxyObj)
  120. },
  121. delItems (row) {
  122. this.confirmDelete({
  123. content: '确认删除么?',
  124. then: () => {
  125. this.axios.post('/api/goods', { id: row.id, state: 0 }).then(res => {
  126. this.getData(this.searchObj)
  127. })
  128. }
  129. })
  130. },
  131. goPage (n, row) {//n = 1 新增 2 编辑 3 查看
  132. let id = row ? row.id : ''
  133. this.$router.push({
  134. path: '/cms/goods/edit',
  135. query: {
  136. type: n,
  137. id: id
  138. }
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .nav {
  146. display: flex;
  147. justify-content: space-between;
  148. align-items: center;
  149. }
  150. .vertical-center-modal {
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. .ivu-modal {
  155. top: 0;
  156. }
  157. }
  158. </style>