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>
<el-dialog
class="dialog-just-form"
:visible="dialogVisible"
@close="handleClose"
:destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? true"
:width="configs.dialogWidth ?? '50%'"
>
<el-dialog class="dialog-just-form" :visible="dialogVisible" @close="handleClose" :destroy-on-close="false"
:close-on-click-modal="configs.clickModalToClose ?? true" :width="configs.dialogWidth ?? '50%'">
<!-- title -->
<div slot="title" class="dialog-title">
<h1 class="">
@ -20,70 +14,46 @@
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length">
<!-- 通过多个 col === null 可以控制更灵活的 span 大小 -->
<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.forceDisabled && col.eraseOnSubmit" v-model="shadowDataForm[col.prop]" disabled 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
}}</el-button>
<el-cascader
v-if="col.cascader"
v-model="dataForm[col.prop]"
:options="col.options"
:disabled="IsNotAvaliable(col)"
v-bind="col.elparams"
></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-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="IsNotAvaliable(col)"
v-bind="col.elparams" />
<el-input v-if="col.forceDisabled && col.eraseOnSubmit" v-model="shadowDataForm[col.prop]" disabled
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
}}</el-button>
<el-cascader v-if="col.cascader" v-model="dataForm[col.prop]" :options="col.options"
:disabled="IsNotAvaliable(col)" v-bind="col.elparams"></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
v-if="col.select"
v-model="dataForm[col.prop]"
clearable
: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 v-if="col.select" v-model="dataForm[col.prop]" clearable :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-switch
v-if="col.switch"
v-model="dataForm[col.prop]"
:active-value="col.activeValue ?? 1"
:inactive-value="col.activeValue ?? 0"
@change="handleSwitchChange"
:disabled="detailMode"
/>
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="IsNotAvaliable(col)" v-bind="col.elparams" />
<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"
/>
<el-switch v-if="col.switch" v-model="dataForm[col.prop]" :active-value="col.activeValue ?? 1"
:inactive-value="col.activeValue ?? 0" @change="handleSwitchChange" :disabled="detailMode" />
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="IsNotAvaliable(col)"
v-bind="col.elparams" />
<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
v-if="col.richInput"
ref="quill-editor"
v-model="dataForm[col.prop]"
:options="col.quillConfig ?? defaultQuillConfig"
style="margin-top: 42px"
:disabled="IsNotAvaliable(col)"
/>
<quillEditor v-if="col.richInput" 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">
<!-- 下面这个 component 几乎是为 富文本 quill 定制的了... TODO后续可能会根据业务需求创建新的版本 -->
<component
:is="col.component"
:key="'component_' + col.prop"
@update:modelValue="handleComponentModelUpdate(col.prop, $event)"
:modelValue="dataForm[col.prop]"
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'"
/>
<component :is="col.component" :key="'component_' + col.prop"
@update:modelValue="handleComponentModelUpdate(col.prop, $event)" :modelValue="dataForm[col.prop]"
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'" />
</div>
<!-- add more... -->
</el-form-item>
@ -94,9 +64,10 @@
<!-- footer -->
<div slot="footer">
<template v-for="(operate, index) in configs.form.operations">
<el-button v-if="showButton(operate)" :key="'operation_' + index" :type="operate.type" @click="handleBtnClick(operate)">{{
operate.label
}}</el-button>
<el-button v-if="showButton(operate)" :key="'operation_' + index" :type="operate.type"
@click="handleBtnClick(operate)">{{
operate.label
}}</el-button>
</template>
<el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button>
</div>
@ -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;
});
@ -381,7 +352,7 @@ export default {
});
});
this.configs.extraFields.forEach((cnf) => {
if (this.configs.extraFields) this.configs.extraFields.forEach((cnf) => {
if (cnf.listenTo) {
console.log("set watcher for: ", cnf.prop);
const unwatch = this.$watch(
@ -676,7 +647,7 @@ export default {
</script>
<style scoped>
.dialog-just-form >>> .el-dialog__body {
.dialog-just-form>>>.el-dialog__body {
/* padding-top: 16px !important;
padding-bottom: 16px !important; */
padding-top: 0 !important;
@ -689,7 +660,7 @@ export default {
width: 100% !important;
}
.dialog-just-form >>> .el-dialog__header {
.dialog-just-form>>>.el-dialog__header {
padding: 10px 20px 10px;
/* 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: "dosHigh", label: "加料上限" },
{ prop: "description", label: "描述" },
{ prop: "remark", label: "备注" },
// { prop: "remark", label: "备注" },
{ prop: "createTime", label: "添加时间", filter: timeFilter },
{
prop: "operations",
@ -129,7 +129,7 @@ export default function () {
// },
],
[{ textarea: true, label: "描述信息", prop: "description", elparams: { placeholder: "描述信息" } }],
[{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
// [{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
],
operations: [
{ name: "add", label: "保存", type: "primary", permission: "pms:materialStorage:save", showOnEdit: false },