<!--
 * @Author: Fly
 * @Date: 2025-12-10 10:06:13
 * @LastEditTime: 2025-12-25 14:55:28
 * @Description: 订单备注
-->
<template>
  <el-dialog title="商家标识" width="30%" :close-on-click-modal="false" :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit('dataForm')"
      label-width="80px">
      <el-form-item label="标识" prop="sellerMark">
        <el-radio-group v-model="dataForm.sellerMark">
          <!-- <el-radio :label="0">普通</el-radio> -->
          <el-radio :label="10">提醒</el-radio>
          <el-radio :label="20">特别</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="dataForm.remark" placeholder="请输入备注"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit('dataForm')">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { shopOrderRemark } from '@/api/order.js'
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        sellerMark: undefined,
        remark: undefined
      },
      dataRule: {
        sellerMark: [{
          required: true,
          message: '请选择标识',
          trigger: 'change'
        }],
        remark: [{
          required: true,
          message: '请输入备注',
          trigger: 'blur'
        }]
      }
    }
  },

  methods: {
    init(item) {
      this.dataForm = {
        sellerMark: undefined,
        remark: undefined,
        orderId: item.orderId
      };
      this.visible = true
    },
    dataFormSubmit(e) {
      this.$refs[e].validate((valid) => {
        if (valid) {
          shopOrderRemark(this.dataForm).then(res => {
            if (res && res.code == 200) {
              this.$message.success('添加成功！')
              this.$emit('result', res.data)
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss">
.flex {
  display: flex;
}

.ml10 {
  margin-left: 10px;
}
</style>
