index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div style="height: calc(100vh - 114px); overflow-y: auto; overflow-x: hidden">
  3. <byTable
  4. :hideTable="true"
  5. :hidePagination="true"
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :searchConfig="searchConfig"
  10. highlight-current-row
  11. @get-list="getList"
  12. @clickReset="clickReset">
  13. </byTable>
  14. <div style="margin-bottom: 10px; display: flex">
  15. <div style="height: 30px; line-height: 30px; margin-right: 10px">
  16. <el-button type="primary" @click="handleBOM()" v-preReClick>选择bom</el-button>
  17. </div>
  18. <div style="height: 30px; line-height: 30px; margin-right: 10px">
  19. <el-button type="primary" @click="handleReset" text>重置</el-button>
  20. </div>
  21. <div style="height: 30px; line-height: 30px; margin-right: 10px">
  22. <el-button type="primary" @click="handleReplace" text>一键替换</el-button>
  23. </div>
  24. </div>
  25. <el-table :data="selectData" :cell-style="{ padding: '0' }" :row-style="{ height: '35px' }" header-row-class-name="tableHeader" style="margin-bottom: 10px">
  26. <el-table-column label="品号" prop="code" width="220" />
  27. <el-table-column label="品名" prop="name" min-width="220" />
  28. <el-table-column label="操作" align="center" width="120">
  29. <template #default="{ row, $index }">
  30. <el-button type="text" @click="handleDelete($index)">删 除</el-button>
  31. </template>
  32. </el-table-column>
  33. </el-table>
  34. <br />
  35. <el-table :data="sourceList.data" :row-style="{ height: '35px' }" header-row-class-name="tableHeader" v-loading="loading">
  36. <el-table-column label="群组品号" prop="skuCode" width="140" />
  37. <el-table-column label="SKU品号" prop="skuSpecCode" width="160" />
  38. <el-table-column label="品名" prop="skuSpecName" min-width="260" />
  39. <el-table-column label="裸垫品号" prop="bomSpecCode" width="180" />
  40. </el-table>
  41. <el-row style="padding: 10px 0" justify="end" type="flex">
  42. <el-pagination
  43. background
  44. layout="total, sizes, prev, pager, next, jumper"
  45. :current-page="sourceList.pagination.pageNum"
  46. :page-size="sourceList.pagination.pageSize"
  47. :total="sourceList.pagination.total"
  48. @current-change="handlePageChange"
  49. @size-change="handleSizeChange" />
  50. </el-row>
  51. <el-dialog title="选择BOM" v-if="openBOM" v-model="openBOM" width="84%">
  52. <SelectBOM :selectStatus="true" @selectBOM="selectBOM"></SelectBOM>
  53. <template #footer>
  54. <el-button @click="openBOM = false" size="large">关 闭</el-button>
  55. </template>
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script setup>
  60. import byTable from "/src/components/byTable/index";
  61. import SelectBOM from "/src/views/group/BOM/management/index";
  62. import { ElMessage, ElMessageBox } from "element-plus";
  63. const { proxy } = getCurrentInstance();
  64. const props = defineProps({
  65. type: String,
  66. });
  67. const sourceList = ref({
  68. data: [],
  69. pagination: {
  70. total: 0,
  71. pageNum: 1,
  72. pageSize: 10,
  73. skuCode: "",
  74. skuSpecCode: "",
  75. bomSpecCode: "",
  76. length: "",
  77. width: "",
  78. height: "",
  79. type: props.type,
  80. },
  81. });
  82. const loading = ref(false);
  83. const searchConfig = computed(() => {
  84. return [
  85. {
  86. type: "input",
  87. prop: "skuCode",
  88. label: "群组品号",
  89. },
  90. {
  91. type: "input",
  92. prop: "skuSpecCode",
  93. label: "SKU品号",
  94. },
  95. {
  96. type: "input",
  97. prop: "bomSpecCode",
  98. label: "BOM品号",
  99. },
  100. {
  101. type: "input",
  102. prop: "length",
  103. label: "长",
  104. },
  105. {
  106. type: "input",
  107. prop: "width",
  108. label: "宽",
  109. },
  110. {
  111. type: "input",
  112. prop: "height",
  113. label: "高",
  114. },
  115. ];
  116. });
  117. const config = computed(() => {
  118. return [];
  119. });
  120. const getList = async (req, status) => {
  121. if (status) {
  122. sourceList.value.pagination = {
  123. pageNum: sourceList.value.pagination.pageNum,
  124. pageSize: sourceList.value.pagination.pageSize,
  125. };
  126. } else {
  127. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  128. }
  129. loading.value = true;
  130. proxy.post("/sku/getReplacePrincipalMaterialPage", sourceList.value.pagination).then((res) => {
  131. sourceList.value.data = res.rows;
  132. sourceList.value.pagination.total = res.total;
  133. setTimeout(() => {
  134. loading.value = false;
  135. }, 200);
  136. });
  137. };
  138. getList();
  139. const clickReset = () => {
  140. getList("", true);
  141. };
  142. const handlePageChange = (val) => {
  143. getList({ pageNum: val });
  144. };
  145. const handleSizeChange = (val) => {
  146. getList({ pageNum: 1, pageSize: val });
  147. };
  148. const openBOM = ref(false);
  149. const selectData = ref([]);
  150. const handleBOM = () => {
  151. openBOM.value = true;
  152. };
  153. const selectBOM = (item) => {
  154. selectData.value = [item];
  155. ElMessage({ message: "选择完成", type: "success" });
  156. openBOM.value = false;
  157. };
  158. const handleDelete = (index) => {
  159. selectData.value.splice(index, 1);
  160. };
  161. const handleReset = () => {
  162. selectData.value = [];
  163. };
  164. const handleReplace = () => {
  165. if (selectData.value && selectData.value.length > 0) {
  166. ElMessageBox.confirm("是否确认替换所有BOM", "提示", {
  167. confirmButtonText: "确定",
  168. cancelButtonText: "取消",
  169. type: "warning",
  170. })
  171. .then(() => {
  172. proxy.post("/sku/replacePrincipalMaterial", { ...sourceList.value.pagination, replaceBomSpecId: selectData.value[0].id }).then(() => {
  173. ElMessage({ message: "替换成功", type: "success" });
  174. getList();
  175. });
  176. })
  177. .catch(() => {});
  178. } else {
  179. return ElMessage("请选择BOM");
  180. }
  181. };
  182. </script>
  183. <style lang="scss" scoped></style>