<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="任务名称" prop="taskName">
        <el-input
          v-model="queryParams.taskName"
          placeholder="请输入任务名称"
          clearable
          size="mini"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="流程key" prop="processKey">-->
<!--        <el-input-->
<!--          v-model="queryParams.processKey"-->
<!--          placeholder="请输入流程key"-->
<!--          clearable-->
<!--          size="mini"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="流程名称" prop="instanceName">-->
<!--        <el-input-->
<!--          v-model="queryParams.instanceName"-->
<!--          placeholder="请输入流程名称"-->
<!--          clearable-->
<!--          size="mini"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="流程类型" prop="processKey">
        <el-select v-model="queryParams.processKey" clearable placeholder="流程类型"  @change="onInput()"         size="mini">
          <el-option
            v-for="item in listModeler"
            :key="item.key"
            :label="item.name"
            :value="item.key">
          </el-option>
        </el-select>
      </el-form-item>
<!--      <el-form-item label="部门id" prop="deptId">-->
<!--        <el-input-->
<!--          v-model="queryParams.deptId"-->
<!--          placeholder="请输入部门id"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item class="treeselectForm" label="部门名称" prop="orgIds">
        <tree @treeselectFn="treeselectFn" :treeval="orgIds" style="top:5px"></tree>
      </el-form-item>
<!--      <el-form-item label="部门级别" prop="deptLevel">-->
<!--        <el-input-->
<!--          v-model="queryParams.deptLevel"-->
<!--          placeholder="请输入部门级别"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="部门编号" prop="deptCode">-->
<!--        <el-input-->
<!--          v-model="queryParams.deptCode"-->
<!--          placeholder="请输入部门编号"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="部门名称" prop="deptName">-->
<!--        <el-input-->
<!--          v-model="queryParams.deptName"-->
<!--          placeholder="请输入部门名称"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sfa:taskInstance:add']"
        >新增</el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="success"-->
<!--          plain-->
<!--          icon="el-icon-edit"-->
<!--          size="mini"-->
<!--          :disabled="single"-->
<!--          @click="handleUpdate"-->
<!--          v-hasPermi="['sfa:taskInstance:edit']"-->
<!--        >修改</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="danger"-->
<!--          plain-->
<!--          icon="el-icon-delete"-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="handleDelete"-->
<!--          v-hasPermi="['sfa:taskInstance:remove']"-->
<!--        >删除</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="warning"-->
<!--          plain-->
<!--          icon="el-icon-download"-->
<!--          size="mini"-->
<!--          @click="handleExport"-->
<!--          v-hasPermi="['sfa:taskInstance:export']"-->
<!--        >导出</el-button>-->
<!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="taskInstanceList" @selection-change="handleSelectionChange">
<!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="任务名称"  prop="taskName" />
<!--      <el-table-column label="流程key" align="center" prop="processKey" />-->
      <el-table-column label="流程名称"  prop="instanceName" />
      <el-table-column label="部门级别"  prop="deptLevel" width="150">
        <template slot-scope="scope">
          {{storeCategoryFormatter(scope.row,scope.column)}}
        </template>
      </el-table-column>
<!--      <el-table-column label="部门编号" align="center" prop="deptCode" />-->
      <el-table-column label="部门名称"  prop="deptName" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="110">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['sfa:taskInstance:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['sfa:taskInstance:remove']"
            class="text-danger"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改任务和审批流程一对多关系对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="任务名称" prop="taskName">
          <div @click="taskOpenFn">
              <el-input readonly v-model="form.taskName" placeholder="请输入任务名称" />
          </div>
        </el-form-item>
<!--        <el-form-item label="流程key" prop="processKey">-->
<!--          <el-input v-model="form.processKey" placeholder="请输入流程key" />-->
<!--        </el-form-item>-->
        <el-form-item label="流程类型" prop="processKey">
          <el-select v-model="form.processKey" clearable placeholder="流程类型" style="width: 100%;" @change="onInput()">
            <el-option
              v-for="item in listModeler"
              :key="item.key"
              :label="item.name"
              :value="item.key">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="归属部门" prop="deptId" >
          <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门"  style="width: 100%"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="title" :visible.sync="taskOpen" width="80%" append-to-body>
      <el-form :model="queryTaskParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="任务名称" prop="taskName">
          <el-input
            v-model="queryTaskParams.taskName"
            placeholder="请输入任务名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="任务类型" prop="taskType">
          <el-select v-model="queryTaskParams.taskType" clearable placeholder="任务类型" @change="onInput()" >
            <el-option
              v-for="item in taskTypeOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="显示周期" prop="displayCycle">
          <el-select v-model="queryTaskParams.displayCycle" clearable placeholder="显示周期" @change="onInput()">
            <el-option
              v-for="item in displayCycleOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="流程类型" prop="processKey">
          <el-select v-model="queryTaskParams.processKey" clearable placeholder="流程类型" style="width: 178px;" @change="onInput()">
            <el-option
              v-for="item in listModeler"
              :key="item.key"
              :label="item.name"
              :value="item.key">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleTaskQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetTaskQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="taskList" @selection-change="handleSelectionChange">
        <el-table-column label="任务编号" align="center" prop="taskCode" width="90" />
        <el-table-column label="任务名称" align="center" prop="taskName"  :show-overflow-tooltip="true"  />
        <el-table-column label="任务类型" align="center" prop="taskType" width="80" >
          <template slot-scope="scope">
            <span>{{taskTypeFormat(scope.row,scope.column)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="流程类型" align="center" prop="processName" width="160" :show-overflow-tooltip="true" />
        <el-table-column label="是否必填" align="center" prop="isMust" width="80">
          <template slot-scope="scope">
            <span>{{isMustFormat(scope.row,scope.column)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="显示周期" align="center" prop="displayCycle" width="120" >
          <template slot-scope="scope">
            <span>{{displayCycleFormat(scope.row,scope.column)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="是否有效" align="center" prop="isValid" width="90" >
          <template slot-scope="scope">
            <span>{{isValidFormat(scope.row,scope.column)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="创建人" align="center" prop="createBy" width="140"/>
        <el-table-column label="创建时间" align="center" prop="createTime" width="150" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
          <template slot-scope="scope">
            <el-button
              type="text"
              icon="el-icon-plus"
              size="mini"
              @click="handleTaskAdd(scope.row)"
            >添加</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="previewFn(scope.row)"
              v-show="scope.row.taskType != '2'"
            >预览</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="Tasktotal>0"
        :total="Tasktotal"
        :page.sync="queryTaskParams.pageNum"
        :limit.sync="queryTaskParams.pageSize"
        @pagination="getTaskList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="taskOpen=false">关 闭</el-button>
      </div>
    </el-dialog>
    <el-dialog title="预览" :visible.sync="preview" width="60%" append-to-body>
      <el-form class="previewFormItem" :model="item" label-width="110px" v-for="(item,index) in previewForm" :key="index">
        <el-form-item>
          <div>
            <span class="font-red" v-if="item.isMust == 0">*</span>{{item.collectionName}}
            <icon :answerType="item.answerType"></icon>
          </div>
        </el-form-item>
        <el-form-item label="" v-show="item.answerType == 'dx'">
          <!--          <radio :radioValF="item.answer" :index="index" :radioOptions="item.collectionOptionList" @radioFn="radioFn"></radio>-->
          <el-radio-group v-model="item.values">
            <el-radio :label="itemc.collectionOptionId" v-for="itemc in item.collectionOptionList" :key="itemc.collectionOptionId">{{itemc.collectionOption}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <div v-show="item.answerType == 'dx'">
          <div v-for="childItem  in item.collectionOptionList" style="padding-left: 40px">
            <div v-show="childItem.collectionOptionId == item.values">
              <div v-for="itemT  in childItem.collectionItems">
                <el-form-item>
                  <div>
                    <span class="font-red" v-if="itemT.isMust == 0">*</span>{{itemT.collectionName}}
                    <icon :answerType="itemT.answerType"></icon>
                  </div>
                </el-form-item>
                <el-form-item label="" v-show="itemT.answerType == 'dx'">
                  <!--              <radio :radioValF="itemT.answer" :radioOptions="itemT.collectionOptionList"></radio>-->
                  <el-radio-group v-model="itemT.values">
                    <el-radio :label="itemTS.collectionOptionId" v-for="itemTS in itemT.collectionOptionList" :key="itemTS.collectionOptionId">{{itemTS.collectionOption}}</el-radio>
                  </el-radio-group>
                </el-form-item>
                <div v-show="itemT.answerType == 'dx'">
                  <div v-for="childItemT  in itemT.collectionOptionList" style="padding-left: 80px">
                    <div v-show="childItemT.collectionOptionId == itemT.values">
                      <div v-for="itemTT  in childItemT.collectionItems">
                        <el-form-item>
                          <div>
                            <span class="font-red" v-if="itemTT.isMust == 0">*</span>{{itemTT.collectionName}}
                            <icon :answerType="itemTT.answerType"></icon>
                          </div>
                        </el-form-item>
                        <el-form-item label="" v-show="itemTT.answerType == 'dx'">
                          <radio :radioValF="itemTT.answer" :radioOptions="itemTT.collectionOptionList"></radio>
                        </el-form-item>
                        <el-form-item v-show="itemTT.answerType == 'duox'">
                          <checkbox :checkboxValF="itemTT.answer" :checkboxOptions="itemTT.collectionOptionList"></checkbox>
                        </el-form-item>
                        <el-form-item class="mobile-input" v-if="itemTT.answerType == 'wb' || itemTT.answerType == 'sz'||itemTT.answerType == 'tel'||itemTT.answerType == 'date'">
                          <div v-if="itemTT.collectionOptionList.length>0">
                            <el-input size="mini" disabled v-model="itemTT.collectionOptionList[0].collectionOption"
                                      type="textarea" :rows="10"  resize="none"/>
                          </div>
                        </el-form-item>
                      </div>
                    </div>
                  </div>
                </div>
                <el-form-item v-show="itemT.answerType == 'duox'">
                  <checkbox :checkboxValF="itemT.answer" :checkboxOptions="itemT.collectionOptionList"></checkbox>
                </el-form-item>
                <el-form-item class="mobile-input" v-if="itemT.answerType == 'wb' || itemT.answerType == 'sz'||itemT.answerType == 'tel'||itemT.answerType == 'date'">
                  <div v-if="itemT.collectionOptionList.length>0">
                    <el-input size="mini" disabled v-model="itemT.collectionOptionList[0].collectionOption"
                              type="textarea" :rows="10"  resize="none"/>
                  </div>
                </el-form-item>
              </div>
            </div>
          </div>
        </div>
        <el-form-item v-show="item.answerType == 'duox'">
          <checkbox :checkboxValF="item.answer" :checkboxOptions="item.collectionOptionList"></checkbox>
        </el-form-item>
        <el-form-item class="mobile-input" v-if="item.answerType == 'wb' || item.answerType == 'sz'||item.answerType == 'tel'||item.answerType == 'date'">
          <div v-if="item.collectionOptionList.length>0">
            <el-input size="mini" disabled v-model="item.collectionOptionList[0].collectionOption"
                      type="textarea" :rows="10"  resize="none"/>
          </div>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { listTaskInstance, getTaskInstance, delTaskInstance, addTaskInstance, updateTaskInstance } from "@/api/sfa/taskInstance";
import tree from "@/views/components/sfa/treeselectParent2";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Treeselect from "@riophae/vue-treeselect";
import user from "@/views/components/sfa/userz";
import {treeselect} from "@/api/system/dept";
import {getTask, listTask} from "@/api/sfa/task";
import {listModeler} from "@/api/activiti/modeler";
export default {
  name: "TaskInstance",
  components: { tree,Treeselect},
  data() {
    return {
      // 遮罩层
      loading: true,
      Taskloading: true,
      // 选中数组
      ids: [],
      taskList: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      Tasktotal: 0,
      // 任务和审批流程一对多关系表格数据
      taskInstanceList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        taskId: null,
        taskName: null,
        instanceId: null,
        processKey: null,
        instanceName: null,
        deptId: null,
        deptLevel: null,
        deptCode: null,
        deptName: null,
      },
      queryTaskParams: {
        pageNum: 1,
        pageSize: 10,
        taskId: null,
        taskName: null,
        instanceId: null,
        processKey: null,
        instanceName: null,
        deptId: null,
        deptLevel: null,
        deptCode: null,
        deptName: null,
      },
      taskTypeOptions:[
        {
          dictLabel: "常规类型",
          dictValue: "1"
        },
        {
          dictLabel: "产品类型",
          dictValue: "2"
        },
        {
          dictLabel: "物料类型",
          dictValue: "3"
        },
      ],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        taskName: [
          { required: true, message: "任务名称不能为空", trigger: "change" }
        ],
        processKey: [
          { required: true, message: "流程key不能为空", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "部门不能为空", trigger: "change" }
        ]
      },
      tcfxOptions:[],
      deptOptions:[],
      displayCycleOptions:[],
      isNotOptions:[],
      collectionTypeOptions:[],
      answerTypeOptions:[],
      photoTypeOptions:[],
      level1Options:[],
      brandIdOptions:[],
      taskOpen:false,
      preview: false,
      listModeler:[],
      previewForm:[],
    };
  },
  created() {
    this.getList();
    this.getDicts("dept_level").then(response => {
      this.tcfxOptions = response.data;
    });
    // 显示周期
    this.getDicts("sfa_task_display_cycle").then(response => {
      this.displayCycleOptions = response.data;
    });
    // 是否
    this.getDicts("is_not").then(response => {
      this.isNotOptions = response.data;
    });
    // 采集项类型
    this.getDicts("sfa_collection_type").then(response => {
      this.collectionTypeOptions = response.data;
    });
    // 回答类型
    this.getDicts("sfa_collection_answer_type").then(response => {
      this.answerTypeOptions = response.data;
    });
    // 照片类型
    this.getDicts("sfa_task_photo_type").then(response => {
      this.photoTypeOptions = response.data;
    });
    // 层次一
    this.getDicts("sfa_level1").then(response => {
      this.level1Options = response.data;
    });
    // 品牌
    this.getDicts("sfa_product_brand").then(response => {
      this.brandIdOptions = response.data;
    });
    this.getTreeselect()
    this.getListModeler()
  },
  methods: {
    previewFn(row){
      this.previewForm = [];
      getTask(row.taskId).then(response => {
        console.log(response)
        this.previewForm = response.data.collectionItemList;
        this.preview = true;
      });
    },
    handleTaskAdd(val){
      this.form.taskId=val.taskId
      this.form.taskName=val.taskName
      this.taskOpen=false
    },
    getListModeler(){
      listModeler().then(response=>{
        this.listModeler=response.rows
      })
    },
    getTaskList() {
      this.Taskloading = true;
      listTask(this.queryTaskParams).then(response => {
        this.taskList = response.rows;
        this.Tasktotal = response.total;
        this.Taskloading = false;
      });
    },
    onInput(){
      this.$forceUpdate();
    },
    // 任务类型转换
    taskTypeFormat(row, column){
      return this.selectDictLabel(this.taskTypeOptions, row.taskType);
    },
    // 是否必填中文转换
    isMustFormat(row, column){
      if(row.isMust==1){
        return "否"
      }else{
        return  "是"
      }
    },
    // 是否有效中文转换
    isValidFormat(row, column){
      return this.selectDictLabel(this.isNotOptions, row.isValid);
    },
    // 任务周期
    displayCycleFormat(row, column){
      return this.selectDictLabel(this.displayCycleOptions, row.displayCycle);
    },
    // 采集项类型中文转换
    collectionTypeFormat(row, column){
      return this.selectDictLabel(this.collectionTypeOptions, row.collectionType);
    },
    // 回答类型中文转换
    answerTypeFormat(row, column){
      return this.selectDictLabel(this.answerTypeOptions, row.answerType);
    },
    // 层次一中文转换
    level1Format(row, column){
      return this.selectDictLabel(this.level1Options, row.level1);
    },
    // 品牌中文转换
    brandIdFormat(row, column){
      return this.selectDictLabel(this.brandIdOptions, row.brandCode);
    },
    taskOpenFn(){
      this.taskOpen=true
      this.resetTaskQuery()
      this.title="任务列表"
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    treeselectFn(val){
      this.orgIds = val;
    },
    storeCategoryFormatter(row,column){
      return this.selectDictLabel(this.tcfxOptions, row.deptLevel);
    },
    /** 查询任务和审批流程一对多关系列表 */
    getList() {
      this.loading = true;
      listTaskInstance(this.queryParams).then(response => {
        this.taskInstanceList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        taskInstanceId: null,
        taskId: null,
        taskName: null,
        instanceId: null,
        processKey: null,
        instanceName: null,
        deptId: null,
        deptLevel: null,
        deptCode: null,
        deptName: null,
        delFlag: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if(this.queryParams.processKey!=null){
        this.queryParams.processKey = this.queryParams.processKey.trim();
      }
      if(this.queryParams.instanceName!=null){
        this.queryParams.instanceName = this.queryParams.processKey.trim();
      }
      if(this.queryParams.taskName!=null){
        this.queryParams.taskName = this.queryParams.taskName.trim();
      }
      this.queryParams.deptIds = this.orgIds;
      this.getList();
    },
    handleTaskQuery() {
      this.queryTaskParams.pageNum = 1;
      if(this.queryTaskParams.taskName!=null){
        this.queryTaskParams.taskName = this.queryTaskParams.taskName.trim();
      }
      this.getTaskList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    resetTaskQuery() {
      this.resetForm("queryForm");
      this.handleTaskQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.taskInstanceId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加任务和审批流程一对多关系";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const taskInstanceId = row.taskInstanceId || this.ids
      getTaskInstance(taskInstanceId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改任务和审批流程一对多关系";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.taskInstanceId != null) {
            updateTaskInstance(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTaskInstance(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const taskInstanceIds = row.taskInstanceId || this.ids;
      this.$modal.confirm('是否确认删除任务和审批流程一对多关系编号为"' + taskInstanceIds + '"的数据项？').then(function() {
        return delTaskInstance(taskInstanceIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sfa/taskInstance/export', {
        ...this.queryParams
      }, `taskInstance_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
