index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <el-card class="box-card" v-loading="loadingCard">
  3. <byTable
  4. :hidePagination="true"
  5. :source="sourceList.data"
  6. :config="config"
  7. :loading="loading"
  8. highlight-current-row
  9. :action-list="[
  10. // {
  11. // text: '新增',
  12. // action: () => clickModal(),
  13. // },
  14. {
  15. text: '应用包材配置',
  16. action: () => clickUse(),
  17. },
  18. ]"
  19. @get-list="getList">
  20. </byTable>
  21. <el-dialog :title="modalType == 'add' ? '新增包材配置' : '编辑包材配置'" v-if="openDialog" v-model="openDialog" width="500">
  22. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  23. <template #oppMembraneId>
  24. <div style="width: 100%">
  25. <el-button
  26. v-if="!formData.data.oppMembraneId || formData.data.oppMembraneId === '0'"
  27. type="primary"
  28. size="small"
  29. @click="handleOpen('oppMembrane', '1682221249268375554')"
  30. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  31. 选择BOM
  32. </el-button>
  33. <div style="width: 100%; display: flex; align-items: center" v-else>
  34. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('oppMembrane')"><Remove /></el-icon>
  35. <span>{{ formData.data.oppMembraneCode }}</span>
  36. </div>
  37. </div>
  38. </template>
  39. <template #peBagId>
  40. <div style="width: 100%">
  41. <el-button
  42. v-if="!formData.data.peBagId || formData.data.peBagId === '0'"
  43. type="primary"
  44. size="small"
  45. @click="handleOpen('peBag', '1682221303530086402')"
  46. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  47. 选择BOM
  48. </el-button>
  49. <div style="width: 100%; display: flex; align-items: center" v-else>
  50. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('peBag')"><Remove /></el-icon>
  51. <span>{{ formData.data.peBagCode }}</span>
  52. </div>
  53. </div>
  54. </template>
  55. <template #meshBagId>
  56. <div style="width: 100%">
  57. <el-button
  58. v-if="!formData.data.meshBagId || formData.data.meshBagId === '0'"
  59. type="primary"
  60. size="small"
  61. @click="handleOpen('meshBag', '1682221356147630081')"
  62. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  63. 选择BOM
  64. </el-button>
  65. <div style="width: 100%; display: flex; align-items: center" v-else>
  66. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('meshBag')"><Remove /></el-icon>
  67. <span>{{ formData.data.meshBagCode }}</span>
  68. </div>
  69. </div>
  70. </template>
  71. <template #bubblePackId>
  72. <div style="width: 100%">
  73. <el-button
  74. v-if="!formData.data.bubblePackId || formData.data.bubblePackId === '0'"
  75. type="primary"
  76. size="small"
  77. @click="handleOpen('bubblePack', '1682221453145104386')"
  78. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  79. 选择BOM
  80. </el-button>
  81. <div style="width: 100%; display: flex; align-items: center" v-else>
  82. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('bubblePack')"><Remove /></el-icon>
  83. <span>{{ formData.data.bubblePackCode }}</span>
  84. </div>
  85. </div>
  86. </template>
  87. <template #suspendersId>
  88. <div style="width: 100%">
  89. <el-button
  90. v-if="!formData.data.suspendersId || formData.data.suspendersId === '0'"
  91. type="primary"
  92. size="small"
  93. @click="handleOpen('suspenders', '1682221651040755714')"
  94. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  95. 选择BOM
  96. </el-button>
  97. <div style="width: 100%; display: flex; align-items: center" v-else>
  98. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('suspenders')"><Remove /></el-icon>
  99. <span>{{ formData.data.suspendersCode }}</span>
  100. </div>
  101. </div>
  102. </template>
  103. <template #colouredPaperId>
  104. <div style="width: 100%">
  105. <el-button
  106. v-if="!formData.data.colouredPaperId || formData.data.colouredPaperId === '0'"
  107. type="primary"
  108. size="small"
  109. @click="handleOpen('colouredPaper', '1682221201491058690')"
  110. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  111. 选择BOM
  112. </el-button>
  113. <div style="width: 100%; display: flex; align-items: center" v-else>
  114. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('colouredPaper')"><Remove /></el-icon>
  115. <span>{{ formData.data.colouredPaperCode }}</span>
  116. </div>
  117. </div>
  118. </template>
  119. <template #selfAdhesiveStickerId>
  120. <div style="width: 100%">
  121. <el-button
  122. v-if="!formData.data.selfAdhesiveStickerId || formData.data.selfAdhesiveStickerId === '0'"
  123. type="primary"
  124. size="small"
  125. @click="handleOpen('selfAdhesiveSticker', '1697442459841290241')"
  126. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  127. 选择BOM
  128. </el-button>
  129. <div style="width: 100%; display: flex; align-items: center" v-else>
  130. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('selfAdhesiveSticker')"><Remove /></el-icon>
  131. <span>{{ formData.data.selfAdhesiveStickerCode }}</span>
  132. </div>
  133. </div>
  134. </template>
  135. <template #dropId>
  136. <div style="width: 100%">
  137. <el-button
  138. v-if="!formData.data.dropId || formData.data.dropId === '0'"
  139. type="primary"
  140. size="small"
  141. @click="handleOpen('drop', '1697442971286331393')"
  142. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  143. 选择BOM
  144. </el-button>
  145. <div style="width: 100%; display: flex; align-items: center" v-else>
  146. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('drop')"><Remove /></el-icon>
  147. <span>{{ formData.data.dropCode }}</span>
  148. </div>
  149. </div>
  150. </template>
  151. <template #logisticsPackagingMaterialId>
  152. <div style="width: 100%">
  153. <el-button
  154. v-if="!formData.data.logisticsPackagingMaterialId || formData.data.logisticsPackagingMaterialId === '0'"
  155. type="primary"
  156. size="small"
  157. @click="handleOpen('logisticsPackagingMaterial', '1682221528948760578')"
  158. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  159. 选择BOM
  160. </el-button>
  161. <div style="width: 100%; display: flex; align-items: center" v-else>
  162. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('logisticsPackagingMaterial')"><Remove /></el-icon>
  163. <span>{{ formData.data.logisticsPackagingMaterialCode }}</span>
  164. </div>
  165. </div>
  166. </template>
  167. <template #otherPackingMaterialId>
  168. <div style="width: 100%">
  169. <el-button
  170. v-if="!formData.data.otherPackingMaterialId || formData.data.otherPackingMaterialId === '0'"
  171. type="primary"
  172. size="small"
  173. @click="handleOpen('otherPackingMaterial', '1682221581453058049')"
  174. style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
  175. 选择BOM
  176. </el-button>
  177. <div style="width: 100%; display: flex; align-items: center" v-else>
  178. <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('otherPackingMaterial')"><Remove /></el-icon>
  179. <span>{{ formData.data.otherPackingMaterialCode }}</span>
  180. </div>
  181. </div>
  182. </template>
  183. </byForm>
  184. <template #footer>
  185. <el-button @click="openDialog = false" size="large">取 消</el-button>
  186. <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
  187. </template>
  188. </el-dialog>
  189. <el-dialog title="选择BOM" v-if="openBOM" v-model="openBOM" width="84%">
  190. <SelectBOM :selectStatus="true" :expressStatus="true" :bomClassifyId="bomClassifyId" @selectBOM="selectBOM"></SelectBOM>
  191. <template #footer>
  192. <el-button @click="openBOM = false" size="large">关 闭</el-button>
  193. </template>
  194. </el-dialog>
  195. </el-card>
  196. </template>
  197. <script setup>
  198. import byTable from "/src/components/byTable/index";
  199. import byForm from "/src/components/byForm/index";
  200. import { ElMessage } from "element-plus";
  201. import SelectBOM from "/src/views/group/BOM/management/index";
  202. const { proxy } = getCurrentInstance();
  203. const skuList = ref([]);
  204. const sourceList = ref({
  205. data: [],
  206. });
  207. const loading = ref(false);
  208. const config = computed(() => {
  209. return [
  210. {
  211. attrs: {
  212. label: "尺寸",
  213. prop: "spec",
  214. align: "center",
  215. width: 180,
  216. },
  217. },
  218. {
  219. attrs: {
  220. label: "OPP膜",
  221. prop: "oppMembraneCode",
  222. align: "center",
  223. },
  224. render(val) {
  225. if (val) {
  226. return val;
  227. }
  228. return "-";
  229. },
  230. },
  231. {
  232. attrs: {
  233. label: "PE袋",
  234. prop: "peBagCode",
  235. align: "center",
  236. },
  237. render(val) {
  238. if (val) {
  239. return val;
  240. }
  241. return "-";
  242. },
  243. },
  244. {
  245. attrs: {
  246. label: "网包",
  247. prop: "meshBagCode",
  248. align: "center",
  249. },
  250. render(val) {
  251. if (val) {
  252. return val;
  253. }
  254. return "-";
  255. },
  256. },
  257. {
  258. attrs: {
  259. label: "气泡袋",
  260. prop: "bubblePackCode",
  261. align: "center",
  262. },
  263. render(val) {
  264. if (val) {
  265. return val;
  266. }
  267. return "-";
  268. },
  269. },
  270. {
  271. attrs: {
  272. label: "松紧圈/背带",
  273. prop: "suspendersCode",
  274. align: "center",
  275. },
  276. render(val) {
  277. if (val) {
  278. return val;
  279. }
  280. return "-";
  281. },
  282. },
  283. {
  284. attrs: {
  285. label: "彩纸",
  286. prop: "colouredPaperCode",
  287. align: "center",
  288. },
  289. render(val) {
  290. if (val) {
  291. return val;
  292. }
  293. return "-";
  294. },
  295. },
  296. {
  297. attrs: {
  298. label: "不干胶",
  299. prop: "selfAdhesiveStickerCode",
  300. align: "center",
  301. },
  302. render(val) {
  303. if (val) {
  304. return val;
  305. }
  306. return "-";
  307. },
  308. },
  309. {
  310. attrs: {
  311. label: "吊牌",
  312. prop: "dropCode",
  313. align: "center",
  314. },
  315. render(val) {
  316. if (val) {
  317. return val;
  318. }
  319. return "-";
  320. },
  321. },
  322. {
  323. attrs: {
  324. label: "快递包材",
  325. prop: "logisticsPackagingMaterialCode",
  326. align: "center",
  327. },
  328. render(val) {
  329. if (val) {
  330. return val;
  331. }
  332. return "-";
  333. },
  334. },
  335. {
  336. attrs: {
  337. label: "其他包材",
  338. prop: "otherPackingMaterialCode",
  339. align: "center",
  340. },
  341. render(val) {
  342. if (val) {
  343. return val;
  344. }
  345. return "-";
  346. },
  347. },
  348. {
  349. attrs: {
  350. label: "操作",
  351. width: 80,
  352. align: "center",
  353. fixed: "right",
  354. },
  355. renderHTML(row) {
  356. return [
  357. {
  358. attrs: {
  359. label: "编辑",
  360. type: "primary",
  361. text: true,
  362. },
  363. el: "button",
  364. click() {
  365. clickUpdate(row);
  366. },
  367. },
  368. ];
  369. },
  370. },
  371. ];
  372. });
  373. const getDemandData = () => {
  374. proxy.post("/sku/list", {}).then((res) => {
  375. if (res && res.length > 0) {
  376. skuList.value = res.map((item) => {
  377. return {
  378. value: item.id,
  379. label: item.code,
  380. };
  381. });
  382. }
  383. });
  384. };
  385. getDemandData();
  386. const getList = async () => {
  387. loading.value = true;
  388. proxy.post("/skuDefaultPackageSpec/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  389. sourceList.value.data = res.rows;
  390. setTimeout(() => {
  391. loading.value = false;
  392. }, 200);
  393. });
  394. };
  395. getList();
  396. const modalType = ref("add");
  397. const openDialog = ref(false);
  398. const submit = ref(null);
  399. const formOption = reactive({
  400. inline: true,
  401. labelWidth: "80px",
  402. itemWidth: 100,
  403. rules: [],
  404. labelPosition: "right",
  405. });
  406. const formData = reactive({
  407. data: {},
  408. });
  409. const formConfig = computed(() => {
  410. return [
  411. {
  412. type: "input",
  413. prop: "spec",
  414. label: "规格",
  415. disabled: modalType.value === "edit" ? true : false,
  416. },
  417. {
  418. type: "slot",
  419. slotName: "oppMembraneId",
  420. label: "OPP膜",
  421. },
  422. {
  423. type: "slot",
  424. slotName: "peBagId",
  425. label: "PE袋",
  426. },
  427. {
  428. type: "slot",
  429. slotName: "meshBagId",
  430. label: "网包",
  431. },
  432. {
  433. type: "slot",
  434. slotName: "bubblePackId",
  435. label: "气泡袋",
  436. },
  437. {
  438. type: "slot",
  439. slotName: "suspendersId",
  440. label: "背带",
  441. },
  442. {
  443. type: "slot",
  444. slotName: "colouredPaperId",
  445. label: "彩纸",
  446. },
  447. {
  448. type: "slot",
  449. slotName: "selfAdhesiveStickerId",
  450. label: "不干胶",
  451. },
  452. {
  453. type: "slot",
  454. slotName: "dropId",
  455. label: "吊牌",
  456. },
  457. {
  458. type: "slot",
  459. slotName: "logisticsPackagingMaterialId",
  460. label: "快递包材",
  461. },
  462. {
  463. type: "slot",
  464. slotName: "otherPackingMaterialId",
  465. label: "其他包材",
  466. },
  467. ];
  468. });
  469. const rules = ref({
  470. spec: [{ required: true, message: "请输入规格", trigger: "blur" }],
  471. });
  472. const clickModal = () => {
  473. modalType.value = "add";
  474. formData.data = {};
  475. openDialog.value = true;
  476. };
  477. const labelText = ref("");
  478. const openBOM = ref(false);
  479. const bomClassifyId = ref("");
  480. const handleOpen = (label, id) => {
  481. labelText.value = label;
  482. bomClassifyId.value = id;
  483. openBOM.value = true;
  484. };
  485. const selectBOM = (data) => {
  486. formData.data[labelText.value + "Id"] = data.id;
  487. formData.data[labelText.value + "Code"] = data.code;
  488. openBOM.value = false;
  489. ElMessage({ message: "选择成功", type: "success" });
  490. };
  491. const clickRemove = (label) => {
  492. formData.data[label + "Id"] = "0";
  493. formData.data[label + "Code"] = "0";
  494. };
  495. const submitForm = () => {
  496. submit.value.handleSubmit(() => {
  497. proxy.post("/skuDefaultPackageSpec/" + modalType.value, formData.data).then(() => {
  498. ElMessage({
  499. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  500. type: "success",
  501. });
  502. openDialog.value = false;
  503. getList();
  504. });
  505. });
  506. };
  507. const clickUpdate = (row) => {
  508. modalType.value = "edit";
  509. proxy.post("/skuDefaultPackageSpec/detail", { id: row.id }).then((res) => {
  510. formData.data = res;
  511. openDialog.value = true;
  512. });
  513. };
  514. const loadingCard = ref(false);
  515. const clickUse = () => {
  516. loadingCard.value = true;
  517. ElMessage("请稍后,应用包材配置");
  518. proxy.post("/skuDefaultPackageSpec/refresh", {}).then(
  519. () => {
  520. ElMessage({ message: "应用成功", type: "success" });
  521. loadingCard.value = false;
  522. },
  523. (err) => {
  524. console.log(err);
  525. loadingCard.value = false;
  526. }
  527. );
  528. };
  529. </script>
  530. <style lang="scss" scoped>
  531. :deep(.el-dialog) {
  532. margin-top: 10px !important;
  533. margin-bottom: 10px !important;
  534. }
  535. </style>