<template>
  <div class="data-upload">
    <!-- ------------------------------------------- -- 配置页------------------------------------------------------------------------------- -->
    <div class="tuceng_ys">
      <div class="tuceng_ys_son">
        <p>图层样式配置</p>
        <el-form ref="forms" :model="form" label-width="80px" size="mini">
          <el-form-item label="样式名称">
            <el-input style="width: 300px" v-model="form.styleName"></el-input>
          </el-form-item>
          <el-form-item label="数据格式">
            <el-select
              style="width: 300px"
              v-model="form.type"
              placeholder="请选择数据格式"
            >
              <!-- <el-option label="点" value="0"></el-option> -->
              <el-option label="线" value="1"></el-option>
              <el-option label="面" value="2"></el-option>
            </el-select>
          </el-form-item>
          
          <el-form-item v-show="form.type == 2" label="填充颜色">
            <el-color-picker v-model="form.fillColor"></el-color-picker>
            <!-- <el-input
              style="width: 300px"
              v-model="form.fillColor"
              type="color"
            ></el-input> -->
          </el-form-item>
          <el-form-item v-show="form.type == 2" label="透明度">
            <el-input
              style="width: 300px"
              v-model="form.fillOpacity"
            ></el-input>
          </el-form-item>
          <el-form-item
            v-show="form.type == 2 || form.type == 1"
            label="线条颜色"
          >
            <el-color-picker v-model="form.strokeColor"></el-color-picker>
            <!-- <el-input
              style="width: 300px"
              v-model="form.strokeColor"
            ></el-input> -->
          </el-form-item>
          <el-form-item
            v-show="form.type == 2 || form.type == 1"
            label="线条宽度"
          >
            <el-input
              style="width: 300px"
              v-model="form.strokeWidth"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">立即创建</el-button>
            <el-button @click="$emit('yschange')">取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import { saveLayerStyle } from "../../api/datamange";
export default {
  data() {
    return {
      form: {
        type: "1",
        styleName: "",
        fillColor: "",
        fillOpacity: "",
        strokeColor: "",
        strokeWidth: "",
      },
    };
  },
  methods: {
    onSubmit() {
      // console.log(this.form);
      if (!/[\u4E00-\u9FA5]/g.test(this.form.styleName)) {
        saveLayerStyle(this.form).then((res) => {
          if (res.data.code == 200) {
            this.$message.success("创建成功");
            this.loading = true
            this.$emit("yschange");
          } else {
            this.$message.error("创建失败");
          }
          // console.log(res);
        });
      } else {
        this.$message.error('不能输入中文')
      }
    },
  },
};
</script>

<style scoped>
.data-upload {
  width: 100%;
  position:absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: space-around;
  align-items: center;
  background:#162258;
  z-index:99999999999;
}
.tuceng_ys {
  width: 500px;
  height: calc( 100% - 60px);
}
.tuceng_ys .tuceng_ys_son {
  width: 100%;
  height: 500px;
  border-radius: 10px;
  padding: 10px 10px 10px 30px;
}
.tuceng_ys .tuceng_ys_son > p {
  text-align: center;
  font-size: 32px;
  color: #00b2ff;
  margin-bottom: 20px;
}
.tuceng_ys ::v-deep.tuceng_ys_son .el-input__inner {
  background-color: transparent;
  border: 1px solid #10a2e1;
  color: #fff;
}
.tuceng_ys ::v-deep.tuceng_ys_son .el-form-item__label {
  color: #10a2e1;
}
.tuceng_ys ::v-deep.tuceng_ys_son .el-color-picker__trigger {
  width: 300px;
}
</style>