PictureSetting.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div>
  3. <el-form :model="property" :label-position="labelPosition" label-width="72px">
  4. <el-form-item label="序号" class="serial-number">
  5. <el-input v-model="property.serial_number" />
  6. <SvgIcon icon-class="switch" size="14" @click="switchSerialNumber(property)" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-radio
  10. v-for="{ value, label } in snGenerationMethodList"
  11. :key="value"
  12. v-model="property.sn_generation_method"
  13. :label="value"
  14. >
  15. {{ label }}
  16. </el-radio>
  17. </el-form-item>
  18. <el-form-item label="序号位置">
  19. <div class="grid-container">
  20. <div class="top">
  21. <el-button
  22. :class="['top-start', { active: 'top-start' === property.sn_position }]"
  23. @click="changeNumberPosition('top-start')"
  24. />
  25. <el-button
  26. :class="['top', { active: 'top' === property.sn_position }]"
  27. @click="changeNumberPosition('top')"
  28. />
  29. <el-button
  30. :class="['top-end', { active: 'top-end' === property.sn_position }]"
  31. @click="changeNumberPosition('top-end')"
  32. />
  33. </div>
  34. <div class="left">
  35. <el-button
  36. :class="['left-start', { active: 'left-start' === property.sn_position }]"
  37. @click="changeNumberPosition('left-start')"
  38. />
  39. <el-button
  40. :class="['left', { active: 'left' === property.sn_position }]"
  41. @click="changeNumberPosition('left')"
  42. />
  43. <el-button
  44. :class="['left-end', { active: 'left-end' === property.sn_position }]"
  45. @click="changeNumberPosition('left-end')"
  46. />
  47. </div>
  48. <div class="main"></div>
  49. <div class="right">
  50. <el-button
  51. :class="['right-start', { active: 'right-start' === property.sn_position }]"
  52. @click="changeNumberPosition('right-start')"
  53. />
  54. <el-button
  55. :class="['right', { active: 'right' === property.sn_position }]"
  56. @click="changeNumberPosition('right')"
  57. />
  58. <el-button
  59. :class="['right-end', { active: 'right-end' === property.sn_position }]"
  60. @click="changeNumberPosition('right-end')"
  61. />
  62. </div>
  63. <div class="bottom">
  64. <el-button
  65. :class="['bottom-start', { active: 'bottom-start' === property.sn_position }]"
  66. @click="changeNumberPosition('bottom-start')"
  67. />
  68. <el-button
  69. :class="['bottom', { active: 'bottom' === property.sn_position }]"
  70. @click="changeNumberPosition('bottom')"
  71. />
  72. <el-button
  73. :class="['bottom-end', { active: 'bottom-end' === property.sn_position }]"
  74. @click="changeNumberPosition('bottom-end')"
  75. />
  76. </div>
  77. </div>
  78. </el-form-item>
  79. <el-divider />
  80. <el-form-item label="查看方式">
  81. <el-radio v-for="{ value, label } in viewMethodList" :key="value" v-model="property.view_method" :label="value">
  82. {{ label }}
  83. </el-radio>
  84. </el-form-item>
  85. </el-form>
  86. </div>
  87. </template>
  88. <script>
  89. import SettingMixin from '@/views/book/courseware/create/components/common/SettingMixin';
  90. import {
  91. snGenerationMethodList,
  92. viewMethodList,
  93. switchSerialNumber,
  94. checkString,
  95. } from '@/views/book/courseware/data/common';
  96. export default {
  97. name: 'PictureSetting',
  98. mixins: [SettingMixin],
  99. data() {
  100. return {
  101. switchSerialNumber,
  102. checkString,
  103. snGenerationMethodList,
  104. viewMethodList,
  105. labelPosition: 'left',
  106. property: {
  107. serial_number: 1, // 序号
  108. sn_type: 'number',
  109. sn_position: 'top-start', // 序号位置:top-start top top-end 等
  110. sn_generation_method: snGenerationMethodList[0].value, // 序号生成方式:recalculate 重新计算follow 跟随
  111. view_method: viewMethodList[0].value, // 查看方式:independent 独立 list 列表icon 图标
  112. },
  113. };
  114. },
  115. watch: {
  116. property: {
  117. handler(val) {
  118. if (this.isSet) {
  119. val.sn_type = checkString(val.serial_number);
  120. this.$emit('updateSetting', val);
  121. }
  122. },
  123. deep: true,
  124. },
  125. },
  126. methods: {
  127. /**
  128. * @description 设置属性
  129. * @param {Object} property 属性
  130. */
  131. setSetting(property) {
  132. this.isSet = true;
  133. this.property = property;
  134. },
  135. /**
  136. * @description 改变序号位置
  137. * @param {String} sn_position
  138. */
  139. changeNumberPosition(sn_position) {
  140. this.property.sn_position = sn_position;
  141. },
  142. },
  143. };
  144. </script>
  145. <style lang="scss" scoped>
  146. .el-form {
  147. .serial-number {
  148. :deep .el-form-item__content {
  149. display: flex;
  150. align-items: center;
  151. justify-content: space-between;
  152. }
  153. }
  154. .el-input {
  155. margin-right: 16px;
  156. }
  157. .top {
  158. grid-area: top;
  159. column-gap: 8px;
  160. justify-content: center;
  161. }
  162. .left {
  163. flex-direction: column;
  164. grid-area: left;
  165. row-gap: 4px;
  166. }
  167. .main {
  168. grid-area: main;
  169. }
  170. .right {
  171. flex-direction: column;
  172. grid-area: right;
  173. row-gap: 4px;
  174. }
  175. .bottom {
  176. grid-area: bottom;
  177. column-gap: 8px;
  178. justify-content: center;
  179. }
  180. .grid-container {
  181. display: grid;
  182. grid:
  183. 'top top top top top top'
  184. 'left main main main main right'
  185. 'bottom bottom bottom bottom bottom bottom';
  186. width: 134px;
  187. height: 80px;
  188. padding: 8px 8px 0;
  189. line-height: 10px;
  190. border: 1px solid #ebebeb;
  191. div {
  192. display: flex;
  193. margin: 0 auto;
  194. text-align: center;
  195. background-color: rgba(255, 255, 255, 8%);
  196. .el-button {
  197. width: 16px;
  198. height: 8px;
  199. padding: 0;
  200. margin: 0;
  201. border: 1px solid #e4e4e4;
  202. border-radius: 2px;
  203. &.active {
  204. background-color: $setting-active-color;
  205. }
  206. }
  207. }
  208. .main {
  209. width: 64px;
  210. height: 32px;
  211. background-color: #f8f8f8;
  212. border: 1px solid #e4e4e4;
  213. border-radius: 2px;
  214. }
  215. }
  216. .el-divider {
  217. margin: 16px 0;
  218. }
  219. }
  220. </style>