|
@@ -34,9 +34,7 @@
|
|
|
label="变量名称"
|
|
|
v-model:param="state.form.key"
|
|
|
/>
|
|
|
- <template
|
|
|
- v-if="state.form.type === 'String' || state.form.type === 'Textarea'"
|
|
|
- >
|
|
|
+ <template v-if="state.form.type === 'String'">
|
|
|
<CzrFormColumn
|
|
|
:span="24"
|
|
|
required
|
|
@@ -44,6 +42,38 @@
|
|
|
v-model:param="state.form.length"
|
|
|
/>
|
|
|
</template>
|
|
|
+ <template v-if="state.form.type === 'Select'">
|
|
|
+ <div class="mb-2 w-full">
|
|
|
+ <el-button @click="state.options.push({ value: '' })"
|
|
|
+ >添加下拉选项</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <template v-for="(item, index) in state.options">
|
|
|
+ <div class="mb-2 flex w-full items-center">
|
|
|
+ <CzrFormColumn
|
|
|
+ class="__czr-table-form-column"
|
|
|
+ :span="22"
|
|
|
+ required
|
|
|
+ :label="`选项${index + 1}`"
|
|
|
+ v-model:param="item.value"
|
|
|
+ layout="x"
|
|
|
+ />
|
|
|
+ <SvgIcon
|
|
|
+ v-if="state.options.length > 1"
|
|
|
+ name="czr_del"
|
|
|
+ class="__hover ml-2"
|
|
|
+ @click="state.options.splice(index, 1)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ <CzrFormColumn
|
|
|
+ :span="24"
|
|
|
+ required
|
|
|
+ label="是否必填"
|
|
|
+ v-model:param="state.form.required"
|
|
|
+ link="switch"
|
|
|
+ />
|
|
|
</CzrForm>
|
|
|
</div>
|
|
|
</CzrDialog>
|
|
@@ -60,6 +90,8 @@ import {
|
|
|
} from 'vue'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { VarsSource } from '@/views/workflow/types'
|
|
|
+import CzrDialog from '@/components/czr-ui/CzrDialog.vue'
|
|
|
+import CzrForm from '@/components/czr-ui/CzrForm.vue'
|
|
|
|
|
|
const emit = defineEmits(['update:show', 'refresh'])
|
|
|
const { proxy } = getCurrentInstance()
|
|
@@ -73,12 +105,12 @@ const state: any = reactive({
|
|
|
form: {
|
|
|
type: 'String',
|
|
|
},
|
|
|
+ options: [{ value: '' }],
|
|
|
})
|
|
|
const optionsType = [
|
|
|
{ type: 'String', label: '文本' },
|
|
|
- // {type: 'Textarea', label: '段落'},
|
|
|
{ type: 'Number', label: '数字' },
|
|
|
- // {type: 'Select', label: '下拉选项'},
|
|
|
+ { type: 'Select', label: '下拉选项' },
|
|
|
]
|
|
|
const titleCpt = computed(() => {
|
|
|
let t = '变量'
|
|
@@ -101,6 +133,9 @@ watch(
|
|
|
type: 'String',
|
|
|
source: VarsSource.Param,
|
|
|
}
|
|
|
+ if (state.form.type === 'Select') {
|
|
|
+ state.options = state.form.options.map((v) => ({ value: v }))
|
|
|
+ }
|
|
|
nextTick(() => {
|
|
|
ref_form.value.reset()
|
|
|
})
|
|
@@ -116,9 +151,12 @@ const onSubmit = () => {
|
|
|
label: state.form.label,
|
|
|
key: state.form.key,
|
|
|
type: state.form.type,
|
|
|
+ required: state.form.required,
|
|
|
}
|
|
|
- if (state.form.type === 'String' || state.form.type === 'Textarea') {
|
|
|
+ if (state.form.type === 'String') {
|
|
|
res.length = state.form.length
|
|
|
+ } else if (state.form.type === 'Select') {
|
|
|
+ res.options = state.options.map((v) => v.value)
|
|
|
}
|
|
|
emit('refresh', res)
|
|
|
})
|