<template>
  <el-dialog v-model="props.modelValue" title="新闻详情" width="900px" @closed="closeDialog"  @open="openDialog">
    <el-form ref="formRef" :model="formData" :disabled="true">
      <el-row>
        
        
                           <el-col :span="12">
                               <el-form-item label="新闻类型" prop="news_type">
                               <el-select v-model="formData.news_type" clearable placeholder="请选择">
                                       <el-option
                                           v-for="item in news_type"
                                           :key="item.dictionary_guid" :label="item.dictionary_name"
                                           :value="item.dictionary_value"
                                           ></el-option>
                                   </el-select>
                               </el-form-item>
                           </el-col>
                           <el-col :span="12">
                               <el-form-item :label-width="labelWidth" label="新闻标题" prop="news_title">
                                  <el-input v-model='formData.news_title' type="text" placeholder='请输入新闻标题'></el-input>
                               </el-form-item>
                           </el-col>
                           <el-col :span="24">
                               <el-form-item :label-width="labelWidth" label="新闻简介" prop="news_intro">
                                  <el-input v-model='formData.news_intro' type="textarea" :rows="5" placeholder='请输入新闻简介'></el-input>
                               </el-form-item>
                           </el-col>
                           <el-col :span="12">
                               <el-form-item :label-width="labelWidth" label="文章来源" prop="news_source">
                                  <el-input v-model='formData.news_source' type="text" placeholder='请输入文章来源'></el-input>
                               </el-form-item>
                           </el-col>
                           <el-col :span="12">
                               <el-form-item :label-width="labelWidth" label="跳转链接" prop="news_link">
                                  <el-input v-model='formData.news_link' type="text" placeholder='请输入跳转链接'></el-input>
                               </el-form-item>
                           </el-col>
                           <el-col :span="12">
                               <el-form-item
                                   :label-width="labelWidth"
                                   label="发布日期" prop="news_issue_date"
                               >
                                   <el-date-picker
                                   v-model="formData.news_issue_date"
                                   type="datetime"
                                   value-format="YYYY-MM-DD HH:mm"
                                   placeholder="发布日期"
                                   />
                               </el-form-item>
                           </el-col>
                           <el-col :span="12">
                               <el-form-item :label-width="labelWidth" label="浏览次数" prop="news_views_num">
                                  <el-input-number v-model='formData.news_views_num' controls-position='right' :min='1'></el-input-number>
                               </el-form-item>
                           </el-col>
                           <el-col :span="12">
                               <el-form-item :label-width="labelWidth" label="新闻排序" prop="news_sort">
                                  <el-input-number v-model='formData.news_sort' controls-position='right' :min='1'></el-input-number>
                               </el-form-item>
                           </el-col>
                           <el-col :span="24">
                               <el-form-item :label-width="labelWidth" label="新闻内容" prop="news_content">
                                  <RichText v-model='formData.news_content' :min-height='196'></RichText>
                               </el-form-item>
                           </el-col>

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

<script setup>
import { reactive, ref, watch } from "vue";
import { isEmptyObject } from "~/utils/index";
import { getDictionary } from '~/service/news';

// --业务参数



// --业务方法

                   // 字典获取
                   const news_type = ref([]);
                   async function get_news_type() {
                     await getDictionary({ dictionary_value: 'news_type'}).then((res) => {
                       news_type.value = res
                     })
                   }



// --基础参数
const formRef = ref();
const labelWidth = 100;

const props = defineProps({
  modelValue: Boolean,
  data: Object,
  done: Function,
});
const emits = defineEmits(["update:modelValue"]);
const formData = ref({
  ...props.data,
});


// --基础方法
watch(props, (v) => {
  formData.value = v.data;
  
  
});

// 打开弹窗时执行
const openDialog = () => {
  
  get_news_type()
                   
};

const closeDialog = () => {
  emits("update:modelValue", false);
};
</script>

<style lang="less" scoped>

</style>
