浏览代码

-修改了申请开票的修改逻辑
-新增了申请开票作废的流程

jiangbiao 2 年之前
父节点
当前提交
87020cb90b

+ 32 - 5
master/src/main/java/com/ruoyi/project/invoice/controller/TApproveReserveInvoiceController.java

@@ -127,7 +127,7 @@ public class TApproveReserveInvoiceController extends BaseController {
         String devSupId = "";
         for (String id : ids) {
             TInvoiceBookingworkticket invoice = workService.getById(id);
-            invoice.setStatus(1L);
+            invoice.setStatus(0L);
             workService.updateById(invoice);
             switch (invoice.getWorkArea()) {
                 case "310裂解区":
@@ -205,6 +205,7 @@ public class TApproveReserveInvoiceController extends BaseController {
         variables.put("zzgcsTaskCreateListener", new ZzgcsTaskCreateListener());//装置工程师监听发送邮件
         variables.put("zzjlTaskCreateListener", new ZzjlTaskCreateListener());//装置经理监听发送邮件
         variables.put("invoiceEndSuccessListener", new InvoiceEndSuccessListener());//流程结束监听发送邮件
+        variables.put("invoiceEndFailListener", new InvoiceEndFailListener());//流程结束监听发送邮件
         //采用key来启动流程定义并设置流程变量,返回流程实例
         ProcessInstance pi = runtimeService.startProcessInstanceByKey("reserveInvoice", String.valueOf(bussniseeKey), variables);
         logger.info("流程部署id:" + pi.getDeploymentId());
@@ -230,6 +231,7 @@ public class TApproveReserveInvoiceController extends BaseController {
         //利用任务对象,获取流程实例id
         String processInstancesId = task.getProcessInstanceId();
         TApproveReserveInvoice invoice = tApproveReserveInvoiceService.selectTApproveReserveInvoiceById(Long.parseLong(devTask.getBusinessKey()));
+        TInvoiceBookingworkticket invoiceBook = workService.getById(invoice.getInvoiceId());
         if (devTask.getCondition().equals("1")) {
             devTask.setComment("通过" + symbol + devTask.getComment());
             invoice.setStatus(2L);
@@ -238,25 +240,49 @@ public class TApproveReserveInvoiceController extends BaseController {
             devTask.setComment("未通过" + symbol + devTask.getComment());
             invoice.setStatus(3L);
             invoice.setEnddate(new Date());
+            invoiceBook.setStatus(7L);
         }
         Map<String, Object> param = new HashMap<>();
-
-        TInvoiceBookingworkticket invoiceBook = workService.getById(invoice.getInvoiceId());
+        List<TInvoiceWorkcontent> workcontents = invoiceWorkcontentMapper.selectTInvoiceWorkcontentBybookingticketId(Long.valueOf(invoice.getInvoiceId()));
+        if (task.getName().equals("用户主管签字确认")) {
+            invoice.setDevSupId(getUserId());
+            invoiceBook.setStatus(2L);
+        }
         if (task.getName().equals("装置主管签字确认")) {
             invoice.setDevSupId(getUserId());
+            if (DateUtils.dateTime(invoiceBook.getCreatedate()).equals(DateUtils.dateTime(invoiceBook.getWorkStartTime()))) {
+                invoiceBook.setStatus(5L);
+            }else {
+                for (TInvoiceWorkcontent workcontent : workcontents) {
+                    if (workcontent.getWorkType() == 1 || workcontent.getWorkType() == 15) {
+                        invoiceBook.setStatus(6L);
+                        break;
+                    } else {
+                        invoiceBook.setStatus(3L);
+                    }
+                }
+            }
         }
         if (task.getName().equals("装置工程师签字确认")) {
             invoice.setDevEngineerId(getUserId());
+            for (TInvoiceWorkcontent workcontent : workcontents) {
+                if (workcontent.getWorkType() == 1 || workcontent.getWorkType() == 15) {
+                    invoiceBook.setStatus(6L);
+                    break;
+                } else {
+                    invoiceBook.setStatus(3L);
+                }
+            }
         }
         if (task.getName().equals("装置经理签字确认")) {
             invoice.setManagerconId(getUserId());
+            invoiceBook.setStatus(3L);
         }
         if (DateUtils.dateTime(invoiceBook.getCreatedate()).equals(DateUtils.dateTime(invoiceBook.getWorkStartTime()))) {
             param.put("istoday", "1");
         } else {
             param.put("istoday", "0");
         }
-        List<TInvoiceWorkcontent> workcontents = invoiceWorkcontentMapper.selectTInvoiceWorkcontentBybookingticketId(Long.valueOf(invoice.getInvoiceId()));
         for (TInvoiceWorkcontent workcontent : workcontents) {
             if (workcontent.getWorkType() == 1 || workcontent.getWorkType() == 15) {
                 param.put("isspecial", "1");
@@ -268,12 +294,13 @@ public class TApproveReserveInvoiceController extends BaseController {
         param.put("condition", devTask.getCondition());
         ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
         TaskService taskService = processEngine.getTaskService();
+        tApproveReserveInvoiceService.updateTApproveReserveInvoice(invoice);
+        workService.updateTInvoiceBookingworkticket(invoiceBook);
         //认领任务
         processEngine.getTaskService()
                 .claim(taskId, getUserId().toString());
         taskService.addComment(taskId, processInstancesId, devTask.getComment());
         taskService.complete(taskId, param);
-        tApproveReserveInvoiceService.updateTApproveReserveInvoice(invoice);
         return AjaxResult.success();
     }
 

+ 9 - 0
master/src/main/java/com/ruoyi/project/invoice/domain/TInvoiceBookingworkticketVo.java

@@ -23,6 +23,15 @@ public class TInvoiceBookingworkticketVo extends BaseEntity
     private String workDescription;
     private String workPeopleNumber;
     private String estimateWorktime;
+    private Long bookingticketId;
+
+    public Long getBookingticketId() {
+        return bookingticketId;
+    }
+
+    public void setBookingticketId(Long bookingticketId) {
+        this.bookingticketId = bookingticketId;
+    }
 
     public String getStatus() {
         return status;

+ 90 - 0
master/src/main/java/com/ruoyi/project/listener/invoiceApprove/InvoiceEndFailListener.java

@@ -0,0 +1,90 @@
+package com.ruoyi.project.listener.invoiceApprove;
+
+import com.alibaba.fastjson.JSON;
+import com.github.stuxuhai.jpinyin.PinyinFormat;
+import com.github.stuxuhai.jpinyin.PinyinHelper;
+import com.ruoyi.common.sendEmail.IMailService;
+import com.ruoyi.common.utils.SpringContextUtils;
+import com.ruoyi.project.invoice.domain.TApproveReserveInvoice;
+import com.ruoyi.project.invoice.domain.TInvoiceBookingworkticket;
+import com.ruoyi.project.invoice.service.ITApproveReserveInvoiceService;
+import com.ruoyi.project.invoice.service.ITInvoiceBookingworkticketService;
+import com.ruoyi.project.system.service.ISysUserService;
+import org.activiti.engine.delegate.DelegateExecution;
+import org.activiti.engine.delegate.ExecutionListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Service("invoiceEndFailListener")
+public class InvoiceEndFailListener implements Serializable, ExecutionListener {
+    protected Logger logger = LoggerFactory.getLogger(getClass());
+
+
+    @Override
+    public void notify(DelegateExecution delegateExecution) {
+        String id = delegateExecution.getProcessInstanceBusinessKey();
+        logger.info("delegateExecution--------------------------------" + delegateExecution);
+        logger.info("审批id--------------------------------" + id);
+        ITApproveReserveInvoiceService tApproveReserveInvoiceService = (ITApproveReserveInvoiceService) SpringContextUtils.getBean("tApproveReserveInvoiceService");
+        ITInvoiceBookingworkticketService tInvoiceBookingworkticketService = (ITInvoiceBookingworkticketService) SpringContextUtils.getBean("tInvoiceBookingworkticketService");
+        ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
+        IMailService mailService = (IMailService) SpringContextUtils.getBean("mailService");
+        TApproveReserveInvoice approveEntity = tApproveReserveInvoiceService.selectTApproveReserveInvoiceById(Long.parseLong(id)) ;
+
+        // 修改申请状态
+        TInvoiceBookingworkticket invoiceBook = tInvoiceBookingworkticketService.selectTInvoiceBookingworkticketById(Long.valueOf(approveEntity.getInvoiceId()));
+        invoiceBook.setStatus(7L);
+        tInvoiceBookingworkticketService.updateById(invoiceBook);
+        //发送邮件
+        try {
+            String email = sysUserService.selectUserById(approveEntity.getUserId()).getEmail();
+            String apNo = approveEntity.getApNo();
+            logger.info("apNo:" + apNo);
+            String username = sysUserService.selectUserById(approveEntity.getUserId()).getNickName();
+            String usernameEN = PinyinHelper.convertToPinyinString(username, " ", PinyinFormat.WITHOUT_TONE);
+            logger.info("email:" + email);
+            logger.info("username:" + username);
+            //写html开始内容
+            String start = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title></title></head><body><div style=\"background-color:#ECECEC; padding: 35px;\">" +
+                    "<table cellpadding=\"0\" align=\"center\"" +
+                    "style=\"width: 600px; margin: 0px auto; text-align: left; position: relative; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; font-size: 14px; font-family:微软雅黑, 黑体; line-height: 1.5; box-shadow: rgb(153, 153, 153) 0px 0px 5px; border-collapse: collapse; background-position: initial initial; background-repeat: initial initial;background:#fff;\">" +
+                    "<tbody><tr><th valign=\"middle\" style=\"height: 25px; line-height: 25px; padding: 15px 35px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #42a3d3; background-color: #49bcff; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px;\">" +
+                    "<font face=\"微软雅黑\" size=\"5\" style=\"color: rgb(255, 255, 255); \">预约开票管理系统 </font><font face=\"微软雅黑\" size=\"3\" style=\"color: rgb(255, 255, 255); \">Reserve Invoice</font></th></tr>";
+            //表html中间内容
+            String prime = "";
+            String center = "<tr><td><div style=\"padding:25px 35px 40px; background-color:#fff;\"><h2 style=\"margin: 5px 0px; \">" +
+                    "<font color=\"#333333\" style=\"line-height: 20px; \"><font style=\"line-height: 22px; \" size=\"4\">" +
+                    "亲爱的 username</font><br><font style=\"line-height: 22px; \" size=\"4\">" +
+                    "Dear usernameEN</font></font></h2>" +
+                    "<p>您的申请已作废<br>" +
+                    "Your application has been voided:<br>" +
+                    "任务编号:<b>apNo</b><br>" +
+                    "Task Number: <b>apNoEN</b><br>" +
+                    "请登录<a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#/approve/pending\">预约开票申请流程</a>查看。<br>" +
+                    "Please log in the <a href=\"https://cpms.basf-ypc.net.cn/cpms/index.html#/approve/pending\">InvoiceApprove</a> to handle it.</p>" +
+                    "<p align=\"right\">date</p>" +
+                    "<div style=\"width:700px;margin:0 auto;\">" +
+                    "<div style=\"padding:10px 10px 0;border-top:1px solid #ccc;color:#747474;margin-bottom:20px;line-height:1.3em;font-size:12px;\">" +
+                    "<p>此为系统邮件,请勿回复<br>This e-Mail is an automatic reminder sent by SEMS, please do not reply</p>" +
+                    "</div></div></div></td></tr>";
+            String one = center.replaceFirst("username", username);
+            String two = one.replaceFirst("usernameEN", usernameEN);
+            String four = two.replaceFirst("apNo", apNo);
+            String five = four.replaceFirst("apNoEN", apNo);
+            String result = five.replaceFirst("date", String.valueOf(new Date()));
+            prime = prime + result;
+            //写html结尾内容
+            String end = "</tbody></table></div></body></html>";
+            //拼接html
+            String html = start + prime + end;
+            logger.info("html:" + html);
+          //  mailService.sendHtmlMail(email, "预约开票:您有一个新的待办任务 Reserve Invoice:Your application has been voided (" + apNo + ")", html);
+        }catch (Exception e) {
+            logger.error("邮件发送失败" + JSON.toJSONString(e));
+        }
+    }
+}

+ 3 - 2
master/src/main/resources/mybatis/invoice/TInvoiceBookingworkticketMapper.xml

@@ -42,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="workPeopleNumber"    column="work_people_number"    />
         <result property="estimateWorktime"    column="estimate_worktime"    />
         <result property="status"    column="status"    />
+        <result property="bookingticketId"    column="id"    />
     </resultMap>
 
     <sql id="selectTInvoiceBookingworkticketVo">
@@ -77,9 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectDetailById" parameterType="Long" resultMap="TInvoiceBookingworkticketResultVo">
-        select a.work_unit,a.work_area,a.floor_location,a.work_start_time,a.work_end_time,a.status,b.work_type,b.risk_level,b.work_description,b.work_people_number,b.estimate_worktime,a.contact,a.phonenumber
+        select a.work_unit,a.work_area,a.floor_location,a.work_start_time,a.work_end_time,a.status,b.work_type,b.risk_level,b.work_description,b.work_people_number,b.estimate_worktime,a.contact,a.phonenumber,a.id
         from  t_invoice_bookingworkticket a,t_invoice_workcontent b
-        where a.id=b.bookingticket_id and  a.id=#{id} and a.del_flag = 0
+        where a.id=b.bookingticket_id and  a.id=#{id} and a.del_flag = 0 and b.del_flag = 0
     </select>
 
     <select id="selectTInvoiceBookingworkticketById" parameterType="Long" resultMap="TInvoiceBookingworkticketResult">

+ 3 - 0
master/src/main/resources/processes/reserveInvoice.bpmn

@@ -55,6 +55,9 @@
       <conditionExpression xsi:type="tFormalExpression"><![CDATA[${condition == 1}]]></conditionExpression>
     </sequenceFlow>
     <endEvent id="end1" name="结束">
+      <extensionElements>
+        <activiti:executionListener event="start" delegateExpression="${invoiceEndFailListener}"></activiti:executionListener>
+      </extensionElements>
     </endEvent>
     <sequenceFlow id="flow24" name="不通过" sourceRef="yhzgtask" targetRef="end1">
       <conditionExpression xsi:type="tFormalExpression"><![CDATA[${condition == 0}]]></conditionExpression>

+ 493 - 85
ui/src/views/approve/approveDetail/invoice-detail.vue

@@ -1,74 +1,294 @@
 <template>
-  <el-dialog
-    :title="!this.taskForm.taskId == '' ? $t('处理') : $t('详情')"
-    :close-on-click-modal="false"
-    :visible.sync="visible"
-    :append-to-body="true">
-    <el-form :model="taskForm" :rules="dataRule"  ref="dataForm" @keyup.enter.native="" label-width="80px">
-      <el-form-item :label="$t('申请开票')">
-        <el-table :data="devList" :span-method="mergeMethod" border style="width: 100%;">
-          <el-table-column label="作业单位" align="center" prop="workUnit" :show-overflow-tooltip="true"/>
-          <el-table-column label="作业区域单元" align="center" prop="workArea" :show-overflow-tooltip="true"/>
-          <el-table-column label="楼层位置" align="center" prop="floorLocation" :formatter="floorLocationFormat"/>
-          <el-table-column label=" 作业开始时间" align="center" prop="workStartTime" width="100">
-            <template slot-scope="scope">
-              <span>{{ parseTime(scope.row.workStartTime, '{y}-{m}-{d}') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="作业结束时间" align="center" prop="workEndTime" width="100">
-            <template slot-scope="scope">
-              <span>{{ parseTime(scope.row.workEndTime, '{y}-{m}-{d}') }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column label="作业类型" align="center" prop="workType" :formatter="workTypeFormat"  :show-overflow-tooltip="true"/>
-          <el-table-column label="风险等级" align="center" prop="riskLevel" :formatter="riskLevelFormat"/>
-          <el-table-column label="作业内容描述" align="center" prop="workDescription" :show-overflow-tooltip="true"/>
-          <el-table-column label="作业人员数" align="center" prop="workPeopleNumber" :show-overflow-tooltip="true"/>
-          <el-table-column label="预计作业时间" align="center" prop="estimateWorktime" :show-overflow-tooltip="true"/>
-          <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"/>
-        </el-table>
-      </el-form-item>
-      <el-form-item :label="$t('申请时间')" prop="creattime">
-        <el-input v-model="dataForm.creattime" disabled></el-input>
-      </el-form-item>
-    </el-form>
-    <form ref="downloadForm" :action="downloadAction" target="FORMSUBMIT">
-      <input name="approveId" v-model="dataForm.id"  hidden  />
-      <input name="processId" v-model="dataForm.processId"  hidden  />
-    </form>
-    <span slot="footer" class="dialog-footer">
-      <el-button v-if="this.taskForm.taskId == ''" @click="visible = false">{{$t('message.return')}}</el-button>
-      <el-button v-if="!this.taskForm.taskId == ''" type="primary" @click="dataFormSubmit(1)" >{{$t('通过')}}</el-button>
-<!--      <el-button v-if="!this.taskForm.taskId == ''" type="danger" @click="dataFormSubmit(0)" :disabled="submitDisabled">{{$t('拒绝')}}</el-button>-->
+  <div>
+    <el-dialog
+      :title="!this.taskForm.taskId == '' ? $t('处理') : $t('详情')"
+      :close-on-click-modal="false"
+      :visible.sync="visible"
+      :append-to-body="true">
+      <el-form :model="taskForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="" label-width="80px">
+        <el-form-item :label="$t('申请开票')">
+          <el-table :data="devList" :span-method="mergeMethod" border style="width: 100%;">
+            <el-table-column label="作业单位" align="center" prop="workUnit" :show-overflow-tooltip="true"/>
+            <el-table-column label="作业区域单元" align="center" prop="workArea" :show-overflow-tooltip="true"/>
+            <el-table-column label="楼层位置" align="center" prop="floorLocation" :formatter="floorLocationFormat"/>
+            <el-table-column label=" 作业开始时间" align="center" prop="workStartTime" width="100">
+              <template slot-scope="scope">
+                <span>{{ parseTime(scope.row.workStartTime, '{y}-{m}-{d}') }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="作业结束时间" align="center" prop="workEndTime" width="100">
+              <template slot-scope="scope">
+                <span>{{ parseTime(scope.row.workEndTime, '{y}-{m}-{d}') }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="作业类型" align="center" prop="workType" :formatter="workTypeFormat"
+                             :show-overflow-tooltip="true"/>
+            <el-table-column label="风险等级" align="center" prop="riskLevel" :formatter="riskLevelFormat"/>
+            <el-table-column label="作业内容描述" align="center" prop="workDescription" :show-overflow-tooltip="true"/>
+            <el-table-column label="作业人员数" align="center" prop="workPeopleNumber" :show-overflow-tooltip="true"/>
+            <el-table-column label="预计作业时间" align="center" prop="estimateWorktime" :show-overflow-tooltip="true"/>
+            <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"/>
+          </el-table>
+        </el-form-item>
+        <el-form-item :label="$t('申请时间')" prop="creattime">
+          <el-input v-model="dataForm.creattime" disabled></el-input>
+        </el-form-item>
+      </el-form>
+      <form ref="downloadForm" :action="downloadAction" target="FORMSUBMIT">
+        <input name="approveId" v-model="dataForm.id" hidden/>
+        <input name="processId" v-model="dataForm.processId" hidden/>
+      </form>
+      <span slot="footer" class="dialog-footer">
+      <el-button v-if="this.taskForm.taskId == ''" @click="visible = false">{{ $t('message.return') }}</el-button>
+      <el-button v-if="!this.taskForm.taskId == ''" type="primary"
+                 @click="dataFormSubmit(1)">{{ $t('通过') }}</el-button>
+      <el-button v-if="!this.taskForm.taskId == ''&&isUserMag" type="success"
+                 @click="updateDetail">{{ $t('修改并重新申请') }}</el-button>
+      <el-button v-if="!this.taskForm.taskId == ''&&isUserMag" type="danger" @click="dataFormSubmit(0)"
+                 :disabled="submitDisabled">{{ $t('作废') }}</el-button>
     </span>
-    <div>
-      <span>{{$t('流转详情')}}</span>
-      <el-table :data="historyList" border v-loading="historyLoading" style="width: 100%;">
-        <el-table-column prop="taskName" header-align="center" align="center" :label="$t('流程进度')"></el-table-column>
-        <el-table-column prop="userName" header-align="center" align="center" :label="$t('姓名')"></el-table-column>
-        <el-table-column prop="taskCreateTime" header-align="center" align="center" :label="$t('开始时间')"></el-table-column>
-        <el-table-column prop="taskEndTime" header-align="center" align="center" :label="$t('结束时间')"></el-table-column>
-        <el-table-column prop="comment" header-align="center" align="center" :label="$t('审批意见')"></el-table-column>
-      </el-table>
-    </div>
-    <record v-if="recordVisible" ref="recordDeal"></record>
-  </el-dialog>
+      <div>
+        <span>{{ $t('流转详情') }}</span>
+        <el-table :data="historyList" border v-loading="historyLoading" style="width: 100%;">
+          <el-table-column prop="taskName" header-align="center" align="center"
+                           :label="$t('流程进度')"></el-table-column>
+          <el-table-column prop="userName" header-align="center" align="center" :label="$t('姓名')"></el-table-column>
+          <el-table-column prop="taskCreateTime" header-align="center" align="center"
+                           :label="$t('开始时间')"></el-table-column>
+          <el-table-column prop="taskEndTime" header-align="center" align="center"
+                           :label="$t('结束时间')"></el-table-column>
+          <el-table-column prop="comment" header-align="center" align="center"
+                           :label="$t('审批意见')"></el-table-column>
+        </el-table>
+      </div>
+      <record v-if="recordVisible" ref="recordDeal"></record>
+    </el-dialog>
+    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-bod :before-close="detailCancel">
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-row>
+          <el-col :span="8">
+            <el-form-item label="承包商" prop="workUnit">
+              <el-input v-model="form.workUnit" placeholder="请输入作业单位" :disabled="edit"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="作业区域" prop="workArea">
+              <el-select v-model="form.workArea" placeholder="请选择作业区域">
+                <el-option
+                  v-for="dict in workAreaOptions"
+                  :key="dict.id"
+                  :label="dict"
+                  :value="dict"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="归属部门" prop="deptId">
+              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门"/>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="楼层位置" prop="floorLocation">
+              <el-select v-model="form.floorLocation" multiple placeholder="请选择楼层位置">
+                <el-option
+                  v-for="dict in floorLocationOptions"
+                  :key="dict.dictValue"
+                  :label="dict.dictLabel"
+                  :value="parseInt(dict.dictValue)"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label=" 作业开始" prop="workStartTime">
+              <el-date-picker clearable size="small" style="width: 190px"
+                              v-model="form.workStartTime"
+                              type="date"
+                              value-format="yyyy-MM-dd"
+                              placeholder="选择 作业开始时间">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="作业结束" prop="workEndTime">
+              <el-date-picker clearable size="small" style="width: 190px"
+                              v-model="form.workEndTime"
+                              type="date"
+                              value-format="yyyy-MM-dd"
+                              placeholder="选择作业结束时间">
+              </el-date-picker>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="用户单位" prop="userUnit">
+              <el-select v-model="form.userUnit" placeholder="请选择用户单位"
+                         @change="checkCategoryPromotion(form.userUnit)">
+                <el-option
+                  v-for="dict in userUnitOptions"
+                  :key="dict.dictValue"
+                  :label="dict.dictLabel"
+                  :value="parseInt(dict.dictValue)"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="用户主管" prop="userMg">
+              <el-select v-model="form.userMg" placeholder="请先选择好用户单位">
+                <el-option
+                  v-for="dict in userMgOptions"
+                  :key="dict.userId"
+                  :label="dict.nickName"
+                  :value="dict.userId"
+                ></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <el-card v-for="(ruleForm, index) in ruleForm" :key="index" shadow="always">
+        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+          <el-row>
+            <el-col :span="18">
+              <el-form-item label="作业内容描述" prop="workDescription">
+                <el-input v-model="ruleForm.workDescription"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="3">
+              <el-button type="success" plain @click.prevent="addDomain(ruleForm)" style="float: right;">拷贝
+              </el-button>
+            </el-col>
+            <el-col :span="3">
+              <el-button type="info" plain @click.prevent="removeDomain(ruleForm)" style="float: right;">删除
+              </el-button>
+            </el-col>
+          </el-row>
+          <el-row>
+            <el-col :span="6">
+              <el-form-item label="作业类型" prop="workType">
+                <el-select v-model="ruleForm.workType" placeholder="请选择作业类型" clearable size="small">
+                  <el-option
+                    v-for="dict in workTypeOptions"
+                    :key="dict.dictValue"
+                    :label="dict.dictLabel"
+                    :value="parseInt(dict.dictValue)"
+                  />
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="风险等级" prop="riskLevel">
+                <el-select v-model="ruleForm.riskLevel" placeholder="请选择风险等级" clearable size="small">
+                  <el-option
+                    v-for="dict in riskLevelOptions"
+                    :key="dict.dictValue"
+                    :label="dict.dictLabel"
+                    :value="parseInt(dict.dictValue)"
+                  />
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="作业人数" prop="workPeopleNumber">
+                <el-input v-model="ruleForm.workPeopleNumber"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="预计作业时间" prop="estimateWorktime">
+                <el-input v-model="ruleForm.estimateWorktime"></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+      </el-card>
+
+      <el-button @click="resetForm1()">重置</el-button>
+      <el-button @click="add">新增一条</el-button>
+      <el-button @click="reduce" :disabled="flag">移除一条</el-button>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="confirmDetail">确 定</el-button>
+        <el-button @click="detailCancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
 </template>
 
 <script>
-  import {getToken} from "@/utils/auth";
-  import {getHistorylist} from "@/api/ehs/approvedanger";
-  import record from "./spec-itemDetail";
-  import {getInvoice, listInvoice,handleApprove} from "@/api/invoice/invoice";
+import {getToken} from "@/utils/auth";
+import {getHistorylist} from "@/api/ehs/approvedanger";
+import record from "./spec-itemDetail";
+import {getInvoice, listInvoice, handleApprove, addInvoice} from "@/api/invoice/invoice";
+import Bookingworkticket from "@/views/invoice/bookingworkticket/index"
+import log from "@/views/monitor/job/log";
+import {getUserByUnit} from "@/api/invoice/unit";
+import {treeselect} from "@/api/system/dept";
+import {addBookingworkticket, getBookingworkticket, updateBookingworkticket} from "@/api/invoice/bookingworkticket";
+import Treeselect from "@riophae/vue-treeselect";
 
 export default {
   name: "invoice-detail",
-  components: {record},
+  components: {record, Bookingworkticket, Treeselect},
   data() {
-    return {
+    return {// 表单校验
+      ruleForm: [{}],
+      //禁用
+      edit: true,
+      flag: true,
+      rules: {
+        workArea: [
+          {required: true, message: "作业区域不能为空", trigger: "blur"}
+        ],
+        floorLocation: [
+          {required: true, message: "楼层位置不能为空", trigger: "blur"}
+        ],
+        workStartTime: [
+          {required: true, message: "作业开始时间不能为空", trigger: "blur"}
+        ],
+        workEndTime: [
+          {required: true, message: "作业结束时间不能为空", trigger: "blur"}
+        ],
+        userMg: [
+          {required: true, message: "用户主管不能为空", trigger: "blur"}
+        ],
+        userUnit: [
+          {required: true, message: "用户单位不能为空", trigger: "blur"}
+        ],
+        workType: [
+          {required: true, message: "作业类型不能为空", trigger: "change"}
+        ],
+        workDescription: [
+          {required: true, message: "作业内容不能为空", trigger: "change"}
+        ],
+        riskLevel: [
+          {required: true, message: "风险等级不能为空", trigger: "change"}
+        ],
+        workPeopleNumber: [
+          {required: true, message: "作业人数不能为空", trigger: "change"}
+        ],
+        estimateWorktime: [
+          {required: true, message: "预计作业时间不能为空", trigger: "change"}
+        ],
+      },
+      // 弹出层标题
+      title: "",
+      open: false,
+      form: [],
+      approveForm: {},
+      isUserMag: false,
       loading: true,
+      bookingworkticketVisible: false,
       // 总条数
       total: 0,
       approvedangerList: [],
@@ -106,7 +326,7 @@ export default {
       fileTips: '',
       showDelay: false,
       submitDisabled: false,
-      dataListLoading:true,
+      dataListLoading: true,
       taskName: '',
       dataForm: {
         id: 0,
@@ -153,7 +373,7 @@ export default {
         // 报告附件上传位置编号
         ids: 0,
         // 设置上传的请求头部
-        headers: { Authorization: "Bearer " + getToken() },
+        headers: {Authorization: "Bearer " + getToken()},
         // 上传的地址
         url: process.env.VUE_APP_BASE_API + "/sems/specfile/uploadFile",
         commonfileList: null,
@@ -162,16 +382,17 @@ export default {
       },
       dataRule: {
         approveType: [
-          { required: true, message: this.$t('approveType') + this.$t('notEmpty'), trigger: 'blur' }
+          {required: true, message: this.$t('approveType') + this.$t('notEmpty'), trigger: 'blur'}
         ],
         content: [
-          { required: true, message: this.$t('content') + this.$t('notEmpty'), trigger: 'blur' }
+          {required: true, message: this.$t('content') + this.$t('notEmpty'), trigger: 'blur'}
         ]
       },
-      downloadAction: process.env.VUE_APP_BASE_API +'/sems/approve/exportPDF',
+      downloadAction: process.env.VUE_APP_BASE_API + '/sems/approve/exportPDF',
       approveOption: [],
       belong: '',
       fileList: [],
+      deptOptions: []
     };
   },
   watch: {
@@ -181,9 +402,24 @@ export default {
     }
   },
   created() {
-
+    this.getTreeselect();
   },
   methods: {
+    /** 查询部门下拉树结构 */
+    getTreeselect() {
+      treeselect().then(response => {
+        this.deptOptions = response.data;
+      });
+    },
+    //根据用户单位 查询对应选择的用户主管  根据用户单位 字段 查找对应的多个主管 返回 Sysuser的集合(id,name)
+    checkCategoryPromotion(oneId) {
+
+      getUserByUnit(oneId).then(response => {
+        //     this.form.userMg=null;
+        this.userMgOptions = response.data;
+        //   let arr=  response.data.userIds.split(',');
+      });
+    },
     // 状态字典翻译
     statusFormat(row, column) {
       return this.selectDictLabel(this.statusOptions, row.status);
@@ -202,12 +438,11 @@ export default {
     },
     // 字典翻译
     floorLocationFormat(row, column) {
-      console.log(row.floorLocation)
-      let floor="";
-      row.floorLocation.split(",").forEach(item=>{
-        floor+= this.selectDictLabel(this.floorLocationOptions,item)+","
+      let floor = "";
+      row.floorLocation.split(",").forEach(item => {
+        floor += this.selectDictLabel(this.floorLocationOptions, item) + ","
       })
-      return floor.substring(0,floor.length-1);
+      return floor.substring(0, floor.length - 1);
     },
     // 字典翻译
     userMgFormat(row, column) {
@@ -229,7 +464,7 @@ export default {
     guardianUnitFormat(row, column) {
       return this.selectDictLabel(this.guardianUnitOptions, row.guardianUnit);
     },
-    init (id, taskId, processId,taskName) {
+    init(id, taskId, processId, taskName) {
       this.reset();
       this.fileList = [];
       this.getDicts("booking_work_status").then(response => {
@@ -269,7 +504,6 @@ export default {
       this.visible = true
       this.queryParams.processId = processId;
       getHistorylist(this.queryParams).then(response => {
-        console.log(response.rows)
         this.historyList = response.rows;
         this.historyLoading = false
       });
@@ -291,6 +525,7 @@ export default {
         this.dataForm.devno = response.data.devno
         this.dataForm.files = response.data.files
         this.devList = response.data.devList
+        this.isUserMag = this.devList[0].status == 0 ? true : false;
         this.dataForm.delayDate = response.data.delayDate
         this.dataForm.delayReason = response.data.delayReason
         this.dataForm.delayMeasure = response.data.delayMeasure
@@ -312,8 +547,32 @@ export default {
       this.visible = false;
       this.reset();
     },
+
+    detailCancel() {
+      this.open = false;
+      this.detailReset();
+      this.$nextTick(() => {
+        this.$refs.ruleForm[0].resetFields();
+        if (this.$refs.ruleForm[1] != null) {
+          this.$refs.ruleForm[1].resetFields();
+        }
+        if (this.$refs.ruleForm[2] != null) {
+          this.$refs.ruleForm[2].resetFields();
+        }
+        if (this.$refs.ruleForm[3] != null) {
+          this.$refs.ruleForm[3].resetFields();
+        }
+        if (this.$refs.ruleForm[4] != null) {
+          this.$refs.ruleForm[4].resetFields();
+        }
+      })
+    },
     // 表单重置
     reset() {
+      this.historyList = [];
+      this.devList = [];
+    },
+    detailReset() {
       this.form = {
         id: null,
         userId: null,
@@ -340,15 +599,12 @@ export default {
         deptId: null
       };
       this.resetForm("form");
-      this.historyList=[];
-      this.devList=[];
     },
 
     /** 提交按钮 */
     // 表单提交
-    dataFormSubmit (val) {
+    dataFormSubmit(val) {
       this.submitDisabled = true
-      console.log(this.taskForm.govFileList)
       this.dataForm.files = []
       if (this.taskForm.govFileList.length > 0) {
         for (let i = 0; i < this.taskForm.govFileList.length; i++) {
@@ -370,14 +626,13 @@ export default {
         this.comment = ''
       })
     },
-    recordHandle(devList,dataForm){
+    recordHandle(devList, dataForm) {
       this.recordVisible = true
       this.$nextTick(() => {
-        this.$refs.recordDeal.init(devList,dataForm);
+        this.$refs.recordDeal.init(devList, dataForm);
       })
     },//合并单元格
-    mergeMethod({ row, column, rowIndex, columnIndex }) {
-      // console.log(row)
+    mergeMethod({row, column, rowIndex, columnIndex}) {
       if (columnIndex === 0) {
         const _row = this.setTable(this.devList).merge[rowIndex];
         const _col = _row > 0 ? 1 : 0;
@@ -425,14 +680,16 @@ export default {
           rowspan: _row,
           colspan: _col
         };
-      }if (columnIndex === 11) {
+      }
+      if (columnIndex === 11) {
         const _row = this.setTable(this.devList).merge[rowIndex];
         const _col = _row > 0 ? 1 : 0;
         return {
           rowspan: _row,
           colspan: _col
         };
-      }if (columnIndex === 12) {
+      }
+      if (columnIndex === 12) {
         const _row = this.setTable(this.devList).merge[rowIndex];
         const _col = _row > 0 ? 1 : 0;
         return {
@@ -465,7 +722,158 @@ export default {
         merge: spanArr
       };
     },
-}
+    updateDetail() {
+      this.detailReset();
+      const id = this.devList[0].bookingticketId
+      getBookingworkticket(id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改预约作业票台账";
+        this.ruleForm = response.data.tInvoiceWorkcontentList
+        //  回显用户主管
+        this.checkCategoryPromotion(this.form.userUnit);
+        //  console.log(row.floorLocation)  将后台的字符串数组重新转换为el-select要的数组格式
+        let arr = this.devList[0].floorLocation.split(",")
+        let st = []
+        // 将字符串数组的每一项转换成Number,生成一个新的数组
+        for (var arrInt in arr) {
+          st.push(parseInt(arr[arrInt]))
+        }
+        this.form.floorLocation = st
+
+        this.ruleForm.length = response.data.tInvoiceWorkcontentList.length
+      });
+    },
+    //校验
+    getFormPromise(formDone) {
+      return new Promise(resolve => {
+        formDone.validate(res => {
+          resolve(res);
+        });
+      });
+    },
+    confirmDetail() {
+
+      let arr = []
+      const basicForm = this.$refs.form;
+      arr.push(basicForm)
+      const genForm = this.$refs.ruleForm[0];
+      arr.push(genForm)
+      if (this.$refs.ruleForm[1] != null) {
+        const genForm1 = this.$refs.ruleForm[1];
+        arr.push(genForm1)
+      }
+      if (this.$refs.ruleForm[2] != null) {
+        const genForm2 = this.$refs.ruleForm[2];
+        arr.push(genForm2)
+      }
+      if (this.$refs.ruleForm[3] != null) {
+        const genForm3 = this.$refs.ruleForm[3];
+        arr.push(genForm3)
+      }
+      if (this.$refs.ruleForm[4] != null) {
+        const genForm4 = this.$refs.ruleForm[4];
+        arr.push(genForm4)
+      }
+      //多重校验
+      Promise.all([this.dataFormSubmit(0),arr.map(this.getFormPromise)]).then(res=> {
+        const validateResult = res[1] .every(item => !!item);
+        if (validateResult) {
+          if (this.form.id != null) {
+            this.form.tInvoiceWorkcontentList = this.ruleForm
+            this.form.floorLocation = this.form.floorLocation.join(',')
+            updateBookingworkticket(this.form).then(response => {
+              this.approveForm.invoiceId = this.form.id
+              var nowTime = this.getNowFormatDate()
+              //判断是否涉及 动火 和当日
+              if (this.form.workStartTime && this.form.workStartTime === nowTime) {
+                this.approveForm.isToday = 1;
+              } else {
+                this.approveForm.isToday = 0;
+              }
+              for (let i = 0; i < this.ruleForm.length; i++) {
+                if (this.ruleForm[i].workType === 1 || this.ruleForm[i].workType === 15) {
+                  this.approveForm.isSpecial = 1
+                  break;
+                } else {
+                  this.approveForm.isSpecial = 0
+                }
+              }
+              this.approveForm.userSupId = this.form.userMg
+
+              addInvoice(this.approveForm).then(response => {
+                // this.msgSuccess(this.$t('预约成功'));
+                this.msgSuccess("已提交申请");
+              })
+              this.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        } else {
+          this.msgError("表单校验未通过,每项申请内容都必填");
+        }
+      });
+
+
+    },
+//拷贝
+    addDomain(domain) {
+      let arr = {}
+      arr.workType = domain.workType;
+      arr.workDescription = domain.workDescription;
+      arr.riskLevel = domain.riskLevel;
+      arr.workPeopleNumber = domain.workPeopleNumber;
+      arr.estimateWorktime = domain.estimateWorktime;
+      this.ruleForm.push(
+        arr
+      );
+      this.flags()
+    },
+//删除自身
+    removeDomain(item) {
+      //如果子类大于1  可点击删除按钮
+      if (this.ruleForm.length > 1) {
+        var index = this.ruleForm.indexOf(item)
+        if (index !== -1) {
+          this.ruleForm.splice(index, 1)
+        }
+      }
+      this.flags()
+    },
+// 表单添加一行
+    add() {
+      var arr = {}
+      this.ruleForm.push(arr)
+      this.flags()
+    },
+// 表单减少一行
+    reduce() {
+
+      this.ruleForm.length = this.ruleForm.length - 1
+      this.flags()
+    },
+    // 重置方法
+    resetForm1() {
+      this.ruleForm = [{}]
+    },
+    //时间
+    getNowFormatDate() {
+      var date = new Date();
+      var seperator1 = "-";
+      var year = date.getFullYear();
+      var month = date.getMonth() + 1;
+      var strDate = date.getDate();
+      if (month >= 1 && month <= 9) {
+        month = "0" + month;
+      }
+      if (strDate >= 0 && strDate <= 9) {
+        strDate = "0" + strDate;
+      }
+      var currentdate = year + seperator1 + month + seperator1 + strDate;
+      return currentdate;
+    },
+  }
 }
 
 

+ 1 - 1
ui/src/views/invoice/bookingworkticket/index.vue

@@ -948,7 +948,7 @@ export default {
              this.approveForm.userSupId=this.form.userMg
 
              addInvoice(this.approveForm).then(response => {
-          this.msgSuccess(this.$t('预约成功'));
+          // this.msgSuccess(this.$t('预约成功'));
                  this.msgSuccess("已提交申请");
            })