commit
2463587f19
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../:\py_workspace\ERP_5\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="django" name="Django">
|
||||
<configuration>
|
||||
<option name="rootFolder" value="$MODULE_DIR$" />
|
||||
<option name="settingsModule" value="ERP_5/settings.py" />
|
||||
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
|
||||
<option name="environment" value="<map/>" />
|
||||
<option name="doNotUseTestRunner" value="false" />
|
||||
<option name="trackFilePattern" value="migrations" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/ERP_5/apps" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||
<option name="TEMPLATE_FOLDERS">
|
||||
<list>
|
||||
<option value="$MODULE_DIR$/../ERP_5\templates" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="erp_5" uuid="4bc53945-f65a-487e-8aae-a32e60fe31b7">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306/erp_5</jdbc-url>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
||||
#n:information_schema
|
||||
!<md> [null, 0, null, null, -2147483648, -2147483648]
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||
<serverData>
|
||||
<paths name="root@192.168.23.3:22 agent">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="root@192.168.23.3:22 password">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,33 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="6">
|
||||
<item index="0" class="java.lang.String" itemvalue="mysqlclient" />
|
||||
<item index="1" class="java.lang.String" itemvalue="install" />
|
||||
<item index="2" class="java.lang.String" itemvalue="Django" />
|
||||
<item index="3" class="java.lang.String" itemvalue="urllib3" />
|
||||
<item index="4" class="java.lang.String" itemvalue="redis" />
|
||||
<item index="5" class="java.lang.String" itemvalue="idna" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="E501" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="N802" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (django-3.2.16_env) (3)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/ERP_5.iml" filepath="$PROJECT_DIR$/.idea/ERP_5.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/datas/nation_data.sql" dialect="GenericSQL" />
|
||||
<file url="PROJECT" dialect="MySQL" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,4 @@
|
||||
|
||||
from .celery import celery_app
|
||||
|
||||
__all__ = ('celery_app',)
|
@ -0,0 +1 @@
|
||||
# 存放所有项目中APP
|
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
@ -0,0 +1,9 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BasicInfoConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'basic_info'
|
||||
|
||||
def ready(self):
|
||||
import basic_info.signals
|
@ -0,0 +1,56 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-26 20:15
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Nation',
|
||||
fields=[
|
||||
('id', models.IntegerField(primary_key=True, serialize=False)),
|
||||
('n_name', models.CharField(max_length=30, verbose_name='国家名称')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '国家表',
|
||||
'verbose_name_plural': '国家表',
|
||||
'db_table': 'nation',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Province',
|
||||
fields=[
|
||||
('id', models.IntegerField(primary_key=True, serialize=False)),
|
||||
('p_name', models.CharField(max_length=30, verbose_name='省份名称')),
|
||||
('nation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='province_list', to='basic_info.nation', verbose_name='省份所在的国家')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '省份表',
|
||||
'verbose_name_plural': '省份表',
|
||||
'db_table': 'province',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='City',
|
||||
fields=[
|
||||
('id', models.IntegerField(primary_key=True, serialize=False)),
|
||||
('c_name', models.CharField(max_length=30, verbose_name='城市名称')),
|
||||
('province', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='city_list', to='basic_info.province', verbose_name='城市所在的省份')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '城市表',
|
||||
'verbose_name_plural': '城市表',
|
||||
'db_table': 'city',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
),
|
||||
]
|
@ -0,0 +1,44 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-26 20:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('basic_info', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SupplierModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=100, unique=True, verbose_name='供应商名称')),
|
||||
('mobile', models.CharField(blank=True, max_length=11, null=True, verbose_name='手机号码')),
|
||||
('phone', models.CharField(blank=True, max_length=22, null=True, verbose_name='联系电话')),
|
||||
('contacts_name', models.CharField(blank=True, max_length=22, null=True, verbose_name='联系人名')),
|
||||
('email', models.CharField(blank=True, max_length=50, null=True, verbose_name='电子邮箱')),
|
||||
('ratepayer_number', models.CharField(blank=True, max_length=50, null=True, verbose_name='纳税人识别号码')),
|
||||
('bank', models.CharField(blank=True, max_length=50, null=True, verbose_name='开户银行')),
|
||||
('account_number', models.CharField(blank=True, max_length=50, null=True, verbose_name='银行账号')),
|
||||
('nation', models.CharField(blank=True, max_length=50, null=True, verbose_name='国家')),
|
||||
('province', models.CharField(blank=True, max_length=50, null=True, verbose_name='省份')),
|
||||
('city', models.CharField(blank=True, max_length=50, null=True, verbose_name='城市')),
|
||||
('address', models.CharField(blank=True, max_length=50, null=True, verbose_name='详细地址')),
|
||||
('remark', models.CharField(blank=True, max_length=512, null=True, verbose_name='备注')),
|
||||
('init_pay', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=20, verbose_name='初期应付')),
|
||||
('current_pay', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=20, verbose_name='末期应付')),
|
||||
('order_number', models.IntegerField(default=100, verbose_name='排序号码')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '供应商',
|
||||
'verbose_name_plural': '供应商',
|
||||
'db_table': 't_supplier',
|
||||
'ordering': ['order_number', 'id'],
|
||||
},
|
||||
),
|
||||
]
|
@ -0,0 +1,44 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-26 21:48
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('basic_info', '0002_suppliermodel'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='CustomerModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=100, unique=True, verbose_name='客户名称')),
|
||||
('mobile', models.CharField(blank=True, max_length=11, null=True, verbose_name='手机号码')),
|
||||
('phone', models.CharField(blank=True, max_length=22, null=True, verbose_name='联系电话')),
|
||||
('contacts_name', models.CharField(blank=True, max_length=22, null=True, verbose_name='联系人名')),
|
||||
('email', models.CharField(blank=True, max_length=50, null=True, verbose_name='电子邮箱')),
|
||||
('ratepayer_number', models.CharField(blank=True, max_length=50, null=True, verbose_name='纳税人识别号码')),
|
||||
('bank', models.CharField(blank=True, max_length=50, null=True, verbose_name='开户银行')),
|
||||
('account_number', models.CharField(blank=True, max_length=50, null=True, verbose_name='银行账号')),
|
||||
('nation', models.CharField(blank=True, max_length=50, null=True, verbose_name='国家')),
|
||||
('province', models.CharField(blank=True, max_length=50, null=True, verbose_name='省份')),
|
||||
('city', models.CharField(blank=True, max_length=50, null=True, verbose_name='城市')),
|
||||
('address', models.CharField(blank=True, max_length=50, null=True, verbose_name='详细地址')),
|
||||
('remark', models.CharField(blank=True, max_length=512, null=True, verbose_name='备注')),
|
||||
('init_receivable', models.DecimalField(blank=True, decimal_places=2, max_digits=20, null=True, verbose_name='初期应收')),
|
||||
('current_receivable', models.DecimalField(blank=True, decimal_places=2, max_digits=20, null=True, verbose_name='末期应收')),
|
||||
('order_number', models.IntegerField(default=100, verbose_name='排序号码')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '客户',
|
||||
'verbose_name_plural': '客户',
|
||||
'db_table': 't_customer',
|
||||
'ordering': ['order_number', 'id'],
|
||||
},
|
||||
),
|
||||
]
|
@ -0,0 +1,64 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-28 20:49
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('basic_info', '0003_customermodel'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SettlementAccountModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=100, unique=True, verbose_name='仓库名称')),
|
||||
('number_code', models.CharField(max_length=28, unique=True, verbose_name='编号')),
|
||||
('remark', models.CharField(blank=True, max_length=512, null=True, verbose_name='备注')),
|
||||
('init_amount', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='初期金额')),
|
||||
('balance', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='余额')),
|
||||
('order_number', models.IntegerField(default=100, verbose_name='排序号码')),
|
||||
('is_default', models.BooleanField(default=False, verbose_name='是否默认')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '结算账户',
|
||||
'verbose_name_plural': '结算账户',
|
||||
'db_table': 't_settlement_account',
|
||||
'ordering': ['order_number', 'id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='WarehouseModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=100, unique=True, verbose_name='仓库名称')),
|
||||
('nation', models.CharField(blank=True, max_length=50, null=True, verbose_name='国家')),
|
||||
('province', models.CharField(blank=True, max_length=50, null=True, verbose_name='省份')),
|
||||
('city', models.CharField(blank=True, max_length=50, null=True, verbose_name='城市')),
|
||||
('address', models.CharField(blank=True, max_length=50, null=True, verbose_name='详细地址')),
|
||||
('remark', models.CharField(blank=True, max_length=512, null=True, verbose_name='备注')),
|
||||
('warehouse_fee', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='仓储费用(元/天/KG)')),
|
||||
('truckage', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='搬运费用')),
|
||||
('order_number', models.IntegerField(default=100, verbose_name='排序号码')),
|
||||
('is_default', models.BooleanField(default=False, verbose_name='是否默认的仓库')),
|
||||
('leader_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='仓库负责人')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '仓库',
|
||||
'verbose_name_plural': '仓库',
|
||||
'db_table': 't_warehouse',
|
||||
'ordering': ['order_number', 'id'],
|
||||
},
|
||||
),
|
||||
]
|
@ -0,0 +1,29 @@
|
||||
from rest_framework import serializers
|
||||
from basic_info.models import Nation, Province, City
|
||||
|
||||
|
||||
class NationSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
国家列化器
|
||||
"""
|
||||
class Meta:
|
||||
model = Nation
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ProvinceSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
省份列化器
|
||||
"""
|
||||
class Meta:
|
||||
model = Province
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class CitySerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
城市列化器
|
||||
"""
|
||||
class Meta:
|
||||
model = City
|
||||
fields = '__all__'
|
@ -0,0 +1,24 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from basic_info.models import CustomerModel
|
||||
|
||||
|
||||
class CustomerSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
客户信息的序列化器
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = CustomerModel
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class CustomerFindSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
搜索过滤的序列化器
|
||||
"""
|
||||
name = serializers.CharField(required=False, write_only=True, help_text='客户名称关键字')
|
||||
|
||||
class Meta:
|
||||
model = CustomerModel
|
||||
fields = ['name', 'mobile', 'phone']
|
@ -0,0 +1,12 @@
|
||||
from basic_info.models import SettlementAccountModel
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class AccountSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
结算账户信息的序列化器
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = SettlementAccountModel
|
||||
fields = '__all__'
|
@ -0,0 +1,24 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from basic_info.models import SupplierModel
|
||||
|
||||
|
||||
class SupplierSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
供应商信息的序列化器
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = SupplierModel
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class SupplierFindSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
搜索过滤的序列化器
|
||||
"""
|
||||
name = serializers.CharField(required=False, write_only=True)
|
||||
|
||||
class Meta:
|
||||
model = SupplierModel
|
||||
fields = ['name', 'mobile', 'phone']
|
@ -0,0 +1,24 @@
|
||||
from basic_info.models import WarehouseModel
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class WarehouseSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
仓库信息的序列化器
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = WarehouseModel
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
# 用于查询结果的序列化器,因为需要显示负责人的真实名字
|
||||
class WarehouseSearchSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
查询结果的序列化, SlugRelatedField,返回主表的某一个字段值:slug_field可以指定一个需要展示的字段
|
||||
"""
|
||||
leader_user = serializers.SlugRelatedField(slug_field='real_name', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = WarehouseModel
|
||||
fields = '__all__'
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,39 @@
|
||||
"""ERP_5 URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/3.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, re_path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import supplier_views, customer_views, area_viewsets, settlement_account_views, warehouse_views
|
||||
from rest_framework_jwt.views import obtain_jwt_token
|
||||
|
||||
urlpatterns = [
|
||||
# path('admin/', admin.site.urls),
|
||||
# path('users/login/', obtain_jwt_token), # 登录并且由JWT签发token
|
||||
# re_path(r'^users/reset/(?P<pk>\d+)/$', user_views.ResetPasswordView.as_view()),
|
||||
|
||||
|
||||
]
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register('suppliers', supplier_views.SupplierViewSet)
|
||||
router.register('customers', customer_views.CustomerViewSet)
|
||||
router.register(r'nation', area_viewsets.NationView) # 国家的视图接口
|
||||
router.register(r'province', area_viewsets.ProvinceView) # 省份的视图接口
|
||||
router.register(r'city', area_viewsets.CityView) # 城市的视图接口
|
||||
router.register(r'warehouses', warehouse_views.WarehouseView) #
|
||||
router.register(r'accounts', settlement_account_views.AccountView) #
|
||||
|
||||
urlpatterns += router.urls
|
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
@ -0,0 +1,9 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ErpSystemConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'erp_system'
|
||||
#
|
||||
# def ready(self):
|
||||
# import erp_system.signals
|
@ -0,0 +1,67 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-14 20:25
|
||||
|
||||
import django.contrib.auth.models
|
||||
import django.contrib.auth.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Menu',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('number', models.IntegerField(blank=True, null=True, verbose_name='排序数字')),
|
||||
('url', models.CharField(blank=True, max_length=256, null=True, verbose_name='菜单访问的URL')),
|
||||
('name', models.CharField(max_length=50, verbose_name='菜单名字')),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='erp_system.menu')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '功能菜单',
|
||||
'verbose_name_plural': '功能菜单',
|
||||
'db_table': 't_menu',
|
||||
'ordering': ['number'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='UserModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('password', models.CharField(max_length=128, verbose_name='password')),
|
||||
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
||||
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
|
||||
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
|
||||
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
|
||||
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
|
||||
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
||||
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
||||
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
|
||||
('phone', models.CharField(blank=True, max_length=11, null=True, unique=True, verbose_name='手机号码')),
|
||||
('real_name', models.CharField(blank=True, max_length=128, null=True, verbose_name='真实姓名')),
|
||||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
|
||||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '功能菜单',
|
||||
'verbose_name_plural': '功能菜单',
|
||||
'db_table': 't_user',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
managers=[
|
||||
('objects', django.contrib.auth.models.UserManager()),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,56 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-14 21:42
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('erp_system', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PermissionsModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=50, verbose_name='权限名')),
|
||||
('is_menu', models.BooleanField(default=True, verbose_name='是否为菜单')),
|
||||
('method', models.CharField(blank=True, choices=[('POST', '增'), ('DELETE', '删'), ('PUT', '改'), ('PATCH', '改局部'), ('GET', '查')], default='', max_length=8, verbose_name='请求方法')),
|
||||
('path', models.CharField(blank=True, default='', max_length=200, verbose_name='请求路径')),
|
||||
('desc', models.CharField(blank=True, default='', max_length=512, verbose_name='权限描述')),
|
||||
('menu', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='permissions_list', to='erp_system.menu')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '权限',
|
||||
'verbose_name_plural': '权限',
|
||||
'db_table': 't_permissions',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='RolesModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=32, unique=True, verbose_name='角色名字')),
|
||||
('permissions', models.ManyToManyField(blank=True, db_table='t_roles_permissions', to='erp_system.PermissionsModel', verbose_name='权限')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '角色',
|
||||
'verbose_name_plural': '角色',
|
||||
'db_table': 't_roles',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='usermodel',
|
||||
name='roles',
|
||||
field=models.ManyToManyField(blank=True, db_table='t_users_roles', to='erp_system.RolesModel', verbose_name='用户所拥有的角色列表'),
|
||||
),
|
||||
]
|
@ -0,0 +1,36 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-21 20:24
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('erp_system', '0002_auto_20230314_2142'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='DeptModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=32, unique=True, verbose_name='部门')),
|
||||
('address', models.CharField(blank=True, default='', max_length=128, verbose_name='部门地址')),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='erp_system.deptmodel', verbose_name='父部门')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '部门',
|
||||
'verbose_name_plural': '部门',
|
||||
'db_table': 't_dept',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='usermodel',
|
||||
name='dept',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='erp_system.deptmodel', verbose_name='用户所在的部门'),
|
||||
),
|
||||
]
|
@ -0,0 +1,27 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from erp_system.models import DeptModel
|
||||
|
||||
|
||||
class ChildDeptSerializer(serializers.ModelSerializer):
|
||||
children = serializers.SerializerMethodField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = DeptModel
|
||||
fields = ['id', 'name', 'parent', 'children']
|
||||
|
||||
def get_children(self, obj):
|
||||
if obj.children:
|
||||
return ChildDeptSerializer(instance=obj.children, many=True).data
|
||||
return None
|
||||
|
||||
|
||||
class DeptSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
部门的序列化器
|
||||
"""
|
||||
children = ChildDeptSerializer(read_only=True, many=True)
|
||||
|
||||
class Meta:
|
||||
model = DeptModel
|
||||
fields = ['id', 'name', 'parent', 'children']
|
@ -0,0 +1,10 @@
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
|
||||
from erp_system.models import Menu
|
||||
|
||||
|
||||
class MenuSerializer(ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Menu
|
||||
fields = '__all__'
|
@ -0,0 +1,9 @@
|
||||
from rest_framework.serializers import ModelSerializer, ValidationError
|
||||
from erp_system.models import PermissionsModel
|
||||
|
||||
|
||||
# 权限基本的序列化类
|
||||
class PermissionsSerializer(ModelSerializer):
|
||||
class Meta:
|
||||
model = PermissionsModel
|
||||
fields = '__all__'
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,39 @@
|
||||
"""ERP_5 URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/3.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, re_path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import menu_views, user_views, dept_views, role_views, permission_views
|
||||
|
||||
from rest_framework_jwt.views import obtain_jwt_token
|
||||
|
||||
urlpatterns = [
|
||||
# path('admin/', admin.site.urls),
|
||||
path('users/login/', obtain_jwt_token), # 登录并且由JWT签发token
|
||||
re_path(r'^users/reset/(?P<pk>\d+)/$', user_views.ResetPasswordView.as_view()),
|
||||
|
||||
|
||||
]
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register('menus', menu_views.MenuViewSet)
|
||||
router.register('users/register', user_views.RegisterUserView)
|
||||
router.register('roles', role_views.RolesViewSet)
|
||||
router.register('permissions', permission_views.PermissionViewSet)
|
||||
router.register('dept', dept_views.DeptViewSet)
|
||||
router.register('users', user_views.UserView)
|
||||
|
||||
urlpatterns += router.urls
|
@ -0,0 +1,53 @@
|
||||
from rest_framework import mixins
|
||||
from rest_framework.generics import GenericAPIView
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
from ERP_5.utils.base_views import MultipleDestroyMixin
|
||||
from ERP_5.utils.paginations import GlobalPagination
|
||||
from erp_system.models import UserModel
|
||||
from erp_system.serializers.user_serializer import UserAddSerializer, UserUpdateDeleteSerializer, UserGetSerializer, \
|
||||
ResetPasswordSerializer
|
||||
|
||||
|
||||
class RegisterUserView(mixins.CreateModelMixin, GenericViewSet):
|
||||
"""
|
||||
create:
|
||||
用户注册。
|
||||
|
||||
并且把用户注册之后的用户信息返回
|
||||
"""
|
||||
queryset = UserModel.objects.all()
|
||||
serializer_class = UserAddSerializer
|
||||
|
||||
|
||||
class UserView(mixins.RetrieveModelMixin,
|
||||
mixins.UpdateModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.ListModelMixin,
|
||||
MultipleDestroyMixin, # 批量删除用户
|
||||
GenericViewSet):
|
||||
"""
|
||||
没有用户注册和修改用户密码的模型类
|
||||
"""
|
||||
queryset = UserModel.objects.all()
|
||||
pagination_class = GlobalPagination
|
||||
|
||||
def get_serializer_class(self):
|
||||
if self.action == 'partial_update' or self.action == 'update' or self.action == 'destroy':
|
||||
return UserUpdateDeleteSerializer
|
||||
else:
|
||||
return UserGetSerializer
|
||||
|
||||
|
||||
class ResetPasswordView(mixins.UpdateModelMixin, GenericAPIView):
|
||||
"""
|
||||
patch:
|
||||
用户--重置密码
|
||||
|
||||
用户重置密码, status: 200(成功), return: None
|
||||
"""
|
||||
queryset = UserModel.objects.all()
|
||||
serializer_class = ResetPasswordSerializer
|
||||
|
||||
def patch(self, request, *args, **kwargs):
|
||||
return self.partial_update(request, *args, **kwargs)
|
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class GoodsInfoConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'goods_info'
|
@ -0,0 +1,121 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-28 20:51
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('basic_info', '0004_settlementaccountmodel_warehousemodel'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AttachmentModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('a_file', models.FileField(upload_to='', verbose_name='附件或者图片')),
|
||||
('a_type', models.CharField(blank=True, choices=[('image', '图片'), ('doc', 'Word文档'), ('excel', 'Excel文档'), ('zip', '压缩文件'), ('other', '其他文件')], max_length=20, null=True, verbose_name='附件的类型')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '附件表',
|
||||
'verbose_name_plural': '附件表',
|
||||
'db_table': 't_attachment',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GoodsCategoryModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=100, verbose_name='类别名称')),
|
||||
('number_code', models.CharField(max_length=28, unique=True, verbose_name='编号')),
|
||||
('remark', models.CharField(blank=True, max_length=512, null=True, verbose_name='备注')),
|
||||
('order_number', models.IntegerField(default=100, verbose_name='排序号码')),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='children', to='goods_info.goodscategorymodel')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '商品类别',
|
||||
'verbose_name_plural': '商品类别',
|
||||
'db_table': 't_category',
|
||||
'ordering': ['order_number', 'id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='UnitsModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('basic_name', models.CharField(max_length=20, unique=True, verbose_name='基本单位')),
|
||||
('backup_name', models.CharField(blank=True, max_length=20, null=True, verbose_name='副单位')),
|
||||
('remark', models.CharField(blank=True, max_length=512, null=True, verbose_name='备注')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '计量单位',
|
||||
'verbose_name_plural': '计量单位',
|
||||
'db_table': 't_units',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GoodsModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('delete_flag', models.CharField(default='0', help_text='是否启用', max_length=1, verbose_name='是否启用')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
|
||||
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
|
||||
('name', models.CharField(max_length=20, unique=True, verbose_name='货品名称')),
|
||||
('specification', models.CharField(blank=True, max_length=50, null=True, verbose_name='规格')),
|
||||
('model_number', models.CharField(blank=True, max_length=50, null=True, verbose_name='型号')),
|
||||
('color', models.CharField(blank=True, max_length=50, null=True, verbose_name='颜色')),
|
||||
('basic_weight', models.CharField(blank=True, max_length=50, null=True, verbose_name='基础重量')),
|
||||
('expiration_day', models.IntegerField(blank=True, null=True, verbose_name='保质期')),
|
||||
('remark', models.CharField(blank=True, max_length=512, null=True, verbose_name='备注')),
|
||||
('number_code', models.CharField(max_length=28, unique=True, verbose_name='编号或者批号')),
|
||||
('purchase_price', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=10, verbose_name='采购价')),
|
||||
('retail_price', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=10, verbose_name='零售价')),
|
||||
('sales_price', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=10, verbose_name='销售价')),
|
||||
('lowest_price', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=10, verbose_name='最低售价')),
|
||||
('order_number', models.IntegerField(default=100, verbose_name='排序号码')),
|
||||
('images_list', models.CharField(blank=True, max_length=20, null=True, verbose_name='商品图片所对应的id列表')),
|
||||
('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='goods_info.goodscategorymodel')),
|
||||
('units', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='goods_info.unitsmodel')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '货品表',
|
||||
'verbose_name_plural': '货品表',
|
||||
'db_table': 't_goods',
|
||||
'ordering': ['order_number', 'id'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='GoodsInventoryModel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('init_inventory', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='期初库存数量')),
|
||||
('cur_inventory', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='现在库存数量')),
|
||||
('lowest_inventory', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='最低安全库存, 0表示不设置')),
|
||||
('highest_inventory', models.DecimalField(decimal_places=2, default=0, max_digits=10, verbose_name='最高安全库存,0表示不设置')),
|
||||
('warehouse_name', models.CharField(max_length=50, verbose_name='仓库的名称')),
|
||||
('goods', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='inventory_list', to='goods_info.goodsmodel')),
|
||||
('warehouse', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='basic_info.warehousemodel')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '货品库存表',
|
||||
'verbose_name_plural': '货品库存表',
|
||||
'db_table': 't_goods_inventory',
|
||||
'ordering': ['id'],
|
||||
},
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.16 on 2023-03-30 20:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('goods_info', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='goodsmodel',
|
||||
name='images_list',
|
||||
field=models.CharField(blank=True, max_length=20, null=True, verbose_name='商品附件所对应的id列表'),
|
||||
),
|
||||
]
|
@ -0,0 +1,120 @@
|
||||
from django.db import models
|
||||
|
||||
from django.db import models
|
||||
from ERP_5.utils.base_model import BaseModel
|
||||
|
||||
|
||||
# 货品(商品)类别模型类
|
||||
class GoodsCategoryModel(BaseModel):
|
||||
name = models.CharField(max_length=100, verbose_name='类别名称')
|
||||
number_code = models.CharField('编号', max_length=28, unique=True)
|
||||
remark = models.CharField('备注', max_length=512, blank=True, null=True)
|
||||
order_number = models.IntegerField('排序号码', default=100)
|
||||
parent = models.ForeignKey('self', blank=True, null=True, related_name='children', on_delete=models.SET_NULL)
|
||||
|
||||
class Meta:
|
||||
db_table = 't_category'
|
||||
verbose_name = '商品类别'
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ['order_number', 'id']
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
# 计量单位模型类
|
||||
class UnitsModel(BaseModel):
|
||||
basic_name = models.CharField(max_length=20, verbose_name='基本单位', unique=True)
|
||||
backup_name = models.CharField('副单位', max_length=20, null=True, blank=True)
|
||||
remark = models.CharField('备注', max_length=512, blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 't_units'
|
||||
verbose_name = '计量单位'
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ['id']
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.basic_name}({self.backup_name})'
|
||||
|
||||
|
||||
# 图片或者附件的模型类
|
||||
class AttachmentModel(BaseModel):
|
||||
# 附件文件的类型
|
||||
type_choices = (
|
||||
('image', '图片'),
|
||||
('doc', 'Word文档'),
|
||||
('excel', 'Excel文档'),
|
||||
('zip', '压缩文件'),
|
||||
('other', '其他文件')
|
||||
)
|
||||
"""
|
||||
只要是choices参数的字段 如果你想要获取对应信息 固定写法 get_字段名_display()
|
||||
print(Attachment.a_type)
|
||||
print(Attachment.get_a_type_display())
|
||||
"""
|
||||
a_file = models.FileField('附件或者图片')
|
||||
a_type = models.CharField('附件的类型', max_length=20, blank=True, null=True, choices=type_choices)
|
||||
|
||||
class Meta:
|
||||
db_table = 't_attachment'
|
||||
verbose_name = '附件表'
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ['id']
|
||||
|
||||
def __str__(self):
|
||||
return self.a_file.name
|
||||
|
||||
|
||||
# 货品库存 模型类
|
||||
class GoodsInventoryModel(models.Model):
|
||||
# 期初库存数量在创建好之后不能修改
|
||||
init_inventory = models.DecimalField('期初库存数量', max_digits=10, decimal_places=2, default=0)
|
||||
cur_inventory = models.DecimalField('现在库存数量', max_digits=10, decimal_places=2, default=0)
|
||||
lowest_inventory = models.DecimalField('最低安全库存, 0表示不设置', max_digits=10, decimal_places=2, default=0)
|
||||
highest_inventory = models.DecimalField('最高安全库存,0表示不设置', max_digits=10, decimal_places=2, default=0)
|
||||
|
||||
goods = models.ForeignKey('GoodsModel', related_name='inventory_list', on_delete=models.CASCADE, blank=True,
|
||||
null=True)
|
||||
warehouse = models.ForeignKey('basic_info.WarehouseModel', on_delete=models.CASCADE)
|
||||
# 冗余字段,主要目的:减少联表查询的次数
|
||||
warehouse_name = models.CharField('仓库的名称', max_length=50)
|
||||
|
||||
class Meta:
|
||||
db_table = 't_goods_inventory'
|
||||
verbose_name = '货品库存表'
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ['id']
|
||||
|
||||
def __str__(self):
|
||||
return self.warehouse_name + str(self.id)
|
||||
|
||||
|
||||
# 货品(商品)模型类
|
||||
class GoodsModel(BaseModel):
|
||||
name = models.CharField(max_length=20, verbose_name='货品名称', unique=True)
|
||||
specification = models.CharField('规格', max_length=50, null=True, blank=True)
|
||||
model_number = models.CharField('型号', max_length=50, null=True, blank=True)
|
||||
color = models.CharField('颜色', max_length=50, null=True, blank=True)
|
||||
basic_weight = models.CharField('基础重量', max_length=50, null=True, blank=True)
|
||||
expiration_day = models.IntegerField('保质期', null=True, blank=True)
|
||||
remark = models.CharField('备注', max_length=512, blank=True, null=True)
|
||||
number_code = models.CharField('编号或者批号', max_length=28, unique=True)
|
||||
purchase_price = models.DecimalField('采购价', max_digits=10, decimal_places=2, blank=True, default=0) # 精确到小数点后两位
|
||||
retail_price = models.DecimalField('零售价', max_digits=10, decimal_places=2, blank=True, default=0) # 精确到小数点后两位
|
||||
sales_price = models.DecimalField('销售价', max_digits=10, decimal_places=2, blank=True, default=0) # 精确到小数点后两位
|
||||
lowest_price = models.DecimalField('最低售价', max_digits=10, decimal_places=2, blank=True, default=0) # 精确到小数点后两位
|
||||
order_number = models.IntegerField('排序号码', default=100)
|
||||
|
||||
units = models.ForeignKey('UnitsModel', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
category = models.ForeignKey('GoodsCategoryModel', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
images_list = models.CharField('商品附件所对应的id列表', max_length=20, null=True, blank=True) # 字段的值为: 1,2,3,4
|
||||
|
||||
class Meta:
|
||||
db_table = 't_goods'
|
||||
verbose_name = '货品表'
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ['order_number', 'id']
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
@ -0,0 +1,21 @@
|
||||
from goods_info.models import AttachmentModel
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class AttachmentsSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
附件和图片的序列化器
|
||||
"""
|
||||
# source 如果是字段,会显示字段,如果是方法,会执行方法,不用加括号
|
||||
# 附件或者图片的文件名
|
||||
file_name = serializers.CharField(source='a_file.name', read_only=True)
|
||||
|
||||
# 附件或者图片的访问地址
|
||||
file_url = serializers.CharField(source='a_file.url', read_only=True)
|
||||
|
||||
# 附件的文件类型(中文)
|
||||
type_display = serializers.CharField(source='get_a_type_display', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = AttachmentModel
|
||||
fields = ['id', 'a_file', 'a_type', 'file_url', 'file_name', 'type_display']
|
@ -0,0 +1,19 @@
|
||||
from goods_info.models import GoodsCategoryModel
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class CategorySerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
商品类别的序列化器
|
||||
"""
|
||||
# 树形展示
|
||||
children = serializers.SerializerMethodField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = GoodsCategoryModel
|
||||
fields = ['id', 'number_code', 'remark', 'name', 'order_number', 'parent', 'children']
|
||||
|
||||
def get_children(self, obj):
|
||||
if obj.children:
|
||||
return CategorySerializer(obj.children, many=True).data
|
||||
return None
|
@ -0,0 +1,17 @@
|
||||
from goods_info.models import UnitsModel
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class UnitsSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
计量单位的序列化器
|
||||
"""
|
||||
# 指定新增的属性,是从一个函数中得到值
|
||||
units_name = serializers.SerializerMethodField(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = UnitsModel
|
||||
fields = ['id', 'basic_name', 'backup_name', 'delete_flag', 'units_name']
|
||||
|
||||
def get_units_name(self, obj):
|
||||
return str(obj) # 就是调用该对象的__str__函数
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,34 @@
|
||||
"""ERP_5 URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/3.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, re_path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .views import units_views, attachments_views, goods_category_views, goods_views
|
||||
|
||||
from rest_framework_jwt.views import obtain_jwt_token
|
||||
|
||||
urlpatterns = [
|
||||
# path('admin/', admin.site.urls),
|
||||
|
||||
]
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register('category', goods_category_views.CategoryView)
|
||||
router.register('units', units_views.UnitsView)
|
||||
router.register('attachments', attachments_views.AttachmentView)
|
||||
router.register('goods', goods_views.GoodsInfoViewSet)
|
||||
|
||||
urlpatterns += router.urls
|
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PurchaseInfoConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'purchase_info'
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,31 @@
|
||||
"""ERP_5 URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/3.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, re_path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
# from .views import units_views, attachments_views, goods_category_views, goods_views
|
||||
|
||||
from rest_framework_jwt.views import obtain_jwt_token
|
||||
|
||||
urlpatterns = [
|
||||
# path('admin/', admin.site.urls),
|
||||
|
||||
]
|
||||
|
||||
router = DefaultRouter()
|
||||
# router.register('category', goods_category_views.CategoryView)
|
||||
|
||||
urlpatterns += router.urls
|
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for ERP_5 project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ERP_5.settings')
|
||||
|
||||
application = get_asgi_application()
|
@ -0,0 +1,15 @@
|
||||
import os
|
||||
from celery import Celery
|
||||
from django.conf import settings
|
||||
import django
|
||||
|
||||
# 设置环境变量
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ERP_5.settings.dev')
|
||||
|
||||
# 注册Celery的APP, ERP_5必须是项目名字
|
||||
celery_app = Celery('ERP_5')
|
||||
# 绑定配置文件
|
||||
celery_app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||
|
||||
# 自动从settings.INSTALLED_APPS注册的应用中加载tasks.py
|
||||
celery_app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
After Width: | Height: | Size: 7.3 MiB |
@ -0,0 +1,126 @@
|
||||
"""
|
||||
Django settings for ERP_5 project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.2.16.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.2/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-o!nl319=c4gr)@c)n#@*kq)zil-i(4puha&59&1o*wd0cbrj!5'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'ERP_5.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [BASE_DIR / 'templates']
|
||||
,
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'ERP_5.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/3.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
@ -0,0 +1,51 @@
|
||||
"""ERP_5 URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/3.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include, re_path
|
||||
from django.views.static import serve
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.views import get_schema_view
|
||||
from rest_framework import permissions
|
||||
from rest_framework.documentation import include_docs_urls
|
||||
from ERP_5.utils.base_views import GenerateCode
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi.Info(
|
||||
title="接口 API文档",
|
||||
default_version='v1',
|
||||
description="马士兵ERP系统项目接口文档",
|
||||
),
|
||||
public=True,
|
||||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/', include('erp_system.urls')),
|
||||
path('api/', include('basic_info.urls')),
|
||||
path('api/', include('goods_info.urls')),
|
||||
path('api/', include('purchase_info.urls')),
|
||||
re_path(r'^api/generate_code/$', GenerateCode.as_view()),
|
||||
|
||||
# 媒体资源文件的访问路由
|
||||
re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
|
||||
path('docs/', include_docs_urls(title='ERP系统的接口文档')),
|
||||
# swagger接口文档的路由
|
||||
path('swagger<format>/', schema_view.without_ui(cache_timeout=0), name='schema-json'),
|
||||
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
||||
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
||||
]
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue