index.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-list-page');
  4. ComponentHelper::loadComponentView('com-list-table');
  5. ?>
  6. <com-list-page :crumbs="crumbs" id="application">
  7. <com-list-table ref="table" :api="api" :search-list="searchList">
  8. <el-table-column label="ID" align="center" prop="id"></el-table-column>
  9. <el-table-column label="前端字段显示" align="center" prop="frontend_name"></el-table-column>
  10. <el-table-column label="模板名称" align="center" prop="name"></el-table-column>
  11. <el-table-column label="商品使用数" align="center" prop="use_num"></el-table-column>
  12. <el-table-column label="操作" align="center">
  13. <template slot-scope="scope">
  14. <el-button type="text" @click="toEdit(scope.row.id)">编辑</el-button>
  15. <el-button type="text" @click="del(scope.row.id)">删除</el-button>
  16. </template>
  17. </el-table-column>
  18. <template slot="header-left">
  19. <el-button size="mini" type="primary" @click="toEdit(0)">添加模板</el-button>
  20. </template>
  21. </com-list-table>
  22. </com-list-page>
  23. <script>
  24. const application = new Vue({
  25. el: '#application',
  26. data: {
  27. api: 'mall/goods/description-template',
  28. crumbs: [
  29. {
  30. title: '商品说明',
  31. }
  32. ]
  33. },
  34. mounted() {
  35. },
  36. computed: {
  37. searchList() {
  38. return [
  39. {
  40. label: '模板名称',
  41. type: 'text',
  42. key: 'name',
  43. placeholder: '请输入模板名称',
  44. clearable: true,
  45. },
  46. ]
  47. }
  48. },
  49. methods: {
  50. toEdit(id = 0) {
  51. this.$navigate({
  52. r: 'mall/goods/edit-description-template',
  53. id: id
  54. })
  55. },
  56. del(id) {
  57. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  58. confirmButtonText: '确定',
  59. cancelButtonText: '取消',
  60. type: 'warning'
  61. }).then(() => {
  62. request({
  63. params: {
  64. r: 'mall/goods/del-description-template',
  65. },
  66. data: {
  67. id: id,
  68. },
  69. method: 'POST'
  70. }).then(e => {
  71. if (e.data.code === 0) {
  72. this.$refs.table.getList()
  73. this.$message({
  74. type: 'success',
  75. message: '删除成功!'
  76. });
  77. } else {
  78. this.$message.error(e.data.msg);
  79. }
  80. })
  81. })
  82. }
  83. }
  84. })
  85. </script>