question.js 29.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 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 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
const option_name = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];
var init_count = 0;
var fa_form;

define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'exam/question/index' + location.search,
                    add_url: 'exam/question/add',
                    edit_url: 'exam/question/edit',
                    del_url: 'exam/question/del',
                    multi_url: 'exam/question/multi',
                    import_url: 'exam/question/import',
                    table: 'exam_question',
                }
            });

            var table = $("#table");
            //在普通搜索渲染后
            table.on('post-common-search.bs.table', function (event, table) {
                let form = $("form", table.$commonsearch);
                $("input[name='cate_id']", form).addClass("selectpage").data("source", "exam/cate/selectpage").data("params", {"custom[kind]": "QUESTION","isTree":true}).data("orderBy", "sort desc");
                // $("input[name='is_material_child']", form).val(0);
                // $("input[name='exam_type_id']", form).addClass("selectpage").data("source", "exam_type/index").data("orderBy", "sort desc");

                Form.events.cxselect(form);
                Form.events.selectpage(form);
            });

            //当内容渲染完成给编辑按钮添加`data-area`属性,点击列表编辑按钮时全屏
            table.on('post-body.bs.table', function (e, settings, json, xhr) {
                $(".btn-add").data("area", ["100%", "100%"]);
                $(".btn-editone").data("area", ["100%", "100%"]);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                showExport: false,//隐藏导出
                showToggle: false,//隐藏浏览模式
                showColumns: false,//隐藏显示隐藏模式
                searchFormVisible: true,//默认显示搜索表单
                escape:false,//false解析html,默认为true不解析
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'cate_id', title: __('Cate_id'), autocomplete: false, visible: false},
                        {field: 'cate.name', title: __('Cate_id'), operate: false},
                        // {field: 'exam_type_id', title: __('Exam_type_id'), visible: false},
                        // {field: 'examtype.name', title: __('Exam_type_id'), operate: false},
                        {
                            field: 'kind',
                            title: __('Kind'),
                            searchList: {"JUDGE": __('Judge'), "SINGLE": __('Single'), "MULTI": __('Multi'), "FILL": __('Fill'), "SHORT": __('Short'), "MATERIAL": __('Material')},
                            formatter: Table.api.formatter.normal,
                            // operate: "IN",
                        },
                        {field: 'title', title: __('Title'), autocomplete: false, operate: 'LIKE', formatter: Table.api.formatter.content},
                        {
                          field: 'is_material_child',
                          title: __('属于材料题子题'),
                          searchList: {"0": __('否'), "1": __('是')},
                          defaultValue: 0,
                          visible: false
                        },
                        {
                            field: 'difficulty',
                            title: __('Difficulty'),
                            searchList: {"EASY": __('Easy'), "GENERAL": __('General'), "HARD": __('Hard')},
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'answer', title: __('Answer'), halign: 'center', align: 'left', operate: false, formatter: function (value, row, index) {
                                var answer = value;
                                if (row.kind == 'FILL') {
                                    try {
                                        answer = '';
                                        let fill_answers = JSON.parse(row.answer);
                                        for (let i = 0; i < fill_answers.length; i++) {
                                            answer += '填空位' + (i + 1) + ':' + fill_answers[i].answers.join('、') + '<br>';
                                        }
                                    } catch (e) {
                                        console.log('answer', index, answer, e);
                                        return value;
                                    }
                                } else if (row.kind == 'SHORT') {
                                    try {
                                        let short_answers = JSON.parse(row.answer);
                                        answer = '标准答案:' + short_answers.answer + '<br>';
                                        for (let i = 0; i < short_answers.config.length; i++) {
                                            // answer += '关键词' + (i + 1) + ':' + short_answers[i].answer + '<br>';
                                            answer += '关键词' + (i + 1) + ':' + short_answers.config[i].answer + '(' + short_answers.config[i].score + '分)<br>';
                                        }
                                    } catch (e) {
                                        console.log('short answer', index, answer, e);
                                        return value;
                                    }
                                } else if (row.kind == 'MATERIAL') {
                                    return '-';
                                }

                                console.log('answer', value, answer);
                                return answer;
                            }
                        },
                        {
                            field: 'status',
                            title: __('Status'),
                            searchList: {"NORMAL": __('Normal'), "HIDDEN": __('Hidden')},
                            formatter: Table.api.formatter.status,
                            operate: false
                        },
                        /*{
                            field: 'createtime',
                            title: __('Createtime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },*/
                        /*{
                            field: 'updatetime',
                            title: __('Updatetime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },*/

                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

            // 打开导入页面
            $('.btn-importPage').click(function () {
                Fast.api.open('exam/question/import', '导入试题', {
                    area: ['800px', '380px'],
                    callback: function (data) {
                        table.bootstrapTable('refresh');
                    }
                });
            });
        },
        recyclebin: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'exam/question/recyclebin' + location.search,
                pk: 'id',
                sortName: 'id',
                escape:false,//false解析html,默认为true不解析
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'title', title: __('Title'), align: 'left', formatter: Table.api.formatter.content},
                        {
                            field: 'deletetime',
                            title: __('Deletetime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'operate',
                            width: '130px',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'Restore',
                                    text: __('Restore'),
                                    classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
                                    icon: 'fa fa-rotate-left',
                                    url: 'exam/question/restore',
                                    refresh: true
                                },
                                {
                                    name: 'Destroy',
                                    text: __('Destroy'),
                                    classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
                                    icon: 'fa fa-times',
                                    url: 'exam/question/destroy',
                                    refresh: true
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            fa_form = Form
            Controller.api.bindevent();
            $('input[name="row[kind]"]')[0].click()
            setTimeout(() => {
                optionCtrl(Form);
                init_count++;
            }, 500)
        },
        edit: function () {
            Controller.api.bindevent();
            optionCtrl(Form, 'edit');
            init_count++;
        },
        image: function () {
            // Controller.api.bindevent();
            Form.api.bindevent($("form[role=form]"), function (data, ret) {
                let img = $('#c-imgs').val();
                if (!img) {
                    Toastr.warning('未上传图片文件');
                }

                Fast.api.close(img);
            }, function (data, ret) {
                Toastr.error("失败");
            });
        },
        import: function () {
            Controller.api.bindevent();

            // 手动绑定导入事件
            Upload.api.upload($('.btn-import'), function (data, ret) {
                let cate = $('#c-cate_id').val();
                // let exam_type = $('#c-exam_type_id').val();

                if (!cate) { //  || !exam_type
                    Fast.api.msg('请先选择所属类型及考试分类再进行上传!')
                    return false;
                }

                $('#file_url').val(data.url);
                Fast.api.ajax({
                    url: 'exam/question/importExcel',
                    data: {
                        file: data.url,
                        cate: cate,
                        // exam_type: exam_type
                    },
                }, function (data, ret) {
                    console.log(data, ret)
                    $('#question_count').html(`本次上传识别到 ${data.count} 道题`)
                });
            });

            $('#test').click(function () {
                Fast.api.ajax({
                    url: 'exam/question/test',
                }, function (data, ret) {
                    console.log(data, ret)
                    return false
                })
            })
        },
        // 选择题目页面
        select: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'exam/question/select' + location.search,
                    // add_url: 'exam/question/add',
                    // edit_url: 'exam/question/edit',
                    // del_url: 'exam/question/del',
                    // multi_url: 'exam/question/multi',
                    // import_url: 'exam/question/import',
                    table: 'exam_question',
                }
            });

            var table = $("#table");
            //在普通搜索渲染后
            table.on('post-common-search.bs.table', function (event, table) {
                let form = $("form", table.$commonsearch);
                $("input[name='cate_id']", form).addClass("selectpage").data("source", "exam/cate/selectpage").data("params", {"custom[kind]": "QUESTION"}).data("orderBy", "sort desc");
                // $("input[name='exam_type_id']", form).addClass("selectpage").data("source", "exam_type/index").data("orderBy", "sort desc");

                Form.events.cxselect(form);
                Form.events.selectpage(form);
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                showExport: false,//隐藏导出
                showToggle: false,//隐藏浏览模式
                showColumns: false,//隐藏显示隐藏模式
                searchFormVisible: true,//默认显示搜索表单
                escape:false,//false解析html,默认为true不解析
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'cate_id', title: __('Cate_id'), autocomplete: false, visible: false},
                        {field: 'cate.name', title: __('Cate_id'), operate: false},
                        {
                            field: 'kind',
                            title: __('Kind'),
                            searchList: {"JUDGE": __('Judge'), "SINGLE": __('Single'), "MULTI": __('Multi'), "FILL": __('Fill'), "SHORT": __('Short'), "MATERIAL": __('Material')},
                            formatter: Table.api.formatter.normal
                        },
                        {field: 'title', title: __('Title'), autocomplete: false, operate: 'LIKE', formatter: Table.api.formatter.content},
                        {
                            field: 'difficulty',
                            title: __('Difficulty'),
                            searchList: {"EASY": __('Easy'), "GENERAL": __('General'), "HARD": __('Hard')},
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'answer', title: __('Answer'), halign: 'center', align: 'left', operate: false, formatter: function (value, row, index) {
                                var answer = value;
                                // 填空题
                                if (row.kind == 'FILL') {
                                    try {
                                        answer = '';
                                        let fill_answers = JSON.parse(row.answer);
                                        for (let i = 0; i < fill_answers.length; i++) {
                                            answer += '填空位' + (i + 1) + ':' + fill_answers[i].answers.join('、') + '<br>';
                                        }
                                    } catch (e) {
                                        console.log('fill answer', index, answer, e);
                                        return value;
                                    }
                                } else if (row.kind == 'SHORT') {
                                    try {
                                        answer = '';
                                        let short_answers = JSON.parse(row.answer);
                                        for (let i = 0; i < short_answers.length; i++) {
                                            // answer += '关键词' + (i + 1) + ':' + short_answers[i].answer + '<br>';
                                            answer += '关键词' + (i + 1) + ':' + short_answers[i].answer + '(' + short_answers[i].score + '分)<br>';
                                        }
                                    } catch (e) {
                                        console.log('short answer', index, answer, e);
                                        return value;
                                    }
                                }

                                return answer;
                            }
                        },
                        {
                            field: 'status',
                            title: __('Status'),
                            searchList: {"NORMAL": __('Normal'), "HIDDEN": __('Hidden')},
                            formatter: Table.api.formatter.status,
                            operate: false
                        },
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

            // 批量确认选择
            $('.btn-confirm-choose').click(function () {
                // Table.api.select
                // var ids = Table.api.selectedids(table);//获取选中列的id
                // if (ids.length == 0){
                //     layer.alert("请选择题目");
                //     return false;
                // }

                var rows = $("#table").bootstrapTable('getSelections');
                console.log('select questions', rows, rows.length, 'length')
                if (rows.length == 0){
                    layer.alert("请选择题目");
                    return false;
                }

                Fast.api.close(rows);
            });
        },
        api: {
            bindevent: function () {
                Form.api.bindevent(
                    $("form[role=form]"),

                    () => {
                        console.log('success', this)
                    },
                    () => {
                        console.log('fail', this)
                    },
                    () => {
                        console.log('submit', this, valid_result)
                        // 触发验证
                        $('#valid').click()
                        return valid_result;
                    },

                );

                // 题库和材料题联动
                $('#c-cate_id').on('change', function () {
                    $("#c-material_question_id").selectPageClear()
                });
                $("#c-material_question_id").data("params", function () {
                    const cate_id = $("input[name='row[cate_id]']").val();
                    return {
                        custom: {
                            cate_id: cate_id,
                            kind: 'MATERIAL',
                        }
                    }
                });
            }
        }
    };
    return Controller;
});

function optionCtrl(Form, type = 'add') {
    console.log('init_count', init_count)
    if (init_count > 0) {
        return;
    }

    $('.btn-append').html('<i class="fa fa-plus"></i> 添加选项');
    // 添加选项
    $(document).on("fa.event.appendfieldlist", '[data-name="row[options_json]"] .btn-append', function () {
        console.log('append xxx')
        $('.btn-dragsort').hide();
        let dd = $('dd[class="form-inline"]');
        let options_img = $('#c-options_img');
        let question_num = dd.length;
        if (question_num > 8) {
            Toastr.error('选项不能超过8个');
            // $('input[name="row[options_json]['+question_num+'][value]"]').next().click();
            // $('input[name="row[options_json]['+question_num+'][value]"]').parent().remove();
            dd[question_num - 1].remove();
            return false;
        }

        // 重排选项名称
        sortOptions();
        // 删除选项
        bindRemoveOption();

        // 添加上传图片控件
        // $(dd[question_num - 1]).append(imageUploadHtml('row[options_json][' + (question_num - 1) + '][image]'));
        // $(dd[question_num - 1]).append(editorHtml('row[options_json][' + (question_num - 1) + '][image]'));
        // Form.api.bindevent($("form[role=form]"));
        // 添加设为答案按钮
        $(dd[question_num - 1]).append('<span class="btn btn-sm btn-info btn-set m-l-5" data-type="SET">设为答案</span>');
        // 添加上传图片按钮
        $(dd[question_num - 1]).append('<span class="btn btn-sm btn-success btn-image m-l-5" data-type="UPLOAD" id="upload_' + (question_num - 1) + '" data-id="' + (question_num - 1) + '">上传图片</span>');

        if (options_img.val()) {
            let option_img_json = JSON.parse(options_img.val())

            if(option_img_json) {
                option_img_json.forEach((item) => {
                    let index = option_name.indexOf(item.key)
                    // 不知为啥会执行两次
                    if ($('.option-preview-' + index).length === 0) {
                        $(dd[index]).append(previewHtml(index, item.value));
                    }
                })
            }
        }

        bindSetAnswer();
        bindUploadImage();

        if (type === 'edit') {
            initEditBtn()
        }
    });
}

// 编辑时处理按钮文本
function initEditBtn() {
    let answer = $('#c-answer').val()
    if (!answer) return

    console.log('initEditBtn answer', answer)
    $('.btn-set').each(function (index, ele) {
        const key = $($(ele).parent().find('input')[0]).val()
        console.log('initEditBtn key', key)
        if (key && answer.indexOf(key) > -1) {
            $(ele).removeClass('btn-info').addClass('btn-warning').text('取消答案').data('type', 'CANCEL')
        }
    })
}

// 监听删除选项按钮事件
function bindRemoveOption() {
    $('.btn-remove').click(function () {
        //延迟重排选项名称
        setTimeout(() => {
            sortOptions();
        }, 300);
    });
}

// 监听设为答案按钮事件
function bindSetAnswer() {
    $('.btn-set').unbind('click').click(function () {
        let type = $(this).data('type');
        let name = $($(this).parent().children('input')[0]).val();
        let answer_type = getAnswerType();
        let c_answer = $('#c-answer');
        // 设为答案
        if (type === 'SET') {
            // 单选
            if (answer_type === 'SINGLE' || !c_answer.val()) {
                c_answer.val(name);

                $('.btn-set').removeClass('btn-warning').addClass('btn-info').text('设为答案').data('type', 'SET');
                $(this).removeClass('btn-info').addClass('btn-warning').text('取消答案').data('type', 'CANCEL');
            } else {// 多选
                let answers = c_answer.val();
                let answer_arr = answers.split(',');

                answer_arr.push(name);
                answer_arr = unique(answer_arr);
                c_answer.val(answer_arr.join(','));

                $(this).removeClass('btn-info').addClass('btn-warning').text('取消答案').data('type', 'CANCEL');
            }
        } else {// 取消答案
            // 单选
            if (answer_type === 'SINGLE') {
                if (c_answer.val() === name) {
                    c_answer.val('');
                    $(this).removeClass('btn-warning').addClass('btn-info').text('设为答案').data('type', 'SET');
                }
            } else {// 多选
                let answers = c_answer.val();
                let answer_arr = answers.split(',');
                answer_arr = answer_arr.filter(function (item) {
                    return item !== name;
                });
                console.log(answer_arr);
                c_answer.val(answer_arr.join(','));

                $(this).removeClass('btn-warning').addClass('btn-info').text('设为答案').data('type', 'SET');
            }
        }
    });
}

// 监听上传图片按钮事件
function bindUploadImage() {
    $('.btn-image').unbind('click').click(function () {
        let index = $(this).data('id')
        Fast.api.open('exam/question/image', '选项图片', {
            area: ['500px', '300px'],
            callback: function (data) {
                if (!data) {
                    return
                }
                // if ($($('dd[class="form-inline"]')[index]).find('.plupload-preview').length > 0) {
                //     return
                // }

                // 加预览图
                $($('dd[class="form-inline"]')[index]).append(previewHtml(index, data))
                // 赋值图片数据
                $('#c-options_img').html(JSON.stringify(getAllPreview()))

                bindDeleteImage()
            }
        })
    });

    bindDeleteImage()
}

// 删除图片按钮事件
function bindDeleteImage() {
    $('.btn-option-img-trash').unbind('click').click(function () {
        let index = $(this).data('id')
        $('#c-option_preview_' + index).remove()
        // 赋值图片数据
        $('#c-options_img').html(JSON.stringify(getAllPreview()))
    });
}

// 重排选项名称
function sortOptions() {
    $('dd[class="form-inline"]').each(function (index, ele) {
        console.log(option_name[index]);
        // 配置选项名并设为只读
        $($(this).find('.form-control')[0]).val(option_name[index]).attr('readonly', 'readonly');
    });
}

function unique(arr) {
    arr.sort();
    let newArr = [arr[0]];
    for (let i = 1; i < arr.length; i++) {
        if (arr[i] !== newArr[newArr.length - 1]) {
            newArr.push(arr[i]);
        }
    }
    return newArr;
}

function getAnswerType() {
    let kind = $('input[type="radio"][name="row[kind]"]:checked').val();
    return kind === 'MULTI' ? 'MULTI' : 'SINGLE';
}

function getAllPreview() {
    let options_img = []

    $('.option-preview').each(function (index, ele) {
        index = $(ele).data('id')
        options_img.push({
            key: getOptionNameByIndex(index),
            value: $(this).data('url')
        })
    })

    return options_img
}

function getOptionNameByIndex(index) {
    console.log('getOptionNameByIndex', index)
    return $($($('dd[class="form-inline"]')[index]).find('.form-control')[0]).val();
}

function previewHtml(id, value) {
    let cdnurl = Fast.api.cdnurl(value)
    return '<ul class="row list-inline plupload-preview option-preview-' + id + '" data-listidx="0" id="c-option_preview_' + id + '">' +
        '<li class="col-xs-3">' +
        '<a href="' + value + '" data-url="' + value + '" data-id="' + id + '" target="_blank" class="thumbnail option-preview">' +
        '<img src="' + cdnurl + '" class="img-responsive">' +
        '</a>' +
        '<a href="javascript:;" class="btn btn-danger btn-xs btn-trash btn-option-img-trash" data-id="' + id + '"><i class="fa fa-trash"></i></a>' +
        '</li>' +
        '</ul>';
}

function editorHtml(id, value) {
    return '<textarea id="' + id + '" class="form-control editor" name="' + id + '" value="' + value + '" ></textarea>';
}

function imageUploadHtml(id) {
    let html = '<div class="input-group" data-attr="image-upload">'
    html += '<input id="' + id + '" class="form-control" name="row[' + id + ']" size="300" type="text" >';
    html += '<div class="input-group-addon no-border no-padding">';
    html += '<span><button type="button" id="plupload-' + id + '" class="btn btn-danger plupload" data-input-id="' + id + '" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-' + id + '"><i class="fa fa-upload"></i> 上传</button></span>';
    html += '<span><button type="button" id="fachoose-image_url" class="btn btn-primary fachoose" data-input-id="' + id + '" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>';
    html += '</div>';
    html += '<span class="msg-box n-right" for="' + id + '"></span>';
    html += '</div>';
    html += '<ul class="row list-inline plupload-preview" id="p-' + id + '"></ul>';
    return html;
}