bugfix DialogJustForm

This commit is contained in:
lb 2023-04-04 15:22:46 +08:00
parent b0d172fee6
commit aa91d41412
2 changed files with 46 additions and 75 deletions

View File

@ -1,12 +1,6 @@
<template> <template>
<el-dialog <el-dialog class="dialog-just-form" :visible="dialogVisible" @close="handleClose" :destroy-on-close="false"
class="dialog-just-form" :close-on-click-modal="configs.clickModalToClose ?? true" :width="configs.dialogWidth ?? '50%'">
:visible="dialogVisible"
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? true"
:width="configs.dialogWidth ?? '50%'"
>
<!-- title --> <!-- title -->
<div slot="title" class="dialog-title"> <div slot="title" class="dialog-title">
<h1 class=""> <h1 class="">
@ -20,70 +14,46 @@
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length"> <el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length">
<!-- 通过多个 col === null 可以控制更灵活的 span 大小 --> <!-- 通过多个 col === null 可以控制更灵活的 span 大小 -->
<el-form-item v-if="col !== null" :label="col.label" :prop="col.prop" :rules="col.rules || null"> <el-form-item v-if="col !== null" :label="col.label" :prop="col.prop" :rules="col.rules || null">
<el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="IsNotAvaliable(col)" v-bind="col.elparams" /> <el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="IsNotAvaliable(col)"
<el-input v-if="col.forceDisabled && col.eraseOnSubmit" v-model="shadowDataForm[col.prop]" disabled v-bind="col.elparams" /> v-bind="col.elparams" />
<el-input v-if="col.forceDisabled && !col.eraseOnSubmit" v-model="dataForm[col.prop]" disabled v-bind="col.elparams" /> <el-input v-if="col.forceDisabled && col.eraseOnSubmit" v-model="shadowDataForm[col.prop]" disabled
<el-button type="" plain v-if="col.button" v-bind="col.elparams" style="width: 100%" @click="handleButtonClick(col)">{{ v-bind="col.elparams" />
<el-input v-if="col.forceDisabled && !col.eraseOnSubmit" v-model="dataForm[col.prop]" disabled
v-bind="col.elparams" />
<el-button type="" plain v-if="col.button" v-bind="col.elparams" style="width: 100%"
@click="handleButtonClick(col)">{{
col.label col.label
}}</el-button> }}</el-button>
<el-cascader <el-cascader v-if="col.cascader" v-model="dataForm[col.prop]" :options="col.options"
v-if="col.cascader" :disabled="IsNotAvaliable(col)" v-bind="col.elparams"></el-cascader>
v-model="dataForm[col.prop]" <el-select v-if="col.forceDisabledSelect" disabled v-model="dataForm[col.prop]" clearable
:options="col.options" v-bind="col.elparams">
:disabled="IsNotAvaliable(col)" <el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label"
v-bind="col.elparams" :value="opt.value" />
></el-cascader>
<el-select v-if="col.forceDisabledSelect" disabled v-model="dataForm[col.prop]" clearable v-bind="col.elparams">
<el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label" :value="opt.value" />
</el-select> </el-select>
<el-select <el-select v-if="col.select" v-model="dataForm[col.prop]" clearable :disabled="IsNotAvaliable(col)"
v-if="col.select" v-bind="col.elparams" @change="handleSelectChange(col, $event)">
v-model="dataForm[col.prop]" <el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label"
clearable :value="opt.value" />
:disabled="IsNotAvaliable(col)"
v-bind="col.elparams"
@change="handleSelectChange(col, $event)"
>
<el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label" :value="opt.value" />
</el-select> </el-select>
<el-switch <el-switch v-if="col.switch" v-model="dataForm[col.prop]" :active-value="col.activeValue ?? 1"
v-if="col.switch" :inactive-value="col.activeValue ?? 0" @change="handleSwitchChange" :disabled="detailMode" />
v-model="dataForm[col.prop]" <el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="IsNotAvaliable(col)"
:active-value="col.activeValue ?? 1" v-bind="col.elparams" />
:inactive-value="col.activeValue ?? 0" <el-date-picker v-if="col.datetime" v-model="dataForm[col.prop]" :disabled="IsNotAvaliable(col)"
@change="handleSwitchChange" v-bind="col.elparams" />
:disabled="detailMode" <uploadBtn v-if="col.upload" :key="'upload_' + rowIndex + colIndex" :action="col.actionUrl"
/> :file-list="dataForm['files']" :disabled="IsNotAvaliable(col)" v-bind="col.elparams"
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="IsNotAvaliable(col)" v-bind="col.elparams" /> @update-file-list="handleFilelistUpdate" />
<el-date-picker v-if="col.datetime" v-model="dataForm[col.prop]" :disabled="IsNotAvaliable(col)" v-bind="col.elparams" />
<uploadBtn
v-if="col.upload"
:key="'upload_' + rowIndex + colIndex"
:action="col.actionUrl"
:file-list="dataForm['files']"
:disabled="IsNotAvaliable(col)"
v-bind="col.elparams"
@update-file-list="handleFilelistUpdate"
/>
<quillEditor <quillEditor v-if="col.richInput" ref="quill-editor" v-model="dataForm[col.prop]"
v-if="col.richInput" :options="col.quillConfig ?? defaultQuillConfig" style="margin-top: 42px" :disabled="IsNotAvaliable(col)" />
ref="quill-editor"
v-model="dataForm[col.prop]"
:options="col.quillConfig ?? defaultQuillConfig"
style="margin-top: 42px"
:disabled="IsNotAvaliable(col)"
/>
<div class="" v-if="col.component" style="margin: 42px 0 0"> <div class="" v-if="col.component" style="margin: 42px 0 0">
<!-- 下面这个 component 几乎是为 富文本 quill 定制的了... TODO后续可能会根据业务需求创建新的版本 --> <!-- 下面这个 component 几乎是为 富文本 quill 定制的了... TODO后续可能会根据业务需求创建新的版本 -->
<component <component :is="col.component" :key="'component_' + col.prop"
:is="col.component" @update:modelValue="handleComponentModelUpdate(col.prop, $event)" :modelValue="dataForm[col.prop]"
:key="'component_' + col.prop" :mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'" />
@update:modelValue="handleComponentModelUpdate(col.prop, $event)"
:modelValue="dataForm[col.prop]"
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'"
/>
</div> </div>
<!-- add more... --> <!-- add more... -->
</el-form-item> </el-form-item>
@ -94,7 +64,8 @@
<!-- footer --> <!-- footer -->
<div slot="footer"> <div slot="footer">
<template v-for="(operate, index) in configs.form.operations"> <template v-for="(operate, index) in configs.form.operations">
<el-button v-if="showButton(operate)" :key="'operation_' + index" :type="operate.type" @click="handleBtnClick(operate)">{{ <el-button v-if="showButton(operate)" :key="'operation_' + index" :type="operate.type"
@click="handleBtnClick(operate)">{{
operate.label operate.label
}}</el-button> }}</el-button>
</template> </template>
@ -154,7 +125,7 @@ export default {
}); });
}); });
this.configs.extraFields.forEach((cnf) => { if (this.configs.extraFields) this.configs.extraFields.forEach((cnf) => {
dataForm[cnf.prop] = cnf.default ?? null; dataForm[cnf.prop] = cnf.default ?? null;
}); });
@ -381,7 +352,7 @@ export default {
}); });
}); });
this.configs.extraFields.forEach((cnf) => { if (this.configs.extraFields) this.configs.extraFields.forEach((cnf) => {
if (cnf.listenTo) { if (cnf.listenTo) {
console.log("set watcher for: ", cnf.prop); console.log("set watcher for: ", cnf.prop);
const unwatch = this.$watch( const unwatch = this.$watch(
@ -676,7 +647,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.dialog-just-form >>> .el-dialog__body { .dialog-just-form>>>.el-dialog__body {
/* padding-top: 16px !important; /* padding-top: 16px !important;
padding-bottom: 16px !important; */ padding-bottom: 16px !important; */
padding-top: 0 !important; padding-top: 0 !important;
@ -689,7 +660,7 @@ export default {
width: 100% !important; width: 100% !important;
} }
.dialog-just-form >>> .el-dialog__header { .dialog-just-form>>>.el-dialog__header {
padding: 10px 20px 10px; padding: 10px 20px 10px;
/* background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white); */ /* background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white); */
} }

View File

@ -17,7 +17,7 @@ export default function () {
// { prop: "dosLow", label: "加料下限" }, // { prop: "dosLow", label: "加料下限" },
// { prop: "dosHigh", label: "加料上限" }, // { prop: "dosHigh", label: "加料上限" },
{ prop: "description", label: "描述" }, { prop: "description", label: "描述" },
{ prop: "remark", label: "备注" }, // { prop: "remark", label: "备注" },
{ prop: "createTime", label: "添加时间", filter: timeFilter }, { prop: "createTime", label: "添加时间", filter: timeFilter },
{ {
prop: "operations", prop: "operations",
@ -129,7 +129,7 @@ export default function () {
// }, // },
], ],
[{ textarea: true, label: "描述信息", prop: "description", elparams: { placeholder: "描述信息" } }], [{ textarea: true, label: "描述信息", prop: "description", elparams: { placeholder: "描述信息" } }],
[{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], // [{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
], ],
operations: [ operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:materialStorage:save", showOnEdit: false }, { name: "add", label: "保存", type: "primary", permission: "pms:materialStorage:save", showOnEdit: false },