lxf 1 vuosi sitten
vanhempi
commit
af36f541cb

+ 209 - 0
src/views/group/product/classification/index.vue

@@ -0,0 +1,209 @@
+<template>
+  <el-card class="box-card">
+    <byTable
+      :hideTable="true"
+      :hidePagination="true"
+      :source="sourceList.data"
+      :pagination="sourceList.pagination"
+      :config="config"
+      :loading="loading"
+      :searchConfig="searchConfig"
+      highlight-current-row
+      :action-list="[
+        {
+          text: '新增',
+          action: () => clickModal(),
+        },
+      ]"
+      @get-list="getList"
+      @clickReset="clickReset">
+    </byTable>
+    <el-table :data="sourceList.data" row-key="id" default-expand-all>
+      <el-table-column prop="name" label="分类名称" min-width="180" />
+      <el-table-column prop="sort" label="排序" align="center" width="100" />
+      <el-table-column label="操作" align="center" width="180">
+        <template #default="{ row }">
+          <div>
+            <el-button type="primary" @click="addChildNode(row)" text>添加子节点</el-button>
+            <el-button type="primary" @click="clickUpdate(row)" v-if="row.parentId" text>编辑</el-button>
+            <el-button type="primary" @click="clickDelete(row)" v-if="row.parentId" text>删除</el-button>
+          </div>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <el-dialog :title="modalType == 'add' ? '新增分类' : '编辑分类'" v-if="openDialog" v-model="openDialog" width="400">
+      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+        <template #parentId>
+          <div style="width: 100%">
+            <el-cascader
+              v-model="formData.data.parentId"
+              :options="sourceList.data"
+              :props="{ checkStrictly: true, value: 'id', label: 'name', emitPath: false }"
+              clearable
+              style="width: 100%" />
+          </div>
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="openDialog = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitForm()" :disabled="btnDisabled" size="large">确 定</el-button>
+      </template>
+    </el-dialog>
+  </el-card>
+</template>
+
+<script setup>
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import { ElMessage, ElMessageBox } from "element-plus";
+
+const { proxy } = getCurrentInstance();
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 0,
+    name: "",
+  },
+});
+const loading = ref(false);
+const searchConfig = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "name",
+      label: "分类名称",
+    },
+  ];
+});
+const config = computed(() => {
+  return [];
+});
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy.post("/bomClassify/tree", sourceList.value.pagination).then((res) => {
+    sourceList.value.data = res;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
+getList();
+const clickReset = () => {
+  getList({ name: "" });
+};
+const modalType = ref("add");
+const submit = ref(null);
+const openDialog = ref(false);
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const formData = reactive({
+  data: {},
+});
+const formConfig = computed(() => {
+  return [
+    {
+      type: "slot",
+      prop: "parentId",
+      slotName: "parentId",
+      label: "上级分类",
+    },
+    {
+      type: "input",
+      prop: "name",
+      label: "分类名称",
+      itemType: "text",
+    },
+    {
+      type: "input",
+      prop: "code",
+      label: "分类编码",
+      itemType: "text",
+    },
+    {
+      type: "number",
+      prop: "sort",
+      label: "排序",
+      precision: 0,
+    },
+    {
+      type: "input",
+      prop: "remark",
+      label: "备注",
+      itemType: "textarea",
+    },
+  ];
+});
+const rules = ref({
+  parentId: [{ required: true, message: "请选择上级分类", trigger: "change" }],
+  name: [{ required: true, message: "请输入分类名称", trigger: "blur" }],
+  code: [{ required: true, message: "请输入分类编码", trigger: "blur" }],
+});
+const btnDisabled = ref(false);
+const clickModal = () => {
+  modalType.value = "add";
+  formData.data = {};
+  btnDisabled.value = false;
+  openDialog.value = true;
+};
+const addChildNode = (row) => {
+  modalType.value = "add";
+  formData.data = {
+    parentId: row.id,
+  };
+  btnDisabled.value = false;
+  openDialog.value = true;
+};
+const submitForm = () => {
+  submit.value.handleSubmit(() => {
+    btnDisabled.value = true;
+    proxy.post("/bomClassify/" + modalType.value, formData.data).then(
+      () => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        openDialog.value = false;
+        btnDisabled.value = false;
+        getList();
+      },
+      (err) => {
+        console.log(err);
+        btnDisabled.value = false;
+      }
+    );
+  });
+};
+const clickUpdate = (row) => {
+  modalType.value = "edit";
+  formData.data = {
+    id: row.id,
+    parentId: row.parentId,
+    name: row.name,
+    code: row.code,
+    sort: row.sort,
+    remark: row.remark,
+  };
+  btnDisabled.value = false;
+  openDialog.value = true;
+};
+const clickDelete = (row) => {
+  ElMessageBox.confirm("你是否确认此操作", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  }).then(() => {
+    proxy.post("/bomClassify/delete", { id: row.id }).then(() => {
+      ElMessage({ message: "删除成功", type: "success" });
+      getList();
+    });
+  });
+};
+</script>
+
+<style lang="scss" scoped></style>

+ 5 - 5
src/views/system/role2/index - 副本.vue

@@ -23,17 +23,17 @@
 				}"
 				:action-list="[
 					{
+						text: '添加角色',
+						action: () => openModal('add'),
+						disabled:!sourceList.pagination.tenantId
+					},
+					{
 						text: '权限配置',
 						plain: true,
 						//type: 'warning',
 						action: () => openRoomModal(),
 						disabled:selection.data.length != 1,
 					},
-					{
-						text: '添加角色',
-						action: () => openModal('add'),
-						disabled:!sourceList.pagination.tenantId
-					},
 				]"
 				@get-list="getList"
 			>

+ 5 - 5
src/views/system/role2/index.vue

@@ -17,17 +17,17 @@
         }"
         :action-list="[
           {
+            text: '添加角色',
+            action: () => openModal('add'),
+            disabled: !sourceList.pagination.tenantId,
+          },
+          {
             text: '权限配置',
             plain: true,
             //type: 'warning',
             action: () => openRoomModal(),
             disabled: selection.data.length != 1,
           },
-          {
-            text: '添加角色',
-            action: () => openModal('add'),
-            disabled: !sourceList.pagination.tenantId,
-          },
         ]"
         @get-list="getList">
         <template #slotName="{ item }">

+ 5 - 5
src/views/system/tenant/index.vue

@@ -15,16 +15,16 @@
         }"
         :action-list="[
           {
+            text: '添加租户',
+            action: () => openModal('add'),
+          },
+          {
             text: '权限配置',
             plain: true,
             //type: 'warning',
             action: () => openRoomModal(),
             disabled: selection.data.length != 1,
           },
-          {
-            text: '添加租户',
-            action: () => openModal('add'),
-          },
         ]"
         @get-list="getList">
         <template #slotName="{ item }">
@@ -353,7 +353,7 @@ const noRepeat = (arr) => {
 };
 const submitTree = () => {
   let data = noRepeat(tree.value.getHalfCheckedKeys().concat(tree.value.getCheckedKeys()));
-  if(data.length == 0) {
+  if (data.length == 0) {
     ElMessage({
       message: "请至少选择一个菜单",
       type: "error",