utils.js 7.78 KB
Newer Older
张烨's avatar
张烨 committed
1 2
import { ITEM_TYPE } from '@/components/BaseForm';

张烨's avatar
张烨 committed
3 4 5 6
export const webMode = {
  single: 'single',
  integration: 'integration',
};
张烨's avatar
张烨 committed
7 8 9 10 11 12
const typeContent = hasIntegerate => {
  if (hasIntegerate) {
    return [];
  }
  return [
    {
张烨's avatar
张烨 committed
13
      value: webMode.integration,
张烨's avatar
张烨 committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
      children: '集成网站',
    },
  ];
};

export const integrateStyleData = {
  platform: '工作台',
  webgis: 'WEBGIS',
  ios: 'IOS',
  catalog: 'Catalog',
  virtualcity: 'VirtualCity',
};
export const singleStyleData = {
  platform: '工作台',
  webgis: 'WEBGIS',
};
export const menuStyle = {
31 32 33 34 35 36
  'banner-left': '经典',
  // banner: '标题栏',
  // 'banner-big': '标题栏-大',
  // table: '左侧',
  // dock: '底部',
  // 'banner-left-noShrink': '标题栏-左-不收',
张烨's avatar
张烨 committed
37 38 39 40 41 42
};
export const MDILabel = {
  MDI: '多标签模式',
  SDI: '单标签模式',
};
export const notificationTypes = {
43
  // notify: '轮询通知',
张烨's avatar
张烨 committed
44 45 46
  MQTT: 'MQTT消息',
};

张烨's avatar
张烨 committed
47 48 49
const isIntegerate = (mode, hasIntegerate) => {
  if (typeof mode !== 'undefined') {
    return mode === 'single';
张烨's avatar
张烨 committed
50 51 52 53
  }
  return hasIntegerate;
};

张烨's avatar
张烨 committed
54
export const defaultWebConfigObj = {
55 56
  title: '',
  subtitle: '',
张烨's avatar
张烨 committed
57
  mode: webMode.single,
58 59 60 61 62
  shortcutIcon: '',
  logo: '',
  client: '',
  bannerLogo: '',
  homePage: '',
张烨's avatar
张烨 committed
63 64
  menu: 'banner-left',
  mdi: 'MDI',
65 66 67 68 69 70
  theme: '',
  style: '',
  hideMap: false,
  waterMark: true,
  mapPlan: '',
  qrcode: '',
张烨's avatar
张烨 committed
71
  loginTemplate: 'Default.html',
张烨's avatar
张烨 committed
72
};
张烨's avatar
张烨 committed
73

张烨's avatar
张烨 committed
74 75 76 77 78 79 80 81 82
export const getDefaultGetWebconfig = ({
  initialValues = {},
  hasIntegerate,
  webThemes,
  onGetThemes,
  loginPages,
  onGetLoginPages,
  mapConfigs,
  onGetMapConfig,
Maofei94's avatar
Maofei94 committed
83 84
  products,
  onGetProduct,
张烨's avatar
张烨 committed
85
  isEdit,
张烨's avatar
张烨 committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
}) => {
  const config = {
    title: {
      label: '标题',
      formType: ITEM_TYPE.INPUT,
      allowClear: true,
      placeholder: '请输入标题',
      rules: [
        {
          required: true,
          message: '标题为必填项',
        },
      ],
    },
    subtitle: {
      label: '副标题',
      formType: ITEM_TYPE.INPUT,
      allowClear: true,
    },
张烨's avatar
张烨 committed
105
    mode: {
张烨's avatar
张烨 committed
106 107
      label: '网站类型',
      formType: ITEM_TYPE.SINGLE_RADIO,
张烨's avatar
张烨 committed
108
      initialValue: webMode.single,
张烨's avatar
张烨 committed
109
      disabled: isEdit,
张烨's avatar
张烨 committed
110 111
      options: [
        {
张烨's avatar
张烨 committed
112
          value: webMode.single,
张烨's avatar
张烨 committed
113 114
          children: '一般网站',
        },
张烨's avatar
张烨 committed
115
      ], // .concat(typeContent(hasIntegerate)),
张烨's avatar
张烨 committed
116 117 118 119
    },
    shortcutIcon: {
      label: '系统icon',
      formType: ITEM_TYPE.IMGSHOP,
Maofei94's avatar
Maofei94 committed
120
      picType: 'icon',
张烨's avatar
张烨 committed
121 122 123 124 125 126 127 128 129 130
      rules: [
        {
          required: true,
          message: '请选择图标icon',
        },
      ],
    },
    logo: {
      label: '登录logo',
      formType: ITEM_TYPE.IMGSHOP,
Maofei94's avatar
Maofei94 committed
131
      picType: 'logo',
张烨's avatar
张烨 committed
132 133 134 135 136 137 138
      rules: [
        {
          required: true,
          message: '请选择登录logo',
        },
      ],
    },
张烨's avatar
张烨 committed
139
    bannerLogo: {
张烨's avatar
张烨 committed
140 141
      label: '标题logo',
      formType: ITEM_TYPE.IMGSHOP,
Maofei94's avatar
Maofei94 committed
142
      picType: 'logo',
张烨's avatar
张烨 committed
143 144 145 146 147 148 149 150 151 152
      rules: [
        {
          required: true,
          message: '请选择标题logo',
        },
      ],
    },
    client: {
      label: '虚拟目录',
      formType: ITEM_TYPE.INPUT,
张烨's avatar
张烨 committed
153
      disabled: isEdit,
张烨's avatar
张烨 committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
      allowClear: true,
      size: 'small',
      rules: [
        {
          required: true,
          message: '虚拟目录不能为空',
        },
      ],
    },
    homePage: {
      label: '主页',
      formType: ITEM_TYPE.INPUT,
      allowClear: true,
    },
    loginTemplate: {
      label: '登录模板',
      formType: ITEM_TYPE.SELECT,
      placeholder: '请选择登录模板',
      options: loginPages.map(t => ({
        value: t.value,
        children: t.text,
        key: t.value,
      })),
      onDropdownVisibleChange: onGetLoginPages,
      showSearch: true,
      filterOption: (input, option) =>
        option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
      rules: [
        {
          required: true,
          message: '登录模板必填',
        },
      ],
    },
Maofei94's avatar
Maofei94 committed
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
    // product: {
    //   label: '产品类型',
    //   formType: ITEM_TYPE.SELECT,
    //   placeholder: '请选择产品类型',
    //   options: products.map(t => ({
    //     value: t.ProductName,
    //     children: t.ProductAlias,
    //     key: t.Id,
    //   })),
    //   onDropdownVisibleChange: onGetProduct,
    //   showSearch: false,
    //   filterOption: (input, option) =>
    //     option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
    //   rules: [
    //     {
    //       required: false,
    //       message: '产品类型必填',
    //     },
    //   ],
    // },
Maofei94's avatar
Maofei94 committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
    // theme: {
    //   label: '系统皮肤',
    //   formType: ITEM_TYPE.SELECT,
    //   initialValue: '',
    //   showSearch: true,
    //   filterOption: (input, option) =>
    //     option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
    //   options:
    //     webThemes.map(t => ({
    //       value: t.value,
    //       children: t.text,
    //       key: t.value,
    //     })) || [],
    //   onDropdownVisibleChange: onGetThemes,
    // },
    // style: {
    //   label: '系统风格',
    //   formType: ITEM_TYPE.SELECT,
    //   initialValue: '',
    //   options: Object.keys(
    //     isIntegerate(initialValues.mode, hasIntegerate)
    //       ? integrateStyleData
    //       : singleStyleData,
    //   ).map(k => ({
    //     value: k,
    //     key: k,
    //     children: integrateStyleData[k] || singleStyleData[k],
    //   })),
    // },
张烨's avatar
张烨 committed
237 238 239 240 241 242 243 244 245
    menu: {
      label: '菜单类型',
      formType: ITEM_TYPE.SINGLE_RADIO,
      options: Object.keys(menuStyle).map(k => ({
        value: k,
        key: k,
        children: menuStyle[k],
      })),
    },
Maofei94's avatar
Maofei94 committed
246 247 248 249 250 251 252 253 254
    // mdi: {
    //   label: '功能标签',
    //   formType: ITEM_TYPE.SINGLE_RADIO,
    //   options: Object.keys(MDILabel).map(k => ({
    //     value: k,
    //     key: k,
    //     children: MDILabel[k],
    //   })),
    // },
张烨's avatar
张烨 committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268
    qrcode: {
      label: '二维码地址',
      formType: ITEM_TYPE.INPUT,
      allowClear: true,
    },
    alarmWays: {
      label: '通知方式',
      formType: ITEM_TYPE.CHECK_BOX,
      options: Object.keys(notificationTypes).map(k => ({
        value: k,
        key: k,
        children: notificationTypes[k],
      })),
    },
Maofei94's avatar
Maofei94 committed
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
    // mapPlan: {
    //   label: '地图方案',
    //   formType: ITEM_TYPE.SELECT,
    //   options: mapConfigs.map(m => ({
    //     value: m.value,
    //     children: m.text,
    //     key: m.value,
    //   })),
    //   onDropdownVisibleChange: onGetMapConfig,
    // },
    // hideMap: {
    //   label: '按需加载地图',
    //   formType: ITEM_TYPE.SINGLE_RADIO,
    //   optionType: 'button',
    //   options: [
    //     {
    //       value: true,
    //       key: '1',
    //       children: '是',
    //     },
    //     {
    //       value: false,
    //       key: '2',
    //       children: '否',
    //     },
    //   ],
    // },
    // waterMark: {
    //   label: '地图水印',
    //   formType: ITEM_TYPE.SINGLE_RADIO,
    //   options: [
    //     {
    //       value: true,
    //       key: '1',
    //       children: '显示',
    //     },
    //     {
    //       value: false,
    //       key: '2',
    //       children: '不显示',
    //     },
    //   ],
    // },
张烨's avatar
张烨 committed
312
  };
张烨's avatar
张烨 committed
313 314
  if (initialValues) {
    Object.keys(config).forEach(k => {
张烨's avatar
张烨 committed
315 316
      config[k].initialValue =
        typeof initialValues[k] !== 'undefined' ? initialValues[k] : '';
Maofei94's avatar
Maofei94 committed
317 318 319
      // if (k === 'alarmWays') {
      //   config[k].initialValue = config[k].initialValue.split(',');
      // }
张烨's avatar
张烨 committed
320 321 322 323 324 325 326 327 328 329 330 331 332
      // if (k === 'mode' && initialValues.mode) {
      //   config[k].options = [
      //     {
      //       value: webMode.single,
      //       children: '一般网站',
      //     },
      //     // {
      //     //   value: webMode.integration,
      //     //   children: '集成网站',
      //     // },
      //   ];
      //   config[k].initialValue = webMode.single; // initialValues.mode;
      // }
张烨's avatar
张烨 committed
333 334
    });
  }
张烨's avatar
张烨 committed
335 336
  return config;
};