index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div class="rightBox">
  3. <div class="title">
  4. <div class="c_info_title">创建表单内容</div>
  5. </div>
  6. <div class="edit_top">
  7. <div class="edit_btn">
  8. <span class="edit" :class="{ active: type == 1 }" @click="type = 1">编辑</span>
  9. <span class="check" :class="{ active: type == 2 }" @click="type = 2">预览</span>
  10. <!-- <span :class="{ active: type == 3 }" @click="type = 3">回答</span>
  11. <span :class="{ active: type == 4 }" @click="type = 4">统计</span> -->
  12. </div>
  13. <div class="op_btn">
  14. <el-button type="primary" size="small" @click="lastSteps">上一步</el-button>
  15. <el-button type="primary" size="small" @click="save">保存</el-button>
  16. <el-button type="primary" size="small" @click="publish">发布</el-button>
  17. </div>
  18. </div>
  19. <div class="e_box">
  20. <editBox v-if="type == 1" :checkJson="checkJson" @changeJson="changeJson" :title="title"></editBox>
  21. <checkBox v-if="type == 2" :cJson="checkJson" :title="title"></checkBox>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import editBox from './edit/index.vue'
  27. import checkBox from './check/index.vue'
  28. export default {
  29. components: {
  30. editBox,
  31. checkBox
  32. },
  33. props: {
  34. title: {
  35. type: String
  36. },
  37. testType: {
  38. type: Array
  39. },
  40. see: {
  41. type: Boolean
  42. },
  43. steps: {
  44. type: Number
  45. },
  46. cJson: {
  47. type: Array
  48. }
  49. },
  50. data() {
  51. return {
  52. type: 1,
  53. checkJson: [],
  54. }
  55. },
  56. watch: {
  57. cJson: {
  58. handler: function (newVal, oldVal) {
  59. this.checkJson = this.depthCopy(newVal);
  60. },
  61. deep: true,
  62. },
  63. },
  64. methods: {
  65. lastSteps() {
  66. this.$emit('update:steps', this.steps - 1)
  67. },
  68. save() {
  69. this.$emit("save", 4)
  70. },
  71. publish() {
  72. this.$emit("publish")
  73. },
  74. depthCopy(s) {
  75. return s ? JSON.parse(JSON.stringify(s)) : ''
  76. },
  77. changeJson(json) {
  78. console.log(json);
  79. this.$emit("update:cJson", json);
  80. }
  81. },
  82. mounted() {
  83. this.checkJson = this.depthCopy(this.cJson);
  84. },
  85. }
  86. </script>
  87. <style scoped>
  88. .c_info_title {
  89. padding: 15px 0 15px 0;
  90. font-size: 16px;
  91. font-weight: bold;
  92. margin: 0 0 0 0;
  93. box-sizing: border-box;
  94. display: flex;
  95. align-items: center;
  96. line-height: 20px;
  97. }
  98. .c_info_title::before {
  99. content: '';
  100. display: block;
  101. width: 3px;
  102. height: 20px;
  103. background: #0061FF;
  104. border-radius: 3px;
  105. margin: 0 5px 0 0;
  106. }
  107. .rightBox {
  108. width: calc(100%);
  109. /* background: #F0F2F5; */
  110. background: #fff;
  111. overflow: auto;
  112. height: calc(100%);
  113. margin: 0 auto;
  114. position: relative;
  115. box-sizing: border-box;
  116. }
  117. .rightBox>.title {
  118. background: #fff;
  119. width: 100%;
  120. padding: 0 20px 0;
  121. box-sizing: border-box;
  122. }
  123. .edit_top {
  124. height: 50px;
  125. background: #fff;
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. position: relative;
  130. }
  131. .edit_top>.edit_btn {
  132. display: flex;
  133. height: 40px;
  134. align-items: center;
  135. border: 1px solid #E5E5E5;
  136. box-sizing: border-box;
  137. padding: 4px;
  138. border-radius: 4px;
  139. }
  140. .edit_top>.edit_btn>span {
  141. cursor: pointer;
  142. padding-bottom: 5px;
  143. display: block;
  144. width: 90px;
  145. padding: 0 15px;
  146. height: 100%;
  147. font-size: 14px;
  148. box-sizing: border-box;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. border-radius: 4px;
  153. }
  154. .edit_top>.edit_btn>.active {
  155. color: #3e88f4;
  156. /* border-bottom: 2px solid #2f80f3; */
  157. background: rgb(224, 234, 251);
  158. }
  159. .edit_top>.edit_btn>span+span {
  160. margin-left: 10px;
  161. }
  162. .edit_top>.edit_btn>span::before {
  163. content: '';
  164. display: block;
  165. background-size: 100% 100%;
  166. margin-right: 8px;
  167. }
  168. .edit_top>.edit_btn>.check::before {
  169. width: 15px;
  170. height: 15px;
  171. background-image: url(../../../../../assets/icon/test/add_check_icon.png);
  172. }
  173. .edit_top>.edit_btn>.edit::before {
  174. width: 15px;
  175. height: 16px;
  176. background-image: url(../../../../../assets/icon/test/add_edit_icon.png);
  177. }
  178. .edit_top>.edit_btn>.active.check::before {
  179. background-image: url(../../../../../assets/icon/test/add_check_icon_active.png);
  180. }
  181. .edit_top>.edit_btn>.active.edit::before {
  182. background-image: url(../../../../../assets/icon/test/add_edit_icon_active.png);
  183. }
  184. .edit_top>.op_btn {
  185. position: absolute;
  186. right: 30px;
  187. }
  188. .e_box {
  189. height: calc(100% - 135px);
  190. width: calc(100% - 40px);
  191. overflow: hidden;
  192. /* background: rgb(196, 226, 241); */
  193. background: #fff;
  194. border: 1px solid #E5E5E5;
  195. -webkit-box-sizing: border-box;
  196. box-sizing: border-box;
  197. margin: 15px auto 0;
  198. border-radius: 5px;
  199. }</style>