| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673 |
- @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',
- },
- 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.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.user_workgroup_id !== old.user_workgroup_id ||
- 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;
- 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)audit.storage = true;
- if (res.operation_audit_count)audit.operation = true;
- if (res.express_audit_count)audit.express = true;
- if (res.logistic_audit_count)audit.logistic = true;
- if (res.direct_logistic_audit_count)audit.directLogistic = true;
- if (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;
- }
- });
- },
- filterUserGroup(e){
- let value = e.target.value;
- if (!value)this.owner.user_workgroup_id = "";
- this.userGroups.some(userGroup=>{
- if (userGroup.name.indexOf(value)!==-1){
- this.owner.user_workgroup_id = 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
|