SettingMixin.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { checkString, isEnable, pinyinPositionList } from '@/views/book/courseware/data/common';
  2. import SerialNumber from '@/views/book/courseware/create/components/common/SerialNumber.vue';
  3. import BackgroundSet from '@/views/book/courseware/create/components/common/BackgroundSet.vue';
  4. const mixin = {
  5. data() {
  6. return {
  7. param: {}, // 组件设置时传过来的特有参数
  8. checkString,
  9. isEnable,
  10. pinyinPositionList,
  11. };
  12. },
  13. components: {
  14. SerialNumber,
  15. BackgroundSet,
  16. },
  17. watch: {
  18. 'property.serial_number': {
  19. handler(val) {
  20. this.property.sn_type = checkString(val); // 序号与序号类型需保持匹配
  21. },
  22. },
  23. },
  24. provide() {
  25. return {
  26. updateProperty: this.updateProperty,
  27. };
  28. },
  29. methods: {
  30. /**
  31. * @description 设置属性
  32. * @param {object} property 属性
  33. * @param {object} param 参数
  34. */
  35. setSetting(property, param) {
  36. this.property = property;
  37. this.param = param;
  38. },
  39. /**
  40. * @description 更新属性
  41. * @param {string} key
  42. * @param {string|number} value
  43. */
  44. updateProperty(key, value) {
  45. this.$set(this.property, key, value);
  46. },
  47. },
  48. };
  49. export default mixin;