|
|
@@ -102,12 +102,14 @@
|
|
|
" :formatter="value => record.options.thousandth == true && value != '' ?
|
|
|
`${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : value" :allowClear="record.options.clearable"
|
|
|
tree-node-filter-prop="label" :dynamicData="dynamicData" :treeData="computedOptions"
|
|
|
- :options="computedOptions" :mode="record.options.multiple ? 'multiple' : ''" @change="handleChange($event, record.model, record)"
|
|
|
+ :options="computedOptions" :mode="record.options.multiple ? 'multiple' : ''"
|
|
|
+ @change="handleChange($event, record.model, record)"
|
|
|
:is="componentItem" v-model:value="formData[record.model]"
|
|
|
:placeholder="(disabled || record.options.disabled) ? '' : record.options.placeholder"></component>
|
|
|
</a-form-item>
|
|
|
<!-- 可隐藏label -->
|
|
|
- <a-form-item :class="{ 'red-label': record?.options?.requiredFirst ||record?.rules?.find(f=>f.required)}" v-else-if="['batch', 'selectInputList'].includes(record.type)"
|
|
|
+ <a-form-item :class="{ 'red-label': record?.options?.requiredFirst ||record?.rules?.find(f=>f.required)}"
|
|
|
+ v-else-if="['batch', 'selectInputList'].includes(record.type)"
|
|
|
:label="!record.options.showLabel ? '' : record.label" :label-col="formConfig.layout === 'horizontal' && record.options.showLabel
|
|
|
? formConfig.labelLayout === 'flex'
|
|
|
? { style: `width:${formConfig.labelWidth}px` }
|
|
|
@@ -161,7 +163,8 @@
|
|
|
<!-- html -->
|
|
|
<div :id="record.key" v-else-if="record.type === 'html'" v-html="record.options.defaultValue"></div>
|
|
|
<!-- 弹出框 -->
|
|
|
- <PopUpQuery v-else-if="record.type === 'popUpSelect'" :options="computedOptions" :dynamicData="dynamicData" :disabled="disabled || record.options.disabled" :readonly="record.options.readonly"
|
|
|
+ <PopUpQuery v-else-if="record.type === 'popUpSelect'" :options="computedOptions" :dynamicData="dynamicData"
|
|
|
+ :disabled="disabled || record.options.disabled" :readonly="record.options.readonly"
|
|
|
:placeholder="(disabled || record.options.disabled) ? '' : record.options.placeholder"
|
|
|
@change="handleChange"
|
|
|
:formConfig="formConfig" :record="record" :formData="formData"
|
|
|
@@ -197,7 +200,8 @@ import {getDynamicData} from "/@/api/flow/formApi.js";
|
|
|
|
|
|
import {getRulesFunc} from "../../packages/core/contant";
|
|
|
import {useFlowStore} from '/@/store/modules/flow';
|
|
|
-import { PROVINCE_CITY_DISTRICT } from '/@/views/flow/stFormDesign/province-city-district.js';
|
|
|
+import {PROVINCE_CITY_DISTRICT} from '/@/views/flow/stFormDesign/province-city-district.js';
|
|
|
+
|
|
|
export default {
|
|
|
name: "StFormItem",
|
|
|
props: {
|
|
|
@@ -254,9 +258,9 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
computedOptions() {
|
|
|
- if (this.record.options.area==true){
|
|
|
+ if (this.record.options.area == true) {
|
|
|
return PROVINCE_CITY_DISTRICT
|
|
|
- } else if (!this.record.options.dynamic) {
|
|
|
+ } else if (!this.record.options.dynamic) {
|
|
|
return this.record.options.options || [];
|
|
|
} else if (this.record.options.dynamicOptions) {
|
|
|
return this.record.options.dynamicOptions;
|
|
|
@@ -292,11 +296,14 @@ export default {
|
|
|
if (rule.keyCode == 'custom') {
|
|
|
if (stScriptCodeList != null) {
|
|
|
const ruleCode = stScriptCodeList.find(v => v.objectid == rule.eventKey);
|
|
|
- rule.validator = (rule, value) => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- new Function('bizObj', ruleCode.scriptValue).call({}, {rule, value, resolve, reject})
|
|
|
- })
|
|
|
- }
|
|
|
+ const fn = new Function('bizObj', ruleCode.scriptValue);
|
|
|
+ rule.validator = async (rule, value, callback) => {
|
|
|
+ const result = fn({rule, value});
|
|
|
+ if (!result) {
|
|
|
+ return Promise.reject(callback(new Error('')));
|
|
|
+ }
|
|
|
+ return Promise.resolve(callback());
|
|
|
+ };
|
|
|
}
|
|
|
} else {
|
|
|
const {validator} = getRulesFunc(rule.keyCode);
|
|
|
@@ -305,19 +312,22 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- if (this.$refs.StBatch){
|
|
|
+ if (this.$refs.StBatch) {
|
|
|
this.$refs.StBatch.record.list.forEach((item, index) => {
|
|
|
- item.rules.forEach((rule,i)=>{
|
|
|
+ item.rules.forEach((rule, i) => {
|
|
|
if (rule.flag == "Internal") {
|
|
|
if (rule.keyCode) {
|
|
|
if (rule.keyCode == 'custom') {
|
|
|
if (stScriptCodeList != null) {
|
|
|
const ruleCode = stScriptCodeList.find(v => v.objectid == rule.eventKey);
|
|
|
- rule.validator = (rule, value) => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- new Function('bizObj', ruleCode.scriptValue).call({}, {rule, value, resolve, reject})
|
|
|
- })
|
|
|
- }
|
|
|
+ const fn = new Function('bizObj', ruleCode.scriptValue);
|
|
|
+ rule.validator = async (rule, value, callback) => {
|
|
|
+ const result = fn({rule, value});
|
|
|
+ if (!result) {
|
|
|
+ return Promise.reject(callback(new Error('')));
|
|
|
+ }
|
|
|
+ return Promise.resolve(callback());
|
|
|
+ };
|
|
|
}
|
|
|
} else {
|
|
|
const {validator} = getRulesFunc(rule.keyCode);
|
|
|
@@ -413,6 +423,7 @@ export default {
|
|
|
.anticon.anticon-question-circle-o {
|
|
|
margin-left: 5px;
|
|
|
}
|
|
|
+
|
|
|
::v-deep(.red-label .ant-form-item-label > label) {
|
|
|
color: red;
|
|
|
}
|