<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div>
        <el-input v-model="searchParam.nameLike" clearable size="small" placeholder="人员名称" style="width: 200px;" class="filter-item" />
        <el-select v-model="searchParam.departmentId" clearable size="small" filterable remote placeholder="所属部门" :remote-method="searchParamDepartmentSearch" style="width: 200px;" class="filter-item">
          <el-option v-for="item in searchParamSelection._departmentSelections" :key="item.id" :label="item.name" :value="item.id" />
        </el-select>
        <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="searchSubmit">搜索</el-button>
        <el-button class="filter-item" size="mini" type="warning" icon="el-icon-refresh-left" @click="searchParamReset">重置</el-button>
        <el-tooltip class="item" effect="dark" content="按当前查询条件导出" placement="top">
          <el-button :loading="exporting" class="filter-item" size="mini" type="info" plain icon="el-icon-download" @click="exportSubmit">导出</el-button>
        </el-tooltip>
      </div>
      <el-button class="filter-item" size="mini" type="primary" icon="el-icon-plus" @click="doAdd()">新增</el-button>
      <el-upload
        class="filter-item"
        action="/api/staff/import"
        multiple
        :data="{mineType:selectedMine.mineType,mineId:selectedMine.id}"
        :headers="httpHeaders"
        :before-upload="beforeImport"
        :on-success="importSuccess"
        :on-error="importError"
        :show-file-list="false"
      >
        <el-button :loading="dialog3Saving" size="mini" type="success" icon="el-icon-upload2">导入</el-button>
      </el-upload>
    </div>
    <!--弹出框1-->
    <el-dialog append-to-body :close-on-click-modal="true" :visible.sync="dialog1Show" :title="editState==1?'新增':editState==2?'修改':'查看'" width="960px">
      <el-form ref="dialog1Form" :model="dialog1Data" :hide-required-asterisk="!dialog1Editing" :rules="dialog1Rules" size="mini" label-width="180px" style="margin-right: 80px;">
        <el-row :gutter="20">
          <el-col :span="20">
            <el-form-item label="工号：" prop="staffCode">
              <span v-show="!dialog1Editing">{{ dialog1Data.staffCode }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.staffCode" maxlength="30" show-word-limit placeholder="建议仅填写数字或字母，或确保打卡机支持" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="姓名：" prop="name">
              <span v-show="!dialog1Editing">{{ dialog1Data.name }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.name" maxlength="30" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别：" prop="sex">
              <span v-show="!dialog1Editing">{{ dialog1Data.sex==1?'男':dialog1Data.sex==2?'女':'' }}</span>
              <el-select v-show="dialog1Editing" v-model="dialog1Data.sex" clearable style="width: 100%;">
                <el-option :key="1" label="男" :value="1" />
                <el-option :key="2" label="女" :value="2" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="所属部门：" prop="departmentId">
              <span v-show="!dialog1Editing">{{ dialog1Data.departmentName }}</span>
              <el-select v-show="dialog1Editing" v-model="dialog1Data.departmentId" filterable remote placeholder="请输入关键词搜索" clearable :remote-method="dialog1DepartmentSearch" style="width: 100%;">
                <el-option v-for="item in dialog1Data._departmentSelections" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="岗位：" prop="jobId">
              <span v-show="!dialog1Editing">{{ dialog1Data.jobName }}</span>
              <el-select v-show="dialog1Editing" v-model="dialog1Data.jobId" filterable remote placeholder="请输入关键词搜索" clearable :remote-method="dialog1JobSearch" style="width: 100%;">
                <el-option v-for="item in dialog1Data._jobSelections" :key="item.id" :label="item.name" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="身份证号：" prop="idcard">
              <span v-show="!dialog1Editing">{{ dialog1Data.idcard }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.idcard" maxlength="18" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工种：" prop="workType">
              <span v-show="!dialog1Editing">{{ dialog1Data.workType }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.workType" maxlength="100" show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="民族：" prop="national">
              <span v-show="!dialog1Editing">{{ dialog1Data.national }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.national" maxlength="10" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="职务：" prop="position">
              <span v-show="!dialog1Editing">{{ dialog1Data.position }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.position" maxlength="100" show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="政治面貌：" prop="politicalAffiliation">
              <span v-show="!dialog1Editing">{{ dialog1Data.politicalAffiliation }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.politicalAffiliation" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="联系电话：" prop="phone">
              <span v-show="!dialog1Editing">{{ dialog1Data.phone }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.phone" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="学历：" prop="schoolingRecord">
              <span v-show="!dialog1Editing">{{ dialog1Data.schoolingRecord }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.schoolingRecord" maxlength="100" show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="职称：" prop="professionalTitle">
              <span v-show="!dialog1Editing">{{ dialog1Data.professionalTitle }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.professionalTitle" maxlength="100" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专业：" prop="specialty">
              <span v-show="!dialog1Editing">{{ dialog1Data.specialty }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.specialty" maxlength="100" show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="出生日期：" prop="birthday">
              <span v-show="!dialog1Editing">{{ dialog1Data.birthday }}</span>
              <el-date-picker v-show="dialog1Editing" v-model="dialog1Data.birthday" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="入职时间：" prop="inductionDate">
              <span v-show="!dialog1Editing">{{ dialog1Data.inductionDate }}</span>
              <el-date-picker v-show="dialog1Editing" v-model="dialog1Data.inductionDate" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="常住地址：" prop="address">
              <span v-show="!dialog1Editing">{{ dialog1Data.address }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.address" maxlength="500" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="照片：" prop="photoPath">
              <div v-for="file in dialog1Data._photoList" v-show="!dialog1Editing" :key="file.url">
                <el-link type="primary" @click="openFile(file)">{{ file.name }}</el-link>
              </div>
              <el-upload
                v-show="dialog1Editing"
                class="upload-demo"
                action="/api/file/upload"
                multiple
                :headers="httpHeaders"
                :limit="1"
                :on-success="upFileSuccess"
                :on-remove="upFileRemove"
                :on-error="upFileError"
                :on-exceed="upFileExceed"
                :before-upload="upFileBefore"
                :on-preview="openFile"
                :file-list="dialog1Data._photoListShow"
              >
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">图片不要超过20M，仅支持jpeg、png格式</div>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="紧急联系人：" prop="emergencyContact">
              <span v-show="!dialog1Editing">{{ dialog1Data.emergencyContact }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.emergencyContact" maxlength="100" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="紧急联系人电话：" prop="emergencyPhone">
              <span v-show="!dialog1Editing">{{ dialog1Data.emergencyPhone }}</span>
              <el-input v-show="dialog1Editing" v-model="dialog1Data.emergencyPhone" maxlength="100" show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div v-show="dialog1Editing" slot="footer" class="dialog-footer">
        <el-button type="text" @click="dialog1Show=false">取消</el-button>
        <el-button :loading="dialog1Saving" type="primary" @click="dialog1Submit">确认</el-button>
      </div>
    </el-dialog>
    <!--弹出框2-->
    <el-dialog append-to-body :close-on-click-modal="true" :visible.sync="dialog2Show" :title="'确认删除'" width="580px">
      <div>
        <span>确认要删除人员信息：</span><span style="font-weight: bold;">{{ dialog2Data.name }}</span><span>吗？</span>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="text" @click="dialog2Show=false">取消</el-button>
        <el-button :loading="dialog2Saving" type="primary" @click="dialog2Submit">确认</el-button>
      </div>
    </el-dialog>
    <!--弹出框3-->
    <el-dialog append-to-body :close-on-click-modal="true" :visible.sync="dialog3Show" :title="'导入结果'" width="580px">
      <div>
        <span>共计成功导入：</span>
        <span style="font-weight: bold;">{{ dialog3Data.successCount + dialog3Data.failCount }}</span>
        <span>条，请核对总数。</span>
      </div>
      <div>
        <span>其中，成功：</span>
        <span style="color: #67C23A;">{{ dialog3Data.successCount }}</span>
        <span>条；失败：</span>
        <span style="color: #F56C6C;">{{ dialog3Data.failCount }}</span>
        <span>条。</span>
      </div>
      <br>
      <div v-if="dialog3Data.failCount">
        <div><span>失败信息：</span></div>
        <br>
        <div v-for="failReason in dialog3Data.failReasonList" :key="failReason.index">
          <span>第{{ failReason.index }}条数据</span>
          <span v-if="failReason.row" style="font-size: 10px;color: #909399;">第{{ failReason.row }}行</span>
          <span v-if="failReason.col" style="font-size: 10px;color: #909399;">第{{ failReason.col }}列</span>
          <span v-if="failReason.data" style="margin-left: 10px; color: #F56C6C;">{{ failReason.data }}</span>
          <span style="margin-left: 10px;">{{ failReason.reason }}</span>
        </div>
      </div>
    </el-dialog>
    <!--表格-->
    <el-table ref="table" v-loading="searching" :data="tableData" row-key="id">
      <el-table-column :show-overflow-tooltip="true" prop="id" label="编号" width="100px" align="center" />
      <el-table-column :show-overflow-tooltip="true" prop="staffCode" label="工号" align="center" />
      <el-table-column :show-overflow-tooltip="true" prop="name" label="姓名" align="center" />
      <el-table-column :show-overflow-tooltip="true" prop="sex" label="性别" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.sex==1?'男':scope.row.sex==2?'女':'' }}</span>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="phone" label="联系方式" align="center" />
      <el-table-column :show-overflow-tooltip="true" prop="departmentName" label="所在部门" align="center" />
      <el-table-column :show-overflow-tooltip="true" prop="position" label="职务" align="center" />
      <el-table-column :show-overflow-tooltip="true" prop="professionalTitle" label="职称" align="center" />
      <el-table-column :show-overflow-tooltip="true" prop="inductionDate" label="入职时间" align="center" />
      <el-table-column label="操作" width="300px" align="center" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" round @click="doEdit(scope.row.id,false)">查看</el-button>
          <el-button size="mini" round @click="doEdit(scope.row.id,true)">修改</el-button>
          <el-button size="mini" round @click="doDelete(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :page-sizes="[10, 20, 50, 100]"
      :current-page.sync="searchParam.page"
      :page-size.sync="searchParam.count"
      :total="searchResult.total"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="searchSubmit"
      @current-change="searchSubmit"
    />
  </div>
</template>

<script>
import staffApi from '@/api/kd/staff'
import staffJobApi from '@/api/kd/staffJob'
import staffDepartmentApi from '@/api/kd/staffDepartment'
import { getToken } from '@/utils/auth'
import { mapGetters } from 'vuex'
import { downloadFile } from '@/utils'
import { validatePhone, validateIdNo } from '@/utils/validate'
const searchParam = {// 默认搜索条件
  page: 1,
  count: 10,
  searchCount: true
}
export default {
  name: 'EStaff', // 本页面名
  components: { },
  data() {
    return {
      selectedMine: {},
      httpHeaders: {
        'Authorization': getToken()
      },
      searching: false,
      exporting: false,
      searchParam: {},
      searchParamSelection: {},
      searchResult: {
        total: 0,
        results: [] // 搜索结果
      },
      dialog1Show: false,
      dialog1Editing: false,
      dialog1Saving: false,
      dialog1Data: {},
      dialog1Rules: {
        name: [
          { required: true, message: '请填写' }
        ],
        sex: [
          { required: true, message: '请填写' }
        ],
        departmentId: [
          { required: true, message: '请填写' }
        ],
        jobId: [
          { required: true, message: '请填写' }
        ],
        idcard: [
          { required: true, trigger: 'blur', validator: validateIdNo }
        ],
        workType: [
          { required: true, message: '请填写' }
        ],
        national: [
          { required: true, message: '请填写' }
        ],
        position: [
          { required: true, message: '请填写' }
        ],
        phone: [{ required: false, trigger: 'blur', validator: validatePhone }]
      },
      editState: 0, // （刚打开窗口时）记录了上次窗口作用；（保存编辑时）记录了当前窗口作用； 0无 1新增 2修改 3查看
      addingData: {}, // 上次正在新增时的内容，下次打开dialog1窗口时记录下来
      dialog2Show: false,
      dialog2Saving: false,
      dialog2Data: {},
      dialog3Show: false,
      dialog3Data: {},
      dialog3Saving: false
    }
  },
  computed: {
    ...mapGetters([
      'user',
      'baseApi'
    ]),
    tableData() {
      // 此处对返回值进行算法重组
      return this.searchResult.results
    }
  },
  mounted() {
    const selectedMineJson = window.localStorage.getItem('kd.selected.mine')
    let noMine = false
    if (!selectedMineJson) {
      noMine = true
    } else {
      const selectedMine = JSON.parse(selectedMineJson)
      if (!selectedMine || selectedMine.enterpriseId !== this.user.enterpriseId) {
        noMine = true
      } else {
        this.selectedMine = selectedMine
      }
    }
    if (noMine) {
      this.$message.error('当前未选择矿山')
      this.$router.replace('/dashboard')
    }
    this.searchParamReset()
    this.searchSubmit()
  },
  methods: {
    searchParamDepartmentSearch(queryString) {
      staffDepartmentApi.getPage({
        nameLike: queryString,
        mineType: this.selectedMine.mineType,
        mineId: this.selectedMine.id
      }).then(response => {
        this.$delete(this.searchParamSelection, '_departmentSelections') // 解决$set不更新DOM
        this.$set(this.searchParamSelection, '_departmentSelections', response.results)
      }).catch(() => {
        this.$message.error('出错啦，请重试')
      })
    },
    searchParamReset() {
      this.searchParam = JSON.parse(JSON.stringify(searchParam))
    },
    searchSubmit() {
      this.searching = true
      this.searchParam.mineType = this.selectedMine.mineType
      this.searchParam.mineId = this.selectedMine.id
      staffApi.getPage(this.searchParam).then(response => {
        this.searching = false
        this.searchResult = response
      }).catch(() => {
        this.searching = false
      })
    },
    exportSubmit() {
      this.exporting = true
      this.searchParam.mineType = this.selectedMine.mineType
      this.searchParam.mineId = this.selectedMine.id
      staffApi.export(this.searchParam).then(response => {
        downloadFile(response, '全员档案', 'xlsx')
        this.exporting = false
      }).catch(() => {
        this.exporting = false
      })
    },
    dialog1Submit() {
      this.$refs['dialog1Form'].validate(valid => {
        if (!valid) {
          return
        } else {
          this.dialog1Saving = true
          if (this.dialog1Data._photoList) {
            this.dialog1Data.photoPath = JSON.stringify(this.dialog1Data._photoList)
          }
          if (this.editState === 1) { // 新增
            this.dialog1Data.mineType = this.selectedMine.mineType
            this.dialog1Data.mineId = this.selectedMine.id
            staffApi.add(this.dialog1Data).then(() => {
              this.dialog1Show = false
              this.$message.success('保存成功')
              setTimeout(() => { // 立即清除会导致输入框Validate一闪变红
                this.dialog1Data = {}
                this.dialog1Data._photoListShow = []
                this.dialog1Saving = false
              }, 500)
              this.searchSubmit()
            }).catch(() => {
              this.dialog1Saving = false
            })
          } else if (this.editState === 2) { // 修改
            staffApi.set(this.dialog1Data).then(() => {
              this.dialog1Show = false
              this.$message.success('修改成功')
              setTimeout(() => { // 立即清除会导致输入框Validate一闪变红
                this.dialog1Data = {}
                this.dialog1Saving = false
              }, 500)
              this.searchSubmit()
            }).catch(() => {
              this.dialog1Saving = false
            })
          } else {
            this.$message.error('出错啦，请重试')
            this.dialog1Saving = false
          }
        }
      })
    },
    beforeDialog1Open() { // 窗口打开前的统一操作
      if (this.editState === 1) {
        this.addingData = this.dialog1Data
      }
    },
    doAdd() {
      this.beforeDialog1Open()
      this.editState = 1
      this.dialog1Editing = true
      this.dialog1Data = this.addingData // 初始值：上次编辑的内容
      this.dialog1Show = true
      this.$nextTick(() => {
        this.$refs['dialog1Form'].clearValidate()
      })
    },
    doEdit(id, isEdit) {
      this.beforeDialog1Open()
      this.editState = isEdit ? 2 : 3
      staffApi.getById(id).then(response => {
        this.dialog1Data = response
        this.dialog1Data._departmentName = response.departmentName
        if (response.departmentId) {
          this.dialog1Data._departmentSelections = [{ id: response.departmentId, name: response.departmentName }]
        }
        this.dialog1Data._jobName = response.jobName
        if (response.jobId) {
          this.dialog1Data._jobSelections = [{ id: response.jobId, name: response.jobName }]
        }
        if (this.dialog1Data.photoPath) {
          this.dialog1Data._photoList = JSON.parse(this.dialog1Data.photoPath)
          this.dialog1Data._photoListShow = JSON.parse(this.dialog1Data.photoPath) // 数据存放与原始绑定分开，可以防止中途赋值产生的闪烁问题
        }
        this.dialog1Editing = isEdit
        this.dialog1Show = true
      }).catch(() => {
        this.searchSubmit()
      })
    },
    dialog2Submit() {
      this.dialog2Saving = true
      staffApi.del(this.dialog2Data).then(() => {
        this.dialog2Show = false
        this.$message.success('删除成功')
        this.dialog2Data = {}
        this.dialog2Saving = false
        this.searchSubmit()
      }).catch(() => {
        this.dialog2Saving = false
      })
    },
    doDelete(id) {
      staffApi.getById(id).then(response => {
        this.dialog2Data = response
        this.dialog2Show = true
      }).catch(() => {
        this.searchSubmit()
      })
    },
    dialog1DepartmentSearch(queryString) {
      staffDepartmentApi.getPage({
        nameLike: queryString,
        mineType: this.selectedMine.mineType,
        mineId: this.selectedMine.id
      }).then(response => {
        this.$delete(this.dialog1Data, '_departmentSelections') // 解决$set不更新DOM
        this.$set(this.dialog1Data, '_departmentSelections', response.results)
      }).catch(() => {
        this.$message.error('出错啦，请重试')
      })
    },
    dialog1JobSearch(queryString) {
      staffJobApi.getPage({
        nameLike: queryString,
        mineType: this.selectedMine.mineType,
        mineId: this.selectedMine.id
      }).then(response => {
        this.$delete(this.dialog1Data, '_jobSelections') // 解决$set不更新DOM
        this.$set(this.dialog1Data, '_jobSelections', response.results)
      }).catch(() => {
        this.$message.error('出错啦，请重试')
      })
    },
    elementuiUpListFormat(fileList) {
      const filePathArray = []
      fileList.forEach(f => {
        if (f.response && f.response.result) {
          filePathArray.push({
            name: f.name,
            url: f.response.result
          })
        } else if (f.name && f.url) {
          filePathArray.push({
            name: f.name,
            url: f.url
          })
        }
      })
      return filePathArray
    },
    upFileSuccess(response, file, fileList) {
      if (!this.dialog1Data._photoList) {
        this.dialog1Data._photoList = []
      }
      this.dialog1Data._photoList.push({
        name: file.name,
        url: response.result
      })
    },
    upFileRemove(file, fileList) {
      this.dialog1Data._photoList = this.elementuiUpListFormat(fileList)
    },
    upFileError() {
      this.$message.error('上传失败，请稍后再试')
    },
    upFileExceed() {
      this.$message.error('只可以上传一张照片')
    },
    upFileBefore(file) {
      const isIMG = file.type === 'image/jpeg' || file.type === 'image/png'
      const isLtSize = file.size / 1024 / 1024 < 20
      if (!isIMG) {
        this.$message.error('上传图片只能是 JPG/JPEG/PNG 格式')
        return false
      }
      if (!isLtSize) {
        this.$message.error('上传图片大小不能超过 20MB')
        return false
      }
      return true
    },
    openFile(file) {
      if (file.url) {
        window.open(this.baseApi + '/file' + file.url)
      } else if (file.response && file.response.result) {
        window.open(this.baseApi + '/file' + file.response.result)
      }
    },
    beforeImport() {
      this.dialog3Saving = true
    },
    importSuccess(response, file, fileList) {
      this.dialog3Data = response
      this.dialog3Show = true
      this.searchSubmit()
      this.dialog3Saving = false
    },
    importError(error) {
      this.$message.error('导入失败')
      console.error('导入失败', error)
      this.dialog3Saving = false
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  ::v-deep .el-input-number .el-input__inner {
    text-align: left;
  }
  ::v-deep .vue-treeselect__control,::v-deep .vue-treeselect__placeholder,::v-deep .vue-treeselect__single-value {
    height: 30px;
    line-height: 30px;
  }
</style>
