<template>
  <el-dialog
    width="350px"
    title="语言"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form
             v-model="dataList"
             inline="inline"
             size="mini"
             label-width="80px">
      <el-form-item v-for="(item,index) in dataList"
                    :key="item.columnProp"
                    :label="item.columnLabel"
                    :prop="item.columnProp">
        <el-form-item>
          {{item.languageCode }}
        </el-form-item>
        <el-form-item>
          <el-input v-model="item.languageValue" controls-position="right" style="display:inline"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="dataFormSubmit(item)"> {{buttons.add}}</el-button>
        </el-form-item>


      </el-form-item>
    </el-form>

    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false" type="primary">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import {searchMenuLanguageById,saveMenuLanguage} from '@/api/sysLanguageMenu.js'

export default {
  data() {
    return {
      visible: false,
      addLanguage: false,
      functionId: 9001,
      tableId: "common1001",
      value1: true,
      showDefault: false,
      dataListLoading: false,
      dataList: [],
      querySysLanguageParam: {},
      buttons: {
        add: '确认',
      },
    }
  },
  methods: {
    init(id) {
      this.visible = true
      let menu = {
        menuId: id
      }
      searchMenuLanguageById(menu).then(({data}) =>{
        this.dataList = data.menuLanguageList
      })
    },
    saveLanguageList(){

    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = false

    },
    // 表单提交
    dataFormSubmit(val) {
      saveMenuLanguage(val).then(({data})=>{
        if (data.code == 0){
          this.$message.success(data.msg)
        }else {
          this.$message.error(data.msg)
        }
      })
    }
  }
}
</script>

<style lang="scss">

 .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
   margin-bottom: 5px;
 }
</style>
