update DialogJustForm disabled status

This commit is contained in:
lb 2023-04-03 15:39:37 +08:00
parent 4e01129793
commit 697320d744
2 changed files with 22 additions and 12 deletions

View File

@ -20,7 +20,7 @@
<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="detailMode" v-bind="col.elparams" /> <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="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-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)">{{ <el-button type="" plain v-if="col.button" v-bind="col.elparams" style="width: 100%" @click="handleButtonClick(col)">{{
@ -30,7 +30,7 @@
v-if="col.cascader" v-if="col.cascader"
v-model="dataForm[col.prop]" v-model="dataForm[col.prop]"
:options="col.options" :options="col.options"
:disabled="detailMode" :disabled="IsNotAvaliable(col)"
v-bind="col.elparams" v-bind="col.elparams"
></el-cascader> ></el-cascader>
<el-select v-if="col.forceDisabledSelect" disabled v-model="dataForm[col.prop]" clearable v-bind="col.elparams"> <el-select v-if="col.forceDisabledSelect" disabled v-model="dataForm[col.prop]" clearable v-bind="col.elparams">
@ -40,7 +40,7 @@
v-if="col.select" v-if="col.select"
v-model="dataForm[col.prop]" v-model="dataForm[col.prop]"
clearable clearable
:disabled="detailMode" :disabled="IsNotAvaliable(col)"
v-bind="col.elparams" v-bind="col.elparams"
@change="handleSelectChange(col, $event)" @change="handleSelectChange(col, $event)"
> >
@ -54,14 +54,14 @@
@change="handleSwitchChange" @change="handleSwitchChange"
:disabled="detailMode" :disabled="detailMode"
/> />
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" /> <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="detailMode" v-bind="col.elparams" /> <el-date-picker v-if="col.datetime" v-model="dataForm[col.prop]" :disabled="IsNotAvaliable(col)" v-bind="col.elparams" />
<uploadBtn <uploadBtn
v-if="col.upload" v-if="col.upload"
:key="'upload_' + rowIndex + colIndex" :key="'upload_' + rowIndex + colIndex"
:action="col.actionUrl" :action="col.actionUrl"
:file-list="dataForm['files']" :file-list="dataForm['files']"
:disabled="detailMode" :disabled="IsNotAvaliable(col)"
v-bind="col.elparams" v-bind="col.elparams"
@update-file-list="handleFilelistUpdate" @update-file-list="handleFilelistUpdate"
/> />
@ -72,7 +72,7 @@
v-model="dataForm[col.prop]" v-model="dataForm[col.prop]"
:options="col.quillConfig ?? defaultQuillConfig" :options="col.quillConfig ?? defaultQuillConfig"
style="margin-top: 42px" style="margin-top: 42px"
:disabled="detailMode" :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">
@ -384,6 +384,9 @@ export default {
}, },
}, },
methods: { methods: {
IsNotAvaliable(col) {
return this.detailMode || (col.disableOnEdit && this.editMode);
},
handleFilelistUpdate(newFilelist) { handleFilelistUpdate(newFilelist) {
// TODO: 访 .files // TODO: 访 .files
this.dataForm.files = newFilelist.map((file) => ({ this.dataForm.files = newFilelist.map((file) => ({

View File

@ -104,6 +104,7 @@ export default function () {
optionValue: 'carId', optionValue: 'carId',
fetchData: () => this.$http.post("/pms/carHandle/pageView", { page: 1, limit: 999 }), fetchData: () => this.$http.post("/pms/carHandle/pageView", { page: 1, limit: 999 }),
disableWatcherOnEdit: true, disableWatcherOnEdit: true,
disableOnEdit: true, // 编辑模式下不可编辑
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },
elparams: { placeholder: "请输入窑车号", filterable: true }, elparams: { placeholder: "请输入窑车号", filterable: true },
injectTo: [ injectTo: [
@ -117,6 +118,7 @@ export default function () {
label: "当前位置", label: "当前位置",
// options: getDictDataList(), // options: getDictDataList(),
prop: "posCode", prop: "posCode",
elparams: { placeholder: "-" },
}, },
{ {
forceDisabledSelect: true, forceDisabledSelect: true,
@ -130,6 +132,7 @@ export default function () {
{ label: '摆渡车', value: '3' }, { label: '摆渡车', value: '3' },
{ label: '空窑车', value: '4' }, { label: '空窑车', value: '4' },
], ],
elparams: { placeholder: "-" },
}, },
{ {
select: true, select: true,
@ -139,7 +142,8 @@ export default function () {
{ label: '是', value: 'yes' }, { label: '是', value: 'yes' },
{ label: '否', value: 'no', default: true }, { label: '否', value: 'no', default: true },
], ],
// rules: { required: true, message: "必选项不能为空", trigger: "blur" }, default: 'no',
rules: { required: true, message: "必选项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择报废状态" }, elparams: { placeholder: "请选择报废状态" },
}, },
], ],
@ -154,7 +158,8 @@ export default function () {
hasPrev: 'carId', // 当 carId 改变的时候,也会 fetchData hasPrev: 'carId', // 当 carId 改变的时候,也会 fetchData
fetchDataParam: { search: 'carId', get: 'id' }, // 伴随着 hasPrev 出现 fetchDataParam: { search: 'carId', get: 'id' }, // 伴随着 hasPrev 出现
fetchData: (hisId) => this.$http.get(`/pms/carHandle/${hisId}`), fetchData: (hisId) => this.$http.get(`/pms/carHandle/${hisId}`),
disableWatcherOnEdit: true, disableWatcherOnEdit: true, // 编辑模式下关闭 watcher
disableOnEdit: true, // 编辑模式下不可编辑
rules: { required: true, message: "必选项不能为空", trigger: "blur" }, rules: { required: true, message: "必选项不能为空", trigger: "blur" },
elparams: { placeholder: "请选择订单" }, elparams: { placeholder: "请选择订单" },
injectTo: [ injectTo: [
@ -167,19 +172,19 @@ export default function () {
forceDisabled: true, forceDisabled: true,
label: "子号", label: "子号",
prop: "orderCate", prop: "orderCate",
elparams: { placeholder: "" }, elparams: { placeholder: "-" },
}, },
{ {
forceDisabled: true, forceDisabled: true,
label: "砖型", label: "砖型",
prop: "shapeCode", prop: "shapeCode",
elparams: { placeholder: "" }, elparams: { placeholder: "-" },
}, },
{ {
forceDisabled: true, forceDisabled: true,
label: "订单砖数", label: "订单砖数",
prop: "orderQty", prop: "orderQty",
elparams: { placeholder: "" }, elparams: { placeholder: "-" },
}, },
], ],
[ [
@ -205,6 +210,7 @@ export default function () {
}, },
{ {
input: true, input: true,
disableOnEdit: true, // 编辑模式下不可编辑
label: "检测人", label: "检测人",
prop: "checkPerson", prop: "checkPerson",
// rules: { required: true, message: "必填项不能为空", trigger: "blur" }, // rules: { required: true, message: "必填项不能为空", trigger: "blur" },
@ -212,6 +218,7 @@ export default function () {
}, },
{ {
datetime: true, datetime: true,
disableOnEdit: true, // 编辑模式下不可编辑
label: "检测时间", label: "检测时间",
prop: "checkTime", prop: "checkTime",
rules: { required: true, message: "必填项不能为空", trigger: "blur" }, rules: { required: true, message: "必填项不能为空", trigger: "blur" },