index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div class="padding-20">
  3. <div class="search-box">
  4. <el-form ref="form"
  5. :inline="true"
  6. :model="searchForm"
  7. clearable
  8. class="mt-10">
  9. <el-form-item label="附加名称:">
  10. <el-input v-model="searchForm.attach_name" placeholder="请输入附加名称" clearable></el-input>
  11. </el-form-item>
  12. <el-form-item class="ml-10">
  13. <el-button icon="el-icon-search" type="primary" @click="searchSubmit">查询</el-button>
  14. </el-form-item>
  15. <el-form-item class="ml-10">
  16. <el-button icon="el-icon-plus" type="primary" @click="add">添加</el-button>
  17. </el-form-item>
  18. </el-form>
  19. </div>
  20. <el-table :data="tableData"
  21. stripe
  22. v-loading="tableLoading"
  23. fit
  24. class="marginT-10 order-table"
  25. border
  26. :max-height="vheight">
  27. <el-table-column label="ID" prop="id" width="200"></el-table-column>
  28. <el-table-column label="附加名称" prop="attach_name" width="200"></el-table-column>
  29. <el-table-column label="可选值列表">
  30. <template slot-scope="scope">
  31. <p>{{ scope.row.attach_content.replace(/,/g, ',') }}</p>
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="操作" width="220">
  35. <template slot-scope="scope">
  36. <el-button type="text"
  37. @click="edit(scope.row)">编辑
  38. </el-button>
  39. <el-button type="text"
  40. @click="del(scope.row)">删除
  41. </el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <el-pagination
  46. class="marginT-20"
  47. @size-change="handleSizeChange"
  48. @current-change="handleCurrentChange"
  49. :hide-on-single-page="true"
  50. :current-page="page"
  51. :page-size="page_size"
  52. :page-sizes="[10, 20, 100, 200, 300, 400]"
  53. background
  54. layout="total, sizes, prev, pager, next, jumper"
  55. :total="totalCount"/>
  56. <detail v-if="detailsDialog.show"
  57. v-model="detailsDialog.show"
  58. :exData="detailsDialog.exData"
  59. @success="init"></detail>
  60. </div>
  61. </template>
  62. <script>
  63. import page from '@/mixin/page'
  64. import detail from './details'
  65. export default {
  66. mixins: [page],
  67. components: {
  68. detail,
  69. },
  70. data () {
  71. return {
  72. detailsDialog: {
  73. show: false,
  74. exData: {}
  75. },
  76. searchForm: {},
  77. tableData: [],
  78. tableUrl: '/v1/bar/product/attach/list'
  79. }
  80. },
  81. methods: {
  82. add () {
  83. this.detailsDialog.exData = {}
  84. this.detailsDialog.show = true
  85. },
  86. edit (row) {
  87. this.detailsDialog.exData = row
  88. this.detailsDialog.show = true
  89. },
  90. del (row) {
  91. this.$confirm('确定要删除吗', '确认', {
  92. confirmButtonText: '确定',
  93. cancelButtonText: '取消',
  94. type: 'warning'
  95. }).then(async () => {
  96. const data = await this.$fetch('/v1/bar/product/attach/delete', { id: row.id }, 'get')
  97. if (data.code === 200) {
  98. this.$message.success('删除成功')
  99. this.init()
  100. this.$store.dispatch('common/fetchGoodsAttr')
  101. }
  102. }).catch(() => {})
  103. }
  104. },
  105. mounted () {
  106. this.init()
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .el-dropdown {
  112. margin: 0 10px;
  113. .el-dropdown-link {
  114. cursor: pointer;
  115. color: #409EFF;
  116. }
  117. }
  118. </style>