CardHead.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div :class="classes">
  3. <div class="card-head-top">
  4. <!-- 高度变化之后会印象内容排版,先固定高度 -->
  5. <div class="card-head-title">
  6. <el-input
  7. v-if="!preview && !data.isSimple"
  8. id="cardTitleInput"
  9. v-model="cardTitle"
  10. size="small"
  11. placeholder="请输入题卡标题"
  12. @blur="nameChange"
  13. >
  14. </el-input>
  15. <h1 v-else>{{ data.cardTitle }}</h1>
  16. </div>
  17. <div class="card-head-subtitle">
  18. <el-input
  19. v-if="!preview && !data.isSimple"
  20. id="cardDescInput"
  21. v-model="cardDesc"
  22. type="textarea"
  23. resize="none"
  24. :rows="2"
  25. placeholder="请输入题卡描述信息"
  26. @blur="nameChange"
  27. >
  28. </el-input>
  29. <p v-else>{{ data.cardDesc }}</p>
  30. </div>
  31. </div>
  32. <template v-if="data.columnNumber === 2">
  33. <div class="card-head-body" v-if="data.examNumberStyle !== 'fill'">
  34. <div class="grid-container">
  35. <div class="grid-row">
  36. <div class="grid-col grid-col-dash">
  37. <head-stdno :data="data"></head-stdno>
  38. </div>
  39. <div class="grid-col">
  40. <head-stdinfo :data="data"></head-stdinfo>
  41. </div>
  42. </div>
  43. <div class="grid-row" v-if="!data.isSimple">
  44. <div class="grid-col">
  45. <head-notice :data="data"></head-notice>
  46. </div>
  47. <div class="grid-col">
  48. <head-dynamic :data="data"></head-dynamic>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="card-head-body" v-else>
  54. <card-head-body-auto-resize>
  55. <head-stdinfo :data="data" slot="stdinfo"></head-stdinfo>
  56. <head-notice :data="data" slot="notice"></head-notice>
  57. <head-stdno :data="data" slot="stdno"></head-stdno>
  58. <head-dynamic
  59. :data="data"
  60. slot="dynamic"
  61. v-if="!data.isSimple && hasDynamicArea"
  62. ></head-dynamic>
  63. </card-head-body-auto-resize>
  64. </div>
  65. </template>
  66. <template v-if="data.columnNumber > 2">
  67. <div class="card-head-body" v-if="data.examNumberStyle !== 'fill'">
  68. <head-stdno class="card-head-part" :data="data"></head-stdno>
  69. <head-stdinfo class="card-head-part" :data="data"></head-stdinfo>
  70. <head-dynamic
  71. class="card-head-part"
  72. :data="data"
  73. v-if="!data.isSimple && hasDynamicArea"
  74. ></head-dynamic>
  75. <head-notice
  76. class="card-head-part"
  77. :data="data"
  78. v-if="!data.isSimple"
  79. ></head-notice>
  80. </div>
  81. <div class="card-head-body" v-else>
  82. <head-stdinfo class="card-head-part" :data="data"></head-stdinfo>
  83. <head-stdno class="card-head-part" :data="data"></head-stdno>
  84. <head-dynamic
  85. class="card-head-part"
  86. :data="data"
  87. v-if="!data.isSimple && hasDynamicArea"
  88. ></head-dynamic>
  89. <head-notice class="card-head-part" :data="data"></head-notice>
  90. </div>
  91. </template>
  92. </div>
  93. </template>
  94. <script>
  95. import HeadDynamic from "./cardHeadSpin/HeadDynamic";
  96. import HeadNotice from "./cardHeadSpin/HeadNotice";
  97. import HeadStdinfo from "./cardHeadSpin/HeadStdinfo";
  98. import HeadStdno from "./cardHeadSpin/HeadStdno";
  99. import CardHeadBodyAutoResize from "./CardHeadBodyAutoResize";
  100. import { mapMutations } from "vuex";
  101. export default {
  102. name: "card-head",
  103. components: {
  104. HeadStdno,
  105. HeadStdinfo,
  106. HeadNotice,
  107. HeadDynamic,
  108. CardHeadBodyAutoResize
  109. },
  110. props: {
  111. data: {
  112. type: Object
  113. },
  114. preview: {
  115. type: Boolean,
  116. default: false
  117. }
  118. },
  119. data() {
  120. return {
  121. cardTitle: this.data.cardTitle,
  122. cardDesc: this.data.cardDesc
  123. };
  124. },
  125. computed: {
  126. classes() {
  127. return [
  128. "page-element",
  129. "card-head",
  130. {
  131. "card-head-narrow": this.data.columnNumber > 2,
  132. "card-head-handle": this.data.examNumberStyle === "fill",
  133. "card-head-normal":
  134. this.data.examNumberStyle !== "fill" && this.data.columnNumber <= 2
  135. }
  136. ];
  137. },
  138. hasDynamicArea() {
  139. const noDynamic =
  140. this.data.examNumberStyle === "fill"
  141. ? !this.data.missAndFill && !this.data.aOrB
  142. : !this.data.missAndFill && !this.data.writeSign && !this.data.aOrB;
  143. return !noDynamic;
  144. }
  145. },
  146. methods: {
  147. ...mapMutations("card", ["setCardConfig"]),
  148. nameChange() {
  149. this.setCardConfig({
  150. cardTitle: this.cardTitle,
  151. cardDesc: this.cardDesc
  152. });
  153. }
  154. }
  155. };
  156. </script>