test #47

Merged
gtz217 merged 273 commits from test into master 2023-10-17 08:53:54 +08:00
2 changed files with 98 additions and 52 deletions
Showing only changes of commit 006e94a865 - Show all commits

View File

@ -33,9 +33,27 @@
<base-dialog
:dialogTitle="title"
:dialogVisible="open"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<el-form ref="form" :model="form" :rules="rules" label-width="128px">
<DialogForm
v-if="open"
ref="form"
:dataForm="form"
:rows="[
[
{
input: true,
label: '检测类型名称',
prop: 'name',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
},
],
[{ input: true, label: '检测类型编码', prop: 'code' }],
[{ input: true, label: '备注', prop: 'remark' }],
]" />
<!-- <el-form ref="form" :model="form" :rules="rules" label-width="128px">
<el-form-item label="检测类型名称" prop="name">
<el-input v-model="form.name" placeholder="请输入检测类型名称" />
</el-form-item>
@ -45,14 +63,14 @@
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
</el-form> -->
</base-dialog>
</div>
</template>
<script>
import moment from 'moment';
import DialogForm from '../../components/dialogForm.vue';
import {
createQualityInspectionType,
@ -65,19 +83,23 @@ import {
export default {
name: 'QualityInspectionType',
components: {},
components: { DialogForm },
data() {
return {
tableBtn: [
this.$auth.hasPermi('base:quality-inspection-type:update') ? {
this.$auth.hasPermi('base:quality-inspection-type:update')
? {
type: 'edit',
btnName: '修改',
} : undefined,
this.$auth.hasPermi('base:quality-inspection-type:delete') ? {
}
: undefined,
this.$auth.hasPermi('base:quality-inspection-type:delete')
? {
type: 'delete',
btnName: '删除',
} : undefined,
].filter(v=>v),
}
: undefined,
].filter((v) => v),
tableData: [],
tableProps: [
{
@ -173,7 +195,7 @@ export default {
// name: 'reset',
// },
{
type: 'separate'
type: 'separate',
},
{
type: this.$auth.hasPermi('base:quality-inspection-type:create')
@ -195,6 +217,14 @@ export default {
],
};
},
// watch: {
// form: {
// handler: (val) => {
// console.log('form changed', val);
// },
// deep: true
// },
// },
created() {
this.getList();
},
@ -289,10 +319,13 @@ export default {
},
/** 提交按钮 */
submitForm() {
// console.log('this.$refs.form', this.$refs.form);
// return;
this.$refs['form'].validate((valid) => {
if (!valid) {
return;
}
console.log('final form', JSON.stringify(this.form));
//
if (this.form.id != null) {
updateQualityInspectionType(this.form).then((response) => {

View File

@ -9,21 +9,20 @@
<el-form
ref="form"
:model="form"
:rules="rules"
label-width="`${labelWidth}px`"
:label-width="`${labelWidth}px`"
v-loading="formLoading">
<el-row :gutter="20" v-for="(row, rindex) in rows" :key="rindex">
<el-col v-for="col in row" :key="col.label" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules">
<el-input
v-if="col.input"
v-model="form[col.prop]"
@change="$emit('update', form)"
rules="col.rules"
v-bind="col.bind" />
<el-select
v-if="col.select"
v-model="form[col.prop]"
@change="$emit('update', form)"
v-bind="col.bind">
<el-option
v-for="opt in optionListOf[col.prop]"
@ -42,13 +41,15 @@
* 找到最长的label
* @param {*} options
*/
function findMaxLabelWidth(options) {
function findMaxLabelWidth(rows) {
let max = 0;
options.forEach((opt) => {
rows.forEach((row) => {
row.forEach((opt) => {
if (opt.label.length > max) {
max = opt.label.length;
}
});
});
return max;
}
@ -61,7 +62,7 @@ export default {
emits: ['update'],
components: {},
props: {
options: {
rows: {
type: Array,
default: () => [],
},
@ -78,9 +79,10 @@ export default {
},
computed: {
labelWidth() {
let max = findMaxLabelWidth(this.options);
let max = findMaxLabelWidth(this.rows);
// 20px
return max * 20;
// return max * 20 + 'px';
},
form: {
get() {
@ -97,10 +99,18 @@ export default {
this.handleOptions();
},
methods: {
/** 模拟透传 ref */
validate(cb) {
return this.$refs.form.validate(cb);
},
resetFields(args) {
return this.$refs.form.resetFields(args);
},
handleOptions() {
this.formLoading = true;
const promiseList = [];
this.options.forEach(async (opt) => {
this.rows.forEach((cols) => {
cols.forEach(async (opt) => {
if (opt.options) {
this.optionListOf[opt.prop] = opt.options;
} else if (opt.url) {
@ -121,6 +131,7 @@ export default {
);
});
try {
this.formLoading = true;
await Promise.all(promiseList);
this.formLoading = false;
} catch (error) {
@ -129,6 +140,8 @@ export default {
}
}
});
});
// this.formLoading = false;
},
},
};