import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import {ref} from "vue";
import {defHttp} from "@/utils/http/axios";
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '站点id',
    align:"center",
    dataIndex: 'siteId_dictText'
   },
   {
    title: '页面路径',
    align:"center",
    dataIndex: 'url'
   },
   {
    title: '优势标题',
    align:"center",
    dataIndex: 'advantageTitle'
   },
   {
    title: '关键词标题',
    align:"center",
    dataIndex: 'keywordsTitle'
   },
   {
    title: 'faq标题',
    align:"center",
    dataIndex: 'faqTitle'
   },
   {
    title: '同步状态',
    align:"center",
    dataIndex: 'status_dictText'
   },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '更新日期',
    align:"center",
    dataIndex: 'updateTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const siteId = ref();
export const formSchema: FormSchema[] = [
  {
    label: '站点id',
    field: 'siteId',
    component: 'JSearchSelect',
    componentProps: {
      dict:"okki_site,company_name,site_id",
      onChange: (e) => {
        siteId.value = e;
      }
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入站点id!'},
          ];
     },
  },
  {
    label: '页面路径',
    field: 'url',
    component: 'Input',
  },
  {
    label: '优势标题',
    field: 'advantageTitle',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入优势标题!'},
          ];
     },
  },
  {
    label: '优势内容',
    field: 'advantageContent',
    component: 'JEditor',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入优势内容!'},
          ];
     },
  },
  {
    label: '关键词标题',
    field: 'keywordsTitle',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入关键词标题!'},
          ];
     },
  },
  {
    label: 'faq标题',
    field: 'faqTitle',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入faq标题!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
export const okkiOverviewFormSchema: FormSchema[] = [
  {
    label: '概览标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入概览标题!'},
          ];
     },
  },
  {
    label: '概览图片',
    field: 'pic',
    component: 'JImageUpload',
  },
  {
    label: '概览内容',
    field: 'content',
    component: 'InputTextArea',
    //属性
    componentProps:{
      //可以点击清除图标删除内容
      allowClear: true,
      //是否展示字数
      showCount: true,
      //自适应内容高度，可设置为 true | false 或对象：{ minRows: 2, maxRows: 6 }
      autoSize:{
        //最小显示行数
        minRows: 10,
        //最大显示行数
        maxRows: 20
      },
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入概览内容!'},
          ];
     },
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
export const okkiProductListFormSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'title',
    component: 'Input',
  },
  {
    label: '商品pid',
    field: 'pidList',
    component: 'ApiSelect',
    componentProps:{
      //multiple: 多选；不填写为单选
      mode: 'multiple',
      //请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
      api: ()=> defHttp.get({ url: '/showlist/okkiShowlist/productList?siteId=' + siteId.value}),
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'c_title',
      //值字段
      valueField: 'cid',
      //请求参数
      params: {},
      //返回结果字段
      resultField:'list'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 // { required: true, message: '请输入商品pid!'},
          ];
     },
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
export const okkiAdvantageListFormSchema: FormSchema[] = [];
export const okkiFaqFormSchema: FormSchema[] = [];
//子表表格配置
export const okkiAdvantageColumns: JVxeColumn[] = [
    {
      title: '组件标题',
      key: 'blockTitle',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '组件内容',
      key: 'blockContent',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '组件图片',
      key: 'blockPic',
      type: JVxeTypes.image,
      token:true,
      responseName:"message",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
  ]
export const okkiKeywordsColumns: JVxeColumn[] = [
    {
      title: '关键词名',
      key: 'keywordListName',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '关键词链接',
      key: 'keywordListLinkUrl',
      type: JVxeTypes.input,
      // dictCode:"okki_showlist,url,url",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
  ]
export const okkiFaqColumns: JVxeColumn[] = [
    {
      title: '问题',
      key: 'question',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '答案',
      key: 'answer',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  siteId: {title: '站点id',order: 0,view: 'number', type: 'number',dictTable: "okki_site", dictCode: 'site_id', dictText: 'company_name',},
  url: {title: '页面路径',order: 1,view: 'text', type: 'string',},
  advantageTitle: {title: '优势标题',order: 2,view: 'text', type: 'string',},
  keywordsTitle: {title: '关键词标题',order: 4,view: 'text', type: 'string',},
  faqTitle: {title: 'faq标题',order: 5,view: 'text', type: 'string',},
  status: {title: '同步状态',order: 6,view: 'number', type: 'number',},
  createTime: {title: '创建日期',order: 7,view: 'datetime', type: 'string',},
  updateTime: {title: '更新日期',order: 8,view: 'datetime', type: 'string',},
  //子表高级查询
  okkiOverview: {
    title: '概览',
    view: 'table',
    fields: {
        title: {title: '概览标题',order: 0,view: 'text', type: 'string',},
        content: {title: '概览内容',order: 1,view: 'textarea', type: 'string',},
    }
  },
  okkiProductList: {
    title: '产品',
    view: 'table',
    fields: {
        title: {title: '标题',order: 0,view: 'text', type: 'string',},
        pidList: {title: '商品pid',order: 1,view: 'list_multi', type: 'string',},
    }
  },
  okkiAdvantage: {
    title: '优势',
    view: 'table',
    fields: {
        blockTitle: {title: '组件标题',order: 0,view: 'text', type: 'string',},
        blockContent: {title: '组件内容',order: 1,view: 'textarea', type: 'string',},
        blockPic: {title: '组件图片',order: 2,view: 'image', type: 'string',},
    }
  },
  okkiKeywords: {
    title: '关键词',
    view: 'table',
    fields: {
        keywordListName: {title: '关键词名',order: 0,view: 'textarea', type: 'string',},
        keywordListLinkUrl: {title: '关键词链接',order: 1,view: 'text', type: 'string',},
    }
  },
  okkiFaq: {
    title: '常见问题',
    view: 'table',
    fields: {
        question: {title: '问题',order: 0,view: 'text', type: 'string',},
        answer: {title: '答案',order: 1,view: 'text', type: 'string',},
    }
  },
};
