| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637 |
- @extends('layouts.app')
- @section('title')项目编辑-项目管理@endsection
- @section("head")<link href="{{ mix('css/animation.css') }}" rel="stylesheet">@endsection
- @section('content')
- @component('customer.project.menu')
- @if($owner)
- <li class="nav-item">
- <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">编辑</a>
- </li>
- @endif
- @endcomponent
- <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-if="base == 'three'">
- <div v-show="isLoad">@include("customer.project.part._three")</div>
- <div class="row justify-content-center text-secondary" style="min-height: 200px;margin-left: -25%" v-show="!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>
- </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->tax_rate_id ?? ''}}",
- linkman : "{{$owner->linkman ?? ''}}",
- phone_number : "{{$owner->phone_number ?? ''}}",
- description : "{{$owner->description ?? ''}}",
- waring_line_on : "{{$owner->waring_line_on ?? ''}}",
- },
- 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 : "",
- discount_type : "无减免",
- discount_value : "",
- unit_id : "",
- time_unit_id : "",
- },
- operation:{},
- express:{
- name:"",
- initial_weight:"",
- additional_weight:"",
- items:[],
- logistics:[],
- },
- logistic:{
- items:[],
- other_ranges:[],
- ranges:[],
- logistics:[],
- },
- directLogistic:{
- items:[],
- },
- },
- pool:{//基础数据选择池,以方便异步懒加载而非即时加载 例:units,owners等
- counting_type:[
- "包仓","灵活用仓","统单价"
- ],
- using_type:[
- "常温","恒温"
- ],
- discount_type:[
- "无减免","按单减免","固定减免"
- ],
- feature_type:{!! json_encode(\App\Feature::type,JSON_UNESCAPED_UNICODE) !!},
- logic : ['包含','不包含','等于'],
- },
- poolMapping:{},//基础数据选择池的映射对象 供展示使用
- selectedModel:{//已选定的计费模型
- storage:[],
- operation:[],
- express:[],
- logistic:[],
- directLogistic:{},
- },
- thisOperationItemIndex:-1,//当前选中的作业费子项下标,用以唤起特征模态框
- operationItems:{},//控制作业费子项的渐入展开
- importError:[],//导入时的错误数据原因
- isShowError:false,//是否展开导入错误信息
- isExist:Boolean("{{$isExist ?? false}}"),
- isLoad:false,//全局加载标记,符合条件时确保仅加载一次
- introduce:{},//引入model
- isSearch:false,//是否查询,用于加载动画显示
- searchResult:[],//查询结果
- searchResultMapping:{},//查询结果映射
- selectedResult:"",
- searchItem:{},//搜索子项集
- searchBase:5,//搜索基数
- hover:{},//可悬浮列表
- audit:{},
- },
- mounted(){
- let type = "{{$type ?? ''}}";
- if (type){
- this.base = "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);
- }
- this._resetOperation();
- this.ownerTemp = JSON.parse(JSON.stringify(this.owner));
- $('[data-toggle="tooltip"]').tooltip();
- $("#container").removeClass("d-none");
- },
- methods:{
- //重置作业计费数据
- _resetOperation(){
- this.model.operation = {
- operation_type:"入库",
- strategy:"默认",
- discount_count:[''],
- name:"",
- 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') this._loadStorage();
- if (base === 'two')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");
- break;
- case "logistic":
- this._loadLogistic();
- dom = $("#logistic-card");
- break;
- case "directLogistic":
- this._loadDirectLogistic();
- dom = $("#directLogistic-card");
- 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.base = "two";
- });
- break;
- case "two":
- if (this._verifyTwo())this.base = "three";
- this._loadStorage();
- 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;
- }
- 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.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;
- 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){
- if (operation.discount_count) operation.discount_count = operation.discount_count.split(",");
- if (operation.total_discount_price) operation.total_discount_price = operation.total_discount_price.split(",");
- operation.isDiscount = true;
- }
- operation.items.forEach((item,j)=>{
- if (item.discount_price) operation.items[j].discount_price = item.discount_price.split(",");
- });
- if (operation.total_price)operation.isSingle = true;
- return operation;
- },
- //重载快递费
- _overrideExpress(express){
- express.logistics.forEach((logistic,j)=>{
- express.logistics[j] = logistic.id;
- });
- 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;
- 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=>{operation = 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)=>{
- express = 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)=>{
- logistic = 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]);
- }
- 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){
- if (!val)return;
- let mapping = [];
- val.forEach(item=>{
- mapping[item.id] = item.name;
- });
- 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');
- },0);
- });
- },
- //获取车型
- _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);});
- },
- //保存模型
- 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;
- }
- },
- _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)error["price"] = ["未输入单价"];
- 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 (JSON.stringify(error) !== "{}"){
- this.errors = error;
- return;
- }
- 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 : "",
- discount_type : "无减免",
- discount_value : "",
- unit_id : "",
- time_unit_id : "",
- };
- this.errors = {};
- this.audit.storage = true;
- });
- },
- _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.model.operation.isDiscount){
- let sign = false;
- this.model.operation.discount_count.forEach((item,i)=>{
- if (!item || (i!==0 && Number(item)<=Number(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.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.isSingle){
- if ((this.model.operation.operation_type === '出库' && this._verifyOperationItem(0)) || this._verifyOperationItem(1))return;
- if (this.model.operation.items.length>2){
- for (let i=2;i<this.model.operation.items.length;i++){
- if (this._verifyOperationItem(i))return;
- }
- }
- 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 = [""];
- }
- 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;
- let sign = 0;
- if (res.operation_type === '入库') sign++;
- for (let i=0;i<res.items.length;i++){
- res.items[i].features = this.model.operation.items[sign]['features'];
- res.items[i].featureFormat = this.model.operation.items[sign]['featureFormat'];
- res.items[i].type = this.model.operation.items[sign]['type'];
- res.items[i].discount_price = res.items[i].discount_price ? res.items[i].discount_price.split(",") : [""];
- sign++;
- }
- 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(",") : [""];
- if (params.id) this.selectedModel.operation[params.index] = res;
- else this.selectedModel.operation.push(res);
- this._resetOperation();
- this.errors = {};
- this.audit.operation = true;
- });
- },
- _verifyOperationItem(itemIndex){//验证作业费子项信息完整
- let obj = this.model.operation.items[itemIndex];
- let sign = false;
- if (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.model.express.items.length>0){
- this.model.express.items.forEach((item,index)=>{
- if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
- if (!item.initial_weight_price)error["item."+index+".initial_weight_price"] = ["不存在"];
- if (!item.additional_weight_price)error["item."+index+".additional_weight_price"] = ["不存在"];
- });
- }
- if (JSON.stringify(error) !== "{}"){
- this.errors = error;
- return;
- }
- 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;
- }
- 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:"",
- logistics:[],
- initial_weight:"",
- additional_weight:"",
- items:[],
- };
- this.errors = {};
- this.importError = [];
- $(".selectpicker").filter('.express').selectpicker('val',[]);
- this.audit.express = true;
- });
- },
- _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 (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;
- });
- },
- _verifyDirectLogistic(){
- let error = {};
- if (!this.model.directLogistic.name) error.name = ["名称不得为空"];
- if (!this.model.directLogistic.base_km) error.base_km = ["起步公里数不得为空"];
- 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;
- });
- },
- //增加作业费特征子项
- addOperationItem(){
- this.model.operation.items.push({
- strategy:"特征",
- discount_price:new Array(this.model.operation.discount_count.length).fill(""),
- });
- },
- //删除作业费子项
- delOperationItem(index){
- this.$delete(this.model.operation.items,index);
- },
- //显示特征选择modal
- showAddFeatureModal(index){
- 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(){
- this.model.express.items.unshift({
- province_id : "",
- initial_weight_price:"",
- additional_weight_price:"",
- });
- },
- //删除快递子项
- delExpressItem(index){
- this.$delete(this.model.express.items,index);
- },
- //选择文件
- selectFile(id){
- this.importError = [];
- $("#"+id).click();
- },
- //导入快递子项
- 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.forEach(data=>{
- let unique = this.model.express.items.every(item=>{
- if (data.province_id === item.province_id)return false;
- return true;
- });
- if (unique)this.model.express.items.push(data);
- });
- this.importError = res.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;
- 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,
- 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,
- 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,
- items:items,
- };
- });
- this.searchResult = result;
- this.searchResultMapping = mapping;
- 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 "删除成功";
- });
- });
- },
- //编辑仓储
- editStorage(index){
- this.switchType("storage");
- this.model.storage = JSON.parse(JSON.stringify(this.selectedModel.storage[index]));
- this.model.storage.index = index;
- },
- //编辑作业
- editOperation(index){
- this.switchType("operation");
- this.model.operation = JSON.parse(JSON.stringify(this.selectedModel.operation[index]));
- if (this.model.operation.operation_type==='入库') this.model.operation.items.unshift({});
- this.model.operation.index = index;
- if (this.model.operation.items.length == 0){
- this.model.operation.items = [
- {strategy:"起步",type:"0"},
- {strategy:"默认"},
- {strategy:"特征"},
- ];
- }
- },
- //编辑快递
- 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));
- },
- //搜索快递子项
- 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('');
- },
- //删除阶梯满减阈值
- 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){
- let url = "{{url('maintenance/priceModel/auditOrRecoverModel')}}";
- let param = {owner_id:this.ownerTemp.id,type:type,isAudit:isAudit};
- window.tempTip.confirm("确定要"+(isAudit ? '审核' : '恢复')+"上次的全部操作吗?",()=>{
- window.tempTip.postBasicRequest(url,param,res=>{
- switch (type){
- case "storage":
- this.selectedModel.storage = res;
- break;
- case "operation":
- this._loadOperation();
- res.forEach(operation=>{operation = this._overrideOperation(operation);});
- this.selectedModel.operation = res;
- break;
- case "express":
- this._loadExpress();
- res.forEach((express,i)=>{
- express = this._overrideExpress(express);
- this.upList['express-item-'+i] = true;
- });
- this.selectedModel.express = res;
- break;
- case "logistic":
- this._loadLogistic();
- res.forEach((logistic,i)=>{
- logistic = 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;
- }
- this.$set(this.audit,type,false);
- })
- })
- },
- },
- });
- </script>
- @stop
|