emis-frontend/src/views/emis/emisWaybillAttachment/emisWaybillAttachmentForm.vue

180 lines
5.0 KiB
Vue
Raw Normal View History

2024-03-01 04:54:02 +00:00
<template>
<div >
<el-row :gutter="0">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="24">
<el-form-item label="运单id" prop="waybillId">
<el-input v-model="form.waybillId" placeholder="请输入运单id" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="文件名称" prop="fileName">
<el-input v-model="form.fileName" placeholder="请输入文件名称" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="文件地址" prop="fileUrl">
<el-input v-model="form.fileUrl" placeholder="请输入文件地址" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="文件描述" prop="fileDesc">
<el-input v-model="form.fileDesc" placeholder="请输入文件描述" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="排序" prop="orderNum">
<el-input v-model="form.orderNum" placeholder="请输入排序" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-col>
<el-form-item label="上级字典">
<treeselect
ref="tree"
v-model="form.parentId"
:options="emisWaybillAttachmentOptions"
:normalizer="normalizer"
:default-expand-level="1"
:show-count="true"
placeholder="选择上级"
/>
</el-form-item>
</el-form>
</el-row>
<div style="text-align: center;margin-bottom: 10px;">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</div>
</template>
<script>
import { listEmisWaybillAttachment, getEmisWaybillAttachment, delEmisWaybillAttachment, addEmisWaybillAttachment, updateEmisWaybillAttachment } from "@/api/emis/emisWaybillAttachment";
export default {
name: "emisWaybillAttachmentForm",
props:{
id:undefined
},
components: { },
dicts: [
],
data() {
return {
emisWaybillAttachmentOptions: [],
// 遮罩层
loading: true,
// 表单参数
form: {},
// 表单校验
rules: {
id: [
{ required: true, message: "id不能为空", trigger: "blur" }
],
}
};
},
watch: {
"id": {
handler (newValue, oldValue) {
this.id = newValue;
this.initData();
},
deep: true
}
},
created() {
this.initData();
},
methods: {
initData() {
this.reset();
if(this.id !=undefined) {
this.loading = true;
getEmisWaybillAttachment(this.id).then(response => {
this.form = response.data;
this.loading = false;
});
}
this.getTreeselect();
},
// 取消按钮
cancel() {
this.reset();
this.$emit("on-cancel");
},
// 表单重置
reset() {
this.form = {
id: null,
waybillId: null,
fileName: null,
fileUrl: null,
fileDesc: null,
orderNum: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateEmisWaybillAttachment(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$emit("on-changed");
});
} else {
addEmisWaybillAttachment(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.$emit("on-changed");
});
}
}
});
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.idName,
children: node.children
};
},
/** 查询菜单下拉树结构 */
getTreeselect() {
const queryParams = {}
listEmisWaybillAttachment(queryParams).then(response => {
this.emisWaybillAttachmentOptions = [];
const rootItem = { idId: 0, emisWaybillAttachmentName: '-', children: [] };
rootItem.children = this.handleTree(response.data, "id");
this.emisWaybillAttachmentOptions.push(rootItem);
if(this.parentId != undefined) {
this.form.parentId = this.parentId;
}
});
},
}
};
</script>