Selaa lähdekoodia

仓库种类管理

damon227 10 kuukautta sitten
vanhempi
commit
7a1c6655f4

+ 1 - 0
src/api/warehouse.js

@@ -236,3 +236,4 @@ export function infoByNameAndCode (params) {
     params
   })
 }
+

+ 167 - 0
src/views/modules/warehouse/category-add-or-update.vue

@@ -0,0 +1,167 @@
+<template>
+  <div>
+    <div class="my-title">{{ !dataForm.id ? "新增" : "修改" }}</div>
+    <el-form
+      :model="dataForm"
+      :rules="dataRule"
+      ref="dataForm"
+      label-width="100px"
+    >
+      <el-row class="my-row">
+        <el-col :span="8">
+          <el-form-item label="仓库类型名称" prop="name">
+            <el-input v-model="dataForm.name"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="上级名称" prop="parentId">
+            <el-select
+              v-model="dataForm.parentId"
+              filterable
+              clearable
+              placeholder="请选择"
+            >
+              <el-option
+                v-for="item in dataList"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row class="my-row">
+        <el-col :span="24">
+          <el-form-item label="备注" prop="notes">
+            <el-input
+              type="textarea"
+              v-model="dataForm.notes"
+              placeholder="备注"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">取消</el-button>
+      <el-button type="primary" @click="dataFormSubmit()" v-reClick
+        >确定</el-button
+      >
+    </span>
+  </div>
+</template>
+
+<script>
+import EDesc from "../common/e-desc";
+import EDescItem from "../common/e-desc-item";
+export default {
+  name: "category-add-or-update",
+  components: {
+    EDesc,
+    EDescItem,
+  },
+  data() {
+    return {
+      visible: false,
+      id: 0,
+      dataForm: {
+        id: "",
+      },
+      dataList: [],
+      dataRule: {},
+    };
+  },
+  methods: {
+    onChose() {
+      this.$emit("onChose");
+    },
+    async init(id) {
+      this.visible = true;
+      this.id = id || 0;
+      this.dataForm = {};
+       this.dataForm.id = id || 0
+
+      await this.getDataList();
+
+      if (this.id) {
+        this.$http({
+          url: this.$http.adornUrl(`/biz-service/wh-category/info/${this.id}`),
+          method: "get",
+          params: this.$http.adornParams(),
+        }).then(({ data }) => {
+          if (data.code === "200") {
+            this.dataForm = data.data;
+          } else {
+            this.$message.error(data.msg);
+          }
+        });
+      }
+    },
+    // 表单提交
+    dataFormSubmit() {
+      this.$refs["dataForm"].validate((valid) => {
+        if (valid) {
+          this.$http({
+            url: this.$http.adornUrl(
+              `/biz-service/wh-category/${
+                !this.dataForm.id ? "save" : "update"
+              }`
+            ),
+            method: !this.dataForm.id ? "post" : "put",
+            data: this.$http.adornData(
+              !this.dataForm.id
+                ? {
+                    name: this.dataForm.name,
+                    parentId: this.dataForm.parentId,
+                    notes: this.dataForm.notes,
+                  }
+                : {
+                    id: this.dataForm.id,
+                    name: this.dataForm.name,
+                    parentId: this.dataForm.parentId,
+                    note: this.dataForm.note,
+                  }
+            ),
+          }).then(({ data }) => {
+            if (data && data.code === "200") {
+              this.$message({
+                message: "操作成功",
+                type: "success",
+                duration: 1500,
+                onClose: () => {
+                  this.onChose();
+                  this.$emit("refreshDataList");
+                },
+              });
+            } else {
+              this.$message.error(data.msg);
+            }
+          });
+        }
+      });
+    },
+    // 获取数据列表
+    getDataList(name) {
+      this.$http({
+        url: this.$http.adornUrl("/biz-service/wh-category/list"),
+        method: "get",
+        params: this.$http.adornParams({
+          current: this.pageIndex,
+          size: 100,
+          materialName: name,
+        }),
+      }).then(({ data }) => {
+        if (data && data.code === "200") {
+          this.dataList = data.data.records;
+        } else {
+          this.dataList = [];
+        }
+      });
+    },
+  },
+};
+</script>
+
+<style scoped></style>

+ 176 - 0
src/views/modules/warehouse/category.vue

@@ -0,0 +1,176 @@
+<!-- 出入库管理 -->
+<template>
+  <div class="stock-order">
+    <template v-if="!updateVisible">
+      <el-form :inline="true">
+        <el-form-item>
+          <el-button
+            v-if="isAuth('wh:stock-mg-ctl:material-save')"
+            type="primary"
+            @click="addHandle()"
+            >新增</el-button
+          >
+        </el-form-item>
+      </el-form>
+      <el-table
+        :data="dataList"
+        border
+        v-loading="dataListLoading"
+        style="width: 100%"
+      >
+        <el-table-column
+          type="selection"
+          header-align="center"
+          align="center"
+          width="50"
+        >
+        </el-table-column>
+        <el-table-column label="序号" type="index" width="50" align="center">
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          header-align="center"
+          align="center"
+          min-width="160"
+          :show-tooltip-when-overflow="true"
+          label="仓库类别名称"
+        >
+        </el-table-column>
+        <el-table-column
+          prop="notes"
+          header-align="center"
+          align="center"
+          width="100"
+          label="备注"
+        >
+        </el-table-column>
+        <el-table-column
+          prop="parentName"
+          header-align="center"
+          align="center"
+          width="100"
+          label="上级类别"
+        >
+        </el-table-column>
+        <el-table-column
+          fixed="right"
+          header-align="center"
+          align="center"
+          width="150"
+          label="操作"
+        >
+          <template slot-scope="scope">
+            <el-button
+              v-if="isAuth('wh:in:editor')"
+              type="text"
+              size="small"
+              @click="updateHandle(scope.row.id)"
+              >编辑</el-button
+            >
+            <el-button
+              v-if="isAuth('wh:in:editor')"
+              type="text"
+              size="small"
+              @click="deleteHandle(scope.row.id)"
+              >删除</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-pagination
+        @size-change="sizeChangeHandle"
+        @current-change="currentChangeHandle"
+        :current-page="pageIndex"
+        :page-sizes="[10, 20, 50, 100]"
+        :page-size="pageSize"
+        :total="totalPage"
+        layout="total, sizes, prev, pager, next, jumper"
+      >
+      </el-pagination>
+    </template>
+    <category-add-or-update
+      v-if="updateVisible"
+      ref="update"
+      @onChose="onChose"
+      @refreshDataList="getDataList"
+    ></category-add-or-update>
+  </div>
+</template>
+
+<script>
+import CategoryAddOrUpdate from "./category-add-or-update";
+
+export default {
+  name: "category",
+  components: { CategoryAddOrUpdate },
+  created() {
+    this.queryData();
+  },
+  data() {
+    return {
+      dataList: [],
+      pageIndex: 1,
+      pageSize: 10,
+      totalPage: 0,
+      dataListLoading: false,
+      updateVisible: false,
+    };
+  },
+  methods: {
+    onChose() {
+      this.updateVisible = false;
+    },
+    queryData() {
+      this.pageIndex = 1;
+      this.getDataList();
+    },
+    // 获取数据列表
+    getDataList() {
+      this.dataListLoading = true;
+      this.$http({
+        url: this.$http.adornUrl("/biz-service/wh-category/list"),
+        method: "get",
+        params: this.$http.adornParams({
+          current: this.pageIndex,
+          size: this.pageSize,
+        }),
+      }).then(({ data }) => {
+        if (data && data.code === "200") {
+          this.dataList = data.data.records;
+          this.totalPage = Number(data.data.total);
+        } else {
+          this.dataList = [];
+          this.totalPage = 0;
+        }
+        this.dataListLoading = false;
+      });
+    },
+    // 每页数
+    sizeChangeHandle(val) {
+      this.pageSize = val;
+      this.pageIndex = 1;
+      this.getDataList();
+    },
+    // 当前页
+    currentChangeHandle(val) {
+      this.pageIndex = val;
+      this.getDataList();
+    },
+    //新增
+    addHandle() {
+      this.updateVisible = true;
+      this.$nextTick(() => {
+        this.$refs.update.init();
+      });
+    },
+    updateHandle(id) {
+      this.updateVisible = true;
+      this.$nextTick(() => {
+        this.$refs.update.init(id);
+      });
+    },
+  },
+};
+</script>
+
+<style scoped></style>