GoodsAdd.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="添加实物奖品"
  5. width="1000px"
  6. :visible.sync="dialogVisible"
  7. :before-close="close"
  8. >
  9. <div class="dialog-search">
  10. <div>商品名称:</div>
  11. <el-input
  12. v-model="goodsTitle"
  13. placeholder="请输入商品名称"
  14. clearable
  15. size="small"
  16. style="width: 220px" @clear="queryParams.pageNum = 1;getGoodsList()"
  17. @keyup.enter.native="queryParams.pageNum = 1;getGoodsList()"
  18. />
  19. <div style="margin-left: 20px">商品价格:</div>
  20. <!-- <el-input v-model="minValue" placeholder="最低价格" clearable @keyup.enter.native="pageParams.pageNum = 1;getList()" />-->
  21. <el-input style="width: 220px" v-model="queryParams.minValue" @clear="queryParams.pageNum = 1;getGoodsList()" placeholder="最低价格" clearable @keyup.enter.native="queryParams.pageNum = 1;getGoodsList()"/>
  22. <div style="width: 20px;text-align: center">-</div>
  23. <!-- <el-input v-model="maxValue" placeholder="最高价格" clearable @keyup.enter.native="pageParams.pageNum = 1;getList()" />-->
  24. <el-input style="width: 220px" v-model="queryParams.maxValue" @clear="queryParams.pageNum = 1;getGoodsList()" placeholder="最高价格" clearable @keyup.enter.native="queryParams.pageNum = 1;getGoodsList()"/>
  25. <div class="ge"></div>
  26. <el-button
  27. type="primary"
  28. icon="el-icon-search"
  29. size="mini"
  30. @click="getGoodsList()"
  31. >查询</el-button
  32. >
  33. </div>
  34. <el-table
  35. v-loading="loading"
  36. :data="goodsList"
  37. @selection-change="handleSelectionGoods"
  38. class="el-table"
  39. >
  40. <el-table-column
  41. type="selection"
  42. width="55"
  43. align="center"
  44. fixed="left"
  45. />
  46. <el-table-column label="商品ID" prop="goodsId" />
  47. <el-table-column label="商品图片">
  48. <template slot-scope="{ row }">
  49. <div v-if="row.picUrl">
  50. <el-image
  51. style="width: 100px; height: 100px"
  52. :src="row.picUrl.split(',')[0]"
  53. :preview-src-list="row.picUrl.split(',')"
  54. >
  55. </el-image>
  56. </div>
  57. <p v-else>-</p>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="商品名称" prop="title" min-width="85" />
  61. <el-table-column label="商品价格" min-width="85">
  62. <template slot-scope="scope">
  63. <div>¥{{ $numberFormat(scope.row.value) }}</div>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="商品库存" prop="quantity" width="80" />
  67. </el-table>
  68. <pagination
  69. v-show="goodsTotal > 0"
  70. :total="goodsTotal"
  71. :page.sync="pageParams.pageNum"
  72. :limit.sync="pageParams.pageSize"
  73. @pagination="getGoodsList"
  74. />
  75. <div class="dialog-btn">
  76. <el-button size="small" @click="close"> 取 消 </el-button>
  77. <div class="ge"></div>
  78. <el-button type="primary" size="small" @click="confirmGoods">
  79. 确 认
  80. </el-button>
  81. </div>
  82. </el-dialog>
  83. </div>
  84. </template>
  85. <script>
  86. import { publicFileGetUrl } from "@/api/common";
  87. import { getGoodsList } from "@/api/business/goods";
  88. import { accMul } from '@/utils/util'
  89. export default {
  90. name: "GoodsAdd",
  91. props: {
  92. dialogVisible: {
  93. type: Boolean,
  94. default: false,
  95. },
  96. },
  97. data() {
  98. return {
  99. loading: false,
  100. goodsTitle: "", // 商品名称
  101. queryParams:{},
  102. goodsList: [], // 商品列表
  103. goodsTotal: 0, // 商品总数
  104. selectGoodsList: [], // 选中商品
  105. pageParams: {
  106. pageNum: 1,
  107. pageSize: 10,
  108. },
  109. };
  110. },
  111. created() {
  112. this.getGoodsList();
  113. },
  114. methods: {
  115. // 商品列表
  116. getGoodsList() {
  117. this.loading = true;
  118. getGoodsList(
  119. "pageNum=" +
  120. this.pageParams.pageNum +
  121. "&pageSize=" +
  122. this.pageParams.pageSize +
  123. "&",
  124. { title: this.goodsTitle, status: "on", minValue: this.queryParams.minValue?accMul(this.queryParams.minValue, 100):this.queryParams.minValue, maxValue: this.queryParams.maxValue?accMul(this.queryParams.maxValue, 100):this.queryParams.maxValue,}
  125. ).then((res) => {
  126. this.goodsList = res.rows.map((item) => {
  127. return {
  128. ...item,
  129. picUrl: publicFileGetUrl + item.picUrl.split(",")[0],
  130. };
  131. });
  132. this.goodsTotal = res.total;
  133. this.loading = false;
  134. });
  135. },
  136. // 选中商品
  137. handleSelectionGoods(e) {
  138. this.selectGoodsList = e.map((item) => {
  139. return {
  140. prizeType: "goods",
  141. // quantity: 1,
  142. goodsId: item.goodsId,
  143. picUrl: item.picUrl,
  144. title: item.title,
  145. sortWeight: 100
  146. };
  147. });
  148. },
  149. // 确认选中商品
  150. confirmGoods() {
  151. this.$emit("confirmGoods", this.selectGoodsList);
  152. },
  153. close() {
  154. this.$emit("close");
  155. },
  156. },
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .dialog-search {
  161. display: flex;
  162. line-height: 32px;
  163. margin-bottom: 20px;
  164. .ge {
  165. width: 20px;
  166. }
  167. }
  168. .dialog-btn {
  169. display: flex;
  170. align-content: center;
  171. justify-content: flex-end;
  172. padding: 40px 0 0;
  173. .ge {
  174. width: 20px;
  175. }
  176. }
  177. </style>