|
@@ -1,77 +1,85 @@
|
|
|
-<template>
|
|
|
- <el-dialog :title="title" v-model="open" width="700px" append-to-body>
|
|
|
- <el-form ref="dialogFormRef" :model="form" :label-width="labelWidth" >
|
|
|
+<template>
|
|
|
+ <el-dialog :title="title" v-model="open" width="700px" append-to-body>
|
|
|
+ <el-form ref="dialogFormRef" :model="form" :label-width="labelWidth" class="dialogClass">
|
|
|
<template v-for="item in column" :key="item.prop">
|
|
|
<!-- 输入框 -->
|
|
|
<el-form-item :label="item.label" v-if="item.type === 'input'" :prop="item.prop" :rules="item.rules">
|
|
|
- <el-input v-model="form[item.prop]" :placeholder="'请输入' + item.label" clearable :disabled="disables[item.prop]">
|
|
|
- <template v-if="item.dese" #append > <a @click="item.deseClick?item.deseClick(form):''">{{ item.dese }}</a> </template>
|
|
|
+ <el-input v-model="form[item.prop]" :placeholder="'请输入' + item.label" clearable
|
|
|
+ :disabled="disables[item.prop]">
|
|
|
+ <template v-if="item.dese" #append> <a @click="item.deseClick ? item.deseClick(form) : ''">{{
|
|
|
+ item.dese }}</a> </template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
<!-- 文本域 -->
|
|
|
- <el-form-item :label="item.label" v-if="item.type === 'textarea'&& (item.show ? item.show(form): true)" :prop="item.prop" :rules="item.rules">
|
|
|
- <el-input v-model="form[item.prop]" type="textarea"
|
|
|
- :autosize="{ minRows: 2, maxRows: 4 }"
|
|
|
- :placeholder="'请输入' + item.label" clearable :disabled="disables[item.prop]"/>
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'textarea' && (item.show ? item.show(form) : true)"
|
|
|
+ :prop="item.prop" :rules="item.rules">
|
|
|
+ <el-input v-model="form[item.prop]" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }"
|
|
|
+ :placeholder="'请输入' + item.label" clearable :disabled="disables[item.prop]" />
|
|
|
</el-form-item>
|
|
|
|
|
|
- <el-form-item :label="item.label" v-if="item.type === 'radio' && item.options" :prop="item.prop" :rules="item.rules">
|
|
|
- <el-radio-group v-model="form[item.prop]" :disabled="disables[item.prop]">
|
|
|
- <el-radio v-for="dict in item.options" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'radio' && item.options" :prop="item.prop"
|
|
|
+ :rules="item.rules">
|
|
|
+ <el-radio-group v-model="form[item.prop]" :disabled="disables[item.prop]">
|
|
|
+ <el-radio v-for="dict in item.options" :key="dict.value" :value="dict.value">{{ dict.label
|
|
|
+ }}</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
+
|
|
|
|
|
|
<!-- 时间选择 -->
|
|
|
<el-form-item :label="item.label" v-if="item.type === 'date'" :prop="item.prop" :rules="item.rules">
|
|
|
<el-date-picker v-model="form[item.prop]" value-format="YYYY-MM-DD" type="daterange"
|
|
|
- range-separator="-" start-placeholder="开始日期" clearable end-placeholder="结束日期" :disabled="disables[item.prop]"></el-date-picker>
|
|
|
+ range-separator="-" start-placeholder="开始日期" clearable end-placeholder="结束日期"
|
|
|
+ :disabled="disables[item.prop]"></el-date-picker>
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 下拉框选择 -->
|
|
|
- <el-form-item :label="item.label" v-if="item.type === 'select' && item.dictionary" :prop="item.prop" :rules="item.rules">
|
|
|
- <el-select v-model="form[item.prop]" :placeholder="'请选择' + item.label" clearable :disabled="disables[item.prop]">
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'select' && item.dictionary" :prop="item.prop"
|
|
|
+ :rules="item.rules">
|
|
|
+ <el-select v-model="form[item.prop]" :placeholder="'请选择' + item.label" clearable
|
|
|
+ :disabled="disables[item.prop]">
|
|
|
<el-option v-for="dict in dictionaryOptions[item.dictionary]" :key="dict.value"
|
|
|
:label="dict.label" :value="dict.value"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <el-form-item :label="item.label" v-if="item.type === 'select' && item.options" :prop="item.prop" :rules="item.rules">
|
|
|
- <el-select v-model="form[item.prop]" :placeholder="'请选择' + item.label" clearable :disabled="disables[item.prop]">
|
|
|
- <el-option v-for="dict in item.options" :key="dict.value"
|
|
|
- :label="dict.label" :value="dict.value"></el-option>
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'select' && item.options" :prop="item.prop"
|
|
|
+ :rules="item.rules">
|
|
|
+ <el-select v-model="form[item.prop]" :placeholder="'请选择' + item.label" clearable
|
|
|
+ :disabled="disables[item.prop]">
|
|
|
+ <el-option v-for="dict in item.options" :key="dict.value" :label="dict.label"
|
|
|
+ :value="dict.value"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
|
|
|
- <!-- <el-form-item :label="item.label" v-if="item.type === 'dict' && item.dict" :prop="item.prop" :rules="item.rules">
|
|
|
- <el-select v-model="form[item.prop]" :placeholder="'请选择' + item.label" clearable :disabled="disables[item.prop]">
|
|
|
- <el-option v-for="dict in item.dict" :key="dict.value"
|
|
|
- :label="dict.label" :value="dict.value"></el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item> -->
|
|
|
|
|
|
- <!-- 联动选择框 -->
|
|
|
- <el-form-item :label="item.label" v-if="item.type === 'cascader' " :prop="item.prop">
|
|
|
+
|
|
|
+ <!-- 联动选择框 -->
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'cascader'" :prop="item.prop">
|
|
|
<el-cascader v-model="form[item.prop]" :options="item.options || []" style="width: 100%;"
|
|
|
- :props="item.props" :disabled="disables[item.prop]"/>
|
|
|
+ :props="item.props" :disabled="disables[item.prop]" />
|
|
|
</el-form-item>
|
|
|
|
|
|
- <!-- 图片预览 -->
|
|
|
- <el-form-item :label="item.label" v-if="item.type === 'img' " :prop="item.prop">
|
|
|
+ <!-- 图片预览 -->
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'img'" :prop="item.prop">
|
|
|
<el-space wrap>
|
|
|
- <div v-for="(imgItem,imgIndex) in getImages(item.prop)" :key="imgIndex">
|
|
|
- <img :src="imgItem" alt="" srcset="" style="width: 180px;" />
|
|
|
+ <div v-for="(imgItem, imgIndex) in getImages(item.prop)" :key="imgIndex">
|
|
|
+ <img :src="imgItem" alt="" srcset="" style="width: 100px;" />
|
|
|
</div>
|
|
|
</el-space>
|
|
|
</el-form-item>
|
|
|
+ <!-- 文本显示 -->
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'text'" :prop="item.prop" :rules="item.rules">
|
|
|
+ {{ form[item.prop] }} <a v-if="item.dese" @click="item.deseClick ? item.deseClick(form) : ''">{{
|
|
|
+ item.dese }}</a>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <!-- 字典显示 -->
|
|
|
+ <el-form-item :label="item.label" v-if="item.type === 'dict'" :prop="item.prop" :rules="item.rules">
|
|
|
+ <dict-tag v-if="item.dict" :options="item.dict" :value="String(form[item.prop])" />
|
|
|
+ </el-form-item>
|
|
|
</template>
|
|
|
|
|
|
-
|
|
|
- <!-- <el-form-item v-if="form.appStatus === '3'" label="驳回原因" prop="rejectReason" :rules="{ required: true, message: '请输入驳回原因', trigger: 'blur' }">
|
|
|
- <el-input v-model="form.rejectReason" type="textarea"
|
|
|
- :autosize="{ minRows: 2, maxRows: 4 }"
|
|
|
- placeholder="请输入驳回原因" clearable :disabled="disables.appStatus"/>
|
|
|
- </el-form-item> -->
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
@@ -102,6 +110,7 @@ const props = defineProps({
|
|
|
default: '120px',
|
|
|
},
|
|
|
|
|
|
+
|
|
|
})
|
|
|
|
|
|
const open = ref(false);
|
|
@@ -113,12 +122,14 @@ const dialogFormRef = ref(null);
|
|
|
|
|
|
const disables = ref({});
|
|
|
|
|
|
+const formStatus = ref('form') //form:表单 details:详情
|
|
|
+
|
|
|
|
|
|
const getImages = (key) => {
|
|
|
const imgs = form.value[key];
|
|
|
- console.log(233,imgs,key);
|
|
|
-
|
|
|
- if(!imgs){
|
|
|
+ console.log(233, imgs, key);
|
|
|
+
|
|
|
+ if (!imgs) {
|
|
|
return [];
|
|
|
}
|
|
|
return imgs.split(',')
|
|
@@ -126,13 +137,13 @@ const getImages = (key) => {
|
|
|
|
|
|
const handleInit = () => {
|
|
|
try {
|
|
|
- const data = props.column.value || props.column ;
|
|
|
+ const data = props.column.value || props.column;
|
|
|
const keys = data.map(item => {
|
|
|
if (item.type === 'select' && item.dictionary) {
|
|
|
return item.dictionary;
|
|
|
}
|
|
|
}).filter(Boolean);
|
|
|
- if(keys && keys.length > 0){
|
|
|
+ if (keys && keys.length > 0) {
|
|
|
const res = proxy.useDict(keys);
|
|
|
Object.assign(dictionaryOptions, res)
|
|
|
}
|
|
@@ -147,9 +158,9 @@ onMounted(() => {
|
|
|
handleInit();
|
|
|
})
|
|
|
|
|
|
-const handleDialog = (status,data) => {
|
|
|
- console.log('status',status);
|
|
|
- if(data){
|
|
|
+const handleDialog = (status, data) => {
|
|
|
+ console.log('status', status);
|
|
|
+ if (data) {
|
|
|
form.value = data;
|
|
|
}
|
|
|
open.value = status;
|
|
@@ -160,7 +171,7 @@ const submitForm = () => {
|
|
|
proxy.$refs["dialogFormRef"].validate(valid => {
|
|
|
if (valid) {
|
|
|
console.log('form', form.value);
|
|
|
- emit('submit',form.value)
|
|
|
+ emit('submit', form.value)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -172,10 +183,10 @@ const cancel = () => {
|
|
|
}
|
|
|
|
|
|
|
|
|
-const initForm = (data,disableData) => {
|
|
|
- console.log('initForm',data);
|
|
|
+const initForm = (data, disableData,formStatus) => {
|
|
|
+ console.log('initForm', data);
|
|
|
form.value = data;
|
|
|
- if(disableData){
|
|
|
+ if (disableData) {
|
|
|
disables.value = disableData;
|
|
|
}
|
|
|
}
|
|
@@ -183,8 +194,14 @@ const initForm = (data,disableData) => {
|
|
|
|
|
|
defineExpose({
|
|
|
handleDialog,
|
|
|
- initForm
|
|
|
+ initForm,
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
-<style lang='scss' scoped></style>
|
|
|
+<style lang='scss' scoped>
|
|
|
+.dialogClass {
|
|
|
+ height: calc(100vh - 280px);
|
|
|
+ overflow: hidden;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+</style>
|