gaoluyang
4 天以前 81fb8afca320a12c38d868edf392e6bf9a665a0f
src/views/basicData/product/index.vue
@@ -12,6 +12,7 @@
          prefix-icon="Search"
        />
        <el-button
          v-if="false"
          type="primary"
          @click="openProDia('addOne')"
          style="margin-left: 10px"
@@ -49,6 +50,7 @@
                <el-button
                  type="primary"
                  link
                  :disabled="isTopLevelNode(data, node)"
                  @click="openProDia('edit', data)"
                >
                  编辑
@@ -61,6 +63,7 @@
                  style="margin-left: 4px"
                  type="danger"
                  link
                  :disabled="isTopLevelNode(data, node)"
                  @click="remove(node, data)"
                >
                  删除
@@ -285,6 +288,8 @@
const search = ref("");
const currentId = ref("");
const currentParentId = ref("");
const editId = ref("");
const editParentId = ref("");
const operationType = ref("");
const treeLoad = ref(false);
const list = ref([]);
@@ -375,13 +380,25 @@
const searchFilter = () => {
  proxy.$refs.tree.filter(search.value);
};
const isTopLevelNode = (data, node) => {
  if (node?.level !== undefined) {
    return node.level === 1;
  }
  return [null, undefined, "", 0, "0"].includes(data?.parentId);
};
// 打开产品弹框
const openProDia = (type, data) => {
  if (data && type === "edit" && isTopLevelNode(data)) {
    proxy.$modal.msgWarning("一级节点不能编辑或删除");
    return;
  }
  operationType.value = type;
  productDia.value = true;
  form.value.productName = "";
  if (type === "edit") {
    form.value.productName = data.productName;
    editId.value = data.id;
    editParentId.value = data.parentId;
  }
};
// 打开规格型号弹框
@@ -406,8 +423,8 @@
        form.value.id = "";
        form.value.parentId = "";
      } else {
        form.value.id = currentId.value;
        form.value.parentId = "";
        form.value.id = editId.value;
        form.value.parentId = editParentId.value;
      }
      addOrEditProduct(form.value).then((res) => {
        proxy.$modal.msgSuccess("提交成功");
@@ -425,6 +442,10 @@
// 删除产品
const remove = (node, data) => {
  if (isTopLevelNode(data, node)) {
    proxy.$modal.msgWarning("一级节点不能编辑或删除");
    return;
  }
  let ids = [];
  ids.push(data.id);
  ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除提示", {