check.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="check_box">
  3. <div class="check_div" v-for="(item, index) in checkData" :key="index">
  4. <div class="check_div_title">
  5. <div class="check_div_open" :class="{ active: item.open}" @click="openC(index)"></div>
  6. <div class="check_div_name">{{ item.name }}</div>
  7. </div>
  8. <div class="check_div_children" v-show="item.open">
  9. <div class="check_div_child" v-for="(item2) in item.children" :key="item2.type" @click="addCheck(item2)">
  10. <div class="check_icon">
  11. <img :src="item2.icon" alt="">
  12. </div>
  13. <div class="check_div_child_name">{{ item2.name }}</div>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. // import u_arrow from '../../../../assets/icon/new/u_arrow.png'
  21. import icon_check_addUser from '../../../../assets/icon/englishVoice/icon_check_addUser.png'
  22. import icon_check_qa from '../../../../assets/icon/englishVoice/icon_check_qa.png'
  23. import icon_check_sentence from '../../../../assets/icon/englishVoice/icon_check_sentence.png'
  24. import icon_check_theme from '../../../../assets/icon/englishVoice/icon_check_theme.png'
  25. import icon_check_user from '../../../../assets/icon/englishVoice/icon_check_user.png'
  26. import icon_check_word from '../../../../assets/icon/englishVoice/icon_check_word.png'
  27. import minxin from '../minxins/minxin'
  28. export default {
  29. mixins: [minxin],
  30. props: {
  31. checkJson: {
  32. type: Array,
  33. },
  34. },
  35. data() {
  36. return {
  37. checkData:[
  38. {
  39. name:'朗读',
  40. open: true,
  41. children:[
  42. {
  43. icon:icon_check_word,
  44. name:'单词/词组',
  45. type:'word'
  46. },
  47. {
  48. icon:icon_check_sentence,
  49. name:'句子/短文',
  50. type:'sentence'
  51. }
  52. ]
  53. },
  54. {
  55. name:'回答',
  56. open: true,
  57. children:[
  58. {
  59. icon:icon_check_qa,
  60. name:'题目',
  61. type:'QA'
  62. }
  63. ]
  64. },
  65. // {
  66. // name:'对话',
  67. // open: true,
  68. // children:[
  69. // {
  70. // icon:icon_check_addUser,
  71. // name:'创建角色',
  72. // type:'createRole'
  73. // }
  74. // ]
  75. // },
  76. {
  77. name:'主题陈述',
  78. open: true,
  79. children:[
  80. {
  81. icon:icon_check_theme,
  82. name:'新建主题',
  83. type:'theme'
  84. }
  85. ]
  86. }
  87. ],
  88. checkArray:[]
  89. }
  90. },
  91. methods: {
  92. openC(index) {
  93. this.checkData[index].open = !this.checkData[index].open
  94. this.$forceUpdate()
  95. },
  96. addCheck(item){
  97. if(item.type == 'word'){
  98. this.checkArray.push({
  99. type:'word',
  100. title:'',
  101. img:'',
  102. content:'' //单词/词组
  103. })
  104. }else if(item.type == 'sentence'){
  105. this.checkArray.push({
  106. type:'sentence',
  107. title:'',
  108. img:'',
  109. content:'' //句子/短文
  110. })
  111. }else if(item.type == 'QA'){
  112. this.checkArray.push({
  113. type:'QA',
  114. title:'',
  115. img:'',
  116. content:'' //题目
  117. })
  118. }else if(item.type == 'theme'){
  119. this.checkArray.push({
  120. type:'theme',
  121. title:'',
  122. img:'',
  123. content:'' , //题目
  124. content2:'', //内容
  125. rTime: 1, //准备时间
  126. oTime: 1, //演讲时间
  127. })
  128. }else if(item.type == 'createRole'){
  129. this.checkArray.push({
  130. type:'createRole',
  131. title:'',
  132. img:'',
  133. content:'' , //人名
  134. content2:'', //角色定义
  135. content3:'', //角色问候
  136. })
  137. }
  138. this.$forceUpdate()
  139. this.$emit('setJson', this.checkArray)
  140. }
  141. },
  142. watch: {
  143. checkJson: {
  144. handler: function (newVal, oldVal) {
  145. this.checkArray = this.depthCopy(newVal);
  146. },
  147. deep: true,
  148. }
  149. },
  150. mounted(){
  151. this.checkArray = this.depthCopy(this.checkJson);
  152. }
  153. }
  154. </script>
  155. <style scoped>
  156. .check_box{
  157. width: 100%;
  158. }
  159. .check_div{
  160. width: 100%;
  161. }
  162. .check_div + .check_div{
  163. margin-top: 16px;
  164. }
  165. .check_div_title{
  166. width: 100%;
  167. display: flex;
  168. align-items: center;
  169. margin-bottom: 8px;
  170. }
  171. .check_div_open{
  172. width: 11px;
  173. height: 11px;
  174. background-image: url('../../../../assets/icon/new/u_arrow.png');
  175. background-size: 100% 100%;
  176. margin-right: 7px;
  177. cursor: pointer;
  178. transition: all 0.3s;
  179. transform: rotate(-90deg);
  180. }
  181. .check_div_open.active{
  182. transform: rotate(0deg);
  183. }
  184. .check_div_name{
  185. font-size: 14px;
  186. color: #000;
  187. font-weight: bold;
  188. }
  189. .check_div_children{}
  190. .check_div_child{
  191. cursor: pointer;
  192. display: flex;
  193. width: 100%;
  194. padding: 8px 8px;
  195. box-sizing: border-box;
  196. background: rgb(240, 242, 245);
  197. border-radius: 4px;
  198. align-items: center;
  199. }
  200. .check_div_child+ .check_div_child{
  201. margin-top: 8px;
  202. }
  203. .check_icon{
  204. display: flex;
  205. width: 16px;
  206. height: 16px;
  207. align-items: center;
  208. justify-content: center;
  209. margin-right: 5px;
  210. }
  211. .check_icon > img{
  212. width: 100%;
  213. height: 100%;
  214. object-fit: contain;
  215. }
  216. .check_div_child_name{}
  217. </style>