BindPackage.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="3">
  5. <el-input v-model="search" placeholder="请输入套餐名称"></el-input>
  6. </el-col>
  7. <el-col :span="1">
  8. &nbsp;
  9. </el-col>
  10. <el-col :span="1">
  11. <el-button type="primary" @click="getItems">查询</el-button>
  12. </el-col>
  13. <el-col :span="1">
  14. &nbsp;
  15. </el-col>
  16. <el-col :span="1">
  17. <el-button type="primary" @click="save">绑定</el-button>
  18. </el-col>
  19. <el-col :span="1">
  20. &nbsp;
  21. </el-col>
  22. <el-col :span="1">
  23. <el-button @click="goBack">取消</el-button>
  24. </el-col>
  25. </el-row>
  26. <el-table :data="items">
  27. <el-table-column label="选择" width="80px">
  28. <template slot-scope="scope">
  29. <el-radio v-model="package" :label="scope.row">&nbsp;</el-radio>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="套餐名称" prop="package_name"></el-table-column>
  33. <el-table-column label="套餐描述" prop="describe"></el-table-column>
  34. <el-table-column label="套餐价格" prop="price"></el-table-column>
  35. <el-table-column label="项目总价" prop="total"></el-table-column>
  36. <el-table-column label="套餐备注" prop="remarks"></el-table-column>
  37. </el-table>
  38. </div>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. search: '',
  45. gid: 0,
  46. items: [],
  47. package: 0
  48. }
  49. },
  50. methods: {
  51. getItems: function() {
  52. var param = {
  53. search: this.search
  54. }
  55. this.$http.getPackages(param, this).then(res => {
  56. if (res.code === 0) {
  57. this.items = res.obj
  58. }
  59. })
  60. },
  61. goBack: function() {
  62. this.$router.back()
  63. },
  64. save: function() {
  65. if (this.package === 0) {
  66. this.$message({
  67. message: '请选择套餐',
  68. type: 'warning'
  69. })
  70. return
  71. }
  72. var param = {
  73. gid: this.gid,
  74. packageid: this.package.id,
  75. packagename: this.package.package_name
  76. }
  77. var that = this
  78. this.$http.bindPackage(param, this).then(res => {
  79. if (res.code === 0) {
  80. this.$message({
  81. message: '操作成功',
  82. type: 'success',
  83. duration: 1000,
  84. onClose: function() {
  85. that.goBack()
  86. }
  87. })
  88. }
  89. })
  90. }
  91. },
  92. mounted: function() {
  93. var gid = this.$route.query.gid
  94. this.gid = gid
  95. this.getItems()
  96. }
  97. }
  98. </script>