Bladeren bron

云模盒管理页面又改了一堆

Reiskuchen 5 jaren geleden
bovenliggende
commit
a714839bdd
1 gewijzigde bestanden met toevoegingen van 35 en 47 verwijderingen
  1. 35 47
      ys_vue/src/views/base/allocation.vue

+ 35 - 47
ys_vue/src/views/base/allocation.vue

@@ -32,15 +32,15 @@
       style="width: 100%;"
     >
       <el-table-column type="index" width="60"></el-table-column>
-      <el-table-column prop="id" label="云模盒编号" width="120" sortable></el-table-column>
-      <el-table-column prop="power" label="电量" width="80" sortable></el-table-column>
+      <el-table-column prop="equipmentNo" label="云模盒编号" width="120" sortable></el-table-column>
+      <el-table-column label="电量" width="80" sortable></el-table-column>
       <el-table-column prop="useLife" label="倒计时" width="100" sortable></el-table-column>
       <el-table-column prop="equipmentName" label="模具名称" width="100" sortable></el-table-column>
-      <el-table-column prop="equipmentNo" label="模具编号" width="120" sortable></el-table-column>
+      <el-table-column label="模具编号" width="120" sortable></el-table-column>
       <el-table-column prop="belongCompanyId" label="资产方" width="120" sortable></el-table-column>
-      <el-table-column prop="state" label="模具状态" width="100" sortable>
+      <el-table-column label="模具状态" width="100" sortable>
         <template slot-scope="scope">
-          <span v-if="scope.row.isUse == 1">未启用</span>
+          <span v-if="scope.row.isUse == 0">未启用</span>
           <span v-else>已启用</span>
         </template>
       </el-table-column>
@@ -50,9 +50,9 @@
             size="small"
             type="primary"
             @click="enable(scope.$index)"
-            :disabled="scope.row.state == true"
+            :disabled="scope.row.isUse == 1"
           >启用</el-button>
-          <el-button size="small" @click="showEdit(5)">修改</el-button>
+          <el-button size="small" @click="showEdit(scope.row.id)">修改</el-button>
           <el-button type="danger" size="small">删除</el-button>
         </template>
       </el-table-column>
@@ -87,7 +87,7 @@
         :inline="true"
         class="demo-form-inline"
       >
-        <el-form-item label="设备号">
+        <el-form-item label="云模盒编号">
           <el-input v-model="newAllocation.equipmentNo" autocomplete="off" placeholder="请填写"></el-input>
         </el-form-item>
         <el-form-item label="所属公司">
@@ -128,7 +128,7 @@
         :inline="true"
         class="demo-form-inline"
       >
-        <el-form-item label="设备号">
+        <el-form-item label="云模盒编号">
           <el-input v-model="newAllocation.equipmentNo" autocomplete="off" placeholder="请填写"></el-input>
         </el-form-item>
         <el-form-item label="所属公司">
@@ -155,7 +155,7 @@
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click.native="editFormVisible = false">取消</el-button>
-        <el-button type="primary" @click="editMould">提交</el-button>
+        <el-button type="primary" @click="editMould(newAllocation.id)">提交</el-button>
       </div>
     </el-dialog>
   </section>
@@ -166,27 +166,7 @@ import util from "../../common/js/util";
 export default {
   data() {
     return {
-      allocations: [
-        //临时数据
-        {
-          id: "1234567",
-          power: "N/A",
-          useLife: "400天",
-          equipmentName: "墨盒",
-          equipmentNo: "MUJU123456",
-          belongCompanyId: "南京火石闪信",
-          isUse: 1
-        },
-        {
-          id: "7891011",
-          power: "N/A",
-          useLife: "100天",
-          equipmentName: "墨盒2",
-          equipmentNo: "MUJU654321",
-          belongCompanyId: "南京火石闪信",
-          isUse: 0
-        }
-      ],
+      allocations: [],
       companies: {},
       newAllocation: {
         equipmentNo: "", //设备编号
@@ -202,7 +182,11 @@ export default {
       },
       formRules: {},
       listLoading: false,
+      addLoading: false,
+      editLoading: false,
       total: 0,
+      page: 1,
+      size: 20,
       tableHeight: 0,
       addFormVisible: false,
       editFormVisible: false
@@ -212,24 +196,23 @@ export default {
     //分页
     handleCurrentChange(val) {
       this.page = val;
-      // this.getMoulds();
+      this.getMoulds();
     },
     handleSizeChange(val) {
       this.size = val;
-      // this.getMoulds();
+      this.getMoulds();
     },
     //读取云模盒信息
-    getMould() {
+    getMoulds() {
+      this.listLoading = true;
       this.http.post(
         this.port.base.mouldeList,
         {},
         res => {
-          this.allocations = res.data.list;
+          this.listLoading = false;
           if (res.code == "ok") {
-            this.$message({
-              message: "成功",
-              type: "success"
-            });
+            this.allocations = res.data.list;
+            this.total = res.data.total;
           } else {
             this.$message({
               message: res.msg,
@@ -238,6 +221,7 @@ export default {
           }
         },
         error => {
+          this.listLoading = false;
           this.$message({
             message: error,
             type: "error"
@@ -271,7 +255,7 @@ export default {
     addMould() {
       this.$refs.newAllocation.validate(valid => {
         if (valid) {
-          this.editLoading = true;
+          this.addLoading = true;
           this.http.post(
             this.port.base.editMould,
             {
@@ -279,13 +263,14 @@ export default {
               belongCompanyId: this.newAllocation.belongCompanyId
             },
             res => {
-              this.editLoading = false;
-              this.editFormVisible = false;
+              this.addLoading = false;
+              this.addFormVisible = false;
               if (res.code == "ok") {
                 this.$message({
                   message: "添加成功",
                   type: "success"
                 });
+                this.getMoulds();
               } else {
                 this.$message({
                   message: res.msg,
@@ -294,8 +279,8 @@ export default {
               }
             },
             error => {
-              this.editLoading = false;
-              this.editFormVisible = false;
+              this.addLoading = false;
+              this.addFormVisible = false;
               this.$message({
                 message: error,
                 type: "error"
@@ -327,6 +312,7 @@ export default {
                   message: "添加成功",
                   type: "success"
                 });
+                this.getMoulds();
               } else {
                 this.$message({
                   message: res.msg,
@@ -348,13 +334,13 @@ export default {
     },
     //启用设备
     enable(index) {
-      this.allocations[index].state = true;
+      this.allocations[index].isUse = 1;
       //启用设备调用
       this.http.post(
         this.port.base.enableMould,
         {
           //数是瞎写的
-          id: 1,
+          id: this.allocations[index].id,
           isUse: 1
         },
         res => {
@@ -385,6 +371,9 @@ export default {
     this.tableHeight = height - 210;
   },
   mounted() {
+    //获取模具列表
+    this.getMoulds();
+    //获取公司下拉列表
     this.http.post(
       this.port.base.comps,
       {},
@@ -405,7 +394,6 @@ export default {
         });
       }
     );
-    this.getMould();
   }
 };
 </script>