<template>
  <div class="th-model-properties">
    <Form :label-width="75" label-position="left" v-if="data.parameters.length>0">
      <FormItem :label="item.id" v-for="(item,index) in data.parameters" :key="index">
        <Input :value="item.value" @on-change="propertyChange($event,item.id)"/>
      </FormItem>
    </Form>
    <div v-else>无参数</div>
  </div>
</template>

<script>
import config from '../../constants/config'
import _ from 'lodash'
import {modelUpdate} from '../../libs/request'
export default {
  props: ['data', 'isprivate'],
  methods: {
    propertyChange(e,property){
      let updateData = _.cloneDeep(this.data)
      updateData.parameters.forEach(element => {
        if (element.id === property) {
          element.value = e.target.value
        }
      })
      let ownerId = config.USER
      modelUpdate(ownerId, this.data.modelId, updateData)
      this.$emit("on-change",updateData)
    }
  },
  data() {
    return {
    }
  },
  computed: {
  }
}  
</script>
