index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. this.$emit("update:cJson", json);
  79. }
  80. },
  81. mounted() {
  82. this.checkJson = this.depthCopy(this.cJson);
  83. },
  84. }
  85. </script>
  86. <style scoped>
  87. .c_info_title {
  88. padding: 15px 0 15px 0;
  89. font-size: 16px;
  90. font-weight: bold;
  91. margin: 0 0 0 0;
  92. box-sizing: border-box;
  93. display: flex;
  94. align-items: center;
  95. line-height: 20px;
  96. }
  97. .c_info_title::before {
  98. content: '';
  99. display: block;
  100. width: 3px;
  101. height: 20px;
  102. background: #0061FF;
  103. border-radius: 3px;
  104. margin: 0 5px 0 0;
  105. }
  106. .rightBox {
  107. width: calc(100%);
  108. /* background: #F0F2F5; */
  109. background: #fff;
  110. overflow: auto;
  111. height: calc(100%);
  112. margin: 0 auto;
  113. position: relative;
  114. box-sizing: border-box;
  115. }
  116. .rightBox>.title {
  117. background: #fff;
  118. width: 100%;
  119. padding: 0 20px 0;
  120. box-sizing: border-box;
  121. }
  122. .edit_top {
  123. height: 50px;
  124. background: #fff;
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. position: relative;
  129. }
  130. .edit_top>.edit_btn {
  131. display: flex;
  132. height: 40px;
  133. align-items: center;
  134. border: 1px solid #E5E5E5;
  135. box-sizing: border-box;
  136. padding: 4px;
  137. border-radius: 4px;
  138. }
  139. .edit_top>.edit_btn>span {
  140. cursor: pointer;
  141. padding-bottom: 5px;
  142. display: block;
  143. width: 90px;
  144. padding: 0 15px;
  145. height: 100%;
  146. font-size: 14px;
  147. box-sizing: border-box;
  148. display: flex;
  149. align-items: center;
  150. justify-content: center;
  151. border-radius: 4px;
  152. }
  153. .edit_top>.edit_btn>.active {
  154. color: #3e88f4;
  155. /* border-bottom: 2px solid #2f80f3; */
  156. background: rgb(224, 234, 251);
  157. }
  158. .edit_top>.edit_btn>span+span {
  159. margin-left: 10px;
  160. }
  161. .edit_top>.edit_btn>span::before {
  162. content: '';
  163. display: block;
  164. background-size: 100% 100%;
  165. margin-right: 8px;
  166. }
  167. .edit_top>.edit_btn>.check::before {
  168. width: 15px;
  169. height: 15px;
  170. background-image: url(../../../../../assets/icon/test/add_check_icon.png);
  171. }
  172. .edit_top>.edit_btn>.edit::before {
  173. width: 15px;
  174. height: 16px;
  175. background-image: url(../../../../../assets/icon/test/add_edit_icon.png);
  176. }
  177. .edit_top>.edit_btn>.active.check::before {
  178. background-image: url(../../../../../assets/icon/test/add_check_icon_active.png);
  179. }
  180. .edit_top>.edit_btn>.active.edit::before {
  181. background-image: url(../../../../../assets/icon/test/add_edit_icon_active.png);
  182. }
  183. .edit_top>.op_btn {
  184. position: absolute;
  185. right: 30px;
  186. }
  187. .e_box {
  188. height: calc(100% - 135px);
  189. width: calc(100% - 40px);
  190. overflow: hidden;
  191. /* background: rgb(196, 226, 241); */
  192. background: #fff;
  193. border: 1px solid #E5E5E5;
  194. -webkit-box-sizing: border-box;
  195. box-sizing: border-box;
  196. margin: 15px auto 0;
  197. border-radius: 5px;
  198. }</style>