<template>
  <!-- 1022 -->
   <div>
 
     <el-card class="box-card">
       <!-- 搜索区域 -->
       <div class="search-bx1">
           <el-input v-model="searchData.number" placeholder="工单编号"  style="width: 180px;" class="g-mr20 g-mb20" clearable />
           <el-input v-model="searchData.work_order_user_name" placeholder="负责人"  style="width: 180px;" class="g-mr20" clearable />
     
           <el-input v-model="searchData.operation_user_name" placeholder="派单人"  style="width: 180px;" class="g-mr20" clearable />
 
           <el-select v-model="searchData.work_order_type" filterable placeholder="工单类型" class="g-mr20" style="width: 180px;" clearable>
             <el-option v-for="item in orderTypeList" :key="item.id" :label="item.name" :value="item.id" />
           </el-select>

 
           <el-select v-model="searchData.work_order_category_id" filterable placeholder="工单分类" class="g-mr20" style="width: 180px;" clearable>
             <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id" />
           </el-select>
          
           <el-select v-model="searchData.status" filterable placeholder="状态" class="g-mr20" style="width: 180px;" clearable>
             <el-option v-for="item in statusList" :key="item.id" :label="item.name" :value="item.id" />
           </el-select>
 
           <el-date-picker v-model="searchData.inputDatetime1" class="g-mr20" type="daterange" range-separator="至" start-placeholder="完成时间" end-placeholder="完成时间" style="width: 250px;" />
 
           <el-date-picker v-model="searchData.inputDatetime2" class="g-mr20" type="daterange" range-separator="至" start-placeholder="派单时间" end-placeholder="派单时间" style="width: 250px;" />
         
           
           <el-button type="primary"   @click="form_search">搜索</el-button>
           <el-button type="primary"   @click="form_clear">重置</el-button>
           <el-button type="primary"   v-if="isButtonEdit" @click="form_add1">添加一次性工单</el-button>
           <el-button type="primary"   v-if="isButtonEdit" @click="form_add2">添加周期工单</el-button>  
            <!-- <el-button type="primary"   @click="form_export">导出</el-button> -->
       </div>
 
  
       <!-- 表格 -->
       <el-table   key="0"  :data="tableList"  v-loading="tableLoading" element-loading-text="给我一点时间"    border fit>
         <el-table-column label="序号"  width="50px" align="center"  fixed="left">
           <template slot-scope="scope">
             <span>{{ scope.row.id }}</span>
           </template>
         </el-table-column>
         <el-table-column label="工单编号" min-width="200px" align="center"  fixed="left">
           <template slot-scope="scope">
             <span>{{ scope.row.number }}</span> 
          
           </template>
         </el-table-column>
         <el-table-column label="工单分类" min-width="150px" align="center" fixed="left">
           <template slot-scope="scope">
             <span>{{ scope.row.work_order_category_name }}</span>
           </template>
         </el-table-column>
         <el-table-column label="状态" min-width="150px" align="center"  fixed="left">
           <template slot-scope="scope">
            <span v-if = "scope.row.status == 1">未派发</span>
             <span v-if = "scope.row.status == 2">未接单</span>
             <span v-if = "scope.row.status == 3">未完成</span>
             <span v-if = "scope.row.status == 4">已关闭</span>
             <span v-if = "scope.row.status == 5">已完成</span>
           </template>
         </el-table-column>

 
 
         <el-table-column label="工单类型" min-width="150px" align="center">
           <template slot-scope="scope">
             <span v-if = "scope.row.work_order_type == 1">一次性工单</span>
             <span v-if = "scope.row.work_order_type == 2">周期性工单</span>
           </template>
         </el-table-column>
 
         <el-table-column label="任务" min-width="150px" align="center">
           <template slot-scope="scope">
             <span>{{ scope.row.remark }}</span>
           </template>
         </el-table-column>
        
         <el-table-column label="派单人" min-width="150px" align="center">
           <template slot-scope="scope">
             <span>{{ scope.row.operation_user_name }}</span>
           </template>
         </el-table-column>
         <el-table-column label="派单人手机号" min-width="150px" align="center">
           <template slot-scope="scope">
             <span>{{ scope.row.operation_user_phone }}</span>
           </template>
         </el-table-column>
         <el-table-column label="派单时间" min-width="150px" align="center">
           <template slot-scope="scope">
             <span>{{ scope.row.created_at_format }}</span>
           </template>
         </el-table-column>
         <el-table-column label="负责人" min-width="150px" align="center">
           <template slot-scope="scope">
             <span>{{ scope.row.work_order_user_name }}</span>
           </template>
         </el-table-column>
 
         <el-table-column label="完成时间" min-width="150px" align="center">
           <template slot-scope="scope">
             <span>{{ scope.row.finished_at_format }}</span>
           </template>
         </el-table-column>
 
         <el-table-column label="操作" align="center" width="500" class-name="small-padding fixed-width" fixed="right">
           <template slot-scope="scope">
             <!-- <el-button type="primary" v-if="isButtonEdit " size="mini" icon="el-icon-edit" @click="form_edit(scope.row)">修改</el-button> -->

          


              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 1" size="mini" icon="el-icon-edit" @click="form_set1(scope.row)">发送设置1</el-button>

              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 2 " size="mini" icon="el-icon-edit" @click="form_set2(scope.row)">发送设置2</el-button>



              <!-- 1未派发  2未接单  3未完成  4已关闭  5已完成 -->
              <!-- 
              一次性工单 编辑——未派发、
              一次性工单  详情—— 未完成、已完成、已关闭
              一次性工单  关闭—— 未完成
              一次性工单  执行结果—— 未完成、已完成、已关闭
              一次性工单  删除—— 未派发、已完成、已关闭
             -->
 

              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 1 &&  scope.row.status == 1" size="mini" icon="el-icon-edit" @click="form_edit1(scope.row)">修改1</el-button>
              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 1 && scope.row.status !== 1 && scope.row.status !== 2" size="mini" icon="el-icon-edit" @click="form_see1(scope.row)">详情1</el-button>
              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 1 && scope.row.status  == 3" size="mini" icon="el-icon-edit" @click="form_close1(scope.row)">关闭工单1</el-button>
              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 1 && scope.row.status !== 1  && scope.row.status !== 2" size="mini" icon="el-icon-edit" @click="form_result1(scope.row)">执行结果1</el-button>

              <!-- 
              周期工单 编辑——未派发、未完成、已完成、已关闭
              周期工单  详情—— 未完成、已完成、已关闭
              周期工单  关闭—— 未完成
              周期工单  执行结果—— 未完成、已完成、已关闭 
              周期工单  删除——未派发、已完成、已关闭
            -->
              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 2  " size="mini" icon="el-icon-edit" @click="form_edit2(scope.row)">修改2</el-button>
              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 2 &&  scope.row.status !== 1" size="mini" icon="el-icon-edit" @click="form_see2(scope.row)">详情2</el-button>
              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 2  && scope.row.status  == 3" size="mini" icon="el-icon-edit" @click="form_close2(scope.row)">关闭工单2</el-button>
              <el-button type="primary" v-if="isButtonEdit &&  scope.row.work_order_type == 2  && scope.row.status !== 1" size="mini" icon="el-icon-edit" @click="form_result2(scope.row)">执行结果2</el-button>
 
 
 
              <el-button type="danger"   v-if="isButtonEdit  && scope.row.status !== 3"  size="mini" icon="el-icon-delete" @click="form_delete(scope.row)">删除工单</el-button>
           </template>
         </el-table-column>
       </el-table>
 
 
       <!-- 分页区域 -->
       <el-pagination  @size-change="change_size_page"  @current-change="change_current_page"  :current-page="searchData.page" :page-sizes="[1,5,10,20,30,50]"  :page-size="searchData.page_size" layout="total, prev, pager, next" :total="searchData.total"/>
     </el-card>
 
 
     <!-- 弹窗 新增or修改一次性工单 -->
     <el-dialog  :title="addFormTxt1[addFormStatus1]" :visible.sync="addFormShow1" @close="add_dialog_close1" width="50%">
       <div class="">
         <el-form  ref="addFormRef1"  :rules="addFormRules1"  :model="addForm1"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
 
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="工单分类" prop="work_order_category_id">
                 <el-select  v-model="addForm1.work_order_category_id"  placeholder="请选择"   style="width: 100%;"  >
                   <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"  />
                 </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="12">
               <el-form-item label="工单任务：" prop="remark">
                 <el-input  v-model="addForm1.remark" type="textarea" maxlength="200"   :rows="1"   />
               </el-form-item>
             </el-col>
              
           </el-row>
           <el-row :gutter="20">
         
             <el-col :span="12" style="text-align:left">
                 <h4>工单对象</h4>
 
                 <el-input
                   placeholder="输入关键字进行过滤"
                   v-model="filterText">
                 </el-input>
                 <!-- 树形控件  -->
                 <el-tree  ref="tree" :data="rightlist" :props="{   label:'name',children:'barn_list'  }" show-checkbox   node-key="idTxt"  default-expand-all :default-checked-keys="checkedIdTxtArr"  @check-change="change_check" :filter-node-method="filterNode"> </el-tree>
             </el-col>
             <el-col :span="12" style="text-align:left">
 
                 <h4>已选栏舍</h4>
                 <el-tag v-for="item in leftlist" style="margin-right:20px;margin-bottom:20px">{{item}}</el-tag>
 
             </el-col>
 
          
                 
           </el-row>
 
 
      
             
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" v-if="addFormStatus1==='create' || addFormStatus1==='edit'" @click="addFormStatus1==='create'?add_dialog_save1():edit_dialog_save1()">确认</el-button>
           <el-button @click="addFormShow1 = false">关闭</el-button>
         </div>
       </div>
     </el-dialog>
 
 
     <!-- 弹窗  详情 一次性工单  详情-->
     <el-dialog   title="工单信息" :visible.sync="seeFormShow1" @close="see_dialog_close1" width="50%">
       <div class="">
         <el-form  ref="seeFormRef1"   :model="seeForm1"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
 
           <el-row :gutter="20"  >
             <el-col :span="12">
               <el-form-item label="工单分类：" prop="work_order_category_id">
                 <el-select  v-model="seeForm1.work_order_category_id"  placeholder="请选择"   style="width: 100%;" disabled >
                   <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"   />
                 </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="12">
               <el-form-item label="工单任务：" prop="remark">
                 <el-input  v-model="seeForm1.remark" type="textarea" maxlength="200"   :rows="1"  disabled />
               </el-form-item>
             </el-col>
              
           </el-row>
           <el-row :gutter="20">
 
            
             <el-table  :data="tableSeeList1"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  :span-method="ObjectSpanMethod"  >
                 <el-table-column  prop="barn_group_name_and_number"    label="栏舍组"  min-width="200px"  align="center" >  </el-table-column>
                 <el-table-column   prop="barn_name"   label="栏舍"  min-width="200px"  align="center">   </el-table-column>
                 <el-table-column  prop="barn_calf_amount"  label="数量"     min-width="200px"  align="center">   </el-table-column>
             </el-table>
                
           </el-row>
 
     
         </el-form>
         <div slot="footer" class="dialog-footer">
         
    
           <el-button    @click="see_dialog_close1()">返回</el-button>
         </div>
       </div>
     </el-dialog>


     <!-- 弹窗  详情 一次性工单  关闭-->
     <el-dialog   title="工单信息" :visible.sync="closeFormShow1" @close="close_dialog_close1" width="50%">
       <div class="">
         <el-form  ref="closeFormRef1"   :model="closeForm1"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
  
           <el-row :gutter="20">
              <el-table  :data="tableCloseList1"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  :span-method="ObjectSpanMethod"  >
                <el-table-column  prop="barn_group_name_and_number"    label="栏舍组"  min-width="200px"  align="center" >  </el-table-column>
                 <el-table-column   prop="barn_name"   label="栏舍"  min-width="200px"  align="center">   </el-table-column>
                 <el-table-column  prop="barn_calf_amount"  label="数量"     min-width="200px"  align="center">   </el-table-column>
              </el-table>
            
              
                
           </el-row>
 
     
         </el-form>
         <div slot="footer" class="dialog-footer">
         
           <el-button type="primary"    @click="sure_dialog_close1()">关闭该工单</el-button>
           <el-button    @click="close_dialog_close1()">返回</el-button>
         </div>
       </div>
     </el-dialog>
   
 
     <!-- 弹窗  执行结果 一次性工单 -->
     <el-dialog   title="工单信息" :visible.sync="resultFormShow1" @close="result_dialog_close1" width="80%">
       <div class="">
         <el-form  ref="resultFormRef1"   :model="resultForm1"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
 
           <el-row :gutter="20">
  
             <el-table  :data="tableResultList1"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  >
                 <el-table-column  prop="id"    label="序号"    min-width="100px" align="center" >  </el-table-column>
                 <el-table-column   prop="number"   label="子工单号"  min-width="200px" align="center">   </el-table-column>
                 <el-table-column   prop="created_at_format"   label="派单时间"  min-width="200px" align="center" >   </el-table-column>
                 <el-table-column label="状态" min-width="150px" align="center"   >
                  <template slot-scope="scope">
                    <span v-if = "scope.row.status == 1">未派发</span>
                    <span v-if = "scope.row.status == 2">未接单</span>
                    <span v-if = "scope.row.status == 3">未完成</span>
                    <span v-if = "scope.row.status == 4">已关闭</span>
                    <span v-if = "scope.row.status == 5">已完成</span>
                  </template>
                 </el-table-column>
                 <el-table-column  prop="work_order_user_name"  label="执行人"     min-width="200px" align="center" >   </el-table-column>
                 <el-table-column  prop="finished_at_format"  label="执行时间"     min-width="200px" align="center" >   </el-table-column>
                 <el-table-column  prop="exec_total_time"  label="用时"     min-width="60px" align="center"  >   </el-table-column>
                <el-table-column label="工单对象" align="center" width="200" class-name="small-padding fixed-width" fixed="right">
                    <template slot-scope="scope">
                  
                        <el-button type="primary"   size="mini" icon="el-icon-edit" @click="form_result_detail_see1(scope.row)">查看</el-button>
                         
                    </template>
                  </el-table-column>
                
             </el-table>
   
           </el-row>
 
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary"  @click="result_dialog_close1()">确认</el-button>
   
         </div>
       </div>
     </el-dialog>


     <!-- 弹窗  执行结果 一次性工单 执行结果详情-->
     <el-dialog   title="工单信息" :visible.sync="resultFormDetailShow1" @close="result_detail_dialog_close1" width="80%">
       <div class="">
         <el-form  ref="resultFormDetailRef1"   :model="resultFormDetail1"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
  
           <el-row :gutter="20">
 
             <el-table  :data="tableResultDetailList1"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  :span-method="ObjectSpanMethod"  >
                <el-table-column  prop="barn_group_name_and_number"    label="栏舍组"  min-width="200px"  align="center" >  </el-table-column>
                 <el-table-column   prop="barn_name"   label="栏舍"  min-width="200px"  align="center">   </el-table-column>
                 <el-table-column  prop="barn_calf_amount"  label="数量"     min-width="200px"  align="center">   </el-table-column>
              </el-table>
        
              
   
           </el-row>
 
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary"  @click="result_detail_dialog_close1()">确认</el-button>
   
         </div>
       </div>
     </el-dialog>


      <!-- 弹窗 新增or修改 周期工单 -->
      <el-dialog  :title="addFormTxt2[addFormStatus2]" :visible.sync="addFormShow2" @close="add_dialog_close2" width="50%">
       <div class="">
         <el-form  ref="addFormRef2"  :rules="addFormRules2"  :model="addForm2"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
 
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="工单分类：" prop="work_order_category_id">
                 <el-select  v-model="addForm2.work_order_category_id"  placeholder="请选择"   style="width: 100%;"  >
                   <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"  />
                 </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="12">
               <el-form-item label="工单任务：" prop="remark">
                 <el-input  v-model="addForm2.remark" type="textarea" maxlength="200"   :rows="1"  />
               </el-form-item>
             </el-col>
           </el-row>
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="状态：" prop="is_show">
                 <el-select  v-model="addForm2.is_show"  placeholder="请选择"   style="width: 100%;"  >
                   <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id"  />
                 </el-select>
               </el-form-item>
             </el-col>

             
             
           </el-row>

          

           <el-row :gutter="20">
              <h3 style="text-align:left;">
                事件条件范围
                <span style="color:#ff0303;font-size:14px;">注：同一组的关系为“且”；组与组之间关系为“或”</span>
              </h3>
 
              <el-button type="primary"   v-if="isButtonEdit" @click="condition_add1">添加条件</el-button>
               
              <el-table  :data="tableAddList2"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  >
                <el-table-column label="组" min-width="150px" align="center" fixed="left">
                  <template slot-scope="scope">
                    <span class="groupSpanClass spanc1" v-show="scope.row.group_id == 1" >{{ 1 }}</span>
                    <span class="groupSpanClass spanc2" v-show="scope.row.group_id == 2" >{{ 2 }}</span>
                    <span class="groupSpanClass spanc3" v-show="scope.row.group_id == 3" >{{ 3 }}</span>
                    <span class="groupSpanClass spanc4" v-show="scope.row.group_id == 4" >{{ 4 }}</span>
                    <span class="groupSpanClass spanc5" v-show="scope.row.group_id == 5" >{{ 5 }}</span>
                    <span class="groupSpanClass spanc6" v-show="scope.row.group_id == 6" >{{ 6 }}</span>
                    <span class="groupSpanClass spanc7" v-show="scope.row.group_id == 7" >{{ 7 }}</span>
                    <span class="groupSpanClass spanc8" v-show="scope.row.group_id == 8" >{{ 8 }}</span>
                    <span class="groupSpanClass spanc9" v-show="scope.row.group_id == 9" >{{ 9 }}</span>
                    <span class="groupSpanClass spanc10" v-show="scope.row.group_id == 10" >{{ 10 }}</span>
                
                  </template>
                </el-table-column>
                <el-table-column label="条件" min-width="250px" align="center" >
                  <template slot-scope="scope">
                    <!-- <span class="ifClass" >{{ scope.row.sql_name  }}</span> -->

                    <span class="ifClass" >{{ scope.row.field_name  }}</span>

                    <!-- <span class="ifClass" >{{ scope.row.condition_key }}</span> -->

                    <span class="ifClass" >{{ scope.row.condition_value   }}</span>

                    <span   >{{ scope.row.value }}</span>
                  </template>
                </el-table-column>
          

                 <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
                    <template slot-scope="scope">
 
                        <el-button type="primary" v-if="isButtonEdit " size="mini" icon="el-icon-edit" @click="condition_edit1(scope.row,scope.$index)">编辑</el-button>
                      
                        <el-button type="danger" v-if="isButtonEdit " size="mini" icon="el-icon-delete" @click="condition_delete1(scope.row,scope.$index)">删除</el-button>
                    </template>
                  </el-table-column>
                        
           
                
              </el-table>
 
           </el-row>
 
 
             
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" v-if="addFormStatus2==='create' || addFormStatus2==='edit'" @click="addFormStatus2==='create'?add_dialog_save2():edit_dialog_save2()">确认</el-button>
           <el-button @click="addFormShow2 = false">关闭</el-button>
         </div>
       </div>
     </el-dialog>


     <!-- 弹窗 周期工单  条件-->
     <el-dialog  :title="conditionFormTxt1[conditionFormStatus1]" :visible.sync="conditionFormShow1" @close="condition_dialog_close1" width="50%">
       <div class="">
         <el-form  ref="conditionFormRef1"  :rules="conditionFormRules1"  :model="conditionForm1"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
 
           <el-row :gutter="20">
             <el-col :span="20">
               <el-form-item label="组别：" prop="group_id">
                 <el-select  v-model="conditionForm1.group_id"  placeholder="请选择"   style="width: 100%;"  >
                   <el-option v-for="item in groupList" :key="item.id" :label="item.name" :value="item.id"  />
                 </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="4">
                 <span v-show="conditionForm1.group_id == 1" class="colorSpan spanc1"></span>
                 <span v-show="conditionForm1.group_id == 2" class="colorSpan spanc2"></span>
                 <span v-show="conditionForm1.group_id == 3" class="colorSpan spanc3"></span>
                 <span v-show="conditionForm1.group_id == 4" class="colorSpan spanc4"></span>
                 <span v-show="conditionForm1.group_id == 5" class="colorSpan spanc5"></span>
                 <span v-show="conditionForm1.group_id == 6" class="colorSpan spanc6"></span>
                 <span v-show="conditionForm1.group_id == 7" class="colorSpan spanc7"></span>
                 <span v-show="conditionForm1.group_id == 8" class="colorSpan spanc8"></span>
                 <span v-show="conditionForm1.group_id == 9" class="colorSpan spanc9"></span>
                 <span v-show="conditionForm1.group_id == 10" class="colorSpan spanc10"></span>
             </el-col>
              
           </el-row>
           <el-row :gutter="20">
              <el-form-item label="字段：" prop="sql_name">
                 <el-select  v-model="conditionForm1.sql_name"  placeholder="请选择"   style="width: 100%;"  >
                   <el-option v-for="item in fieldList" :key="item.sql_name" :label="item.filed_name" :value="item.sql_name"  />
                 </el-select>
               </el-form-item>
           </el-row>
           <el-row :gutter="20">
            <el-form-item label="筛选：" prop="condition_key">
                 <el-select  v-model="conditionForm1.condition_key"  placeholder="请选择"   style="width: 100%;"  >
                   <el-option v-for="item in conditionList" :key="item.id" :label="item.name" :value="item.id"  />
                 </el-select>
               </el-form-item>
           </el-row>
 
           <el-row :gutter="20" v-if="conditionForm1.condition_key !== 9">
                <el-form-item label="值：" prop="value">
                    <el-input  v-model="conditionForm1.value" type="input"   />
                </el-form-item>
           </el-row>

           <h4>多个值之间用英文逗号分割，如1,2,3</h4>
 
 
      
             
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" v-if="conditionFormStatus1==='create' || conditionFormStatus1==='edit'" @click="conditionFormStatus1==='create'?add_condition_save1():edit_condition_save1()">确认</el-button>
           <el-button @click="conditionFormShow1 = false">关闭</el-button>
         </div>
       </div>
     </el-dialog>


     <!-- 弹窗  详情 周期工单  详情-->
     <el-dialog   title="工单信息" :visible.sync="seeFormShow2" @close="see_dialog_close2" width="50%">
       <div class="">
         <el-form  ref="seeFormRef2"   :model="seeForm2"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
          <el-row :gutter="20"  >
             <el-col :span="12">
               <el-form-item label="工单分类：" prop="work_order_category_id">
                 <el-select  v-model="seeForm2.work_order_category_id"  placeholder="请选择"   style="width: 100%;" disabled >
                   <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"   />
                 </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="12">
               <el-form-item label="工单任务：" prop="remark">
                 <el-input  v-model="seeForm2.remark" type="textarea" maxlength="200"   :rows="1" disabled />
               </el-form-item>
             </el-col>
           </el-row>
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="状态：" prop="is_show">
                 <el-select  v-model="seeForm2.is_show"  placeholder="请选择"   style="width: 100%;" disabled>
                   <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id"  />
                 </el-select>
               </el-form-item>
             </el-col>
 
           </el-row>



          

           

           <el-row :gutter="20"  >
              <h3 style="text-align:left;">
                事件条件范围
                <span style="color:#ff0303;font-size:14px;">注：同一组的关系为“且”；组与组之间关系为“或”</span>
              </h3>
 
            
               
              <el-table  :data="tableSeeList2"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  >
                <el-table-column label="组" min-width="150px" align="center" fixed="left">
                  <template slot-scope="scope">
                    <span class="groupSpanClass spanc1" v-show="scope.row.group_id == 1" >{{ 1 }}</span>
                    <span class="groupSpanClass spanc2" v-show="scope.row.group_id == 2" >{{ 2 }}</span>
                    <span class="groupSpanClass spanc3" v-show="scope.row.group_id == 3" >{{ 3 }}</span>
                    <span class="groupSpanClass spanc4" v-show="scope.row.group_id == 4" >{{ 4 }}</span>
                    <span class="groupSpanClass spanc5" v-show="scope.row.group_id == 5" >{{ 5 }}</span>
                    <span class="groupSpanClass spanc6" v-show="scope.row.group_id == 6" >{{ 6 }}</span>
                    <span class="groupSpanClass spanc7" v-show="scope.row.group_id == 7" >{{ 7 }}</span>
                    <span class="groupSpanClass spanc8" v-show="scope.row.group_id == 8" >{{ 8 }}</span>
                    <span class="groupSpanClass spanc9" v-show="scope.row.group_id == 9" >{{ 9 }}</span>
                    <span class="groupSpanClass spanc10" v-show="scope.row.group_id == 10" >{{ 10 }}</span>
                    <span class="groupSpanClass spanc11" v-show="scope.row.group_id == 11" >{{ 11 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="条件" min-width="250px" align="center" >
                  <template slot-scope="scope">
                    <!-- <span class="ifClass" >{{ scope.row.sql_name  }}</span> -->

                    <span class="ifClass" >{{ scope.row.field_name  }}</span>

                    <!-- <span class="ifClass" >{{ scope.row.condition_key }}</span> -->

                    <span class="ifClass" >{{ scope.row.condition_value   }}</span>
                  </template>
                </el-table-column>
              

                 
                        
           
                
              </el-table>
 
           </el-row>


       
 
     
         </el-form>
         <div slot="footer" class="dialog-footer">
         
         
           <el-button    @click="see_dialog_close2()">返回</el-button>
         </div>
       </div>
     </el-dialog>
     

     
     <!-- 弹窗  详情 周期工单  关闭-->
     <el-dialog   title="工单信息" :visible.sync="closeFormShow2" @close="close_dialog_close2" width="50%">
       <div class="">
         <el-form  ref="closeFormRef2"   :model="closeForm2"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
            

           <el-row :gutter="20">
 
             <div v-for="item in tableCloseList2">
                 <h3>{{item.created_at_format}}</h3>
                
                 <el-table  :data="item.barn_group_list"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border :span-method="ObjectSpanMethod" >
                    <el-table-column  prop="barn_group_name_and_number"    label="栏舍组"  min-width="200px"  align="center" >  </el-table-column>
                    <el-table-column   prop="barn_name"   label="栏舍"  min-width="200px"  align="center">   </el-table-column>
                    <el-table-column  prop="barn_calf_amount"  label="数量"     min-width="200px"  align="center">   </el-table-column>
                </el-table>
                <el-button type="primary"    @click="sure_dialog_close2(item)">关闭该工单</el-button>
             </div>
 
            
                
           </el-row>
 
     
         </el-form>
         <div slot="footer" class="dialog-footer">
         
         
           <el-button    @click="close_dialog_close2()">返回</el-button>
         </div>
       </div>
     </el-dialog>

     <!-- 弹窗  执行结果 周期工单 -->
     <el-dialog   title="工单信息" :visible.sync="resultFormShow2" @close="result_dialog_close2" width="80%">
       <div class="">
         <el-form  ref="resultFormRef2"   :model="resultForm2"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
          
        <div class="search-bx1">
           <el-date-picker v-model="resultSearchData2.inputDatetime1" class="g-mr20" type="daterange" range-separator="至" start-placeholder="完成时间" end-placeholder="完成时间" style="width: 250px;" />

          
           <el-input v-model="resultSearchData2.user_name" placeholder="执行人"  style="width: 180px;" class="g-mr20" clearable />
          
           
           <el-select v-model="resultSearchData2.status" filterable placeholder="状态" class="g-mr20" style="width: 180px;" clearable>
             <el-option v-for="item in statusList2" :key="item.id" :label="item.name" :value="item.id" />
           </el-select>

           <el-input v-model="resultSearchData2.sub_work_order_number" placeholder="子工单号"  style="width: 180px;" class="g-mr20" clearable />
 
          
  
           <el-button type="primary"   @click="form_search_result2">搜索</el-button>
 
            <!-- <el-button type="primary"   @click="form_export">导出</el-button> -->
       </div>
           <el-row :gutter="20">
 
  
 
            <el-table  :data="tableResultList2"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  >
                 <el-table-column  prop="id"    label="序号"    min-width="100px" align="center" >  </el-table-column>
                 <el-table-column   prop="number"   label="子工单号"  min-width="200px" align="center">   </el-table-column>
                 <el-table-column   prop="created_at_format"   label="派单时间"  min-width="200px" align="center" >   </el-table-column>
                 <el-table-column label="状态" min-width="150px" align="center"   >
                  <template slot-scope="scope">
                    <span v-if = "scope.row.status == 1">未派发</span>
                    <span v-if = "scope.row.status == 2">未接单</span>
                    <span v-if = "scope.row.status == 3">未完成</span>
                    <span v-if = "scope.row.status == 4">已关闭</span>
                    <span v-if = "scope.row.status == 5">已完成</span>
                  </template>
                 </el-table-column>
                 <el-table-column  prop="work_order_user_name"  label="执行人"     min-width="200px" align="center" >   </el-table-column>
                 <el-table-column  prop="finished_at_format"  label="执行时间"     min-width="200px" align="center" >   </el-table-column>
                 <el-table-column  prop="exec_total_time"  label="用时"     min-width="60px" align="center"  >   </el-table-column>
                <el-table-column label="工单对象" align="center" width="200" class-name="small-padding fixed-width" fixed="right">
                    <template slot-scope="scope">
                  
                        <el-button type="primary"   size="mini" icon="el-icon-edit" @click="form_result_detail_see1(scope.row)">查看</el-button>
                         
                    </template>
                  </el-table-column>
                
             </el-table>

             <!-- 分页区域 -->
            <el-pagination  @size-change="change_size_page_result2"  @current-change="change_current_page_result2"  :current-page="resultSearchData2.page" :page-sizes="[1,5,10,20,30,50]"  :page-size="resultSearchData2.page_size" layout="total, prev, pager, next" :total="resultSearchData2.total"/>
         
              
          
                 
           </el-row>
 
 
     
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary"  @click="result_dialog_close2()">确认</el-button>
   
         </div>
       </div>
     </el-dialog>


      <!-- 弹窗  执行结果 周期工单 执行结果详情-->
      <el-dialog   title="工单信息" :visible.sync="resultFormDetailShow2" @close="result_detail_dialog_close2" width="80%">
       <div class="">
         <el-form  ref="resultFormDetailRef1"   :model="resultFormDetail2"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
  
           <el-row :gutter="20">
 
            
        
              <!-- <el-table  :data="tableResultDetailList1"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border :span-method="ObjectSpanMethod" > -->
             <el-table  :data="tableResultDetailList2"   style="width: 100%;margin-bottom: 20px;"    row-key="id"  border  >
                 <el-table-column  prop="cowshedGroup"    label="栏舍组"         min-width="200px" >  </el-table-column>
  
                 <el-table-column   prop="cowshed"   label="栏舍"  min-width="200px" >   </el-table-column>
                 <el-table-column  prop="num"  label="数量"     min-width="200px" >   </el-table-column>
                
             </el-table>
   
           </el-row>
 
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary"  @click="result_detail_dialog_close2()">确认</el-button>
   
         </div>
       </div>
     </el-dialog>



      <!-- 弹窗 发送设置 一次性 -->
      <el-dialog   title="发送设置" :visible.sync="setFormShow1" @close="set_dialog_close1" width="50%">
       <div class="">
         <el-form  ref="setFormRef1"  :rules="setFormRules1"  :model="setForm1"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
 
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="负责员工：" prop="userId">
                  <el-cascader v-model="setForm1.userId" :options="userList" :props="{ checkStrictly: true,  label: 'name',   children: 'user_list',  value: 'id',}" node-key="id" @change="change_user1" ref = "treeCas1" style="width: 100%;"></el-cascader>
               </el-form-item>
             </el-col>
             <el-col :span="12">

              <el-tag style="margin-right:20px" v-for="(item,index) in userClickList1"   :key="item.id"  closable  @close="close_user1(item,index)"> 
                 {{item.name}}
              </el-tag>
              
                
             </el-col>
              
           </el-row>
           <el-row :gutter="20">
         
              <el-col :span="12">
                <el-form-item label="消息模板：" prop="message_template_id">
                  <el-select  v-model="setForm1.message_template_id"  placeholder="请选择"   style="width: 100%;"  >
                    <el-option v-for="item in messageList" :key="item.id" :label="item.name" :value="item.id"    />
                  </el-select>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                  
              </el-col>
           </el-row>

           <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="发送方式：" prop="type">
                  <el-select  v-model="setForm1.type"  placeholder="请选择"   style="width: 100%;"  >
                    <el-option v-for="item in sendMethodList" :key="item.id" :label="item.name" :value="item.id"  />
                  </el-select>
                </el-form-item>
              </el-col>
              
              <el-col :span="12"> 
              </el-col>
           </el-row>

           <el-row :gutter="20" v-show="setForm1.type == 2">
              <el-col :span="12" >
                <el-form-item label="发送时间：" prop="day_time" >
                  <el-time-picker v-model="setForm1.day_time" format='HH:mm:ss' type="time" placeholder="选择时间"   style="width: 100%;" :clearable="false"   />
                </el-form-item>
              </el-col>
              
              <el-col :span="12"> 
              </el-col>
           </el-row>

 
      
             
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary"  @click="set_save1()">确认</el-button>
           <el-button @click="setFormShow1 = false">关闭</el-button>
         </div>
       </div>
      </el-dialog>


      <!-- 弹窗 发送设置 周期性-->
      <el-dialog   title="发送设置" :visible.sync="setFormShow2" @close="set_dialog_close2" width="50%">
       <div class="">
         <el-form  ref="setFormRef2"  :rules="setFormRules2"  :model="setForm2"  label-position="right" label-width="140px"  style="width:90%;margin:0 auto 50px">
     
           <el-row :gutter="20">
             <el-col :span="12">
               <el-form-item label="负责员工：" prop="user_id">
                <el-cascader v-model="setForm2.userId" :options="userList" :props="{ checkStrictly: true,  label: 'name',   children: 'user_list',  value: 'id',}" node-key="id" @change="change_user2" ref = "treeCas2" style="width: 100%;"></el-cascader>
               </el-form-item>
             </el-col>
             <el-col :span="12">

              <el-tag style="margin-right:20px" v-for="(item,index) in userClickList2"   :key="item.id"  closable  @close="close_user2(item,index)"> 
                 {{item.name}}
              </el-tag>
              
                
             </el-col>
              
           </el-row>
           <el-row :gutter="20">
         
              <el-col :span="12">
             
                <el-form-item label="消息模板：" prop="message_template_id">
                  <el-select  v-model="setForm2.message_template_id"  placeholder="请选择"   style="width: 100%;"  >
                    <el-option v-for="item in messageList" :key="item.id" :label="item.name" :value="item.id"  />
                  </el-select>
                </el-form-item>
 
              </el-col>

              <el-col :span="12">
                  
              </el-col>
           </el-row>

           <el-row :gutter="20">
           

             <el-col :span="12">
                <el-form-item label="发送方式：" prop="cron_type">
                  <el-select  v-model="setForm2.cron_type"  placeholder="天周月"   style="width: 100%;"  >
                    <el-option v-for="item in setList2" :key="item.id" :label="item.name" :value="item.id"  />
                  </el-select>
                </el-form-item>
             </el-col>

             <el-col :span="6">
                 <el-select  v-model="setForm2.week_kind" multiple   placeholder="周几"   style="width: 100%;"  v-show = "setForm2.cron_type ==2">
                   <el-option v-for="item in setList31" :key="item.id" :label="item.name" :value="item.id"  />
                </el-select>
                <el-select  v-model="setForm2.day_kind"  multiple placeholder="几号"   style="width: 100%;"  v-show = "setForm2.cron_type ==3" >
                   <el-option v-for="item in setList32" :key="item.id" :label="item.name" :value="item.id"  />
                </el-select>
             </el-col>

             <el-col :span="6">
              
             </el-col>

           </el-row>

           <el-row :gutter="20">
              <el-col :span="12">
                <el-form-item label="发送时间：" prop="day_time">
                  <el-time-picker v-model="setForm2.day_time" format='HH:mm:ss' type="time" placeholder="选择时间"   style="width: 100%;" :clearable="false"   />
                </el-form-item>
              </el-col>
              
              <el-col :span="12"> 
              </el-col>
           </el-row>

 
      
             
         </el-form>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary"  @click="set_save2()">确认</el-button>
           <el-button @click="setFormShow2 = false">关闭</el-button>
         </div>
       </div>
      </el-dialog>
  
     
   </div>
 
 
 </template> 
 
 <script>
 import {  ajaxDataGet, ajaxDataPost, ajaxDataPut, ajaxDataDelete, checkButtons} from '@/api/common'
 import { parseTime, json2excel } from '@/utils/index.js'
 export default {
   data() {
  
     return {
 
 
      
       
         
       //接口 - 获取 - 表格
       url_get_table:'/api/v1/ops/work_order/list',
       //接口 - 新增 - 表格
       url_add_table:'/api/v1/ops/work_order/add',  
       //接口 - 修改 - 表格
       url_edit_table:'/api/v1/ops/work_order/update', 
       //接口 - 删除 - 表格
       url_delete_table:'/api/v1/ops/work_order/delete', 


       //接口 - 表格中的详情表格 - 表格
       url_close_detail_table:'/api/v1/ops/work_order/close_view', 
       
       //接口 - 下拉框 列表 
       url_get_select1:'/role/getAll',
 
       //按钮权限
       isButtonEdit:false,
 
       //获取 - 表格数据 - 参数
       searchData:{
         number: "",
         work_order_user_name: "",
         operation_user_name: "",
         work_order_category_id: undefined,
         work_order_type: undefined,
         status: undefined,
         start_finished_time: "",
         end_finished_time: "",
         start_created_time: "",
         end_created_time: "",
         inputDatetime1:"",
         inputDatetime2:"",
         page: 1,  //页码
         page_size: 10,   //每页数量
         total:0,  //总页数
         pastureId: ""
       },
       tableLoading: false,
       //表格内容
       tableList:[
           { number:"admin", id:100, date:'2023-12-01',email:'测试信息1123',roleList:[2,3] },
         // { username:"epans", id:200, date:'2023-12-01',email:'测试信息1123',roleList:[] },
         // { username:"derek", id:300, date:'2023-12-01',email:'测试信息1123' },
         // { username:"admin", id:100, date:'2023-12-01',email:'测试信息1123' },
         // { username:"epans", id:200, date:'2023-12-01',email:'测试信息1123' },
         // { username:"derek", id:300, date:'2023-12-01',email:'测试信息1123' },
         // { username:"admin", id:100, date:'2023-12-01',email:'测试信息1123' },
         // { username:"epans", id:200, date:'2023-12-01',email:'测试信息1123' },
         // { username:"derek", id:300, date:'2023-12-01',email:'测试信息1123' },
         // { username:"admin", id:100, date:'2023-12-01',email:'测试信息1123' },
         // { username:"epans", id:200, date:'2023-12-01',email:'测试信息1123' },
         // { username:"derek", id:300, date:'2023-12-01',email:'测试信息1123' },
       ],
 
 
       messageList:[
         
       ],

       sendMethodList:[
         {id:2,name:"定时"},
         {id:1,name:"立即"},
       ],


       typeList:[
         
       ],
 

       enableList:[
         {id: 1, name: '开启'},
         {id: 2, name: '关闭'},
       ],

       setList1:[
         {id: 1, name: '实时'},
         {id: 2, name: '定时'},
       ],
       setList2:[
         {id: 1, name: '每天'},
         {id: 2, name: '每周'},
         {id: 3, name: '每月'},
       ],
       setList31:[
         {id: 1, name: '周一'},
         {id: 2, name: '周二'},
         {id: 3, name: '周三'},
         {id: 4, name: '周四'},
         {id: 5, name: '周五'},
         {id: 6, name: '周六'},
         {id: 7, name: '周天'},
       ],
       setList32:[
         {id: 1, name: '1号'}, {id: 2, name: '2号'},  {id: 3, name: '3号'}, {id: 4, name: '4号'},
         {id: 5, name: '5号'}, {id: 6, name: '6号'},  {id: 7, name: '7号'}, {id: 8, name: '8号'},
         {id: 9, name: '9号'}, {id: 10, name: '10号'},  {id: 11, name: '11号'}, {id: 12, name: '12号'},
         {id: 13, name: '13号'}, {id: 14, name: '14号'},  {id: 15, name: '15号'}, {id: 16, name: '16号'},
         {id: 17, name: '17号'}, {id: 18, name: '18号'},  {id: 19, name: '19号'}, {id: 20, name: '20号'},
         {id: 21, name: '21号'}, {id: 22, name: '22号'},  {id: 23, name: '23号'}, {id: 24, name: '24号'},
         {id: 25, name: '25号'}, {id: 26, name: '26号'},  {id: 27, name: '27号'}, {id: 28, name: '28号'},
         {id: 29, name: '29号'}, {id: 30, name: '30号'},  {id: 31, name: '31号'} 
       ],

       groupList:[
         {id: 1, name: 1},
         {id: 2, name: 2},
         {id: 3, name: 3},
         {id: 4, name: 4},
         {id: 5, name: 5},
         {id: 6, name: 6},
         {id: 7, name: 7},
         {id: 8, name: 8},
         {id: 9, name: 9},
         {id: 10, name: 10},
       ],
       fieldList:[
        
       ],

       conditionList:[
         {id: 1, name: '等于'},
         {id: 2, name: '不等于'},
         {id: 3, name: '小于'},
         {id: 4, name: '小于等于'},
         {id: 5, name: '大于'},
         {id: 6, name: '大于等于'},
         {id: 7, name: '包含'},
         {id: 8, name: '不包含'},
         {id: 9, name: '为空'},
         {id: 10, name: '不为空'},
         {id: 11, name: '区间'},
 
       ],

       
   
   
       personList:[
         
        ],

     

 
       statusList:[
         {id: 1, name: '未派发'},
        //  {id: 2, name: '未接单'},
         {id: 3, name: '未完成'},
         {id: 4, name: '已关闭'},
         {id: 5, name: '已完成'},
       ],

       statusList2:[
         {id: 3, name: '未完成'},
         {id: 4, name: '已关闭'},
         {id: 5, name: '已完成'},
   
       ],
 
 
       orderTypeList:[
         {id: 1, name: '一次性工单'},
         {id: 2, name: '周期性工单'},
       ],
     
       
  
       setFormShow1:false,
       setFormStatus1: '',
       setFormTxt1: {  edit: '修改',  create: '新增' },
       setForm1:{
         remark:'',type:'',day_time: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'), user_id:undefined, accept_order_user_id:undefined,message_template_id:undefined,id:undefined,
       },
       setFormRules1:{
         name: [ { required: true, message: '类型名称必填', trigger: 'blur' },  ],
       },


       
       setFormShow2:false,
       setFormStatus2: '',
       setFormTxt2: {  edit: '修改',  create: '新增' },
       setForm2:{
        remark:'',cron_type:undefined,day_time: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'), user_id:undefined, accept_order_user_id:undefined,message_template_id:undefined,id:undefined,week_kind:[],day_kind:[]
       },
       setFormRules2:{
         name: [ { required: true, message: '类型名称必填', trigger: 'blur' },  ],
       },


      
       addFormShow1:false,
       addFormStatus1: '',
       addFormTxt1: {  edit: '修改',  create: '新增' },
       addForm1:{
         remark:'',  work_order_category_id:undefined, work_order_category_name:"",work_order_type:undefined,id:undefined,work_order_object:[], 
       },
       addFormRules1:{
         name: [ { required: true, message: '类型名称必填', trigger: 'blur' },  ],
       },

       addFormShow2:false,
       addFormStatus2: '',
       addFormTxt2: {  edit: '修改',  create: '新增' },
       addForm2:{
         remark:'',user_phone:'',  work_order_category_id:undefined,user_id:undefined,id:undefined,
       },
 
       addFormRules2:{
         name: [ { required: true, message: '类型名称必填', trigger: 'blur' },  ],
    
 
       },
       tableAddList2:[
          //  {  id: 1,  sort: '1',color:"#ff9292",field: 1,   field_name: '111',  value: '40-60'  },   
          //  { id: 31,  sort: '2',  color:"#8dffd4",field: 1,   field_name: '222',  value: '40，50，60'  }, 
       ],


       conditionFormShow1:false,
       conditionFormStatus1: '',
       conditionFormTxt1: {  edit: '修改',  create: '新增' },
       conditionForm1:{
        
          group_id:1,sql_name:"", field_name:"",condition_value:1, value:"",id:undefined ,condition_key:undefined 
   
       },
       conditionIndex:0,
       conditionFormRules1:{
           group_id: [ { required: true, message: '必填', trigger: 'blur' },  ],
           sql_name: [ { required: true, message: '必填', trigger: 'blur' },  ],
           condition_key: [ { required: true, message: '必填', trigger: 'blur' },  ],
           value: [ { required: true, message: '必填', trigger: 'blur' },  ],
       },

      
 
       seeFormShow1:false,
       seeFormStatus1: 'see',
       seeFormTxt1: {  edit: '修改',  create: '新增' },
       seeForm1:{
         remark:'',user_phone:'',  work_order_category_id:undefined,user_id:undefined,id:undefined,
       },
       
       tableSeeList1:[
           {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
           { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
           { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
           {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
           { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
           { id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
       ],
 
       seeFormShow2:false,
       seeFormStatus2: 'see',
       seeFormTxt2: {  edit: '修改',  create: '新增' },
       seeForm2:{
         remark:'',user_phone:'',  work_order_category_id:undefined,user_id:undefined,id:undefined,
       },

       tableSeeList2:[
         
  
 
       ],


       
       closeFormShow2:false,
       closeFormStatus2: 'see',
       closeFormTxt2: {  edit: '修改',  create: '新增' },
       closeForm2:{
         remark:'',user_phone:'',  work_order_category_id:undefined,user_id:undefined,id:undefined,
       },

       tableCloseList2:[
        //  {date:"123123", id: 1,tableArr: [
        //       {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
        //       { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
        //       { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
        //       {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
        //       { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
        //       { id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
        //     ]
        //  } ,
        //  {date:"2222", id: 1,tableArr: [
        //       {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
        //       { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
        //       { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
        //       {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
        //       { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
        //       { id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
        //     ]
 
        //  }
  
 
       ],
         
         


       closeFormShow1:false,
       closeFormStatus1: 'see',
       closeFormTxt1: {  edit: '修改',  create: '新增' },
       closeForm1:{
         remark:'',user_phone:'',  work_order_category_id:undefined,user_id:undefined,id:undefined,

      

      },
      tableCloseList1:[
          //  {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
          //  { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
          //  { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
          //  {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
          //  { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
          //  { id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
       ],  

       tableCloseId1:undefined,
     
 
 
       resultFormShow1:false,
       resultFormStatus1: '',
       resultFormTxt1: {  edit: '修改',  create: '新增' },
       resultForm1:{
          work_order_id:undefined,    start_created_time: "",  end_created_time: "", inputDatetime1:"", 
          user_name:'',status:undefined,  sub_work_order_number:"",id:undefined,
       },

       resultSearchData1:{
          work_order_id:undefined,    start_created_time: "",  end_created_time: "", inputDatetime1:"", 
          user_name:'',status:undefined,  sub_work_order_number:"",id:undefined,  
          page: 1,  //页码
          page_size: 10,   //每页数量
          total:0,  //总页数
       },


      
       tableResultList1:[
          //  {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
          //  { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
          //  { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
          //  {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
          //  { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
          //  { id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
       ],



       resultFormDetailShow1:false,
       resultFormDetail1:{},
       tableResultDetailList1:[
          //  {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
          //  { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
          //  { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
          //  {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
          //  { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
           //{ id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
       ],
 
       

 
       resultFormShow2:false,
       resultFormStatus2: '',
       resultFormTxt2: {  edit: '修改',  create: '新增' },
       resultForm2:{
         remark:'',user_phone:'',  work_order_category_id:undefined,user_id:undefined,id:undefined,
       },
       resultSearchData2:{
          work_order_id:undefined,    start_created_time: "",  end_created_time: "", inputDatetime1:"", 
          user_name:'',status:undefined,  sub_work_order_number:"",id:undefined,  
          page: 1,  //页码
          page_size: 10,   //每页数量
          total:0,  //总页数
       },
       tableResultList2:[
          //  {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
          //  { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
          //  { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
          //  {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
          //  { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
          //  { id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
       ],


       resultFormDetailShow2:false,
       resultFormDetail2:{},
       tableResultDetailList2:[
           {  id: 1,  cowshedGroup: 'A组(总数：100)', groupnum: '100',   num: '33',    cowshed: '001舍' },   
           { id: 31,  cowshedGroup: 'A组(总数：100)',  groupnum: '100', num: '33',  cowshed: '002舍'  }, 
           { id: 32, cowshedGroup: 'A组(总数：100)',   groupnum: '100',num: '33', cowshed: '003舍' }, 
           {  id: 1,  cowshedGroup: 'B组(总数：100)',   groupnum: '200',num: '33',    cowshed: '003舍' },   
           { id: 31,  cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33',  cowshed: '003舍'  }, 
           { id: 32, cowshedGroup: 'B组(总数：100)',  groupnum: '200', num: '33', cowshed: '006舍' }, 
       ],
 
       

       userClickList1:[
        //  {name:"员工1",id:"员工ID1"}
       ],

       userClickList2:[
           //  {name:"员工1",id:"员工ID1"}
       ],
 
       userList:[
        {
          value: '角色ID1', label: '角色1',  
          children: [
            { value: '员工ID1', label: '员工1' }, 
            { value: '员工ID2', label: '员工2' }
          ]
        }, 
        {
          value: '角色ID2',  label: '角色2',
          children: [
            { value: '员工ID3', label: '员工3' }, 
            { value: '员工ID4', label: '员工4' }
          ]
          
        },
         {
          value: '角色ID3',  label: '角色ID3',
          children: [
            {  value: '员工3',  label: '员工3'  }, 
            { value: '员工4',  label: '员工4'   }, 
            {   value: '员工5', label: '员工5' }
          ]
        }
      ],
 
       
 
       rightlistAll:[],
        
        //权限数据
        rightlist: [
          
  
         
      ],
 
      //栏舍名字数据
       cowShedlist: [
        
        
        ],
 
       //名字数据
       leftlist: [
        
        
       ],

       //名字ID数据
       leftIdlist: [
        
        
       ],
  
        //树形控件的属性绑定对象
       //  treeProps:{
       //    label:'name',children:'barn_list'
       //  },
  
        
        //树形默认选中的值
        checkedIdTxtArr:[],
        
        filterText:""
      
        
     }
   },
 
    
   created(){
       //获取按钮权限
       const isButtonEdit = checkButtons(this.$store.state.buttonsList, "犊牛类型编辑")
       this.isButtonEdit = isButtonEdit
       console.log('this.isButtonEdit==========',this.isButtonEdit)
      
      var me = this
      //获取下拉框
      this.get_select_list1()
 
       //表格 - 初始化 
      this.get_table_data()
 
 
 
      
 
     
     
   },
   watch: {
       filterText(val) {
         this.$refs.tree.filter(val);
       }
     },
   methods:{
 
 
     getSpanArr2(list,index) {
       var me = this
         // 先给所有的数据都加一个v.rowspan = 1
         list.forEach(item => {
             item.rowspan = 1;
             item.rowspan1 = 1;
         
         });
         // 双层循环
         for (let i = 0; i < list.length; i++) {
             for (let j = i + 1; j < list.length; j++) {
                 //此处可根据相同字段进行合并
                 if (list[i].barn_group_name_and_number== list[j].barn_group_name_and_number) {
                     list[i].rowspan++;
                     list[j].rowspan--;
                 }
             }
             // 这里跳过已经重复的数据
             i = i + list[i].rowspan - 1;
             i = i + list[i].rowspan1 - 1;
         }
         me.tableSeeList2[index].barn_group_list = list;
     },
 
     //设置单元格
     getSpanArr1(list) {
         // 先给所有的数据都加一个v.rowspan = 1
         list.forEach(item => {
             item.rowspan = 1;
             item.rowspan1 = 1;
         
         });
         // 双层循环
         for (let i = 0; i < list.length; i++) {
             for (let j = i + 1; j < list.length; j++) {
                 //此处可根据相同字段进行合并 -  第一列
                 if (list[i].barn_group_name_and_number== list[j].barn_group_name_and_number) {
                     list[i].rowspan++;
                     list[j].rowspan--;
                 }
                 //此处可根据相同字段进行合并 -  第二列
                 // if (list[i].cowshed== list[j].cowshed) {
                 //     list[i].rowspan1++;
                 //     list[j].rowspan1--;
                 // }
             }
             // 这里跳过已经重复的数据
             i = i + list[i].rowspan - 1;
             i = i + list[i].rowspan1 - 1;
         }
         this.tableSeeList1 = list;
     },

     getSpanArr22(list,index) {
       var me = this
         // 先给所有的数据都加一个v.rowspan = 1
         list.forEach(item => {
             item.rowspan = 1;
             item.rowspan1 = 1;
         
         });
         // 双层循环
         for (let i = 0; i < list.length; i++) {
             for (let j = i + 1; j < list.length; j++) {
                 //此处可根据相同字段进行合并
                 if (list[i].barn_group_name_and_number== list[j].barn_group_name_and_number) {
                     list[i].rowspan++;
                     list[j].rowspan--;
                 }
             }
             // 这里跳过已经重复的数据
             i = i + list[i].rowspan - 1;
             i = i + list[i].rowspan1 - 1;
         }
         me.tableCloseList2[index].barn_group_list = list;
     },

     getSpanArr222(list,index) {
         var me = this
         // 先给所有的数据都加一个v.rowspan = 1
         list.forEach(item => {
             item.rowspan = 1;
             item.rowspan1 = 1;
         
         });
         // 双层循环
         for (let i = 0; i < list.length; i++) {
             for (let j = i + 1; j < list.length; j++) {
                 //此处可根据相同字段进行合并 -  第一列
                 if (list[i].barn_group_name_and_number== list[j].barn_group_name_and_number) {
                     list[i].rowspan++;
                     list[j].rowspan--;
                 }
                 //此处可根据相同字段进行合并 -  第二列
                 // if (list[i].cowshed== list[j].cowshed) {
                 //     list[i].rowspan1++;
                 //     list[j].rowspan1--;
                 // }
             }
             // 这里跳过已经重复的数据
             i = i + list[i].rowspan - 1;
             i = i + list[i].rowspan1 - 1;
         }
         this.tableResultDetailList2 = list;
     },
 
     //设置单元格
     getSpanArr11(list) {
         // 先给所有的数据都加一个v.rowspan = 1
         list.forEach(item => {
             item.rowspan = 1;
             item.rowspan1 = 1;
         
         });
         // 双层循环
         for (let i = 0; i < list.length; i++) {
             for (let j = i + 1; j < list.length; j++) {
                 //此处可根据相同字段进行合并 -  第一列
                 if (list[i].barn_group_name_and_number== list[j].barn_group_name_and_number) {
                     list[i].rowspan++;
                     list[j].rowspan--;
                 }
                 //此处可根据相同字段进行合并 -  第二列
                 // if (list[i].cowshed== list[j].cowshed) {
                 //     list[i].rowspan1++;
                 //     list[j].rowspan1--;
                 // }
             }
             // 这里跳过已经重复的数据
             i = i + list[i].rowspan - 1;
             i = i + list[i].rowspan1 - 1;
         }
         this.tableCloseList1 = list;
     },

     //设置单元格
     getSpanArr111(list) {
         // 先给所有的数据都加一个v.rowspan = 1
         list.forEach(item => {
             item.rowspan = 1;
             item.rowspan1 = 1;
         
         });
         // 双层循环
         for (let i = 0; i < list.length; i++) {
             for (let j = i + 1; j < list.length; j++) {
                 //此处可根据相同字段进行合并 -  第一列
                 if (list[i].barn_group_name_and_number== list[j].barn_group_name_and_number) {
                     list[i].rowspan++;
                     list[j].rowspan--;
                 }
                 //此处可根据相同字段进行合并 -  第二列
                 // if (list[i].cowshed== list[j].cowshed) {
                 //     list[i].rowspan1++;
                 //     list[j].rowspan1--;
                 // }
             }
             // 这里跳过已经重复的数据
             i = i + list[i].rowspan - 1;
             i = i + list[i].rowspan1 - 1;
         }
         this.tableResultDetailList1 = list;
     },

     
 
     // 合并单元格相同内容
     ObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
         // 第一列
         if (columnIndex === 0) {
             return {
                 rowspan: row.rowspan,
                 colspan: 1,
             };
         }
         // 第二列
         // if (columnIndex === 1) {
         //     return {
         //         rowspan: row.rowspan1,
         //         colspan: 1,
         //     };
         // }
       
    },
 
     filterNode(value, data) {
         if (!value) return true;
         return data.name.indexOf(value) !== -1;
       },
 
     get_auto_buttons() {
       // 编辑
       const isButtonEdit = checkButtons(this.$store.state.buttonsList, "用户管理编辑")
       this.isButtonEdit = isButtonEdit
       console.log('this.isButtonEdit==========',this.isButtonEdit)
     },
     
     //获取 下拉框
     get_select_list1(){
         var me = this
         
         ajaxDataPost('/api/v1/ops/base_setting/category_table/list?page=1&page_size=1000', {category_type:1}).then(e => {
           console.log("工单分类下拉框1：",e)
           if(e.code == 200 ){
             me.typeList = e.data.list
           } else {
             me.typeList = []
           }
 
         })
 
         
  
 
 
         ajaxDataPost('/api/v1/system/user/list?page=1&page_size=1000', {name:""}).then(e => {
           console.log("人员下拉：",e)
           if(e.code == 200 ){
             me.personList = e.data.list
           } else {
             me.personList = []
           }
 
         })
 
 
 
  
 //         rightlist
 
         ajaxDataPost('/api/v1/ops/barn_group/list?page=1&page_size=1000', {name:""}).then(e => {
           console.log("多选框1：",e)
 
           //打印请求成功结果
           if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
             me.rightlist = []
           } else {
             var rightlist = e.data.list
             //由于后端数据ID重复，这里需要ID前增加虚拟数据。一级组，二级舍
             rightlist.forEach(function(item){
               item.idTxt = "组"+item.id
               console.log(item)
               if(item.barn_list.length !== 0){
                 item.barn_list.forEach(function(items){
                   items.idTxt = ""+ items.id
                 }) 
               }
                 
             })
             me.rightlist = rightlist
           }
 
           console.log("多选框 me.rightlist ：", me.rightlist )
 
         })
 
 
          ajaxDataPost('/api/v1/ops/barn/list?page=1&page_size=1000', {name:"",barn_group_name:"",status:undefined}).then(e => {
           console.log("所有栏舍：",e)
 
           //打印请求成功结果
           if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
             me.cowShedlist = []
           } else {
         
             me.cowShedlist = e.data.list
 
           }
 
         })
 

         


         ajaxDataGet('/api/v1/ops/calf_feed/table/field_list?page=1&page_size=1000', { }).then(e => {
           console.log("字段下拉框1：",e)
           if(e.code == 200 ){
             me.fieldList = e.data
           } else {
             me.fieldList = []
           }
 
         })


         ajaxDataPost('/api/v1/system/role/user_list?page=1&page_size=1000', { }).then(e => {
           console.log("userList用户下拉框1：",e)
           if(e.code == 200 ){
             me.userList = e.data.list
           } else {
             me.userList = []
           }
 
         })
         

         ajaxDataPost('/api/v1/ops/message_template/list?page=1&page_size=1000', { }).then(e => {
           console.log("消息模板下拉：",e)
 
           //打印请求成功结果
           if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
             me.messageList = []
           } else {
         
             me.messageList = e.data.list
 
           }
 
         })
         
 
         // ajaxDataPost('/api/v1/ops/barn_group/list?page=1&page_size=1000', {name:""}).then(e => {
         //   console.log("穿梭框1：",e)
 
         //   //打印请求成功结果
         //   if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
         //     me.transDataList1 = []
         //   } else {
         //     var transDataList1 = e.data.list
         //     transDataList1.forEach(function(item){
         //       item.name = item.name + "（犊牛数量："+ item.calf_number + "）"
         //     })
         //     me.transDataList1 = transDataList1
         //   }
 
         // })
 
 
         // ajaxDataPost('/api/v1/ops/barn/list?page=1&page_size=1000', {name:"",barn_group_name:"",status:undefined}).then(e => {
         //   console.log("穿梭框2：",e)
 
         //   //打印请求成功结果
         //   if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
         //     me.transDataList2 = []
         //   } else {
         
         //     var transDataList2 = e.data.list
         //     transDataList2.forEach(function(item){
         //       if(item.stauts == 4){
         //         item.name = item.name + "（犊牛数量：0）"
         //       } else {
         //         item.name = item.name + "（犊牛数量：1）"
         //       }
               
         //     })
         //     me.transDataList2 = transDataList2
 
         //   }
 
         // })
     
     },
 
     
     //获取 表格
     get_table_data() {
  
      var me = this
 
      me.tableLoading = true
      console.log("searchData======>", me.searchData)





      if( me.searchData.work_order_category_id == ""){
        me.searchData.work_order_category_id = undefined
      }

      if( me.searchData.work_order_type == ""){
        me.searchData.work_order_type = undefined
      }

      if( me.searchData.status == ""){
        me.searchData.status = undefined
      }
 
       var send_url = me.url_get_table + '?page=' + me.searchData.page +  '&page_size=' + me.searchData.page_size
 
       ajaxDataPost(send_url,  me.searchData).then(e => {
         console.log("表格请求结果：",e)
           //打印请求成功结果
           if(e.code == 200 ){
             me.tableList = e.data.list
             me.searchData.total = e.data.total;	// 总数
             me.searchData.page = e.data.page;	//页码
             me.searchData.page_size = e.data.page_size;	//每页数量
            
           } else {
             me.$message({ type: 'error', message: '请求表格列表失败！' + e.msg, duration: 2000 })
           }
 
           setTimeout(() => {
             me.tableLoading = false
           }, 100)
   
         })
 
        
     },
     //搜索 查询表格
     form_search(){
       var me = this
       console.log('请求表格列表searchData',me.searchData)
       if (me.searchData.inputDatetime1 !== '' && me.searchData.inputDatetime1 !== null) {
           me.searchData.start_finished_time = parseTime(me.searchData.inputDatetime1[0], '{y}-{m}-{d}')
           me.searchData.end_finished_time = parseTime(me.searchData.inputDatetime1[1], '{y}-{m}-{d}')
         } else {
           me.searchData.inputDatetime1 = ''
           me.searchData.start_finished_time = ''
           me.searchData.end_finished_time = ''
         }
 
         if (me.searchData.inputDatetime2 !== '' && me.searchData.inputDatetime2 !== null) {
           me.searchData.start_created_time = parseTime(me.searchData.inputDatetime2[0], '{y}-{m}-{d}')
           me.searchData.end_created_time = parseTime(me.searchData.inputDatetime2[1], '{y}-{m}-{d}')
         } else {
           me.searchData.inputDatetime2 = ''
           me.searchData.start_created_time = ''
           me.searchData.end_created_time = ''
         }



       me.get_table_data()
 
     },


   
 
     //重置 表格
     form_clear(){
       var me = this
       me.searchData.number = ""
       me.searchData.work_order_user_name = ""
       me.searchData.operation_user_name = ""
 
       me.searchData.work_order_category_id = undefined
       me.searchData.work_order_type = undefined
       me.searchData.status = undefined
       me.searchData.start_finished_time = ""
       me.searchData.end_finished_time = ""
       me.searchData.start_created_time = ""
       me.searchData.end_created_time = ""
       me.searchData.inputDatetime1 = ""
       me.searchData.inputDatetime2 = ""
 
       me.searchData.page = 1
       me.searchData.page_size = 10


  
       me.get_table_data()
     },
 
     //监听 page_size 改变的事件
     change_size_page(item){
       console.log(item)
      // this.searchData.page_size = item
       //  this.getUserList()
     },

     change_size_page_result2(item){
       console.log(item)
      // this.searchData.page_size = item
       //  this.getUserList()
     },
 
     //监听 page 改变的事件
     change_current_page(item){
       console.log(item)
        this.searchData.page = item
        this.get_table_data()
     },
     change_current_page_result2(item){
       console.log(item)
        this.searchData.page = item
        this.get_table_data()
     },
 
     //清空弹窗表单信息
     reset_form1(){
       this.addForm1.remark = ''
       this.addForm1.work_order_category_name = ''
       this.addForm1.work_order_category_id = undefined
       this.addForm1.work_order_type = undefined
       this.addForm1.id = undefined
       this.addForm1.is_show = 1
       this.addForm1.work_order_object = []
       this.leftIdlist = []
       this.leftlist = []

 


      
     },

     //清空弹窗表单信息
     reset_form2(){
       this.addForm2.remark = ''
       this.addForm2.work_order_category_name = ''
       this.addForm2.work_order_category_id = undefined
       this.addForm2.work_order_type = undefined
       this.addForm2.id = undefined
       this.addForm2.is_show = 1
       this.addForm2.work_order_object = []
       this.tableAddList2 = []
 
      
     },


  

     reset_condition1(){
 
       this.conditionForm1.group_id = 1
       this.conditionForm1.value = ''
       this.conditionForm1.condition_value = ''
       this.conditionForm1.field_name = ''
       this.conditionForm1.sql_name = ''
       this.conditionForm1.condition_key = undefined
      
     },
 
     //新增
     form_add1() {
       this.reset_form1()
       this.addFormStatus1 = 'create'
       this.addFormShow1 = true
       this.$nextTick(() => {
         this.$refs['addFormRef1'].clearValidate()
       })
     },


     form_add2() {
       this.reset_form2()
       this.addFormStatus2 = 'create'
       this.addFormShow2 = true
       this.$nextTick(() => {
         this.$refs['addFormRef2'].clearValidate()
       })
     },
 
     condition_add1() {
       this.reset_condition1()
       this.conditionFormStatus1 = 'create'
       this.conditionFormShow1 = true
       this.$nextTick(() => {
         this.$refs['conditionFormRef1'].clearValidate()
       })
     },

 
 
     form_see1(row) {
       var me = this
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.seeForm1 = Object.assign({}, row)  
      

       ajaxDataPost( me.url_close_detail_table+'?page=1&page_size=1000', {work_order_id:row.id}).then(e => {
           console.log("详情里的表格1：",e)
           //打印请求成功结果
           if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
             me.tableSeeList1 = []
           } else {
              
             me.tableSeeList1 = e.data.list[0].barn_group_list
             me.tableSeeList1.forEach(function(item){
                item.barn_group_name_and_number = item.barn_group_name + "（总数："  + item.barn_group_calf_amount + "）"
             })
          
           }

            //合并单元格
            me.getSpanArr1(me.tableSeeList1)


           me.seeFormStatus1 = 'see'
           me.seeFormShow1 = true
        })

        
        this.$nextTick(() => {
          this.$refs['seeFormRef1'].clearValidate()
        })
     },

     form_see2(row) {
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.seeForm2 = Object.assign({}, row)  
       this.tableSeeList2 = row.work_order_object.condition
       this.seeFormStatus2 = 'see'
       this.seeFormShow2 = true
       this.$nextTick(() => {
         this.$refs['seeFormRef2'].clearValidate()
       })
     },


     form_close1(row) {
       console.log('行内容row=========', row)
       //编辑行内容赋值
       var me = this

       ajaxDataPost( me.url_close_detail_table+'?page=1&page_size=1000', {work_order_id:row.id}).then(e => {
           console.log("详情里的表格1：",e)
           //打印请求成功结果
           if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
             me.tableCloseList1 = []
             me.tableCloseId1 = undefined
           } else {
              
             me.tableCloseList1 = e.data.list[0].barn_group_list
             me.tableCloseId1 = e.data.list[0].id
             me.tableCloseList1.forEach(function(item){
                item.barn_group_name_and_number = item.barn_group_name + "（总数："  + item.barn_group_calf_amount + "）"
             })
          
           }

            //合并单元格
            me.getSpanArr11(me.tableCloseList1)

            this.closeFormShow1 = true
          
      })
 
       
       this.$nextTick(() => {
         this.$refs['closeFormRef1'].clearValidate()
       })
     },

     form_close2(row) {
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.closeForm2 = Object.assign({}, row)  
       var me = this

     

        ajaxDataPost( me.url_close_detail_table+'?page=1&page_size=1000', {work_order_id:row.id}).then(e => {
            console.log("详情里的表格1：",e)
            //打印请求成功结果
            if(e.data.list == null || e.data.list == undefined ||e.data.list.length == 0   ){
              me.tableCloseList2 = []
              me.tableCloseId2 = undefined
            } else {
                
              me.tableCloseList2 = e.data.list
  
              me.tableCloseList2.forEach(function(item){

                  item.barn_group_list.forEach(function(items){
                    items.barn_group_name_and_number = items.barn_group_name + "（总数："  + items.barn_group_calf_amount + "）"
                  })
                  
              })
            
            }

            //不定项的合并单元格
            me.tableCloseList2.forEach(function(item,index){
              me.getSpanArr22(item.barn_group_list, index)
            })
  

            me.closeFormShow2 = true
            
        })

 
 
      
     },
     //关闭工单
     sure_dialog_close1(){
        var me = this 
        ajaxDataDelete( '/api/v1/ops/work_order/user/close/'+ me.tableCloseId1, {}).then(e => {
           console.log("关闭工单",e)
           if(e.code == 200  ){
                   me.$message({ type: 'success', message: '成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.closeFormShow1 = false
                   me.get_table_data()
            } else {
                   me.$message({ type: 'error', message: '失败！' + e.msg, duration: 2000 })
            }

          
        })
      
   
     },



 
     sure_dialog_close2(row){
      console.log(row)
    
        var me = this 
        ajaxDataDelete( '/api/v1/ops/work_order/user/close/'+ row.id, {}).then(e => {
           console.log("关闭工单",e)
           if(e.code == 200  ){
                   me.$message({ type: 'success', message: '成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.closeFormShow2 = false
                   me.get_table_data()
            } else {
                   me.$message({ type: 'error', message: '失败！' + e.msg, duration: 2000 })
            }

          
        })
     },


     
     close_dialog_close1(){
        //内容重置
 
        this.closeFormShow1 = false
     },

     close_dialog_close2(){
        //内容重置
      
        this.closeFormShow2 = false
     },

     see_dialog_close1(){
        //内容重置
 
        this.seeFormShow1 = false
     },
 
     see_dialog_close2(){
        //内容重置
 
        this.seeFormShow2 = false
     },
 
     
     form_result1(row) {
       var me = this 
       console.log('行内容row=========', row)
       //编辑行内容赋值
       me.resultForm1 = Object.assign({}, row)  
       me.resultSearchData1.work_order_id = row.id 
       

        ajaxDataPost('/api/v1/ops/work_order/exec_result?page=1&page_size=1000',  me.resultSearchData1).then(e => {
          console.log("执行结果：",e)
          if(e.code == 200 ){
            me.tableResultList1 = e.data.list
          } else {
            me.tableResultList1 = []
          }

        })


       this.resultFormShow1 = true

     },
     
     form_result2(row) {
      var me = this
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.resultForm2 = Object.assign({}, row)  

 
      
   

       me.resultSearchData2.work_order_id = row.id 
       me.resultSearchData2.user_name = ""
       me.resultSearchData2.sub_work_order_number = ""
       me.resultSearchData2.status = undefined
       me.resultSearchData2.start_created_time = ""
       me.resultSearchData2.end_created_time = ""
       me.resultSearchData2.inputDatetime1 = ""
       me.resultSearchData2.page = 1
       me.resultSearchData2.page_size = 10

       ajaxDataPost('/api/v1/ops/work_order/exec_result'+ '?page=' + me.resultSearchData2.page +  '&page_size=' + me.resultSearchData2.page_size,  me.resultSearchData2).then(e => {
          console.log("执行结果：",e)
          if(e.code == 200 ){
            me.tableResultList2 = e.data.list
          } else {
            me.tableResultList2 = []
          }

          me.resultFormShow2 = true
        })


      
     },


     //搜索 查询表格
     form_search_result2(){
       var me = this
       console.log('请求表格列表searchData',me.searchData)
  
 

       if (me.resultSearchData2.inputDatetime1 !== '' && me.resultSearchData2.inputDatetime1 !== null) {
           me.resultSearchData2.start_created_time = parseTime(me.resultSearchData2.inputDatetime1[0], '{y}-{m}-{d}')
           me.resultSearchData2.end_created_time = parseTime(me.resultSearchData2.inputDatetime1[1], '{y}-{m}-{d}')
         } else {
           me.resultSearchData2.inputDatetime1 = ''
           me.resultSearchData2.start_created_time = ''
           me.resultSearchData2.end_created_time = ''
         }
 


       ajaxDataPost('/api/v1/ops/work_order/exec_result'+ '?page=' + me.resultSearchData2.page +  '&page_size=' + me.resultSearchData2.page_size,  me.resultSearchData2).then(e => {
          console.log("执行结果：",e)
          if(e.code == 200 ){
            me.tableResultList2 = e.data.list
          } else {
            me.tableResultList2 = []
          }
 
        })

 
     },


     form_result_detail_see1(row) {
       console.log('行内容row=========', row)
       var me = this 
  

       me.tableResultDetailList1 = row.result_object
 
       me.tableResultDetailList1.forEach(function(item){
            item.barn_group_name_and_number = item.barn_group_name + "（总数："  + item. barn_group_calf_amount + "）"
       })
       me.getSpanArr111(me.tableResultDetailList1)

       this.resultFormDetailShow1 = true
     },

     form_result_detail_see2(row) {
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.resultFormDetail2 = Object.assign({}, row)  

       me.tableResultDetailList2 = row.result_object
 
       me.tableResultDetailList2.forEach(function(item){
            item.barn_group_name_and_number = item.barn_group_name + "（总数："  + item. barn_group_calf_amount + "）"
       })
       me.getSpanArr222(me.tableResultDetailList2)


       this.resultFormDetailShow2 = true
     },


     result_detail_dialog_close1(){
        //内容重置
        this.resultFormDetailShow1 = false
     },

     result_detail_dialog_close2(){
        //内容重置
        this.resultFormDetailShow2 = false
     },
 
     result_dialog_close1(){
        //内容重置
        this.resultFormShow1 = false
     },

     result_dialog_close2(){
        //内容重置
        this.resultFormShow2 = false
     },
 
 
     
     form_set1(row) {
       var me = this
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.setForm1.id = row.id 

       if(row.send_message_option.accept_order_user_id.length !== 0){
         me.setForm1.accept_order_user_id = row.send_message_option.accept_order_user_id
         me.setForm1.message_template_id = row.send_message_option.message_template_id
         me.setForm1.type = row.send_message_option.crontab_option.type

         var day_time = "Sat Oct 07 2023 "+row.send_message_option.crontab_option.crontab_config.day_time+" GMT+0800 (中国标准时间)"
         me.setForm1.day_time = new Date(day_time)

 
         me.userClickList1 = row.send_message_option.accept_order_user_detail
       } else {


         me.setForm1.accept_order_user_id = undefined
         me.setForm1.message_template_id =  undefined
         me.setForm1.type = undefined
         me.setForm1.day_time = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')

    
         me.userClickList1 = []
       }


 
 
       me.setFormShow1 = true
       this.$nextTick(() => {
         this.$refs['setFormRef1'].clearValidate()
       })
     },
 

     form_set2(row) {
       var me = this
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.setForm2.id = row.id 
      

       if(row.send_message_option.accept_order_user_id.length !== 0){
         me.setForm2.accept_order_user_id = row.send_message_option.accept_order_user_id
         me.setForm2.message_template_id = row.send_message_option.message_template_id
         me.setForm2.cron_type = row.send_message_option.crontab_option.crontab_config.cron_type

         var day_time = "Sat Oct 07 2023 "+row.send_message_option.crontab_option.crontab_config.day_time+" GMT+0800 (中国标准时间)"
         me.setForm2.day_time = new Date(day_time)

 
         me.setForm2.week_kind = row.send_message_option.crontab_option.crontab_config.week_kind
         me.setForm2.day_kind = row.send_message_option.crontab_option.crontab_config.day_kind
       
         me.userClickList2 = row.send_message_option.accept_order_user_detail
       } else {


         me.setForm2.accept_order_user_id = undefined
         me.setForm2.message_template_id = undefined
         me.setForm2.cron_type = undefined
         me.setForm2.day_time = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')

         me.setForm2.week_kind =  []
         me.setForm2.day_kind =  []
         me.userClickList2 = []
       }
       
 
       this.setFormShow2 = true
       this.$nextTick(() => {
         this.$refs['setFormRef2'].clearValidate()
       })
     },

     set_dialog_close1(){
      this.setFormShow1 = false
     },
     set_dialog_close2(){
      this.setFormShow2 = false
     },

     set_save1(){
       var me = this
       this.$refs['setFormRef1'].validate(valid => {
         //验证成功
         if (valid) {

          var clickArr = []

           if(me.userClickList1.length == 0){
            me.$message({ type: 'error', message: '请选择用户！'  , duration: 2000 })
            return false 
           } else {
              me.userClickList1.forEach(function(item){
                clickArr.push(item.id)
              })
           }
           //发起请求
           var send_data = {
              "id": me.setForm1.id,
              "work_order_type": 1, 
              "send_message_option": {
                "accept_order_user_id": clickArr,
                "accept_order_user_detail": me.userClickList1,
                "message_template_id":me.setForm1.message_template_id,
                "crontab_option": {
                  "type": me.setForm1.type,
                  "crontab_config": {
                    "cron_type": 0,
                    "week_kind": [],
                    "day_kind": [],
                    "day_time": parseTime(me.setForm1.day_time, '{h}:{i}:{s}') 
                  }
                }
              }
            }
          
           console.log("弹窗参数：", send_data)
 
           //关闭弹窗
           // me.addFormShow = false
          //加载 - 发送新增保存
          ajaxDataPost("/api/v1/ops/work_order/send_message/update", send_data).then(e => {
                 console.log("发送结果：",e)
                 //打印请求成功结果
                 if(e.code == 200  ){
                   me.$message({ type: 'success', message: '发送成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.setFormShow1 = false
                   me.get_table_data()
                 } else {
                   me.$message({ type: 'error', message: '发送失败！' + e.msg, duration: 2000 })
                 }
             })
          
         }
       })
     },

     set_save2(){
       var me = this
       console.log(me.setForm2)
       this.$refs['setFormRef2'].validate(valid => {
         //验证成功
         if (valid) {

          var clickArr = []

           if(me.userClickList2.length == 0){
            me.$message({ type: 'error', message: '请选择用户！'  , duration: 2000 })
            return false 
           } else {
              me.userClickList2.forEach(function(item){
                clickArr.push(item.id)
              })
           }
           //发起请求
           var send_data = {
              "id": me.setForm2.id,
              "work_order_type": 2, 
              "send_message_option": {
                "accept_order_user_id": clickArr,
                "accept_order_user_detail": me.userClickList2,
                "message_template_id":me.setForm2.message_template_id,
                "crontab_option": {
                  "type": 3,  
                  "crontab_config": {
                    "cron_type": me.setForm2.cron_type,
                    "week_kind": me.setForm2.week_kind,
                    "day_kind": me.setForm2.day_kind,
                    "day_time": parseTime(me.setForm2.day_time, '{h}:{i}:{s}') 
                  }
                }
              }
            }
          
           console.log("弹窗参数：", send_data)
 
           //关闭弹窗
           // me.addFormShow = false
          //加载 - 发送新增保存
          ajaxDataPost("/api/v1/ops/work_order/send_message/update", send_data).then(e => {
                 console.log("发送结果：",e)
                 //打印请求成功结果
                 if(e.code == 200  ){
                   me.$message({ type: 'success', message: '发送成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.setFormShow2 = false
                   me.get_table_data()
                 } else {
                   me.$message({ type: 'error', message: '发送失败！' + e.msg, duration: 2000 })
                 }
          })
          
         }
       })
     },

 
     //编辑
     form_edit1(row) {
       var me = this

       this.reset_form1()
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.addForm1 = Object.assign({}, row)  
  
       //这里获取一下实际存的栏舍ID
      //  var checklist = [27,28,30]

       var checklist = row.work_order_object.barn_ids
       if(checklist.length !== 0){
         var newChecklist = checklist.map((item)=>{
           return ""+item 
         })
       }
      
 
       console.log("newChecklist===========",newChecklist)
      
       me.checkedIdTxtArr  = newChecklist
 
       var leftlist = []
       var leftIdlist = []
       //去所有栏舍里获取当前实际栏舍选择的名字
       me.cowShedlist.forEach(function(item){
 
         newChecklist.forEach(function(items){
             if(parseFloat(items) == item.id ){
       
               if(items.indexOf("组")  == -1 ){
                   leftlist.push(item.name)
                   leftIdlist.push(item.id)
               }  
          
             }
           
         })
 
       })
       
       me.leftlist = leftlist
       me.leftIdlist = leftIdlist

       console.log("me.leftlist",me.leftlist)
       console.log("me.leftIdlist",me.leftIdlist)
       
 
     
 
  
 
       this.addFormStatus1 = 'edit'
       this.addFormShow1 = true
       this.$nextTick(() => {
         this.$refs['addFormRef1'].clearValidate()
       })
     },

     form_edit2(row) {
       var me = this
       this.reset_form2()
       console.log('行内容row=========', row)
       //编辑行内容赋值
       this.addForm2 = Object.assign({}, row)  
  
       var tableAddList2 = row.work_order_object.condition
       if(tableAddList2.length !== 0){
         me.tableAddList2 = tableAddList2
       } else {
        me.tableAddList2 = []
       }
 
       this.addFormStatus2 = 'edit'
       this.addFormShow2 = true
       this.$nextTick(() => {
         this.$refs['addFormRef2'].clearValidate()
       })
     },


  

     condition_edit1(row,index ) {
       var me = this
       console.log('行内容row=========', row)
       console.log('行内容index=========', index)
       //编辑行内容赋值
       this.conditionForm1 = Object.assign({}, row)  
       this.conditionIndex = index
  
      
  
 
       this.conditionFormStatus1 = 'edit'
       this.conditionFormShow1 = true
       this.$nextTick(() => {
         this.$refs['conditionFormRef1'].clearValidate()
       })
     },


     condition_delete1(row,index ) {
       var me = this
       console.log('行内容row=========', row)
       console.log('行内容index=========', index)
       //编辑行内容赋值
 
       me.tableAddList2.splice(index, 1)
 
    
 
       
     },

 
 
     //新增关闭
     add_dialog_close1(){
        //内容重置
        this.$refs['addFormRef1'].resetFields()
        this.addFormShow1 = false
     },

     add_dialog_close2(){
        //内容重置
        this.$refs['addFormRef2'].resetFields()
        this.addFormShow2 = false
     },
 

     condition_dialog_close1(){
        //内容重置
        this.$refs['conditionFormRef1'].resetFields()
        this.conditionFormShow1 = false
     },

     //新增 保存
     add_dialog_save1() {
       var me = this
     
       this.$refs['addFormRef1'].validate(valid => {
         //验证成功
         if (valid) {
           //发起请求
           var send_data = {
              "work_order_category_id": me.addForm1.work_order_category_id,
              "work_order_category_name": "",
              "work_order_type": 1,  // 1 一次性工单  2 周期性工单
              "work_order_object": {
                "barn_ids": me.leftIdlist,
                "condition": [ ]
              },
              "remark": me.addForm1.remark,
              "is_show": 1,// 1 一次性工单默认开启
            }
            
 
         
           console.log("弹窗参数：", send_data)
 
           //关闭弹窗
           // me.addFormShow = false
          //加载 - 发送新增保存
            ajaxDataPost(me.url_add_table, send_data).then(e => {
                 console.log("新增结果：",e)
                 //打印请求成功结果
                 if(e.code == 200  ){
                   me.$message({ type: 'success', message: '新增成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.addFormShow1 = false
                   me.get_table_data()
                 } else {
                   me.$message({ type: 'error', message: '新增失败！' + e.msg, duration: 2000 })
                 }
             })
          
         }
       })
     },

     add_dialog_save2() {
       var me = this
       this.$refs['addFormRef2'].validate(valid => {
         //验证成功
         if (valid) {
           //发起请求
           var send_data = {
              "work_order_category_id": me.addForm2.work_order_category_id,
              "work_order_category_name": "",
              "work_order_type": 2,  // 1 一次性工单  2 周期性工单
              "work_order_object": {
                "barn_ids": [ ], 
                "condition":  me.tableAddList2
              },
              "remark": me.addForm2.remark,
              "is_show": me.addForm2.is_show,
            }
            
 
         
           console.log("弹窗参数：", send_data)
 
           //关闭弹窗
           // me.addFormShow = false
          //加载 - 发送新增保存
            ajaxDataPost(me.url_add_table, send_data).then(e => {
                 console.log("新增结果：",e)
                 //打印请求成功结果
                 if(e.code == 200  ){
                   me.$message({ type: 'success', message: '新增成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.addFormShow2 = false
                   me.get_table_data()
                 } else {
                   me.$message({ type: 'error', message: '新增失败！' + e.msg, duration: 2000 })
                 }
             })
          
         }
       })
     },

     //前端展示数据
     add_condition_save1() {
       var me = this
 

       this.$refs['conditionFormRef1'].validate(valid => {
         //验证成功
         if (valid) {
           //发起请求
 
          var add_data = Object.assign({}, me.conditionForm1)  
          var field_name = me.fieldList.find(obj => obj.sql_name == add_data.sql_name).filed_name
          var condition_value  = me.conditionList.find(obj => obj.id == add_data.condition_key).name


          add_data.field_name = field_name
          add_data.condition_value = condition_value
          
           console.log("add_data",add_data)
        
           me.tableAddList2.push(add_data)


           me.conditionFormShow1 = false
          
         }
       })
     },
     

     //编辑 保存
     edit_dialog_save1(){
       var me = this
       this.$refs['addFormRef1'].validate(valid => {
         //验证成功
         if (valid) {
           //发起请求
           var send_data = {
              "id": me.addForm1.id,
              "work_order_category_id": me.addForm1.work_order_category_id,
              "work_order_category_name": "",
              "work_order_type": 1,  // 1 一次性工单  2 周期性工单
              "work_order_object": {
                "barn_ids": me.leftIdlist,
                "condition": [ ]
              },
              "remark": me.addForm1.remark,
            }
            
           console.log("弹窗参数：", send_data)
 
           //关闭弹窗
           // me.addFormShow = false
          //加载 - 发送新增保存
          ajaxDataPut(me.url_edit_table, send_data).then(e => {
                 console.log("编辑结果：",e)
                 //打印请求成功结果
                 if(e.code == 200  ){
                   me.$message({ type: 'success', message: '编辑成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.addFormShow1 = false
                   me.get_table_data()
                 } else {
                   me.$message({ type: 'error', message: '编辑失败！' + e.msg, duration: 2000 })
                 }
             })
          
         }
       })
     },

     //编辑 保存
     edit_dialog_save2(){
       var me = this
       this.$refs['addFormRef2'].validate(valid => {
         //验证成功
         if (valid) {
           //发起请求
           var send_data = {
            
               "id": me.addForm2.id,
               "work_order_category_id": me.addForm2.work_order_category_id,
                "work_order_category_name": "",
                "work_order_type": 2,  // 1 一次性工单  2 周期性工单
                "work_order_object": {
                  "barn_ids": [ ], 
                  "condition":  me.tableAddList2
                },
                "remark": me.addForm2.remark,
                "is_show": me.addForm2.is_show,
            }
           console.log("弹窗参数：", send_data)
 
           //关闭弹窗
           // me.addFormShow = false
          //加载 - 发送新增保存
          ajaxDataPut(me.url_edit_table, send_data).then(e => {
                 console.log("编辑结果：",e)
                 //打印请求成功结果
                 if(e.code == 200  ){
                   me.$message({ type: 'success', message: '编辑成功！'  , duration: 2000 })
                   //关闭弹窗
                   me.addFormShow2 = false
                   me.get_table_data()
                 } else {
                   me.$message({ type: 'error', message: '编辑失败！' + e.msg, duration: 2000 })
                 }
             })
          
         }
       })
     },
 
 
 
     edit_condition_save1(){
       var me = this
       this.$refs['conditionFormRef1'].validate(valid => {
         //验证成功
         if (valid) {
           //发起请求
          console.log(me.conditionForm1)


          var edit_data = Object.assign({}, me.conditionForm1)  

          console.log(edit_data)


          
          var field_name = me.fieldList.find(obj => obj.sql_name == edit_data.sql_name).filed_name
          var condition_value  = me.conditionList.find(obj => obj.id == edit_data.condition_key).name
          edit_data.field_name = field_name
          edit_data.condition_value = condition_value
        
           me.tableAddList2[me.conditionIndex].group_id = edit_data.group_id 
           me.tableAddList2[me.conditionIndex].field_name = edit_data.field_name 
           me.tableAddList2[me.conditionIndex].condition_key = edit_data.condition_key 
           me.tableAddList2[me.conditionIndex].sql_name = edit_data.sql_name 
           me.tableAddList2[me.conditionIndex].condition_value = edit_data.condition_value 
 

           me.conditionFormShow1 = false
          
         }
       })
     },
     
 
 
 
     form_delete(row) {
       var me = this
 
        me.$confirm('是否删除此条内容?', '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
             console.log("删除的ID参数：", row.id)
             //加载 - 发送新增保存
             ajaxDataDelete(me.url_delete_table + '/' +row.id, {}).then(e => {
                 console.log("编辑结果：",e)
                 //打印请求成功结果
                 if(e.code == 200  ){
                   me.$message({ type: 'success',  message: '删除成功!'  });
                   me.get_table_data()
                 } else {
                   me.$message({ type: 'error', message: '删除失败！' + e.msg, duration: 2000 })
                 }
             })
 
         
  
           
         }).catch(() => {
           me.$message({
             type: 'info',
             message: '已取消删除'
           });          
         });
 
 
        
     },
     //监听勾选
     change_check(data, checked, indeterminate) {
       console.log(data, checked, indeterminate) 
       var me =  this
   
       var checkedKeys = this.$refs.tree.getCheckedKeys() // 所有被选中的节点的 key 所组成的数组数据
       console.log(checkedKeys)
       this.checkedIdTxtArr = checkedKeys
  
       console.log("选中的IDTXT  checkedIdTxtArr",me.checkedIdTxtArr)
  
       console.log("    me.cowShedlist",    me.cowShedlist)
 
       var leftlist = []
       var leftIdlist = []
     
       me.cowShedlist.forEach(function(item){
 
          me.checkedIdTxtArr.forEach(function(items){
             if(parseFloat(items)  == item.id ){
                //不包含 组这个字段
                if(items.indexOf("组")  == -1 ){
                    console.log(items)
                    leftlist.push(item.name)
                    leftIdlist.push(item.id)
                }  
             }
           
          })
 
       })
       me.leftlist = leftlist
       me.leftIdlist = leftIdlist
 
       console.log("    me.leftlist",    me.leftlist)
       console.log("    me.leftIdlist",    me.leftIdlist)
 
     },
 
     change_person(value){
       var me = this 
       console.log("更改人员Id",value)
       var item  = me.personList.find(obj => obj.id == value)
       console.log("更改人员当前的内容",item)
       me.addForm.user_phone = item.phone
           
     },
 
     change_user1(value) {
        console.log(value)
        var me = this
        //选中的是最后的子节点
        if(value.length == 2){
          var nodesInfo = this.$refs['treeCas1'].getCheckedNodes()
          console.log(nodesInfo)
          var click_node = {"name":nodesInfo[0].data.name,"id":nodesInfo[0].data.id}
      
          var click_value = nodesInfo[0].data.id
  
 
          var isExist = me.userClickList1.filter(function(item){
            return item.id == click_value
          })
          console.log('isExist',isExist)
              
          if(isExist.length == 0){
            me.userClickList1.push(click_node)
          }  
        }

        console.log(me.userClickList1)
       
 

     },

     change_user2(value) {
        console.log(value)
        var me = this
        //选中的是最后的子节点
        if(value.length == 2){
          var nodesInfo = this.$refs['treeCas2'].getCheckedNodes()
          console.log(nodesInfo)
          var click_node = {"name":nodesInfo[0].data.name,"id":nodesInfo[0].data.id}
      
          var click_value = nodesInfo[0].data.id
  
 
          var isExist = me.userClickList2.filter(function(item){
            return item.id == click_value
          })
          console.log('isExist',isExist)
              
          if(isExist.length == 0){
            me.userClickList2.push(click_node)
          }  
        }

        console.log(me.userClickList2)
 

     },

     close_user1(item,index){
      console.log(item,index)

      this.userClickList1.splice(index, 1);
     },

     close_user2(item,index){
      console.log(item,index)

      this.userClickList2.splice(index, 1);
     },
      
  
     form_export() {
     //获取请求表格数据的参数
     //this.download.getdataListParm.parammaps = this.tableObj.getdataListParm.parammaps
     //请求表格
     // GetDataByName(this.download.getdataListParm).then(response => {
     //     if (response.data.list !== null) {
     //       this.download.list = response.data.list
     //     } else {
     //       this.download.list = []
     //     }
     //     var excelDatas = [
     //       {
     //         tHeader: ['表头1', '表头2', '表头3', '表头4',],
     //         filterVal: ['title1', 'title2', 'title3', 'title4'],
     //         tableDatas: this.download.list,
     //         sheetName: 'Sheet1'
     //       }
     //     ]
     //     json2excel(excelDatas, '表格大标题', true, 'xlsx')
     // })
 
     var excelDatas = [
         {
             tHeader: ['表头1', '表头2', '表头3', '表头4',],
             filterVal: ['title1', 'title2', 'title3', 'title4'],
             tableDatas: [ 
                 {title1: "内容1",title2: "内容2",title3: "内容3",title4: "内容4"},
                 {title1: "内容11",title2: "内容22",title3: "内容32",title4: "内容44"},
                 {title1: "内容111",title2: "内容222",title3: "内容333",title4: "内容444"},
             ],
             sheetName: 'Sheet1'
         }
     ]
     json2excel(excelDatas, '表格大标题', true, 'xlsx')
 }
 
      
 
   }
 }
 </script>
 <!-- 加了scoped，则是仅在此组件里生效 -->
 <style scoped>
 .el-transfer /deep/.el-transfer-panel {  width:300px;  text-align: left;}
 .groupSpanClass{display: inline-block; width: 60px;  height: 20px;  border-radius: 20px;}
 .ifClass{display: inline-block;margin-right:30px }

 .colorSpan{display: inline-block; width: 60px;  height: 40px;  border-radius: 20px;background:#fff}
 .spanc1{background-color:#409eff}
 .spanc2{background-color:#67c23a}
 .spanc3{background-color:#e6a23c}
 .spanc4{background-color:#f56c6c}
 .spanc5{background-color:#6890bb}
 .spanc6{background-color:#7eb961}
 .spanc7{background-color:#dbdf51}
 .spanc8{background-color:#f9a75d}
 .spanc9{background-color:#d2e8ff}
 .spanc10{background-color:#cdffb4}
 .spanc11{background-color:#ffd6b1}
 

 </style>
 
 