瀏覽代碼

BOM分类及样式调整,组件调整

lxf 1 年之前
父節點
當前提交
b6af189576
共有 3 個文件被更改,包括 216 次插入99 次删除
  1. 12 9
      src/assets/styles/btn.scss
  2. 35 14
      src/components/byTable/index.vue
  3. 169 76
      src/views/group/BOM/classification/index.vue

+ 12 - 9
src/assets/styles/btn.scss

@@ -1,4 +1,4 @@
-@import './variables.module.scss';
+@import "./variables.module.scss";
 
 @mixin colorBtn($color) {
   background: $color;
@@ -14,31 +14,31 @@
 }
 
 .blue-btn {
-  @include colorBtn($blue)
+  @include colorBtn($blue);
 }
 
 .light-blue-btn {
-  @include colorBtn($light-blue)
+  @include colorBtn($light-blue);
 }
 
 .red-btn {
-  @include colorBtn($red)
+  @include colorBtn($red);
 }
 
 .pink-btn {
-  @include colorBtn($pink)
+  @include colorBtn($pink);
 }
 
 .green-btn {
-  @include colorBtn($green)
+  @include colorBtn($green);
 }
 
 .tiffany-btn {
-  @include colorBtn($tiffany)
+  @include colorBtn($tiffany);
 }
 
 .yellow-btn {
-  @include colorBtn($yellow)
+  @include colorBtn($yellow);
 }
 
 .pan-btn {
@@ -64,7 +64,7 @@
 
   &:before,
   &:after {
-    content: '';
+    content: "";
     position: absolute;
     top: 0;
     right: 0;
@@ -97,3 +97,6 @@
   font-size: 14px;
   border-radius: 4px;
 }
+.is-text {
+  padding: 0 !important;
+}

+ 35 - 14
src/components/byTable/index.vue

@@ -1,4 +1,13 @@
 <template>
+  <el-form :inline="true" :model="pagination" v-if="searchConfig && searchConfig.length > 0">
+    <el-form-item v-for="(item, index) in searchConfig" :key="index" :label="item.label + ':'" :prop="item.prop">
+      <el-input v-if="item.type === 'input'" v-model="pagination[item.prop]" :placeholder="'请输入' + item.label" />
+    </el-form-item>
+    <el-form-item>
+      <el-button size="small" @click="searchFn" class="searchBtn">搜索</el-button>
+      <el-button size="small" @click="clickReset">重置</el-button>
+    </el-form-item>
+  </el-form>
   <div class="header-actions" v-if="getActionList.length != 0">
     <div class="overflow-box">
       <el-button
@@ -27,8 +36,6 @@
         style="width: 100%"
         v-bind="$attrs"
         v-on="tableEvents"
-        row-key="id"
-        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
         :height="tableHeight"
         :row-style="{ height: '35px' }"
         header-row-class-name="tableHeader">
@@ -108,6 +115,13 @@ export default defineComponent({
         return [];
       },
     },
+    // 查询条件
+    searchConfig: {
+      type: Array,
+      default() {
+        return [];
+      },
+    },
     tableHeight: {
       type: Number,
       required: false,
@@ -217,7 +231,6 @@ export default defineComponent({
       const propValue = prop && scope.row[prop];
       scope.row.$index = scope.$index;
       const args = propValue !== undefined ? propValue : scope.row;
-
       return item[fn.name][fn.type](getParent.value, args);
     };
     // 匹配 render 开头的函数
@@ -230,13 +243,11 @@ export default defineComponent({
     const isFunction = (fn) => {
       return isFn(fn);
     };
-    const searchFn = (val) => {
-      proxy.$emit(
-        "getList",
-        Object.assign(props.filterParams, {
-          [props.searchKey]: props.pagination.keyword,
-        })
-      );
+    const searchFn = () => {
+      proxy.$emit("getList", { pageNum: 1 });
+    };
+    const clickReset = () => {
+      proxy.$emit("clickReset", "");
     };
     const handlePageChange = (val) => {
       proxy.$emit("getList", Object.assign(props.filterParams, { pageNum: val }));
@@ -275,7 +286,6 @@ export default defineComponent({
       }
     };
     const hocElTable = ref();
-
     return {
       getParent,
       getPagination,
@@ -292,6 +302,7 @@ export default defineComponent({
       stopBubbles,
       handleNativeClick,
       searchFn,
+      clickReset,
       isSelectable,
       statWarpHeight,
       changeStatData,
@@ -519,12 +530,11 @@ export default defineComponent({
 .header-actions {
   flex: 1;
   overflow-x: auto;
-  padding: 20px;
   background: #fff;
-  margin-bottom: 20px;
   .overflow-box {
+    margin-bottom: 10px;
     :deep() .el-button:nth-child(1) {
-      margin-left: 10px;
+      margin-right: 10px;
     }
   }
 }
@@ -555,4 +565,15 @@ export default defineComponent({
   height: 35px;
   padding: 0;
 }
+::v-deep(.el-button--small) {
+  padding: 5px 17px;
+}
+.searchBtn {
+  background: #20b2aa;
+  color: #fff;
+  border: 1px solid #20b2aa;
+}
+::v-deep(.el-form-item) {
+    margin-right: 16px !important;
+}
 </style>

+ 169 - 76
src/views/group/BOM/classification/index.vue

@@ -1,116 +1,209 @@
 <template>
   <el-card class="box-card">
     <byTable
+      :hideTable="true"
+      :hidePagination="true"
       :source="sourceList.data"
       :pagination="sourceList.pagination"
       :config="config"
       :loading="loading"
-      :selectConfig="selectConfig"
+      :searchConfig="searchConfig"
       highlight-current-row
-      @get-list="getList">
-      <template #amount="{ item }">
-        <div>
-          <span style="padding-right: 4px">{{ item.currency }}</span>
-          <span>{{ moneyFormat(item.amount, 2) }}</span>
-        </div>
-      </template>
+      :action-list="[
+        {
+          text: '新增',
+          action: () => openModal(),
+        },
+      ]"
+      @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()" v-loading="btnLoading" 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 orderStatus = ref([]);
 const sourceList = ref({
-  data: [{ code: "踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩从" }, {}],
+  data: [],
   pagination: {
-    total: 1000,
-    pageNum: 1,
-    pageSize: 10,
-    keyword: "",
-    status: "",
-    payStatus: "",
+    total: 0,
+    name: "",
   },
 });
-const selectConfig = computed(() => {
+const loading = ref(false);
+const searchConfig = computed(() => {
   return [
     {
-      label: "质检状态",
-      prop: "status",
-      data: [],
-    },
-    {
-      label: "订单类型",
-      prop: "payStatus",
-      data: [],
-    },
-    {
-      label: "结论",
-      prop: "payStatus",
-      data: [],
+      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 [
     {
-      attrs: {
-        label: "采购单号",
-        prop: "code",
-        "min-width": 180,
-      },
+      type: "slot",
+      prop: "parentId",
+      slotName: "parentId",
+      label: "上级分类",
     },
-    // {
-    //   attrs: {
-    //     label: "供应商",
-    //     prop: "sellCorporationId",
-    //     "min-width": 220,
-    //   },
-    //   render(type) {
-    //     return proxy.dictValueLabel(type, supplierList.value);
-    //   },
-    // },
     {
-      attrs: {
-        label: "操作",
-        width: 160,
-        align: "center",
-        fixed: "right",
-      },
-      renderHTML(row) {
-        return [];
-      },
+      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 getDict = () => {
-  proxy.getDictOne(["order_status"]).then((res) => {
-    if (res["order_status"] && res["order_status"].length > 0) {
-      orderStatus.value = res["order_status"].map((x) => ({
-        label: x.dictValue,
-        value: x.dictKey,
-      }));
-    }
+const rules = ref({
+  parentId: [{ required: true, message: "请选择上级分类", trigger: "change" }],
+  name: [{ required: true, message: "请输入分类名称", trigger: "blur" }],
+  code: [{ required: true, message: "请输入分类编码", trigger: "blur" }],
+});
+const btnLoading = ref(false);
+const openModal = () => {
+  modalType.value = "add";
+  formData.data = {};
+  btnLoading.value = false;
+  openDialog.value = true;
+};
+const addChildNode = (row) => {
+  modalType.value = "add";
+  formData.data = {
+    parentId: row.id,
+  };
+  btnLoading.value = false;
+  openDialog.value = true;
+};
+const submitForm = () => {
+  submit.value.handleSubmit(() => {
+    btnLoading.value = true;
+    proxy.post("/bomClassify/" + modalType.value, formData.data).then(
+      () => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        openDialog.value = false;
+        btnLoading.value = false;
+        getList();
+      },
+      (err) => {
+        console.log(err);
+        btnLoading.value = false;
+      }
+    );
   });
 };
-getDict();
-const getList = async (req) => {
-  console.log(req);
-  //   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
-  //   loading.value = true;
-  //   proxy.post("/ehsdPurchase/page", sourceList.value.pagination).then((res) => {
-  //     console.log(res);
-  //     sourceList.value.data = res.rows;
-  //     sourceList.value.pagination.total = res.total;
-  //     setTimeout(() => {
-  //       loading.value = false;
-  //     }, 200);
-  //   });
+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,
+  };
+  btnLoading.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();
+    });
+  });
 };
-getList();
 </script>
 
 <style lang="scss" scoped>