<template>
  <el-dialog
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      top="50px"
      width="50%"
  >
    <div class="tabsdom">
      <el-form ref="form" :model="form" :rules="1" style="width: 100%;padding: 5px">

        <el-col style="padding-bottom: 10px">
          <el-card shadow="always" style="padding: 15px 5px 5px 15px">
            <el-row style="margin-top: 25px">
              <el-col :span="2" class="col-txt">新委托人</el-col>
              <el-col :span="22">
                <user-select
                    :default-select="selectList"
                    :multiple="false"
                    width="700"
                    @selectValue="parentMethod"
                />
              </el-col>
            </el-row>

          </el-card>
        </el-col>

      </el-form>
    </div>
    <div slot="footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="confirmSubmit()">确 定</el-button>
    </div>
  </el-dialog>

</template>

<script>
import UserSelect from '@/views/components/UserSelect'
import Base from '@/views/base/base.vue'
import BaseData from '@/views/base/baseData.vue'
import {upload} from '@/static/utils/channel'

export default {
  name: 'ApplyPay',
  components: {
    UserSelect
  },
  mixins: [Base, BaseData],
  data() {
    return {
      dialogVisible: false,
      form: {},
      fileError: false,
      fileList: [],
      selectList: [],
      value1: [],
      ProjectData: [
        {name: '年假(剩余x天)', type: 'year'},
        {name: '事假(剩余x小时)', type: 'affair'},
        {name: '病假', type: 'illness'}
      ],
      dialogTitle: '请假申请',
    }
  },
  methods: {
    uploadFile(param) {
      upload(param, true).then((res) => {
        this.form.fileUrlList.push(res)
      })
    },
    parentMethod: function (val) {
      if (val.length > 0) {
        console.log(val)
        this.form.pushEntrustId = val.join(',')
      }
    },
    async setVisible(status, row) {

      this.form.flowMainPushId = row.flowMainPushId
      this.dialogVisible = status
    },
    async confirmSubmit() {

      if (!this.form.pushEntrustId || this.form.pushEntrustId.length == 0) return this.$message.warning("请选择新的委托人")
      const {data: data} = await this.baseRequest1('FlowMainController', 'entrustOperate', {...this.form})
      if (data.code == 200) {
        this.$message.success('委托人变更成功')
        this.dialogVisible = false
        this.$emit("getData")
      } else {
        this.$message.warning(data.msg)
      }
    },
    baseRequest1(prefix, opUrl, postData) {
      return this.$channel.globleRequest(prefix, opUrl, postData, 'project task')
    },
  }
}
</script>

<style lang="scss">
.ml5 {
  margin-left: 5px;
}

.tabsdom {
  .el-tabs__header {
    text-align: center !important;
    width: 139px !important;
    text-align: center !important;
    display: block !important;
    margin: auto !important;
    margin-bottom: 15px !important;
  }

  .el-tabs__nav-wrap::after {
    display: none;
  }

  .el-upload {
    width: 100%;
  }
}

</style>
