CardHead.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. :disabled="disabledEditCardName"
  13. @blur="nameChange"
  14. >
  15. </el-input>
  16. <h1 v-else>{{ data.cardTitle }}</h1>
  17. </div>
  18. <div class="card-head-subtitle">
  19. <div v-if="!preview && !data.isSimple">
  20. <el-input
  21. v-model.trim="firstLevelSubheading"
  22. placeholder="请输入一级副标题"
  23. @blur="nameChange"
  24. >
  25. </el-input>
  26. <el-input
  27. v-model.trim="secondLevelSubheading"
  28. placeholder="请输入二级副标题"
  29. @blur="nameChange"
  30. >
  31. </el-input>
  32. </div>
  33. <div v-else>
  34. <p>{{ firstLevelSubheading }}</p>
  35. <p>{{ secondLevelSubheading }}</p>
  36. </div>
  37. </div>
  38. </div>
  39. <template v-if="!narrowCard">
  40. <div class="card-head-body" v-if="data.examNumberStyle !== 'FILL'">
  41. <div class="grid-container">
  42. <div class="grid-row">
  43. <div class="grid-col grid-col-dash">
  44. <head-stdno :data="data"></head-stdno>
  45. </div>
  46. <div class="grid-col">
  47. <head-stdinfo :data="data"></head-stdinfo>
  48. </div>
  49. </div>
  50. <div class="grid-row" v-if="!data.isSimple">
  51. <div class="grid-col">
  52. <head-notice :data="data"></head-notice>
  53. </div>
  54. <div class="grid-col">
  55. <head-dynamic :data="data"></head-dynamic>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="card-head-body" v-else>
  61. <card-head-body-auto-resize :data="data">
  62. <head-stdinfo :data="data" slot="stdinfo"></head-stdinfo>
  63. <head-notice :data="data" slot="notice"></head-notice>
  64. <head-stdno :data="data" slot="stdno"></head-stdno>
  65. <head-dynamic
  66. :data="data"
  67. slot="dynamic"
  68. v-if="!data.isSimple && hasDynamicArea"
  69. ></head-dynamic>
  70. </card-head-body-auto-resize>
  71. </div>
  72. </template>
  73. <template v-if="narrowCard">
  74. <div class="card-head-body" v-if="data.examNumberStyle !== 'FILL'">
  75. <head-stdno class="card-head-part" :data="data"></head-stdno>
  76. <head-stdinfo class="card-head-part" :data="data"></head-stdinfo>
  77. <head-dynamic
  78. class="card-head-part"
  79. :data="data"
  80. v-if="!data.isSimple && hasDynamicArea"
  81. ></head-dynamic>
  82. <head-notice
  83. class="card-head-part"
  84. :data="data"
  85. v-if="!data.isSimple"
  86. ></head-notice>
  87. </div>
  88. <div class="card-head-body" v-else>
  89. <head-stdinfo class="card-head-part" :data="data"></head-stdinfo>
  90. <head-stdno class="card-head-part" :data="data"></head-stdno>
  91. <head-dynamic
  92. class="card-head-part"
  93. :data="data"
  94. v-if="!data.isSimple && hasDynamicArea"
  95. ></head-dynamic>
  96. <head-notice class="card-head-part" :data="data"></head-notice>
  97. </div>
  98. </template>
  99. </div>
  100. </template>
  101. <script>
  102. import HeadDynamic from "./cardHeadSpin/HeadDynamic";
  103. import HeadNotice from "./cardHeadSpin/HeadNotice";
  104. import HeadStdinfo from "./cardHeadSpin/HeadStdinfo";
  105. import HeadStdno from "./cardHeadSpin/HeadStdno";
  106. import CardHeadBodyAutoResize from "./CardHeadBodyAutoResize";
  107. import { mapMutations, mapState } from "vuex";
  108. export default {
  109. name: "card-head",
  110. components: {
  111. HeadStdno,
  112. HeadStdinfo,
  113. HeadNotice,
  114. HeadDynamic,
  115. CardHeadBodyAutoResize,
  116. },
  117. props: {
  118. data: {
  119. type: Object,
  120. },
  121. preview: {
  122. type: Boolean,
  123. default: false,
  124. },
  125. },
  126. data() {
  127. return {
  128. cardTitle: "",
  129. firstLevelSubheading: "",
  130. secondLevelSubheading: "",
  131. };
  132. },
  133. created() {
  134. this.cardTitle = this.data.cardTitle;
  135. this.firstLevelSubheading = this.data.firstLevelSubheading;
  136. this.secondLevelSubheading = this.data.secondLevelSubheading;
  137. },
  138. computed: {
  139. ...mapState("card", ["cardConfig"]),
  140. classes() {
  141. return [
  142. "page-element",
  143. "card-head",
  144. {
  145. "card-head-narrow": this.narrowCard,
  146. "card-head-handle": this.data.examNumberStyle === "FILL",
  147. "card-head-normal":
  148. this.data.examNumberStyle !== "FILL" && !this.narrowCard,
  149. },
  150. ];
  151. },
  152. narrowCard() {
  153. return (
  154. (this.data.pageSize === "A3" && this.data.columnNumber > 2) ||
  155. (this.data.pageSize === "A4" && this.data.columnNumber === 2)
  156. );
  157. },
  158. hasDynamicArea() {
  159. const noDynamic =
  160. this.data.examNumberStyle === "FILL"
  161. ? !this.data.examAbsent && !this.data.aOrB && !this.data.discipline
  162. : !this.data.examAbsent &&
  163. !this.data.writeSign &&
  164. !this.data.aOrB &&
  165. !this.data.discipline;
  166. return !noDynamic;
  167. },
  168. disabledEditCardName() {
  169. // 客服制卡不可修改标题
  170. return this.cardConfig["makeMethod"] === "CUST";
  171. },
  172. },
  173. methods: {
  174. ...mapMutations("card", ["setCardConfig"]),
  175. nameChange() {
  176. this.setCardConfig({
  177. cardTitle: this.cardTitle,
  178. firstLevelSubheading: this.firstLevelSubheading,
  179. secondLevelSubheading: this.secondLevelSubheading,
  180. });
  181. },
  182. },
  183. };
  184. </script>