index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <el-card class="box-card">
  3. <byTable
  4. :source="sourceList.data"
  5. :pagination="sourceList.pagination"
  6. :config="config"
  7. :loading="loading"
  8. :searchConfig="searchConfig"
  9. highlight-current-row
  10. :action-list="[
  11. {
  12. text: '新增赠品',
  13. action: () => clickModal(),
  14. },
  15. ]"
  16. @get-list="getList"
  17. @clickReset="clickReset">
  18. <template #specImgUrl="{ item }">
  19. <div>
  20. <el-image
  21. style="cursor: pointer; border-radius: 5px; width: 60px"
  22. v-if="item.specImgUrl"
  23. :src="item.specImgUrl"
  24. fit="scale-down"
  25. @click="openFile(item.specImgUrl)"
  26. lazy>
  27. </el-image>
  28. </div>
  29. </template>
  30. </byTable>
  31. <el-dialog title="选择赠品" v-if="openGiveaway" v-model="openGiveaway" width="90%">
  32. <SelectProduct :selectStatus="true" :type="'null'" @selectProduct="selectGiveaway"></SelectProduct>
  33. <template #footer>
  34. <el-button @click="openGiveaway = false" size="large">关 闭</el-button>
  35. </template>
  36. </el-dialog>
  37. </el-card>
  38. </template>
  39. <script setup>
  40. import byTable from "/src/components/byTable/index";
  41. import { ElMessage, ElMessageBox } from "element-plus";
  42. import SelectProduct from "/src/views/group/product/management/index";
  43. const { proxy } = getCurrentInstance();
  44. const sourceList = ref({
  45. data: [],
  46. pagination: {
  47. total: 0,
  48. pageNum: 1,
  49. pageSize: 10,
  50. code: "",
  51. name: "",
  52. },
  53. });
  54. const loading = ref(false);
  55. const searchConfig = computed(() => {
  56. return [
  57. {
  58. type: "input",
  59. prop: "code",
  60. label: "品号",
  61. },
  62. {
  63. type: "input",
  64. prop: "name",
  65. label: "品名",
  66. },
  67. ];
  68. });
  69. const config = computed(() => {
  70. return [
  71. {
  72. attrs: {
  73. label: "规格图",
  74. slot: "specImgUrl",
  75. width: 100,
  76. },
  77. },
  78. {
  79. attrs: {
  80. label: "品号",
  81. prop: "code",
  82. width: 200,
  83. },
  84. },
  85. {
  86. attrs: {
  87. label: "品名",
  88. prop: "name",
  89. },
  90. },
  91. {
  92. attrs: {
  93. label: "操作",
  94. width: 80,
  95. align: "center",
  96. fixed: "right",
  97. },
  98. renderHTML(row) {
  99. return [
  100. {
  101. attrs: {
  102. label: "删除",
  103. type: "danger",
  104. text: true,
  105. },
  106. el: "button",
  107. click() {
  108. clickDelete(row);
  109. },
  110. },
  111. ];
  112. },
  113. },
  114. ];
  115. });
  116. const getList = (req, status) => {
  117. if (status) {
  118. sourceList.value.pagination = {
  119. pageNum: sourceList.value.pagination.pageNum,
  120. pageSize: sourceList.value.pagination.pageSize,
  121. };
  122. } else {
  123. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  124. }
  125. loading.value = true;
  126. proxy.post("/skuSpec/giftPage", sourceList.value.pagination).then((res) => {
  127. sourceList.value.data = res.rows;
  128. sourceList.value.pagination.total = res.total;
  129. setTimeout(() => {
  130. loading.value = false;
  131. }, 200);
  132. });
  133. };
  134. getList();
  135. const clickReset = () => {
  136. getList("", true);
  137. };
  138. const clickDelete = (row) => {
  139. ElMessageBox.confirm("你是否确认此操作", "提示", {
  140. confirmButtonText: "确定",
  141. cancelButtonText: "取消",
  142. type: "warning",
  143. })
  144. .then(() => {
  145. proxy.post("/skuSpec/giftDelete", { id: row.id }).then(() => {
  146. ElMessage({ message: "删除成功", type: "success" });
  147. getList();
  148. });
  149. })
  150. .catch(() => {});
  151. };
  152. const openFile = (path) => {
  153. window.open(path, "_blank");
  154. };
  155. const openGiveaway = ref(false);
  156. const clickModal = () => {
  157. openGiveaway.value = true;
  158. };
  159. const selectGiveaway = (item) => {
  160. proxy.post("/skuSpec/giftAdd", { id: item.id }).then(() => {
  161. openGiveaway.value = false;
  162. ElMessage({ message: "添加成功", type: "success" });
  163. getList();
  164. });
  165. };
  166. </script>
  167. <style lang="scss" scoped>
  168. :deep(.el-dialog) {
  169. margin-top: 10px !important;
  170. margin-bottom: 10px !important;
  171. }
  172. </style>