com-select-goods.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <style>
  2. .com-select-goods .el-input__inner {
  3. border-color: #DCDFE6 !important;
  4. }
  5. </style>
  6. <template id="com-select-goods">
  7. <div class="com-select-goods">
  8. <el-dialog title="选择商品" :visible.sync="dialogSelectVisible" top="5vh" width="960px" append-to-body>
  9. <el-input placeholder="根据名称搜索" v-model="search.keyword" @keyup.enter.native="searchList" prop="rr">
  10. <el-button slot="append" @click="searchList">搜索</el-button>
  11. </el-input>
  12. <el-table v-loading="listLoading" :data="list" stripe height="544"
  13. style="margin-top:27px"
  14. @selection-change="handleSelectionChange" border>
  15. <el-table-column v-if="false" type="selection" width="55"></el-table-column>
  16. <el-table-column v-if="false" label="ID" width="100" prop="id"></el-table-column>
  17. <el-table-column width="100" label="ID" props="id">
  18. <template slot-scope="scope">
  19. <el-radio-group v-model="radioSelection" @change="handleSelectionChange(scope.row)">
  20. <el-radio :label="scope.row.id"></el-radio>
  21. </el-radio-group>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="名称" width="600">
  25. <template slot-scope="scope">
  26. <div flex="dir:left cross:center">
  27. <el-image style="height: 50px;width: 50px;margin-right: 10px" class="cover-pic" :src="scope.row.cover_pic"></el-image>
  28. <com-ellipsis :line="2">{{scope.row.goods_name}}</com-ellipsis>
  29. </div>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="成本价" width="100" prop="cost_price"></el-table-column>
  33. <el-table-column label="库存" width="100" prop="stock"></el-table-column>
  34. </el-table>
  35. <div slot="footer" class="dialog-footer">
  36. <div style="float: left">
  37. <el-pagination
  38. v-if="pagination"
  39. background
  40. :page-size="pagination.pageSize"
  41. @current-change="getList"
  42. layout="prev, pager, next"
  43. :total="pagination.totalCount">
  44. </el-pagination>
  45. </div>
  46. <el-button v-if="false" @click="dialogSelectVisible = false">取 消</el-button>
  47. <el-button type="primary" @click="confirm">确 定</el-button>
  48. </div>
  49. </el-dialog>
  50. <div @click="showModel">
  51. <slot></slot>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. Vue.component('com-select-goods', {
  57. template: '#com-select-goods',
  58. props: {
  59. url: {
  60. type: String,
  61. default: 'mall/goods/index'
  62. },
  63. },
  64. data() {
  65. return {
  66. pagination: null,
  67. dialogSelectVisible: false,
  68. listLoading: false,
  69. radioSelection: 0,
  70. list: [],
  71. search: {
  72. keyword: '',
  73. },
  74. goodsData: {},
  75. }
  76. },
  77. methods: {
  78. searchList() {
  79. this.getList();
  80. },
  81. showModel() {
  82. this.dialogSelectVisible = true;
  83. this.getList();
  84. },
  85. getList(page = 1) {
  86. this.listLoading = true;
  87. request({
  88. params: {
  89. r: this.url,
  90. search: this.search,
  91. page,
  92. },
  93. method: 'get'
  94. }).then(e => {
  95. this.listLoading = false;
  96. if (e.data.code === 0) {
  97. this.list = e.data.data.list;
  98. this.pagination = e.data.data.pagination;
  99. this.pagination.pageSize = e.data.data.page_size;
  100. }
  101. }).catch(e => {
  102. this.listLoading = false;
  103. })
  104. },
  105. handleSelectionChange(val) {
  106. this.multipleSelection = val;
  107. },
  108. confirm() {
  109. this.$emit('selected', this.multipleSelection);
  110. this.dialogSelectVisible = false;
  111. this.pagination = null;
  112. }
  113. }
  114. })
  115. </script>