123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=no,
- width=device-width,initial-scale=1.0">
- <title>问卷调查</title>
- <!-- import CSS -->
- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
- </head>
- <style>
- .tpl_title {
- font-size: 18px;
- margin-bottom: 20px;
- }
- .el-form-item__label{
- float:none;
- }
- </style>
- <body>
- <div id="app">
- <div class="item-main">
- <img src="static/survey_logo.png" alt="" class="survey_logo" />
- <h5 align="center" class="tpl_title">{{ title }}</h5>
- <el-form ref="form" :model="form2" class="tpl_form over_y">
- <el-form-item
- v-for="(item, index) in widgetList"
- :key="index"
- :label="item.label"
- >
- <el-input
- v-if="item.type == 'input'"
- v-model="form2[item.label]"
- :placeholder="item.placeholder"
- ></el-input>
- <el-input
- v-if="item.type == 'textarea'"
- type="textarea"
- v-model="form2[item.label]"
- :placeholder="item.placeholder"
- ></el-input>
- <el-radio-group
- v-if="item.type == 'radio'"
- v-model="form2[item.label]"
- >
- <el-radio
- :label="iitem.label"
- v-for="(iitem, index) in item.items"
- :key="index"
- >{{ iitem.label }}</el-radio
- >
- </el-radio-group>
- <el-checkbox-group
- v-else-if="item.type == 'checkbox'"
- v-model="form2[item.label]"
- >
- <el-checkbox
- :label="iitem.label"
- v-for="(iitem, index) in item.items"
- :key="index"
- ></el-checkbox>
- </el-checkbox-group>
- <el-upload
- v-if="item.type == 'image'"
- action="/api/admin/uploadfile"
- list-type="picture-card"
- :data="{ type: item.label }"
- :on-success="handleSuccess"
- >
- <i class="el-icon-plus"></i>
- </el-upload>
- <el-upload
- v-if="item.type == 'file'"
- class="upload-demo"
- ref="upload"
- action="/api/admin/uploadfile"
- :data="{ type: item.label }"
- :on-success="handleSuccess"
- >
- <!-- <el-button slot="trigger" size="small" type="primary">选取文件</el-button> -->
- <el-button
- style="margin-left: 10px"
- size="small"
- type="primary"
- plain
- >添加文件</el-button
- >
- <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
- </el-upload>
- </el-form-item>
- <el-form-item v-if="widgetList.length">
- <el-button
- size="medium"
- type="primary"
- @click="saveResult"
- style="width: 100%"
- >提交</el-button
- >
- </el-form-item>
- </el-form>
- </div>
- </div>
- </body>
- <!-- import Vue before Element -->
- <script src="static/jquery.min.js"></script>
- <script src="static/vue.js"></script>
- <!-- import JavaScript -->
- <script src="https://unpkg.com/element-ui/lib/index.js"></script>
- <script>
- new Vue({
- el: '#app',
- data: function() {
- return {
- form2:{
-
- },
- widgetList:[],
- id:'',
- title:'',
- show:0
- }
- },
- methods:{
- getData(){
- $.ajax({
- url:'https://test.scxjc.club/api/admin/message',
- method:'get',
- data:{
- id:this.id
- },
- success:res=>{
- let widgetList=res.data.widget;
- for(let i=0;i<widgetList.length;i++){
- if(widgetList[i].type=='checkbox'){
- let key = widgetList[i].label
- this.$set(this.form2, key, [])
- }
- }
- this.title = res.data.name
- this.widgetList=widgetList
- }
- })
- },
- saveResult(){
- let result = JSON.stringify(this.form2);
- $.ajax({
- url:'/api/admin/message/survey/result',
- method:'post',
- data:{
- message_id: this.id,
- result: result,
- },
- success:res=>{
- if (res.code == 0) {
- //this.$message({
- // type: "success",
- // message: "保存成功!",
- //});
- alert("保存成功!")
- } else {
- //this.$message.error("保存失败!");
- alert("保存成功!")
- }
- this.form2 = {}
- }
- })
- },
- handleSuccess(res, file) {
- this.form2[res.data.type] = res.data.url;
- },
- },
- created(){
- var search=window.location.search.split('?')[1].split('&');
- this.id=search[0].split('=')[1]
- this.getData()
- }
- })
- </script>
- </html>
|