create.blade.php 143 KB

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