This commit is contained in:
shilixia 2020-07-08 16:00:08 +08:00
parent b6034728fd
commit 400fbf6a56
11 changed files with 1041 additions and 735 deletions

View File

@ -7,7 +7,12 @@ export function getEnterpriseList(query) {
params: query
})
}
export function getEnterprise(id) {
return request({
url: `/crm/enterprise/${id}/`,
method: 'get'
})
}
export function createEnterprise(data) {
return request({
url: '/crm/enterprise/',
@ -30,3 +35,34 @@ export function deleteEnterprise(id) {
method: 'delete'
})
}
export function getAddressList(query) {
return request({
url: '/crm/enterpriseaddress/',
method: 'get',
params: query
})
}
export function createAddress(data) {
return request({
url: '/crm/enterpriseaddress/',
method: 'post',
data
})
}
export function updateAddress(id, data) {
return request({
url: `/crm/enterpriseaddress/${id}/`,
method: 'put',
data
})
}
export function deleteAddress(id) {
return request({
url: `/certset/enterpriseaddress/${id}/`,
method: 'delete'
})
}

View File

@ -0,0 +1,237 @@
<template>
<div class="app-container">
<div>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">新增</el-button>
</div>
<el-table v-loading="listLoading"
:data="addressList"
style="width: 100%;margin-top:10px;"
border
fit
stripe
highlight-current-row
max-height="600">
<el-table-column type="index" width="50" />
<el-table-column align="center" label="中文地址">
<template slot-scope="scope">
{{ scope.row.address }}
</template>
</el-table-column>
<el-table-column align="center" label="英文地址">
<template slot-scope="scope">
{{ scope.row.eaddress }}
</template>
</el-table-column>
<el-table-column align="center" label="邮编">
<template slot-scope="scope">
{{ scope.row.code }}
</template>
</el-table-column>
<el-table-column align="center" label="地址类型">
<template slot-scope="scope">
{{ scope.row.type }}
</template>
</el-table-column>
</el-table>
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='update'?'编辑':'新增'">
<el-form ref="Form"
:model="addressData"
label-width="80px"
label-position="right"
:rules="rule1">
<el-form-item label="中文地址:" prop="address">
<el-input v-model="addressData.address" placeholder="中文地址" />
</el-form-item>
<el-form-item label="英文地址:" prop="eadress">
<el-input v-model="addressData.eaddress" placeholder="英文地址" />
</el-form-item>
<el-form-item label="地址邮编:" prop="code">
<el-input v-model="addressData.code" placeholder="邮编" />
</el-form-item>
<el-form-item label="地址类型:" prop="type">
<el-select v-model="addressData.type" placeholder="请选择地址类型" clearable :style="{width: '100%'}">
<el-option v-for="(item, index) in typeOptions" :key="index" :label="item.label"
:value="item.value" :disabled="item.disabled"></el-option>
</el-select>
</el-form-item>
<el-form-item label="级联选择" prop="county_code">
<el-select filterable v-model="addressData.country_code" @change='getValue'
placeholder="请选择国家"
clearable
:style="{width: '35%'}">
<el-option v-for="(item, index) in country_Options"
:key="index"
:label="item.name"
:value="item.id"
:disabled="item.disabled">
</el-option>
</el-select>
<el-cascader v-model="addressData.county_code" :options="countyOptions" :props="county_prosecode"
:style="{width: '60%'}" filterable placeholder="请选择地区"></el-cascader>
</el-form-item>
</el-form>
<div style="text-align:right;">
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
<el-button type="primary" @click="confirm('Form')">确认</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { getAddressList, createAddress, updateAddress, deleteAddress} from "@/api/enterprise"
import Pagination from "@/components/Pagination"
import checkPermission from '@/utils/permission'
import { genTree } from "@/utils";
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { getDictList } from "@/api/dict";
export default {
name:'AddressData',
components: {Treeselect, Pagination},
props:['enterprise'],
data() {
return {
addressData: {
id: null,
address: null,
eaddress: null,
code: null,
type: null,
county_code: null,
enterprise:this.enterprise
},
addressList: [],
listLoading: true,
listQuery: {
enterprise:this.enterprise
},
rule1: {
},
country_Options: [],
countyOptions:[],
field101Options: [],
county_prosecode: {
"multiple": false,
"label": "name",
"value": "value",
"children": "children"
},
typeOptions: [
{
label: "生产地址",
value: "生产地址"
},
{
label: "通信地址",
value: "通信地址"
},
{
label: "注册地址",
value: "注册地址"
}
],
dialogVisible:false,
dialogType:'create',
};
},
created() {
this.getList(),
this. getcountrytype()
},
methods: {
checkPermission,
getList() {
this.listLoading = true;
getAddressList(this.listQuery).then(response => {
if (response.data) {
this.addressList = response.data.results
}
this.listLoading = false
});
},
getcountrytype() {
getDictList({ type__code: "world_regions" }).then(response => {
this.country_Options = genTree(response.data);
});
this.getValue()
},
getValue() {
console.log(this.addressData.country_code)
if (this.addressData.country_code == 69) {
getDictList({ type__code: "china_regions" }).then(response => {
this.countyOptions = genTree(response.data);
});
}
else
this.countyOptions = '';
},
handleCreate() {
this.dialogType = 'create'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs['Form'].clearValidate()
})
},
handleUpdate(scope) {
this.addressData = Object.assign({}, scope.row) // copy obj
this.dialogType = 'update'
this.dialogVisible = true
this.$nextTick(() => {
this.$refs['Form'].clearValidate()
})
},
handleDelete(scope){
deleteAddress(scope.row.id).then(res=>{
this.$notify({
title: '成功',
type: 'success',
duration: 2000
})
this.getList()
})
},
async confirm(form) {
this.$refs[form].validate(valid => {
if (valid) {
const isEdit = this.dialogType === 'update'
if (isEdit) {
updateAddress(this.addressData.id, this.addressData).then(() => {
this.getList()
this.dialogVisible = false
this.$notify({
title: '成功',
type: 'success',
duration: 2000
})
})
} else {
this.addressData.county_code=this.addressData.county_code[2]
console.log(this.addressData)
createAddress(this.addressData).then(res => {
this.getList()
this.dialogVisible = false
this.$notify({
title: '成功',
type: 'success',
duration: 2000
})
})
}
} else {
return false
}
})
}
}
};
</script>

View File

@ -29,18 +29,14 @@
fit
stripe
highlight-current-row
max-height="800">
max-height="1000">
<el-table-column fixed="left" type="index" width="50" />
<el-table-column fixed="left" width="150" label="组织查询码">
<template slot-scope="scope">
{{ scope.row.query_code }}
</template>
</el-table-column>
<el-table-column width="150" label="编号">
<template slot-scope="scope">
{{ scope.row.fid }}
</template>
</el-table-column>
<el-table-column width="150" label="工厂编号">
<template slot-scope="scope">
{{ scope.row.code }}
@ -62,7 +58,7 @@
</template>
</el-table-column>
<el-table-column width="150" label="机构类型">
<template slot-scope="scope">
<template slot-scope="scope" v-if="scope.row.type">
{{ scope.row.type.name }}
</template>
</el-table-column>
@ -78,7 +74,7 @@
</el-table-column>
<el-table-column width="150" label="经济行业">
<template slot-scope="scope">
<template slot-scope="scope" v-if="scope.row.economy_class">
{{ scope.row.economy_class.name }}
</template>
</el-table-column>
@ -128,12 +124,12 @@
<template slot-scope="scope">
<el-button type="primary"
size="small"
:disabled="!checkPermission(['implementrule_update'])"
:disabled="!checkPermission(['enterprise_update'])"
@click="handleUpdate(scope)">编辑</el-button>
<el-button type="danger"
size="small"
:disabled="!checkPermission(['implementrule_delete'])"
:disabled="!checkPermission(['enterprise_delete'])"
@click="handleDelete(scope)">删除</el-button>
</template>
</el-table-column>
@ -147,7 +143,7 @@
</div>
</template>
<script>
import { getEnterpriseList } from "@/api/enterprise"
import { getEnterpriseList,deleteEnterprise } from "@/api/enterprise"
import Pagination from "@/components/Pagination"
import checkPermission from '@/utils/permission'
export default {
@ -191,7 +187,25 @@ export default {
handleCreate() {
this.$router.push({path:"/crm/enterprise/create"})
},
handleDelete(scope) {
this.$confirm('确定删除本条数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteEnterprise(scope.row.id).then(res=>{
this.$message.success('删除成功')
this.getList()
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
},
}
};
</script>

View File

@ -1,12 +1,8 @@
<template>
<div class="app-container">
<el-row :gutter="10">
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>组织基本信息</span>
</div>
<el-tabs type="border-card">
<el-tab-pane label="组织基本信息">
<el-form ref="elForm" :model="formData" :rules="rule1" size="medium" label-width="100px">
<el-col :span="8" font="left">
<el-form-item label="组织查询码" prop="query_code">
@ -74,7 +70,7 @@
:style="{width: '100%'}">
<el-option v-for="(item, index) in professional_classOptions"
:key="index"
:label="item.fullname"
:label="item.name"
:value="item.value"
:disabled="item.disabled">
@ -98,8 +94,8 @@
:style="{width: '100%'}">
<el-option v-for="(item, index) in economy_classOptions"
:key="index"
:label="item.fullname"
:value="item.code"
:label="item.name"
:value="item.value"
:disabled="item.disabled"></el-option>
</el-select>
</el-form-item>
@ -114,8 +110,8 @@
:style="{width: '100%'}">
<el-option v-for="(item, index) in type_Options"
:key="index"
:label="item.fullname"
:value="item.code"
:label="item.name"
:value="item.value"
:disabled="item.disabled">
</el-option>
@ -128,7 +124,7 @@
<el-col :span="8" font="left">
<el-form-item label="经济类型" prop="type">
<el-form-item label="经济类型" prop="economy_type">
<el-select filterable v-model="formData.economy_type"
placeholder="请选择经济类型"
clearable
@ -136,7 +132,7 @@
<el-option v-for="(item, index) in economy_typeOptions"
:key="index"
:label="item.name"
:value="item.code"
:value="item.value"
:disabled="item.disabled">
</el-option>
@ -171,8 +167,8 @@
</el-form-item>
</el-col>
</el-card>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>组织联系人信息</span>
@ -329,133 +325,21 @@
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
</el-card>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>组织地址信息</span>
</div>
<el-col :span="6" font="left">
<el-form-item label="注册地址" prop="registered_address">
<el-input v-model="formData.registered_address"
placeholder="中文地址"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="left">
<el-form-item prop="registered_eaddress">
<el-input v-model="formData.registered_eaddress"
placeholder="英文地址"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="right">
<el-form-item prop="registered_code">
<el-input v-model="formData.registered_code"
placeholder="地址邮编"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="right">
<el-form-item prop="linkman1_mobile">
<el-input v-model="formData.linkman1_mobile"
placeholder="地域代码"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="left">
<el-form-item label="通讯地址" prop="mailing_address">
<el-input v-model="formData.mailing_address"
placeholder="中文地址"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="left">
<el-form-item prop="mailing_eaddress">
<el-input v-model="formData.mailing_eaddress"
placeholder="英文地址"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="4" font="right">
<el-form-item prop="mailing_code">
<el-input v-model="formData.mailing_code"
placeholder="地址邮编"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="8" font="right">
<el-select filterable v-model="formData.country_type" @change='getValue'
placeholder="请选择国家"
clearable
:style="{width: '35%'}">
<el-option v-for="(item, index) in country_Options"
:key="index"
:label="item.name"
:value="item.code"
:disabled="item.disabled">
</el-option>
</el-select>
<el-form-item label="级联选择" prop="field101">
<el-cascader v-model="formData.field101" :options="field101Options" :props="field101Props"
:style="{width: '60%'}" filterable placeholder="请选择地区"></el-cascader>
</el-form-item>
</el-col>
<el-col :span="6" font="left">
<el-form-item label="生产地址" prop="production_address">
<el-input v-model="formData.production_address"
placeholder="中文地址"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="left">
<el-form-item prop="production_eaddress">
<el-input v-model="formData.production_eaddress"
placeholder="英文地址"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="right">
<el-form-item prop="production_postcode">
<el-input v-model="formData.production_postcode"
placeholder="地址邮编"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
<el-col :span="6" font="right">
<el-form-item prop="linkman1_mobile">
<el-input v-model="formData.linkman1_mobile"
placeholder="地域代码"
clearable
:style="{width: '100%'}"></el-input>
</el-form-item>
</el-col>
</el-card>
<el-col :span="24">
<el-col :span="24" style="margin-top:4px">
<el-form-item size="large">
<el-button type="primary" @click="submitForm">创建</el-button>
<el-button type="primary" @click="submitForm">保存</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
</el-tab-pane>
<el-tab-pane label="组织地址信息" v-if="formData.id">
<Addresstype :enterprise="formData.id"></Addresstype>
</el-tab-pane>
</el-tabs>
</div>
</template>
<style>
.text {
font-size: 14px;
@ -474,18 +358,17 @@
.clearfix:after {
clear: both
}
</style>
<script>
import { getDictList } from "@/api/dict";
import { createEnterprise } from "@/api/enterprise";
import { createEnterprise,getEnterprise } from "@/api/enterprise";
import { genTree } from "@/utils";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { upUrl, upHeaders } from "@/api/file";
import Addresstype from "@/views/enterprise/addresstype";
export default {
components: { Treeselect },
components: { Treeselect,Addresstype},
props: [],
data() {
return {
@ -493,15 +376,50 @@ export default {
upHeaders: upHeaders(),
upUrl: upUrl(),
formData: {
query_code: undefined,
name: undefined,
ename: undefined,
credit_code: undefined,
legal: undefined,
gassets: undefined,
person_count: undefined,
professional: undefined,
ceramics_output: undefined,
economy_class: undefined,
type: undefined,
economy_type: undefined,
build_time: undefined,
code: undefined,
business_type: undefined,
linkman1_name: undefined,
linkman1_duty: undefined,
linkman1_mobile: undefined,
linkman1_tel: undefined,
linkman1_fax: undefined,
linkman_email: undefined,
linkman2_name: undefined,
linkman2_duty: undefined,
linkman2_mobile: undefined,
linkman2_tel: undefined,
linkman2_fax: undefined,
linkman2_email: undefined,
linkman3_name: undefined,
linkman3_duty: undefined,
linkman3_mobile: undefined,
linkman3_tel: undefined,
linkman3_fax: undefined,
linkman3_email: undefined
},
economy_classOptions: [
],
economy_typeOptions:[],
professional_classOptions: [
],
type_Options: [],
country_typeOptions: [],
rule1: {
query_code: [{ required: true, message: '请输入组织查询码', trigger: 'blur' }],
code: [{ required: true, message: '请输入工厂编号', trigger: 'blur' }]
},
field101Options: [],
field101Props: {
"multiple": false,
@ -515,10 +433,11 @@ export default {
computed: {},
created() {
this.getEclass(),
this.getECclass(),
this.getPfclass(),
this.getTypeclass(),
this.getcountrytype()
this.getECtype()
},
mounted() { },
methods: {
@ -529,19 +448,16 @@ export default {
window.open(file.response.data.path);
}
},
handleSuccess(response, file, fileList) {
this.formData.path = response.data.path;
},
changeRules() {
},
getEclass() {
getPfclass() {
getDictList({ type__code: "professional_type" }).then(response => {
this.professional_classOptions = genTree(response.data);
});
},
getPfclass() {
getECclass() {
getDictList({ type__code: "economy_class" }).then(response => {
this.economy_classOptions = genTree(response.data);
});
@ -554,32 +470,33 @@ export default {
});
},
getcountrytype() {
getDictList({ type__code: "world_regions" }).then(response => {
this.country_Options = genTree(response.data);
getECtype() {
getDictList({ type__code: "economy_type" }).then(response => {
this. economy_typeOptions = genTree(response.data);
});
},
getValue() {
console.log(this.formData.field101);
if (this.formData.country_type == 69) {
getDictList({ type__code: "china_regions" }).then(response => {
this.field101Options = genTree(response.data);
});
}
else
this.field101Options = '';
},
submitForm() {
this.$refs["elForm"].validate(valid => {
if (!valid) return;
// TODO 提交表单
createEnterprise(this.formData).then(response => {
this.$router.go(-1);
this.$message({
type: 'success',
message: '成功!'
})
this.formData.id = response.data.id;
console.log(response.data);
});
});
},
resetForm() {
this.$refs["elForm"].resetFields();
}
}
};
</script>

View File

@ -79,6 +79,12 @@
:disabled="!checkPermission(['implementrule_update'])"
@click="handleUpdate(scope)"
>编辑</el-button>
<el-button
type="primary"
size="small"
:disabled="!checkPermission(['implementrule_update'])"
@click="handleUpate(scope)"
>单元划分</el-button>
<el-button
type="danger"
size="small"
@ -128,7 +134,7 @@ export default {
this.listLoading = true;
getImplementRuleList(this.listQuery).then(response => {
if (response.data) {
this.ruleList = response.data
this.ruleList = response.data.results
}
this.listLoading = false
});

View File

@ -1,10 +1,8 @@
<template>
<div class="app-container">
<el-tabs type="border-card">
<el-tab-pane label="规则信息">
<el-row :gutter="10">
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
<el-row>
<el-col :span="8">
<el-col :span="18">
<el-form-item label="认证类型" prop="cert_type">
<el-select
v-model="formData.cert_type"
@ -22,7 +20,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-col :span="18">
<el-form-item label="规则编号" prop="code">
<el-input
v-model="formData.code"
@ -32,7 +30,7 @@
></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-col :span="18">
<el-form-item label="规则名称" prop="name">
<el-input
v-model="formData.name"
@ -42,9 +40,7 @@
></el-input>
</el-form-item>
</el-col>
</el-row>
<el-col :span="24">
<el-col :span="18">
<el-form-item label="认证模式" prop="cert_pattern">
<el-select
v-model="formData.cert_pattern"
@ -63,7 +59,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="24" v-if="formData.cert_type =='pv'">
<el-col :span="18" v-if="formData.cert_type =='pv'">
<el-form-item label="产品领域" prop="pv_scope">
<el-select
v-model="formData.pv_scope"
@ -81,7 +77,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="24" v-if="formData.cert_type =='pv'">
<el-col :span="18" v-if="formData.cert_type =='pv'">
<el-form-item label="产品分类" prop="pv_class">
<treeselect
v-model="formData.pv_class"
@ -93,7 +89,7 @@
></treeselect>
</el-form-item>
</el-col>
<el-col :span="24" v-if="formData.cert_type =='ccc'">
<el-col :span="18" v-if="formData.cert_type =='ccc'">
<el-form-item label="产品分类" prop="ccc_list">
<treeselect
v-model="formData.ccc_list"
@ -105,7 +101,7 @@
></treeselect>
</el-form-item>
</el-col>
<el-col :span="24">
<el-col :span="18">
<el-form-item label="文件" prop="path">
<el-upload
:on-preview="handlePreview"
@ -119,31 +115,30 @@
</el-upload>
</el-form-item>
</el-col>
<el-col :span="24" style="margin-top:4px">
<el-col :span="24">
<el-form-item size="large">
<el-button type="primary" @click="submitForm">保存</el-button>
<el-button
type="primary"
@click="submitForm2"
v-if="formData.cert_type =='ccc'|| formData.cert_type == 'pv'"
>保存并继续单元划分</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-tab-pane>
<el-tab-pane label="单元类型划分" v-if="(formData.cert_type =='ccc'|| formData.cert_type == 'pv')&&(formData.id)">
<Unittype :implementrule="formData.id"></Unittype>
</el-tab-pane>
</el-tabs>
</el-row>
</div>
</template>
<script>
import { getDictList } from "@/api/dict";
import { updateImplementRule, getImplementRule } from "@/api/implementrule";
import { createImplementRule, getImplementRule } from "@/api/implementrule";
import { genTree } from "@/utils";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { upUrl, upHeaders } from "@/api/file";
import Unittype from "@/views/implementrule/unittype";
export default {
components: { Treeselect, Unittype },
components: { Treeselect },
props: [],
data() {
return {
@ -205,10 +200,18 @@ export default {
value: "sys"
}
],
pv_scopeOptions: [],
pv_classOptions: [],
ccc_listOptions: [],
cert_patternOptions: []
pv_scopeOptions: [
],
pv_classOptions: [
],
ccc_listOptions: [
],
cert_patternOptions: [
]
};
},
computed: {},
@ -216,12 +219,12 @@ export default {
"formData.cert_type": "changeRules"
},
created() {
this.formData.id = this.$route.query.id; //接收参数
this.formData.id = this.$route.query.id //接收参数
this.getRule();
this.getPvscope();
this.getPvclass();
this.getCccList();
this.getCertpattern();
this.getPvscope()
this.getPvclass()
this.getCccList()
this.getCertpattern()
},
mounted() {},
methods: {
@ -270,8 +273,8 @@ export default {
},
getRule() {
getImplementRule(this.formData.id).then(response => {
this.formData = response.data;
});
this.formData = response.data
})
},
getPvscope() {
getDictList({ type__code: "pv_scope" }).then(response => {
@ -305,11 +308,17 @@ export default {
this.$refs["elForm"].validate(valid => {
if (!valid) return;
// TODO 提交表单
updateImplementRule(this.formData.id, this.formData).then(response => {
this.$message({
type: 'success',
message: '成功!'
})
createImplementRule(this.formData).then(response => {
this.$router.go(-1);
});
});
},
submitForm2() {
this.$refs["elForm"].validate(valid => {
if (!valid) return;
// TODO 提交表单
createImplementRule(this.formData).then(response => {
//this.$router.go(-1);
});
});
},

View File

@ -0,0 +1,76 @@
# Generated by Django 3.0.5 on 2020-07-06 02:48
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('system', '0021_auto_20200616_1722'),
('crm', '0005_auto_20200701_1505'),
]
operations = [
migrations.RemoveField(
model_name='enterprise',
name='mailing_address',
),
migrations.RemoveField(
model_name='enterprise',
name='mailing_code',
),
migrations.RemoveField(
model_name='enterprise',
name='mailing_eaddress',
),
migrations.RemoveField(
model_name='enterprise',
name='production_address',
),
migrations.RemoveField(
model_name='enterprise',
name='production_eaddress',
),
migrations.RemoveField(
model_name='enterprise',
name='production_postcode',
),
migrations.RemoveField(
model_name='enterprise',
name='registered_address',
),
migrations.RemoveField(
model_name='enterprise',
name='registered_code',
),
migrations.RemoveField(
model_name='enterprise',
name='registered_eaddress',
),
migrations.CreateModel(
name='EnterpriseAddress',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
('address', models.CharField(blank=True, max_length=1000, null=True, verbose_name='地址名称')),
('eaddress', models.CharField(blank=True, max_length=1000, null=True, verbose_name='地址英文名称')),
('code', models.CharField(blank=True, max_length=1000, null=True, verbose_name='地址邮编邮编')),
('type', models.CharField(choices=[('2', '注册地址'), ('1', '通信地址'), ('0', '生产地址')], default='生产地址', max_length=50, verbose_name='地址类型')),
('country_code', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='enterpriseaddress_country_code', to='system.Dict', verbose_name='国家代码')),
('county_code', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='enterpriseaddress_county_code', to='system.Dict', verbose_name='县/区代码')),
('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='enterpriseaddress_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
('enterprise', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='enterpriseaddress_enterprise', to='crm.Enterprise', verbose_name='地址属性')),
('provinceCode', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='enterpriseaddress_provinceCode', to='system.Dict', verbose_name='省代码')),
('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='enterpriseaddress_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
],
options={
'abstract': False,
},
),
]

View File

@ -1,5 +1,5 @@
from django.db import models
from apps.system.models import CommonBModel, Dict
from apps.system.models import CommonBModel,CommonAModel,Dict
from simple_history.models import HistoricalRecords
import uuid
# Create your models here.
@ -27,20 +27,7 @@ class Enterprise(CommonBModel):
linkman2_fax = models.CharField('备用联系人传真',max_length=300,null=True, blank=True)
country_code = models.ForeignKey(Dict, on_delete=models.SET_NULL,null=True, blank=True,verbose_name='生产企业所在国家地区代码', related_name= 'enterprise_country_code')
credit_code = models.CharField('统一社会信用代码',max_length=300,null=True, blank=True)
registered_address = models.CharField('注册地址',max_length=1000,null=True, blank=True)
registered_eaddress = models.CharField('注册地址英文',max_length=1000,null=True, blank=True)
registered_code = models.CharField('注册地址邮编',max_length=1000,null=True, blank=True)
production_address = models.CharField('生产地址',null=True, blank=True,max_length=1000)
production_eaddress = models.CharField('生产英文地址',null=True, blank=True,max_length=1000)
production_postcode = models.CharField('生产地址邮编',null=True, blank=True,max_length=100)
mailing_address = models.CharField('通信地址',max_length=1000,null=True, blank=True)
mailing_eaddress = models.CharField('通信英文地址',max_length=1000,null=True, blank=True)
mailing_code = models.CharField('地址邮编',max_length=300,null=True, blank=True)
region_code = models.ForeignKey(Dict, on_delete=models.SET_NULL,verbose_name='县/区',null=True, blank=True, related_name= 'enterprise_region_code1')
# status = models.CharField('是否受理',null=True, blank=True, max_length=1000)
# bak1 = models.CharField('',null=True, blank=True, max_length=1000)
# bak2 = models.CharField('',null=True, blank=True, max_length=1000)
# bak3 = models.CharField('',null=True, blank=True, max_length=1000)
professional = models.ForeignKey(Dict, on_delete=models.SET_NULL,verbose_name='所属专业',null=True, blank=True, related_name= 'enterprise_professional')
qms_person = models.IntegerField('QMS人数',null=True, blank=True)
ems_person = models.IntegerField('EMS人数',null=True, blank=True)
@ -69,12 +56,23 @@ class Enterprise(CommonBModel):
def __str__(self):
return self.name
class EnterpriseAddress(CommonAModel):
EnterpriseFid = models.ForeignKey(Enterprise, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='地址属性', related_name='enterpriseaddress_ enterpriseFid')
type_choices = (
('注册地址', '注册地址'),
('通信地址', '通信地址'),
('生产地址', '生产地址')
)
enterprise= models.ForeignKey(Enterprise, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='地址属性', related_name='enterpriseaddress_enterprise')
address = models.CharField('地址名称',max_length=1000,null=True, blank=True)
eaddress = models.CharField('地址英文名称',max_length=1000,null=True, blank=True)
code = models.CharField('地址邮编邮编',max_length=1000,null=True, blank=True)
type = models.CharField('地址属性',max_length=1000,null=True, blank=True)
code = models.CharField('地址邮编',max_length=1000,null=True, blank=True)
type = models.CharField('地址类型', max_length=50,choices=type_choices, default='生产地址')
county_code = models.ForeignKey(Dict, on_delete=models.SET_NULL,verbose_name='县/区代码',null=True, blank=True, related_name= 'enterpriseaddress_county_code')
country_code = models.ForeignKey(Dict, on_delete=models.SET_NULL,verbose_name='国家代码',null=True, blank=True, related_name= 'enterpriseaddress_country_code')
provinceCode = models.ForeignKey(Dict, on_delete=models.SET_NULL,verbose_name='省代码',null=True, blank=True, related_name= 'enterpriseaddress_provinceCode')
class Meta:
verbose_name = '组织地址'
verbose_name_plural = verbose_name
def __str__(self):
return self.name

View File

@ -1,6 +1,6 @@
from rest_framework import serializers
from .models import Enterprise
from .models import Enterprise,EnterpriseAddress
from apps.system.serializers import DictSerializer
@ -13,7 +13,7 @@ class EnterpriseListSerializer(serializers.ModelSerializer):
economy_class = DictSerializer()
class Meta:
model = Enterprise
fields = ['id','query_code', 'code','fid', 'name','ename','type','legal','production_address','production_eaddress','production_postcode','build_time','person_count','ceramics_output','gassets','linkman1_name','linkman1_tel','linkman1_mobile','country_code','credit_code','professional','all_person','economy_class','economy_type','linkman1_duty','business_type']
fields = ['id','query_code', 'code', 'name','ename','type','legal','build_time','person_count','ceramics_output','gassets','linkman1_name','linkman1_tel','linkman1_mobile','country_code','credit_code','professional','all_person','economy_class','economy_type','linkman1_duty','business_type']
@staticmethod
def setup_eager_loading(queryset):
""" Perform necessary eager loading of data. """
@ -22,3 +22,10 @@ class EnterpriseListSerializer(serializers.ModelSerializer):
def get_cert_type(self, obj):
return obj.get_cert_type_display()
class EnterpriseAddressSerializer(serializers.ModelSerializer):
class Meta:
model = EnterpriseAddress
fields = '__all__'

View File

@ -1,9 +1,10 @@
from django.urls import path, include
from .views import EnterpriseViewSet
from .views import EnterpriseViewSet,EnterpriseAddressViewSet
from rest_framework import routers
router = routers.DefaultRouter()
router.register('enterprise', EnterpriseViewSet, basename="enterprise")
router.register('enterpriseaddress', EnterpriseAddressViewSet, basename="enterpriseaddress")
urlpatterns = [
path('', include(router.urls))

View File

@ -1,13 +1,14 @@
from django.shortcuts import render
from rest_framework.viewsets import ModelViewSet
from .models import Enterprise
from .models import Enterprise,EnterpriseAddress
from utils.queryset import get_child_queryset2
from .serializers import EnterpriseSerializer,EnterpriseListSerializer
from .serializers import EnterpriseSerializer,EnterpriseListSerializer,EnterpriseAddressSerializer
from apps.system.permission_data import RbacFilterSet
from apps.system.mixins import CreateUpdateCustomMixin, OptimizationMixin
# Create your views here.
class EnterpriseViewSet(RbacFilterSet, ModelViewSet):
class EnterpriseViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
perms_map = {'get': '*', 'post': 'Enterprise_create',
'put': 'Enterprise_update', 'delete': 'Enterprise_delete'}
queryset = Enterprise.objects
@ -20,9 +21,13 @@ class EnterpriseViewSet(RbacFilterSet, ModelViewSet):
return EnterpriseListSerializer
return EnterpriseSerializer
def get_queryset(self):
queryset = self.queryset
if hasattr(self.get_serializer_class(), 'setup_eager_loading'):
queryset = self.get_serializer_class().setup_eager_loading(queryset) # 性能优化
return queryset
class EnterpriseAddressViewSet(CreateUpdateCustomMixin, OptimizationMixin, ModelViewSet):
perms_map = {'get': '*', 'post': 'enterpriseaddress_create',
'put': 'enterpriseaddress_update', 'delete': 'enterpriseaddress_delete'}
queryset = EnterpriseAddress.objects
serializer_class = EnterpriseAddressSerializer
search_fields = ['address']
ordering = ['-create_time']