<template>
  <div class="app-container">
    <el-form v-model="queryParams" :inline="true">
      <el-form-item :label="$t('algconvert.mainSystem')">
        <el-select
          :placeholder="
            $t('share.PleaseChoose') + ' ' + $t('algconvert.mainSystem')
          "
        >
          <!-- <el-option label="item.label" value="item.value"></el-option> -->
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('algconvert.algorithm')">
        <el-select
          :placeholder="
            $t('share.PleaseChoose') + ' ' + $t('algconvert.algorithm')
          "
        >
          <el-option label="item.label" value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('algconvert.algorithm')">
        <el-input
          :placeholder="
            $t('share.PleaseChoose') +
            ' ' +
            $t('algconvert.OriginalAlgorithmNumber')
          "
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="handleQuery"
          size="mini"
          >{{ $t("share.search") }}</el-button
        >
        <el-button icon="el-icon-refresh" @click="resetQuery" size="mini">{{
          $t("share.reset")
        }}</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          plain
          size="mini"
          @click="add"
          >{{ $t("share.new") }}</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" icon="el-icon-edit" plain size="mini"  @click="handleEdit()">{{
          $t("share.edit")
        }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" icon="el-icon-delete" plain size="mini">{{
          $t("share.delete")
        }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" icon="el-icon-download" plain size="mini">{{
          $t("share.export")
        }}</el-button>
      </el-col>
    </el-row>
    <el-table :data="tableData" style="width: 100%; margin-bottom: 20px">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        prop="id"
        :label="$t('algconvert.LedgerID')"
        align="center"
      />
      <el-table-column
        prop="id"
        :label="$t('algconvert.MainSystemNumber')"
        align="center"
      />
      <el-table-column
        prop="name"
        :label="$t('algconvert.MainSystemName')"
        align="center"
      />
      <el-table-column
        prop="id"
        :label="$t('algconvert.ManufacturerNumber')"
        align="center"
      />
      <el-table-column
        prop="id"
        :label="$t('algconvert.ManufacturerName')"
        align="center"
      />
      <el-table-column
        prop="id"
        :label="$t('algconvert.algorithm')"
        align="center"
      />
      <el-table-column
        prop="id"
        :label="$t('algconvert.AlgorithmNumber')"
        align="center"
      />
      <el-table-column
        prop="id"
        :label="$t('algconvert.OriginalAlgorithmNumber')"
        align="center"
      />
      <el-table-column :label="$t('share.operate')" align="center">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            @click="handleEdit(scope.$index, scope.row)"
            >{{ $t("share.edit") }}</el-button
          >
          <el-button
            type="text"
            size="small"
            @click="handleDelete(scope.$index, scope.row)"
            >{{ $t("share.delete") }}</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
    />
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-form :model="dialogForm" :rules="rules" ref="ruleForm">
        <el-form-item :label="$t('algconvert.mainSystem')" prop="mainSystem">
          <el-select
            style="width: 100%"
            :placeholder="
              $t('share.PleaseChoose') + ' ' + $t('algconvert.mainSystem')
            "
          >
            <el-option label="item.label" value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('algconvert.algorithm')" prop="algorithm">
          <el-select
            style="width: 100%"
            :placeholder="
              $t('share.PleaseChoose') + ' ' + $t('algconvert.algorithm')
            "
          >
            <el-option label="item.label" value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('algconvert.OriginalAlgorithmNumber')" prop="OriginalAlgorithmNumber">
          <el-input
            :placeholder="
              $t('share.PleaseEnter') +
              ' ' +
              $t('algconvert.OriginalAlgorithmNumber')
            "
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">{{
          $t("share.cancel")
        }}</el-button>
        <el-button type="primary" @click="dialogVisible = false">{{
          $t("share.confirm")
        }}</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryParams: {},
      tableData: [
        {
          id: 1,
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          id: 2,
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          id: 3,
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          id: 4,
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
      total: 10,
      dialogVisible: false,
      dialogForm: {},
      title:this.$t('algconvert.AddBasicData-DeviceCorrespondence'),
      rules: {
        mainSystem: [
          {
            required: true,
            message:
              this.$t("share.PleaseChoose") +
              " " +
              this.$t("algconvert.mainSystem"),
            trigger: "change",
          },
        ],
        algorithm:[
          {
            required: true,
            message:
              this.$t("share.PleaseChoose") +
              " " +
              this.$t("algconvert.algorithm"),
            trigger: "change",
          },
        ],
        OriginalAlgorithmNumber:[
          {
            required: true,
            message:
              this.$t("share.PleaseEnter") +
              " " +
              this.$t("algconvert.OriginalAlgorithmNumber"),
            trigger: "blur",
          },
        ]
      },
    };
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {
    add() {
      this.dialogVisible = true;
      this.title=this.$t('algconvert.AddBasicData-DeviceCorrespondence')
    },
    handleEdit(){
      this.dialogVisible = true;
      this.title=this.$t('algconvert.EditBasicData-DeviceCorrespondence')
    }
  },
};
</script>

<style lang="scss" scoped></style>
