| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732 |
- @extends('layouts.app')
- @section('title')项目编辑-项目管理@endsection
- @section("head")<link href="{{ mix('css/animation.css') }}" rel="stylesheet">@endsection
- @section('content')
- <div class="container-fluid card d-none" id="container">
- <div class="card-body offset-1">
- <div class="row">
- <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('one')">
- <div class="h-100 w-25">
- <div class="h1 fillet text-center" :class="[base == 'one' ? 'sign' : '', (base!=='one' && !owner.name) ? 'bg-secondary border-secondary' : 'bg-info']">
- <span class="fa fa-edit ml-1 text-white"></span>
- </div>
- </div>
- <div class="h-100 w-75">
- <span class="font-weight-bold ml-1">基础信息</span><br>
- <span class="small ml-1">名称:@{{ owner.name }}</span><br>
- <span class="small ml-1">代码:@{{ owner.code }}</span><br>
- </div>
- </div>
- <div class="col-2">
- <hr class="w-100 mt-4 hr-info">
- </div>
- <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('two')">
- <div class="h-100 w-25">
- <div class="h1 fillet text-center" :class="[base == 'two' ? 'sign' : '', (base!=='two' && !owner.customer_id) ? 'bg-secondary border-secondary' : 'bg-info']">
- <span class="fa fa-book ml-1 text-white"></span>
- </div>
- </div>
- <div class="h-100 w-75">
- <span class="font-weight-bold ml-1">详细描述</span><br>
- <span class="small ml-1">客户:@{{ owner.customer_name }}</span><br>
- <span class="small ml-1">小组:@{{ owner.owner_group_name }}</span><br>
- </div>
- </div>
- <div class="col-2">
- <hr class="w-100 mt-4 hr-info">
- </div>
- <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('three')">
- <div class="h-100 w-25">
- <div class="h1 fillet text-center" :class="[base == 'three' ? 'sign' : '', (base!=='three' && !isExist) ? 'bg-secondary border-secondary' : 'bg-info']">
- <span class="fa fa-rmb ml-1 text-white "></span>
- </div>
- </div>
- <div class="h-100 w-75">
- <div class="font-weight-bold ml-1 h-100 mt-3">计费模型</div>
- </div>
- </div>
- </div>
- <div v-if="base == 'one'">
- @include("customer.project.part._one")
- </div>
- <div v-if="base == 'two'">
- @include("customer.project.part._two")
- </div>
- <div v-show="base == 'three'">
- <div v-if="isLoad">@include("customer.project.part._three")</div>
- <div class="row justify-content-center text-secondary" style="min-height: 200px;margin-left: -25%" v-if="!isLoad">
- <div class="align-self-center h1">
- <i class="fa fa-spinner fa-pulse"></i>
- </div>
- </div>
- </div>
- <hr class="mt-2">
- <div class="row mt-3" v-if="base != 'three' || isLoad">
- <div class="pull-right offset-7">
- <button type="button" class="btn btn-info ml-1 text-white" v-show="base !== 'one'" @click="back()">上一步</button>
- <button type="button" class="btn btn-info ml-1 text-white" v-show="base !== 'three'" @click="next()">下一步</button>
- <button type="button" class="btn btn-success ml-1" @click="success()">完成</button>
- <button type="button" class="btn btn-secondary ml-1" @click="reset()" v-show="base !== 'three'">重置</button>
- </div>
- </div>
- @include("customer.project.part._auditComparison")
- </div>
- </div>
- @stop
- @section('lastScript')
- <script>
- new Vue({
- el:"#container",
- data:{
- base:"one",
- owner : {
- id:"{{$owner->id ?? ''}}",
- name : "{{$owner->name ?? ''}}",
- code : "{{$owner->code ?? ''}}",
- customer_id : "{{$owner->customer_id ?? ''}}",
- customer_name : "{{ isset($owner) ? ($owner->customer ? $owner->customer->name : '') : ''}}",
- owner_group_name : "{{ isset($owner) ? ($owner->userOwnerGroup ? $owner->userOwnerGroup->name : '') : ''}}",
- owner_group_id : "{{$owner->user_owner_group_id ?? ''}}",
- user_workgroup_id : "{{$owner->user_workgroup_id ?? ''}}",
- warehouse_id : "{{ $owner->warehouse_id ?? ''}}",
- tax_rate_id : "{{$owner->is_tax_exist ?? ''}}"==='Y' ? '0' : "{{$owner->tax_rate_id ?? ''}}",
- linkman : "{{$owner->linkman ?? ''}}",
- phone_number : "{{$owner->phone_number ?? ''}}",
- description : "{{$owner->description ?? ''}}",
- waring_line_on : "{{$owner->waring_line_on ?? ''}}",
- subjection : "{{$owner->subjection ?? ''}}",
- is_tax_exist : "{{$owner->is_tax_exist ?? ''}}"==='Y',
- kc :"{{$owner->kc ?? ''}}",
- jg :"{{$owner->jg ?? ''}}",
- th :"{{$owner->th ?? ''}}",
- sh :"{{$owner->sh ?? ''}}",
- fh :"{{$owner->fh ?? ''}}",
- },
- ownerTemp : {},
- customers : [
- @foreach($customers as $customer)
- {id:"{{$customer->id}}",name:"{{$customer->name}}"},
- @endforeach
- ],
- ownerGroups : [
- @foreach($ownerGroups as $ownerGroup)
- {id:"{{$ownerGroup->id}}",name:"{{$ownerGroup->name}}"},
- @endforeach
- ],
- userGroups : [
- @foreach($userGroups as $userGroup)
- {id:"{{$userGroup->id}}",name:"{{$userGroup->name}}",warehouse_id:"{{$userGroup->warehouse_id}}"},
- @endforeach
- ],
- warehouses:[
- @foreach($warehouses as $warehouse)
- {id:"{{$warehouse->id}}",name:"{{$warehouse->name}}"},
- @endforeach
- ],
- style : '',
- errors : {!! $errors !!}, //全部的错误提示
- upList:{ //控制元素的渐入展开与收起
- storage : false,
- },
- type:"storage",//当前编辑类型 仓储,作业,物流...
- currentInputting:{
- edittingOperation:null,
- },
- model:{ //编辑元素绑定值
- storage:{
- counting_type : "",
- using_type : "",
- minimum_area : "",
- price : [""],
- amount_interval : [""],
- discount_type : "无减免",
- discount_value : "",
- unit_id : "",
- time_unit_id : "",
- },
- operation:{},
- express:{
- name:"",
- initial_weight:"",
- additional_weight:"",
- amount_interval:[""],
- weight_interval:[[]],
- items:[],
- logistics:[],
- },
- logistic:{
- items:[],
- other_ranges:[],
- ranges:[],
- logistics:[],
- },
- directLogistic:{
- items:[],
- },
- system:{
- usage_fee:""
- },
- },
- pool:{//基础数据选择池,以方便异步懒加载而非即时加载 例:units,owners等
- counting_type:[
- "包仓","灵活用仓","统单价"
- ],
- using_type:[
- "常温","恒温"
- ],
- discount_type:[
- "无减免","按单减免","固定减免"
- ],
- feature_type:[],
- logic : ['包含','不包含','等于',"大于","大于等于","小于","小于等于"],
- },
- poolMapping:{},//基础数据选择池的映射对象 供展示使用
- selectedModel:{//已选定的计费模型
- storage:[],
- operation:[],
- express:[],
- logistic:[],
- directLogistic:{},
- system:{},
- },
- thisOperationItemIndex:-1,//当前选中的作业费子项下标,用以唤起特征模态框
- operationItems:{},//控制作业费子项的渐入展开
- importError:[],//导入时的错误数据原因
- isShowError:false,//是否展开导入错误信息
- isExist:Boolean("{{$isExist ?? false}}"),
- isLoad:false,//全局加载标记,符合条件时确保仅加载一次
- introduce:{},//引入model
- isSearch:false,//是否查询,用于加载动画显示
- searchResult:[],//查询结果
- searchResultMapping:{},//查询结果映射
- selectedResult:"",
- searchItem:{},//搜索子项集
- searchBase:5,//搜索基数
- hover:{},//可悬浮列表
- audit:{},//审核按钮
- auditList:{
- storage:{},operation:{},express:{},logistic:{},directLogistic:{},system:{},
- mapping: {
- "storage": {
- "name": "名称",
- "counting_type": "计费类型",
- "using_type": "用仓类型",
- "minimum_area": "最低起租面积",
- "discount_type": "减免类型",
- "discount_value": "减免值",
- "unit_id": "单位",
- "time_unit_id": "计时单位",
- "amount_interval": "数量-单价",
- "tax_rate_id": "税率",
- },
- "operation": {
- name: "名称",
- operation_type: "作业类型",
- strategy: "策略",
- feature: "特征",
- total_price: "按单价",
- total_discount_price: "按单减免单价",
- discount_count: "减免值",
- type_mark: "类型",
- surcharge: "附加费",
- surcharge_unit_id: "附加费单位",
- max_fee: "封顶费",
- remark: "备注",
- tax_rate_id: "税率",
- child: {
- strategy: "子策略",
- amount: "起步数",
- unit_id: "单位",
- unit_price: "单价",
- feature: "特征",
- discount_price: "减免单价",
- odd_price: "零头价",
- }
- },
- "express": {
- name: "名称",
- initial_weight: "首重",
- additional_weight: "续重",
- weight_interval: "数量-重量",
- tax_rate_id: "税率",
- child: {
- province_id: "省",
- initial_weight_price: "初始单价",
- additional_weight_price: "续重单价",
- },
- },
- "logistic": {
- name: "名称",
- unit_id: "单位一",
- unit_range: "单位一区间",
- other_unit_id: "单位二",
- other_unit_range: "单位二区间",
- pick_up_price: "提货费",
- fuel_price: "燃油附加费",
- service_price: "服务费",
- tax_rate_id: "税率",
- child: {
- unit_id: "单位",
- range: "区间",
- province_id: "省份",
- city_id: "城市",
- unit_price: "单价",
- delivery_fee: "送货费",
- initial_fee: "起始计费",
- initial_amount: "起始计数",
- rate: "费率",
- },
- },
- "directLogistic": {
- name: "名称",
- base_km: "起步公里数",
- tax_rate_id: "税率",
- child: {
- car_type_id: "车型",
- base_fee: "起步费",
- additional_fee: "续费(元/KM)"
- }
- },
- }
- },//审核对比
- selectedAudit:"",//当前选择对比项
- showAuditPiece:{
- "C":false,"D":false,"U":false
- },//显示审核块
- isAudit:true,
- comparisonTemp:{},
- },
- created(){
- this.filterCustomers = JSON.parse(JSON.stringify(this.customers));
- this.filterOwnerGroups = JSON.parse(JSON.stringify(this.ownerGroups));
- this.filterUserGroups = JSON.parse(JSON.stringify(this.userGroups));
- },
- mounted(){
- let type = "{{$type ?? ''}}";
- this._resetOperation();
- this.ownerTemp = JSON.parse(JSON.stringify(this.owner));
- if (type){
- this.switchBase("three");
- this.type = "";
- setTimeout(()=>{
- this.switchType(type);
- if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
- if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
- },0);
- }
- $('[data-toggle="tooltip"]').tooltip();
- $("#container").removeClass("d-none");
- },
- methods:{
- //重置作业计费数据
- _resetOperation(){
- this.model.operation = {
- operation_type:"入库",
- strategy:"默认",
- discount_count:[''],
- name:"",
- isRejected:false,
- feature:"",
- total_discount_price:[''],
- items : [
- {strategy:"起步",type:"0",discount_price:['']},
- {strategy:"默认",discount_price:['']},
- {strategy:"特征",discount_price:['']},
- ],
- };
- },
- //悬浮效果
- hoverEffect(key,val){
- this.$set(this.hover,key,val);
- },
- //收起展开
- show(id){
- if (this.upList[id])$("#"+id).slideDown();
- else $("#"+id).slideUp();
- this.upList[id] = !this.upList[id];
- this.$forceUpdate();
- },
- //清除垃圾数据
- _clearRefuse(){
- this.errors = {};
- this.importError = [];
- this.selectedResult = "";
- this.searchResult = [];
- this.searchResultMapping = {};
- this.introduce = {};
- },
- //切换选项
- switchBase(base){
- if (!this.owner.id)return;
- if (base === this.base)return;
- if (base === 'three'){
- if (!this.pool.taxRates) this._getTaxRates();
- this._loadStorage();
- }
- if (base === 'two')if (!this.pool.taxRates) this._getTaxRates();
- this.base = base;
- },
- //切换类型
- switchType(type){
- if (type === this.type)return;//相同终止是为了减少重复加载动作
- this._clearRefuse();//清除垃圾数据
- let parent = $("#parent");
- let dom = "";
- switch (type) {
- case "storage":
- this._loadStorage();
- dom = $("#storage-card");
- break;
- case "operation":
- this._loadOperation();
- dom = $("#operation-card");
- break;
- case "express":
- this._loadExpress();
- dom = $("#express-card");
- $("#expressImport").tooltip();
- break;
- case "logistic":
- this._loadLogistic();
- dom = $("#logistic-card");
- break;
- case "directLogistic":
- this._loadDirectLogistic();
- dom = $("#directLogistic-card");
- break;
- case "system":
- dom = $("#system-card");
- if(this.selectedModel.system && this.selectedModel.system.id)this.model.system = this.selectedModel.system;
- break;
- }
- dom.addClass("animation-translation");
- dom.fadeOut(500);
- setTimeout(function(){
- dom.removeClass("animation-translation");
- parent.prepend(dom);
- dom.fadeIn();
- },400);
- this.type = type;
- },
- //下一步
- next(){
- switch (this.base) {
- case "one":
- this._verifyOne(()=>{
- this.switchBase('two');
- });
- break;
- case "two":
- if (this._verifyTwo()){
- this.switchBase('three');
- }
- break;
- }
- },
- //完成
- success(){
- switch (this.base) {
- case "one":
- this._verifyOne(()=>{
- window.location.href = "{{url('customer/project/index')}}";
- });
- break;
- case "two":
- if (this._verifyTwo())window.location.href = "{{url('customer/project/index')}}";
- break;
- default:
- window.tempTip.confirm("<span class='text-danger'>确定后计费模型未保存项将被抛弃,您确认仍要完成吗?</span>",()=>{
- window.location.href = "{{url('customer/project/index')}}";
- });
- break;
- }
- },
- //重置
- reset(){
- switch (this.base) {
- case "one":
- this.owner = this.ownerTemp;
- break;
- case "two":
- this.owner = this.ownerTemp;
- break;
- }
- },
- //验证基础信息
- _verifyOne(func){
- if (!this.owner.code){
- this.$set(this.errors,"code",["项目代码为必填项"]);
- return false;
- }
- if (!this.owner.name){
- this.$set(this.errors,"name",["项目名称为必填项"]);
- return false;
- }
- if (this.owner.name !== this.ownerTemp.name || this.owner.code !== this.ownerTemp.code){
- let url = "{{url('maintenance/owner/apiStore')}}";
- let params = {name:this.owner.name,code:this.owner.code,id:this.owner.id};
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res.errors){
- this.errors = res.errors;
- return;
- }
- this.errors = {};
- this.owner.id = res.id;
- this.ownerTemp.id = res.id;
- this.ownerTemp.name = res.name;
- this.ownerTemp.code = res.code;
- func();
- });
- }else func();
- },
- //验证详细描述
- _verifyTwo(){
- let error = {};
- if (!this.owner.customer_id) error["customer_id"] = ["必须选择客户"];
- if (!this.owner.owner_group_id) error["owner_group_id"] = ["必须选择项目小组"];
- if (!this.owner.warehouse_id) error["warehouse_id"] = ["必须选择仓库"];
- // if (!this.owner.user_workgroup_id) error["user_workgroup_id"] = ["必须选择仓库小组"];
- if (!this.owner.kc) error["kc"] = ["必须选择库存组"];
- if (!this.owner.jg) error["jg"] = ["必须选择加工组"];
- if (!this.owner.th) error["th"] = ["必须选择退货组"];
- if (!this.owner.sh) error["sh"] = ["必须选择收货组"];
- if (!this.owner.fh) error["fh"] = ["必须选择发货组"];
- //if (!this.owner.tax_rate_id) error["tax_rate_id"] = ["必须选择税率"];
- if (JSON.stringify(error) !== "{}"){
- this.errors = error;
- return false;
- }
- this.owner.is_tax_exist = this.owner.tax_rate_id==='0';
- let url = "{{url('customer/project/projectUpdate')}}";
- let params = this.owner;
- let old = this.ownerTemp;
- if (params.customer_id !== old.customer_id ||
- params.owner_group_id !== old.owner_group_id ||
- params.kc !== old.kc ||
- params.jg !== old.jg ||
- params.th !== old.th ||
- params.sh !== old.sh ||
- params.fh !== old.fh ||
- params.warehouse_id !== old.warehouse_id ||
- params.tax_rate_id !== old.tax_rate_id ||
- params.waring_line_on !== old.waring_line_on ||
- params.phone_number !== old.phone_number ||
- params.subjection !== old.subjection ||
- params.is_tax_exist !== old.is_tax_exist ||
- params.description !== old.description){
- let result = undefined;
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res.errors){
- this.errors = res.errors;
- result = false;
- return;
- }
- this.errors = [];
- this.ownerTemp.customer_id = res.customer_id;
- this.ownerTemp.owner_group_id = res.owner_group_id;
- // this.ownerTemp.user_workgroup_id = res.user_workgroup_id;
- if (res.department_obligation_owner.obligation_code==='kc')this.ownerTemp.kc = res.department_obligation_owner.obligation_id;
- if (res.department_obligation_owner.obligation_code==='jg')this.ownerTemp.jg = res.department_obligation_owner.obligation_id;
- if (res.department_obligation_owner.obligation_code==='th')this.ownerTemp.th = res.department_obligation_owner.obligation_id;
- if (res.department_obligation_owner.obligation_code==='sh')this.ownerTemp.sh = res.department_obligation_owner.obligation_id;
- if (res.department_obligation_owner.obligation_code==='fh')this.ownerTemp.fh = res.department_obligation_owner.obligation_id;
- this.ownerTemp.warehouse_id = res.warehouse_id;
- this.ownerTemp.tax_rate_id = res.tax_rate_id;
- this.ownerTemp.waring_line_on = res.waring_line_on;
- this.ownerTemp.phone_number = res.phone_number;
- this.ownerTemp.description = res.description;
- this.ownerTemp.customer_name = params.customer_name;
- this.ownerTemp.owner_group_name = params.owner_group_name;
- this.ownerTemp.subjection = params.subjection;
- this.ownerTemp.is_tax_exist = params.is_tax_exist;
- result = true;
- });
- while (result){
- if (typeof result !== "undefined")return result;
- }
- }
- return true;
- },
- //上一步
- back(){
- switch (this.base) {
- case "two":
- this.base = 'one';
- break;
- case "three":
- this.base = 'two';
- break;
- }
- },
- //重载作业费
- _overrideOperation(operation){
- if (operation.discount_count){
- operation.isDiscount = true;
- operation.discount_count = operation.discount_count.split(",");
- } else operation.discount_count = [];
- if (operation.total_discount_price) operation.total_discount_price = operation.total_discount_price.split(",");
- else operation.total_discount_price = [];
- operation.items.forEach((item,j)=>{
- if (item.discount_price) operation.items[j].discount_price = item.discount_price.split(",");
- else operation.items[j].discount_price = [];
- });
- if (operation.total_price)operation.isSingle = true;
- if (operation.type_mark===0 || operation.type_mark==='0')operation.isRejected = true;
- return operation;
- },
- //重载快递费
- _overrideExpress(express){
- express.logistics.forEach((logistic,j)=>{
- express.logistics[j] = logistic.id;
- });
- if (!express.amount_interval || !express.weight_interval){
- express.amount_interval = [""];
- express.weight_interval = [[]];
- }else express.isInterval = true;
- return JSON.parse(JSON.stringify(express).replace(/details/g,"items"));
- },
- //重载物流费
- _overrideLogistic(logistic){
- logistic.logistics.forEach((l,j)=>{
- logistic.logistics[j] = l.id;
- });
- return JSON.parse(JSON.stringify(logistic).replace(/details/g,"items"));
- },
- //重载直发费
- _overrideDirectLogistic(directLogistic){
- return JSON.parse(JSON.stringify(directLogistic).replace(/details/g,"items"));
- },
- //加载计费模型
- _loadPriceModel(){
- let url = "{{url('customer/project/getPriceModel')}}";
- let params = {id:this.ownerTemp.id};
- window.tempTip.postBasicRequest(url,params,res=>{
- let audit = {};
- if (res.storage_audit_count && Number(res.storage_audit_count))audit.storage = true;
- if (res.operation_audit_count && Number(res.operation_audit_count))audit.operation = true;
- if (res.express_audit_count && Number(res.express_audit_count))audit.express = true;
- if (res.logistic_audit_count && Number(res.logistic_audit_count))audit.logistic = true;
- if (res.direct_logistic_audit_count && Number(res.direct_logistic_audit_count))audit.directLogistic = true;
- if (res.system_audit_count && Number(res.system_audit_count))audit.system = true;
- this.audit = audit;
- if (res.owner_storage_price_models.length>0)this.selectedModel.storage = res.owner_storage_price_models;
- if (res.owner_price_operations.length>0){
- this._loadOperation();
- res.owner_price_operations.forEach((operation,i)=>{res.owner_price_operations[i] = this._overrideOperation(operation);});
- this.selectedModel.operation = res.owner_price_operations;
- }
- if (res.owner_price_expresses.length>0){
- this._loadExpress();
- res.owner_price_expresses.forEach((express,i)=>{
- res.owner_price_expresses[i] = this._overrideExpress(express);
- this.upList['express-item-'+i] = true;
- });
- this.selectedModel.express = res.owner_price_expresses;
- }
- if (res.owner_price_logistics.length>0){
- if (res.owner_price_expresses.length===0)this._loadLogistic();
- else {this._getUnits();this._getCities();}
- res.owner_price_logistics.forEach((logistic,i)=>{
- res.owner_price_logistics[i] = this._overrideLogistic(logistic);
- this.upList['logistic-item-'+i] = true;
- });
- this.selectedModel.logistic = res.owner_price_logistics;
- }
- if (res.owner_price_direct_logistics.length>0){
- this._loadDirectLogistic();
- this.upList["directLogistic-item"] = true;
- this.selectedModel.directLogistic = this._overrideDirectLogistic(res.owner_price_direct_logistics[0]);
- }
- if (res.owner_price_system)this.selectedModel.system = res.owner_price_system;
- setTimeout(()=> {
- $(".up").slideUp();
- this.isLoad = true;
- },0)
- });
- },
- //加载仓储所需基础信息
- _loadStorage(){
- if (!this.pool.units)this._getUnits();
- if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
- if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
- },
- //加载作业
- _loadOperation(){
- if (!this.pool.units)this._getUnits();
- },
- //加载快递
- _loadExpress(){
- if (!this.pool.provinces)this._getProvinces();
- if (!this.pool.logistics)this._getLogistics();
- },
- //加载物流
- _loadLogistic(){
- if (!this.pool.units) this._getUnits();
- if (!this.pool.provinces)this._getProvinces();
- if (!this.pool.cities)this._getCities();
- if (!this.pool.logistics)this._getLogistics();
- },
- //加载直发车
- _loadDirectLogistic(){
- if (!this.pool.cars)this._getCars();
- },
- //加载引入
- loadIntroduce(){
- if (!this.pool.owners)this._getOwners();
- if (!this.pool.logistics)this._getLogistics();
- },
- _setModelData(key,val,column='name',append=""){
- if (!val)return;
- let mapping = [];
- val.forEach(item=>{
- mapping[item.id] = item[column]+append;
- });
- this.$set(this.pool,key,val);
- this.$set(this.poolMapping,key,mapping);
- },
- //获取项目
- _getOwners(){
- let url = "{{url('maintenance/owner/get')}}";
- window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("owners",res);});
- },
- //获取单位
- _getUnits(){
- let url = "{{url('maintenance/unit/getUnits')}}";
- window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("units",res);});
- },
- //获取省份
- _getProvinces(){
- let url = "{{url('maintenance/province/get')}}";
- window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("provinces",res);});
- },
- //获取城市
- _getCities(){
- let url = "{{url('maintenance/city/get')}}";
- window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("cities",res);});
- },
- //获取承运商
- _getLogistics(){
- let url = "{{url('maintenance/logistic/get')}}";
- window.tempTip.postBasicRequest(url,{type:''},res=>{
- this._setModelData("logistics",res);
- setTimeout(()=>{
- $(".selectpicker").selectpicker('refresh');
- },100);
- });
- },
- //获取车型
- _getCars(){
- let url = "{{url('maintenance/carType/get')}}";
- window.axios.post(url).then(res=>{this._setModelData("cars",res.data);});
- },
- //获取税率
- _getTaxRates(){
- let url = "{{url('maintenance/taxRate/get')}}";
- window.axios.post(url).then(res=>{this._setModelData("taxRates",res.data,"value","%");});
- },
- //保存模型
- saveModel(){
- this._clearRefuse();
- switch (this.type) {
- case "storage":
- this._verifyStorage();
- break;
- case "operation":
- this._verifyOperation();
- break;
- case "express":
- this._verifyExpress();
- break;
- case "logistic":
- this._verifyLogistic();
- break;
- case "directLogistic":
- this._verifyDirectLogistic();
- break;
- case "system":
- this._verifySystem();
- break;
- }
- },
- _verifySystem(){
- if (this.model.system.usage_fee<0){
- this.errors = {usage_fee:["费用不得小于0"]};
- return;
- }
- if (!this.model.system.time_unit_id){
- this.errors = {time_unit_id:["未选择计时单位"]};
- return;
- }
- if(this.owner.is_tax_exist && !this.model.system.tax_rate_id){
- this.errors = {tax_rate_id:["税率不可为空"]};
- return;
- }
- let url = "{{url('maintenance/priceModel/apiStoreSystem')}}";
- let params = this.model.system;
- params.owner_id = this.ownerTemp.id;
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res && res.errors){
- this.errors = res.errors;
- return;
- }
- this.selectedModel.system = res;
- this.model.system = {
- usage_fee:"",
- };
- this.errors = {};
- this.audit.system = true;
- });
- },
- _verifyStorage(){
- let error = {};
- if (!this.model.storage.counting_type)error["counting_type"] = ["未选择计费类型"];
- if (!this.model.storage.name)error["name"] = ["未填写名称"];
- if (!this.model.storage.using_type)error["using_type"] = ["未选择用仓类型"];
- if (!this.model.storage.price[0])error["price.0"] = ["未输入单价"];
- if (!this.model.storage.discount_type)error["discount_type"] = ["未选择减免类型"];
- if (!this.model.storage.unit_id)error["unit_id"] = ["未选择单位"];
- if (!this.model.storage.time_unit_id)error["time_unit_id"] = ["未选择计时单位"];
- if(this.owner.is_tax_exist && !this.model.storage.tax_rate_id)error = {tax_rate_id:["税率不可为空"]};
- if (this.model.storage.isInterval){
- if (this.model.storage.amount_interval.length<1 || this.model.storage.price.length<1){
- error["amount_interval.0"] = ["未设定数量区间"];
- error["price.0"] = ["未输入单价"];
- }else{
- this.model.storage.amount_interval.forEach((amount,i)=>{
- if (amount==="")error["amount_interval."+i] = ["未设定数量区间"];
- else if (i!==0 && Number(amount)<=Number(this.model.storage.amount_interval[i-1]))
- error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
- this.model.storage.amount_interval[i] = parseFloat(this.model.storage.amount_interval[i]);
- });
- this.model.storage.price.forEach((price,i)=>{
- if (price==="")error["price."+i] = ["未输入单价"];
- this.model.storage.price[i] = parseFloat(this.model.storage.price[i]);
- });
- }
- }
- if (JSON.stringify(error) !== "{}"){
- this.errors = error;
- return;
- }
- if (!this.model.storage.isInterval){
- this.model.storage.amount_interval = null;
- this.model.storage.price = [parseFloat(this.model.storage.price[0])];
- }
- let url = "{{url('maintenance/priceModel/apiStoreStorage')}}";
- let params = this.model.storage;
- params.owner_id = this.ownerTemp.id;
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res && res.errors){
- this.errors = res.errors;
- return;
- }
- if (this.model.storage.id){
- if (!res) this.selectedModel.storage[this.model.storage.index] = this.model.storage;
- else this.$set(this.selectedModel.storage,this.model.storage.index,res);
- }else {
- this.model.storage.id = res;
- this.selectedModel.storage.unshift(this.model.storage);
- }
- this.model.storage = {
- name : "",
- counting_type : "",
- using_type : "",
- minimum_area : "",
- price : [""],
- amount_interval : [""],
- discount_type : "无减免",
- discount_value : "",
- unit_id : "",
- time_unit_id : "",
- };
- this.errors = {};
- this.audit.storage = true;
- return "保存成功";
- });
- },
- _verifyOperation() {
- if (this.selectedModel.operation.length>0 && !this.model.operation.id){
- if (this.model.operation.strategy!=='特征'){
- if (!this.selectedModel.operation.every(operation=>{
- if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
- this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
- this.$forceUpdate();
- return false;
- }
- return true;
- }))return;
- }
- }
- if (!this.model.operation.name){
- this.$set(this.errors,"name",["名称不得为空"]);
- return;
- }
- if(this.owner.is_tax_exist && !this.model.operation.tax_rate_id){
- this.error = {tax_rate_id:["税率不可为空"]};return;
- }
- if (this.model.operation.isDiscount){
- let sign = false;
- this.model.operation.discount_count.forEach((item,i)=>{
- if (!item || (i!==0 && parseFloat(item)<=parseFloat(this.model.operation.discount_count[i-1]))){
- this.$set(this.errors,"discount_count_"+i,["非法满减值"]);
- sign = true;
- }
- });
- if (sign){
- this.$forceUpdate();
- return;
- }
- }
- if (!this.model.operation.isRejected && this.model.operation.strategy === '特征' && !this.model.operation.feature){
- this.$set(this.errors,"feature",["特征未填写"]);
- return;
- }
- if (this.model.operation.isSingle && !this.model.operation.total_price){
- this.$set(this.errors,"total_price",["按单价格不存在"]);
- return;
- }
- if (this.model.operation.isDiscount && this.model.operation.isSingle){
- if (!this.model.operation.total_discount_price[0]){
- this.$set(this.errors,"total_discount_price",["满减价格不存在"]);
- return;
- }
- this.model.operation.total_discount_price.forEach((item,i)=>{
- if (i!==0 && !item)this.model.operation.total_discount_price[i] = this.model.operation.total_discount_price[i-1];
- })
- }
- if (this.model.operation.surcharge && !this.model.operation.surcharge_unit_id){
- this.$set(this.errors,"surcharge_unit_id",["耗材附加费单位未选择"]);
- return;
- }
- if (this.model.operation.surcharge_unit_id && !this.model.operation.surcharge){
- this.$set(this.errors,"surcharge_unit_id",["耗材附加费未填写"]);
- return;
- }
- let unit = null;
- for (let i=0;i<this.model.operation.items.length;i++){
- if (this.model.operation.items[i].amount){
- if(!unit)unit = this.model.operation.items[i].unit_id;
- else if(unit !== this.model.operation.items[i].unit_id){
- this.$set(this.errors,'items.'+i+'.unit_id',["所有子项单位必须一致"]);
- return;
- }
- }
- }
- if (!this.model.operation.isSingle){
- for (let i=0;i<this.model.operation.items.length;i++){
- if (this._verifyOperationItem(i))return;
- }
- this.model.operation.total_discount_price = [];
- this.model.operation.total_price = "";
- }else this.$set(this.model.operation,"items",[]);
- if (!this.model.operation.isDiscount) {
- this.model.operation.discount_count = [""];
- this.model.operation.total_discount_price = [""];
- }
- if (this.model.operation.isRejected)this.model.operation.type_mark = 0;
- let url = "{{url('maintenance/priceModel/apiStoreOperation')}}";
- let params = this.model.operation;
- params.owner_id = this.ownerTemp.id;
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res && res.errors){
- if (res.errors.owner_id){
- window.tempTip.show(res.errors.owner_id[0]);
- return;
- }
- this.errors = res.errors;
- return;
- }
- res.features = this.model.operation.features;
- res.featureFormat = this.model.operation.featureFormat;
- for (let i=0;i<res.items.length;i++){
- res.items[i].features = this.model.operation.items[i]['features'];
- res.items[i].featureFormat = this.model.operation.items[i]['featureFormat'];
- res.items[i].type = this.model.operation.items[i]['type'];
- res.items[i].discount_price = res.items[i].discount_price ? res.items[i].discount_price.split(",") : [""];
- }
- if (res.discount_count)res.isDiscount = true;
- if (res.total_price)res.isSingle = true;
- res.discount_count = res.discount_count ? res.discount_count.split(",") : [""];
- res.total_discount_price = res.total_discount_price ? res.total_discount_price.split(",") : [""];
- res.isRejected = this.model.operation.type_mark==='0'||this.model.operation.type_mark===0;
- if (params.id) this.selectedModel.operation[params.index] = res;
- else this.selectedModel.operation.push(res);
- this._resetOperation();
- this.errors = {};
- this.audit.operation = true;
- return "保存成功";
- });
- },
- _verifyOperationItem(itemIndex){//验证作业费子项信息完整
- let obj = this.model.operation.items[itemIndex];
- let sign = false;
- if (!this.model.operation.isRejected && obj.strategy === '特征' && !obj.feature) {
- this.errors['items.' + itemIndex + '.feature'] = ["必须选择特征"];
- sign = true;
- }
- if (obj.strategy!=='起步' && !obj.amount){
- this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
- sign = true;
- }else if (!obj.amount) obj.amount = 0;
- if (obj.strategy!=='起步' && !obj.unit_id){
- this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
- sign = true;
- }else if (!obj.unit_id) obj.unit_id = 0;
- if (!obj.unit_price){
- this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
- sign = true;
- }
- if (this.model.operation.isDiscount){
- if (!obj.discount_price[0]){
- this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
- sign = true;
- }else{
- obj.discount_price.forEach((item,i)=>{
- if (i!==0&&!item) obj.discount_price[i]=obj.discount_price[i-1];
- })
- }
- }
- if (sign)this.$forceUpdate();
- return sign;
- },
- _verifyExpress(){
- let error = {};
- if (!this.model.express.name)error.name = ["名称不得为空"];
- if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
- if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
- if(this.owner.is_tax_exist && !this.model.express.tax_rate_id)error = {tax_rate_id:["税率不可为空,子项税率必填"]};
- if (this.model.express.items.length>0){
- this.model.express.items.forEach((item,index)=>{
- if (!item.province_id)error["items."+index+".province_id"] = ["不存在"];
- if (!this.model.express.isInterval){
- if (!item.initial_weight_price[0][0])error["items."+index+".initial_weight_price.0.0"] = ["不存在"];
- if (!item.additional_weight_price[0][0])error["items."+index+".additional_weight_price.0.0"] = ["不存在"];
- }else{
- this.model.express.amount_interval.forEach((amount,i)=>{
- if (this.model.express.weight_interval[i].length>0){
- this.model.express.weight_interval[i].forEach((weight,j)=>{
- if (!item.initial_weight_price[i][j])error["items."+index+".initial_weight_price."+i+"."+j] = ["费用不存在"];
- else item.initial_weight_price[i][j] = (Number)(item.initial_weight_price[i][j]);
- if (!item.additional_weight_price[i][j])error["items."+index+".additional_weight_price."+i+"."+j] = ["费用不存在"];
- else item.additional_weight_price[i][j] = (Number)(item.additional_weight_price[i][j]);
- })
- }
- });
- }
- });
- }
- if (this.model.express.isInterval){
- this.model.express.amount_interval.forEach((amount,i)=>{
- if (amount==="") error["amount_interval."+i] = ["区间值不得为空"];
- else if (i!==0 && Number(amount)<=Number(this.model.express.amount_interval[i-1]))error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
- if (this.model.express.weight_interval[i].length>0){
- this.model.express.weight_interval[i].forEach((weight,j)=>{
- this.model.express.weight_interval[i][j] = parseFloat(this.model.express.weight_interval[i][j]);
- if (weight==="") error["weight_interval."+i+"."+j] = ["区间值不得为空"];
- else if (j!==0 && Number(weight)<=Number(this.model.express.weight_interval[j-1]))error["weight_interval."+i+"."+j] = ["阶梯区间应大于上一区间值"];
- })
- }
- });
- }
- if (JSON.stringify(error) !== "{}"){
- this.errors = error;
- return;
- }
- if (!this.model.express.isInterval){
- this.model.express.amount_interval = null;
- this.model.express.weight_interval = null;
- if (this.model.express.items.length>0){
- this.model.express.items.forEach((item,i)=>{
- this.model.express.items[i].initial_weight_price = [[parseFloat(item.initial_weight_price[0][0])]];
- this.model.express.items[i].additional_weight_price = [[parseFloat(item.additional_weight_price[0][0])]];
- });
- }
- }
- let url = "{{url('maintenance/priceModel/apiStoreExpress')}}";
- let params = this.model.express;
- params.owner_id = this.ownerTemp.id;
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res && res.errors){
- this.errors = res.errors;
- if (res.errors.owner_id)window.tempTip.show(res.errors.owner_id[0]);
- return;
- }
- if (!this.model.express.amount_interval) this.model.express.amount_interval = [""];
- if (!this.model.express.weight_interval) this.model.express.weight_interval = [[]];
- this.model.express.items.forEach((item,i)=>{
- item.id = res.details[i].id;
- });
- if (this.model.express.id){
- if (res.operation) this.model.express.id = res.id;
- this.selectedModel.express[this.model.express.index] = this.model.express;
- }else{
- this.model.express.id = res.id;
- this.selectedModel.express.unshift(this.model.express);
- }
- this.model.express = {
- name:"",
- initial_weight:"",
- additional_weight:"",
- amount_interval:[""],
- weight_interval:[[]],
- items:[],
- logistics:[],
- };
- this.errors = {};
- this.importError = [];
- $(".selectpicker").filter('.express').selectpicker('val',[]);
- this.audit.express = true;
- return "保存成功";
- });
- },
- _verifyLogistic(){
- let error = {};
- if (!this.model.logistic.name) error.name = ["名称不得为空"];
- if (!this.model.logistic.unit_id) error.unit_id = ["单位一不得为空"];
- if (!this.model.logistic.unit_range) error.unit_range = ["区间值不得为空"];
- if (!this.model.logistic.other_unit_id) error.other_unit_id = ["单位二不得为空"];
- if (!this.model.logistic.other_unit_range) error.other_unit_range = ["区间值不得为空"];
- if(this.owner.is_tax_exist && !this.model.logistic.tax_rate_id)error = {tax_rate_id:["税率不可为空"]};
- if (JSON.stringify(error) !== "{}"){
- this.errors = error;
- return;
- }
- let url = "{{url('maintenance/priceModel/apiStoreLogistic')}}";
- let params = this.model.logistic;
- params.owner_id = this.ownerTemp.id;
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res && res.errors){
- this.errors = res.errors;
- window.tempTip.show("检查您的子项详情列表是否完整");
- return;
- }
- this.model.logistic.items.forEach((item,i)=>{
- item.id = res.details[i].id;
- });
- if (this.model.logistic.id){
- if (res.operation) this.model.logistic.id = res.id;
- this.selectedModel.logistic[this.model.logistic.index] = this.model.logistic;
- }else {
- this.model.logistic.id = res.id;
- this.selectedModel.logistic.unshift(this.model.logistic);
- }
- this.model.logistic = {
- items:[],
- other_ranges:[],
- ranges:[],
- logistics:[],
- };
- this.errors = {};
- this.importError = [];
- $(".selectpicker").filter('.logistic').selectpicker('val',[]);
- this.audit.logistic = true;
- return "保存成功";
- });
- },
- _verifyDirectLogistic(){
- let error = {};
- if (!this.model.directLogistic.name) error.name = ["名称不得为空"];
- if (!this.model.directLogistic.base_km) error.base_km = ["起步公里数不得为空"];
- if(this.owner.is_tax_exist && !this.model.directLogistic.tax_rate_id)error = {tax_rate_id:["税率不可为空"]};
- if (JSON.stringify(error) !== "{}"){
- this.errors = error;
- return;
- }
- let url = "{{url('maintenance/priceModel/apiStoreDirectLogistic')}}";
- let params = this.model.directLogistic;
- params.owner_id = this.ownerTemp.id;
- window.tempTip.postBasicRequest(url,params,res=>{
- if (res && res.errors){
- this.errors = res.errors;
- return;
- }
- this.model.directLogistic.items.forEach((item,i)=>{
- item.id = res.details[i].id;
- });
- this.model.directLogistic.id = res.id;
- this.selectedModel.directLogistic = this.model.directLogistic;
- this.model.directLogistic = {
- items:[],
- };
- this.errors = {};
- this.importError = [];
- this.audit.directLogistic = true;
- return "保存成功";
- });
- },
- //增加作业费特征子项
- addOperationItem(strategy){
- if (strategy!=='特征' && !this.model.operation.items.every(item=>{
- if (item.strategy===strategy)return false;
- return true;
- }))return;
- this.model.operation.items.push({
- strategy:strategy,
- discount_price:new Array(this.model.operation.discount_count.length).fill(""),
- });
- },
- //删除作业费子项
- delOperationItem(index){
- this.$delete(this.model.operation.items,index);
- },
- //显示特征选择modal
- showAddFeatureModal(index){
- let types = {!! json_encode(\App\Feature::TYPE,JSON_UNESCAPED_UNICODE) !!};
- let typeIn = {!! json_encode(array_keys(\App\Feature::MAPPING['store'])) !!};
- let typeOut = {!! json_encode(array_keys(\App\Feature::MAPPING['order'])) !!};
- let node = {!! json_encode(\App\Feature::TYPE_NODE) !!};
- let temp = [];
- if (this.model.operation.operation_type==='入库'){
- if (index === -1)typeIn.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
- else typeIn.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
- }else{
- if (index === -1)typeOut.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
- else typeOut.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
- }
- this.pool.feature_type = temp;
- if (index === -1){
- if (!this.model.operation.feature){
- this.model.operation.features = this._createFeature();
- this.thisOperationItemIndex = index;
- this.$forceUpdate();
- $("#addFeatureModal").modal("show");
- return;
- }
- if (this.model.operation.features) {
- this.thisOperationItemIndex = index;
- $("#addFeatureModal").modal("show");
- return;
- }
- }else{
- if (!this.model.operation.items[index].feature){
- this.model.operation.items[index].features = this._createFeature();
- this.thisOperationItemIndex = index;
- this.$forceUpdate();
- $("#addFeatureModal").modal("show");
- return;
- }
- if (this.model.operation.items[index].features) {
- this.thisOperationItemIndex = index;
- $("#addFeatureModal").modal("show");
- return;
- }
- }
- let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
- let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
- window.tempTip.postBasicRequest(url,{feature:feature},res=>{
- if (!res || res.length === 0){
- res = this._createFeature();
- }
- if (index === -1) this.model.operation.features = res;
- else this.model.operation.items[index].features = res;
- this.thisOperationItemIndex = index;
- this.$forceUpdate();
- $("#addFeatureModal").modal("show");
- });
- },
- //增加特征
- addFeature(){
- let obj = {
- "strategyGroupStartSign": false,
- "calculation" : "",
- "type" : "",
- "id" : "",
- "logic" : "",
- "describe" : "",
- "strategyGroupEndSign" : false,
- };
- if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
- else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
- this.$forceUpdate();
- },
- _createFeature(){
- return [{
- "strategyGroupStartSign": false,
- "calculation" : "",
- "type" : "",
- "id" : "",
- "logic" : "",
- "describe" : "",
- "strategyGroupEndSign" : false,
- }];
- },
- //删除特征
- delFeature(index) {
- if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
- else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
- this.$forceUpdate();
- },
- //提交特征更新现有
- submitFeature(){
- let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
- let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
- window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
- if (this.thisOperationItemIndex === -1){
- this.model.operation.feature = res.feature;
- this.model.operation.featureFormat = res.featureFormat;
- } else {
- this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
- this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
- this.$forceUpdate();
- }
- $("#addFeatureModal").modal("hide");
- return "已更新特征";
- },true);
- },
- //移入移出时更改长文本显示效果
- textClass(event,isOver){
- event = event.target.children[0];
- if (isOver) event.className = "text-overflow-warp-100";
- else event.className = "cursor-pointer text-overflow-replace-100";
- },
- //展开子策略
- showOperationItem(index){
- let trId = "operation-tr-"+index;
- let itemId = "operation-item-"+index;
- if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
- this.operationItems['_'+index] = false;
- $("#"+itemId).slideUp(undefined,function () {
- $("#"+trId).addClass("d-none");
- });
- }else {
- $("#"+trId).removeClass("d-none");
- this.operationItems['_'+index] = true;
- $("#"+itemId).slideDown();
- }
- this.$forceUpdate();
- },
- //新增快递子项
- addExpressItem(){
- let arr = [];
- this.model.express.amount_interval.forEach((amount,i)=>{
- if (this.model.express.weight_interval[i].length>0){
- let it = [];
- this.model.express.weight_interval[i].forEach(weight=>{
- it.push("");
- });
- arr.push(it);
- }else arr.push([""]);
- });
- let re=[];
- for(let i=0;i<arr.length;i++){
- re.push(arr[i].slice(0));
- }
- this.model.express.items.unshift({
- province_id : "",
- initial_weight_price:arr,
- additional_weight_price:re,
- });
- },
- //删除快递子项
- delExpressItem(index){
- window.tempTip.confirm("确定要删除该子项吗?",res=>{
- this.$delete(this.model.express.items,index);
- })
- },
- //选择文件
- selectFile(id){
- this.importError = [];
- $("#"+id).click();
- },
- _getExpressImportData(index,data){
- let arr = [];
- this.model.express.amount_interval.forEach((amount,i)=>{
- if (this.model.express.weight_interval[i].length>0){
- let it = [];
- this.model.express.weight_interval[i].forEach(weight=>{
- it.push(data[index] ? data[index] : "");
- index++;
- });
- arr.push(it);
- }else {
- arr.push([data[index] ? data[index] : ""]);
- index++;
- }
- });
- return [arr,index];
- },
- //导入快递子项
- importExpress(e){
- let file=e.target.files[0];
- window.tempTip.setDuration(3000);
- if (!file){
- window.tempTip.show("未选择文件");
- return;
- }
- let formData = new FormData();
- formData.append("file",file);
- window.axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
- 'Content-Type':'multipart/form-data'
- }).then(res=>{
- if (res.data.success) {
- res.data.data.data.forEach(data=>{
- if(this.model.express.items.every(item=>{
- if (data.province_id === item.province_id)return false;
- return true;
- })){
- if (this.model.express.isInterval){
- let result = this._getExpressImportData(1,data);
- this.model.express.items.push({
- province_id : data[0],
- initial_weight_price:result[0],
- additional_weight_price:this._getExpressImportData(result[1],data)[0],
- });
- }else this.model.express.items.push({
- province_id : data[0],
- initial_weight_price:[[data[1]]],
- additional_weight_price:[[data[2]]],
- });
- }
- });
- this.importError = res.data.data.errors;
- window.tempTip.setDuration(2000);
- window.tempTip.showSuccess("导入成功!");
- return;
- }
- window.tempTip.show(res.data.data);
- }).catch(err=> {
- window.tempTip.show("网络错误:"+err);
- })
- },
- //物流详情列表modal
- showDetailModal() {
- $("#logisticModal").modal("show");
- },
- //新增物流详情
- addLogisticDetail(){
- this.model.logistic.items.unshift({});
- },
- //导入物流详情
- importLogistic(e){
- window.tempTip.setIndex(1099);
- let file=e.target.files[0];
- if (!file){
- window.tempTip.setDuration(3000);
- window.tempTip.show("未选择文件");
- return;
- }
- let formData = new FormData();
- formData.append("file",file);
- window.axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
- 'Content-Type':'multipart/form-data'
- }).then(res=>{
- if (res.data.success) {
- res.data.data.forEach(data=>{
- //过滤非已选择单位的数据
- let id = "";
- if (data.unit_id === this.poolMapping.units[this.model.logistic.unit_id]) id = this.model.logistic.unit_id;
- if (data.unit_id === this.poolMapping.units[this.model.logistic.other_unit_id]) id = this.model.logistic.other_unit_id;
- if (id){
- //过滤重复数据
- let unique = this.model.logistic.items.every(item=>{
- if (id === item.unit_id && data.range === item.range
- && data.province_id === item.province_id && data.city_id === item.city_id)return false;
- return true;
- });
- if (unique){
- data.unit_id = id;
- this.model.logistic.items.push(data);
- }
- }
- });
- this.importError = res.data.errors;
- window.tempTip.setDuration(3000);
- window.tempTip.showSuccess("导入成功!");
- return;
- }
- window.tempTip.setDuration(3000);
- window.tempTip.show(res.data.data);
- }).catch(err=> {
- window.tempTip.setDuration(3000);
- window.tempTip.show("网络错误:"+err);
- })
- },
- //删除物流子项
- delLogisticItem(index){
- this.$delete(this.model.logistic.items,index);
- },
- //改变物流区间时改变可选择项
- changeRange(type){
- if (type === 'ranges'){
- this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
- }else{
- this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
- }
- },
- //增加直发车子项
- addDirectLogisticItem(){
- this.model.directLogistic.items.unshift({
- car_type_id : "",
- base_fee:"",
- additional_fee:"",
- });
- },
- //导入直发车子项
- importDirectLogistic(e){
- window.tempTip.setIndex(1099);
- let file=e.target.files[0];
- if (!file){
- window.tempTip.setDuration(3000);
- window.tempTip.show("未选择文件");
- return;
- }
- let formData = new FormData();
- formData.append("file",file);
- window.axios.post('{{url('maintenance/priceModel/directLogistic/import')}}',formData,{
- 'Content-Type':'multipart/form-data'
- }).then(res=>{
- if (res.data.success) {
- if (this.model.directLogistic.items.length > 0){
- res.data.data.forEach(data=>{
- let unique = this.model.directLogistic.items.every(item=>{
- if (item.car_type_id === data.car_type_id)return false;
- return true;
- });
- if (unique) this.model.directLogistic.items.unshift(data);
- });
- }else this.model.directLogistic.items = res.data.data;
- this.importError = res.data.errors;
- window.tempTip.setDuration(3000);
- window.tempTip.showSuccess("导入成功!");
- return;
- }
- window.tempTip.setDuration(3000);
- window.tempTip.show(res.data.data);
- }).catch(err=> {
- window.tempTip.setDuration(3000);
- window.tempTip.show("网络错误:"+err);
- })
- },
- //删除直发车子项
- delDirectLogisticItem(index){
- this.$delete(this.model.directLogistic.items,index);
- },
- //改变客户
- selectOwner(){
- let id = this.owner.customer_id;
- this.customers.some(customer=>{
- if (id === customer.id){
- this.owner.customer_name = customer.name;
- return true;
- }
- });
- },
- //改变小组
- selectGroup(){
- let id = this.owner.owner_group_id;
- this.ownerGroups.some(group=>{
- if (id === group.id){
- this.owner.owner_group_name = group.name;
- return true;
- }
- });
- },
- //获取引入计费模型查询列表搜索
- searchPriceModel(){
- this.isSearch = true;
- switch (this.type) {
- case "storage":
- this._getStoragePriceModel();
- break;
- case "operation":
- this._getOperationPriceModel();
- break;
- case "express":
- this._getExpressPriceModel();
- break;
- case "logistic":
- this._getLogisticPriceModel();
- break;
- case "system":
- this._getSystemPriceModel();
- break;
- default:
- this._getDirectLogisticPriceModel();
- }
- },
- _getStoragePriceModel(){
- let url = "{{url('maintenance/priceModel/apiGetStorage')}}";
- window.tempTip.postBasicRequest(url,this.introduce,res=>{
- let result = [];
- let mapping = {};
- res.forEach(model=> {
- let text = model.name+" ("+model.counting_type+"-"+model.using_type+")";
- result.push({id:model.id,text:text});
- mapping[model.id] = {
- name : model.name,
- counting_type : model.counting_type,
- using_type : model.using_type,
- minimum_area : model.minimum_area,
- price : model.price,
- discount_type : model.discount_type,
- discount_value : model.discount_value,
- amount_interval : model.amount_interval ? model.amount_interval : [""],
- isInterval:!!model.amount_interval,
- unit_id : model.unit_id,
- };
- });
- this.searchResult = result;
- this.searchResultMapping = mapping;
- this.isSearch = false;
- });
- },
- _getOperationPriceModel(){
- let url = "{{url('maintenance/priceModel/apiGetOperation')}}";
- window.tempTip.postBasicRequest(url,this.introduce,res=>{
- let result = [];
- let mapping = {};
- res.forEach(model=> {
- let text = model.name+" ("+model.operation_type+"-"+model.strategy+")";
- result.push({id:model.id,text:text});
- mapping[model.id] = {
- name : model.name,
- operation_type : model.operation_type,
- strategy : model.strategy,
- feature : model.feature,
- featureFormat : model.featureFormat,
- remark : model.remark,
- type_mark : model.type_mark,
- isRejected : model.type_mark==='0'||model.type_mark===0,
- items:model.items,
- };
- });
- this.searchResult = result;
- this.searchResultMapping = mapping;
- this.isSearch = false;
- });
- },
- _getExpressPriceModel(){
- let url = "{{url('maintenance/priceModel/apiGetExpress')}}";
- window.tempTip.postBasicRequest(url,this.introduce,res=>{
- let result = [];
- let mapping = {};
- res.forEach(model=> {
- let text = model.name+" (首重:"+model.initial_weight+"KG 续重:"+model.additional_weight+"KG)";
- result.push({id:model.id,text:text});
- let logistics = [];
- model.logistics.forEach(logistic=>{
- logistics.push(logistic.id);
- });
- let items = [];
- model.details.forEach(item=>{
- items.push({
- province_id:item.province_id,
- initial_weight_price:item.initial_weight_price,
- additional_weight_price:item.additional_weight_price,
- });
- });
- mapping[model.id] = {
- logistics : logistics,
- name:model.name,
- initial_weight:model.initial_weight,
- additional_weight:model.additional_weight,
- amount_interval:model.amount_interval ? model.amount_interval : [""],
- weight_interval:model.weight_interval ? model.weight_interval : [[]],
- isInterval:!!model.amount_interval,
- items:items,
- };
- });
- this.searchResult = result;
- this.searchResultMapping = mapping;
- this.isSearch = false;
- });
- },
- _getSystemPriceModel(){
- this.searchResult = [];
- this.searchResultMapping = [];
- this.isSearch = false;
- },
- _getLogisticPriceModel(){
- let url = "{{url('maintenance/priceModel/apiGetLogistic')}}";
- window.tempTip.postBasicRequest(url,this.introduce,res=>{
- let result = [];
- let mapping = {};
- res.forEach(model=> {
- let text = model.name+" (单位一:"+this.poolMapping.units[model.unit_id]+"["+model.unit_range+
- "] 单位二:"+this.poolMapping.units[model.other_unit_id]+"["+model.other_unit_range+"])";
- result.push({id:model.id,text:text});
- let logistics = [];
- model.logistics.forEach(logistic=>{
- logistics.push(logistic.id);
- });
- let items = [];
- model.details.forEach(item=>{
- items.push({
- unit_id:item.unit_id,
- range:item.range,
- province_id:item.province_id,
- city_id:item.city_id,
- unit_price:item.unit_price,
- delivery_fee:item.delivery_fee,
- initial_fee:item.initial_fee,
- initial_amount:item.initial_amount,
- rate:item.rate,
- });
- });
- mapping[model.id] = {
- logistics : logistics,
- name:model.name,
- unit_range:model.unit_range,
- unit_id:model.unit_id,
- other_unit_range:model.other_unit_range,
- other_unit_id:model.other_unit_id,
- pick_up_price:model.pick_up_price,
- fuel_price:model.fuel_price,
- service_price:model.service_price,
- items:items,
- };
- });
- this.searchResult = result;
- this.searchResultMapping = mapping;
- this.isSearch = false;
- });
- },
- _getDirectLogisticPriceModel(){
- let url = "{{url('maintenance/priceModel/apiGetDirectLogistic')}}";
- window.tempTip.postBasicRequest(url,this.introduce,res=>{
- let result = [];
- let mapping = {};
- res.forEach(model=> {
- let text = model.name+" (起步数:"+model.base_km+"KM)";
- result.push({id:model.id,text:text});
- let items = [];
- model.details.forEach(item=>{
- items.push({
- car_type_id:item.car_type_id,
- base_fee:item.base_fee,
- additional_fee:item.additional_fee,
- });
- });
- mapping[model.id] = {
- name:model.name,
- base_km:model.base_km,
- items:items,
- };
- });
- this.searchResult = result;
- this.searchResultMapping = mapping;
- this.isSearch = false;
- });
- },
- //提交引入
- submitIntroduce(){
- if (!this.selectedResult || !this.searchResultMapping[this.selectedResult]){
- window.tempTip.setDuration(3000);
- window.tempTip.show("尚未选择引入项,请单击选择列表,如列表为空则无结果");
- return;
- }
- let model = this.searchResultMapping[this.selectedResult];
- switch (this.type) {
- case "storage":
- this.model.storage = model;
- break;
- case "operation":
- this.model.operation = model;
- break;
- case "express":
- this.model.express = model;
- break;
- case "logistic":
- this.model.logistic = model;
- break;
- default:
- this.model.directLogistic = model;
- break;
- }
- $("#introduce").modal('hide');
- window.tempTip.setDuration(2000);
- window.tempTip.showSuccess("引入成功");
- },
- //删除仓储
- delStorage(item,index){
- window.tempTip.confirm("您确定要删除仓储计费“"+item.name+"”吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelStorage')}}",{id:item.id},res=>{
- this.$delete(this.selectedModel.storage,index);
- this.audit.storage = true;
- return "删除“"+item.name+"”成功";
- });
- });
- },
- //删除作业
- delOperation(item,index){
- window.tempTip.confirm("您确定要删除作业计费“"+item.name+"”吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperation')}}",{id:item.id},res=>{
- this.$delete(this.selectedModel.operation,index);
- this.audit.operation = true;
- return "删除“"+item.name+"”成功";
- });
- });
- },
- //删除作业子项
- deleteOperationItem(item,index,parentIndex){
- window.tempTip.confirm("您确定要删除该作业子项吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperationItem')}}",{id:item.id},res=>{
- if (res) this.$set(this.selectedModel.operation,parentIndex,this._overrideOperation(res));
- else this.$delete(this.selectedModel.operation[parentIndex].items,index);
- this.audit.operation = true;
- return "删除成功";
- });
- });
- },
- //删除快递
- delExpress(item,index){
- window.tempTip.confirm("您确定要删除该快递计费“"+item.name+"”吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpress')}}",{id:item.id},res=>{
- this.$delete(this.selectedModel.express,index);
- this.audit.express = true;
- return "删除“"+item.name+"”成功";
- });
- });
- },
- //删除快递子项
- deleteExpressItem(item,index,parentIndex){
- window.tempTip.confirm("您确定要删除该快递计费子项吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpressItem')}}",{id:item.id},res=>{
- if (res) this.$set(this.selectedModel.express,parentIndex,this._overrideExpress(res));
- else this.$delete(this.selectedModel.express[parentIndex].items,index);
- this.audit.express = true;
- return "删除成功";
- });
- });
- },
- //删除物流
- delLogistic(item,index){
- window.tempTip.confirm("您确定要删除该物流计费“"+item.name+"”吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogistic')}}",{id:item.id},res=>{
- this.$delete(this.selectedModel.logistic,index);
- this.audit.logistic = true;
- return "删除“"+item.name+"”成功";
- });
- });
- },
- //删除物流子项
- deleteLogisticItem(item,index,parentIndex){
- window.tempTip.confirm("您确定要删除该物流计费子项吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogisticItem')}}",{id:item.id},res=>{
- if (res) this.$set(this.selectedModel.logistic,parentIndex,this._overrideLogistic(res));
- else this.$delete(this.selectedModel.logistic[parentIndex].items,index);
- this.audit.logistic = true;
- return "删除成功";
- });
- });
- },
- //删除直发车
- delDirectLogistic(item){
- window.tempTip.confirm("您确定要删除该直发车计费“"+item.name+"”吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogistic')}}",{id:item.id},res=>{
- this.selectedModel.directLogistic = {};
- this.audit.directLogistic = true;
- return "删除“"+item.name+"”成功";
- });
- });
- },
- //删除直发车子项
- deleteDirectLogisticItem(item,index){
- window.tempTip.confirm("您确定要删除该直发车计费子项吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogisticItem')}}",{id:item.id},res=>{
- if (res) this.$set(this.selectedModel,"directLogistic",this._overrideDirectLogistic(res));
- else this.$delete(this.selectedModel.directLogistic.items,index);
- this.audit.directLogistic = true;
- return "删除成功";
- });
- });
- },
- //删除系统
- deleteSystem(item){
- window.tempTip.confirm("您确定要删除该系统计费吗?",()=>{
- window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelSystem')}}",{id:item.id},res=>{
- this.$set(this.selectedModel,"system",{usage_fee:""});
- this.audit.system = true;
- return "删除成功";
- });
- });
- },
- //编辑仓储
- editStorage(index){
- this.switchType("storage");
- this.model.storage = JSON.parse(JSON.stringify(this.selectedModel.storage[index]));
- this.model.storage.index = index;
- if (this.model.storage.amount_interval)this.model.storage.isInterval = true;
- },
- //编辑作业
- editOperation(index){
- this.switchType("operation");
- this.model.operation = JSON.parse(JSON.stringify(this.selectedModel.operation[index]));
- this.model.operation.index = index;
- },
- //编辑快递
- editExpress(index){
- this.switchType("express");
- this.model.express = JSON.parse(JSON.stringify(this.selectedModel.express[index]));
- this.model.express.index = index;
- },
- //编辑物流
- editLogistic(index){
- this.switchType("logistic");
- this.model.logistic = JSON.parse(JSON.stringify(this.selectedModel.logistic[index]));
- this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
- this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
- this.model.logistic.index = index;
- },
- //编辑直发车
- editDirectLogistic(){
- this.switchType("directLogistic");
- this.model.directLogistic = JSON.parse(JSON.stringify(this.selectedModel.directLogistic));
- },
- //编辑系统
- editSystem(){
- this.switchType("system");
- this.model.system = JSON.parse(JSON.stringify(this.selectedModel.system));
- },
- //搜索快递子项
- searchExpress(e){
- let val = e.target.value;
- if (!val){
- this.$set(this.searchItem,'express',null);
- return;
- }
- let items = [];
- this.model.express.items.forEach((item,i)=>{
- if (this.poolMapping.provinces[item.province_id].indexOf(val) !== -1)items.push(i);
- });
- this.$set(this.searchItem,'express',items);
- },
- //搜索直发子项
- searchDirectLogistic(e){
- let val = e.target.value;
- if (!val){
- this.$set(this.searchItem,'directLogistic',null);
- return;
- }
- let items = [];
- this.model.directLogistic.items.forEach((item,i)=>{
- if (this.poolMapping.cars[item.car_type_id].indexOf(val) !== -1)items.push(i);
- });
- this.$set(this.searchItem,'directLogistic',items);
- },
- //搜索物流子项
- searchLogistic(e){
- let val = e.target.value;
- if (!val){
- this.$set(this.searchItem,'logistic',null);
- return;
- }
- let items = [];
- this.model.logistic.items.forEach((item,i)=>{
- if (item.unit_id || item.province_id || item.city_id){
- if ((item.unit_id && this.poolMapping.units[item.unit_id].indexOf(val) !== -1) ||
- (item.province_id && this.poolMapping.provinces[item.province_id].indexOf(val) !== -1) ||
- (item.city_id && this.poolMapping.cities[item.city_id].indexOf(val) !== -1))items.push(i);
- }
- });
- this.$set(this.searchItem,'logistic',items);
- },
- //增加阶梯满减阈值
- addDiscount(arr){
- this.model.operation.items.forEach(item=>{
- item.discount_price.push('');
- });
- this.model.operation.total_discount_price.push("");
- arr.push('');
- },
- //开启满减
- onDiscount(type){
- if (!type)return;
- if (this.model.operation.discount_count.length===1) this.model.operation.discount_count = ["0"];
- if (this.model.operation.discount_count.length===0) this.model.operation.discount_count = ["0"];
- },
- //删除阶梯满减阈值
- delDiscount(index){
- this.model.operation.items.forEach((item,i)=>{
- delete item.discount_price[index];
- this.$set(this.model.operation.items,i,item);
- });
- this.$delete(this.model.operation.total_discount_price,index);
- this.$delete(this.model.operation.discount_count,index);
- },
- //审核或恢复
- auditOrRecoverModel(type,isAudit = true){
- this.getPriceModelAudit(type,isAudit);
- this.selectedAudit = type;
- this.isAudit = isAudit;
- setTimeout(function () {
- $("#auditOrRecover").modal("show");
- },100);
- },
- exeAuditOrRecoverModel(){
- let url = "{{url('maintenance/priceModel/auditOrRecoverModel')}}";
- let type = this.selectedAudit;
- let isAudit = this.isAudit;
- let param = {owner_id:this.ownerTemp.id,type:type,isAudit:isAudit};
- window.tempTip.postBasicRequest(url,param,res=>{
- switch (type){
- case "storage":
- this.selectedModel.storage = res;
- break;
- case "operation":
- this._loadOperation();
- res.forEach((operation,i)=>{res[i] = this._overrideOperation(operation);});
- this.selectedModel.operation = res;
- break;
- case "express":
- this._loadExpress();
- res.forEach((express,i)=>{
- res[i] = this._overrideExpress(express);
- this.upList['express-item-'+i] = true;
- });
- this.selectedModel.express = res;
- break;
- case "logistic":
- this._loadLogistic();
- res.forEach((logistic,i)=>{
- res[i] = this._overrideLogistic(logistic);
- this.upList['logistic-item-'+i] = true;
- });
- this.selectedModel.logistic = res;
- break;
- case "directLogistic":
- this._loadDirectLogistic();
- this.upList["directLogistic-item"] = true;
- this.selectedModel.directLogistic = this._overrideDirectLogistic(res[0]);
- break;
- case "system":
- this.selectedModel.system = res;
- break;
- }
- this.$set(this.audit,type,false);
- $("#auditOrRecover").modal("hide");
- return (isAudit ? '审核' : '恢复')+"成功!";
- },true)
- },
- //增加数量区间
- addStoreAmount(){
- this.model.storage.amount_interval.push("");
- this.model.storage.price.push("");
- },
- //删除数量区间
- delStoreAmount(index){
- if (this.model.storage.amount_interval.length<2)return;
- this.$delete(this.model.storage.amount_interval,index);
- this.$delete(this.model.storage.price,index);
- },
- //增加快递数量区间
- addExpressAmount(){
- this.model.express.amount_interval.push("");
- this.model.express.weight_interval.push([]);
- if (this.model.express.items.length>0){
- this.model.express.items.forEach((item,i)=>{
- if (this.model.express.items[i]["initial_weight_price"])this.model.express.items[i]["initial_weight_price"].push([""]);
- else this.$set(this.model.express.items[i],"initial_weight_price",[[""]]);
- if (this.model.express.items[i]["additional_weight_price"])this.model.express.items[i]["additional_weight_price"].push([""]);
- else this.$set(this.model.express.items[i],"additional_weight_price",[[""]]);
- })
- }
- },
- //增加快递重量区间
- addExpressWeight(index){
- this.model.express.weight_interval[index].push("");
- if (!this.model.express.maxDom || this.model.express.weight_interval[index].length > this.model.express.maxDom)
- this.$set(this.model.express,'maxDom',this.model.express.weight_interval[index].length);
- },
- //删除快递数量区间
- delExpressAmount(){
- let len = this.model.express.amount_interval.length;
- if (len>1){
- this.$delete(this.model.express.amount_interval,len-1);
- this.$delete(this.model.express.weight_interval,len-1);
- if (this.model.express.items.length>0){
- this.model.express.items.forEach((item,i)=>{
- this.$delete(this.model.express.items[i]["initial_weight_price"],len-1);
- this.$delete(this.model.express.items[i]["additional_weight_price"],len-1);
- })
- }
- }
- },
- //删除快递重量区间
- delExpressWeight(index){
- let len = this.model.express.weight_interval[index].length;
- this.$delete(this.model.express.weight_interval[index],len-1);
- if (this.model.express.items.length>0){
- this.model.express.items.forEach((item,i)=>{
- this.$delete(this.model.express.items[i]["initial_weight_price"][index],len-1);
- this.$delete(this.model.express.items[i]["additional_weight_price"][index],len-1);
- })
- }
- },
- filterCustomer(e){
- let value = e.target.value;
- if (!value)this.owner.customer_id = "";
- this.customers.some(customer=>{
- if (customer.name.indexOf(value)!==-1){
- this.owner.customer_id = customer.id;
- return true;
- }
- });
- },
- filterOwnerGroup(e){
- let value = e.target.value;
- if (!value)this.owner.owner_group_id = "";
- this.ownerGroups.some(ownerGroup=>{
- if (ownerGroup.name.indexOf(value)!==-1){
- this.owner.owner_group_id = ownerGroup.id;
- return true;
- }
- });
- },
- filterkc(e){
- let value = e.target.value;
- if (!value)this.owner.kc = "";
- this.userGroups.some(userGroup=>{
- if (userGroup.name.indexOf(value)!==-1){
- this.owner.kc = userGroup.id;
- return true;
- }
- });
- },
- filterjg(e){
- let value = e.target.value;
- if (!value)this.owner.jg = "";
- this.userGroups.some(userGroup=>{
- if (userGroup.name.indexOf(value)!==-1){
- this.owner.jg = userGroup.id;
- return true;
- }
- });
- },
- filterth(e){
- let value = e.target.value;
- if (!value)this.owner.th = "";
- this.userGroups.some(userGroup=>{
- if (userGroup.name.indexOf(value)!==-1){
- this.owner.th = userGroup.id;
- return true;
- }
- });
- },
- filtersh(e){
- let value = e.target.value;
- if (!value)this.owner.sh = "";
- this.userGroups.some(userGroup=>{
- if (userGroup.name.indexOf(value)!==-1){
- this.owner.sh = userGroup.id;
- return true;
- }
- });
- },
- filterfh(e){
- let value = e.target.value;
- if (!value)this.owner.fh = "";
- this.userGroups.some(userGroup=>{
- if (userGroup.name.indexOf(value)!==-1){
- this.owner.fh = userGroup.id;
- return true;
- }
- });
- },
- getPriceModelAudit(type,isAudit){
- this.showAuditPiece = {
- "C":false,"D":false,"U":false
- };
- this.auditList[type] = {};
- let url="{{url('maintenance/priceModel/getPriceModelAudit')}}";
- this.comparisonTemp = {};
- switch (type) {
- case "storage":
- window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
- if (!res)return;
- if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonStorage(res[i],isAudit);
- else for(let i=res.length-1;i>=0;i--)this._AuditComparisonStorage(res[i],isAudit);
- });
- break;
- case "operation":
- window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
- if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonOperation(res[i],isAudit);
- else for(let i=res.length-1;i>=0;i--)this._AuditComparisonOperation(res[i],isAudit);
- });
- break;
- case "express":
- window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
- if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonExpress(res[i],isAudit);
- else for(let i=res.length-1;i>=0;i--)this._AuditComparisonExpress(res[i],isAudit);
- });
- break;
- case "logistic":
- window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
- if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonLogistic(res[i],isAudit);
- else for(let i=res.length-1;i>=0;i--)this._AuditComparisonLogistic(res[i],isAudit);
- });
- break;
- case "directLogistic":
- window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
- if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonDirectLogistic(res[i],isAudit);
- else for(let i=res.length-1;i>=0;i--)this._AuditComparisonDirectLogistic(res[i],isAudit);
- });
- break;
- case "system":
- window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
- if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonSystem(res[i],isAudit);
- else for(let i=res.length-1;i>=0;i--)this._AuditComparisonSystem(res[i],isAudit);
- });
- break;
- }
- },
- _pushAuditList(model,type,data){
- if (this.auditList[model][type]){
- this.auditList[model][type].push(data);
- }else{
- this.showAuditPiece[type] = true;
- this.auditList[model][type] = [data];
- }
- },
- _reverseAuditComparison(operation){
- switch (operation) {
- case "C":
- return "D";
- case "D":
- return "C";
- case "U":
- return "";
- default:
- return "U";
- }
- },
- _AuditComparisonStorage(data,isAudit){
- if (!isAudit){
- if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
- data.operation = this._reverseAuditComparison(data.operation);
- }
- data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
- data.time_unit_id = this.poolMapping.units ? this.poolMapping.units[data.time_unit_id] : '';
- data.unit_id = this.poolMapping.units ? this.poolMapping.units[data.unit_id] : '';
- switch (data.operation) {
- case "C":
- this._pushAuditList("storage","C",data);
- break;
- case "D":
- this._pushAuditList("storage","D",data);
- break;
- case "U":
- let result = this._formatComparisonData("storage",data);
- if (result===null) this._pushAuditList("storage","C",data);
- else this._pushAuditList("storage","U",result);
- break;
- default:
- if (!this.auditList.storage.H)this.auditList.storage.H = {};
- this.auditList.storage.H[data.id] = data;
- break;
- }
- },
- _AuditComparisonOperation(data,isAudit){
- if (!isAudit){
- if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
- data.operation = this._reverseAuditComparison(data.operation);
- }
- data.discount_count = data.discount_count ? data.discount_count.split(",") : [];
- data.total_discount_price = data.total_discount_price ? data.total_discount_price.split(",") : [];
- data.surcharge_unit_id = this.poolMapping.units ? this.poolMapping.units[data.surcharge_unit_id] : '';
- data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
- data.items.forEach((item,j)=>{
- data.items[j].discount_price = data.items[j].discount_price ? data.items[j].discount_price.split(",") : [];
- data.items[j].unit_id = this.poolMapping.units ? this.poolMapping.units[data.items[j].unit_id] : '';
- });
- switch (data.operation) {
- case "C":
- this._pushAuditList("operation","C",data);
- break;
- case "D":
- this._pushAuditList("operation","D",data);
- break;
- case "U":
- let result = this._formatComparisonData("operation",data);
- if (result===null) this._pushAuditList("operation","C",data);
- else this._pushAuditList("operation","U",result);
- break;
- default:
- if (!this.auditList.operation.H)this.auditList.operation.H = {};
- this.auditList.operation.H[data.id] = data;
- break;
- }
- },
- _AuditComparisonExpress(data,isAudit){
- if (!isAudit){
- if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
- data.operation = this._reverseAuditComparison(data.operation);
- }
- data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
- data.logistics.forEach((logistic,j)=>{
- data.logistics[j] = logistic.name;
- });
- data.details.forEach((detail,j)=>{
- data.details[j].province_id = this.poolMapping.provinces ? this.poolMapping.provinces[data.details[j].province_id] : '';
- });
- switch (data.operation) {
- case "C":
- this._pushAuditList("express","C",data);
- break;
- case "D":
- this._pushAuditList("express","D",data);
- break;
- case "U":
- let result = this._formatComparisonData("express",data);
- if (result===null) this._pushAuditList("express","C",data);
- else this._pushAuditList("express","U",result);
- break;
- default:
- if (!this.auditList.express.H)this.auditList.express.H = {};
- this.auditList.express.H[data.id] = data;
- break;
- }
- },
- _AuditComparisonLogistic(data,isAudit){
- if (!isAudit){
- if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
- data.operation = this._reverseAuditComparison(data.operation);
- }
- data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
- data.logistics.forEach((logistic,j)=>{
- data.logistics[j] = logistic.name;
- });
- data.other_unit_id = this.poolMapping.units ? this.poolMapping.units[data.other_unit_id] : '';
- data.unit_id = this.poolMapping.units ? this.poolMapping.units[data.unit_id] : '';
- data.unit_range = data.unit_range ? data.unit_range.split(",") : [];
- data.other_unit_range = data.other_unit_range ? data.other_unit_range.split(",") : [];
- data.details.forEach((detail,j)=>{
- data.details[j].province_id = this.poolMapping.provinces ? this.poolMapping.provinces[data.details[j].province_id] : '';
- data.details[j].city_id = this.poolMapping.cities ? this.poolMapping.cities[data.details[j].city_id] : '';
- data.details[j].unit_id = this.poolMapping.units ? this.poolMapping.units[data.details[j].unit_id] : '';
- });
- switch (data.operation) {
- case "C":
- this._pushAuditList("logistic","C",data);
- break;
- case "D":
- this._pushAuditList("logistic","D",data);
- break;
- case "U":
- let result = this._formatComparisonData("logistic",data);
- if (result===null) this._pushAuditList("logistic","C",data);
- else this._pushAuditList("logistic","U",result);
- break;
- default:
- if (!this.auditList.logistic.H)this.auditList.logistic.H = {};
- this.auditList.logistic.H[data.id] = data;
- break;
- }
- },
- _AuditComparisonDirectLogistic(data,isAudit){
- if (!isAudit){
- if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
- data.operation = this._reverseAuditComparison(data.operation);
- }
- data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
- data.details.forEach((detail,j)=>{
- data.details[j].car_type_id = this.poolMapping.cars ? this.poolMapping.cars[data.details[j].car_type_id] : '';
- });
- switch (data.operation) {
- case "C":
- this._pushAuditList("directLogistic","C",data);
- break;
- case "D":
- this._pushAuditList("directLogistic","D",data);
- break;
- case "U":
- let result = this._formatComparisonData("directLogistic",data);
- if (result===null) this._pushAuditList("directLogistic","C",data);
- else this._pushAuditList("directLogistic","U",result);
- break;
- default:
- if (!this.auditList.directLogistic.H)this.auditList.directLogistic.H = {};
- this.auditList.directLogistic.H[data.id] = data;
- break;
- }
- },
- _AuditComparisonSystem(data,isAudit){
- if (!isAudit){
- if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
- data.operation = this._reverseAuditComparison(data.operation);
- }
- data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
- switch (data.operation) {
- case "C":
- this.auditList.system.C = data;
- this.showAuditPiece.C = true;
- break;
- case "D":
- this.auditList.system.D = data;
- this.showAuditPiece.D = true;
- break;
- case "U":
- if (!this.auditList.system.H){
- this.auditList.system.C = data;
- this.showAuditPiece.C = true;
- }else{
- this.auditList.system.U = data;
- this.showAuditPiece.U = true;
- }
- break;
- default:
- this.auditList.system.H = data;
- break;
- }
- },
- _formatComparisonData(type,data){
- let temp = {"name":"名称"};
- let font = "<div class='float-left'><span class='float-left fa fa-arrow-right text-info ml-2 mr-2' style='margin-top: 0.25em'></span>";
- let tar = null;
- let itemTem;
- let items;
- let amount;
- switch (type) {
- case "storage":
- tar = this.auditList.storage.H ? this.auditList.storage.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : null;
- if (!tar)return null;
- for (let key in this.auditList.mapping.storage){
- if (String(data[key])!==String(tar[key])){
- if (!temp[key]) temp[key] = this.auditList.mapping.storage[key];
- data[key] = this.transformData(tar,key)+font+this.transformData(data,key,true)+"</div>";
- }else data[key] = this.transformData(data,key);
- }
- if (String(data["price"])!==String(tar["price"]) && String(data["amount_interval"])===String(tar["amount_interval"])){
- data["amount_interval"] = this.transformData(tar,"amount_interval")+font+this.transformData(data,"amount_interval",true)+"</div>";
- }
- break;
- case "operation":
- temp={"name":"名称",child:{strategy:"子策略"}};
- itemTem = {};
- items=[];
- amount=0;
- tar = this.auditList.operation.H ? this.auditList.operation.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
- if (!tar)return null;
- for (let key in this.auditList.mapping.operation){
- if (String(data[key])!==String(tar[key])){
- if (!temp[key]) temp[key] = this.auditList.mapping.operation[key];
- data[key] = this.transformData(tar,key)+font+this.transformData(data,key,true)+"</div>";
- }else data[key] = this.transformData(data,key);
- }
- tar.items.forEach(item=>{
- if (!itemTem[item.strategy])itemTem[item.strategy] = [];
- itemTem[item.strategy].push(item);
- });
- data.items.forEach(item=>{
- if (itemTem[item.strategy]){
- let mark = true;
- for (let i=0;i<itemTem[item.strategy].length;i++){
- for (let key in this.auditList.mapping.operation.child){
- let oldStr = itemTem[item.strategy][i][key];
- let newStr = item[key];
- if (String(newStr)!==String(oldStr)){
- mark = false;break;
- }
- }
- if (mark){
- item.operation = "H";
- itemTem[item.strategy].splice(i,1);
- if (itemTem[item.strategy].length===0)itemTem[item.strategy] = null;
- break;
- }
- }
- }//去重
- });
- data.items.forEach(item=>{
- if (item.operation!=='H'){
- if (!itemTem[item.strategy]){
- for (let key in this.auditList.mapping.operation.child)item[key] = this.transformData(item,key);
- item.operation = "C";
- items.unshift(item);
- amount++;
- }else{
- let tar = item.strategy;
- for (let key in this.auditList.mapping.operation.child){
- if (String(item[key])!==String(itemTem[tar][0][key])){
- if (!temp.child[key]) temp.child[key] = this.auditList.mapping.operation.child[key];
- item[key] = this.transformData(itemTem[tar][0],key)+font+this.transformData(item,key,true)+"</div>";
- }else item[key] = this.transformData(item,key);
- }
- item.operation = "U";
- items.push(item);
- itemTem[tar].splice(0,1);
- if (itemTem[tar].length===0) itemTem[tar] = null;
- }
- }
- });
- for (let key in itemTem){
- if (itemTem[key]){
- itemTem[key].forEach(item=>{
- for (let key in this.auditList.mapping.operation.child)item[key] = this.transformData(item,key);
- item.operation = "D";
- items.splice(amount,0,item);
- amount++;
- });
- }
- }
- data.items = items;
- break;
- case "express":
- temp={"name":"名称",child:{province_id:"省"}};
- itemTem={};
- items=[];
- amount=0;
- tar = this.auditList.express.H ? this.auditList.express.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : null;
- if (!tar)return null;
- for (let key in this.auditList.mapping.express) {
- if (String(data[key]) !== String(tar[key])) {
- if (!temp[key]) temp[key] = this.auditList.mapping.express[key];
- data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
- } else data[key] = this.transformData(data, key);
- if (String(data["amount_interval"])!==String(tar["amount_interval"]) && String(data["weight_interval"])===String(tar["weight_interval"])){
- data["weight_interval"] = this.transformData(tar,"weight_interval")+font+this.transformData(data,"weight_interval",true)+"</div>";
- }
- }
- tar.details.forEach(item => {itemTem[item.province_id] = item;});
- data.details.forEach(item=>{
- if (!itemTem[item.province_id]){
- for (let key in this.auditList.mapping.express.child)item[key] = this.transformData(item,key);
- item.operation = "C";
- items.unshift(item);
- amount++;
- }else{
- let mark = true;
- for (let key in this.auditList.mapping.express.child){
- if (String(item[key])!==String(itemTem[item.province_id][key])){
- mark = false;break;
- }
- }
- if (!mark){
- let tar = item.province_id;
- for (let key in this.auditList.mapping.express.child) {
- if (String(item[key]) !== String(itemTem[tar][key])) {
- if (!temp.child[key]) temp.child[key] = this.auditList.mapping.express.child[key];
- item[key] = this.transformData(itemTem[tar], key) + font + this.transformData(item, key, true) + "</div>";
- } else item[key] = this.transformData(item, key);
- }
- item.operation = "U";
- items.push(item);
- delete itemTem[tar];
- }else delete itemTem[item.province_id];
- }
- });
- for (let key in itemTem){
- for (let k in this.auditList.mapping.express.child)itemTem[key][k] = this.transformData(itemTem[key],k);
- itemTem[key].operation = "D";
- items.splice(amount,0,itemTem[key]);
- amount++;
- }
- data.details = items;
- break;
- case "logistic":
- temp={name:"名称",child:{province_id:"省份",city_id:"城市"}};
- tar = this.auditList.logistic.H ? this.auditList.logistic.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
- if (!tar)return null;
- for (let key in this.auditList.mapping.logistic) {
- if (String(data[key]) !== String(tar[key])) {
- if (!temp[key]) temp[key] = this.auditList.mapping.logistic[key];
- data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
- } else data[key] = this.transformData(data, key);
- }
- itemTem = this.logisticDataFormat(tar);
- let dataTem = this.logisticDataFormat(data);
- items = [];
- for (let key in itemTem){
- if (dataTem[key]){
- for (let key2 in itemTem[key]){
- if (dataTem[key][key2]){
- for (let key3 in itemTem[key][key2]){
- if (dataTem[key][key2][key3]){
- for (let key4 in itemTem[key][key2][key3]){
- if (dataTem[key][key2][key3][key4]){
- let mark = true;
- for (let key5 in this.auditList.mapping.logistic.child){
- if (String(dataTem[key][key2][key3][key4][key5]) !== String(itemTem[key][key2][key3][key4][key5])){
- if (!temp.child[key5]) temp.child[key5] = this.auditList.mapping.logistic.child[key5];
- mark=false;
- if (!temp.child[key5]) temp.child[key5] = this.auditList.mapping.logistic.child[key5];
- dataTem[key][key2][key3][key4][key5] = this.transformData(itemTem[key][key2][key3][key4], key5) + font + this.transformData(dataTem[key][key2][key3][key4], key5, true) + "</div>";
- } else dataTem[key][key2][key3][key4][key5] = this.transformData(dataTem[key][key2][key3][key4], key5);
- }
- if (!mark){
- dataTem[key][key2][key3][key4].operation = "U";
- items.push(dataTem[key][key2][key3][key4])
- }
- delete dataTem[key][key2][key3][key4];
- delete itemTem[key][key2][key3][key4];
- }
- }
- }
- }
- }
- }
- }
- }
- dataTem = this.logisticDataRestore(dataTem,"C");
- dataTem.push.apply(dataTem,this.logisticDataRestore(itemTem,"D"));
- dataTem.push.apply(dataTem,items);
- data.details = dataTem;
- break;
- case "directLogistic":
- temp={name:"名称",child:{car_type_id:"车型"}};
- itemTem={};
- items=[];
- amount=0;
- tar = this.auditList.directLogistic.H ? this.auditList.directLogistic.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
- if (!tar)return null;
- for (let key in this.auditList.mapping.directLogistic) {
- if (String(data[key]) !== String(tar[key])) {
- if (!temp[key]) temp[key] = this.auditList.mapping.directLogistic[key];
- data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
- } else data[key] = this.transformData(data, key);
- }
- tar.details.forEach(item => {itemTem[item.car_type_id] = item;});
- data.details.forEach(item => {
- if (itemTem[item.car_type_id]){
- let car = item.car_type_id;
- let mark = true;
- for (let key in this.auditList.mapping.directLogistic.child) {
- if (String(item[key]) !== String(itemTem[car][key])) {
- mark = false;
- if (!temp.child[key]) temp.child[key] = this.auditList.mapping.directLogistic.child[key];
- item[key] = this.transformData(itemTem[car], key) + font + this.transformData(item, key, true) + "</div>";
- } else item[key] = this.transformData(item, key);
- }
- if (!mark){
- item.operation = "U";
- items.push(item);
- }
- delete itemTem[car];
- }else{
- item.operation = "C";
- items.unshift(item);
- amount++;
- }
- for (let key in itemTem){
- for (let k in this.auditList.mapping.directLogistic.child)itemTem[key][k] = this.transformData(itemTem[key],k);
- itemTem[key].operation = "D";
- items.splice(amount,0,itemTem[key]);
- amount++;
- }
- });
- data.details = items;
- break;
- }
- this.auditList.mapping[type] = temp;
- return data;
- },
- transformData(data,key,font=false){
- let html = '<div class="float-left small ';
- if (font)html += "text-primary font-weight-bold";
- else html += "text-secondary";
- html+='">';
- if (!data[key])return html+"无</div>";
- switch (key) {
- case "amount_interval":
- data[key].forEach((am,i)=>{
- if (i!==data[key].length-1) html += "<span>"+am+"-"+data[key][i+1]+"("+data["price"][i]+"元)<br></span>";
- });
- html += "<span>"+data[key][data[key].length-1]+" +("+data["price"][data[key].length-1]+"元)<br></span></div>";
- return html;
- case "total_discount_price":
- data[key].forEach(am=>{
- html += '<span>'+am+'元<br></span>'
- });
- return html+"</div>";
- case "discount_price":
- data[key].forEach(am=>{
- html += '<span>'+am+'元<br></span>'
- });
- return html+"</div>";
- case "discount_count":
- data[key].forEach((am,i)=>{
- if (i!==data[key].length-1)html += '<span>'+am+'-'+data[key][i+1]+'<br></span>'
- });
- html += '<span>'+data[key][data[key].length-1]+' +<br></span>';
- return html+"</div>";
- case "weight_interval":
- data[key].forEach((arr,i)=>{
- if (i!==data[key].length-1) html += '<span>'+data.amount_interval[i]+'-'+data.amount_interval[i+1]+'/单(';
- arr.forEach((w,j)=>{
- if (j!==arr.length-1)html += w+'-'+arr[j+1]+'/KG,';
- });
- html += (arr[arr.length-1] ? arr[arr.length-1] : 0)+' +/KG)<br></span>';
- });
- html += '<span>'+data.amount_interval[data.amount_interval.length-1]+' +/单(';
- let arr = data.weight_interval[data.weight_interval.length-1];
- arr.forEach((w,j)=>{
- if (j!==arr.length-1)html += w+'-'+arr[j+1]+'/KG,';
- });
- html += (arr[arr.length-1] ? arr[arr.length-1] : 0)+' +/KG)<br></span>';
- return html+"</div>";
- case "initial_weight_price":
- data[key].forEach(arr=>{
- html += "<span class='small'>"+arr+"<br></span>";
- });
- return html+"</div>";
- case "additional_weight_price":
- data[key].forEach(arr=>{
- html += "<span class='small'>"+arr+"<br></span>";
- });
- return html+"</div>";
- case "unit_range":
- data[key].forEach(r=>{
- html += '<span class="small">'+r+'<br></span>';
- });
- return html+"</div>";
- case "other_unit_range":
- data[key].forEach(r=>{
- html += '<span class="small">'+r+'<br></span>';
- });
- return html+"</div>";
- }
- return html+= data[key]+"</div>";
- },
- logisticDataFormat(tar){
- let obj={};
- tar.details.forEach(item => {
- if (obj[item.province_id]){
- if (obj[item.province_id][item.city_id]){
- if (obj[item.province_id][item.city_id][item.unit_id]){
- obj[item.province_id][item.city_id][item.unit_id][item.range] = item;
- }else{
- let arr1={};
- arr1[item.range] = item;
- obj[item.province_id][item.city_id][item.unit_id] = arr1;
- }
- }else{
- let arr1={};
- arr1[item.range] = item;
- let arr2={};
- arr2[item.unit_id] = arr1;
- obj[item.province_id][item.city_id] = arr2;
- }
- }else{
- let arr1={};
- arr1[item.range] = item;
- let arr2={};
- arr2[item.unit_id] = arr1;
- let arr3={};
- arr3[item.city_id] = arr2;
- obj[item.province_id] = arr3;
- }
- });
- return obj;
- },
- logisticDataRestore(tar,type,items=[],count=0){
- if (count===4){
- tar["operation"] = type;
- items.push(tar);
- } else{
- count++;
- for (let key in tar){
- this.logisticDataRestore(tar[key],type,items,count);
- }
- }
- return items;
- },
- },
- });
- </script>
- @stop
|