create.blade.php 144 KB

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