|
@@ -4,10 +4,15 @@
|
|
|
<van-pull-refresh v-model="loading" @refresh="onRefresh">
|
|
|
<div class="list">
|
|
|
<van-list v-model:loading="loading" :finished="finished" finished-text="" @load="onLoad" style="margin-bottom: 60px">
|
|
|
- <commonList :data="[]" @onClick="toDtl" :config="listConfig"> </commonList>
|
|
|
- <treeNav :tree-data="listData" @clickItem="(item) => toDtl(item)"></treeNav>
|
|
|
+ <commonList :data="[]" :config="listConfig"> </commonList>
|
|
|
+ <treeNav
|
|
|
+ :tree-data="listData"
|
|
|
+ @clickAdd="(item) => clickAdd(item)"
|
|
|
+ @clickUpdate="(item) => clickUpdate(item)"
|
|
|
+ @clickDelete="(item) => clickDelete(item)">
|
|
|
+ </treeNav>
|
|
|
<div style="margin: 16px">
|
|
|
- <van-button round block type="primary" @click="clickAdd">添加一级节点</van-button>
|
|
|
+ <van-button round block type="primary" @click="clickAdd({ id: '' })">添加一级节点</van-button>
|
|
|
</div>
|
|
|
</van-list>
|
|
|
</div>
|
|
@@ -19,6 +24,9 @@ import { ref, getCurrentInstance } from "vue";
|
|
|
import commonList from "@/components/common-list.vue";
|
|
|
import treeNav from "@/components/tree-nav.vue";
|
|
|
import { useRoute } from "vue-router";
|
|
|
+import { showConfirmDialog } from "vant";
|
|
|
+import { showSuccessToast } from "vant";
|
|
|
+
|
|
|
const loading = ref(false);
|
|
|
const router = useRoute();
|
|
|
const req = ref({
|
|
@@ -43,21 +51,11 @@ const onLoad = () => {
|
|
|
getList();
|
|
|
};
|
|
|
const onClickLeft = () => proxy.$router.push("/main/working");
|
|
|
-const toDtl = (row) => {
|
|
|
- console.log(row);
|
|
|
- // proxy.$router.push({
|
|
|
- // path: "workOrderDtl",
|
|
|
- // query: {
|
|
|
- // id: row.id,
|
|
|
- // },
|
|
|
- // });
|
|
|
-};
|
|
|
const getList = (type) => {
|
|
|
loading.value = true;
|
|
|
proxy
|
|
|
.post("/productClassify/tree", { parentId: "", name: "", definition: "2" })
|
|
|
.then((res) => {
|
|
|
- console.log(res);
|
|
|
listData.value = res.data;
|
|
|
finished.value = true;
|
|
|
loading.value = false;
|
|
@@ -66,7 +64,42 @@ const getList = (type) => {
|
|
|
loading.value = false;
|
|
|
});
|
|
|
};
|
|
|
-const clickAdd = () => proxy.$router.push("/main/materialClassificationAdd");
|
|
|
+const clickAdd = (row) => {
|
|
|
+ proxy.$router.push({
|
|
|
+ path: "/main/materialClassificationAdd",
|
|
|
+ query: {
|
|
|
+ parentId: row.id,
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+const clickUpdate = (row) => {
|
|
|
+ proxy.$router.push({
|
|
|
+ path: "/main/materialClassificationEdit",
|
|
|
+ query: {
|
|
|
+ id: row.id,
|
|
|
+ name: row.label,
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+const clickDelete = (row) => {
|
|
|
+ showConfirmDialog({
|
|
|
+ title: "标题",
|
|
|
+ message: "是否确认删除该分类",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ proxy
|
|
|
+ .post("/productClassify/delete", {
|
|
|
+ id: row.id,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ showSuccessToast("删除成功");
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ // on cancel
|
|
|
+ });
|
|
|
+};
|
|
|
getList();
|
|
|
</script>
|
|
|
|