From 6529363ff9fbfe843d8feb63d6892a12f82d0944 Mon Sep 17 00:00:00 2001 From: unknown <1043974142@qq.com> Date: Tue, 28 May 2024 22:40:27 +0800 Subject: [PATCH] second commit --- .idea/.gitignore | 8 + .idea/Django_CRM_System-master.iml | 32 ++ .idea/inspectionProfiles/Project_Default.xml | 17 + .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 7 + .idea/modules.xml | 8 + sales/__init__.py | 0 sales/__pycache__/__init__.cpython-39.pyc | Bin 0 -> 158 bytes sales/__pycache__/admin.cpython-39.pyc | Bin 0 -> 199 bytes sales/__pycache__/apps.cpython-39.pyc | Bin 0 -> 433 bytes sales/__pycache__/models.cpython-39.pyc | Bin 0 -> 2308 bytes sales/__pycache__/urls.cpython-39.pyc | Bin 0 -> 1228 bytes sales/__pycache__/views.cpython-39.pyc | Bin 0 -> 7592 bytes sales/admin.py | 3 + sales/apps.py | 6 + sales/migrations/__init__.py | 0 .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 169 bytes sales/models.py | 66 ++++ sales/tests.py | 3 + sales/urls.py | 38 +++ sales/views.py | 319 ++++++++++++++++++ serve/__init__.py | 0 serve/__pycache__/__init__.cpython-39.pyc | Bin 0 -> 158 bytes serve/__pycache__/admin.cpython-39.pyc | Bin 0 -> 199 bytes serve/__pycache__/apps.cpython-39.pyc | Bin 0 -> 433 bytes serve/__pycache__/models.cpython-39.pyc | Bin 0 -> 1743 bytes serve/__pycache__/urls.cpython-39.pyc | Bin 0 -> 534 bytes serve/__pycache__/views.cpython-39.pyc | Bin 0 -> 3025 bytes serve/admin.py | 3 + serve/apps.py | 6 + serve/migrations/__init__.py | 0 .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 169 bytes serve/models.py | 49 +++ serve/tests.py | 3 + serve/urls.py | 12 + serve/views.py | 121 +++++++ 36 files changed, 707 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Django_CRM_System-master.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 sales/__init__.py create mode 100644 sales/__pycache__/__init__.cpython-39.pyc create mode 100644 sales/__pycache__/admin.cpython-39.pyc create mode 100644 sales/__pycache__/apps.cpython-39.pyc create mode 100644 sales/__pycache__/models.cpython-39.pyc create mode 100644 sales/__pycache__/urls.cpython-39.pyc create mode 100644 sales/__pycache__/views.cpython-39.pyc create mode 100644 sales/admin.py create mode 100644 sales/apps.py create mode 100644 sales/migrations/__init__.py create mode 100644 sales/migrations/__pycache__/__init__.cpython-39.pyc create mode 100644 sales/models.py create mode 100644 sales/tests.py create mode 100644 sales/urls.py create mode 100644 sales/views.py create mode 100644 serve/__init__.py create mode 100644 serve/__pycache__/__init__.cpython-39.pyc create mode 100644 serve/__pycache__/admin.cpython-39.pyc create mode 100644 serve/__pycache__/apps.cpython-39.pyc create mode 100644 serve/__pycache__/models.cpython-39.pyc create mode 100644 serve/__pycache__/urls.cpython-39.pyc create mode 100644 serve/__pycache__/views.cpython-39.pyc create mode 100644 serve/admin.py create mode 100644 serve/apps.py create mode 100644 serve/migrations/__init__.py create mode 100644 serve/migrations/__pycache__/__init__.cpython-39.pyc create mode 100644 serve/models.py create mode 100644 serve/tests.py create mode 100644 serve/urls.py create mode 100644 serve/views.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Django_CRM_System-master.iml b/.idea/Django_CRM_System-master.iml new file mode 100644 index 0000000..15ada9c --- /dev/null +++ b/.idea/Django_CRM_System-master.iml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..071bd26 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2757df9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b1c42bd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/sales/__init__.py b/sales/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sales/__pycache__/__init__.cpython-39.pyc b/sales/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..df634bc6cd0191ab2208b55d2a5f1311478f84f2 GIT binary patch literal 158 zcmYe~<>g`kf)n%lQb6=$5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!HsvsFxJacWU< zjG>XGp+SsGetBL_equ^-j7wHxUV47KbC7R*aAk2xYOZc>B9JPIDNf8uEslwg&&g`kf)n%lQtW~BV-N=!FabFZKwK;UBvKes7;_kM8KW2(8B&;n88n$+0!0}# z8E>&BrsQVk`Drpm@ug%X=B4NBCFkdr6lEqAfecv5P{a(Rz{D>HXRDad;?$zz7(*jV zLxUKX{PMh<{KS;v7#Fb4c;_JB_~6RolGI$?+(aN%6jPj-lUf`DwnDF<@)n0pZhlH> OPO2Rv(9q97%m4uI#xeE) literal 0 HcmV?d00001 diff --git a/sales/__pycache__/apps.cpython-39.pyc b/sales/__pycache__/apps.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f666a9c20845b5b53aefdf941b27dacd1eba88be GIT binary patch literal 433 zcmYjNy-ve05Vqq~D*agyD-vr4BFY9r(9#MfI#97hku1YGQIYdQ+z7QR%zXrQ-h^lH z%ET)$ahF!2C*A+&@6M~Av7PNj4#RBg3MrAoJ@?@SqQDs*+CPP$vfJU>31H;!m65vHX2xReHcczTC8-mp# zJgYn{LU;_b0<^K=^*kNbi{fUk4Y-yi>@;Y(wv@Tbw3MzRB|>XMaZk#ZTA6KUA9SK> zvyci2WYRGB)ca%=U7|6+SL5^e!RpG!gVVFYNjxcDb5kg=@ub;Bj_>c}Y-txdJI)lk zDsHxjRax4wTvh_9=yaA$oBO<}OatM%+usnf@@OJq|7UNaF4kQ8V)KbhI+-PGPy7MV CC~OD- literal 0 HcmV?d00001 diff --git a/sales/__pycache__/models.cpython-39.pyc b/sales/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c9f64cda0e89d81aab1cd8dd1ee8a5067f88a977 GIT binary patch literal 2308 zcmah~&2HO95aypGilSs&cAPkWMbTfiiP7|yq9_vBaB37*f;jDgFtDJxYnv`by1SHP z2ff)qPVOTV?a^=2XV_~m^(*91^qVD>D2?8X<){~Oan7b-oi|)o@sJ_ z(;Bod;L94=x;ZMi$W%gb`f+QZZbA`OWOFNWURpagx4CobNA63@vmy_!TpezZkBvBw zcZE#sDL15(CmL!IqO?l;XY0iI&H3Hhcgfe8O+JPfv=rxQrRs+`OZmXl4K+RxQqo=> z?uwHAG#2t$iBdOr(ySB`%RMEsopW2a8B4NQDaOvNR}WXd+WKAzskZKYdH>!QTdT$M zJS$?ZwpRD!e79gLPdC`+u`0#r?kL8e+){BS)K(RX<%46{!b@o=2g0&nEKPsn^7LT_ z4ec|Q$0Na*4j6-vaYlN`aNszrEXJYk)~8HFmN6znxUK{dKz2#c*ETWCi+$VR1o*Az zH6vbOdXgOB?t2ta?w&bO1E@({IJ2Xcv491};v0)^EbV$v+gJjF0^TvGQ=`zJ(4a2w z8Pu(9GY0i)G;7cd&@7)b{^x2--&p!Jnm1@3sL2=j6~2h`E|^_c`8B=-bj6^6UpFfk z#nlrlx&|iS;5WhKnF@ULJEE93==wK8du}tK< z<(_WyZI%?-c$Di-GFD|V5|X9-+?K@63l0GX69Z*Vd&%y8rv2hj$iq}TzgVC(ewOAx zvQeBzfzb~3id>|BA$PjNg-T?4P^JZ}i4<`us+C}8x|~<><;8OrbFMq%1F|v_@6d-z?E!|G zg_zKX+mXv1s>K&GZ-TnKA<8)FmW&F7Rk0nOd$Na}a)t!?&^`iN#@m^g;_g^HQL}RJLG}rgd6Zr)-Ff$?NbU zZ$LyXN)Fmm)F$N#B}v{QL%Rx~F;%I6s=KQcPo$)NLuH`}dE4wlhMt-P$p)~lvrD^l zP{o_{s$sQ??R}AyO47Gp78TitfnuaSgz%l76V{`L|LR9GJ-hlf9kb(|WKy$uKyFSU zCds5q6AkJHrpnwi&vXHwIs$K^!l?2CbOhfZs&${Yd0-ILdKXSH#1{OsHH z;iD*^aG?g!(c~v^82R+(bqd7bH6)%PhezUJ_3@v=Vn``JBkgk%E(xl-|EAzwSnpvd zikt8FwqtvLH$6i>JH)SNgLbrPIB21Jn%i@kZ&#Jt+Nf^)itr6{Lz?d~J1&co_P?&K R$8RVTil`el`py1F{{W0&CvX4& literal 0 HcmV?d00001 diff --git a/sales/__pycache__/urls.cpython-39.pyc b/sales/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..211b6c54584ec396c0902c532b6f3659c7178e54 GIT binary patch literal 1228 zcmaKr&2G~`5XWuDiSy|sc9MS4@_p!mnsNgnKx(gWpyComT3MM@o62^gU8kjf2Y3YT zya~^+H^iy0&LInDugODdgRg0T)PbR<5t0iVnl_QTu%&4msRuin9w7B$SJNJn2M;wpLh|9UrYA@P zcuI8I9S`BziLw9u8qaU+TgqO9>6vn7$uwF5zc$Hhs_MmzUrJS#VZ>!tnT)Yj<`g-B@^o@(q0CuT_6noCi_8Js87=D-#+^wY7hu3I*dhv(K%dhqJB#CH zgR(CGo`$n1P+Mhh5sB4kF1u4CD4Mi+d#eA77G2sa7Yf$<6R6#F7b_>M?QYd7UnkuY zx@w%S8+T9Ws*S#GYvNnMCst2k)2%0l*cdP5C<{IAHsw-f3Ubx r^|$dHmJxqPuSXuE^vt$pTdwI=>ZbKKx6pPi*D5$yyJVOBMb7VkE>d}Y literal 0 HcmV?d00001 diff --git a/sales/__pycache__/views.cpython-39.pyc b/sales/__pycache__/views.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..92e93fa7623a70706bb0446f93b70d80e7edc391 GIT binary patch literal 7592 zcmbtZ>u(&_b)WZh`4An#vya@F zl|^b1 zp{X8SjoQ5w9bq$(7fV$ceX-w?QT-E7oUabXmg8YSsXP3}R< zdyk%a_yXNNx$x14{^+A8FP!c^*NM9gkz6=E-{{PB>!+T1s(x-ENu&0I?FPQ&1-`+B zE3N3cNkA|0~nxwN+i{Yxzj+eO(y*~u&^Qe)nnw}hKn!do#`?KN%5?fg|{%WK0PTlmACCo@z2 z!?4E`!La98=ExrpdmIrCd!`1hqOzi^JETtLX2!Cyr_|5fWjzft ze_0n3FI!7N8fL+={yFWOW@%~VhQ4r2*Oma{#e-=m05~!AvO)ch_AH2EDZCb*E51)^ zCsD%7-+MNq`3ubH8yWx zL~ch?cI8b&-i_h%9+>J_ZUPs%ITxjpVjy?BUzm@YX_7k^TQMRkcdj&I1f{fT&ORCv zsv-5bm87{DN1fcFqI9U!f8uI0Vn|jia*|p+@=3kZZ|6RjlGb7*X(7ByUY?}2E7@f`A8@_R6vVdxdTVhsK*eMT>R zj430~E2g0vx}!V4aooU|)aA!8Zv-Q>anOe`LcK+lGeU#`Wa#oJN1>kS!dwA9gq4{s zU?v4RgpF7v+H?9xFj>(~RsB4I%3N9?>T=$xT~+2-lV$CPVL2K0t<^x@z(3kbgi8#K&)g|P+( z5by`EX$f!yBUDeF6u1Ni9pSDJfqH$q%dPLdw(-MP)?a_+*7Y}Yqa|{y1M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YjLz`WRB1KzQ)aOvl?ekdG5}LP##JqDblQAec64|e%Fy^;IX-@7v zf~V`p(VyUTXvsW`+J#C7EPQC9&c-XYp$8ApDS4%WlFOwk+Y@ZZ*kTk$1Q>C5sdXQh JC)oOA{}()9KIQ-b literal 0 HcmV?d00001 diff --git a/sales/admin.py b/sales/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/sales/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/sales/apps.py b/sales/apps.py new file mode 100644 index 0000000..354fa6c --- /dev/null +++ b/sales/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SalesConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'sales' diff --git a/sales/migrations/__init__.py b/sales/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sales/migrations/__pycache__/__init__.cpython-39.pyc b/sales/migrations/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6aa84f3b7209584a94ec32e64f2ca32076b30d0d GIT binary patch literal 169 zcmYe~<>g`kg2d&vX(0MBh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6wy*(xTqIJKxa z#?Z*p&>+SozdSD|KQW~^#w9B;FFilrImkCYxU#q;HCHz`5l9uq6es4S7RTgfrWYla kWaj4;$Hd2H=4F<|$LkeT-r}&y%}*)KNwovn^BIU400gxvqW}N^ literal 0 HcmV?d00001 diff --git a/sales/models.py b/sales/models.py new file mode 100644 index 0000000..13abf4b --- /dev/null +++ b/sales/models.py @@ -0,0 +1,66 @@ +from django.db import models + + +# Create your models here. + +class ModelManager(models.Manager): + def get_queryset(self): + return super(ModelManager, self).get_queryset().filter(isValid=1) + + +# 营销机会模型 +class SaleChance(models.Model): + # 信息来源 + chanceSource = models.CharField(max_length=300, db_column='chance_source') + # 客户id + customerId = models.IntegerField(db_column='customer_id') + # 客户名称 + customerName = models.CharField(max_length=100, db_column='customer_name') + # 成功几率 + cgjl = models.IntegerField(db_column='cgjl') + # 概要 + overview = models.CharField(max_length=300, db_column='overview') + # 联系人 + linkMan = models.CharField(max_length=20, db_column='link_man') + # 联系电话 + linkPhone = models.CharField(max_length=20, db_column='link_phone') + # 描述 + description = models.CharField(max_length=1000, db_column='description') + # 创建人 + createMan = models.CharField(max_length=20, db_column='create_man') + # 分配给谁 + assignMan = models.CharField(max_length=20, db_column='assign_man') + # 分配时间 + assignTime = models.DateTimeField(db_column='assign_time') + # 状态:1-如果有分配就是已分配状态,0-未分配 + state = models.CharField(max_length=20, db_column='state') + # 开发状态:0=未开发 1=开发中 2=开完完成 3=开发失败 + devResult = models.CharField(max_length=20, db_column='dev_result') + isValid = models.IntegerField(db_column='is_valid', default=1) + createDate = models.DateTimeField(db_column='create_date', auto_now_add=True) + updateDate = models.DateTimeField(max_length=20, db_column='update_date') + objects = ModelManager() + + class Meta: + db_table = 't_sale_chance' + + +# 客户计划模型 +class CusDevPlan(models.Model): + # 关联营销机会 + saleChance = models.ForeignKey(SaleChance, db_constraint=False, + db_column='sale_chance_id', + on_delete=models.DO_NOTHING) + # 计划内容 + planItem = models.CharField(max_length=300, db_column='plan_item') + # 计划时间 + planDate = models.DateTimeField(max_length=20, db_column='plan_date') + # 执行效果 + exeAffect = models.CharField(max_length=100, db_column='exe_affect') + isValid = models.IntegerField(db_column='is_valid') + createDate = models.DateTimeField(db_column='create_date') + updateDate = models.DateTimeField(max_length=20, db_column='update_date') + objects = ModelManager() + + class Meta: + db_table = 't_cus_dev_plan' diff --git a/sales/tests.py b/sales/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/sales/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/sales/urls.py b/sales/urls.py new file mode 100644 index 0000000..3380bca --- /dev/null +++ b/sales/urls.py @@ -0,0 +1,38 @@ +from django.urls import path, include +from . import views + +app_name = 'sales' +urlpatterns = [ + path('index/', views.sales_index, name='sales_index'), + path('list/', views.select_sale_chance_list, name='select_sale_chance_list'), + + # 添加/修改营销机会 + path('create_or_update/', views.create_or_update_sales, + name='create_or_update_sales'), + path('customer/', views.select_customer, name='select_customer'), + path('create/', views.create_sale_chance, name='create_sale_chance'), + path('update/', views.update_sale_chance, name='update_sale_chance'), + + # 删除营销机会 + path('delete/', views.delete_sale_chance, name='delete_sale_chance'), + + path('cus_dev_plan/index/', views.cus_dev_plan_index, name='cus_dev_plan_index'), + + path('cus_dev_plan/detail/', views.cus_dev_plan_index_detail, + name='cus_dev_plan_index_detail'), + path('cus_dev_plan/list/', views.select_cus_dev_plan_list, + name='select_cus_dev_plan_list'), + + # 添加/修改/删除开发计划 + path('cus_dev_plan/create_or_update/', views.create_or_update_cus_dev_plan, + name='create_or_update_cus_dev_plan'), + path('cus_dev_plan/create/', views.create_cus_dev_plan, + name='create_cus_dev_plan'), + path('cus_dev_plan/update/', views.update_cus_dev_plan, + name='update_cus_dev_plan'), + path('cus_dev_plan/delete/', views.delete_cus_dev_plan, + name='delete_cus_dev_plan'), + + path('cus_dev_plan/dev_result/', views.update_dev_result, + name='update_dev_result'), +] diff --git a/sales/views.py b/sales/views.py new file mode 100644 index 0000000..c42f611 --- /dev/null +++ b/sales/views.py @@ -0,0 +1,319 @@ +from datetime import datetime + +from django.shortcuts import render +import pymysql +from django.core.paginator import Paginator +from django.http import JsonResponse +from django.shortcuts import render +from django.views.decorators.clickjacking import xframe_options_exempt +from django.views.decorators.csrf import csrf_exempt +from django.views.decorators.http import require_GET + +from customer.models import Customer, LinkMan +from sales.models import SaleChance, CusDevPlan +from system.models import TUser + + +@xframe_options_exempt +@require_GET +def sales_index(request): + """跳转营销管理首页""" + return render(request, 'sales/sale_chance.html') + + +@require_GET +def select_sale_chance_list(request): + try: + page_num = request.GET.get('page') # 页号 + page_size = request.GET.get('limit') # 页容量 + + state = request.GET.get('state') + # 客户名称 + customerName = request.GET.get('customerName') + # 创建人 + createMan = request.GET.get('createMan') + # 开发状态(客户开发计划使用) + devResult = request.GET.get('devResult') + + if customerName: + users = SaleChance.objects.filter(isValid=1, customerName=customerName).values() + elif createMan: + users = SaleChance.objects.filter(isValid=1, createMan=createMan).values() + elif state: + users = SaleChance.objects.filter(isValid=1, state=state).values() + elif devResult: + users = SaleChance.objects.filter(isValid=1, devResult=devResult).values() + else: + users = SaleChance.objects.filter(isValid=1).values() + + paginator = Paginator(users, page_size) + users_list = paginator.page(page_num).object_list + + context = { + 'code': 0, + 'msg': '', + 'count': len(users), + 'data': list(users_list) + } + + return JsonResponse(context) + + except Exception as e: + return JsonResponse({'code': 400, 'msg': 'error'}) + + +@xframe_options_exempt +@require_GET +def create_or_update_sales(request): + """跳转添加/修改营销机会页面""" + # 获取营销机会主键 + saleChanceId = request.GET.get('saleChanceId') + context = None + if saleChanceId: + # 根据营销机会主键查询 + sc = SaleChance.objects.get(pk=saleChanceId) + context = {'sc': sc} + return render(request, 'sales/add_update.html', context) + + +@require_GET +def select_customer(request): + """查询客户""" + customer = Customer.objects.values("id", 'name') \ + .filter(isValid=1).order_by('-id').all() + return JsonResponse(list(customer), safe=False) + + +@csrf_exempt +@require_GET +def create_sale_chance(request): + """添加营销机会和联系人""" + try: + # 接收参数 + customerId = request.GET.get('customer') + customerName = request.GET.get('customerName') + chanceSource = request.GET.get('chanceSource') + linkMan = request.GET.get('linkMan') + linkPhone = request.GET.get('linkPhone') + cgjl = request.GET.get('cgjl') + overview = request.GET.get('overview') + description = request.GET.get('description') + assignMan = request.GET.get('assignMan') + # 如果有联系人还要添加联系人表数据 + if linkMan: + lm = LinkMan(cusId=customerId, linkName=linkMan, phone=linkPhone) + lm.save() + # 如果有分配人,添加分配时间,分配状态为已分配 + if assignMan != '0': + sc = SaleChance(customerId=customerId, customerName=customerName, + chanceSource=chanceSource, linkMan=linkMan, + linkPhone=linkPhone, + cgjl=cgjl, overview=overview, description=description, + assignMan=assignMan, assignTime=datetime.now(), state=1, + devResult=0, + createMan=request.session.get('user')['username']) + else: + sc = SaleChance(customerId=customerId, customerName=customerName, + chanceSource=chanceSource, linkMan=linkMan, + linkPhone=linkPhone, + cgjl=cgjl, overview=overview, description=description, + state=0, devResult=0, + createMan=request.session.get('user')['username']) + # 插入数据 + sc.save() + # 返回提示信息 + return JsonResponse({'code': 200, 'msg': '添加成功'}) + except Exception as e: + return JsonResponse({'code': 400, 'msg': '添加失败'}) + + +@csrf_exempt +@require_GET +def update_sale_chance(request): + """修改营销机会和联系人""" + try: + # 接收参数 + id = request.GET.get('id') + customerId = request.GET.get('customer') + customerName = request.GET.get('customerName') + chanceSource = request.GET.get('chanceSource') + linkMan = request.GET.get('linkMan') + linkPhone = request.GET.get('linkPhone') + cgjl = request.GET.get('cgjl') + overview = request.GET.get('overview') + description = request.GET.get('description') + assignMan = request.GET.get('assignMan') + # 根据主键查询营销机会 + sc = SaleChance.objects.get(pk=id) + # 如果有联系人还要修改联系人表数据 + if linkMan != sc.linkMan: + LinkMan.objects.filter(cusId=customerId) \ + .update(linkName=linkMan, phone=linkPhone, updateDate=datetime.now()) + # 如果用户取消了分配人,要改变分配状态为未分配 + if assignMan == '0': + sc.state = 0 + sc.assignMan = None + sc.assignTime = None + else: + sc.state = 1 + sc.assignMan = assignMan + sc.assignTime = datetime.now() + # 重新赋值 + sc.customerId = customerId + sc.customerName = customerName + sc.chanceSource = chanceSource + sc.linkMan = linkMan + sc.linkPhone = linkPhone + sc.cgjl = cgjl + sc.overview = overview + sc.description = description + sc.updateDate = datetime.now() + # 保存 + sc.save() + # 返回提示信息 + return JsonResponse({'code': 200, 'msg': '修改成功'}) + except Exception as e: + return JsonResponse({'code': 400, 'msg': '修改失败'}) + + +@csrf_exempt +@require_GET +def delete_sale_chance(request): + """删除营销机会""" + try: + # 接收参数 + ids = request.GET.get('ids') + id_list = list(map(int, ids.split(","))) + SaleChance.objects.filter(pk__in=id_list).delete() + + return JsonResponse({'code': 200, 'msg': '删除成功'}) + except Exception as e: + return JsonResponse({'code': 400, 'msg': '删除失败'}) + + +@xframe_options_exempt +@require_GET +def cus_dev_plan_index(request): + """跳转营销机会管理首页""" + return render(request, 'sales/cus_dev_plan.html') + + +@xframe_options_exempt +@require_GET +def cus_dev_plan_index_detail(request): + """跳转客户开发计划详情页""" + # 接收参数 + saleChanceId = request.GET.get('saleChanceId') + # 根据主键查询营销机会 + sc = SaleChance.objects.get(pk=saleChanceId) + context = {'sc': sc} + return render(request, 'sales/cus_dev_plan_detail.html', context) + + +@require_GET +def select_cus_dev_plan_list(request): + """查询客户开发计划详细列表""" + try: + # 获取第几页 + page_num = request.GET.get('page', 1) + # 获取每页多少条 + page_size = request.GET.get('limit', 10) + # 获取客户营销机会主键 + saleChanceId = request.GET.get('saleChanceId') + # 查询 + cdp_list = CusDevPlan.objects.extra(select={'planDate': 'date_format(plan_date, "%%Y-%%m-%%d")'}) \ + .values('id', 'planItem', 'planDate', 'exeAffect', 'saleChance') \ + .filter(saleChance=saleChanceId).order_by('-id') + # 初始化分页对象 + p = Paginator(cdp_list, page_size) + # 获取指定页数的数据 + data = p.page(page_num).object_list + # 返回总条数 + count = p.count + # 返回数据,按照 layuimini 要求格式构建 + context = { + 'code': 0, + 'msg': '', + 'count': count, + 'data': list(data) + } + return JsonResponse(context) + except Exception as e: + return JsonResponse({'code': 400, 'msg': 'error'}) + + +@xframe_options_exempt +@require_GET +def create_or_update_cus_dev_plan(request): + """跳转客户开发计划添加/修改页面""" + # 获取营销机会主键 + saleChanceId = request.GET.get('saleChanceId') + # 获取客户开发计划主键 + id = request.GET.get('id') + context = {'saleChanceId': saleChanceId} + if id: + cusDevPlan = CusDevPlan.objects.get(pk=id) + context['cusDevPlan'] = cusDevPlan + return render(request, 'sales/cus_dev_plan_add_update.html', context) + + +@csrf_exempt +@require_GET +def create_cus_dev_plan(request): + """添加客户开发计划""" + # 接收参数 + data = request.GET.dict() + # 弹出营销机会主键 + saleChanceId = data.pop('saleChanceId') + # 删除主键 + del data['id'] + # 获取营销机会对象 + sc = SaleChance.objects.get(pk=saleChanceId) + data['saleChance'] = sc + # 添加客户开发计划 + CusDevPlan.objects.create(**data) + # 修改营销机会的开发状态为开发中 + sc.devResult = 1 + sc.updateDate = datetime.now() + sc.save() + return JsonResponse({'code': 200, 'msg': '添加成功'}) + + +@csrf_exempt +@require_GET +def update_cus_dev_plan(request): + """修改客户开发计划""" + # 接收参数 + data = request.GET.dict() + # 弹出营销机会主键 + saleChanceId = data.pop('saleChanceId') + # 删除主键 + id = data.pop('id') + # 修改时间 + data['updateDate'] = datetime.now() + # 修改客户开发计划 + CusDevPlan.objects.filter(pk=id).update(**data) + return JsonResponse({'code': 200, 'msg': '修改成功'}) + + +@csrf_exempt +@require_GET +def delete_cus_dev_plan(request): + """删除客户开发计划""" + # 获取主键 + id = request.GET.get('id') + # 逻辑删除客户开发计划 + CusDevPlan.objects.filter(pk=id).update(isValid=0, updateDate=datetime.now()) + return JsonResponse({'code': 200, 'msg': '删除成功'}) + + +@csrf_exempt +@require_GET +def update_dev_result(request): + """开发成功或者开发失败""" + # 接收参数 + saleChanceId = request.GET.get('saleChanceId') + devResult = request.GET.get('devResult') + SaleChance.objects.filter(pk=saleChanceId).update(devResult=devResult, + updateDate=datetime.now()) + return JsonResponse({'code': 200, 'msg': '操作成功'}) diff --git a/serve/__init__.py b/serve/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/serve/__pycache__/__init__.cpython-39.pyc b/serve/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6110a856d98172096be528c3ed00149bc2e2a317 GIT binary patch literal 158 zcmYe~<>g`kf)n%lQb6=$5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!HsvsFxJacWU< zjG>XGp+SsGetBL_equ^-j7wHxUV47KbC7R*aAk2xYOZc>B9JPI0je%bjfs!X%*!l^ ZkJl@xyv1RYo1apelWGSt{4)?U004ufCb<9r literal 0 HcmV?d00001 diff --git a/serve/__pycache__/admin.cpython-39.pyc b/serve/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..904df5ff9a3978aa8093daf6aa0b9487e13d6f98 GIT binary patch literal 199 zcmYe~<>g`kf)n%lQtW~BV-N=!FabFZKwK;UBvKes7;_kM8KW2(8B&;n88n$+0!0}# z8E>&BrsQVk`Drpm@ug%X=B4NBCFkdr6lEqAfecv5P{a(Rz{D>HXRDad;?$zz7(*jV zLxUKX{PMh<{KS;v7#Fb4c;_JB_~6RolGI$?+(aN%6a!RUmKp=LLa(6m7Kcr4eoARh NsvRTH(9b~3008l5G6Mhr literal 0 HcmV?d00001 diff --git a/serve/__pycache__/apps.cpython-39.pyc b/serve/__pycache__/apps.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..675367ec3eab5099eea2f3775f5e93ba82399f2f GIT binary patch literal 433 zcmYjNy-ve05Vqq~D*agyD-vr4BFY9r(9#MfI#97hku1YGQIYdQ+a1+5=Mv4FdsQCW_QJej8tRM{4e$q?1&3)cfrh#zX&2I=9_+3X_{5Lzy^l}tJu>a}x&)rzfB8xL+$Q7? z1nW-#;28{!LJ&a=f7U~8Mi!Vqe??bjP8O8ni3-t_iyfy?kFhfL?xZ z?Xi9F5E|!W+dG_VQ} z;E~I#{7>jT8)Xg8@*%iE^O@AhB^HKlBWIpTt|YXeHmsK^30gjr)vS<9fesOLUp}5n zWw+`XH+d-&s&`}f^Z>-F$pmG-@bJXG9&RN5 z;8>cJ4GdqUk>k(ElO#}m@K@U?kjX|+4wIf2a;^W}Nx=TM0rEV8+3Em%0`rsP-g_(x z&!z1gzD(8Exhw?hxb0p**%jV1Y7fOe2-a`1dfF5(uJiKT)lT8{W_w4NBS^R7vfa9X zxWMAZ`?;&zszMIc3~aD&;e0l%PF=;6YpVF$sgZC;x@}Yox9--_U;wsTmjmbZt=F#3 zCo(fyVG=%+E;R%N=2w3TBJ%nhZwx4;-anxqH{U+3-_UcOCrJpW!`+Do;=ImjySc~f d2wLvmbH*Rq-$q~5_uZG+Ejk1d2eCg4{{`#a!K(lO literal 0 HcmV?d00001 diff --git a/serve/__pycache__/urls.cpython-39.pyc b/serve/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c7a0a631c99498080b94b34523739180fdceb3e2 GIT binary patch literal 534 zcmZ9JO-=$a6o6Z1h8Y+@SeSSP7Bb>aLeK=Zx{$ablT0SOieTp_?Eo@&&?C6_1YW^2 zbnA*M=*CxOOpI;%`o7op{WWYh>jcNg>kGV7LOwP89W{h2Tylj12vANUI-`_81q@z^ zjG2MDIWrjriy12ms$f4GNDfjJY9-Z?Y;a3zAUV)1sfAR7BTWlyR)_YKbUS;DN4iv* zX_!6iF*Oa=X34fvS(1qj%a4aL6N8LJDGxI?@|H2MCr`PD)8IhbK^#UbxA;dgt$G|+j8Dxz?-(47|gGlYvmx%dc6&zOki8xd`NpvBkac;Me*X43DU zU-ZxXNwST35`y$6hiJk0_BxpEB=+Sr3UL$up$=bX(MxyA8Ab`LIUDJwO6{{j8x_-N I(QpF literal 0 HcmV?d00001 diff --git a/serve/__pycache__/views.cpython-39.pyc b/serve/__pycache__/views.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..03749bd00e2dcdaf2c66269da5b923078fad9b88 GIT binary patch literal 3025 zcmai0-H#l_5ufgvot>SX-TO4b{MU=cnHiGVl`!Lkh~k_qx%6nS;hXqoOi&)&?= zrhC@+q1h2#7@uKd^k+fi33%kkAeg~OWW+|(AgI%b#I#AZZboKo zH7%`MQ7N{Y_W$Ums2n>@N89bF61z=T>*c5#dreR4PE?EQ%{no-!#!4E?nPsRY>?&{ zw5rU*R&!kYYOG%PCb$dUF*aVbCv|&*O&0AbHZ^B7ruQHMqd}CzS}9M%n1fzGM?{cT;dw11T0qnu7nL7Ygn_ zb$TAWwUa%WCNURtTwLG*#RU{U6W)mJNqFR85R7C-+t?wD4hSO$jga(dN;89*8M(vA z=!OX~SUv1|?SuEOU4CnKdvo~W;OaYrt6RSrZe6_c;opWYzIJWn^4?$mxHouTIX%fm z2Nta?)YfYtF7O9uX`7y(eK93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f88mK&m609FfX@3AG!su~Oao>vQ}O-O z!lNZ4%sOs#rombQ>(e)^Hl)V&9%az&b{P&D%A8HouG|8Yi?cC*xi>m@qp040$#`;svN`V4>jDV zYK+B?&}ep(Zk|xM$I9#^D>q>mn9s`2c`(O5Pca}syjtY>rHlQxB=ZVF*4-G)B9U@% zAMo#xIy_jqcM=k3;q2AOkXHwgGBIIpqc!lrb$ax3*Y%P?drv-@xmg{Cn61c zsnlhl4j1P9_Q5zzhSxng8$@BS+-?QSVP{ETVyJKY->z`U6Xh@MqSxU-m!_w~oQ;9X zBbmd8*BZ?{x|nq8=}1QsRzs$_&p8f5dl7#ej|KSv2*hUOPrVXSpI4>CeNbzzmKBs= E04>opSpWb4 literal 0 HcmV?d00001 diff --git a/serve/admin.py b/serve/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/serve/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/serve/apps.py b/serve/apps.py new file mode 100644 index 0000000..4737b95 --- /dev/null +++ b/serve/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ServeConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'serve' diff --git a/serve/migrations/__init__.py b/serve/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/serve/migrations/__pycache__/__init__.cpython-39.pyc b/serve/migrations/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d3ccb2711fcd2e04acf77888267f5f9a466162b0 GIT binary patch literal 169 zcmYe~<>g`kg2d&vX(0MBh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6wy*(xTqIJKxa z#?Z*p&>+SozdSD|KQW~^#w9B;FFilrImkCYxU#q;HCHz`5l9uq09BWz#^h$E7bTWt j=I0g1#K&jmWtPOp>lIYq;;_lhPbtkwwFBAn8HgDG2MsE) literal 0 HcmV?d00001 diff --git a/serve/models.py b/serve/models.py new file mode 100644 index 0000000..e34cee6 --- /dev/null +++ b/serve/models.py @@ -0,0 +1,49 @@ +from django.db import models + +# Create your models here. + +from django.db import models + + +class ModelManager(models.Manager): + def get_queryset(self): + return super(ModelManager, self).get_queryset().filter(isValid=1) + + +# 服务模型 +class CustomerServe(models.Model): + # 服务类型 咨询/建议/投诉 + serveType = models.CharField(db_column='serve_type', max_length=50) + # 概要 + overview = models.CharField(db_column='overview', max_length=500) + # 客户 + customer = models.CharField(db_column='customer', max_length=30) + # 新创建/已分配/已处理/已归档 + state = models.CharField(db_column='state', max_length=10) + # 服务请求 + serviceRequest = models.CharField(db_column='service_request', max_length=500) + # 创建人 + createPeople = models.CharField(db_column='create_people', max_length=100) + # 分配人 + assigner = models.CharField(db_column='assigner', max_length=100) + # 分配日期 + assignTime = models.DateTimeField(db_column='assign_time') + # 服务处理 + serviceProce = models.CharField(db_column='service_proce', max_length=500) + # 服务处理人 + serviceProcePeople = models.CharField(db_column='service_proce_people', + max_length=50) + # 服务处理日期 + serviceProceTime = models.DateTimeField(db_column='service_proce_time') + # 服务处理结果 + serviceProceResult = models.CharField(db_column='service_proce_result', + max_length=500) + # 客户满意度 + myd = models.CharField(db_column='myd', max_length=50) + isValid = models.IntegerField(db_column='is_valid', default=1) + createDate = models.DateTimeField(db_column='create_date', auto_now_add=True) + updateDate = models.DateTimeField(db_column='update_date', auto_now_add=True) + objects = ModelManager() + + class Meta: + db_table = 't_customer_serve' diff --git a/serve/tests.py b/serve/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/serve/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/serve/urls.py b/serve/urls.py new file mode 100644 index 0000000..f1c4cfc --- /dev/null +++ b/serve/urls.py @@ -0,0 +1,12 @@ +from django.urls import path +from . import views + +app_name = 'serve' + +urlpatterns = [ + path('/index/', views.serve_index, name='serve_index'), + path('list/', views.select_serve_list, name='select_serve_list'), + path('/workflow/', views.serve_workflow, name='serve_workflow'), + path('create/', views.create_serve, name='create_serve'), + path('update/', views.update_serve, name='update_serve'), +] diff --git a/serve/views.py b/serve/views.py new file mode 100644 index 0000000..aaaf23e --- /dev/null +++ b/serve/views.py @@ -0,0 +1,121 @@ +from datetime import datetime + +from django.core.paginator import Paginator +from django.http import JsonResponse +from django.shortcuts import render +from django.shortcuts import render +from django.views.decorators.clickjacking import xframe_options_exempt +from django.views.decorators.csrf import csrf_exempt +from django.views.decorators.http import require_GET + +from serve.models import CustomerServe + + +# Create your views here. + +@xframe_options_exempt +@require_GET +def serve_index(request, template): + """跳转服务管理各个功能首页""" + context = {'username': request.session.get('user')['username']} + ''' + create 创建 assign 分配 + handle 处理 + feedback 反馈 archive 归档 + ''' + return render(request, 'serve/%s.html' % template, context) + + +@require_GET +def select_serve_list(request): + """工作流程中多个页面的公共查询""" + try: + # 获取第几页 + page_num = request.GET.get('page', 1) + # 获取每页多少条 + page_size = request.GET.get('limit', 10) + # 查询 + select_dict = { + 'assignTime': 'select DATE_FORMAT(assign_time, "%%Y-%%m-%%d-%%H:%%i:%%s")', + 'serviceProceTime': 'select DATE_FORMAT(service_proce_time, "%%Y-%%m-%%d-%%H:%%i:%%s")', + 'createDate': 'select DATE_FORMAT(create_date, "%%Y-%%m-%%d-%%H:%%i:%%s")', + 'updateDate': 'select DATE_FORMAT(update_date, "%%Y-%%m-%%d-%%H:%%i:%%s")', + } + queryset = CustomerServe.objects.extra(select=select_dict) \ + .values().order_by('-id').all() + # 条件查询 + # 服务状态:1 新创建 / 2 已分配 / 3 已处理 / 4 已反馈 + state = request.GET.get('state') + if state: + queryset = queryset.filter(state=state) + # 客户 + customer = request.GET.get('customer') + if customer: + queryset = queryset.filter(customer__icontains=customer) + # 服务类型:6 咨询 / 7 投诉 / 8 建议 + serveType = request.GET.get('serveType') + if serveType: + queryset = queryset.filter(serveType=serveType) + # 初始化分页对象 + p = Paginator(queryset, page_size) + # 获取指定页数的数据 + data = p.page(page_num).object_list + # 返回总条数 + count = p.count + # 返回数据,按照 layuimini 要求格式构建 + context = { + 'code': 0, + 'msg': '', + 'count': count, + 'data': list(data) + } + return JsonResponse(context) + except Exception as e: + return JsonResponse({'code': 400, 'msg': 'error'}) + + +@xframe_options_exempt +@require_GET +def serve_workflow(request, template): + """工作流程中多个子页面的公共函数""" + context = {'username': request.session.get('user')['username']} + # 获取服务主键 + id = request.GET.get('id') + if id: + context['cs'] = CustomerServe.objects.get(pk=id) + return render(request, 'serve/%s_serve.html' % template, context) + + +@csrf_exempt +@require_GET +def create_serve(request): + """创建服务""" + # 接收参数 + data = request.GET.dict() + # 添加 + CustomerServe.objects.create(**data) + return JsonResponse({'code': 200, 'msg': '创建成功'}) + + +@csrf_exempt +@require_GET +def update_serve(request): + """修改服务公共函数""" + # 接收参数 + serve = request.GET.dict() + # 弹出主键 + id = serve.pop('id') + # 获取分配状态 + state = serve.get('state') + # 如果是 2 已分配,修改分配时间 + if state == '2': + serve['assignTime'] = datetime.now() + # 如果是 3 已处理,修改处理时间 + elif state == '3': + serve['serviceProceTime'] = datetime.now() + # 当条记录修改时间 + serve['updateDate'] = datetime.now() + CustomerServe.objects.filter(pk=id).update(**serve) + return JsonResponse({'code': 200, 'message': '操作成功'}) + +