<template>
    <div class="reply" ref = "replyModal">
      <a-modal
        title="调整工资基数"
        width="25%"
        :visible="visible"
        :confirmLoading="loading"
        :getContainer ='()=>$refs.replyModal'
        @cancel="handleCancel"
        :closable="!loading"
        :maskClosable="!loading"
        destroyOnClose
       >
            <template #footer>
                <a-button  @click="handleCancel" :loading = "loading">取消</a-button>
                <a-button  @click="handleOk" type="primary" style="margin-left: 8px;" :loading = "loading">确认</a-button>
            </template>
            <div class="table-page-search-wrapper">
                <a-form-model layout="inline" ref="form" :model="formState"  :rules="validatorRules">
                    <a-row :gutter="24">
                        <a-col :md="24">
                            <a-form-model-item label="当前工资基数"  prop="totalNum"  :labelCol="{offset: 0}">
                                <a-input placeholder="请输入" v-model="formState.oldSalaryBase" disabled/>
                            </a-form-model-item>
                        </a-col>
                        <a-col :md="24" >
                            <a-form-model-item label="新工资基数"  prop="basicSalary" >
                                <a-input-number style="width: 100%;" placeholder="请输入" v-model="formState.basicSalary" />
                            </a-form-model-item>
                        </a-col>
                    </a-row>
                </a-form-model>
            </div>
      </a-modal>
    </div>
</template>
<script>
    
      import moment from 'moment'
      import pick from 'lodash.pick'
      import { FormTypes } from '@/utils/JEditableTableUtil'
      import { putAction,getAction } from '@/api/manage'
      export default {
        name: 'ChangeSalaryBase',
        components: {
            moment,
        },
        data() {
          return {
              formState:{},
              visible:false,
              loading:false, 
              validatorRules: {
                basicSalary: [{required: true, message: '请输入!' }],
              },           
          }
        },
        created(){
        },
        watch: {
        },
        methods: {
            handleCancel(){
                this.visible = false
                this.formState={}
            },
            handleOk(){
                this.$refs.form.validate(valid => {
                    if (valid) {
                        this.loading = true
                        getAction('/salary/salaryChangeRecord/insertSalaryBasicSalaryRecord', {basicSalary:this.formState.basicSalary}).then((res) => {
                            if (res.success) {
                                this.$message.success(res.message);
                                this.handleCancel()
                                this.$emit('ok')
                            } else {
                                this.$message.error(res.message);
                            }
                        }).finally(() => {
                            this.loading = false
                        })
                    }
                })   
            },
           getOldSalaryBase(){
                this.loading = true
                getAction('/salary/salaryChangeRecord/selectSalary').then(res=>{
                    this.loading = false
                    if(res||res==0){
                        this.formState.oldSalaryBase = res
                    }else{
                        this.$message.error(res.message);
                    }
                })
           },
        }
    }
    </script>
    
    <style scoped lang="less">
    /deep/ .nresume .ant-input{
      height: 100px !important;
    }

    /deep/ .ant-select{
      width: 100%;
    }
    .form-table-heard:before {
          content: '*';
          color: red;
    }
    /deep/ .ant-calendar-picker{
      width: 113px !important;
    }
    /deep/.ant-modal-root>.ant-modal-wrap>.ant-modal {
      min-width: 0 !important;
    }
    </style>