Pārlūkot izejas kodu

仓库物品类别管理

damon227 10 mēneši atpakaļ
vecāks
revīzija
8921bfd98a

+ 9 - 8
src/views/modules/warehouse/category-add-or-update.vue

@@ -9,7 +9,7 @@
     >
       <el-row class="my-row">
         <el-col :span="8">
-          <el-form-item label="仓库类型名称" prop="name">
+          <el-form-item label="类型名称" prop="name">
             <el-input v-model="dataForm.name"></el-input>
           </el-form-item>
         </el-col>
@@ -54,13 +54,9 @@
 </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 {
@@ -70,7 +66,9 @@ export default {
         id: "",
       },
       dataList: [],
-      dataRule: {},
+      dataRule: {
+        name:{required:true, trigger:'blur', message:'请输入类型名称'}
+      },
     };
   },
   methods: {
@@ -81,7 +79,7 @@ export default {
       this.visible = true;
       this.id = id || 0;
       this.dataForm = {};
-       this.dataForm.id = id || 0
+      this.dataForm.id = id || 0;
 
       await this.getDataList();
 
@@ -93,6 +91,9 @@ export default {
         }).then(({ data }) => {
           if (data.code === "200") {
             this.dataForm = data.data;
+            if (this.dataForm.parentId == "0") {
+              this.dataForm.parentId = "";
+            }
           } else {
             this.$message.error(data.msg);
           }
@@ -121,7 +122,7 @@ export default {
                     id: this.dataForm.id,
                     name: this.dataForm.name,
                     parentId: this.dataForm.parentId,
-                    note: this.dataForm.note,
+                    notes: this.dataForm.notes,
                   }
             ),
           }).then(({ data }) => {

+ 137 - 0
src/views/modules/warehouse/category-move.vue

@@ -0,0 +1,137 @@
+<template>
+  <div>
+    <div class="my-title">迁移</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="materialTypeId">
+            <el-select
+              v-model="dataForm.materialTypeId"
+              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-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>
+export default {
+  name: "category-move",
+  components: {},
+  data() {
+    return {
+      visible: false,
+      id: 0,
+      dataForm: {
+        id: "",
+      },
+      dataList: [],
+      dataRule: {
+        materialTypeId: { required: true, trigger: "blur", message: "请选择" },
+      },
+    };
+  },
+  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;
+            if (this.dataForm.parentId == "0") {
+              this.dataForm.parentId = "";
+            }
+          } else {
+            this.$message.error(data.msg);
+          }
+        });
+      }
+    },
+    // 表单提交
+    dataFormSubmit() {
+      this.$refs["dataForm"].validate((valid) => {
+        if (valid) {
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/wh-category/move`),
+            method: "post",
+            data: {
+              businessId: this.dataForm.id,
+              materialTypeId: this.dataForm.materialTypeId,
+            },
+          }).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>

+ 53 - 8
src/views/modules/warehouse/category.vue

@@ -1,11 +1,11 @@
 <!-- 出入库管理 -->
 <template>
   <div class="stock-order">
-    <template v-if="!updateVisible">
+    <template v-if="!updateVisible && !moveVisible">
       <el-form :inline="true">
         <el-form-item>
           <el-button
-            v-if="isAuth('wh:stock-mg-ctl:material-save')"
+            v-if="isAuth('wh:wh-category:save')"
             type="primary"
             @click="addHandle()"
             >新增</el-button
@@ -31,7 +31,6 @@
           prop="name"
           header-align="center"
           align="center"
-          min-width="160"
           :show-tooltip-when-overflow="true"
           label="仓库类别名称"
         >
@@ -40,7 +39,6 @@
           prop="notes"
           header-align="center"
           align="center"
-          width="100"
           label="备注"
         >
         </el-table-column>
@@ -48,7 +46,6 @@
           prop="parentName"
           header-align="center"
           align="center"
-          width="100"
           label="上级类别"
         >
         </el-table-column>
@@ -61,14 +58,21 @@
         >
           <template slot-scope="scope">
             <el-button
-              v-if="isAuth('wh:in:editor')"
+              v-if="isAuth('wh:wh-category:update')"
               type="text"
               size="small"
               @click="updateHandle(scope.row.id)"
               >编辑</el-button
             >
             <el-button
-              v-if="isAuth('wh:in:editor')"
+              v-if="isAuth('wh:wh-category:move')"
+              type="text"
+              size="small"
+              @click="moveHandle(scope.row.id)"
+              >迁移</el-button
+            >
+            <el-button
+              v-if="isAuth('wh:wh-category:delete')"
               type="text"
               size="small"
               @click="deleteHandle(scope.row.id)"
@@ -94,15 +98,22 @@
       @onChose="onChose"
       @refreshDataList="getDataList"
     ></category-add-or-update>
+    <category-move
+      v-if="moveVisible"
+      ref="move"
+      @onChose="onChose"
+      @refreshDataList="getDataList">
+      </category-move>
   </div>
 </template>
 
 <script>
 import CategoryAddOrUpdate from "./category-add-or-update";
+import CategoryMove from "./category-move";
 
 export default {
   name: "category",
-  components: { CategoryAddOrUpdate },
+  components: { CategoryAddOrUpdate,CategoryMove },
   created() {
     this.queryData();
   },
@@ -114,11 +125,13 @@ export default {
       totalPage: 0,
       dataListLoading: false,
       updateVisible: false,
+      moveVisible: false
     };
   },
   methods: {
     onChose() {
       this.updateVisible = false;
+      this.moveVisible = false
     },
     queryData() {
       this.pageIndex = 1;
@@ -169,6 +182,38 @@ export default {
         this.$refs.update.init(id);
       });
     },
+     moveHandle(id) {
+      this.moveVisible = true;
+      this.$nextTick(() => {
+        this.$refs.move.init(id);
+      });
+    },
+    deleteHandle(id){
+      this.$confirm(`确定进行删除操作?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/wh-category/delete`),
+            method: 'DELETE',
+            data: [id]
+          }).then(({data}) => {
+            if (data && data.code === '200') {
+              this.$message({
+                message: '操作成功',
+                type: 'success',
+                duration: 1500,
+                onClose: () => {
+                  this.getDataList()
+                }
+              })
+            } else {
+              this.$message.error(data.msg)
+            }
+          })
+        }).catch(() => {})
+    }
   },
 };
 </script>