<template>
  <div>
    <el-form ref="ruleForm" :model="ruleForm" label-width="80px">
      <el-form-item label="标签类型" prop="tags">
        <el-select v-model="ruleForm.tags" class="form_select" multiple filterable clearable placeholder="请选择标签类型">
          <el-option v-for="item in orderTag" :key="item.F_Value" :label="item.F_Value" :value="item.F_Value"/>
        </el-select>
      </el-form-item>
      <el-form-item>
          <el-button type="primary" @click="submitForm()">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>

import { labelOrderCustomerService } from '@/api/customerServiceManagement/orderListCustomerService'
import { getDictionaryValueList } from '@/api/commonAPI'
export default {
    props: {
      rowid: {
        type: String,
        default: ''
      },
      layerid: {
        type: String,
        default: ""
      }
    },
    data(){
      return{
        ruleForm: {
          orderids: '', //订单编号
          tags: '', //标签内容
        },
        orderTag: [],// 标签
      }
    },
    created() {
      this.getOrderTag()
      if (this.rowid) {
          this.ruleForm.orderids = this.rowid
      }
    },
    methods: {
      submitForm(){
        this.ruleForm.tags = this.ruleForm.tags.join(',')
        labelOrderCustomerService(this.ruleForm).then(response => {
          if (response.state.toLowerCase() === 'success') {
            this.$parent.$layer.close(this.layerid);
            this.$parent.getList(); // 重新加载父级数据
            this.$message.success('恭喜你，操作成功!')
          }
        }).catch(() => {
          this.loading = false
        })
      },
      // 获取订单类型
      getOrderTag() {
        return new Promise(resolve=>{
          const params={
            isleaf:true,
            code:'OrderTag'
          }
          getDictionaryValueList(params).then(response=>{
            if(response.state.toLowerCase() === 'success'){
              this.orderTag = response.data.Rows
            }
          })
        })
      },
    },
}
</script>
<style lang="scss" scoped>
.form_select{
  width: 100%
}
</style>