222 lines
6.5 KiB
Vue
222 lines
6.5 KiB
Vue
|
|
<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="区域名称" prop="regionName">
|
|||
|
|
<el-input v-model="form.regionName" placeholder="请输入区域名称" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="英文名称" prop="regionNameEn">
|
|||
|
|
<el-input v-model="form.regionNameEn" placeholder="请输入英文名称" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="简称" prop="shortName">
|
|||
|
|
<el-input v-model="form.shortName" placeholder="请输入简称" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="代码" prop="code">
|
|||
|
|
<el-input v-model="form.code" placeholder="请输入代码" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="类型" prop="regionType">
|
|||
|
|
<el-input v-model="form.regionType" placeholder="请输入类型" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="邮编" prop="zipCode">
|
|||
|
|
<el-input v-model="form.zipCode" 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-col :span="24">
|
|||
|
|
<el-form-item label="删除标志(0代表存在" prop="delFlag">
|
|||
|
|
<el-input v-model="form.delFlag" placeholder="请输入删除标志(0代表存在" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="区域名称" prop="areaName">
|
|||
|
|
<el-input v-model="form.areaName" placeholder="请输入区域名称" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="国家代码" prop="countryCode">
|
|||
|
|
<el-input v-model="form.countryCode" placeholder="请输入国家代码" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
<el-col :span="24">
|
|||
|
|
<el-form-item label="国家名称" prop="countryName">
|
|||
|
|
<el-input v-model="form.countryName" placeholder="请输入国家名称" />
|
|||
|
|
</el-form-item>
|
|||
|
|
</el-col>
|
|||
|
|
|
|||
|
|
<el-form-item label="上级字典">
|
|||
|
|
<treeselect
|
|||
|
|
ref="tree"
|
|||
|
|
v-model="form.parentId"
|
|||
|
|
:options="emisRegionOptions"
|
|||
|
|
: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 { listEmisRegion, getEmisRegion, delEmisRegion, addEmisRegion, updateEmisRegion } from "@/api/emis/emisRegion";
|
|||
|
|
|
|||
|
|
export default {
|
|||
|
|
name: "emisRegionForm",
|
|||
|
|
props:{
|
|||
|
|
id:undefined
|
|||
|
|
},
|
|||
|
|
components: { },
|
|||
|
|
dicts: [
|
|||
|
|
],
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
emisRegionOptions: [],
|
|||
|
|
// 遮罩层
|
|||
|
|
loading: true,
|
|||
|
|
// 表单参数
|
|||
|
|
form: {},
|
|||
|
|
// 表单校验
|
|||
|
|
rules: {
|
|||
|
|
id: [
|
|||
|
|
{ required: true, message: "id不能为空", trigger: "blur" }
|
|||
|
|
],
|
|||
|
|
regionName: [
|
|||
|
|
{ required: true, message: "区域名称不能为空", trigger: "blur" }
|
|||
|
|
],
|
|||
|
|
regionNameEn: [
|
|||
|
|
{ required: true, message: "英文名称不能为空", trigger: "blur" }
|
|||
|
|
],
|
|||
|
|
parentId: [
|
|||
|
|
{ required: true, message: "父区域不能为空", 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;
|
|||
|
|
getEmisRegion(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,
|
|||
|
|
regionName: null,
|
|||
|
|
regionNameEn: null,
|
|||
|
|
shortName: null,
|
|||
|
|
parentId: null,
|
|||
|
|
code: null,
|
|||
|
|
countryId: null,
|
|||
|
|
countryAreaId: null,
|
|||
|
|
regionType: null,
|
|||
|
|
zipCode: null,
|
|||
|
|
remark: null,
|
|||
|
|
tenantId: null,
|
|||
|
|
delFlag: null,
|
|||
|
|
createBy: null,
|
|||
|
|
createTime: null,
|
|||
|
|
updateBy: null,
|
|||
|
|
updateTime: null,
|
|||
|
|
areaName: null,
|
|||
|
|
countryCode: null,
|
|||
|
|
countryName: null
|
|||
|
|
};
|
|||
|
|
this.resetForm("form");
|
|||
|
|
},
|
|||
|
|
/** 提交按钮 */
|
|||
|
|
submitForm() {
|
|||
|
|
this.$refs["form"].validate(valid => {
|
|||
|
|
if (valid) {
|
|||
|
|
if (this.form.id != null) {
|
|||
|
|
updateEmisRegion(this.form).then(response => {
|
|||
|
|
this.$modal.msgSuccess("修改成功");
|
|||
|
|
this.$emit("on-changed");
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
addEmisRegion(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 = {}
|
|||
|
|
listEmisRegion(queryParams).then(response => {
|
|||
|
|
this.emisRegionOptions = [];
|
|||
|
|
const rootItem = { idId: 0, emisRegionName: '-', children: [] };
|
|||
|
|
rootItem.children = this.handleTree(response.data, "id");
|
|||
|
|
this.emisRegionOptions.push(rootItem);
|
|||
|
|
|
|||
|
|
if(this.parentId != undefined) {
|
|||
|
|
this.form.parentId = this.parentId;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
</script>
|