<template>
    <a-card :bordered="false">
  
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="组织">
                <a-select  v-model="queryParam.orgName">
                    <a-select-option value="">所有</a-select-option>
                    <a-select-option value="Apparel Group">Apparel Group</a-select-option>
                    <a-select-option value="宁波森语">宁波森语</a-select-option>
                    <a-select-option value="马菲羊">马菲羊</a-select-option>
                  </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="部门">
                <j-search-select-tag v-model="queryParam.sysOrgCode" placeholder="请选择部门" 
                     dict="sys_depart,depart_name,depart_name,org_type='3' or org_code='TBD' order by org_code"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="姓名">
                <a-input placeholder="请输入" v-model="queryParam.name"  />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              </span>
            </a-col>
  
          </a-row>
        </a-form>
      </div>
  
      <!-- 操作按钮区域 -->

  
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="userId"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :scroll="{x: 1000}"
          :loading="loading"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          @change="handleTableChange">
           <span slot="basicSalary" slot-scope="text, record">
                <a>{{record.beforeAdjustment}}</a>
                <!-- <a >333333</a> -->
           </span>
        </a-table>
      </div>
      <!-- table区域-end -->
  
      <!-- 表单区域 -->
      <ChangeBasicSalary ref="ChangeBasicSalary" @ok="getTableList"></ChangeBasicSalary>
    </a-card>
  </template>
  
  <script>
  
    import { JeecgListMixin } from '@/mixins/JeecgListMixin'
    import { getAction } from '@/api/manage'
    import moment from 'moment'
    import ChangeBasicSalary from './modules/ChangeBasicSalary.vue'
    import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
    export default {
      name: "BasicSalary",
      mixins: [JeecgListMixin],
      components: {
        moment,
        ChangeBasicSalary,
        JSearchSelectTag
      },
      data () {
        return {
          description: '基本薪资',
          DateTime:[],
          selectedRowKeys:[],
          selectedRows:[],
          // 表头
          columns: [
            {
              title: '序号',
              width: 80,
              align:"center",
              dataIndex: 'index',
              customRender:function (t, r, index) {
                    return parseInt(index)+1;
              }
            },
            {
              title: '编号',
              align:"center",
              dataIndex: 'code'
            },
            {
              title: '部门',
              align:"center",
              dataIndex: 'sysOrgCode'
            },
            {
              title: '姓名',
              align:"center",
              dataIndex: 'name'
            },
            {
              title: '组织',
              align:"center",
              dataIndex: 'orgName'
            },
            {
              title: '工资卡号',
              align:"center",
              dataIndex: 'cardNo'
            },
            {
              title: '基本薪资',
              align:"center",
              dataIndex: 'beforeAdjustment',
              scopedSlots: { customRender: 'basicSalary' } ,
              customCell: this.handleBasicSalary,
            },
            {
              title: '最后变更时间',
              align:"center",
              dataIndex: 'updateTime'
            },
          ],
          queryParam:{},
          dataSource:[{}],
          ipagination:{},
          // 请求参数
        //   url: {

        //      },
          }
        },
      computed: {},
      created () {
        this.getTableList()
      },
      methods: {
        getTableList(){
          getAction('/salary/salaryChangeRecord/querySalaryList',this.queryParam).then(res=>{
            if(res.success){
                this.dataSource =res.result.records
                this.ipagination = {
                  total: res.result.total,
                  current: res.result.current,
                  pageSize: res.result.size
                }
            }else{
                this.$message.error(res.message);
            }
          })
        },
        handleBasicSalary(record){
          return {
            on: {
              dblclick: event => {
                this.$refs.ChangeBasicSalary.visible = true
                this.$refs.ChangeBasicSalary.getData(record)
              }
            }
          }
        },
        searchQuery(){
          this.queryParam.pageNo = 1
          this.getTableList()
        },
        searchReset(){
          this.queryParam={}
          this.getTableList()
        },
        onSelectChange(selectedRowKeys, selectionRows) {
            this.selectedRowKeys = selectedRowKeys;
            this.selectedRows = selectionRows;
        },
        handleTableChange(pagination, filters, sorter) {
            this.queryParam.pageNo = pagination.current
            this.queryParam.pageSize = pagination.pageSize
            this.getTableList()
        },
      }
    }
  </script>
  <style scoped>
    @import '~@assets/less/common.less'
  </style>