selectAllAddToSite.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div>
  3. <el-button type="primary" size="small" @click="onshow">{{
  4. $t(`全选并添加至本站`)
  5. }}</el-button>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. name: "selectAllAddToSite",
  11. props: ["where", "queryApiId", "basicLayout"],
  12. methods: {
  13. onshow() {
  14. this.onSelectAllAddToSite();
  15. },
  16. async onSelectAllAddToSite() {
  17. const elTable = this.basicLayout.$refs.table.$refs.tables;
  18. this.basicLayout.list.forEach((row) => {
  19. elTable.toggleRowSelection(row, true);
  20. });
  21. this.$confirm(
  22. this.$t("是否确定将全部物料添加至本站") + "?",
  23. this.$t("提示"),
  24. {
  25. confirmButtonText: this.$t("确定"),
  26. cancelButtonText: this.$t("取消"),
  27. type: "warning",
  28. }
  29. )
  30. .then(async () => {
  31. const queryRes = await this.$api.requested({
  32. id: this.queryApiId,
  33. content: {
  34. pageNumber: 1,
  35. pageSize: 99999,
  36. where: this.where,
  37. },
  38. });
  39. const ids = queryRes.data.map((item) => item.sc_itemid);
  40. const res = await this.$api.requested({
  41. id: 2026051511000002,
  42. content: {
  43. // sc_itemids: ids.join(","),不用传
  44. },
  45. });
  46. this.tool.showMessage(res, () => {
  47. this.$emit("addSuccess");
  48. });
  49. })
  50. .catch(async () => {
  51. elTable.clearSelection();
  52. this.$message({
  53. type: "info",
  54. message: this.$t("已取消全选并添加至本站"),
  55. });
  56. });
  57. },
  58. },
  59. };
  60. </script>