Browse Source

张丁 修改预约作业票新增和修改结构

zhangding 3 years ago
parent
commit
021a78bdfc

+ 21 - 5
master/src/main/java/com/ruoyi/project/invoice/controller/TInvoiceBookingworkticketController.java

@@ -88,7 +88,10 @@ public class TInvoiceBookingworkticketController extends BaseController
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
-        return AjaxResult.success(tInvoiceBookingworkticketService.selectTInvoiceBookingworkticketById(id));
+      TInvoiceBookingworkticket t=  tInvoiceBookingworkticketService.selectTInvoiceBookingworkticketById(id);
+      List<TInvoiceWorkcontent>  list= tInvoiceWorkcontentService.selectTInvoiceWorkcontentBybookingticketId(t.getId());
+           t.settInvoiceWorkcontentList(list);
+        return AjaxResult.success(t);
     }
 
     /**
@@ -101,12 +104,20 @@ public class TInvoiceBookingworkticketController extends BaseController
     {
        //先查当前登录的用户关联的承包商信息
         LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
-     TInvoiceContractor t= tInvoiceContractorService.selectTInvoiceContractorByName(loginUser.getUsername());
+        TInvoiceContractor t= tInvoiceContractorService.selectTInvoiceContractorByName(loginUser.getUsername());
         tInvoiceBookingworkticket.setCreaterCode(getUserId());
-        tInvoiceBookingworkticket.setContact(t.getContact());
-        tInvoiceBookingworkticket.setPhonenumber(t.getPhonenumber());
+      /*  tInvoiceBookingworkticket.setContact(t.getContact());
+        tInvoiceBookingworkticket.setPhonenumber(t.getPhonenumber());*/
         tInvoiceBookingworkticketService.insertTInvoiceBookingworkticket(tInvoiceBookingworkticket);
-        return AjaxResult.success(tInvoiceBookingworkticket.getId());
+        Long didi=tInvoiceBookingworkticket.getId();
+        List<TInvoiceWorkcontent>  w=tInvoiceBookingworkticket.gettInvoiceWorkcontentList();
+
+        for(int i=0;i<w.size();i++){
+             TInvoiceWorkcontent wt= w.get(i);
+            wt.setBookingticketId(didi);
+            tInvoiceWorkcontentService.insertTInvoiceWorkcontent(wt);
+        }
+        return AjaxResult.success(didi);
     }
 
     /**
@@ -117,6 +128,11 @@ public class TInvoiceBookingworkticketController extends BaseController
     @PutMapping
     public AjaxResult edit(@RequestBody TInvoiceBookingworkticket tInvoiceBookingworkticket)
     {
+        List<TInvoiceWorkcontent>  list =tInvoiceBookingworkticket.gettInvoiceWorkcontentList();
+        for(int i=0;i<list.size();i++){
+            TInvoiceWorkcontent wt= list.get(i);
+            tInvoiceWorkcontentService.updateTInvoiceWorkcontent(wt);
+        }
         return toAjax(tInvoiceBookingworkticketService.updateTInvoiceBookingworkticket(tInvoiceBookingworkticket));
     }
 

+ 25 - 50
ui/src/views/invoice/bookingworkticket/index.vue

@@ -139,6 +139,10 @@
           <span>{{ parseTime(scope.row.workEndTime, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
+        
+                 
+                   
+                   
       <el-table-column label="联系人" align="center" prop="contact" :show-overflow-tooltip="true"/>
       <el-table-column label="联系方式" align="center" prop="phonenumber" :show-overflow-tooltip="true"/>
       <el-table-column label="状态" align="center" prop="status" width="100" :formatter="statusFormat" />
@@ -406,6 +410,9 @@ export default {
   components: { Treeselect },
   data() {
     return {
+      tInvoiceWorkcontentList:[],
+        //作业内容表头
+      tabletou:['作业类型','风险等级','作业内容描述','作业人员数','作业预计时间','监护人单位'],
       //用户名和承包商名
       username:"",
       //bookticked关联ID
@@ -514,6 +521,7 @@ export default {
       this.$nextTick(() => {
           this.clientHeight = document.body.clientHeight -250
       })
+           this.getList();
     this.getTreeselect();
       this.getDicts("booking_work_status").then(response => {
       this.statusOptions = response.data;
@@ -545,7 +553,7 @@ export default {
     this.getDicts("book_guardian_unit").then(response => {
       this.guardianUnitOptions = response.data;
     });
-      this.getList();
+ 
   },
   methods: {
 // 表单添加一行
@@ -576,37 +584,19 @@ export default {
 
     /** 查询预约作业票台账列表 */
     getList() {
-       this.getDicts("book_work_unit").then(response => {
-      this.workUnitOptions = response.data;
         this.loading = true;
-      //查到登陆用户的角色和名称 
-          var name = this.$store.state.user.name;
-          var roles =this.$store.state.user.roles
-          this.bookingworkticketList=[]
-          //先判断用户是否是承包商
-        //  debugger
-        for(var i=0;i<this.workUnitOptions.length;i++ ) {
-               if(name==this.workUnitOptions[i].remark){
-               this.username =this.workUnitOptions[i].dictValue;
-               }
+       listBookingworkticket(this.queryParams).then(response => {
+         this.bookingworkticketList=response.rows;
+        for (let i = 0; i <  this.bookingworkticketList.length; i++) {
+  if( this.bookingworkticketList[i].tInvoiceWorkcontentList) {
+    this.tInvoiceWorkcontentList =  this.bookingworkticketList[i].tInvoiceWorkcontentList
+  }
         }
-        //如果是承包商 就循环遍历出这个承包商所预约的
-      listBookingworkticket(this.queryParams).then(response => {
-        console.log(response)
-        let btlist =response.rows;
-         for(var i=0;i<btlist.length;i++){
-          if(this.username==btlist[i].workUnit){
-              this.bookingworkticketList.push(btlist[i]);
-                 this.total = this.bookingworkticketList.total;
-          }else{
-              this.bookingworkticketList=response.rows;
-                 this.total = response.total;
-          }
-         }
+        this.tInvoiceWorkcontentList.tabletou=this.tabletou;
+        this.total = response.total;
         this.loading = false;
+        console.log(this.tInvoiceWorkcontentList)
       });
-    });
-     
     },
      /** 查询部门下拉树结构 */
      getTreeselect() {
@@ -705,12 +695,10 @@ export default {
       this.reset();
       this.resetForm1();
         var roles =this.$store.state.user.roles
-      if(roles=="cbs"){
+  
    this.open = true;
       this.title = "添加预约作业票台账";
-      }else{
-           this.msgSuccess("承包商用户才可申请预约作业票");
-      }
+    
    
     },
     /** 修改按钮操作 */
@@ -721,10 +709,7 @@ export default {
         this.form = response.data;
         this.open = true;
         this.title = "修改预约作业票台账";
-          let bookingticketId=this.form.id
-        getWorkcontentBybookingticketId(bookingticketId).then(response => {
-          this.ruleForm=response.data
-          });
+        this.ruleForm=response.data.tInvoiceWorkcontentList
       });
     },
     /** 提交按钮 */
@@ -732,27 +717,17 @@ export default {
       this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.id != null) {
+              this.form.tInvoiceWorkcontentList=this.ruleForm
             updateBookingworkticket(this.form).then(response => {
-              //修改的时候先修改作业票台账,在根据关联id修改相关的 作业内容子项
-               this.btid=response.data;
-               for(var i=0;i<this.ruleForm.length;i++){
-                   this.ruleForm[i].bookingticketId=this.btid;
-                 updateWorkcontent(this.ruleForm[i]).then(response => {
-            });
-               }
+          
               this.msgSuccess("修改成功");
               this.open = false;
               this.getList();
             });
           } else {
+            this.form.tInvoiceWorkcontentList=this.ruleForm
             addBookingworkticket(this.form).then(response => {
-              //取得返回的关联id,然后多个作业内容数据表单 插入到后台
-                 this.btid=response.data;
-                for(var i=0;i<this.ruleForm.length;i++){
-                   this.ruleForm[i].bookingticketId=this.btid;
-                 addWorkcontent(this.ruleForm[i]).then(response => {
-            });
-              }
+
            this.msgSuccess("新增成功");
               this.open = false;
               this.getList();