<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="main">
      <div class="thetable">
        <div class="fontTitle"> {{'在线签呈'}}</div>
        <div class="titleflex">
          <div>{{'编号'}} :{{ qcData.businessNo }}</div>
          <div>
            <el-radio-group v-model="memberPetitionVo.signType">
              <el-radio
                :label="item.value"
                v-for="item in checkList"
                :key="item.value"
                >{{ item.label }}</el-radio
              >
            </el-radio-group>
          </div>
        </div>
        <table id="tfhover" class="tftable" border="1">
          <tr>
            <td colspan="1" width="190px" align="center"> {{'发起部门'}} :</td>
            <td colspan="1" width="435px">{{ qcData.deptStr }}</td>
            <td colspan="1" width="140px" align="center"> {{'发起人'}} :</td>
            <td colspan="1">{{ qcData.sponsorName }}</td>
          </tr>
          <tr>
            <td colspan="1" align="center"> {{'主旨'}} :</td>
            <td colspan="1">冻结</td>
            <td colspan="1" align="center"> {{'日期'}} :</td>
            <td colspan="1">{{ qcData.creationDate }}</td>
          </tr>
          <!-- // 审批流程 -->
          <tr>
            <td colspan="1" align="center"> {{'审批流程'}}</td>
            <td colspan="3">
              <div class="disflex">
                <span
                  v-for="(ctem, cndex) in memberPetitionVo.userIdList"
                  :key="cndex"
                  style="margin: 0 5px 5px 0"
                >
                  <el-select
                    v-model="memberPetitionVo.userIdList[cndex]"
                    filterable
                    size="mini"
                    @change="getApprover"
                    :placeholder="'请选择'"
                  >
                    <el-option
                      v-for="item in approbalList"
                      :key="item.userId"
                      :label="item.nickName + '(' + item.deptName + ')'"
                      :value="item.userId"
                    >
                    </el-option>
                  </el-select>
                </span>
                <span style="margin: 0 5px 5px 0">
                  <i
                    class="el-icon-remove-outline"
                    @click.stop="delData"
                    style="font-size: 18px; margin-right: 5px"
                  ></i>
                  <i
                    class="el-icon-circle-plus-outline"
                    style="font-size: 18px"
                    @click.stop="addData"
                  ></i>
                </span>
              </div>
            </td>
          </tr>
          <tr>
            <td colspan="1" align="center">抄送部门</td>
            <td colspan="3">
              <!-- <span
                style="margin-right: 20px"
                v-for="(item, index) in qcData.deptList"
                :key="index"
                >{{ item }}</span
              > -->
              <div class="disflex">
                <span
                  v-for="(ctem, cndex) in memberPetitionVo.sendIdList"
                  :key="cndex"
                  style="margin: 0 5px 5px 0"
                >
                  <el-select
                    v-model="memberPetitionVo.sendIdList[cndex]"
                    filterable
                    size="mini"
                    @change="getApprover2"
                    :placeholder="'请选择'"
                  >
                    <el-option
                      v-for="item in userAllList"
                      :key="item.userId"
                      :label="item.nickName + '(' + item.deptName + ')'"
                      :value="item.userId"
                    >
                    </el-option>
                  </el-select>
                </span>
                <span style="margin: 0 5px 5px 0">
                  <i
                    class="el-icon-remove-outline"
                    @click.stop="delData2"
                    style="font-size: 18px; margin-right: 5px"
                  ></i>
                  <i
                    class="el-icon-circle-plus-outline"
                    style="font-size: 18px"
                    @click.stop="addData2"
                  ></i>
                </span>
              </div>
            </td>
          </tr>
          <tr>
            <td style="height: 190px" align="center">{{'情况说明'}}</td>
            <td colspan="3" style="padding: 0">
              <div >
                <el-input
                  type="textarea"
                  :rows="6"
                  :placeholder="'请输入'"
                  v-model="memberPetitionVo.description"
                >
                </el-input>
              </div>
            </td>
          </tr>
          <tr>
            <td style="height: 193px" align="center"> {{'业务诉求'}}</td>
            <td colspan="3" style="padding: 0;vertical-align: top;">
              <div >
                <el-table
                  :data="qcData.memberFrozenAmountVOList"
                  style="width: 100%"
                  :header-cell-style="{ background: '#EEEEEE' }"
                >
                  <el-table-column
                    align="center"
                    prop="memberCode"
                    :label="'会员编号'"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="memberName"
                    :label="'会员姓名'"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="pkAccountVal"
                    :label="'账户类型'"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="lockConsume"
                    :label="`禁止消费(${getUser.currency.symbol}))`"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="lockTransfer"
                    :label="`禁止转账(${getUser.currency.symbol}))`"
                  >
                  </el-table-column>
                  <el-table-column
                    align="center"
                    prop="lockWithdraw"
                    :label="`${'禁止提现'}(${getUser.currency.symbol}))`"
                  >
                  </el-table-column>
                  <el-table-column align="center" prop="remarks" :label="'备注'">
                  </el-table-column>
                </el-table>
              </div>
            </td>
          </tr>
          <!-- <tr>
            <td align="center" style="height: 108px">部门意见</td>
            <td colspan="3">
              <div class="spbox">
                <div>审批状态：</div>
                <div style="margin-right: 20px">
                  <el-select clearable v-model="ywsq" :placeholder="'请选择'">
                    <el-option
                      v-for="item in ywsqList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </div>

                <div> {{'日期'}} :：</div>
              </div>
            </td>
          </tr> -->
        </table>
      </div>
    </div>
    <div class="footer">
      <div style="margin: 0 auto">
        <el-button class="thebtn" @click="cancelCz"> {{ '取消' }}</el-button>
        <el-button type="primary" class="thebtn" @click="saveDate"
          > {{ '确认' }}</el-button
        >
      </div>
    </div>
  </div>
</template>

  <script>
import topBar from "@/components/topBar";
import { batchFozenAmout, fozenAmout } from "@/api/financial";
import { getUserAll } from "@/api/signing";
import * as man from "@/api/manage";
import { mapGetters } from 'vuex'
export default {
  name: "Zxqc",
  components: {
    topBar,
  },
  computed: {
    ...mapGetters(['getUser']),
  },
  data() {
    return {
      moren: "djzxqc",
      topList: [
        {
          name: '基础业务',
          path: "jcyw",
        },
        {
          name: '订单业务',
          path: "ddyw",
        },
        {
          name: "确认业务",
          path: "shyw",
        },
        {
          name: "在线签呈",
          path: "djzxqc",
        },
      ],
      checked: [],
      checkList: [

      ],
      ywsq: "",
      ywsqList: [
        { value: "0", label: "同意" },
        { value: "1", label: "驳回" },
      ],
      qcData: {},
      memberPetitionVo: {
        businessNo: "",
        signType: 1,
        description: "",
        memberFrozenAmountVOList: [],
        czlx: "",
        userIdList: [],
        sendIdList:[]
      },
      approbalList: [],
      userAllList: [],
    };
  },
  created() {
    let data2 = JSON.parse(this.$route.query.data);
    this.qcData = data2;
    this.memberPetitionVo.userIdList = [""];
    this.memberPetitionVo.sendIdList = [""];
    this.czlx = this.$route.query.czlx;
    this.getSignType();
  },
  methods: {
    getSignType() {
      man.signType().then((res) => {
        this.checkList = res.data;
      });
      // 审批流程
      man.approvalUser().then((res) => {
        this.approbalList = res.data;
      });
      //抄送部门
      getUserAll().then((res) => {
        this.userAllList = res.data;
      });
    },
    // 审批流程
    getApprover() {
      this.$nextTick(() => {
        this.$forceUpdate();
      });
    },
    // 审批流程
    addData() {
      let arr = JSON.parse(JSON.stringify(this.memberPetitionVo.userIdList));
      arr.push("");
      this.$set(this.memberPetitionVo, "userIdList", arr);
      this.$forceUpdate();
    },
    // 审批流程
    delData() {
      this.memberPetitionVo.userIdList.pop();
      this.$forceUpdate();
    },
     // 抄送部门
     getApprover2() {
      this.$nextTick(() => {
        this.$forceUpdate();
      });
    },
    // 抄送部门
    addData2() {
      let arr2 = JSON.parse(JSON.stringify(this.memberPetitionVo.sendIdList));
      arr2.push("");
      this.$set(this.memberPetitionVo, "sendIdList", arr2);
      this.$forceUpdate();
    },
    // 抄送部门
    delData2() {
      this.memberPetitionVo.sendIdList.pop();
      this.$forceUpdate();
    },
    saveDate() {
      this.memberPetitionVo.memberFrozenAmountVOList =
        this.qcData.memberFrozenAmountVOList;
      this.memberPetitionVo.businessNo = this.qcData.businessNo;
      let url = "";
      if (this.czlx == 1) {
        url = fozenAmout;
      } else if (this.czlx == 2) {
        url = batchFozenAmout;
      }
      url(
        Object.assign(
          { memberPetitionVo: this.memberPetitionVo },
          JSON.parse(this.$route.query.rechargeData)
        )
      ).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: res.msg,
            type: "success",
          });
          this.$router.push({
            name: "FreezeDetail",
          });
        }
      });
    },
    cancelCz() {
      this.$router.go(-1);
    },
    findQcDetail() {
      findQcDetail(this.$route.query.pkId).then((res) => {
        this.qcList = res.data;
      });
    },
  },
};
</script>

  <style lang="scss" scoped>
::v-deep .el-table thead {
  color: #000000;
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    // margin-top: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    display: flex;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
  }
  .thetable {
    margin: 0 auto;
    .fontTitle {
      font-weight: bold;
      font-size: 24px;
      text-align: center;
    }
    .titleflex {
      display: flex;
      margin-top: 10px;
      margin-bottom: 10px;
      justify-content: space-between;
    }
  }
  .tftable {
    font-size: 14px;
    border-collapse: collapse;
    border-radius: 10px;
    width: 1060px;
    border: 1px solid #cccccc;
    .spbox {
      display: flex;
      align-items: center;
      justify-content: flex-end;
    }
    th {
      font-size: 14px;
      // padding: 20px;
    }
    tr td {
      font-size: 14px;
      padding: 10px 20px;
      height: 60px;
    }
  }
  .footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    .thebtn {
      width: 120px;
      height: 38px;
    }
  }
}
</style>
