CardHead.vue 5.4 KB

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