com-pick-list.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <style>
  2. .form-body {
  3. background-color: #fff;
  4. padding: 20px 50% 20px 0;
  5. }
  6. </style>
  7. <div id="com-pick-list" v-cloak>
  8. <el-table :data="list" v-loading="listLoading" size="small" ref="singleTable">
  9. <el-table-column prop="id" label="选择ID" width="100">
  10. <template slot-scope="scope">
  11. <el-radio v-model="pick_value" :label="scope.row.id" @change="handleChange">{{ scope.row.id }}</el-radio>
  12. </template>
  13. </el-table-column>
  14. <el-table-column prop="title" label="标题">
  15. <template slot-scope="scope">
  16. <div>{{ scope.row.title }}</div>
  17. </template>
  18. </el-table-column>
  19. <el-table-column prop="created_at" label="时间">
  20. <template slot-scope="scope">
  21. <div>{{ scope.row.created_at|dateTimeFormat('Y-m-d H:i:s') }}</div>
  22. </template>
  23. </el-table-column>
  24. </el-table>
  25. <div style="text-align: right;margin: 20px 0;">
  26. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  27. </div>
  28. </div>
  29. <script>
  30. Vue.component('com-pick-list', {
  31. template: '#com-pick-list',
  32. props: {
  33. type: {
  34. type: String,
  35. default: 'diy',// single|单个,multiple|多个
  36. },
  37. },
  38. data() {
  39. return {
  40. page: 1,
  41. pageCount: 0,
  42. listLoading: false,
  43. list: [],
  44. route: '',
  45. ruturn_value: '',
  46. pick_value: 0,
  47. };
  48. },
  49. created() {
  50. console.info(this.type,'type');
  51. this.loadData();
  52. },
  53. methods: {
  54. pagination(currentPage) {
  55. let self = this;
  56. self.page = currentPage;
  57. self.loadData();
  58. },
  59. loadData() {
  60. this.listLoading = true;
  61. request({
  62. params: {
  63. r: 'mall/link/get-pick-list',
  64. type: this.type,
  65. page: self.page,
  66. },
  67. method: 'get',
  68. }).then(e => {
  69. this.listLoading = false;
  70. if (e.data.code === 0) {
  71. this.list = e.data.data.list;
  72. self.pageCount = e.data.data.page_count;
  73. } else {
  74. this.$message.error(e.data.msg);
  75. }
  76. }).catch(e => {
  77. });
  78. },
  79. handleChange(val) {
  80. this.ruturn_value = this.route + val;
  81. }
  82. }
  83. });
  84. </script>