Browse Source

接口制作与完善,前端界面完成

kindring 2 năm trước cách đây
mục cha
commit
bc397a376f
1 tập tin đã thay đổi với 55 bổ sung18 xóa
  1. 55 18
      web_src/src/components/dialog/editLibItem.vue

+ 55 - 18
web_src/src/components/dialog/editLibItem.vue

@@ -99,13 +99,13 @@ export default {
       this.showThisDialog = true;
     },
     resetData(){
-      this.itemName = this.rawData.itemName;
-      this.imageUrl = "";
+      this.itemName = this.isEdit?this.rawData.itemName:'';
+      this.imageUrl = this.isEdit?"":'';
       this.uploadFile = null;
-      this.itemNo = this.rawData.itemNo;
-      this.itemType = this.rawData.itemType;
-      this.trait = this.rawData.trait;
-      this.carNo = this.rawData.carNo;
+      this.itemNo = this.isEdit?this.rawData.itemNo:'';
+      this.itemType = this.isEdit?this.rawData.itemType:'';
+      this.trait =  this.rawData.trait;
+      this.carNo =  this.isEdit?this.rawData.carNo:'';
     },
     async loadLibItemData(){
       this.isLoading = true;
@@ -144,24 +144,61 @@ export default {
       }
     },
     async addHandle(){
-      let addParam = {
-        itemName: this.itemName,
-        itemNo: this.itemNo,
-
-      }
-      if(this.arithmetic === this.aiTypes.face){
-        addParam.idCard = this.idCard;
-        if(!this.uploadFile){return this.$message.warning('上传文件')}
-        addParam.img = this.uploadFile;
-      }
       let formData = new FormData();
       formData.append("itemName",this.itemName);
       formData.append("itemNo",this.itemNo);
-      formData.append("itemName",this.itemName);
+      if(this.arithmetic === this.aiTypes.face){
+        formData.append("idCard",this.idCard);
+        if(!this.uploadFile){return this.$message.warning('上传文件')}
+        formData.append("img",this.uploadFile);
+      }
+      this.isLoading = true;
+      let [err,res] = await handle(this.$axios.post(`/api/device/query/addLibItem/${this.libraryId}`,formData));
+      this.isLoading = false;
+      if(err){
+        return this.$message.warning(err.message);
+      }
+      this.$message.success("添加子项成功")
     },
-    editHandle(){
+    async editHandle(){
       // 获取编辑项
+      let formData = new FormData();
+      let changedTotal = 0;
+      if(this.itemName !== this.rawData.itemName){
+        changedTotal++;
+        formData.append("itemName",this.itemName);
+      }
+      if(this.itemNo !== this.rawData.itemNo){
+        changedTotal++;
+        formData.append("itemNo",this.itemNo);
+      }
+
+
 
+
+      if(this.arithmetic === this.aiTypes.face){
+        if(this.idCard !== this.rawData.idCard){
+          changedTotal++;
+          formData.append("idCard",this.idCard);
+        }
+        if(this.uploadFile){
+          changedTotal++;
+          formData.append("img",this.uploadFile);
+        }
+      }else if(this.arithmetic === this.aiTypes.carPlate){
+        if(this.carNo !== this.rawData.carNo){
+          changedTotal++;
+          formData.append("carNo",this.carNo);
+        }
+      }
+      if(changedTotal<1){this.$message.warning("没有修改项")}
+      this.isLoading = true;
+      let [err,res] = await handle(this.$axios.post(`/api/device/query/editLibItem/${this.itemId}`,formData));
+      this.isLoading = false;
+      if(err){
+        return this.$message.warning(err.message);
+      }
+      this.$message.success("修改子项成功");
     }
   },