Report this 1062 error

report this error error=err_sql_execution, error_description=Error 1062: Duplicate entry"4" for key "unique_persontype"? And there are five such errors
Let the figure
clipboard.png
Code:

< template >
< div align= "center" >

<h3 align="center"></h3>
<el-table :data="tableData" v-loading="loading" border style="width: 80%">
  <el-table-column label="" align="center">
    <template slot-scope="scope">
      {{enumPostType[scope.row.post_type]}}
    </template>
  </el-table-column>

  <el-table-column label="" align="center">
    <template slot-scope="scope">
      <!--{{enumPersonTytype[scope.row.person_type]}}-->
      <el-select placeholder="" v-model="scope.row.person_type" v-if="scope.row.post_type === "1" ">
        <el-option key="1" label="" value="1"></el-option>
        <el-option key="2" label="" value="2"></el-option>
      </el-select>
      <el-select placeholder="" v-model="scope.row.person_type" v-else-if="scope.row.post_type === "2" ">
        <el-option key="3" label="" value="3"></el-option>
        <el-option key="4" label="" value="4"></el-option>
        <el-option key="5" label="" value="5"></el-option>
      </el-select>
      <el-select placeholder="" v-model="scope.row.person_type" v-else-if="scope.row.post_type === "3" ">
        <el-option key="6" label="" value="6"></el-option>
        <el-option key="7" label="" value="7"></el-option>
        <el-option key="8" label="" value="8"></el-option>
      </el-select>
      <el-input placeholder="" v-model="scope.row.person_type" v-else-if="scope.row.post_type === "4""> </el-input>
      <el-input placeholder="" v-model="scope.row.person_type" v-else-if="scope.row.post_type === "5""> </el-input>
      <span v-else></span>
    </template>
  </el-table-column>
</el-table>
<el-row type="flex" class="row-bg" justify="center" style="margin-top: 30px">
  <el-col :span="6"><el-button @click="getData" style="margin-left: 15%"></el-button></el-col>
  <el-col :span="6"><el-button style="margin-left: 10%" @click="Postdata" :loading="postloading"></el-button></el-col>
</el-row>

< / div >
< / template >
< script >
import {getCustomerBusinessEmp, postBbusinessEmp, putBbusinessEmp} from"@ / api/credit"
import {enumPostType, enumPersonTytype} from"@ / utils/enum"
export default {

components: {

},

props: {

},

data () {
  return {
    enumPostType,
    enumPersonTytype,
    tableData: [{post_type: "1"}, {post_type: "2"}, {post_type: "3"}, {post_type: "4"}, {post_type: "5"}],
    loading: false,
    form: {},
    ispost: false,
    postloading: false
  }
},

computed: {

},

watch: {

},

created () {
  this.init()
  this.getData()
},

mounted () {

},

methods: {
  init() {
    this.form = JSON.parse(localStorage.getItem("detail"))
  },

  getData() {
    this.loading = true
    getCustomerBusinessEmp({
      service_id: this.form.service_id,
      customer_id: this.form.customer_id
    }, {id: "eq", customer_id: "eq"}).then(res => {
      if (res.data) {
        this.tableData = res.data
      } else {
        this.ispost = true
      }
    }).catch(err => {
      console.log(err)
    }).then(() => {
      this.loading = false
    })
  },
  Postdata() {
    this.postloading = true
    if (this.tableData.length < 1) { return this.$message.warning("") }
    for (let t = 0; t < this.tableData.length; tPP) {
      this.tableData[t].customer_id = this.form.customer_id
      this.tableData[t].customer_related_id = this.form.customer_related_id
      this.tableData[t].service_id = this.form.service_id
      this.tableData[t].customer_name = this.form.farm_name
    }
    if (this.ispost) {
      postBbusinessEmp(this.tableData).then(res => {
        if (res.data) {
          this.$message.success("")
          this.getData()
        } else {
          this.$message.error("")
        }
      }).catch(err => {
        console.log(err)
        this.$message.error("")
      }).then((res) => {
        this.postloading = false
      })
    } else {
      putBbusinessEmp(this.tableData[0].id, this.tableData[0]).then(res => {
        if (res.data) {
          this.$message.success("")
          this.getData()
        } else {
          this.$message.error("")
        }
      }).catch(err => {
        console.log(err)
        this.$message.error("")
      }).then(() => {
        this.postloading = false
      })
    }
  }
}

}
< / script >
< style scoped >

< / style >

when I press the Save button, it will indicate that the information was saved successfully, but it did not, and which picture error was reported? Please help me, wait online, in urgent need

Sep.06,2021

unique_persontype is the only index, the newly inserted data conflicts

Menu