@zscreate/zhxy-app-component 1.0.163 → 1.0.165

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,7 +63,10 @@
63
63
  {{ widget.name }}
64
64
  </view>
65
65
  <view class="evan-form-item-container__main evan-form-item-container__textarea" :style="mContentStyle">
66
- <textarea maxlength="300" class="form-input cover-text" v-model="dataModel"
66
+ <view v-if="widget.options.disabled" class="form-input cover-text" style="height: initial;line-break: anywhere;">
67
+ {{ dataModel }}
68
+ </view>
69
+ <textarea v-else maxlength="300" class="form-input cover-text" v-model="dataModel"
67
70
  :style="{ height: (widget.options.height || 100) * 2 + 'px'}"
68
71
  placeholder-style="line-height:60rpx" placeholder-class="form-input-placeholder"
69
72
  :placeholder="widget.options.placeholder" :disabled="widget.options.disabled">
@@ -2,7 +2,7 @@ import Pubsub from 'pubsub-js'
2
2
 
3
3
  import validateByApiMinxins from './validateByApiMinxins'
4
4
  import { run, FormulaInstance } from "../../../utils/formula_run"
5
-
5
+ import moment from "../../../utils/moment.js";
6
6
  export const pubSubMixin = {
7
7
  mixins: [validateByApiMinxins],
8
8
  inject: {
@@ -19,7 +19,8 @@ export const pubSubMixin = {
19
19
  var num = Number(num).toFixed(length);
20
20
  return type ? Number(num) : num;
21
21
  },
22
- calc_run() {
22
+ calc_run(isFirstRun) {
23
+ let invalids = false
23
24
  let { formula, relyWidgets =[] } = this.widget.options.formula
24
25
  relyWidgets.forEach(item => {
25
26
  formula = formula.replaceAll(`\$${item}\#`, item)
@@ -29,9 +30,21 @@ export const pubSubMixin = {
29
30
  const formulaModels = keys.reduce((prev, curr) => {
30
31
  const key = `_widget_${curr}`
31
32
  prev[key] = models[curr]
33
+ if (relyWidgets.includes(key) && isFirstRun && models[curr] === '') {
34
+ invalids = true
35
+ }
32
36
  return prev
33
37
  }, {})
34
- this.dataModel = FormulaInstance.RUN(formula, formulaModels)
38
+ if (invalids) return
39
+ let result = FormulaInstance.RUN(formula, formulaModels)
40
+ if ([NaN].includes(result)) {
41
+ result = ''
42
+ }
43
+ if (Object.prototype.toString.call(result).includes('Date')) {
44
+ result = moment(result).format(this.widget.options.format || 'YYYY-MM-DD')
45
+ }
46
+ console.log('result: ', result)
47
+ this.dataModel = result
35
48
  },
36
49
  //关联组件
37
50
  /**
@@ -45,7 +58,7 @@ export const pubSubMixin = {
45
58
  if (this.widget.options.formula?.formula) {
46
59
  let { formula, relyWidgets =[] } = this.widget.options.formula
47
60
  setTimeout(() => {
48
- if (!this.dataModel) this.calc_run()
61
+ if (!this.dataModel) this.calc_run(true)
49
62
  }, 100)
50
63
  relyWidgets.forEach(item => {
51
64
  Pubsub.subscribe('calc_' + item.replace('_widget_', ''),(data) =>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zscreate/zhxy-app-component",
3
- "version": "1.0.163",
3
+ "version": "1.0.165",
4
4
  "private": false,
5
5
  "description": "zhxy-app-component",
6
6
  "main": "index.js",