GoodsAdd.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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>
  26. <div class="dialog-search">
  27. <div>商品类型:</div>
  28. <el-select v-model="queryParams.type" placeholder="请选择商品类型" clearable @change="queryParams.pageNum = 1;getGoodsList()">
  29. <el-option label="全部" value=""/>
  30. <el-option label="实物商品" value="1"/>
  31. <el-option label="卡密商品" value="2"/>
  32. </el-select>
  33. <div class="ge"></div>
  34. <el-button
  35. type="primary"
  36. icon="el-icon-search"
  37. size="mini"
  38. @click="getGoodsList()"
  39. >查询</el-button
  40. >
  41. </div>
  42. <el-table
  43. v-loading="loading"
  44. :data="goodsList"
  45. row-key="goodsId"
  46. @selection-change="handleSelectionGoods"
  47. class="el-table"
  48. >
  49. <el-table-column
  50. type="selection"
  51. width="55"
  52. align="center"
  53. fixed="left"
  54. :reserve-selection="true"
  55. />
  56. <el-table-column label="商品ID" prop="goodsId" />
  57. <el-table-column label="商品图片">
  58. <template slot-scope="{ row }">
  59. <div v-if="row.picUrl">
  60. <el-image
  61. style="width: 100px; height: 100px"
  62. :src="row.picUrl.split(',')[0]"
  63. :preview-src-list="row.picUrl.split(',')"
  64. >
  65. </el-image>
  66. </div>
  67. <p v-else>-</p>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="商品名称" prop="title" min-width="85" />
  71. <el-table-column label="商品价格" min-width="85">
  72. <template slot-scope="scope">
  73. <div>¥{{ $numberFormat(scope.row.value) }}</div>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="商品类型" prop="type" min-width="85">
  77. <template slot-scope="scope">
  78. <div v-if="scope.row.type == 1">实物商品</div>
  79. <div v-else-if="scope.row.type == 2">卡密商品</div>
  80. <div v-else-if="scope.row.type == 3">采购商品</div>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="是否支持兑换" prop="exchangeShow" min-width="85">
  84. <template slot-scope="scope">
  85. <div v-if="scope.row.exchangeShow == 1">支持兑换</div>
  86. <div v-else-if="scope.row.exchangeShow == 0">不支持兑换</div>
  87. <div v-else-if="scope.row.exchangeShow == 2">盲票商品</div>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="商品库存" prop="quantity" width="80" />
  91. </el-table>
  92. <pagination
  93. v-show="goodsTotal > 0"
  94. :total="goodsTotal"
  95. :page.sync="pageParams.pageNum"
  96. :limit.sync="pageParams.pageSize"
  97. @pagination="getGoodsList"
  98. />
  99. <div class="dialog-btn">
  100. <el-button size="small" @click="close"> 取 消 </el-button>
  101. <div class="ge"></div>
  102. <el-button type="primary" size="small" @click="confirmGoods">
  103. 确 认
  104. </el-button>
  105. </div>
  106. </el-dialog>
  107. </div>
  108. </template>
  109. <script>
  110. import { publicFileGetUrl } from "@/api/common";
  111. import { getGoodsList } from "@/api/business/goods";
  112. import { accMul } from '@/utils/util'
  113. export default {
  114. name: "GoodsAdd",
  115. props: {
  116. dialogVisible: {
  117. type: Boolean,
  118. default: false,
  119. },
  120. },
  121. data() {
  122. return {
  123. loading: false,
  124. goodsTitle: "", // 商品名称
  125. queryParams:{},
  126. goodsList: [], // 商品列表
  127. goodsTotal: 0, // 商品总数
  128. selectGoodsList: [], // 选中商品
  129. pageParams: {
  130. pageNum: 1,
  131. pageSize: 10,
  132. },
  133. };
  134. },
  135. created() {
  136. this.getGoodsList();
  137. },
  138. methods: {
  139. // 商品列表
  140. getGoodsList() {
  141. this.loading = true;
  142. getGoodsList(
  143. "pageNum=" +
  144. this.pageParams.pageNum +
  145. "&pageSize=" +
  146. this.pageParams.pageSize +
  147. "&",
  148. { isExcludePurchaseGoods: true, type: this.queryParams.type, 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,}
  149. ).then((res) => {
  150. this.goodsList = res.rows.map((item) => {
  151. return {
  152. ...item,
  153. picUrl: publicFileGetUrl + item.picUrl.split(",")[0],
  154. };
  155. });
  156. this.goodsTotal = res.total;
  157. this.loading = false;
  158. });
  159. },
  160. // 选中商品
  161. handleSelectionGoods(e) {
  162. this.selectGoodsList = e.map((item) => {
  163. return {
  164. prizeType: "goods",
  165. // quantity: 1,
  166. goodsId: item.goodsId,
  167. picUrl: item.picUrl,
  168. title: item.title,
  169. sortWeight: 100
  170. };
  171. });
  172. },
  173. // 确认选中商品
  174. confirmGoods() {
  175. if(!this.selectGoodsList.length) {
  176. this.msgInfo('请选择商品')
  177. return
  178. }
  179. this.$emit("confirmGoods", this.selectGoodsList);
  180. },
  181. close() {
  182. this.$emit("close");
  183. },
  184. },
  185. };
  186. </script>
  187. <style lang="scss" scoped>
  188. .dialog-search {
  189. display: flex;
  190. line-height: 32px;
  191. margin-bottom: 20px;
  192. .ge {
  193. width: 20px;
  194. }
  195. }
  196. .dialog-btn {
  197. display: flex;
  198. align-content: center;
  199. justify-content: flex-end;
  200. padding: 40px 0 0;
  201. .ge {
  202. width: 20px;
  203. }
  204. }
  205. </style>