spulist.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="80px"
  10. >
  11. <el-form-item prop="key">
  12. <el-input
  13. v-model="queryParams.key"
  14. placeholder="请输入商品名称/商品id"
  15. clearable
  16. style="width: 200px"
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="商品分类" prop="categoryId">
  21. <el-cascader
  22. v-model="queryParams.categoryId"
  23. ref="formCascader"
  24. placeholder="请选择分类"
  25. :props="categoryprops"
  26. style="width: 120px"
  27. @change="cascaderChange"
  28. />
  29. </el-form-item>
  30. <el-form-item label="类型" prop="scope">
  31. <el-select
  32. v-model="queryParams.scope"
  33. placeholder="请选择类型"
  34. style="width: 140px"
  35. >
  36. <el-option label="全部" value=""> </el-option>
  37. <el-option label="农商批发商品" :value="1"> </el-option>
  38. <el-option label="同城特价商品" :value="2"> </el-option>
  39. <el-option label="同城秒送商品" :value="3"> </el-option>
  40. <el-option label="会员专区商品" :value="4"> </el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="商品状态" prop="spuStatus">
  44. <el-select
  45. v-model="queryParams.spuStatus"
  46. placeholder="请选择商品状态"
  47. style="width: 140px"
  48. >
  49. <el-option label="全部" value=""> </el-option>
  50. <el-option label="售罄" value="2"> </el-option>
  51. <el-option label="上架" value="0"> </el-option>
  52. <el-option label="下架" value="1"> </el-option>
  53. </el-select>
  54. </el-form-item>
  55. <el-form-item>
  56. <el-button
  57. type="primary"
  58. icon="el-icon-search"
  59. size="mini"
  60. @click="handleQuery"
  61. >搜索</el-button
  62. >
  63. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  64. >重置</el-button
  65. >
  66. </el-form-item>
  67. </el-form>
  68. <el-table
  69. v-loading="loading"
  70. :data="tableList"
  71. @selection-change="handleSelectionChange"
  72. row-key="id"
  73. >
  74. <el-table-column
  75. type="selection"
  76. width="55"
  77. align="center"
  78. :selectable="checkSelectable"
  79. />
  80. <el-table-column label="商品Id" align="center" prop="id" />
  81. <el-table-column label="商品信息" align="center">
  82. <template slot-scope="scope">
  83. <div
  84. style="
  85. display: flex;
  86. flex-direction: row;
  87. justify-content: space-between;
  88. align-items: center;
  89. "
  90. >
  91. <el-image
  92. style="width: 30px; height: 30px"
  93. :src="scope.row.pic"
  94. :preview-src-list="[scope.row.pic]"
  95. >
  96. </el-image>
  97. <div
  98. :title="scope.row.spuName"
  99. style="
  100. width: 80px;
  101. height: auto;
  102. word-wrap: break-word;
  103. overflow: hidden;
  104. text-overflow: ellipsis;
  105. white-space: nowrap;
  106. "
  107. >
  108. {{ scope.row.spuName }}
  109. </div>
  110. </div>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="分类" align="center" prop="categoryName" />
  114. <el-table-column label="商品状态" align="center">
  115. <template slot-scope="scope">
  116. {{
  117. scope.row.spuStatus == 2
  118. ? "售罄"
  119. : scope.row.spuStatus == 0
  120. ? "上架"
  121. : scope.row.spuStatus == 1
  122. ? "下架"
  123. : ""
  124. }}
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="销量" align="center" prop="salesVolume" />
  128. <el-table-column label="价格" align="center" width="120">
  129. <template slot-scope="scope">
  130. {{ scope.row.originalPrice }}元/{{ scope.row.unit }}
  131. </template>
  132. </el-table-column>
  133. <el-table-column label="类型" align="center" width="120">
  134. <template slot-scope="scope">
  135. {{
  136. scope.row.scope == 1
  137. ? "农商批发商品"
  138. : scope.row.scope == 3
  139. ? "同城秒送商品"
  140. : scope.row.scope == 4
  141. ? "会员专区"
  142. : scope.row.scope == 2
  143. ? "同城特价商品"
  144. : ""
  145. }}
  146. </template>
  147. </el-table-column>
  148. </el-table>
  149. <pagination
  150. v-show="total > 0"
  151. :total="total"
  152. :page.sync="queryParams.pageNo"
  153. :limit.sync="queryParams.pageSize"
  154. @pagination="getList"
  155. />
  156. </div>
  157. </template>
  158. <script>
  159. import { getRaffleSpuListPage } from "@/api/marketing/lottery";
  160. import { getClassificationListPage } from "@/api/common/index";
  161. export default {
  162. props: ["selectData"],
  163. name: "product",
  164. data() {
  165. return {
  166. sort: {
  167. merchantClassifyId: "",
  168. },
  169. sortDialog: false,
  170. // 遮罩层
  171. loading: true,
  172. showSearch: true,
  173. total: 0,
  174. tableList: [],
  175. title: "",
  176. dialogVisible: false,
  177. // 日期范围
  178. dateRange: [],
  179. // 查询参数
  180. queryParams: {
  181. pageNo: 1,
  182. pageSize: 10,
  183. key: "",
  184. categoryId: "",
  185. categoryName: "",
  186. scope: "",
  187. },
  188. // 表单参数
  189. form: {},
  190. categoryprops: {
  191. checkStrictly: true,
  192. lazy: true,
  193. lazyLoad: this.categoryLazyLoad,
  194. },
  195. selectList: [],
  196. };
  197. },
  198. mounted() {
  199. this.getList();
  200. },
  201. methods: {
  202. checkSelectable(row) {
  203. // 如果已有选中数据,检查当前行是否已被选中且状态不为禁用
  204. if (this.selectData && this.selectData.length > 0) {
  205. const selectedIds = this.selectData.map((item) => item.id);
  206. return !selectedIds.includes(row.id) && row.status !== "禁用";
  207. }
  208. // 如果没有选中数据,直接检查行状态
  209. return row.status !== "禁用";
  210. },
  211. handleSelectionChange(val) {
  212. this.selectList = val;
  213. this.$emit("voucherChoose", val);
  214. },
  215. /** 查询参数列表 */
  216. getList() {
  217. this.loading = true;
  218. getRaffleSpuListPage(this.queryParams).then((res) => {
  219. this.tableList = res.data.records;
  220. this.total = res.data.total;
  221. this.loading = false;
  222. });
  223. },
  224. /** 搜索按钮操作 */
  225. handleQuery() {
  226. this.queryParams.pageNo = 1;
  227. this.getList();
  228. },
  229. /** 重置按钮操作 */
  230. resetQuery() {
  231. this.dateRange = [];
  232. this.resetForm("queryForm");
  233. this.handleQuery();
  234. },
  235. cascaderChange(val) {
  236. this.queryParams.categoryId = val[val.length - 1];
  237. },
  238. categoryLazyLoad(node, resolve) {
  239. let level = node.level;
  240. if (!node.data) {
  241. getClassificationListPage({ parentId: 0 }).then((res) => {
  242. //接口
  243. const nodes = Array.from(res.data).map((item, index) => ({
  244. value: item.id,
  245. label: `${item.className}`,
  246. leaf: level >= 2,
  247. }));
  248. // 通过调用resolve将子节点数据返回,通知组件数据加载完成
  249. resolve(nodes);
  250. });
  251. } else if (level == 1) {
  252. getClassificationListPage({ parentId: node.data.value }).then((res) => {
  253. const nodes = Array.from(res.data).map((item) => ({
  254. value: item.id,
  255. label: `${item.className}`,
  256. leaf: level >= 2,
  257. // level: 2,
  258. }));
  259. // 通过调用resolve将子节点数据返回,通知组件数据加载完成
  260. resolve(nodes);
  261. });
  262. } else if (level == 2) {
  263. getClassificationListPage({ parentId: node.data.value }).then((res) => {
  264. const nodes = Array.from(res.data).map((item) => ({
  265. value: item.id,
  266. label: `${item.className}`,
  267. leaf: level >= 1,
  268. level: 1,
  269. }));
  270. // 通过调用resolve将子节点数据返回,通知组件数据加载完成
  271. resolve(nodes);
  272. });
  273. } else {
  274. resolve({});
  275. }
  276. },
  277. },
  278. };
  279. </script>
  280. <style>
  281. .el-form-item {
  282. margin-bottom: 10px;
  283. }
  284. </style>