mixinnew.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import dragtool from './templates/DragTool'
  2. import { unix2Date, unix2DateWithTimeZone } from '@/utils/Foundation'
  3. export default {
  4. props: {
  5. /** 模块设计数据 */
  6. data: {
  7. type: Object,
  8. default: () => ({})
  9. },
  10. /** 是否为编辑模式 */
  11. isEdit: {
  12. type: Boolean,
  13. default: false
  14. },
  15. /** 模块绑定数据 **/
  16. bindData: {
  17. type: Object,
  18. default: () => ({})
  19. },
  20. /** 床位数据数组索引 */
  21. childDataIndex: {
  22. type: Number,
  23. default: 0
  24. },
  25. // /** 科室统计信息*/
  26. // statisticData: {
  27. // type: Object,
  28. // default: () => ({})
  29. // },
  30. // /** 自定义看板项目*/
  31. // boardCustomerItems: {
  32. // type: Array,
  33. // default: ([])
  34. // },
  35. /** 动画驱动**/
  36. show: {
  37. type: Boolean,
  38. default: true
  39. }
  40. },
  41. components: {
  42. dragtool
  43. },
  44. computed: {
  45. moduleComputedStyle() {
  46. let backgroundColorNurse = ''
  47. let borderColorNurse = ''
  48. let boxShadow = ''
  49. if (this.data.moduleConfig.styleConfig.borderColorWithNurse && this.data.moduleConfig.styleConfig.borderColorWithNurse !== '') {
  50. const nurseId = this.data.moduleConfig.styleConfig.borderColorWithNurse.replace('nurse_color_', '')
  51. const nurseOption = this.bindData.items[this.childDataIndex]['list'].filter(p => p.nurse_config === parseInt(nurseId))[0]
  52. if (nurseOption) {
  53. borderColorNurse = '#' + nurseOption.nurse_color_rbg
  54. }
  55. }
  56. if (this.data.moduleConfig.styleConfig.backgroundColorWithNurse && this.data.moduleConfig.styleConfig.backgroundColorWithNurse !== '') {
  57. const nurseId = this.data.moduleConfig.styleConfig.backgroundColorWithNurse.replace('nurse_color_', '')
  58. const nurseOption = this.bindData.items[this.childDataIndex]['list'].filter(p => p.nurse_config === parseInt(nurseId))[0]
  59. if (nurseOption) {
  60. backgroundColorNurse = '#' + nurseOption.nurse_color_rbg
  61. }
  62. }
  63. if (this.data.moduleConfig.styleConfig.backgroundColorToday && this.data.moduleConfig.styleConfig.backgroundColorToday !== '') { // 设置日期等于当天的颜色
  64. if (this.displayText === unix2DateWithTimeZone(new Date().getTime(), this.data.moduleConfig.dataConfig.textFormat)) {
  65. backgroundColorNurse = this.data.moduleConfig.styleConfig.backgroundColorToday
  66. }
  67. }
  68. if (this.data.moduleConfig.styleConfig.boxShadowShow) {
  69. boxShadow = '1px 1px 3px 1px #eee'
  70. if (this.data.moduleConfig.styleConfig.boxShadowColor && this.data.moduleConfig.styleConfig.boxShadowColor !== '') {
  71. boxShadow = '1px 1px 3px 1px ' + this.data.moduleConfig.styleConfig.boxShadowColor
  72. }
  73. }
  74. return { ...this.data.moduleConfig.moduleStyle,
  75. borderColor: (borderColorNurse === '' ? this.data.moduleConfig.moduleStyle.borderColor : borderColorNurse),
  76. backgroundColor: (backgroundColorNurse === '' ? this.data.moduleConfig.moduleStyle.backgroundColor : backgroundColorNurse),
  77. boxShadow: boxShadow }
  78. },
  79. titleComputedStyle() { // 显示单元标题样式计算
  80. let titleColor = ''
  81. if (this.data.moduleConfig.styleConfig.titleColorWithNurse && this.data.moduleConfig.styleConfig.titleColorWithNurse !== '') {
  82. const nurseId = this.data.moduleConfig.styleConfig.titleColorWithNurse.replace('nurse_color_', '')
  83. const nurseOption = this.bindData.items[this.childDataIndex]['list'].filter(p => p.nurse_config === parseInt(nurseId))[0]
  84. if (nurseOption) {
  85. titleColor = '#' + nurseOption.nurse_color_rbg
  86. }
  87. }
  88. return { ...this.data.moduleConfig.titleStyle,
  89. color: (titleColor === '' ? this.data.moduleConfig.titleStyle.color : titleColor) }
  90. },
  91. textComputedStyle() { // 显示单元
  92. let textcolor = ''
  93. if (this.data.moduleConfig.styleConfig.textColorWithNurse && this.data.moduleConfig.styleConfig.textColorWithNurse !== '') {
  94. const nurseId = this.data.moduleConfig.styleConfig.textColorWithNurse.replace('nurse_color_', '')
  95. const nurseOption = this.bindData.items[this.childDataIndex]['list'].filter(p => p.nurse_config === parseInt(nurseId))[0]
  96. if (nurseOption) {
  97. textcolor = '#' + nurseOption.nurse_color_rbg
  98. }
  99. }
  100. if (this.data.moduleConfig.styleConfig.textColorToday && this.data.moduleConfig.styleConfig.textColorToday !== '') { // 设置日期等于当天的颜色
  101. if (this.displayText === unix2DateWithTimeZone(new Date().getTime(), this.data.moduleConfig.dataConfig.textFormat)) {
  102. textcolor = this.data.moduleConfig.styleConfig.textColorToday
  103. }
  104. }
  105. return {
  106. ...this.data.moduleConfig.textStyle,
  107. color: (textcolor === '' ? this.data.moduleConfig.textStyle.color : textcolor)
  108. }
  109. },
  110. containerComputedStyle() {
  111. if (this.data.moduleConfig.styleConfig.moduleFixed && !this.isEdit) {
  112. return {
  113. position: 'fixed',
  114. width: '100%',
  115. bottom: 0,
  116. left: 0
  117. }
  118. }
  119. }
  120. },
  121. data() {
  122. return {
  123. systemDate: new Date()
  124. }
  125. },
  126. mounted() {
  127. // let _this=this
  128. this.currentTime()
  129. },
  130. methods: {
  131. currentTime() {
  132. this.systemDate = new Date()
  133. setTimeout(this.currentTime, 1000)
  134. },
  135. /** 获取颜色相关信息 */
  136. colors(columnIndex = 0) {
  137. const _colors = this.data.columnList[columnIndex].titleColors
  138. return {
  139. title: `background-color: ${_colors[0]}; background-image: linear-gradient(90deg, ${_colors.join(',')});`,
  140. color: (colorIndex = 0) => `color: ${_colors[colorIndex]}`
  141. }
  142. },
  143. // /** 获取区块链接 */
  144. // blockHref(block) {
  145. // const { opt_type, opt_value } = block.block_opt
  146. // switch (opt_type) {
  147. // // 链接地址
  148. // case 'URL': return opt_value
  149. // // 商品
  150. // case 'GOODS': return `/goods/${opt_value}`
  151. // // 关键字
  152. // case 'KEYWORD': return `/goods?keyword=${encodeURIComponent(opt_value)}`
  153. // // 店铺
  154. // case 'SHOP': return `/shop/${opt_value}`
  155. // // 分类
  156. // case 'CATEGORY': return `/goods?category=${opt_value}`
  157. // default: return '/'
  158. // }
  159. // },
  160. /** 构建空的block */
  161. emptyBlock(num = 3, type) {
  162. return [...new Array(num)].map(() => ({
  163. block_type: type,
  164. block_value: '',
  165. block_opt: {
  166. opt_type: 'NONE',
  167. opt_value: ''
  168. }
  169. }))
  170. },
  171. /** 编辑区块 */
  172. handleEditBlock(columnIndex, blockIndex) {
  173. // console.log(JSON.stringify(this.data))
  174. this.$emit('edit-block', JSON.parse(JSON.stringify(this.data)), columnIndex, blockIndex)
  175. },
  176. /** 编辑标题 */
  177. handleEditTitle(columnIndex) {
  178. this.$emit('edit-title', JSON.parse(JSON.stringify(this.data)), columnIndex)
  179. },
  180. /** 编辑标签 */
  181. handleEditTags(columnIndex) {
  182. this.$emit('edit-tags', JSON.parse(JSON.stringify(this.data)), columnIndex)
  183. },
  184. deleteModule(unique) {
  185. // console.log('model delete', unique)
  186. this.$emit('remove', unique)
  187. },
  188. copyModule(unique) {
  189. this.$emit('copy', unique)
  190. },
  191. activeModule(unique) {
  192. this.$emit('active', unique)
  193. }
  194. }
  195. }