index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div style="padding-bottom: 60px">
  3. <van-nav-bar :title="$t('classification.name')" left-text="" left-arrow @click-left="onClickLeft"> </van-nav-bar>
  4. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  5. <div class="list">
  6. <van-list v-model:loading="loading" :finished="finished" finished-text="" @load="onLoad" style="margin-bottom: 60px">
  7. <commonList :data="[]" :config="listConfig"> </commonList>
  8. <treeNav
  9. :tree-data="listData"
  10. @clickAdd="(item) => clickAdd(item)"
  11. @clickUpdate="(item) => clickUpdate(item)"
  12. @clickDelete="(item) => clickDelete(item)">
  13. </treeNav>
  14. <div style="margin: 16px">
  15. <van-button round block type="primary" @click="clickAdd({ id: '' })">{{$t('classification.addFirstLevelNode')}}</van-button>
  16. </div>
  17. </van-list>
  18. </div>
  19. </van-pull-refresh>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { ref, getCurrentInstance } from "vue";
  24. import commonList from "@/components/common-list.vue";
  25. import treeNav from "@/components/tree-nav.vue";
  26. import { useRoute } from "vue-router";
  27. import { showConfirmDialog } from "vant";
  28. import { showSuccessToast } from "vant";
  29. const loading = ref(false);
  30. const router = useRoute();
  31. const req = ref({
  32. pageNum: 1,
  33. type: "1",
  34. keyword: null,
  35. });
  36. const finished = ref(false);
  37. const proxy = getCurrentInstance().proxy;
  38. const listData = ref([]);
  39. const listConfig = ref([
  40. {
  41. label: "",
  42. prop: "label",
  43. },
  44. ]);
  45. const onRefresh = () => {
  46. finished.value = false;
  47. getList("refresh");
  48. };
  49. const onLoad = () => {
  50. getList();
  51. };
  52. const onClickLeft = () => proxy.$router.push("/main/working");
  53. const getList = (type) => {
  54. loading.value = true;
  55. proxy
  56. .post("/productClassify/tree", { parentId: "", name: "", definition: "2" })
  57. .then((res) => {
  58. listData.value = res.data;
  59. finished.value = true;
  60. loading.value = false;
  61. })
  62. .catch((err) => {
  63. loading.value = false;
  64. });
  65. };
  66. const clickAdd = (row) => {
  67. proxy.$router.push({
  68. path: "/main/materialClassificationAdd",
  69. query: {
  70. parentId: row.id,
  71. },
  72. });
  73. };
  74. const clickUpdate = (row) => {
  75. proxy.$router.push({
  76. path: "/main/materialClassificationEdit",
  77. query: {
  78. id: row.id,
  79. name: row.label,
  80. },
  81. });
  82. };
  83. const clickDelete = (row) => {
  84. showConfirmDialog({
  85. title: proxy.t('common.prompt'),
  86. message: proxy.t('classification.confirmToDeleteTheClassification'),
  87. })
  88. .then(() => {
  89. proxy
  90. .post("/productClassify/delete", {
  91. id: row.id,
  92. })
  93. .then((res) => {
  94. showSuccessToast(proxy.t('common.deleteSuccess'));
  95. getList();
  96. });
  97. })
  98. .catch(() => {
  99. // on cancel
  100. });
  101. };
  102. getList();
  103. </script>
  104. <style lang="scss" scoped>
  105. .list {
  106. min-height: 70vh;
  107. }
  108. ::v-deep {
  109. .van-collapse-item__content {
  110. padding: 8px 0 8px 8px !important;
  111. }
  112. }
  113. </style>