Browse Source

修改系统类别

yangg 7 months ago
parent
commit
ac5e73153b
1 changed files with 162 additions and 107 deletions
  1. 162 107
      ui/src/views/ProductMent/sysCategory/index.vue

+ 162 - 107
ui/src/views/ProductMent/sysCategory/index.vue

@@ -9,26 +9,45 @@
         style="width: 200px; margin-left: 16px"
         @keyup.enter.native="handleSearch"
       >
-        <el-button slot="append" icon="el-icon-search" @click="handleSearch"></el-button>
+        <el-button
+          slot="append"
+          icon="el-icon-search"
+          @click="handleSearch"
+        ></el-button>
       </el-input>
     </div>
 
     <!-- 表格区域 -->
     <el-table
       :data="tableData"
-
       style="width: 100%; margin-top: 20px"
       v-loading="loading"
     >
-      <el-table-column prop="sysNo" label="系统类别编号" width="180"></el-table-column>
-      <el-table-column prop="sysName" label="系统类别名称" width="180"></el-table-column>
+      <el-table-column
+        prop="sysNo"
+        label="系统类别编号"
+        width="180"
+      ></el-table-column>
+      <el-table-column
+        prop="sysName"
+        label="系统类别名称"
+        width="180"
+      ></el-table-column>
       <el-table-column prop="sysRemark" label="备注"></el-table-column>
-      <el-table-column prop="sysProducts" label="产品数" width="120"></el-table-column>
+      <el-table-column
+        prop="sysProducts"
+        label="产品数"
+        width="120"
+      ></el-table-column>
       <el-table-column label="操作" width="250" fixed="right">
         <template slot-scope="scope">
           <el-button size="mini" @click="handleView(scope.row)">查看</el-button>
-          <el-button size="mini" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
-          <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
+          <el-button size="mini" type="primary" @click="handleEdit(scope.row)"
+            >编辑</el-button
+          >
+          <el-button size="mini" type="danger" @click="handleDelete(scope.row)"
+            >删除</el-button
+          >
         </template>
       </el-table-column>
     </el-table>
@@ -61,181 +80,217 @@
         :validate-on-rule-change="false"
       >
         <el-form-item label="系统类别编号" prop="sysNo">
-          <el-input v-model="form.sysNo" :disabled="dialogTitle === '编辑系统类别'"></el-input>
+          <el-input
+            v-model="form.sysNo"
+            :disabled="dialogTitle === '编辑系统类别'"
+          ></el-input>
         </el-form-item>
         <el-form-item label="系统类别名称" prop="sysName">
           <el-input v-model="form.sysName"></el-input>
         </el-form-item>
         <el-form-item label="备注" prop="sysRemark">
-          <el-input type="textarea" v-model="form.sysRemark" rows="3"></el-input>
+          <el-input
+            type="textarea"
+            v-model="form.sysRemark"
+            rows="3"
+          ></el-input>
         </el-form-item>
       </el-form>
       <div slot="footer">
         <el-button @click="cancelForm">取 消</el-button>
-        <el-button type="primary" @click="submitForm" :loading="submitLoading">确 定</el-button>
+        <el-button type="primary" @click="submitForm" :loading="submitLoading"
+          >确 定</el-button
+        >
       </div>
     </el-dialog>
 
     <!-- 查看详情对话框 -->
-    <el-dialog title="查看系统类别" :visible.sync="viewDialogVisible" width="500px">
+    <el-dialog
+      title="查看系统类别"
+      :visible.sync="viewDialogVisible"
+      width="500px"
+    >
       <el-descriptions :column="1" border>
-        <el-descriptions-item label="系统类别编号">{{ viewForm.systemCode }}</el-descriptions-item>
-        <el-descriptions-item label="系统类别名称">{{ viewForm.systemName }}</el-descriptions-item>
-        <el-descriptions-item label="备注">{{ viewForm.sysRemark || '-' }}</el-descriptions-item>
-        <el-descriptions-item label="产品数">{{ viewForm.productCount }}</el-descriptions-item>
+        <el-descriptions-item label="系统类别编号">{{
+          viewForm.sysNo
+        }}</el-descriptions-item>
+        <el-descriptions-item label="系统类别名称">{{
+          viewForm.sysName
+        }}</el-descriptions-item>
+        <el-descriptions-item label="备注">{{
+          viewForm.sysRemark || "-"
+        }}</el-descriptions-item>
+        <el-descriptions-item label="产品数">{{
+          viewForm.sysProducts
+        }}</el-descriptions-item>
       </el-descriptions>
     </el-dialog>
   </div>
 </template>
 
 <script>
-
-import { add, list,update } from '@/api/sysCategory/sysCategory'
-import { listWork } from '@/api/worksCategory/worksCategory'
-
+import { add, list, update } from "@/api/sysCategory/sysCategory";
+import { listWork } from "@/api/worksCategory/worksCategory";
 
 export default {
-  name: 'SystemCategoryManagement',
+  name: "SystemCategoryManagement",
   data() {
     return {
-      searchQuery: '',
+      searchQuery: "",
       loading: false,
       submitLoading: false,
       tableData: [
         {
-          systemCode: 'pjxs',
-          systemName: '拼接显示',
-          sysRemark: '',
-          productCount: 500
-        }
+          systemCode: "pjxs",
+          systemName: "拼接显示",
+          sysRemark: "",
+          productCount: 500,
+        },
       ],
       pagination: {
         currentPage: 1,
         pageSize: 10,
-        total: 1
+        total: 1,
       },
       dialogVisible: false,
       viewDialogVisible: false,
-      dialogTitle: '',
+      dialogTitle: "",
       form: {
-        sysNo: '',
-        sysName: '',
-        sysRemark: ''
+        sysNo: "",
+        sysName: "",
+        sysRemark: "",
       },
       formQuery: {
-        sysNo: ''
+        sysNo: "",
       },
 
       viewForm: {
-        sysNo: '',
-        sysName: '',
-        sysRemark: '',
-        productCount: 0
+        sysNo: "",
+        sysName: "",
+        sysRemark: "",
+        productCount: 0,
       },
       rules: {
         sysNo: [
-          { required: true, message: '请输入系统类别编号', trigger: 'blur' },
-          { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
+          { required: true, message: "请输入系统类别编号", trigger: "blur" },
+          {
+            min: 2,
+            max: 20,
+            message: "长度在 2 到 20 个字符",
+            trigger: "blur",
+          },
         ],
         sysName: [
-          { required: true, message: '请输入系统类别名称', trigger: 'blur' },
-          { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
-        ]
-      }
-    }
+          { required: true, message: "请输入系统类别名称", trigger: "blur" },
+          {
+            min: 2,
+            max: 50,
+            message: "长度在 2 到 50 个字符",
+            trigger: "blur",
+          },
+        ],
+      },
+    };
   },
   methods: {
     async loadData() {
-      this.loading = true
+      this.loading = true;
       try {
-        list(this.formQuery).then(response => {
+        const params = {
+          ...this.formQuery,
+          pageNum: this.pagination.currentPage,
+          pageSize: this.pagination.pageSize,
+        };
+        list(params).then((response) => {
           this.tableData = response.rows;
-          this.total = response.total;
+          this.pagination.total = response.total;
           this.loading = false;
         });
       } catch (error) {
-        this.$message.error('加载数据失败')
+        this.$message.error("加载数据失败");
       } finally {
-        this.loading = false
+        this.loading = false;
       }
     },
     handleSearch() {
-      this.pagination.currentPage = 1
-      this.loadData()
+      this.pagination.currentPage = 1;
+      this.loadData();
     },
     handleAdd() {
-      this.dialogTitle = '新建系统类别'
+      this.dialogTitle = "新建系统类别";
       this.form = {
-        systemCode: '',
-        systemName: '',
-        sysRemark: ''
-      }
-      this.dialogVisible = true
+        systemCode: "",
+        systemName: "",
+        sysRemark: "",
+      };
+      this.dialogVisible = true;
       this.$nextTick(() => {
-        this.$refs.form.clearValidate()
-      })
+        this.$refs.form.clearValidate();
+      });
     },
     handleEdit(row) {
-      this.dialogTitle = '编辑系统类别'
-      this.form = { ...row }
-      this.dialogVisible = true
+      this.dialogTitle = "编辑系统类别";
+      this.form = { ...row };
+      this.dialogVisible = true;
       this.$nextTick(() => {
-        this.$refs.form.clearValidate()
-      })
+        this.$refs.form.clearValidate();
+      });
     },
     handleView(row) {
-      this.viewForm = { ...row }
-      this.viewDialogVisible = true
+      this.viewForm = { ...row };
+      this.viewDialogVisible = true;
     },
     handleDelete(row) {
-      this.$confirm('确认删除该系统类别?删除后不可恢复', '提示', {
-        type: 'warning',
-        confirmButtonText: '确定',
-        cancelButtonText: '取消'
-      }).then(async () => {
-        try {
-          // await deleteSystemCategory(row.systemCode)
-          this.$message.success('删除成功')
-          this.loadData()
-        } catch (error) {
-          this.$message.error('删除失败')
-        }
-      }).catch(() => {})
+      this.$confirm("确认删除该系统类别?删除后不可恢复", "提示", {
+        type: "warning",
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+      })
+        .then(async () => {
+          try {
+            // await deleteSystemCategory(row.systemCode)
+            this.$message.success("删除成功");
+            this.loadData();
+          } catch (error) {
+            this.$message.error("删除失败");
+          }
+        })
+        .catch(() => {});
     },
     handleSizeChange(val) {
-      this.pagination.pageSize = val
-      this.loadData()
+      this.pagination.pageSize = val;
+      this.loadData();
     },
     handleCurrentChange(val) {
-      this.pagination.currentPage = val
-      this.loadData()
+      this.pagination.currentPage = val;
+      this.loadData();
     },
     cancelForm() {
-      this.dialogVisible = false
-      this.$refs.form.clearValidate()
+      this.dialogVisible = false;
+      this.$refs.form.clearValidate();
     },
     async submitForm() {
       this.$refs.form.validate(async (valid) => {
         if (valid) {
-          this.submitLoading = true
+          this.submitLoading = true;
           try {
             const api = this.dialogTitle === "新建系统类别" ? add : update;
-          const message =
-            this.dialogTitle === "新建系统类别" ? "添加成功" : "更新成功";
+            const message =
+              this.dialogTitle === "新建系统类别" ? "添加成功" : "更新成功";
 
-          api(this.form)
-            .then((res) => {
-              if (res.code === 200) {
-                this.$message.success(message);
-                this.dialogVisible = false;
-                this.loadData();
-              } else {
-                this.$message.error(res.message || "操作失败");
-              }
-            })
-            .catch(() => {
-              this.$message.error("操作失败");
-            });
+            api(this.form)
+              .then((res) => {
+                if (res.code === 200) {
+                  this.$message.success(message);
+                  this.dialogVisible = false;
+                  this.loadData();
+                } else {
+                  this.$message.error(res.message || "操作失败");
+                }
+              })
+              .catch(() => {
+                this.$message.error("操作失败");
+              });
 
             /* add(this.form).then(response => {
               this.open = false;
@@ -248,18 +303,18 @@ export default {
             this.dialogVisible = false
             this.loadData() */
           } catch (error) {
-            this.$message.error('保存失败')
+            this.$message.error("保存失败");
           } finally {
-            this.submitLoading = false
+            this.submitLoading = false;
           }
         }
-      })
-    }
+      });
+    },
   },
   created() {
-    this.loadData()
-  }
-}
+    this.loadData();
+  },
+};
 </script>
 
 <style scoped>