forked from nsjcy/frontEnd/nsjcy

Mr Ke
2020-05-15 e36d04fc335547bc293078a77924c94a31e99cdc
发布问卷做问卷总分值100的最大限制
1 files modified
16 ■■■■■ changed files
SunshineIns/src/page/Newly.jsx 16 ●●●●● patch | view | raw | blame | history
SunshineIns/src/page/Newly.jsx
@@ -143,7 +143,6 @@
      loading: true
    });
    Fetch.questionFindById(id).then(res => {
      console.log('res', res);
      res.questionDtos = res.questionDtos && res.questionDtos.length ? res.questionDtos.map((item) => ({
        ...item,
        remark: true
@@ -165,9 +164,24 @@
    if (!extraData.questionnairBusinessType) {
      return message.error('请选择业务类型');
    }
    let sum = questionDtos.reduce((p, n) => {
      if (n.type == 'radio') {
        return p.concat(Math.max.apply(null, n.scores))
      } else {
        return p.concat(n.scores)
      }
    }, []).reduce(function (prev, curr, idx, arr) {
      return Number(prev) + Number(curr);
    });
    console.log('总分值', sum);
    if (sum > 100) {
      return message.error('分值超过最大值,请重新设定分值');
    }
    questionDtos = questionDtos.map(({ type, title, required, remarkText, options, scores, warnFlag }) => ({
      type, title, required, remarkText, options, scores, warnFlag
    }));
    this.setState({
      btnLoading: true
    })