create.blade.php 149 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732
  1. @extends('layouts.app')
  2. @section('title')项目编辑-项目管理@endsection
  3. @section("head")<link href="{{ mix('css/animation.css') }}" rel="stylesheet">@endsection
  4. @section('content')
  5. <div class="container-fluid card d-none" id="container">
  6. <div class="card-body offset-1">
  7. <div class="row">
  8. <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('one')">
  9. <div class="h-100 w-25">
  10. <div class="h1 fillet text-center" :class="[base == 'one' ? 'sign' : '', (base!=='one' && !owner.name) ? 'bg-secondary border-secondary' : 'bg-info']">
  11. <span class="fa fa-edit ml-1 text-white"></span>
  12. </div>
  13. </div>
  14. <div class="h-100 w-75">
  15. <span class="font-weight-bold ml-1">基础信息</span><br>
  16. <span class="small ml-1">名称:@{{ owner.name }}</span><br>
  17. <span class="small ml-1">代码:@{{ owner.code }}</span><br>
  18. </div>
  19. </div>
  20. <div class="col-2">
  21. <hr class="w-100 mt-4 hr-info">
  22. </div>
  23. <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('two')">
  24. <div class="h-100 w-25">
  25. <div class="h1 fillet text-center" :class="[base == 'two' ? 'sign' : '', (base!=='two' && !owner.customer_id) ? 'bg-secondary border-secondary' : 'bg-info']">
  26. <span class="fa fa-book ml-1 text-white"></span>
  27. </div>
  28. </div>
  29. <div class="h-100 w-75">
  30. <span class="font-weight-bold ml-1">详细描述</span><br>
  31. <span class="small ml-1">客户:@{{ owner.customer_name }}</span><br>
  32. <span class="small ml-1">小组:@{{ owner.owner_group_name }}</span><br>
  33. </div>
  34. </div>
  35. <div class="col-2">
  36. <hr class="w-100 mt-4 hr-info">
  37. </div>
  38. <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('three')">
  39. <div class="h-100 w-25">
  40. <div class="h1 fillet text-center" :class="[base == 'three' ? 'sign' : '', (base!=='three' && !isExist) ? 'bg-secondary border-secondary' : 'bg-info']">
  41. <span class="fa fa-rmb ml-1 text-white "></span>
  42. </div>
  43. </div>
  44. <div class="h-100 w-75">
  45. <div class="font-weight-bold ml-1 h-100 mt-3">计费模型</div>
  46. </div>
  47. </div>
  48. </div>
  49. <div v-if="base == 'one'">
  50. @include("customer.project.part._one")
  51. </div>
  52. <div v-if="base == 'two'">
  53. @include("customer.project.part._two")
  54. </div>
  55. <div v-show="base == 'three'">
  56. <div v-if="isLoad">@include("customer.project.part._three")</div>
  57. <div class="row justify-content-center text-secondary" style="min-height: 200px;margin-left: -25%" v-if="!isLoad">
  58. <div class="align-self-center h1">
  59. <i class="fa fa-spinner fa-pulse"></i>
  60. </div>
  61. </div>
  62. </div>
  63. <hr class="mt-2">
  64. <div class="row mt-3" v-if="base != 'three' || isLoad">
  65. <div class="pull-right offset-7">
  66. <button type="button" class="btn btn-info ml-1 text-white" v-show="base !== 'one'" @click="back()">上一步</button>
  67. <button type="button" class="btn btn-info ml-1 text-white" v-show="base !== 'three'" @click="next()">下一步</button>
  68. <button type="button" class="btn btn-success ml-1" @click="success()">完成</button>
  69. <button type="button" class="btn btn-secondary ml-1" @click="reset()" v-show="base !== 'three'">重置</button>
  70. </div>
  71. </div>
  72. @include("customer.project.part._auditComparison")
  73. </div>
  74. </div>
  75. @stop
  76. @section('lastScript')
  77. <script>
  78. new Vue({
  79. el:"#container",
  80. data:{
  81. base:"one",
  82. owner : {
  83. id:"{{$owner->id ?? ''}}",
  84. name : "{{$owner->name ?? ''}}",
  85. code : "{{$owner->code ?? ''}}",
  86. customer_id : "{{$owner->customer_id ?? ''}}",
  87. customer_name : "{{ isset($owner) ? ($owner->customer ? $owner->customer->name : '') : ''}}",
  88. owner_group_name : "{{ isset($owner) ? ($owner->userOwnerGroup ? $owner->userOwnerGroup->name : '') : ''}}",
  89. owner_group_id : "{{$owner->user_owner_group_id ?? ''}}",
  90. user_workgroup_id : "{{$owner->user_workgroup_id ?? ''}}",
  91. warehouse_id : "{{ $owner->warehouse_id ?? ''}}",
  92. tax_rate_id : "{{$owner->is_tax_exist ?? ''}}"==='Y' ? '0' : "{{$owner->tax_rate_id ?? ''}}",
  93. linkman : "{{$owner->linkman ?? ''}}",
  94. phone_number : "{{$owner->phone_number ?? ''}}",
  95. description : "{{$owner->description ?? ''}}",
  96. waring_line_on : "{{$owner->waring_line_on ?? ''}}",
  97. subjection : "{{$owner->subjection ?? ''}}",
  98. is_tax_exist : "{{$owner->is_tax_exist ?? ''}}"==='Y',
  99. kc :"{{$owner->kc ?? ''}}",
  100. jg :"{{$owner->jg ?? ''}}",
  101. th :"{{$owner->th ?? ''}}",
  102. sh :"{{$owner->sh ?? ''}}",
  103. fh :"{{$owner->fh ?? ''}}",
  104. },
  105. ownerTemp : {},
  106. customers : [
  107. @foreach($customers as $customer)
  108. {id:"{{$customer->id}}",name:"{{$customer->name}}"},
  109. @endforeach
  110. ],
  111. ownerGroups : [
  112. @foreach($ownerGroups as $ownerGroup)
  113. {id:"{{$ownerGroup->id}}",name:"{{$ownerGroup->name}}"},
  114. @endforeach
  115. ],
  116. userGroups : [
  117. @foreach($userGroups as $userGroup)
  118. {id:"{{$userGroup->id}}",name:"{{$userGroup->name}}",warehouse_id:"{{$userGroup->warehouse_id}}"},
  119. @endforeach
  120. ],
  121. warehouses:[
  122. @foreach($warehouses as $warehouse)
  123. {id:"{{$warehouse->id}}",name:"{{$warehouse->name}}"},
  124. @endforeach
  125. ],
  126. style : '',
  127. errors : {!! $errors !!}, //全部的错误提示
  128. upList:{ //控制元素的渐入展开与收起
  129. storage : false,
  130. },
  131. type:"storage",//当前编辑类型 仓储,作业,物流...
  132. currentInputting:{
  133. edittingOperation:null,
  134. },
  135. model:{ //编辑元素绑定值
  136. storage:{
  137. counting_type : "",
  138. using_type : "",
  139. minimum_area : "",
  140. price : [""],
  141. amount_interval : [""],
  142. discount_type : "无减免",
  143. discount_value : "",
  144. unit_id : "",
  145. time_unit_id : "",
  146. },
  147. operation:{},
  148. express:{
  149. name:"",
  150. initial_weight:"",
  151. additional_weight:"",
  152. amount_interval:[""],
  153. weight_interval:[[]],
  154. items:[],
  155. logistics:[],
  156. },
  157. logistic:{
  158. items:[],
  159. other_ranges:[],
  160. ranges:[],
  161. logistics:[],
  162. },
  163. directLogistic:{
  164. items:[],
  165. },
  166. system:{
  167. usage_fee:""
  168. },
  169. },
  170. pool:{//基础数据选择池,以方便异步懒加载而非即时加载 例:units,owners等
  171. counting_type:[
  172. "包仓","灵活用仓","统单价"
  173. ],
  174. using_type:[
  175. "常温","恒温"
  176. ],
  177. discount_type:[
  178. "无减免","按单减免","固定减免"
  179. ],
  180. feature_type:[],
  181. logic : ['包含','不包含','等于',"大于","大于等于","小于","小于等于"],
  182. },
  183. poolMapping:{},//基础数据选择池的映射对象 供展示使用
  184. selectedModel:{//已选定的计费模型
  185. storage:[],
  186. operation:[],
  187. express:[],
  188. logistic:[],
  189. directLogistic:{},
  190. system:{},
  191. },
  192. thisOperationItemIndex:-1,//当前选中的作业费子项下标,用以唤起特征模态框
  193. operationItems:{},//控制作业费子项的渐入展开
  194. importError:[],//导入时的错误数据原因
  195. isShowError:false,//是否展开导入错误信息
  196. isExist:Boolean("{{$isExist ?? false}}"),
  197. isLoad:false,//全局加载标记,符合条件时确保仅加载一次
  198. introduce:{},//引入model
  199. isSearch:false,//是否查询,用于加载动画显示
  200. searchResult:[],//查询结果
  201. searchResultMapping:{},//查询结果映射
  202. selectedResult:"",
  203. searchItem:{},//搜索子项集
  204. searchBase:5,//搜索基数
  205. hover:{},//可悬浮列表
  206. audit:{},//审核按钮
  207. auditList:{
  208. storage:{},operation:{},express:{},logistic:{},directLogistic:{},system:{},
  209. mapping: {
  210. "storage": {
  211. "name": "名称",
  212. "counting_type": "计费类型",
  213. "using_type": "用仓类型",
  214. "minimum_area": "最低起租面积",
  215. "discount_type": "减免类型",
  216. "discount_value": "减免值",
  217. "unit_id": "单位",
  218. "time_unit_id": "计时单位",
  219. "amount_interval": "数量-单价",
  220. "tax_rate_id": "税率",
  221. },
  222. "operation": {
  223. name: "名称",
  224. operation_type: "作业类型",
  225. strategy: "策略",
  226. feature: "特征",
  227. total_price: "按单价",
  228. total_discount_price: "按单减免单价",
  229. discount_count: "减免值",
  230. type_mark: "类型",
  231. surcharge: "附加费",
  232. surcharge_unit_id: "附加费单位",
  233. max_fee: "封顶费",
  234. remark: "备注",
  235. tax_rate_id: "税率",
  236. child: {
  237. strategy: "子策略",
  238. amount: "起步数",
  239. unit_id: "单位",
  240. unit_price: "单价",
  241. feature: "特征",
  242. discount_price: "减免单价",
  243. odd_price: "零头价",
  244. }
  245. },
  246. "express": {
  247. name: "名称",
  248. initial_weight: "首重",
  249. additional_weight: "续重",
  250. weight_interval: "数量-重量",
  251. tax_rate_id: "税率",
  252. child: {
  253. province_id: "省",
  254. initial_weight_price: "初始单价",
  255. additional_weight_price: "续重单价",
  256. },
  257. },
  258. "logistic": {
  259. name: "名称",
  260. unit_id: "单位一",
  261. unit_range: "单位一区间",
  262. other_unit_id: "单位二",
  263. other_unit_range: "单位二区间",
  264. pick_up_price: "提货费",
  265. fuel_price: "燃油附加费",
  266. service_price: "服务费",
  267. tax_rate_id: "税率",
  268. child: {
  269. unit_id: "单位",
  270. range: "区间",
  271. province_id: "省份",
  272. city_id: "城市",
  273. unit_price: "单价",
  274. delivery_fee: "送货费",
  275. initial_fee: "起始计费",
  276. initial_amount: "起始计数",
  277. rate: "费率",
  278. },
  279. },
  280. "directLogistic": {
  281. name: "名称",
  282. base_km: "起步公里数",
  283. tax_rate_id: "税率",
  284. child: {
  285. car_type_id: "车型",
  286. base_fee: "起步费",
  287. additional_fee: "续费(元/KM)"
  288. }
  289. },
  290. }
  291. },//审核对比
  292. selectedAudit:"",//当前选择对比项
  293. showAuditPiece:{
  294. "C":false,"D":false,"U":false
  295. },//显示审核块
  296. isAudit:true,
  297. comparisonTemp:{},
  298. },
  299. created(){
  300. this.filterCustomers = JSON.parse(JSON.stringify(this.customers));
  301. this.filterOwnerGroups = JSON.parse(JSON.stringify(this.ownerGroups));
  302. this.filterUserGroups = JSON.parse(JSON.stringify(this.userGroups));
  303. },
  304. mounted(){
  305. let type = "{{$type ?? ''}}";
  306. this._resetOperation();
  307. this.ownerTemp = JSON.parse(JSON.stringify(this.owner));
  308. if (type){
  309. this.switchBase("three");
  310. this.type = "";
  311. setTimeout(()=>{
  312. this.switchType(type);
  313. if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
  314. if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
  315. },0);
  316. }
  317. $('[data-toggle="tooltip"]').tooltip();
  318. $("#container").removeClass("d-none");
  319. },
  320. methods:{
  321. //重置作业计费数据
  322. _resetOperation(){
  323. this.model.operation = {
  324. operation_type:"入库",
  325. strategy:"默认",
  326. discount_count:[''],
  327. name:"",
  328. isRejected:false,
  329. feature:"",
  330. total_discount_price:[''],
  331. items : [
  332. {strategy:"起步",type:"0",discount_price:['']},
  333. {strategy:"默认",discount_price:['']},
  334. {strategy:"特征",discount_price:['']},
  335. ],
  336. };
  337. },
  338. //悬浮效果
  339. hoverEffect(key,val){
  340. this.$set(this.hover,key,val);
  341. },
  342. //收起展开
  343. show(id){
  344. if (this.upList[id])$("#"+id).slideDown();
  345. else $("#"+id).slideUp();
  346. this.upList[id] = !this.upList[id];
  347. this.$forceUpdate();
  348. },
  349. //清除垃圾数据
  350. _clearRefuse(){
  351. this.errors = {};
  352. this.importError = [];
  353. this.selectedResult = "";
  354. this.searchResult = [];
  355. this.searchResultMapping = {};
  356. this.introduce = {};
  357. },
  358. //切换选项
  359. switchBase(base){
  360. if (!this.owner.id)return;
  361. if (base === this.base)return;
  362. if (base === 'three'){
  363. if (!this.pool.taxRates) this._getTaxRates();
  364. this._loadStorage();
  365. }
  366. if (base === 'two')if (!this.pool.taxRates) this._getTaxRates();
  367. this.base = base;
  368. },
  369. //切换类型
  370. switchType(type){
  371. if (type === this.type)return;//相同终止是为了减少重复加载动作
  372. this._clearRefuse();//清除垃圾数据
  373. let parent = $("#parent");
  374. let dom = "";
  375. switch (type) {
  376. case "storage":
  377. this._loadStorage();
  378. dom = $("#storage-card");
  379. break;
  380. case "operation":
  381. this._loadOperation();
  382. dom = $("#operation-card");
  383. break;
  384. case "express":
  385. this._loadExpress();
  386. dom = $("#express-card");
  387. $("#expressImport").tooltip();
  388. break;
  389. case "logistic":
  390. this._loadLogistic();
  391. dom = $("#logistic-card");
  392. break;
  393. case "directLogistic":
  394. this._loadDirectLogistic();
  395. dom = $("#directLogistic-card");
  396. break;
  397. case "system":
  398. dom = $("#system-card");
  399. if(this.selectedModel.system && this.selectedModel.system.id)this.model.system = this.selectedModel.system;
  400. break;
  401. }
  402. dom.addClass("animation-translation");
  403. dom.fadeOut(500);
  404. setTimeout(function(){
  405. dom.removeClass("animation-translation");
  406. parent.prepend(dom);
  407. dom.fadeIn();
  408. },400);
  409. this.type = type;
  410. },
  411. //下一步
  412. next(){
  413. switch (this.base) {
  414. case "one":
  415. this._verifyOne(()=>{
  416. this.switchBase('two');
  417. });
  418. break;
  419. case "two":
  420. if (this._verifyTwo()){
  421. this.switchBase('three');
  422. }
  423. break;
  424. }
  425. },
  426. //完成
  427. success(){
  428. switch (this.base) {
  429. case "one":
  430. this._verifyOne(()=>{
  431. window.location.href = "{{url('customer/project/index')}}";
  432. });
  433. break;
  434. case "two":
  435. if (this._verifyTwo())window.location.href = "{{url('customer/project/index')}}";
  436. break;
  437. default:
  438. window.tempTip.confirm("<span class='text-danger'>确定后计费模型未保存项将被抛弃,您确认仍要完成吗?</span>",()=>{
  439. window.location.href = "{{url('customer/project/index')}}";
  440. });
  441. break;
  442. }
  443. },
  444. //重置
  445. reset(){
  446. switch (this.base) {
  447. case "one":
  448. this.owner = this.ownerTemp;
  449. break;
  450. case "two":
  451. this.owner = this.ownerTemp;
  452. break;
  453. }
  454. },
  455. //验证基础信息
  456. _verifyOne(func){
  457. if (!this.owner.code){
  458. this.$set(this.errors,"code",["项目代码为必填项"]);
  459. return false;
  460. }
  461. if (!this.owner.name){
  462. this.$set(this.errors,"name",["项目名称为必填项"]);
  463. return false;
  464. }
  465. if (this.owner.name !== this.ownerTemp.name || this.owner.code !== this.ownerTemp.code){
  466. let url = "{{url('maintenance/owner/apiStore')}}";
  467. let params = {name:this.owner.name,code:this.owner.code,id:this.owner.id};
  468. window.tempTip.postBasicRequest(url,params,res=>{
  469. if (res.errors){
  470. this.errors = res.errors;
  471. return;
  472. }
  473. this.errors = {};
  474. this.owner.id = res.id;
  475. this.ownerTemp.id = res.id;
  476. this.ownerTemp.name = res.name;
  477. this.ownerTemp.code = res.code;
  478. func();
  479. });
  480. }else func();
  481. },
  482. //验证详细描述
  483. _verifyTwo(){
  484. let error = {};
  485. if (!this.owner.customer_id) error["customer_id"] = ["必须选择客户"];
  486. if (!this.owner.owner_group_id) error["owner_group_id"] = ["必须选择项目小组"];
  487. if (!this.owner.warehouse_id) error["warehouse_id"] = ["必须选择仓库"];
  488. // if (!this.owner.user_workgroup_id) error["user_workgroup_id"] = ["必须选择仓库小组"];
  489. if (!this.owner.kc) error["kc"] = ["必须选择库存组"];
  490. if (!this.owner.jg) error["jg"] = ["必须选择加工组"];
  491. if (!this.owner.th) error["th"] = ["必须选择退货组"];
  492. if (!this.owner.sh) error["sh"] = ["必须选择收货组"];
  493. if (!this.owner.fh) error["fh"] = ["必须选择发货组"];
  494. //if (!this.owner.tax_rate_id) error["tax_rate_id"] = ["必须选择税率"];
  495. if (JSON.stringify(error) !== "{}"){
  496. this.errors = error;
  497. return false;
  498. }
  499. this.owner.is_tax_exist = this.owner.tax_rate_id==='0';
  500. let url = "{{url('customer/project/projectUpdate')}}";
  501. let params = this.owner;
  502. let old = this.ownerTemp;
  503. if (params.customer_id !== old.customer_id ||
  504. params.owner_group_id !== old.owner_group_id ||
  505. params.kc !== old.kc ||
  506. params.jg !== old.jg ||
  507. params.th !== old.th ||
  508. params.sh !== old.sh ||
  509. params.fh !== old.fh ||
  510. params.warehouse_id !== old.warehouse_id ||
  511. params.tax_rate_id !== old.tax_rate_id ||
  512. params.waring_line_on !== old.waring_line_on ||
  513. params.phone_number !== old.phone_number ||
  514. params.subjection !== old.subjection ||
  515. params.is_tax_exist !== old.is_tax_exist ||
  516. params.description !== old.description){
  517. let result = undefined;
  518. window.tempTip.postBasicRequest(url,params,res=>{
  519. if (res.errors){
  520. this.errors = res.errors;
  521. result = false;
  522. return;
  523. }
  524. this.errors = [];
  525. this.ownerTemp.customer_id = res.customer_id;
  526. this.ownerTemp.owner_group_id = res.owner_group_id;
  527. // this.ownerTemp.user_workgroup_id = res.user_workgroup_id;
  528. if (res.department_obligation_owner.obligation_code==='kc')this.ownerTemp.kc = res.department_obligation_owner.obligation_id;
  529. if (res.department_obligation_owner.obligation_code==='jg')this.ownerTemp.jg = res.department_obligation_owner.obligation_id;
  530. if (res.department_obligation_owner.obligation_code==='th')this.ownerTemp.th = res.department_obligation_owner.obligation_id;
  531. if (res.department_obligation_owner.obligation_code==='sh')this.ownerTemp.sh = res.department_obligation_owner.obligation_id;
  532. if (res.department_obligation_owner.obligation_code==='fh')this.ownerTemp.fh = res.department_obligation_owner.obligation_id;
  533. this.ownerTemp.warehouse_id = res.warehouse_id;
  534. this.ownerTemp.tax_rate_id = res.tax_rate_id;
  535. this.ownerTemp.waring_line_on = res.waring_line_on;
  536. this.ownerTemp.phone_number = res.phone_number;
  537. this.ownerTemp.description = res.description;
  538. this.ownerTemp.customer_name = params.customer_name;
  539. this.ownerTemp.owner_group_name = params.owner_group_name;
  540. this.ownerTemp.subjection = params.subjection;
  541. this.ownerTemp.is_tax_exist = params.is_tax_exist;
  542. result = true;
  543. });
  544. while (result){
  545. if (typeof result !== "undefined")return result;
  546. }
  547. }
  548. return true;
  549. },
  550. //上一步
  551. back(){
  552. switch (this.base) {
  553. case "two":
  554. this.base = 'one';
  555. break;
  556. case "three":
  557. this.base = 'two';
  558. break;
  559. }
  560. },
  561. //重载作业费
  562. _overrideOperation(operation){
  563. if (operation.discount_count){
  564. operation.isDiscount = true;
  565. operation.discount_count = operation.discount_count.split(",");
  566. } else operation.discount_count = [];
  567. if (operation.total_discount_price) operation.total_discount_price = operation.total_discount_price.split(",");
  568. else operation.total_discount_price = [];
  569. operation.items.forEach((item,j)=>{
  570. if (item.discount_price) operation.items[j].discount_price = item.discount_price.split(",");
  571. else operation.items[j].discount_price = [];
  572. });
  573. if (operation.total_price)operation.isSingle = true;
  574. if (operation.type_mark===0 || operation.type_mark==='0')operation.isRejected = true;
  575. return operation;
  576. },
  577. //重载快递费
  578. _overrideExpress(express){
  579. express.logistics.forEach((logistic,j)=>{
  580. express.logistics[j] = logistic.id;
  581. });
  582. if (!express.amount_interval || !express.weight_interval){
  583. express.amount_interval = [""];
  584. express.weight_interval = [[]];
  585. }else express.isInterval = true;
  586. return JSON.parse(JSON.stringify(express).replace(/details/g,"items"));
  587. },
  588. //重载物流费
  589. _overrideLogistic(logistic){
  590. logistic.logistics.forEach((l,j)=>{
  591. logistic.logistics[j] = l.id;
  592. });
  593. return JSON.parse(JSON.stringify(logistic).replace(/details/g,"items"));
  594. },
  595. //重载直发费
  596. _overrideDirectLogistic(directLogistic){
  597. return JSON.parse(JSON.stringify(directLogistic).replace(/details/g,"items"));
  598. },
  599. //加载计费模型
  600. _loadPriceModel(){
  601. let url = "{{url('customer/project/getPriceModel')}}";
  602. let params = {id:this.ownerTemp.id};
  603. window.tempTip.postBasicRequest(url,params,res=>{
  604. let audit = {};
  605. if (res.storage_audit_count && Number(res.storage_audit_count))audit.storage = true;
  606. if (res.operation_audit_count && Number(res.operation_audit_count))audit.operation = true;
  607. if (res.express_audit_count && Number(res.express_audit_count))audit.express = true;
  608. if (res.logistic_audit_count && Number(res.logistic_audit_count))audit.logistic = true;
  609. if (res.direct_logistic_audit_count && Number(res.direct_logistic_audit_count))audit.directLogistic = true;
  610. if (res.system_audit_count && Number(res.system_audit_count))audit.system = true;
  611. this.audit = audit;
  612. if (res.owner_storage_price_models.length>0)this.selectedModel.storage = res.owner_storage_price_models;
  613. if (res.owner_price_operations.length>0){
  614. this._loadOperation();
  615. res.owner_price_operations.forEach((operation,i)=>{res.owner_price_operations[i] = this._overrideOperation(operation);});
  616. this.selectedModel.operation = res.owner_price_operations;
  617. }
  618. if (res.owner_price_expresses.length>0){
  619. this._loadExpress();
  620. res.owner_price_expresses.forEach((express,i)=>{
  621. res.owner_price_expresses[i] = this._overrideExpress(express);
  622. this.upList['express-item-'+i] = true;
  623. });
  624. this.selectedModel.express = res.owner_price_expresses;
  625. }
  626. if (res.owner_price_logistics.length>0){
  627. if (res.owner_price_expresses.length===0)this._loadLogistic();
  628. else {this._getUnits();this._getCities();}
  629. res.owner_price_logistics.forEach((logistic,i)=>{
  630. res.owner_price_logistics[i] = this._overrideLogistic(logistic);
  631. this.upList['logistic-item-'+i] = true;
  632. });
  633. this.selectedModel.logistic = res.owner_price_logistics;
  634. }
  635. if (res.owner_price_direct_logistics.length>0){
  636. this._loadDirectLogistic();
  637. this.upList["directLogistic-item"] = true;
  638. this.selectedModel.directLogistic = this._overrideDirectLogistic(res.owner_price_direct_logistics[0]);
  639. }
  640. if (res.owner_price_system)this.selectedModel.system = res.owner_price_system;
  641. setTimeout(()=> {
  642. $(".up").slideUp();
  643. this.isLoad = true;
  644. },0)
  645. });
  646. },
  647. //加载仓储所需基础信息
  648. _loadStorage(){
  649. if (!this.pool.units)this._getUnits();
  650. if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
  651. if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
  652. },
  653. //加载作业
  654. _loadOperation(){
  655. if (!this.pool.units)this._getUnits();
  656. },
  657. //加载快递
  658. _loadExpress(){
  659. if (!this.pool.provinces)this._getProvinces();
  660. if (!this.pool.logistics)this._getLogistics();
  661. },
  662. //加载物流
  663. _loadLogistic(){
  664. if (!this.pool.units) this._getUnits();
  665. if (!this.pool.provinces)this._getProvinces();
  666. if (!this.pool.cities)this._getCities();
  667. if (!this.pool.logistics)this._getLogistics();
  668. },
  669. //加载直发车
  670. _loadDirectLogistic(){
  671. if (!this.pool.cars)this._getCars();
  672. },
  673. //加载引入
  674. loadIntroduce(){
  675. if (!this.pool.owners)this._getOwners();
  676. if (!this.pool.logistics)this._getLogistics();
  677. },
  678. _setModelData(key,val,column='name',append=""){
  679. if (!val)return;
  680. let mapping = [];
  681. val.forEach(item=>{
  682. mapping[item.id] = item[column]+append;
  683. });
  684. this.$set(this.pool,key,val);
  685. this.$set(this.poolMapping,key,mapping);
  686. },
  687. //获取项目
  688. _getOwners(){
  689. let url = "{{url('maintenance/owner/get')}}";
  690. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("owners",res);});
  691. },
  692. //获取单位
  693. _getUnits(){
  694. let url = "{{url('maintenance/unit/getUnits')}}";
  695. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("units",res);});
  696. },
  697. //获取省份
  698. _getProvinces(){
  699. let url = "{{url('maintenance/province/get')}}";
  700. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("provinces",res);});
  701. },
  702. //获取城市
  703. _getCities(){
  704. let url = "{{url('maintenance/city/get')}}";
  705. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("cities",res);});
  706. },
  707. //获取承运商
  708. _getLogistics(){
  709. let url = "{{url('maintenance/logistic/get')}}";
  710. window.tempTip.postBasicRequest(url,{type:''},res=>{
  711. this._setModelData("logistics",res);
  712. setTimeout(()=>{
  713. $(".selectpicker").selectpicker('refresh');
  714. },100);
  715. });
  716. },
  717. //获取车型
  718. _getCars(){
  719. let url = "{{url('maintenance/carType/get')}}";
  720. window.axios.post(url).then(res=>{this._setModelData("cars",res.data);});
  721. },
  722. //获取税率
  723. _getTaxRates(){
  724. let url = "{{url('maintenance/taxRate/get')}}";
  725. window.axios.post(url).then(res=>{this._setModelData("taxRates",res.data,"value","%");});
  726. },
  727. //保存模型
  728. saveModel(){
  729. this._clearRefuse();
  730. switch (this.type) {
  731. case "storage":
  732. this._verifyStorage();
  733. break;
  734. case "operation":
  735. this._verifyOperation();
  736. break;
  737. case "express":
  738. this._verifyExpress();
  739. break;
  740. case "logistic":
  741. this._verifyLogistic();
  742. break;
  743. case "directLogistic":
  744. this._verifyDirectLogistic();
  745. break;
  746. case "system":
  747. this._verifySystem();
  748. break;
  749. }
  750. },
  751. _verifySystem(){
  752. if (this.model.system.usage_fee<0){
  753. this.errors = {usage_fee:["费用不得小于0"]};
  754. return;
  755. }
  756. if (!this.model.system.time_unit_id){
  757. this.errors = {time_unit_id:["未选择计时单位"]};
  758. return;
  759. }
  760. if(this.owner.is_tax_exist && !this.model.system.tax_rate_id){
  761. this.errors = {tax_rate_id:["税率不可为空"]};
  762. return;
  763. }
  764. let url = "{{url('maintenance/priceModel/apiStoreSystem')}}";
  765. let params = this.model.system;
  766. params.owner_id = this.ownerTemp.id;
  767. window.tempTip.postBasicRequest(url,params,res=>{
  768. if (res && res.errors){
  769. this.errors = res.errors;
  770. return;
  771. }
  772. this.selectedModel.system = res;
  773. this.model.system = {
  774. usage_fee:"",
  775. };
  776. this.errors = {};
  777. this.audit.system = true;
  778. });
  779. },
  780. _verifyStorage(){
  781. let error = {};
  782. if (!this.model.storage.counting_type)error["counting_type"] = ["未选择计费类型"];
  783. if (!this.model.storage.name)error["name"] = ["未填写名称"];
  784. if (!this.model.storage.using_type)error["using_type"] = ["未选择用仓类型"];
  785. if (!this.model.storage.price[0])error["price.0"] = ["未输入单价"];
  786. if (!this.model.storage.discount_type)error["discount_type"] = ["未选择减免类型"];
  787. if (!this.model.storage.unit_id)error["unit_id"] = ["未选择单位"];
  788. if (!this.model.storage.time_unit_id)error["time_unit_id"] = ["未选择计时单位"];
  789. if(this.owner.is_tax_exist && !this.model.storage.tax_rate_id)error = {tax_rate_id:["税率不可为空"]};
  790. if (this.model.storage.isInterval){
  791. if (this.model.storage.amount_interval.length<1 || this.model.storage.price.length<1){
  792. error["amount_interval.0"] = ["未设定数量区间"];
  793. error["price.0"] = ["未输入单价"];
  794. }else{
  795. this.model.storage.amount_interval.forEach((amount,i)=>{
  796. if (amount==="")error["amount_interval."+i] = ["未设定数量区间"];
  797. else if (i!==0 && Number(amount)<=Number(this.model.storage.amount_interval[i-1]))
  798. error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
  799. this.model.storage.amount_interval[i] = parseFloat(this.model.storage.amount_interval[i]);
  800. });
  801. this.model.storage.price.forEach((price,i)=>{
  802. if (price==="")error["price."+i] = ["未输入单价"];
  803. this.model.storage.price[i] = parseFloat(this.model.storage.price[i]);
  804. });
  805. }
  806. }
  807. if (JSON.stringify(error) !== "{}"){
  808. this.errors = error;
  809. return;
  810. }
  811. if (!this.model.storage.isInterval){
  812. this.model.storage.amount_interval = null;
  813. this.model.storage.price = [parseFloat(this.model.storage.price[0])];
  814. }
  815. let url = "{{url('maintenance/priceModel/apiStoreStorage')}}";
  816. let params = this.model.storage;
  817. params.owner_id = this.ownerTemp.id;
  818. window.tempTip.postBasicRequest(url,params,res=>{
  819. if (res && res.errors){
  820. this.errors = res.errors;
  821. return;
  822. }
  823. if (this.model.storage.id){
  824. if (!res) this.selectedModel.storage[this.model.storage.index] = this.model.storage;
  825. else this.$set(this.selectedModel.storage,this.model.storage.index,res);
  826. }else {
  827. this.model.storage.id = res;
  828. this.selectedModel.storage.unshift(this.model.storage);
  829. }
  830. this.model.storage = {
  831. name : "",
  832. counting_type : "",
  833. using_type : "",
  834. minimum_area : "",
  835. price : [""],
  836. amount_interval : [""],
  837. discount_type : "无减免",
  838. discount_value : "",
  839. unit_id : "",
  840. time_unit_id : "",
  841. };
  842. this.errors = {};
  843. this.audit.storage = true;
  844. return "保存成功";
  845. });
  846. },
  847. _verifyOperation() {
  848. if (this.selectedModel.operation.length>0 && !this.model.operation.id){
  849. if (this.model.operation.strategy!=='特征'){
  850. if (!this.selectedModel.operation.every(operation=>{
  851. if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
  852. this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
  853. this.$forceUpdate();
  854. return false;
  855. }
  856. return true;
  857. }))return;
  858. }
  859. }
  860. if (!this.model.operation.name){
  861. this.$set(this.errors,"name",["名称不得为空"]);
  862. return;
  863. }
  864. if(this.owner.is_tax_exist && !this.model.operation.tax_rate_id){
  865. this.error = {tax_rate_id:["税率不可为空"]};return;
  866. }
  867. if (this.model.operation.isDiscount){
  868. let sign = false;
  869. this.model.operation.discount_count.forEach((item,i)=>{
  870. if (!item || (i!==0 && parseFloat(item)<=parseFloat(this.model.operation.discount_count[i-1]))){
  871. this.$set(this.errors,"discount_count_"+i,["非法满减值"]);
  872. sign = true;
  873. }
  874. });
  875. if (sign){
  876. this.$forceUpdate();
  877. return;
  878. }
  879. }
  880. if (!this.model.operation.isRejected && this.model.operation.strategy === '特征' && !this.model.operation.feature){
  881. this.$set(this.errors,"feature",["特征未填写"]);
  882. return;
  883. }
  884. if (this.model.operation.isSingle && !this.model.operation.total_price){
  885. this.$set(this.errors,"total_price",["按单价格不存在"]);
  886. return;
  887. }
  888. if (this.model.operation.isDiscount && this.model.operation.isSingle){
  889. if (!this.model.operation.total_discount_price[0]){
  890. this.$set(this.errors,"total_discount_price",["满减价格不存在"]);
  891. return;
  892. }
  893. this.model.operation.total_discount_price.forEach((item,i)=>{
  894. if (i!==0 && !item)this.model.operation.total_discount_price[i] = this.model.operation.total_discount_price[i-1];
  895. })
  896. }
  897. if (this.model.operation.surcharge && !this.model.operation.surcharge_unit_id){
  898. this.$set(this.errors,"surcharge_unit_id",["耗材附加费单位未选择"]);
  899. return;
  900. }
  901. if (this.model.operation.surcharge_unit_id && !this.model.operation.surcharge){
  902. this.$set(this.errors,"surcharge_unit_id",["耗材附加费未填写"]);
  903. return;
  904. }
  905. let unit = null;
  906. for (let i=0;i<this.model.operation.items.length;i++){
  907. if (this.model.operation.items[i].amount){
  908. if(!unit)unit = this.model.operation.items[i].unit_id;
  909. else if(unit !== this.model.operation.items[i].unit_id){
  910. this.$set(this.errors,'items.'+i+'.unit_id',["所有子项单位必须一致"]);
  911. return;
  912. }
  913. }
  914. }
  915. if (!this.model.operation.isSingle){
  916. for (let i=0;i<this.model.operation.items.length;i++){
  917. if (this._verifyOperationItem(i))return;
  918. }
  919. this.model.operation.total_discount_price = [];
  920. this.model.operation.total_price = "";
  921. }else this.$set(this.model.operation,"items",[]);
  922. if (!this.model.operation.isDiscount) {
  923. this.model.operation.discount_count = [""];
  924. this.model.operation.total_discount_price = [""];
  925. }
  926. if (this.model.operation.isRejected)this.model.operation.type_mark = 0;
  927. let url = "{{url('maintenance/priceModel/apiStoreOperation')}}";
  928. let params = this.model.operation;
  929. params.owner_id = this.ownerTemp.id;
  930. window.tempTip.postBasicRequest(url,params,res=>{
  931. if (res && res.errors){
  932. if (res.errors.owner_id){
  933. window.tempTip.show(res.errors.owner_id[0]);
  934. return;
  935. }
  936. this.errors = res.errors;
  937. return;
  938. }
  939. res.features = this.model.operation.features;
  940. res.featureFormat = this.model.operation.featureFormat;
  941. for (let i=0;i<res.items.length;i++){
  942. res.items[i].features = this.model.operation.items[i]['features'];
  943. res.items[i].featureFormat = this.model.operation.items[i]['featureFormat'];
  944. res.items[i].type = this.model.operation.items[i]['type'];
  945. res.items[i].discount_price = res.items[i].discount_price ? res.items[i].discount_price.split(",") : [""];
  946. }
  947. if (res.discount_count)res.isDiscount = true;
  948. if (res.total_price)res.isSingle = true;
  949. res.discount_count = res.discount_count ? res.discount_count.split(",") : [""];
  950. res.total_discount_price = res.total_discount_price ? res.total_discount_price.split(",") : [""];
  951. res.isRejected = this.model.operation.type_mark==='0'||this.model.operation.type_mark===0;
  952. if (params.id) this.selectedModel.operation[params.index] = res;
  953. else this.selectedModel.operation.push(res);
  954. this._resetOperation();
  955. this.errors = {};
  956. this.audit.operation = true;
  957. return "保存成功";
  958. });
  959. },
  960. _verifyOperationItem(itemIndex){//验证作业费子项信息完整
  961. let obj = this.model.operation.items[itemIndex];
  962. let sign = false;
  963. if (!this.model.operation.isRejected && obj.strategy === '特征' && !obj.feature) {
  964. this.errors['items.' + itemIndex + '.feature'] = ["必须选择特征"];
  965. sign = true;
  966. }
  967. if (obj.strategy!=='起步' && !obj.amount){
  968. this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
  969. sign = true;
  970. }else if (!obj.amount) obj.amount = 0;
  971. if (obj.strategy!=='起步' && !obj.unit_id){
  972. this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
  973. sign = true;
  974. }else if (!obj.unit_id) obj.unit_id = 0;
  975. if (!obj.unit_price){
  976. this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
  977. sign = true;
  978. }
  979. if (this.model.operation.isDiscount){
  980. if (!obj.discount_price[0]){
  981. this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
  982. sign = true;
  983. }else{
  984. obj.discount_price.forEach((item,i)=>{
  985. if (i!==0&&!item) obj.discount_price[i]=obj.discount_price[i-1];
  986. })
  987. }
  988. }
  989. if (sign)this.$forceUpdate();
  990. return sign;
  991. },
  992. _verifyExpress(){
  993. let error = {};
  994. if (!this.model.express.name)error.name = ["名称不得为空"];
  995. if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
  996. if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
  997. if(this.owner.is_tax_exist && !this.model.express.tax_rate_id)error = {tax_rate_id:["税率不可为空,子项税率必填"]};
  998. if (this.model.express.items.length>0){
  999. this.model.express.items.forEach((item,index)=>{
  1000. if (!item.province_id)error["items."+index+".province_id"] = ["不存在"];
  1001. if (!this.model.express.isInterval){
  1002. if (!item.initial_weight_price[0][0])error["items."+index+".initial_weight_price.0.0"] = ["不存在"];
  1003. if (!item.additional_weight_price[0][0])error["items."+index+".additional_weight_price.0.0"] = ["不存在"];
  1004. }else{
  1005. this.model.express.amount_interval.forEach((amount,i)=>{
  1006. if (this.model.express.weight_interval[i].length>0){
  1007. this.model.express.weight_interval[i].forEach((weight,j)=>{
  1008. if (!item.initial_weight_price[i][j])error["items."+index+".initial_weight_price."+i+"."+j] = ["费用不存在"];
  1009. else item.initial_weight_price[i][j] = (Number)(item.initial_weight_price[i][j]);
  1010. if (!item.additional_weight_price[i][j])error["items."+index+".additional_weight_price."+i+"."+j] = ["费用不存在"];
  1011. else item.additional_weight_price[i][j] = (Number)(item.additional_weight_price[i][j]);
  1012. })
  1013. }
  1014. });
  1015. }
  1016. });
  1017. }
  1018. if (this.model.express.isInterval){
  1019. this.model.express.amount_interval.forEach((amount,i)=>{
  1020. if (amount==="") error["amount_interval."+i] = ["区间值不得为空"];
  1021. else if (i!==0 && Number(amount)<=Number(this.model.express.amount_interval[i-1]))error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
  1022. if (this.model.express.weight_interval[i].length>0){
  1023. this.model.express.weight_interval[i].forEach((weight,j)=>{
  1024. this.model.express.weight_interval[i][j] = parseFloat(this.model.express.weight_interval[i][j]);
  1025. if (weight==="") error["weight_interval."+i+"."+j] = ["区间值不得为空"];
  1026. else if (j!==0 && Number(weight)<=Number(this.model.express.weight_interval[j-1]))error["weight_interval."+i+"."+j] = ["阶梯区间应大于上一区间值"];
  1027. })
  1028. }
  1029. });
  1030. }
  1031. if (JSON.stringify(error) !== "{}"){
  1032. this.errors = error;
  1033. return;
  1034. }
  1035. if (!this.model.express.isInterval){
  1036. this.model.express.amount_interval = null;
  1037. this.model.express.weight_interval = null;
  1038. if (this.model.express.items.length>0){
  1039. this.model.express.items.forEach((item,i)=>{
  1040. this.model.express.items[i].initial_weight_price = [[parseFloat(item.initial_weight_price[0][0])]];
  1041. this.model.express.items[i].additional_weight_price = [[parseFloat(item.additional_weight_price[0][0])]];
  1042. });
  1043. }
  1044. }
  1045. let url = "{{url('maintenance/priceModel/apiStoreExpress')}}";
  1046. let params = this.model.express;
  1047. params.owner_id = this.ownerTemp.id;
  1048. window.tempTip.postBasicRequest(url,params,res=>{
  1049. if (res && res.errors){
  1050. this.errors = res.errors;
  1051. if (res.errors.owner_id)window.tempTip.show(res.errors.owner_id[0]);
  1052. return;
  1053. }
  1054. if (!this.model.express.amount_interval) this.model.express.amount_interval = [""];
  1055. if (!this.model.express.weight_interval) this.model.express.weight_interval = [[]];
  1056. this.model.express.items.forEach((item,i)=>{
  1057. item.id = res.details[i].id;
  1058. });
  1059. if (this.model.express.id){
  1060. if (res.operation) this.model.express.id = res.id;
  1061. this.selectedModel.express[this.model.express.index] = this.model.express;
  1062. }else{
  1063. this.model.express.id = res.id;
  1064. this.selectedModel.express.unshift(this.model.express);
  1065. }
  1066. this.model.express = {
  1067. name:"",
  1068. initial_weight:"",
  1069. additional_weight:"",
  1070. amount_interval:[""],
  1071. weight_interval:[[]],
  1072. items:[],
  1073. logistics:[],
  1074. };
  1075. this.errors = {};
  1076. this.importError = [];
  1077. $(".selectpicker").filter('.express').selectpicker('val',[]);
  1078. this.audit.express = true;
  1079. return "保存成功";
  1080. });
  1081. },
  1082. _verifyLogistic(){
  1083. let error = {};
  1084. if (!this.model.logistic.name) error.name = ["名称不得为空"];
  1085. if (!this.model.logistic.unit_id) error.unit_id = ["单位一不得为空"];
  1086. if (!this.model.logistic.unit_range) error.unit_range = ["区间值不得为空"];
  1087. if (!this.model.logistic.other_unit_id) error.other_unit_id = ["单位二不得为空"];
  1088. if (!this.model.logistic.other_unit_range) error.other_unit_range = ["区间值不得为空"];
  1089. if(this.owner.is_tax_exist && !this.model.logistic.tax_rate_id)error = {tax_rate_id:["税率不可为空"]};
  1090. if (JSON.stringify(error) !== "{}"){
  1091. this.errors = error;
  1092. return;
  1093. }
  1094. let url = "{{url('maintenance/priceModel/apiStoreLogistic')}}";
  1095. let params = this.model.logistic;
  1096. params.owner_id = this.ownerTemp.id;
  1097. window.tempTip.postBasicRequest(url,params,res=>{
  1098. if (res && res.errors){
  1099. this.errors = res.errors;
  1100. window.tempTip.show("检查您的子项详情列表是否完整");
  1101. return;
  1102. }
  1103. this.model.logistic.items.forEach((item,i)=>{
  1104. item.id = res.details[i].id;
  1105. });
  1106. if (this.model.logistic.id){
  1107. if (res.operation) this.model.logistic.id = res.id;
  1108. this.selectedModel.logistic[this.model.logistic.index] = this.model.logistic;
  1109. }else {
  1110. this.model.logistic.id = res.id;
  1111. this.selectedModel.logistic.unshift(this.model.logistic);
  1112. }
  1113. this.model.logistic = {
  1114. items:[],
  1115. other_ranges:[],
  1116. ranges:[],
  1117. logistics:[],
  1118. };
  1119. this.errors = {};
  1120. this.importError = [];
  1121. $(".selectpicker").filter('.logistic').selectpicker('val',[]);
  1122. this.audit.logistic = true;
  1123. return "保存成功";
  1124. });
  1125. },
  1126. _verifyDirectLogistic(){
  1127. let error = {};
  1128. if (!this.model.directLogistic.name) error.name = ["名称不得为空"];
  1129. if (!this.model.directLogistic.base_km) error.base_km = ["起步公里数不得为空"];
  1130. if(this.owner.is_tax_exist && !this.model.directLogistic.tax_rate_id)error = {tax_rate_id:["税率不可为空"]};
  1131. if (JSON.stringify(error) !== "{}"){
  1132. this.errors = error;
  1133. return;
  1134. }
  1135. let url = "{{url('maintenance/priceModel/apiStoreDirectLogistic')}}";
  1136. let params = this.model.directLogistic;
  1137. params.owner_id = this.ownerTemp.id;
  1138. window.tempTip.postBasicRequest(url,params,res=>{
  1139. if (res && res.errors){
  1140. this.errors = res.errors;
  1141. return;
  1142. }
  1143. this.model.directLogistic.items.forEach((item,i)=>{
  1144. item.id = res.details[i].id;
  1145. });
  1146. this.model.directLogistic.id = res.id;
  1147. this.selectedModel.directLogistic = this.model.directLogistic;
  1148. this.model.directLogistic = {
  1149. items:[],
  1150. };
  1151. this.errors = {};
  1152. this.importError = [];
  1153. this.audit.directLogistic = true;
  1154. return "保存成功";
  1155. });
  1156. },
  1157. //增加作业费特征子项
  1158. addOperationItem(strategy){
  1159. if (strategy!=='特征' && !this.model.operation.items.every(item=>{
  1160. if (item.strategy===strategy)return false;
  1161. return true;
  1162. }))return;
  1163. this.model.operation.items.push({
  1164. strategy:strategy,
  1165. discount_price:new Array(this.model.operation.discount_count.length).fill(""),
  1166. });
  1167. },
  1168. //删除作业费子项
  1169. delOperationItem(index){
  1170. this.$delete(this.model.operation.items,index);
  1171. },
  1172. //显示特征选择modal
  1173. showAddFeatureModal(index){
  1174. let types = {!! json_encode(\App\Feature::TYPE,JSON_UNESCAPED_UNICODE) !!};
  1175. let typeIn = {!! json_encode(array_keys(\App\Feature::MAPPING['store'])) !!};
  1176. let typeOut = {!! json_encode(array_keys(\App\Feature::MAPPING['order'])) !!};
  1177. let node = {!! json_encode(\App\Feature::TYPE_NODE) !!};
  1178. let temp = [];
  1179. if (this.model.operation.operation_type==='入库'){
  1180. if (index === -1)typeIn.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
  1181. else typeIn.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
  1182. }else{
  1183. if (index === -1)typeOut.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
  1184. else typeOut.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
  1185. }
  1186. this.pool.feature_type = temp;
  1187. if (index === -1){
  1188. if (!this.model.operation.feature){
  1189. this.model.operation.features = this._createFeature();
  1190. this.thisOperationItemIndex = index;
  1191. this.$forceUpdate();
  1192. $("#addFeatureModal").modal("show");
  1193. return;
  1194. }
  1195. if (this.model.operation.features) {
  1196. this.thisOperationItemIndex = index;
  1197. $("#addFeatureModal").modal("show");
  1198. return;
  1199. }
  1200. }else{
  1201. if (!this.model.operation.items[index].feature){
  1202. this.model.operation.items[index].features = this._createFeature();
  1203. this.thisOperationItemIndex = index;
  1204. this.$forceUpdate();
  1205. $("#addFeatureModal").modal("show");
  1206. return;
  1207. }
  1208. if (this.model.operation.items[index].features) {
  1209. this.thisOperationItemIndex = index;
  1210. $("#addFeatureModal").modal("show");
  1211. return;
  1212. }
  1213. }
  1214. let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
  1215. let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
  1216. window.tempTip.postBasicRequest(url,{feature:feature},res=>{
  1217. if (!res || res.length === 0){
  1218. res = this._createFeature();
  1219. }
  1220. if (index === -1) this.model.operation.features = res;
  1221. else this.model.operation.items[index].features = res;
  1222. this.thisOperationItemIndex = index;
  1223. this.$forceUpdate();
  1224. $("#addFeatureModal").modal("show");
  1225. });
  1226. },
  1227. //增加特征
  1228. addFeature(){
  1229. let obj = {
  1230. "strategyGroupStartSign": false,
  1231. "calculation" : "",
  1232. "type" : "",
  1233. "id" : "",
  1234. "logic" : "",
  1235. "describe" : "",
  1236. "strategyGroupEndSign" : false,
  1237. };
  1238. if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
  1239. else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
  1240. this.$forceUpdate();
  1241. },
  1242. _createFeature(){
  1243. return [{
  1244. "strategyGroupStartSign": false,
  1245. "calculation" : "",
  1246. "type" : "",
  1247. "id" : "",
  1248. "logic" : "",
  1249. "describe" : "",
  1250. "strategyGroupEndSign" : false,
  1251. }];
  1252. },
  1253. //删除特征
  1254. delFeature(index) {
  1255. if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
  1256. else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
  1257. this.$forceUpdate();
  1258. },
  1259. //提交特征更新现有
  1260. submitFeature(){
  1261. let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
  1262. let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
  1263. window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
  1264. if (this.thisOperationItemIndex === -1){
  1265. this.model.operation.feature = res.feature;
  1266. this.model.operation.featureFormat = res.featureFormat;
  1267. } else {
  1268. this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
  1269. this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
  1270. this.$forceUpdate();
  1271. }
  1272. $("#addFeatureModal").modal("hide");
  1273. return "已更新特征";
  1274. },true);
  1275. },
  1276. //移入移出时更改长文本显示效果
  1277. textClass(event,isOver){
  1278. event = event.target.children[0];
  1279. if (isOver) event.className = "text-overflow-warp-100";
  1280. else event.className = "cursor-pointer text-overflow-replace-100";
  1281. },
  1282. //展开子策略
  1283. showOperationItem(index){
  1284. let trId = "operation-tr-"+index;
  1285. let itemId = "operation-item-"+index;
  1286. if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
  1287. this.operationItems['_'+index] = false;
  1288. $("#"+itemId).slideUp(undefined,function () {
  1289. $("#"+trId).addClass("d-none");
  1290. });
  1291. }else {
  1292. $("#"+trId).removeClass("d-none");
  1293. this.operationItems['_'+index] = true;
  1294. $("#"+itemId).slideDown();
  1295. }
  1296. this.$forceUpdate();
  1297. },
  1298. //新增快递子项
  1299. addExpressItem(){
  1300. let arr = [];
  1301. this.model.express.amount_interval.forEach((amount,i)=>{
  1302. if (this.model.express.weight_interval[i].length>0){
  1303. let it = [];
  1304. this.model.express.weight_interval[i].forEach(weight=>{
  1305. it.push("");
  1306. });
  1307. arr.push(it);
  1308. }else arr.push([""]);
  1309. });
  1310. let re=[];
  1311. for(let i=0;i<arr.length;i++){
  1312. re.push(arr[i].slice(0));
  1313. }
  1314. this.model.express.items.unshift({
  1315. province_id : "",
  1316. initial_weight_price:arr,
  1317. additional_weight_price:re,
  1318. });
  1319. },
  1320. //删除快递子项
  1321. delExpressItem(index){
  1322. window.tempTip.confirm("确定要删除该子项吗?",res=>{
  1323. this.$delete(this.model.express.items,index);
  1324. })
  1325. },
  1326. //选择文件
  1327. selectFile(id){
  1328. this.importError = [];
  1329. $("#"+id).click();
  1330. },
  1331. _getExpressImportData(index,data){
  1332. let arr = [];
  1333. this.model.express.amount_interval.forEach((amount,i)=>{
  1334. if (this.model.express.weight_interval[i].length>0){
  1335. let it = [];
  1336. this.model.express.weight_interval[i].forEach(weight=>{
  1337. it.push(data[index] ? data[index] : "");
  1338. index++;
  1339. });
  1340. arr.push(it);
  1341. }else {
  1342. arr.push([data[index] ? data[index] : ""]);
  1343. index++;
  1344. }
  1345. });
  1346. return [arr,index];
  1347. },
  1348. //导入快递子项
  1349. importExpress(e){
  1350. let file=e.target.files[0];
  1351. window.tempTip.setDuration(3000);
  1352. if (!file){
  1353. window.tempTip.show("未选择文件");
  1354. return;
  1355. }
  1356. let formData = new FormData();
  1357. formData.append("file",file);
  1358. window.axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  1359. 'Content-Type':'multipart/form-data'
  1360. }).then(res=>{
  1361. if (res.data.success) {
  1362. res.data.data.data.forEach(data=>{
  1363. if(this.model.express.items.every(item=>{
  1364. if (data.province_id === item.province_id)return false;
  1365. return true;
  1366. })){
  1367. if (this.model.express.isInterval){
  1368. let result = this._getExpressImportData(1,data);
  1369. this.model.express.items.push({
  1370. province_id : data[0],
  1371. initial_weight_price:result[0],
  1372. additional_weight_price:this._getExpressImportData(result[1],data)[0],
  1373. });
  1374. }else this.model.express.items.push({
  1375. province_id : data[0],
  1376. initial_weight_price:[[data[1]]],
  1377. additional_weight_price:[[data[2]]],
  1378. });
  1379. }
  1380. });
  1381. this.importError = res.data.data.errors;
  1382. window.tempTip.setDuration(2000);
  1383. window.tempTip.showSuccess("导入成功!");
  1384. return;
  1385. }
  1386. window.tempTip.show(res.data.data);
  1387. }).catch(err=> {
  1388. window.tempTip.show("网络错误:"+err);
  1389. })
  1390. },
  1391. //物流详情列表modal
  1392. showDetailModal() {
  1393. $("#logisticModal").modal("show");
  1394. },
  1395. //新增物流详情
  1396. addLogisticDetail(){
  1397. this.model.logistic.items.unshift({});
  1398. },
  1399. //导入物流详情
  1400. importLogistic(e){
  1401. window.tempTip.setIndex(1099);
  1402. let file=e.target.files[0];
  1403. if (!file){
  1404. window.tempTip.setDuration(3000);
  1405. window.tempTip.show("未选择文件");
  1406. return;
  1407. }
  1408. let formData = new FormData();
  1409. formData.append("file",file);
  1410. window.axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  1411. 'Content-Type':'multipart/form-data'
  1412. }).then(res=>{
  1413. if (res.data.success) {
  1414. res.data.data.forEach(data=>{
  1415. //过滤非已选择单位的数据
  1416. let id = "";
  1417. if (data.unit_id === this.poolMapping.units[this.model.logistic.unit_id]) id = this.model.logistic.unit_id;
  1418. if (data.unit_id === this.poolMapping.units[this.model.logistic.other_unit_id]) id = this.model.logistic.other_unit_id;
  1419. if (id){
  1420. //过滤重复数据
  1421. let unique = this.model.logistic.items.every(item=>{
  1422. if (id === item.unit_id && data.range === item.range
  1423. && data.province_id === item.province_id && data.city_id === item.city_id)return false;
  1424. return true;
  1425. });
  1426. if (unique){
  1427. data.unit_id = id;
  1428. this.model.logistic.items.push(data);
  1429. }
  1430. }
  1431. });
  1432. this.importError = res.data.errors;
  1433. window.tempTip.setDuration(3000);
  1434. window.tempTip.showSuccess("导入成功!");
  1435. return;
  1436. }
  1437. window.tempTip.setDuration(3000);
  1438. window.tempTip.show(res.data.data);
  1439. }).catch(err=> {
  1440. window.tempTip.setDuration(3000);
  1441. window.tempTip.show("网络错误:"+err);
  1442. })
  1443. },
  1444. //删除物流子项
  1445. delLogisticItem(index){
  1446. this.$delete(this.model.logistic.items,index);
  1447. },
  1448. //改变物流区间时改变可选择项
  1449. changeRange(type){
  1450. if (type === 'ranges'){
  1451. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1452. }else{
  1453. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1454. }
  1455. },
  1456. //增加直发车子项
  1457. addDirectLogisticItem(){
  1458. this.model.directLogistic.items.unshift({
  1459. car_type_id : "",
  1460. base_fee:"",
  1461. additional_fee:"",
  1462. });
  1463. },
  1464. //导入直发车子项
  1465. importDirectLogistic(e){
  1466. window.tempTip.setIndex(1099);
  1467. let file=e.target.files[0];
  1468. if (!file){
  1469. window.tempTip.setDuration(3000);
  1470. window.tempTip.show("未选择文件");
  1471. return;
  1472. }
  1473. let formData = new FormData();
  1474. formData.append("file",file);
  1475. window.axios.post('{{url('maintenance/priceModel/directLogistic/import')}}',formData,{
  1476. 'Content-Type':'multipart/form-data'
  1477. }).then(res=>{
  1478. if (res.data.success) {
  1479. if (this.model.directLogistic.items.length > 0){
  1480. res.data.data.forEach(data=>{
  1481. let unique = this.model.directLogistic.items.every(item=>{
  1482. if (item.car_type_id === data.car_type_id)return false;
  1483. return true;
  1484. });
  1485. if (unique) this.model.directLogistic.items.unshift(data);
  1486. });
  1487. }else this.model.directLogistic.items = res.data.data;
  1488. this.importError = res.data.errors;
  1489. window.tempTip.setDuration(3000);
  1490. window.tempTip.showSuccess("导入成功!");
  1491. return;
  1492. }
  1493. window.tempTip.setDuration(3000);
  1494. window.tempTip.show(res.data.data);
  1495. }).catch(err=> {
  1496. window.tempTip.setDuration(3000);
  1497. window.tempTip.show("网络错误:"+err);
  1498. })
  1499. },
  1500. //删除直发车子项
  1501. delDirectLogisticItem(index){
  1502. this.$delete(this.model.directLogistic.items,index);
  1503. },
  1504. //改变客户
  1505. selectOwner(){
  1506. let id = this.owner.customer_id;
  1507. this.customers.some(customer=>{
  1508. if (id === customer.id){
  1509. this.owner.customer_name = customer.name;
  1510. return true;
  1511. }
  1512. });
  1513. },
  1514. //改变小组
  1515. selectGroup(){
  1516. let id = this.owner.owner_group_id;
  1517. this.ownerGroups.some(group=>{
  1518. if (id === group.id){
  1519. this.owner.owner_group_name = group.name;
  1520. return true;
  1521. }
  1522. });
  1523. },
  1524. //获取引入计费模型查询列表搜索
  1525. searchPriceModel(){
  1526. this.isSearch = true;
  1527. switch (this.type) {
  1528. case "storage":
  1529. this._getStoragePriceModel();
  1530. break;
  1531. case "operation":
  1532. this._getOperationPriceModel();
  1533. break;
  1534. case "express":
  1535. this._getExpressPriceModel();
  1536. break;
  1537. case "logistic":
  1538. this._getLogisticPriceModel();
  1539. break;
  1540. case "system":
  1541. this._getSystemPriceModel();
  1542. break;
  1543. default:
  1544. this._getDirectLogisticPriceModel();
  1545. }
  1546. },
  1547. _getStoragePriceModel(){
  1548. let url = "{{url('maintenance/priceModel/apiGetStorage')}}";
  1549. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1550. let result = [];
  1551. let mapping = {};
  1552. res.forEach(model=> {
  1553. let text = model.name+" ("+model.counting_type+"-"+model.using_type+")";
  1554. result.push({id:model.id,text:text});
  1555. mapping[model.id] = {
  1556. name : model.name,
  1557. counting_type : model.counting_type,
  1558. using_type : model.using_type,
  1559. minimum_area : model.minimum_area,
  1560. price : model.price,
  1561. discount_type : model.discount_type,
  1562. discount_value : model.discount_value,
  1563. amount_interval : model.amount_interval ? model.amount_interval : [""],
  1564. isInterval:!!model.amount_interval,
  1565. unit_id : model.unit_id,
  1566. };
  1567. });
  1568. this.searchResult = result;
  1569. this.searchResultMapping = mapping;
  1570. this.isSearch = false;
  1571. });
  1572. },
  1573. _getOperationPriceModel(){
  1574. let url = "{{url('maintenance/priceModel/apiGetOperation')}}";
  1575. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1576. let result = [];
  1577. let mapping = {};
  1578. res.forEach(model=> {
  1579. let text = model.name+" ("+model.operation_type+"-"+model.strategy+")";
  1580. result.push({id:model.id,text:text});
  1581. mapping[model.id] = {
  1582. name : model.name,
  1583. operation_type : model.operation_type,
  1584. strategy : model.strategy,
  1585. feature : model.feature,
  1586. featureFormat : model.featureFormat,
  1587. remark : model.remark,
  1588. type_mark : model.type_mark,
  1589. isRejected : model.type_mark==='0'||model.type_mark===0,
  1590. items:model.items,
  1591. };
  1592. });
  1593. this.searchResult = result;
  1594. this.searchResultMapping = mapping;
  1595. this.isSearch = false;
  1596. });
  1597. },
  1598. _getExpressPriceModel(){
  1599. let url = "{{url('maintenance/priceModel/apiGetExpress')}}";
  1600. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1601. let result = [];
  1602. let mapping = {};
  1603. res.forEach(model=> {
  1604. let text = model.name+" (首重:"+model.initial_weight+"KG 续重:"+model.additional_weight+"KG)";
  1605. result.push({id:model.id,text:text});
  1606. let logistics = [];
  1607. model.logistics.forEach(logistic=>{
  1608. logistics.push(logistic.id);
  1609. });
  1610. let items = [];
  1611. model.details.forEach(item=>{
  1612. items.push({
  1613. province_id:item.province_id,
  1614. initial_weight_price:item.initial_weight_price,
  1615. additional_weight_price:item.additional_weight_price,
  1616. });
  1617. });
  1618. mapping[model.id] = {
  1619. logistics : logistics,
  1620. name:model.name,
  1621. initial_weight:model.initial_weight,
  1622. additional_weight:model.additional_weight,
  1623. amount_interval:model.amount_interval ? model.amount_interval : [""],
  1624. weight_interval:model.weight_interval ? model.weight_interval : [[]],
  1625. isInterval:!!model.amount_interval,
  1626. items:items,
  1627. };
  1628. });
  1629. this.searchResult = result;
  1630. this.searchResultMapping = mapping;
  1631. this.isSearch = false;
  1632. });
  1633. },
  1634. _getSystemPriceModel(){
  1635. this.searchResult = [];
  1636. this.searchResultMapping = [];
  1637. this.isSearch = false;
  1638. },
  1639. _getLogisticPriceModel(){
  1640. let url = "{{url('maintenance/priceModel/apiGetLogistic')}}";
  1641. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1642. let result = [];
  1643. let mapping = {};
  1644. res.forEach(model=> {
  1645. let text = model.name+" (单位一:"+this.poolMapping.units[model.unit_id]+"["+model.unit_range+
  1646. "] 单位二:"+this.poolMapping.units[model.other_unit_id]+"["+model.other_unit_range+"])";
  1647. result.push({id:model.id,text:text});
  1648. let logistics = [];
  1649. model.logistics.forEach(logistic=>{
  1650. logistics.push(logistic.id);
  1651. });
  1652. let items = [];
  1653. model.details.forEach(item=>{
  1654. items.push({
  1655. unit_id:item.unit_id,
  1656. range:item.range,
  1657. province_id:item.province_id,
  1658. city_id:item.city_id,
  1659. unit_price:item.unit_price,
  1660. delivery_fee:item.delivery_fee,
  1661. initial_fee:item.initial_fee,
  1662. initial_amount:item.initial_amount,
  1663. rate:item.rate,
  1664. });
  1665. });
  1666. mapping[model.id] = {
  1667. logistics : logistics,
  1668. name:model.name,
  1669. unit_range:model.unit_range,
  1670. unit_id:model.unit_id,
  1671. other_unit_range:model.other_unit_range,
  1672. other_unit_id:model.other_unit_id,
  1673. pick_up_price:model.pick_up_price,
  1674. fuel_price:model.fuel_price,
  1675. service_price:model.service_price,
  1676. items:items,
  1677. };
  1678. });
  1679. this.searchResult = result;
  1680. this.searchResultMapping = mapping;
  1681. this.isSearch = false;
  1682. });
  1683. },
  1684. _getDirectLogisticPriceModel(){
  1685. let url = "{{url('maintenance/priceModel/apiGetDirectLogistic')}}";
  1686. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1687. let result = [];
  1688. let mapping = {};
  1689. res.forEach(model=> {
  1690. let text = model.name+" (起步数:"+model.base_km+"KM)";
  1691. result.push({id:model.id,text:text});
  1692. let items = [];
  1693. model.details.forEach(item=>{
  1694. items.push({
  1695. car_type_id:item.car_type_id,
  1696. base_fee:item.base_fee,
  1697. additional_fee:item.additional_fee,
  1698. });
  1699. });
  1700. mapping[model.id] = {
  1701. name:model.name,
  1702. base_km:model.base_km,
  1703. items:items,
  1704. };
  1705. });
  1706. this.searchResult = result;
  1707. this.searchResultMapping = mapping;
  1708. this.isSearch = false;
  1709. });
  1710. },
  1711. //提交引入
  1712. submitIntroduce(){
  1713. if (!this.selectedResult || !this.searchResultMapping[this.selectedResult]){
  1714. window.tempTip.setDuration(3000);
  1715. window.tempTip.show("尚未选择引入项,请单击选择列表,如列表为空则无结果");
  1716. return;
  1717. }
  1718. let model = this.searchResultMapping[this.selectedResult];
  1719. switch (this.type) {
  1720. case "storage":
  1721. this.model.storage = model;
  1722. break;
  1723. case "operation":
  1724. this.model.operation = model;
  1725. break;
  1726. case "express":
  1727. this.model.express = model;
  1728. break;
  1729. case "logistic":
  1730. this.model.logistic = model;
  1731. break;
  1732. default:
  1733. this.model.directLogistic = model;
  1734. break;
  1735. }
  1736. $("#introduce").modal('hide');
  1737. window.tempTip.setDuration(2000);
  1738. window.tempTip.showSuccess("引入成功");
  1739. },
  1740. //删除仓储
  1741. delStorage(item,index){
  1742. window.tempTip.confirm("您确定要删除仓储计费“"+item.name+"”吗?",()=>{
  1743. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelStorage')}}",{id:item.id},res=>{
  1744. this.$delete(this.selectedModel.storage,index);
  1745. this.audit.storage = true;
  1746. return "删除“"+item.name+"”成功";
  1747. });
  1748. });
  1749. },
  1750. //删除作业
  1751. delOperation(item,index){
  1752. window.tempTip.confirm("您确定要删除作业计费“"+item.name+"”吗?",()=>{
  1753. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperation')}}",{id:item.id},res=>{
  1754. this.$delete(this.selectedModel.operation,index);
  1755. this.audit.operation = true;
  1756. return "删除“"+item.name+"”成功";
  1757. });
  1758. });
  1759. },
  1760. //删除作业子项
  1761. deleteOperationItem(item,index,parentIndex){
  1762. window.tempTip.confirm("您确定要删除该作业子项吗?",()=>{
  1763. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperationItem')}}",{id:item.id},res=>{
  1764. if (res) this.$set(this.selectedModel.operation,parentIndex,this._overrideOperation(res));
  1765. else this.$delete(this.selectedModel.operation[parentIndex].items,index);
  1766. this.audit.operation = true;
  1767. return "删除成功";
  1768. });
  1769. });
  1770. },
  1771. //删除快递
  1772. delExpress(item,index){
  1773. window.tempTip.confirm("您确定要删除该快递计费“"+item.name+"”吗?",()=>{
  1774. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpress')}}",{id:item.id},res=>{
  1775. this.$delete(this.selectedModel.express,index);
  1776. this.audit.express = true;
  1777. return "删除“"+item.name+"”成功";
  1778. });
  1779. });
  1780. },
  1781. //删除快递子项
  1782. deleteExpressItem(item,index,parentIndex){
  1783. window.tempTip.confirm("您确定要删除该快递计费子项吗?",()=>{
  1784. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpressItem')}}",{id:item.id},res=>{
  1785. if (res) this.$set(this.selectedModel.express,parentIndex,this._overrideExpress(res));
  1786. else this.$delete(this.selectedModel.express[parentIndex].items,index);
  1787. this.audit.express = true;
  1788. return "删除成功";
  1789. });
  1790. });
  1791. },
  1792. //删除物流
  1793. delLogistic(item,index){
  1794. window.tempTip.confirm("您确定要删除该物流计费“"+item.name+"”吗?",()=>{
  1795. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogistic')}}",{id:item.id},res=>{
  1796. this.$delete(this.selectedModel.logistic,index);
  1797. this.audit.logistic = true;
  1798. return "删除“"+item.name+"”成功";
  1799. });
  1800. });
  1801. },
  1802. //删除物流子项
  1803. deleteLogisticItem(item,index,parentIndex){
  1804. window.tempTip.confirm("您确定要删除该物流计费子项吗?",()=>{
  1805. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogisticItem')}}",{id:item.id},res=>{
  1806. if (res) this.$set(this.selectedModel.logistic,parentIndex,this._overrideLogistic(res));
  1807. else this.$delete(this.selectedModel.logistic[parentIndex].items,index);
  1808. this.audit.logistic = true;
  1809. return "删除成功";
  1810. });
  1811. });
  1812. },
  1813. //删除直发车
  1814. delDirectLogistic(item){
  1815. window.tempTip.confirm("您确定要删除该直发车计费“"+item.name+"”吗?",()=>{
  1816. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogistic')}}",{id:item.id},res=>{
  1817. this.selectedModel.directLogistic = {};
  1818. this.audit.directLogistic = true;
  1819. return "删除“"+item.name+"”成功";
  1820. });
  1821. });
  1822. },
  1823. //删除直发车子项
  1824. deleteDirectLogisticItem(item,index){
  1825. window.tempTip.confirm("您确定要删除该直发车计费子项吗?",()=>{
  1826. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogisticItem')}}",{id:item.id},res=>{
  1827. if (res) this.$set(this.selectedModel,"directLogistic",this._overrideDirectLogistic(res));
  1828. else this.$delete(this.selectedModel.directLogistic.items,index);
  1829. this.audit.directLogistic = true;
  1830. return "删除成功";
  1831. });
  1832. });
  1833. },
  1834. //删除系统
  1835. deleteSystem(item){
  1836. window.tempTip.confirm("您确定要删除该系统计费吗?",()=>{
  1837. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelSystem')}}",{id:item.id},res=>{
  1838. this.$set(this.selectedModel,"system",{usage_fee:""});
  1839. this.audit.system = true;
  1840. return "删除成功";
  1841. });
  1842. });
  1843. },
  1844. //编辑仓储
  1845. editStorage(index){
  1846. this.switchType("storage");
  1847. this.model.storage = JSON.parse(JSON.stringify(this.selectedModel.storage[index]));
  1848. this.model.storage.index = index;
  1849. if (this.model.storage.amount_interval)this.model.storage.isInterval = true;
  1850. },
  1851. //编辑作业
  1852. editOperation(index){
  1853. this.switchType("operation");
  1854. this.model.operation = JSON.parse(JSON.stringify(this.selectedModel.operation[index]));
  1855. this.model.operation.index = index;
  1856. },
  1857. //编辑快递
  1858. editExpress(index){
  1859. this.switchType("express");
  1860. this.model.express = JSON.parse(JSON.stringify(this.selectedModel.express[index]));
  1861. this.model.express.index = index;
  1862. },
  1863. //编辑物流
  1864. editLogistic(index){
  1865. this.switchType("logistic");
  1866. this.model.logistic = JSON.parse(JSON.stringify(this.selectedModel.logistic[index]));
  1867. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1868. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1869. this.model.logistic.index = index;
  1870. },
  1871. //编辑直发车
  1872. editDirectLogistic(){
  1873. this.switchType("directLogistic");
  1874. this.model.directLogistic = JSON.parse(JSON.stringify(this.selectedModel.directLogistic));
  1875. },
  1876. //编辑系统
  1877. editSystem(){
  1878. this.switchType("system");
  1879. this.model.system = JSON.parse(JSON.stringify(this.selectedModel.system));
  1880. },
  1881. //搜索快递子项
  1882. searchExpress(e){
  1883. let val = e.target.value;
  1884. if (!val){
  1885. this.$set(this.searchItem,'express',null);
  1886. return;
  1887. }
  1888. let items = [];
  1889. this.model.express.items.forEach((item,i)=>{
  1890. if (this.poolMapping.provinces[item.province_id].indexOf(val) !== -1)items.push(i);
  1891. });
  1892. this.$set(this.searchItem,'express',items);
  1893. },
  1894. //搜索直发子项
  1895. searchDirectLogistic(e){
  1896. let val = e.target.value;
  1897. if (!val){
  1898. this.$set(this.searchItem,'directLogistic',null);
  1899. return;
  1900. }
  1901. let items = [];
  1902. this.model.directLogistic.items.forEach((item,i)=>{
  1903. if (this.poolMapping.cars[item.car_type_id].indexOf(val) !== -1)items.push(i);
  1904. });
  1905. this.$set(this.searchItem,'directLogistic',items);
  1906. },
  1907. //搜索物流子项
  1908. searchLogistic(e){
  1909. let val = e.target.value;
  1910. if (!val){
  1911. this.$set(this.searchItem,'logistic',null);
  1912. return;
  1913. }
  1914. let items = [];
  1915. this.model.logistic.items.forEach((item,i)=>{
  1916. if (item.unit_id || item.province_id || item.city_id){
  1917. if ((item.unit_id && this.poolMapping.units[item.unit_id].indexOf(val) !== -1) ||
  1918. (item.province_id && this.poolMapping.provinces[item.province_id].indexOf(val) !== -1) ||
  1919. (item.city_id && this.poolMapping.cities[item.city_id].indexOf(val) !== -1))items.push(i);
  1920. }
  1921. });
  1922. this.$set(this.searchItem,'logistic',items);
  1923. },
  1924. //增加阶梯满减阈值
  1925. addDiscount(arr){
  1926. this.model.operation.items.forEach(item=>{
  1927. item.discount_price.push('');
  1928. });
  1929. this.model.operation.total_discount_price.push("");
  1930. arr.push('');
  1931. },
  1932. //开启满减
  1933. onDiscount(type){
  1934. if (!type)return;
  1935. if (this.model.operation.discount_count.length===1) this.model.operation.discount_count = ["0"];
  1936. if (this.model.operation.discount_count.length===0) this.model.operation.discount_count = ["0"];
  1937. },
  1938. //删除阶梯满减阈值
  1939. delDiscount(index){
  1940. this.model.operation.items.forEach((item,i)=>{
  1941. delete item.discount_price[index];
  1942. this.$set(this.model.operation.items,i,item);
  1943. });
  1944. this.$delete(this.model.operation.total_discount_price,index);
  1945. this.$delete(this.model.operation.discount_count,index);
  1946. },
  1947. //审核或恢复
  1948. auditOrRecoverModel(type,isAudit = true){
  1949. this.getPriceModelAudit(type,isAudit);
  1950. this.selectedAudit = type;
  1951. this.isAudit = isAudit;
  1952. setTimeout(function () {
  1953. $("#auditOrRecover").modal("show");
  1954. },100);
  1955. },
  1956. exeAuditOrRecoverModel(){
  1957. let url = "{{url('maintenance/priceModel/auditOrRecoverModel')}}";
  1958. let type = this.selectedAudit;
  1959. let isAudit = this.isAudit;
  1960. let param = {owner_id:this.ownerTemp.id,type:type,isAudit:isAudit};
  1961. window.tempTip.postBasicRequest(url,param,res=>{
  1962. switch (type){
  1963. case "storage":
  1964. this.selectedModel.storage = res;
  1965. break;
  1966. case "operation":
  1967. this._loadOperation();
  1968. res.forEach((operation,i)=>{res[i] = this._overrideOperation(operation);});
  1969. this.selectedModel.operation = res;
  1970. break;
  1971. case "express":
  1972. this._loadExpress();
  1973. res.forEach((express,i)=>{
  1974. res[i] = this._overrideExpress(express);
  1975. this.upList['express-item-'+i] = true;
  1976. });
  1977. this.selectedModel.express = res;
  1978. break;
  1979. case "logistic":
  1980. this._loadLogistic();
  1981. res.forEach((logistic,i)=>{
  1982. res[i] = this._overrideLogistic(logistic);
  1983. this.upList['logistic-item-'+i] = true;
  1984. });
  1985. this.selectedModel.logistic = res;
  1986. break;
  1987. case "directLogistic":
  1988. this._loadDirectLogistic();
  1989. this.upList["directLogistic-item"] = true;
  1990. this.selectedModel.directLogistic = this._overrideDirectLogistic(res[0]);
  1991. break;
  1992. case "system":
  1993. this.selectedModel.system = res;
  1994. break;
  1995. }
  1996. this.$set(this.audit,type,false);
  1997. $("#auditOrRecover").modal("hide");
  1998. return (isAudit ? '审核' : '恢复')+"成功!";
  1999. },true)
  2000. },
  2001. //增加数量区间
  2002. addStoreAmount(){
  2003. this.model.storage.amount_interval.push("");
  2004. this.model.storage.price.push("");
  2005. },
  2006. //删除数量区间
  2007. delStoreAmount(index){
  2008. if (this.model.storage.amount_interval.length<2)return;
  2009. this.$delete(this.model.storage.amount_interval,index);
  2010. this.$delete(this.model.storage.price,index);
  2011. },
  2012. //增加快递数量区间
  2013. addExpressAmount(){
  2014. this.model.express.amount_interval.push("");
  2015. this.model.express.weight_interval.push([]);
  2016. if (this.model.express.items.length>0){
  2017. this.model.express.items.forEach((item,i)=>{
  2018. if (this.model.express.items[i]["initial_weight_price"])this.model.express.items[i]["initial_weight_price"].push([""]);
  2019. else this.$set(this.model.express.items[i],"initial_weight_price",[[""]]);
  2020. if (this.model.express.items[i]["additional_weight_price"])this.model.express.items[i]["additional_weight_price"].push([""]);
  2021. else this.$set(this.model.express.items[i],"additional_weight_price",[[""]]);
  2022. })
  2023. }
  2024. },
  2025. //增加快递重量区间
  2026. addExpressWeight(index){
  2027. this.model.express.weight_interval[index].push("");
  2028. if (!this.model.express.maxDom || this.model.express.weight_interval[index].length > this.model.express.maxDom)
  2029. this.$set(this.model.express,'maxDom',this.model.express.weight_interval[index].length);
  2030. },
  2031. //删除快递数量区间
  2032. delExpressAmount(){
  2033. let len = this.model.express.amount_interval.length;
  2034. if (len>1){
  2035. this.$delete(this.model.express.amount_interval,len-1);
  2036. this.$delete(this.model.express.weight_interval,len-1);
  2037. if (this.model.express.items.length>0){
  2038. this.model.express.items.forEach((item,i)=>{
  2039. this.$delete(this.model.express.items[i]["initial_weight_price"],len-1);
  2040. this.$delete(this.model.express.items[i]["additional_weight_price"],len-1);
  2041. })
  2042. }
  2043. }
  2044. },
  2045. //删除快递重量区间
  2046. delExpressWeight(index){
  2047. let len = this.model.express.weight_interval[index].length;
  2048. this.$delete(this.model.express.weight_interval[index],len-1);
  2049. if (this.model.express.items.length>0){
  2050. this.model.express.items.forEach((item,i)=>{
  2051. this.$delete(this.model.express.items[i]["initial_weight_price"][index],len-1);
  2052. this.$delete(this.model.express.items[i]["additional_weight_price"][index],len-1);
  2053. })
  2054. }
  2055. },
  2056. filterCustomer(e){
  2057. let value = e.target.value;
  2058. if (!value)this.owner.customer_id = "";
  2059. this.customers.some(customer=>{
  2060. if (customer.name.indexOf(value)!==-1){
  2061. this.owner.customer_id = customer.id;
  2062. return true;
  2063. }
  2064. });
  2065. },
  2066. filterOwnerGroup(e){
  2067. let value = e.target.value;
  2068. if (!value)this.owner.owner_group_id = "";
  2069. this.ownerGroups.some(ownerGroup=>{
  2070. if (ownerGroup.name.indexOf(value)!==-1){
  2071. this.owner.owner_group_id = ownerGroup.id;
  2072. return true;
  2073. }
  2074. });
  2075. },
  2076. filterkc(e){
  2077. let value = e.target.value;
  2078. if (!value)this.owner.kc = "";
  2079. this.userGroups.some(userGroup=>{
  2080. if (userGroup.name.indexOf(value)!==-1){
  2081. this.owner.kc = userGroup.id;
  2082. return true;
  2083. }
  2084. });
  2085. },
  2086. filterjg(e){
  2087. let value = e.target.value;
  2088. if (!value)this.owner.jg = "";
  2089. this.userGroups.some(userGroup=>{
  2090. if (userGroup.name.indexOf(value)!==-1){
  2091. this.owner.jg = userGroup.id;
  2092. return true;
  2093. }
  2094. });
  2095. },
  2096. filterth(e){
  2097. let value = e.target.value;
  2098. if (!value)this.owner.th = "";
  2099. this.userGroups.some(userGroup=>{
  2100. if (userGroup.name.indexOf(value)!==-1){
  2101. this.owner.th = userGroup.id;
  2102. return true;
  2103. }
  2104. });
  2105. },
  2106. filtersh(e){
  2107. let value = e.target.value;
  2108. if (!value)this.owner.sh = "";
  2109. this.userGroups.some(userGroup=>{
  2110. if (userGroup.name.indexOf(value)!==-1){
  2111. this.owner.sh = userGroup.id;
  2112. return true;
  2113. }
  2114. });
  2115. },
  2116. filterfh(e){
  2117. let value = e.target.value;
  2118. if (!value)this.owner.fh = "";
  2119. this.userGroups.some(userGroup=>{
  2120. if (userGroup.name.indexOf(value)!==-1){
  2121. this.owner.fh = userGroup.id;
  2122. return true;
  2123. }
  2124. });
  2125. },
  2126. getPriceModelAudit(type,isAudit){
  2127. this.showAuditPiece = {
  2128. "C":false,"D":false,"U":false
  2129. };
  2130. this.auditList[type] = {};
  2131. let url="{{url('maintenance/priceModel/getPriceModelAudit')}}";
  2132. this.comparisonTemp = {};
  2133. switch (type) {
  2134. case "storage":
  2135. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2136. if (!res)return;
  2137. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonStorage(res[i],isAudit);
  2138. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonStorage(res[i],isAudit);
  2139. });
  2140. break;
  2141. case "operation":
  2142. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2143. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonOperation(res[i],isAudit);
  2144. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonOperation(res[i],isAudit);
  2145. });
  2146. break;
  2147. case "express":
  2148. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2149. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonExpress(res[i],isAudit);
  2150. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonExpress(res[i],isAudit);
  2151. });
  2152. break;
  2153. case "logistic":
  2154. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2155. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonLogistic(res[i],isAudit);
  2156. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonLogistic(res[i],isAudit);
  2157. });
  2158. break;
  2159. case "directLogistic":
  2160. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2161. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonDirectLogistic(res[i],isAudit);
  2162. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonDirectLogistic(res[i],isAudit);
  2163. });
  2164. break;
  2165. case "system":
  2166. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2167. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonSystem(res[i],isAudit);
  2168. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonSystem(res[i],isAudit);
  2169. });
  2170. break;
  2171. }
  2172. },
  2173. _pushAuditList(model,type,data){
  2174. if (this.auditList[model][type]){
  2175. this.auditList[model][type].push(data);
  2176. }else{
  2177. this.showAuditPiece[type] = true;
  2178. this.auditList[model][type] = [data];
  2179. }
  2180. },
  2181. _reverseAuditComparison(operation){
  2182. switch (operation) {
  2183. case "C":
  2184. return "D";
  2185. case "D":
  2186. return "C";
  2187. case "U":
  2188. return "";
  2189. default:
  2190. return "U";
  2191. }
  2192. },
  2193. _AuditComparisonStorage(data,isAudit){
  2194. if (!isAudit){
  2195. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2196. data.operation = this._reverseAuditComparison(data.operation);
  2197. }
  2198. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2199. data.time_unit_id = this.poolMapping.units ? this.poolMapping.units[data.time_unit_id] : '';
  2200. data.unit_id = this.poolMapping.units ? this.poolMapping.units[data.unit_id] : '';
  2201. switch (data.operation) {
  2202. case "C":
  2203. this._pushAuditList("storage","C",data);
  2204. break;
  2205. case "D":
  2206. this._pushAuditList("storage","D",data);
  2207. break;
  2208. case "U":
  2209. let result = this._formatComparisonData("storage",data);
  2210. if (result===null) this._pushAuditList("storage","C",data);
  2211. else this._pushAuditList("storage","U",result);
  2212. break;
  2213. default:
  2214. if (!this.auditList.storage.H)this.auditList.storage.H = {};
  2215. this.auditList.storage.H[data.id] = data;
  2216. break;
  2217. }
  2218. },
  2219. _AuditComparisonOperation(data,isAudit){
  2220. if (!isAudit){
  2221. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2222. data.operation = this._reverseAuditComparison(data.operation);
  2223. }
  2224. data.discount_count = data.discount_count ? data.discount_count.split(",") : [];
  2225. data.total_discount_price = data.total_discount_price ? data.total_discount_price.split(",") : [];
  2226. data.surcharge_unit_id = this.poolMapping.units ? this.poolMapping.units[data.surcharge_unit_id] : '';
  2227. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2228. data.items.forEach((item,j)=>{
  2229. data.items[j].discount_price = data.items[j].discount_price ? data.items[j].discount_price.split(",") : [];
  2230. data.items[j].unit_id = this.poolMapping.units ? this.poolMapping.units[data.items[j].unit_id] : '';
  2231. });
  2232. switch (data.operation) {
  2233. case "C":
  2234. this._pushAuditList("operation","C",data);
  2235. break;
  2236. case "D":
  2237. this._pushAuditList("operation","D",data);
  2238. break;
  2239. case "U":
  2240. let result = this._formatComparisonData("operation",data);
  2241. if (result===null) this._pushAuditList("operation","C",data);
  2242. else this._pushAuditList("operation","U",result);
  2243. break;
  2244. default:
  2245. if (!this.auditList.operation.H)this.auditList.operation.H = {};
  2246. this.auditList.operation.H[data.id] = data;
  2247. break;
  2248. }
  2249. },
  2250. _AuditComparisonExpress(data,isAudit){
  2251. if (!isAudit){
  2252. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2253. data.operation = this._reverseAuditComparison(data.operation);
  2254. }
  2255. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2256. data.logistics.forEach((logistic,j)=>{
  2257. data.logistics[j] = logistic.name;
  2258. });
  2259. data.details.forEach((detail,j)=>{
  2260. data.details[j].province_id = this.poolMapping.provinces ? this.poolMapping.provinces[data.details[j].province_id] : '';
  2261. });
  2262. switch (data.operation) {
  2263. case "C":
  2264. this._pushAuditList("express","C",data);
  2265. break;
  2266. case "D":
  2267. this._pushAuditList("express","D",data);
  2268. break;
  2269. case "U":
  2270. let result = this._formatComparisonData("express",data);
  2271. if (result===null) this._pushAuditList("express","C",data);
  2272. else this._pushAuditList("express","U",result);
  2273. break;
  2274. default:
  2275. if (!this.auditList.express.H)this.auditList.express.H = {};
  2276. this.auditList.express.H[data.id] = data;
  2277. break;
  2278. }
  2279. },
  2280. _AuditComparisonLogistic(data,isAudit){
  2281. if (!isAudit){
  2282. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2283. data.operation = this._reverseAuditComparison(data.operation);
  2284. }
  2285. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2286. data.logistics.forEach((logistic,j)=>{
  2287. data.logistics[j] = logistic.name;
  2288. });
  2289. data.other_unit_id = this.poolMapping.units ? this.poolMapping.units[data.other_unit_id] : '';
  2290. data.unit_id = this.poolMapping.units ? this.poolMapping.units[data.unit_id] : '';
  2291. data.unit_range = data.unit_range ? data.unit_range.split(",") : [];
  2292. data.other_unit_range = data.other_unit_range ? data.other_unit_range.split(",") : [];
  2293. data.details.forEach((detail,j)=>{
  2294. data.details[j].province_id = this.poolMapping.provinces ? this.poolMapping.provinces[data.details[j].province_id] : '';
  2295. data.details[j].city_id = this.poolMapping.cities ? this.poolMapping.cities[data.details[j].city_id] : '';
  2296. data.details[j].unit_id = this.poolMapping.units ? this.poolMapping.units[data.details[j].unit_id] : '';
  2297. });
  2298. switch (data.operation) {
  2299. case "C":
  2300. this._pushAuditList("logistic","C",data);
  2301. break;
  2302. case "D":
  2303. this._pushAuditList("logistic","D",data);
  2304. break;
  2305. case "U":
  2306. let result = this._formatComparisonData("logistic",data);
  2307. if (result===null) this._pushAuditList("logistic","C",data);
  2308. else this._pushAuditList("logistic","U",result);
  2309. break;
  2310. default:
  2311. if (!this.auditList.logistic.H)this.auditList.logistic.H = {};
  2312. this.auditList.logistic.H[data.id] = data;
  2313. break;
  2314. }
  2315. },
  2316. _AuditComparisonDirectLogistic(data,isAudit){
  2317. if (!isAudit){
  2318. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2319. data.operation = this._reverseAuditComparison(data.operation);
  2320. }
  2321. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2322. data.details.forEach((detail,j)=>{
  2323. data.details[j].car_type_id = this.poolMapping.cars ? this.poolMapping.cars[data.details[j].car_type_id] : '';
  2324. });
  2325. switch (data.operation) {
  2326. case "C":
  2327. this._pushAuditList("directLogistic","C",data);
  2328. break;
  2329. case "D":
  2330. this._pushAuditList("directLogistic","D",data);
  2331. break;
  2332. case "U":
  2333. let result = this._formatComparisonData("directLogistic",data);
  2334. if (result===null) this._pushAuditList("directLogistic","C",data);
  2335. else this._pushAuditList("directLogistic","U",result);
  2336. break;
  2337. default:
  2338. if (!this.auditList.directLogistic.H)this.auditList.directLogistic.H = {};
  2339. this.auditList.directLogistic.H[data.id] = data;
  2340. break;
  2341. }
  2342. },
  2343. _AuditComparisonSystem(data,isAudit){
  2344. if (!isAudit){
  2345. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2346. data.operation = this._reverseAuditComparison(data.operation);
  2347. }
  2348. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2349. switch (data.operation) {
  2350. case "C":
  2351. this.auditList.system.C = data;
  2352. this.showAuditPiece.C = true;
  2353. break;
  2354. case "D":
  2355. this.auditList.system.D = data;
  2356. this.showAuditPiece.D = true;
  2357. break;
  2358. case "U":
  2359. if (!this.auditList.system.H){
  2360. this.auditList.system.C = data;
  2361. this.showAuditPiece.C = true;
  2362. }else{
  2363. this.auditList.system.U = data;
  2364. this.showAuditPiece.U = true;
  2365. }
  2366. break;
  2367. default:
  2368. this.auditList.system.H = data;
  2369. break;
  2370. }
  2371. },
  2372. _formatComparisonData(type,data){
  2373. let temp = {"name":"名称"};
  2374. 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>";
  2375. let tar = null;
  2376. let itemTem;
  2377. let items;
  2378. let amount;
  2379. switch (type) {
  2380. case "storage":
  2381. tar = this.auditList.storage.H ? this.auditList.storage.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : null;
  2382. if (!tar)return null;
  2383. for (let key in this.auditList.mapping.storage){
  2384. if (String(data[key])!==String(tar[key])){
  2385. if (!temp[key]) temp[key] = this.auditList.mapping.storage[key];
  2386. data[key] = this.transformData(tar,key)+font+this.transformData(data,key,true)+"</div>";
  2387. }else data[key] = this.transformData(data,key);
  2388. }
  2389. if (String(data["price"])!==String(tar["price"]) && String(data["amount_interval"])===String(tar["amount_interval"])){
  2390. data["amount_interval"] = this.transformData(tar,"amount_interval")+font+this.transformData(data,"amount_interval",true)+"</div>";
  2391. }
  2392. break;
  2393. case "operation":
  2394. temp={"name":"名称",child:{strategy:"子策略"}};
  2395. itemTem = {};
  2396. items=[];
  2397. amount=0;
  2398. tar = this.auditList.operation.H ? this.auditList.operation.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
  2399. if (!tar)return null;
  2400. for (let key in this.auditList.mapping.operation){
  2401. if (String(data[key])!==String(tar[key])){
  2402. if (!temp[key]) temp[key] = this.auditList.mapping.operation[key];
  2403. data[key] = this.transformData(tar,key)+font+this.transformData(data,key,true)+"</div>";
  2404. }else data[key] = this.transformData(data,key);
  2405. }
  2406. tar.items.forEach(item=>{
  2407. if (!itemTem[item.strategy])itemTem[item.strategy] = [];
  2408. itemTem[item.strategy].push(item);
  2409. });
  2410. data.items.forEach(item=>{
  2411. if (itemTem[item.strategy]){
  2412. let mark = true;
  2413. for (let i=0;i<itemTem[item.strategy].length;i++){
  2414. for (let key in this.auditList.mapping.operation.child){
  2415. let oldStr = itemTem[item.strategy][i][key];
  2416. let newStr = item[key];
  2417. if (String(newStr)!==String(oldStr)){
  2418. mark = false;break;
  2419. }
  2420. }
  2421. if (mark){
  2422. item.operation = "H";
  2423. itemTem[item.strategy].splice(i,1);
  2424. if (itemTem[item.strategy].length===0)itemTem[item.strategy] = null;
  2425. break;
  2426. }
  2427. }
  2428. }//去重
  2429. });
  2430. data.items.forEach(item=>{
  2431. if (item.operation!=='H'){
  2432. if (!itemTem[item.strategy]){
  2433. for (let key in this.auditList.mapping.operation.child)item[key] = this.transformData(item,key);
  2434. item.operation = "C";
  2435. items.unshift(item);
  2436. amount++;
  2437. }else{
  2438. let tar = item.strategy;
  2439. for (let key in this.auditList.mapping.operation.child){
  2440. if (String(item[key])!==String(itemTem[tar][0][key])){
  2441. if (!temp.child[key]) temp.child[key] = this.auditList.mapping.operation.child[key];
  2442. item[key] = this.transformData(itemTem[tar][0],key)+font+this.transformData(item,key,true)+"</div>";
  2443. }else item[key] = this.transformData(item,key);
  2444. }
  2445. item.operation = "U";
  2446. items.push(item);
  2447. itemTem[tar].splice(0,1);
  2448. if (itemTem[tar].length===0) itemTem[tar] = null;
  2449. }
  2450. }
  2451. });
  2452. for (let key in itemTem){
  2453. if (itemTem[key]){
  2454. itemTem[key].forEach(item=>{
  2455. for (let key in this.auditList.mapping.operation.child)item[key] = this.transformData(item,key);
  2456. item.operation = "D";
  2457. items.splice(amount,0,item);
  2458. amount++;
  2459. });
  2460. }
  2461. }
  2462. data.items = items;
  2463. break;
  2464. case "express":
  2465. temp={"name":"名称",child:{province_id:"省"}};
  2466. itemTem={};
  2467. items=[];
  2468. amount=0;
  2469. tar = this.auditList.express.H ? this.auditList.express.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : null;
  2470. if (!tar)return null;
  2471. for (let key in this.auditList.mapping.express) {
  2472. if (String(data[key]) !== String(tar[key])) {
  2473. if (!temp[key]) temp[key] = this.auditList.mapping.express[key];
  2474. data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
  2475. } else data[key] = this.transformData(data, key);
  2476. if (String(data["amount_interval"])!==String(tar["amount_interval"]) && String(data["weight_interval"])===String(tar["weight_interval"])){
  2477. data["weight_interval"] = this.transformData(tar,"weight_interval")+font+this.transformData(data,"weight_interval",true)+"</div>";
  2478. }
  2479. }
  2480. tar.details.forEach(item => {itemTem[item.province_id] = item;});
  2481. data.details.forEach(item=>{
  2482. if (!itemTem[item.province_id]){
  2483. for (let key in this.auditList.mapping.express.child)item[key] = this.transformData(item,key);
  2484. item.operation = "C";
  2485. items.unshift(item);
  2486. amount++;
  2487. }else{
  2488. let mark = true;
  2489. for (let key in this.auditList.mapping.express.child){
  2490. if (String(item[key])!==String(itemTem[item.province_id][key])){
  2491. mark = false;break;
  2492. }
  2493. }
  2494. if (!mark){
  2495. let tar = item.province_id;
  2496. for (let key in this.auditList.mapping.express.child) {
  2497. if (String(item[key]) !== String(itemTem[tar][key])) {
  2498. if (!temp.child[key]) temp.child[key] = this.auditList.mapping.express.child[key];
  2499. item[key] = this.transformData(itemTem[tar], key) + font + this.transformData(item, key, true) + "</div>";
  2500. } else item[key] = this.transformData(item, key);
  2501. }
  2502. item.operation = "U";
  2503. items.push(item);
  2504. delete itemTem[tar];
  2505. }else delete itemTem[item.province_id];
  2506. }
  2507. });
  2508. for (let key in itemTem){
  2509. for (let k in this.auditList.mapping.express.child)itemTem[key][k] = this.transformData(itemTem[key],k);
  2510. itemTem[key].operation = "D";
  2511. items.splice(amount,0,itemTem[key]);
  2512. amount++;
  2513. }
  2514. data.details = items;
  2515. break;
  2516. case "logistic":
  2517. temp={name:"名称",child:{province_id:"省份",city_id:"城市"}};
  2518. tar = this.auditList.logistic.H ? this.auditList.logistic.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
  2519. if (!tar)return null;
  2520. for (let key in this.auditList.mapping.logistic) {
  2521. if (String(data[key]) !== String(tar[key])) {
  2522. if (!temp[key]) temp[key] = this.auditList.mapping.logistic[key];
  2523. data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
  2524. } else data[key] = this.transformData(data, key);
  2525. }
  2526. itemTem = this.logisticDataFormat(tar);
  2527. let dataTem = this.logisticDataFormat(data);
  2528. items = [];
  2529. for (let key in itemTem){
  2530. if (dataTem[key]){
  2531. for (let key2 in itemTem[key]){
  2532. if (dataTem[key][key2]){
  2533. for (let key3 in itemTem[key][key2]){
  2534. if (dataTem[key][key2][key3]){
  2535. for (let key4 in itemTem[key][key2][key3]){
  2536. if (dataTem[key][key2][key3][key4]){
  2537. let mark = true;
  2538. for (let key5 in this.auditList.mapping.logistic.child){
  2539. if (String(dataTem[key][key2][key3][key4][key5]) !== String(itemTem[key][key2][key3][key4][key5])){
  2540. if (!temp.child[key5]) temp.child[key5] = this.auditList.mapping.logistic.child[key5];
  2541. mark=false;
  2542. if (!temp.child[key5]) temp.child[key5] = this.auditList.mapping.logistic.child[key5];
  2543. 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>";
  2544. } else dataTem[key][key2][key3][key4][key5] = this.transformData(dataTem[key][key2][key3][key4], key5);
  2545. }
  2546. if (!mark){
  2547. dataTem[key][key2][key3][key4].operation = "U";
  2548. items.push(dataTem[key][key2][key3][key4])
  2549. }
  2550. delete dataTem[key][key2][key3][key4];
  2551. delete itemTem[key][key2][key3][key4];
  2552. }
  2553. }
  2554. }
  2555. }
  2556. }
  2557. }
  2558. }
  2559. }
  2560. dataTem = this.logisticDataRestore(dataTem,"C");
  2561. dataTem.push.apply(dataTem,this.logisticDataRestore(itemTem,"D"));
  2562. dataTem.push.apply(dataTem,items);
  2563. data.details = dataTem;
  2564. break;
  2565. case "directLogistic":
  2566. temp={name:"名称",child:{car_type_id:"车型"}};
  2567. itemTem={};
  2568. items=[];
  2569. amount=0;
  2570. tar = this.auditList.directLogistic.H ? this.auditList.directLogistic.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
  2571. if (!tar)return null;
  2572. for (let key in this.auditList.mapping.directLogistic) {
  2573. if (String(data[key]) !== String(tar[key])) {
  2574. if (!temp[key]) temp[key] = this.auditList.mapping.directLogistic[key];
  2575. data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
  2576. } else data[key] = this.transformData(data, key);
  2577. }
  2578. tar.details.forEach(item => {itemTem[item.car_type_id] = item;});
  2579. data.details.forEach(item => {
  2580. if (itemTem[item.car_type_id]){
  2581. let car = item.car_type_id;
  2582. let mark = true;
  2583. for (let key in this.auditList.mapping.directLogistic.child) {
  2584. if (String(item[key]) !== String(itemTem[car][key])) {
  2585. mark = false;
  2586. if (!temp.child[key]) temp.child[key] = this.auditList.mapping.directLogistic.child[key];
  2587. item[key] = this.transformData(itemTem[car], key) + font + this.transformData(item, key, true) + "</div>";
  2588. } else item[key] = this.transformData(item, key);
  2589. }
  2590. if (!mark){
  2591. item.operation = "U";
  2592. items.push(item);
  2593. }
  2594. delete itemTem[car];
  2595. }else{
  2596. item.operation = "C";
  2597. items.unshift(item);
  2598. amount++;
  2599. }
  2600. for (let key in itemTem){
  2601. for (let k in this.auditList.mapping.directLogistic.child)itemTem[key][k] = this.transformData(itemTem[key],k);
  2602. itemTem[key].operation = "D";
  2603. items.splice(amount,0,itemTem[key]);
  2604. amount++;
  2605. }
  2606. });
  2607. data.details = items;
  2608. break;
  2609. }
  2610. this.auditList.mapping[type] = temp;
  2611. return data;
  2612. },
  2613. transformData(data,key,font=false){
  2614. let html = '<div class="float-left small ';
  2615. if (font)html += "text-primary font-weight-bold";
  2616. else html += "text-secondary";
  2617. html+='">';
  2618. if (!data[key])return html+"无</div>";
  2619. switch (key) {
  2620. case "amount_interval":
  2621. data[key].forEach((am,i)=>{
  2622. if (i!==data[key].length-1) html += "<span>"+am+"-"+data[key][i+1]+"("+data["price"][i]+"元)<br></span>";
  2623. });
  2624. html += "<span>"+data[key][data[key].length-1]+" +("+data["price"][data[key].length-1]+"元)<br></span></div>";
  2625. return html;
  2626. case "total_discount_price":
  2627. data[key].forEach(am=>{
  2628. html += '<span>'+am+'元<br></span>'
  2629. });
  2630. return html+"</div>";
  2631. case "discount_price":
  2632. data[key].forEach(am=>{
  2633. html += '<span>'+am+'元<br></span>'
  2634. });
  2635. return html+"</div>";
  2636. case "discount_count":
  2637. data[key].forEach((am,i)=>{
  2638. if (i!==data[key].length-1)html += '<span>'+am+'-'+data[key][i+1]+'<br></span>'
  2639. });
  2640. html += '<span>'+data[key][data[key].length-1]+'&nbsp;+<br></span>';
  2641. return html+"</div>";
  2642. case "weight_interval":
  2643. data[key].forEach((arr,i)=>{
  2644. if (i!==data[key].length-1) html += '<span>'+data.amount_interval[i]+'-'+data.amount_interval[i+1]+'/单(';
  2645. arr.forEach((w,j)=>{
  2646. if (j!==arr.length-1)html += w+'-'+arr[j+1]+'/KG,';
  2647. });
  2648. html += (arr[arr.length-1] ? arr[arr.length-1] : 0)+'&nbsp;+/KG)<br></span>';
  2649. });
  2650. html += '<span>'+data.amount_interval[data.amount_interval.length-1]+'&nbsp;+/单(';
  2651. let arr = data.weight_interval[data.weight_interval.length-1];
  2652. arr.forEach((w,j)=>{
  2653. if (j!==arr.length-1)html += w+'-'+arr[j+1]+'/KG,';
  2654. });
  2655. html += (arr[arr.length-1] ? arr[arr.length-1] : 0)+'&nbsp;+/KG)<br></span>';
  2656. return html+"</div>";
  2657. case "initial_weight_price":
  2658. data[key].forEach(arr=>{
  2659. html += "<span class='small'>"+arr+"<br></span>";
  2660. });
  2661. return html+"</div>";
  2662. case "additional_weight_price":
  2663. data[key].forEach(arr=>{
  2664. html += "<span class='small'>"+arr+"<br></span>";
  2665. });
  2666. return html+"</div>";
  2667. case "unit_range":
  2668. data[key].forEach(r=>{
  2669. html += '<span class="small">'+r+'<br></span>';
  2670. });
  2671. return html+"</div>";
  2672. case "other_unit_range":
  2673. data[key].forEach(r=>{
  2674. html += '<span class="small">'+r+'<br></span>';
  2675. });
  2676. return html+"</div>";
  2677. }
  2678. return html+= data[key]+"</div>";
  2679. },
  2680. logisticDataFormat(tar){
  2681. let obj={};
  2682. tar.details.forEach(item => {
  2683. if (obj[item.province_id]){
  2684. if (obj[item.province_id][item.city_id]){
  2685. if (obj[item.province_id][item.city_id][item.unit_id]){
  2686. obj[item.province_id][item.city_id][item.unit_id][item.range] = item;
  2687. }else{
  2688. let arr1={};
  2689. arr1[item.range] = item;
  2690. obj[item.province_id][item.city_id][item.unit_id] = arr1;
  2691. }
  2692. }else{
  2693. let arr1={};
  2694. arr1[item.range] = item;
  2695. let arr2={};
  2696. arr2[item.unit_id] = arr1;
  2697. obj[item.province_id][item.city_id] = arr2;
  2698. }
  2699. }else{
  2700. let arr1={};
  2701. arr1[item.range] = item;
  2702. let arr2={};
  2703. arr2[item.unit_id] = arr1;
  2704. let arr3={};
  2705. arr3[item.city_id] = arr2;
  2706. obj[item.province_id] = arr3;
  2707. }
  2708. });
  2709. return obj;
  2710. },
  2711. logisticDataRestore(tar,type,items=[],count=0){
  2712. if (count===4){
  2713. tar["operation"] = type;
  2714. items.push(tar);
  2715. } else{
  2716. count++;
  2717. for (let key in tar){
  2718. this.logisticDataRestore(tar[key],type,items,count);
  2719. }
  2720. }
  2721. return items;
  2722. },
  2723. },
  2724. });
  2725. </script>
  2726. @stop