<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input
        :size="sizeType"
        v-model="search.printBillCode"
        placeholder="施工单号"
        style="width: 200px;"
        class="filter-item"/>
      <el-input :size="sizeType" v-model="search.spliceManName" placeholder="拼版人" style="width: 200px;"
                class="filter-item"/>
      <el-input :size="sizeType" v-model="search.keyWord" placeholder="关键字" style="width: 200px;" class="filter-item"/>
      <el-select :size="sizeType" v-model="search.taskState">
        <el-option
          v-for="item in stateOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"></el-option>
      </el-select>
      <!--      <el-date-picker-->
      <!--        :size="sizeType"-->
      <!--        v-model="searchTime"-->
      <!--        type="daterange"-->
      <!--        range-separator="-"-->
      <!--        start-placeholder="开始日期"-->
      <!--        end-placeholder="结束日期"-->
      <!--        value-format="yyyy-MM-dd HH:mm:ss"-->
      <!--        :default-time="['00:00:00', '23:59:59']">-->
      <!--      </el-date-picker>-->
      <el-button :size="sizeType" class="filter-item" type="primary" icon="el-icon-search" @click="searchData">
        搜索
      </el-button>

      <!--      <el-button size="mini" class="filter-item" type="primary" icon="el-icon-search" @click="designerBtn">-->
      <!--        人员排序-->
      <!--      </el-button>-->
      <div class="top-right-btn">
        <el-tooltip class="item" effect="dark" content="刷新" placement="top">
          <el-button size="mini" circle icon="el-icon-refresh" @click="getList"/>
        </el-tooltip>
      </div>
      <br><br>
      <el-button
        size="mini"
        class="filter-item"
        type="success"
        @click="onMultiAssignClick">
        批量分配
      </el-button>
      <el-tag>共勾选了 {{ selectedBreedSum }} 套版</el-tag>
    </div>
    <el-table
      size="mini"
      :data="tableData"
      v-loading="listLoading"
      max-height="320px"
      row-key="id"
      border
      style="margin-top: 10px"
      ref="orderTable"
      @row-click="handleClickTableRow"
      @selection-change="onTableSelectionChange"
      :row-class-name="tableRowClassName"
      default-expand-all>
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column
        label="序号"
        fixed
        align="center"
        width="50"
        type="index">
        <template v-slot="scope">
          <span>{{ (listData.page - 1) * listData.pageSize + scope.$index + 1 }}</span>
        </template>
      </el-table-column>

      <el-table-column
        fixed
        label="操作"
        align="center"
        width="160">
        <template v-slot="{row}">
          <el-button
            v-if="row.taskStatus === 0"
            @click="handleDispatch(row)"
            type="primary"
            :size="sizeType">
            分配
          </el-button>
          <el-button
            v-if="row.taskStatus == 0"
            @click="backDispatch(row)"
            type="danger"
            :size="sizeType">
            组长退回
          </el-button>
          <el-button
            v-if="row.taskStatus == 3"
            @click="completeVerify(row)"
            type="primary"
            :size="sizeType">
            审完
          </el-button>
          <el-button
            v-if="row.taskStatus == 3"
            @click="backVerify(row)"
            type="danger"
            :size="sizeType">
            审退
          </el-button>
        </template>
      </el-table-column>
      <el-table-column
        prop="printBillCode"
        label="施工单编号"
        width="130">
        <template v-slot="{row}">
                    <span @click.stop="getPrintStep(row.idPrintBill)"
                          style="color: #409EFF;cursor: pointer" v-html="row.printBillCode"></span>
          <el-image v-if="row.importantBill == 1" :src="new_badge"></el-image>
        </template>
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="productName"
        label="产品类型"
        width="110">
        <template v-slot="{row}">
          <span @click.stop="handleDetail(row.idPrintBill)" style="color: #409EFF;cursor: pointer;"> {{
              row.productName
            }}</span>
        </template>
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="customerName"
        label="客户名称"
        width="110">
        <template v-slot="{row}">
          <span>{{
              row.customerName
            }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column-->
      <!--        prop="printBillName"-->
      <!--        label="印品名称"-->
      <!--        width="150">-->
      <!--      </el-table-column>-->
      <el-table-column
        prop="breedCount"
        label="版套数"
        width="60">
      </el-table-column>

      <el-table-column
        show-overflow-tooltip
        prop="assignManName"
        label="分配人"
        width="100">
      </el-table-column>
      <el-table-column
        prop="spliceManName"
        label="拼版人">
      </el-table-column>
      <el-table-column
        label="状态">
        <template v-slot="{row}">
          <template v-if="row.pauseStatus === 0">
            <el-tag size="mini" v-if="row.taskStatus == 0">未分配</el-tag>
            <el-tag size="mini" v-else-if="row.taskStatus == 1">已分配</el-tag>
            <el-tag size="mini" v-else-if="row.taskStatus == 2">拼版中</el-tag>
            <el-tag size="mini" v-else-if="row.taskStatus == 3">待审稿</el-tag>
            <el-tag size="mini" v-else-if="row.taskStatus == 10">已完成</el-tag>
            <el-tag size="mini" v-else-if="row.taskStatus == 11">已退回</el-tag>
          </template>
          <template v-else-if="row.pauseStatus === 1">
            <el-tag size="mini" type="warning">暂停</el-tag>
          </template>
        </template>
      </el-table-column>
      <el-table-column
        prop="pauseMemo"
        label="暂停备注"
        show-overflow-tooltip
        width="150">
      </el-table-column>
      <el-table-column
        prop="backReason"
        width="100"
        show-overflow-tooltip
        label="退回原因">
      </el-table-column>
      <el-table-column
        prop="assembleBreedRequire"
        label="出版备注"
        show-overflow-tooltip
        width="100">
      </el-table-column>
      <el-table-column
        label="施工单消息"
        width="180px"
        show-overflow-tooltip
      >
        <template v-slot="{row}">
          <template v-if="row.printBillMsg">
            <el-button size="mini" icon="el-icon-plus" @click.stop="openMessage(row)"></el-button>
            <span
              style="color: #20a0ff; cursor: pointer"
              @click.stop="openMessage(row)"> {{ row.printBillMsg }}</span>
          </template>
          <template v-else>
            <el-button size="mini" icon="el-icon-plus" @click.stop="openMessage(row)"></el-button>
          </template>
        </template>
      </el-table-column>
      <el-table-column
        prop="billNote"
        label="施工单备注"
        show-overflow-tooltip
        width="150">
      </el-table-column>
      <el-table-column
        prop="deliveryDate"
        label="施工单交货期"
        width="150">
      </el-table-column>


      <el-table-column
        width="125"
        label="分配时间">
        <template v-slot="{row}">
          <span v-if="row.assignTimeLong"> {{ row.assignTimeLong | getLongTime }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="listData.total>0"
      :total="listData.total"
      :page.sync="listData.page"
      :limit.sync="listData.pageSize"
      @pagination="getList"/>
    <div class="sortTable-con" style="margin-top: 20px">
      <div
        size="mini"
        v-for="(item,index) in tableDataSpliceMan"
        :key="item.id"
        class="item-badge">
        <div style="position: relative;">
          <!--          <el-button-group style="width: 160px">-->
          <el-button style="padding-bottom: 8px; width: 160px" size="mini" :plain="checkId!=item.id"
                     @click="handleClick(index,item.id)" type="success">
            <span style="display: block;width: 130px" class="ellipsis">{{ item.userName }}({{
                item.workInCount
              }})</span>
          </el-button>
          <!--            <el-button size="mini" @click="handleClickBtn(index,item.id)" :plain="checkId!=item.id" type="success"><i-->
          <!--              class="el-icon-arrow-down"></i>-->
          <!--            </el-button>-->
          <!--          </el-button-group>-->
          <!--          <el-button @click="relaxBtn(index,item.id)" type="danger" plain-->
          <!--                     style="position: absolute;left: 75px;top: 28px;z-index: 999;cursor: pointer" size="mini"-->
          <!--                     v-show="checkIdBtn==item.id">停止接单-->
          <!--          </el-button>-->
        </div>
      </div>
    </div>
    <div v-if="spliceTaskList.length>0" style="margin-top: 15px">
      <el-table
        size="mini"
        :data="spliceTaskList"
        v-loading="listLoadingOrder"
        max-height="320px"
        row-key="id"
        border
        style="margin-top: 10px"
        ref="spliceTable"
        default-expand-all>
        <el-table-column
          label="序号"
          fixed
          align="center"
          width="50"
          type="index">
          <template v-slot="scope">
            <span>{{ (listDataTask.page - 1) * listDataTask.pageSize + scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="printBillCode"
          label="施工单编号"
          width="130">
          <template v-slot="{row}">
                    <span @click.stop="getPrintStep(row.idPrintBill)"
                          style="color: #409EFF;cursor: pointer" v-html="row.printBillCode"></span>
            <el-image v-if="row.importantBill == 1" :src="new_badge"></el-image>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          prop="productName"
          label="产品类型"
          width="110">
          <template v-slot="{row}">
            <span @click.stop="handleDetail(row.idPrintBill)" style="color: #409EFF;cursor: pointer;"> {{
                row.productName
              }}</span>
          </template>
        </el-table-column>
        <!--        <el-table-column-->
        <!--          prop="printBillName"-->
        <!--          label="印品名称"-->
        <!--          width="150">-->
        <!--        </el-table-column>-->
        <el-table-column
          prop="breedCount"
          label="版套数"
          width="60">
        </el-table-column>

        <el-table-column
          show-overflow-tooltip
          prop="assignManName"
          label="分配人"
          width="100">
        </el-table-column>
        <el-table-column
          prop="spliceManName"
          label="拼版人">
        </el-table-column>
        <el-table-column
          label="状态">
          <template v-slot="{row}">
            <template v-if="row.pauseStatus === 0">
              <el-tag size="mini" v-if="row.taskStatus == 0">未分配</el-tag>
              <el-tag size="mini" v-else-if="row.taskStatus == 1">已分配</el-tag>
              <el-tag size="mini" v-else-if="row.taskStatus == 2">拼版中</el-tag>
              <el-tag size="mini" v-else-if="row.taskStatus == 3">待审稿</el-tag>
              <el-tag size="mini" v-else-if="row.taskStatus == 10">已完成</el-tag>
              <el-tag size="mini" v-else-if="row.taskStatus == 11">已退回</el-tag>
            </template>
            <template v-else-if="row.pauseStatus === 1">
              <el-tag size="mini" type="warning">暂停</el-tag>
            </template>
          </template>
        </el-table-column>
        <el-table-column
          prop="pauseMemo"
          label="暂停备注"
          show-overflow-tooltip
          width="150">
        </el-table-column>
        <el-table-column
          prop="backReason"
          width="100"
          show-overflow-tooltip
          label="退回原因">
        </el-table-column>
        <el-table-column
          prop="assembleBreedRequire"
          label="出版备注"
          show-overflow-tooltip
          width="100">
        </el-table-column>
        <el-table-column
          label="施工单消息"
          width="180px"
          show-overflow-tooltip
        >
          <template v-slot="{row}">
            <template v-if="row.printBillMsg">
              <el-button size="mini" icon="el-icon-plus" @click.stop="openMessage(row)"></el-button>
              <span
                style="color: #20a0ff; cursor: pointer"
                @click.stop="openMessage(row)"> {{ row.printBillMsg }}</span>
            </template>
            <template v-else>
              <el-button size="mini" icon="el-icon-plus" @click.stop="openMessage(row)"></el-button>
            </template>
          </template>
        </el-table-column>
        <el-table-column
          prop="billNote"
          label="施工单备注"
          show-overflow-tooltip
          width="150">
        </el-table-column>
        <el-table-column
          prop="deliveryDate"
          label="施工单交货期"
          width="150">
        </el-table-column>


        <el-table-column
          width="125"
          label="分配时间">
          <template v-slot="{row}">
            <span v-if="row.assignTimeLong"> {{ row.assignTimeLong | getLongTime }}</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="listDataTask.total>0"
        :total="listDataTask.total"
        :page.sync="listDataTask.page"
        :limit.sync="listDataTask.pageSize"
        @pagination="getSpliceManTaskList"/>
    </div>

    <el-dialog title="分配订单" :close-on-click-modal="false" :visible.sync="distributeDialog" width="800px">
      <el-table
        :data="tableDataSpliceMan"
        border
        v-loading="userListLoading">
        <el-table-column label="操作">
          <template v-slot="{row}">
            <el-button size="mini" type="primary" @click="chooseUser(row)">选择</el-button>
          </template>
        </el-table-column>
        <el-table-column label="用户名" prop="userName"></el-table-column>
        <!--        <el-table-column label="上班时间" prop="checkInTime">-->
        <!--          <template v-slot="{row}">-->
        <!--            <span v-if="row.checkInTime">{{ row.checkInTime | getLongTime }}</span>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <!--        <el-table-column label="工作状态" prop="checkInTime">-->
        <!--          <template v-slot="{row}">-->
        <!--            <el-tag v-if="row.workInState == 1" type="success">可接单</el-tag>-->
        <!--            <el-tag v-else-if="row.workInState == 2" type="danger">忙碌</el-tag>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column label="版套数" prop="workInCount">
        </el-table-column>
      </el-table>
      <pagination
        v-show="userListData.total>0"
        :total="userListData.total"
        :page.sync="userListData.page"
        :limit.sync="userListData.pageSize"
        @pagination="getSpliceManStateList"/>
    </el-dialog>
    <el-dialog title="退回" :close-on-click-modal="false" :visible.sync="backDialog" width="500px">
      <el-form label-width="80px" label-position="right">
        <el-form-item label="退回备注">
          <el-input type="textarea" v-model="backInfo.backReason"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="backDialog = false">取 消</el-button>
        <el-button type="primary" @click="checkBack">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="审稿退回" :close-on-click-modal="false" :visible.sync="proofBackDialog" width="500px">
      <el-form label-width="80px" label-position="right">
        <el-form-item label="退回备注">
          <el-input type="textarea" v-model="proofBackInfo.backReason"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="proofBackDialog = false">取 消</el-button>
        <el-button type="primary" @click="backProofSure">确 定</el-button>
      </div>
    </el-dialog>
    <cancledialog @tableRefresh="tableRefresh" ref="confirmDialog" :noDoubleClick="true"></cancledialog>

    <el-drawer
      title="施工单消息"
      :reverse="true"
      :visible.sync="memoDrawer"
      size="600px">
      <order-message @handleAddBreed="handleAddBreed" ref="orderMessage"></order-message>
    </el-drawer>
    <printbill-detail ref="printbillDetail"></printbill-detail>
    <print-step ref="printStep"></print-step>
  </div>
</template>

<script>
import {
  queryExclusiveTasks,
  getAllSpliceMan,
  getSpliceWorkState,
  assignExclusiveTask,
  backExclusiveTask,
  finalBackExclusiveTask,
  feedbackExclusiveTask, multiAssignExclusiveTask
} from '@/api/exclusiveSplice/dispatchOrder.js'
import PrintbillDetail from "@/components/printbillDetail/printbillDetail";
import printStep from "@/components/printbillDetail/printStep";
import OrderMessage from '@/views/feedBack/orderMessage/orderMessage'
import draggable from 'vuedraggable'
import Cancledialog from "@/components/Dialog/Cancledialog";
import new_badge from '@/assets/new_badge.gif'

export default {
  name: 'ExclusiveSpliceDispatch',
  components: {Cancledialog, PrintbillDetail, printStep, OrderMessage, draggable},
  data() {
    return {
      memoDrawer: false,
      rowData: {},
      checkIdBtn: "",
      new_badge: new_badge,
      printBillDetail: {},
      spliceTaskList: [],
      checkId: "",
      tableDataSpliceMan: [],
      sizeType: 'mini',
      search: {
        printBillCode: '',
        spliceManName: '',
        keyWord: '',
        taskState: 0,
        withBillMsg: 1
      },
      searchTime: [],

      tableData: [],
      listLoadingOrder: false,
      listLoading: false,
      listData: {
        total: 0,
        page: 1,
        pageSize: 20
      },
      listDataTask: {
        total: 0,
        page: 1,
        pageSize: 30
      },

      stateOptions: [
        {
          label: '未分配',
          value: 0
        },
        {
          label: '已分配',
          value: 1
        },
        {
          label: '拼版中',
          value: 2
        },
        {
          label: '待审稿',
          value: 3
        },
        {
          label: '已完成',
          value: 10
        },
        {
          label: '已退回',
          value: 11
        }
      ],
      chooseInfo: {
        id: 0,
        idPrintBill: '',
        breedCount: '',
        printBillCode: '',
        currentVersion: 0
      },
      distributeDialog: false,
      distributeType: 0,
      checkInUserList: [],
      userListLoading: false,
      userListData: {
        total: 0,
        page: 1,
        pageSize: 10
      },
      backDialog: false,
      backInfo: {
        id: 0,
        backReason: '',
        currentVersion: 0
      },
      selectItems: [],

      drawer: false,
      stepList: [],
      timeString: '',
      detailVisible: false,
      workKind: 0,

      proofBackDialog: false,
      proofBackInfo: {
        id: 0,
        backReason: '',
        currentVersion: 0
      },
    }
  },
  computed: {
    selectedBreedSum() {
      let sum = 0
      this.selectItems.forEach(x => {
        sum += x.breedCount
      })
      return sum
    }
  },
  created(){
    this.getSpliceManStateList();
    this.dataRefreh();
  },
  destroyed(){
    // 在页面销毁后，清除计时器
    this.clear();
  },
  mounted() {
    this.getList();
    // this.getWorkKind();
  },
  methods: {
    dataRefreh() {
      // 计时器正在进行中，退出函数
      const _that = this;
      if (_that.intervalId != null) {
        return;
      }
      // 计时器为空，操作
      _that.intervalId = setInterval(() => {
        // console.log("刷新" + _that.$route.path);
        if(_that.$route.path=="/exclusiveSplice/ExclusiveSpliceDispatch"){
          _that.getSpliceManStateList(); //加载数据函数
        }
      }, 5000);
    },
    // 停止定时器
    clear() {
      clearInterval(this.intervalId); //清除计时器
      this.intervalId = null; //设置为null
    },
    getPrintStep(id) {
      const _that = this;

      _that.$refs.printStep.idOrder = id;
      _that.$refs.printStep.drawer = true;
      _that.$refs.printStep.getStep();
    },
    handleDetail(id) {
      const _that = this;
      _that.$refs.printbillDetail.idOrder = id;
      _that.$refs.printbillDetail.printVisible = true;
      _that.$refs.printbillDetail.fullscreenLoading = true;
      _that.$refs.printbillDetail.getDetail()
    },
    handleAddBreed(breedMsg) {
      this.memoDrawer = false;
      this.rowData.breedMsg = breedMsg;
    },
    // 施工单消息
    openMessage(row) {
      var _that = this
      _that.memoDrawer = true;
      _that.rowData = row;
      _that.$nextTick(function () {
        // console.log(_that.$refs.orderMemo);
        _that.$refs.orderMessage.idOrder = row.idPrintBill;
        _that.$refs.orderMessage.idPrint = row.idPrintBill;
        _that.$refs.orderMessage.printBillId = row.idPrintBill;
        _that.$refs.orderMessage.sMessageForm = false;
        _that.$refs.orderMessage.sMessage = "";
        _that.$refs.orderMessage.getBillMessageListByPrintBill()
      })
    },
    handleClick(index, id) {
      const _that = this;
      _that.checkId = id;
      _that.checkIdBtn = "";
      _that.getSpliceManTaskList();
    },
    handleClickBtn(index, id) {
      const _that = this;
      _that.checkIdBtn = id;
    },
    getSpliceManTaskList() {
      const _that = this;
      _that.listLoadingOrder = true;
      var params = {
        idSpliceMan: _that.checkId,
        excludeTaskStates: '10,11,0',
        withBillMsg: 1
      }
      var page = {
        pageIndex: _that.listDataTask.page,
        pageSize: _that.listDataTask.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'page': JSON.stringify(page)
      }
      queryExclusiveTasks(data).then(response => {
        _that.listLoadingOrder = false;
        const data = response.data
        // //  组合表单数据
        _that.listDataTask.total = response.total
        _that.spliceTaskList = data;
        _that.listLoadingOrder = false;
      }).catch(err => {
        _that.$message.error(err);
      })
    },
    getSpliceManStateList() {
      const _that = this;
      var data = {}
      getAllSpliceMan(data).then(response => {
        const data = response.data
        // //  组合表单数据
        _that.tableDataSpliceMan = data;
        // _that.listData2.total = response.total
      }).catch(err => {
        _that.$message.error(err);
      })
    },
    getList() {
      var _that = this;
      _that.listLoading = true;
      // if (_that.searchTime == null || _that.searchTime < 0) {
      //   _that.search.dispatchBeginTime = ''
      //   _that.search.dispatchEndTime = ''
      // } else {
      //   _that.search.dispatchBeginTime = _that.searchTime[0]
      //   _that.search.dispatchEndTime = _that.searchTime[1]
      // }
      var params = _that.search
      var page = {
        pageIndex: _that.listData.page,
        pageSize: _that.listData.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'page': JSON.stringify(page)
      }
      if (_that.listData.pageSize == 10) {
        _that.sizeType = 'medium'
      } else {
        _that.sizeType = 'mini'
      }
      // console.log(data);
      queryExclusiveTasks(data).then(response => {
        // console.log(response)
        const data = response.data
        // //  组合表单数据
        _that.tableData = data
        _that.listData.total = response.total
        _that.listLoading = false
      }).catch(err => {
        _that.$message.error(err)
        _that.listLoading = false
      })
    },
    onTableSelectionChange(val) {
      this.selectItems = val
    },
    handleClickTableRow(row, column, event) {
      this.$refs.orderTable.toggleRowSelection(row)
    },
    onMultiAssignClick() {
      if(this.selectItems.length<=0){
        this.$message("请先勾选订单");
        return
      }
      this.distributeType = 1;
      this.distributeDialog = true;
    },
    // 搜索
    searchData() {
      this.listData.page = 1
      this.getList()
    },

    // 刷新
    tableRefresh() {
      this.getList()
    },

    // 获取脚印
    getOrderStep(row) {
      const _that = this
      _that.$refs.orderStep.idOrder = row.printOrder.id
      _that.$refs.orderStep.getOrderStep()
    },
    // 订单详情
    openDetail(row) {
      var _that = this
      _that.detailVisible = true
      _that.$nextTick(() => {
        _that.$refs.orderDetail.idOrder = row.id
        _that.$refs.orderDetail.getInfo()
      })
    },
    // 分配
    handleDispatch(row) {
      const _that = this
      _that.distributeDialog = true
      _that.distributeType = 2
      _that.chooseInfo.idPrintBill = row.idPrintBill
      _that.chooseInfo.breedCount = row.breedCount
      _that.chooseInfo.id = row.id
      _that.chooseInfo.printBillCode = row.printBillCode
      _that.chooseInfo.currentVersion = row.currentVersion
      // _that.getCheckInUser()
    },
    // getCheckInUser() {
    //   const _that = this
    //   var page = {
    //     pageIndex: _that.userListData.page,
    //     pageSize: _that.userListData.pageSize
    //   }
    //   var data = {
    //     // 'params': JSON.stringify(params),
    //     'page': JSON.stringify(page)
    //   }
    //   getAllCheckInUser(data).then(res => {
    //     console.log(res)
    //     _that.userListLoading = false
    //     _that.checkInUserList = res.data
    //     // _that.tableRefresh()
    //   }).catch(err => {
    //     _that.$message.error(err)
    //   })
    // },
    chooseUser(row) {
      const _that = this
      let data = null

      if (_that.distributeType === 1) {
        _that.selectItems.forEach(x => {
          x.idSpliceMan = row.id
        })
        data = JSON.stringify(_that.selectItems)
      } else if (_that.distributeType === 2) {
        const task = {
          'id': _that.chooseInfo.id,
          'idSpliceMan': row.id,
          'currentVersion': _that.chooseInfo.currentVersion
        }
        data = JSON.stringify([task])

      }

      // console.log(data);
      // return
      if (data) {
        multiAssignExclusiveTask(data).then(res => {
          console.log(res)
          if (res.httpCode === 200) {
            _that.distributeDialog = false
            _that.$message({
              message: '分配成功',
              type: 'success'
            })
            _that.chooseInfo = {
              id: 0,
              idPrintBill: '',
              breedCount: '',
              printBillCode: '',
              currentVersion: 0
            }
            _that.distributeType = 0
            _that.tableRefresh()
          } else {
            _that.$message.error(res.msg)
          }
        }).catch(err => {
          _that.$message.error(err)
        })
      }
    },

    // 退回
    backDispatch(row) {
      const _that = this
      // _that.backDialog = true
      _that.backInfo.id = row.id
      _that.backInfo.backReason = ''
      _that.backInfo.currentVersion = row.currentVersion

      _that.$confirm('确定组长退回？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        _that.checkBack()
      }).catch(() => {
      })
    },
    checkBack() {
      var _that = this
      var data = {
        task: _that.backInfo
      }
      finalBackExclusiveTask(data).then(response => {
        console.log(response)
        if (response.httpCode == 200) {
          _that.backDialog = false
          _that.$message({
            message: '退回成功',
            type: 'success'
          })
          _that.tableRefresh()
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },

    // 审稿完成
    completeVerify(row) {
      const _that = this
      const task = {
        id: row.id,
        taskStatus: 10,
        currentVersion: row.currentVersion
      };
      const data = {
        'task': task
      }
      const url = '/printbill/feedbackExclusiveTask';
      _that.$refs.confirmDialog.updataClick(data, url)
    },
    // 退回审稿
    backVerify(row) {
      const _that = this
      _that.proofBackDialog = true
      _that.proofBackInfo.id = row.id
      _that.proofBackInfo.backReason = ''
      _that.proofBackInfo.taskStatus = 1
      _that.proofBackInfo.currentVersion = row.currentVersion
    },
    backProofSure() {
      const _that = this
      const data = {
        task: _that.proofBackInfo
      }
      feedbackExclusiveTask(data).then(response => {
        console.log(response)
        if (response.httpCode === 200) {
          _that.proofBackDialog = false
          _that.$message({
            message: '退回成功',
            type: 'success'
          })
          _that.tableRefresh()
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    tableRowClassName({row, rowIndex}) {
      if ((row.idSpliceMan) && (row.taskStatus === 0)) {
        return 'backed-row'
      }
    }
  }
}
</script>

<style scoped>
.board-column-content {
  padding-top: 10px;
  height: 600px;
  overflow-y: auto;
  border: 10px solid transparent;
  display: flex;
  justify-content: flex-start;
  flex-direction: column;
  align-items: center;
  background-color: #EBEEF5;
}

.board-item {
  cursor: pointer;
  width: 100%;
  height: 34px;
  margin: 5px 0;
  background-color: #f6f6f6;
  text-align: left;
  line-height: 24px;
  padding: 5px 10px;
  box-sizing: border-box;
  box-shadow: 0px 1px 3px 0 rgba(0, 0, 0, 0.2);
}

.item-badge {
  display: inline-block;
  margin-right: 10px;
  margin-bottom: 10px;
}

::v-deep .el-table .backed-row {
  background: #f38686 !important;
  color: #fff !important;
}
</style>
