<!--
 * @Descripttion: (商品服务与承诺/tb_goods_services 详情弹窗)
 * @version: (1.0)
 * @Author: (lwh)
 * @Date: (2023-06-18)
 * @LastEditors: (lwh)
 * @LastEditTime: (2023-06-18)
-->
 <template>
  <el-dialog v-model="props.modelValue" title="商品服务与承诺信息详情" width="600px" @closed="closeDialog" @open="openDialog">
    <el-form ref="formRef" :model="formData" :disabled="true">
      <el-row :gutter="20" v-if="userid == 1">
        <el-col :lg="18">
          <el-form-item :label-width="labelWidth" label="店铺">
            <el-input v-model='formData.shopName' disabled type="text">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">

        <el-col :lg="24">
          <el-form-item :label-width="labelWidth" label="服务名称" >
            <el-input v-model="formData.goodsServicesName"  />
          </el-form-item>
        </el-col>
        <el-col :lg="24">
          <el-form-item :label-width="labelWidth" label="概述" >
            <el-input v-model="formData.goodsServicesSummary" type="textarea" :rows="5"  />
          </el-form-item>
        </el-col>
        <el-col :lg="12">
          <el-form-item :label-width="labelWidth" label="是否默认" >
            <el-radio-group v-model="formData.goodsServicesIsDefault">
              <el-radio v-for="item in  is_default " :key="item.dictValue" :label="parseInt(item.dictValue)">{{
                item.dictLabel }}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :lg="24">
          <el-form-item :label-width="labelWidth" label="显示状态" >
            <el-radio-group v-model="formData.goodsServicesDisplayStatus">
              <el-radio v-for="item in  display_status " :key="item.dictValue" :label="parseInt(item.dictValue)">{{
                item.dictLabel }}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :lg="24">
          <el-form-item :label-width="labelWidth" label="排序" prop="goodsServicesSort">
            <el-input-number v-model.number="formData.goodsServicesSort" controls-position="right" :min="0" />
          </el-form-item>
        </el-col>

      </el-row>

    </el-form>
  </el-dialog>
</template>

<script setup>
import { ElMessage } from 'element-plus'
import { reactive, ref, watch } from "vue";
import useUserStore from '@/store/modules/user'


// 打开弹窗时回调
const openDialog = async () => {
   await getis_default()
   await getdisplay_status()

}

const formData = ref({
  ...props.data,
});
watch(props, async (v) => {
  formData.value = v.data;
});

// -业务参数
// 是否默认字典选项列表
const is_default = ref([]);
// 显示状态字典选项列表
const display_status = ref([]);
const userid = useUserStore().userId



// -业务方法
// 字典获取
async function getis_default() {
  await proxy.getDicts('is_default').then((res) => {
    is_default.value = res.data
  })
}
// 字典获取
async function getdisplay_status() {
  await proxy.getDicts('display_status').then((res) => {
    display_status.value = res.data
  })
}



// 基础参数
const formRef = ref();
const labelWidth = 100;
const { proxy } = getCurrentInstance()
const props = defineProps({
  modelValue: Boolean,
  data: Object,
  done: Function,
});
const emits = defineEmits(["update:modelValue"]);


// -基础方法
const closeDialog = () => {
  emits("update:modelValue", false);
};

</script>
