kz-ui-base 1.0.60 → 1.0.62

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.
@@ -26,7 +26,7 @@
26
26
  </el-form>
27
27
  </slot>
28
28
  <slot name="footer">
29
- <div class="dialog-footer">
29
+ <div class="dialog-footer" style="text-align: center;">
30
30
  <el-button
31
31
  type="primary"
32
32
  :loading="setting.submitLoading"
@@ -154,7 +154,7 @@ import {
154
154
  Emit,
155
155
  Mixins,
156
156
  } from "vue-property-decorator";
157
- import { listEntity, ajaxUrl } from "../../../../common/src/api/common/common";
157
+ import { listEntity, ajaxUrl } from "kz-ui-base/common/src/api/common/common";
158
158
  import Treeselect from "@riophae/vue-treeselect";
159
159
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
160
160
  import {
@@ -0,0 +1,126 @@
1
+ <template>
2
+ <div>
3
+ <dict-select v-model="stateValue" v-if="keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_ENUM" v-bind="$attrs"
4
+ :type="dictType" @change="change"></dict-select>
5
+ <dict-select v-model="stateValue" v-else-if="keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_YES_NO" v-bind="$attrs"
6
+ type="sys_yes_no_bool" @change="(val) =>{change(val === 'true')}"></dict-select>
7
+ <el-date-picker v-model="stateValue" v-else-if="keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_DATE" v-bind="$attrs"
8
+ @change="change"></el-date-picker>
9
+ <el-input v-model="stateValue" v-else-if="keyInTypeCode === KEY_IN_TYPE_CODE.INPUT_NUMBER" v-bind="$attrs"
10
+ @change="change"></el-input>
11
+ <el-input v-model="stateValue" v-else-if="keyInTypeCode === KEY_IN_TYPE_CODE.INPUT_STRING" v-bind="$attrs"
12
+ @change="change"></el-input>
13
+ <span v-else>录入类型有误</span>
14
+ </div>
15
+ </template>
16
+
17
+ <script>
18
+ import {KEY_IN_TYPE_CODE} from "@/constant/bd";
19
+
20
+ export default {
21
+ name: 'DynamicInputBox',
22
+ computed: {
23
+ KEY_IN_TYPE_CODE() {
24
+ return KEY_IN_TYPE_CODE
25
+ },
26
+ },
27
+ watch: {
28
+ attributeValue(val) {
29
+ this.setStateValue(this.keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_ENUM ? this.attributeValueCode : this.attributeValue);
30
+ },
31
+ attributeValueCode(val) {
32
+ this.setStateValue(this.keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_ENUM ? this.attributeValueCode : this.attributeValue);
33
+ },
34
+ keyInTypeCode(val) {
35
+ this.setStateValue(this.keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_ENUM ? this.attributeValueCode : this.attributeValue);
36
+ }
37
+ },
38
+ props: {
39
+ keyInTypeCode: {
40
+ type: String,
41
+ required: true
42
+ },
43
+ // 当设置小数位数并且录入类型为数字时,执行格式化和补0
44
+ decimalPlace: {
45
+ type: String,
46
+ default: null
47
+ },
48
+ dictType: {
49
+ type: String,
50
+ default: ''
51
+ },
52
+ value: {
53
+ type: String,
54
+ default: ""
55
+ },
56
+ attributeValue: {
57
+ type: [String,Boolean],
58
+ default: ''
59
+ },
60
+ attributeValueCode: {
61
+ type: String,
62
+ default: ''
63
+ },
64
+ },
65
+ data() {
66
+ return {
67
+ stateValue: '',
68
+ }
69
+ },
70
+ created() {
71
+ this.setStateValue(this.keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_ENUM ? this.attributeValueCode : this.attributeValue);
72
+ },
73
+ methods: {
74
+ formatInput() {
75
+ const decimalPlace = this.decimalPlace || 0; // 默认小数位数为0
76
+ // 格式化输入值
77
+ this.stateValue = this.stateValue
78
+ .replace(/[^\d.]/g, '') // 只保留数字和小数点
79
+ .replace(/^0+(?=\d)/, ''); // 去除前导0
80
+ const parts = this.stateValue.split('.');
81
+ if(!parts[0].length){
82
+ parts[0] = "0";
83
+ }
84
+ if (decimalPlace === 0) {
85
+ // 小数位数为0,只保留整数部分
86
+ this.stateValue = parts[0];
87
+ } else {
88
+ if (parts.length === 1) {
89
+ parts[1] = ''
90
+ }
91
+ // 处理小数部分
92
+ parts[1] = parts[1].slice(0, decimalPlace); // 限制小数位数
93
+
94
+ // 自动补零
95
+ while (parts[1].length < decimalPlace) {
96
+ parts[1] += '0';
97
+ }
98
+ // 重新组合值
99
+ this.stateValue = parts[0] + '.' + parts[1];
100
+ }
101
+ },
102
+ setStateValue(val) {
103
+ if(typeof val === 'boolean') {
104
+ this.stateValue = val.toString()
105
+ }else{
106
+ this.stateValue = val
107
+ }
108
+ },
109
+ change(val, option) {
110
+
111
+ if(this.keyInTypeCode === KEY_IN_TYPE_CODE.INPUT_NUMBER && this.decimalPlace != null){
112
+ this.formatInput();
113
+ val = this.stateValue;
114
+ }
115
+
116
+ if (this.keyInTypeCode === KEY_IN_TYPE_CODE.SELECT_ENUM) {
117
+ this.$emit('attributeValueCodeChange', val)
118
+ this.$emit('attributeValueChange', option['dictLabel'])
119
+ } else {
120
+ this.$emit('attributeValueChange', val)
121
+ }
122
+ this.$emit('change', val, option)
123
+ },
124
+ },
125
+ };
126
+ </script>
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <el-input-number v-model="stateValue" :precision="precision" v-bind="$attrs" @change="change"></el-input-number>
3
+ </template>
4
+
5
+ <script>
6
+ import {SCALE_TYPE} from "@/constant/bd";
7
+ import {
8
+ getAmountScaleByCurrencyId,
9
+ getPriceScaleByCurrencyId,
10
+ getUomScaleByUomNo
11
+ } from "@utils/cache/bdCache";
12
+
13
+
14
+ export default {
15
+ name: 'ScaleInputNumber',
16
+ props: {
17
+ type: {
18
+ type: String,
19
+ required: true
20
+ },
21
+ scaleNo: {
22
+ type: String
23
+ },
24
+ currencyId: {
25
+ type: String,
26
+ },
27
+ value: {
28
+ type: [String, Number],
29
+ default: '0'
30
+ }
31
+ },
32
+ watch: {
33
+ value: {
34
+ handler(val) {
35
+ if (typeof val == 'string') {
36
+ val = Number(val)
37
+ }
38
+ this.stateValue = val
39
+ },
40
+ immediate: true
41
+ }
42
+ },
43
+ data() {
44
+ return {
45
+ step: 1,
46
+ min: 0,
47
+ max: 1000000,
48
+ precision: 0,
49
+ stateValue: 0
50
+ };
51
+ },
52
+ created() {
53
+ this.setPrecision();
54
+ },
55
+ methods: {
56
+ change(val) {
57
+ this.$emit('input', val)
58
+ this.$emit('change', val)
59
+ },
60
+ setPrecision() {
61
+ switch (this.type) {
62
+ case SCALE_TYPE.UOM:
63
+ console.log(getUomScaleByUomNo(this.scaleNo));
64
+ this.precision = getUomScaleByUomNo(this.scaleNo).scale;
65
+ break;
66
+ case SCALE_TYPE.AMOUNT:
67
+ console.log(getAmountScaleByCurrencyId(this.currencyId));
68
+ this.precision = getAmountScaleByCurrencyId(this.currencyId).scale;
69
+ break;
70
+ case SCALE_TYPE.PRICE:
71
+ console.log(getPriceScaleByCurrencyId(this.currencyId));
72
+ this.precision = getPriceScaleByCurrencyId(this.currencyId).scale;
73
+ break;
74
+ }
75
+ },
76
+ },
77
+ };
78
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kz-ui-base",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {