create.blade.php 143 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641
  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. return "保存成功";
  818. });
  819. },
  820. _verifyOperation() {
  821. if (this.selectedModel.operation.length>0 && !this.model.operation.id){
  822. if (this.model.operation.strategy!=='特征'){
  823. if (!this.selectedModel.operation.every(operation=>{
  824. if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
  825. this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
  826. this.$forceUpdate();
  827. return false;
  828. }
  829. return true;
  830. }))return;
  831. }
  832. }
  833. if (!this.model.operation.name){
  834. this.$set(this.errors,"name",["名称不得为空"]);
  835. return;
  836. }
  837. if (this.model.operation.isDiscount){
  838. let sign = false;
  839. this.model.operation.discount_count.forEach((item,i)=>{
  840. if (!item || (i!==0 && parseFloat(item)<=parseFloat(this.model.operation.discount_count[i-1]))){
  841. this.$set(this.errors,"discount_count_"+i,["非法满减值"]);
  842. sign = true;
  843. }
  844. });
  845. if (sign){
  846. this.$forceUpdate();
  847. return;
  848. }
  849. }
  850. if (!this.model.operation.isRejected && this.model.operation.strategy === '特征' && !this.model.operation.feature){
  851. this.$set(this.errors,"feature",["特征未填写"]);
  852. return;
  853. }
  854. if (this.model.operation.isSingle && !this.model.operation.total_price){
  855. this.$set(this.errors,"total_price",["按单价格不存在"]);
  856. return;
  857. }
  858. if (this.model.operation.isDiscount && this.model.operation.isSingle){
  859. if (!this.model.operation.total_discount_price[0]){
  860. this.$set(this.errors,"total_discount_price",["满减价格不存在"]);
  861. return;
  862. }
  863. this.model.operation.total_discount_price.forEach((item,i)=>{
  864. if (i!==0 && !item)this.model.operation.total_discount_price[i] = this.model.operation.total_discount_price[i-1];
  865. })
  866. }
  867. if (this.model.operation.surcharge && !this.model.operation.surcharge_unit_id){
  868. this.$set(this.errors,"surcharge_unit_id",["耗材附加费单位未选择"]);
  869. return;
  870. }
  871. if (this.model.operation.surcharge_unit_id && !this.model.operation.surcharge){
  872. this.$set(this.errors,"surcharge_unit_id",["耗材附加费未填写"]);
  873. return;
  874. }
  875. if (!this.model.operation.isSingle){
  876. for (let i=0;i<this.model.operation.items.length;i++){
  877. if (this._verifyOperationItem(i))return;
  878. }
  879. this.model.operation.total_discount_price = [];
  880. this.model.operation.total_price = "";
  881. }else this.$set(this.model.operation,"items",[]);
  882. if (!this.model.operation.isDiscount) {
  883. this.model.operation.discount_count = [""];
  884. this.model.operation.total_discount_price = [""];
  885. }
  886. if (this.model.operation.isRejected)this.model.operation.type_mark = 0;
  887. let url = "{{url('maintenance/priceModel/apiStoreOperation')}}";
  888. let params = this.model.operation;
  889. params.owner_id = this.ownerTemp.id;
  890. window.tempTip.postBasicRequest(url,params,res=>{
  891. if (res && res.errors){
  892. if (res.errors.owner_id){
  893. window.tempTip.show(res.errors.owner_id[0]);
  894. return;
  895. }
  896. this.errors = res.errors;
  897. return;
  898. }
  899. res.features = this.model.operation.features;
  900. res.featureFormat = this.model.operation.featureFormat;
  901. for (let i=0;i<res.items.length;i++){
  902. res.items[i].features = this.model.operation.items[i]['features'];
  903. res.items[i].featureFormat = this.model.operation.items[i]['featureFormat'];
  904. res.items[i].type = this.model.operation.items[i]['type'];
  905. res.items[i].discount_price = res.items[i].discount_price ? res.items[i].discount_price.split(",") : [""];
  906. }
  907. if (res.discount_count)res.isDiscount = true;
  908. if (res.total_price)res.isSingle = true;
  909. res.discount_count = res.discount_count ? res.discount_count.split(",") : [""];
  910. res.total_discount_price = res.total_discount_price ? res.total_discount_price.split(",") : [""];
  911. res.isRejected = this.model.operation.type_mark==='0'||this.model.operation.type_mark===0;
  912. if (params.id) this.selectedModel.operation[params.index] = res;
  913. else this.selectedModel.operation.push(res);
  914. this._resetOperation();
  915. this.errors = {};
  916. this.audit.operation = true;
  917. return "保存成功";
  918. });
  919. },
  920. _verifyOperationItem(itemIndex){//验证作业费子项信息完整
  921. let obj = this.model.operation.items[itemIndex];
  922. let sign = false;
  923. if (!this.model.operation.isRejected && obj.strategy === '特征' && !obj.feature) {
  924. this.errors['items.' + itemIndex + '.feature'] = ["必须选择特征"];
  925. sign = true;
  926. }
  927. if (obj.strategy!=='起步' && !obj.amount){
  928. this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
  929. sign = true;
  930. }else if (!obj.amount) obj.amount = 0;
  931. if (obj.strategy!=='起步' && !obj.unit_id){
  932. this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
  933. sign = true;
  934. }else if (!obj.unit_id) obj.unit_id = 0;
  935. if (!obj.unit_price){
  936. this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
  937. sign = true;
  938. }
  939. if (this.model.operation.isDiscount){
  940. if (!obj.discount_price[0]){
  941. this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
  942. sign = true;
  943. }else{
  944. obj.discount_price.forEach((item,i)=>{
  945. if (i!==0&&!item) obj.discount_price[i]=obj.discount_price[i-1];
  946. })
  947. }
  948. }
  949. if (sign)this.$forceUpdate();
  950. return sign;
  951. },
  952. _verifyExpress(){
  953. let error = {};
  954. if (!this.model.express.name)error.name = ["名称不得为空"];
  955. if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
  956. if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
  957. if (this.model.express.items.length>0){
  958. this.model.express.items.forEach((item,index)=>{
  959. if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
  960. if (!this.model.express.isInterval){
  961. if (!item.initial_weight_price[0][0])error["item."+index+".initial_weight_price.0.0"] = ["不存在"];
  962. if (!item.additional_weight_price[0][0])error["item."+index+".additional_weight_price.0.0"] = ["不存在"];
  963. }else{
  964. item.initial_weight_price.forEach((arr,i)=>{
  965. arr.forEach((price,j)=>{
  966. if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
  967. });
  968. });
  969. item.additional_weight_price.forEach((arr,i)=>{
  970. arr.forEach((price,j)=>{
  971. if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
  972. });
  973. });
  974. }
  975. });
  976. }
  977. if (this.model.express.isInterval){
  978. this.model.express.amount_interval.forEach((amount,i)=>{
  979. if (amount==="") error["amount_interval."+i] = ["区间值不得为空"];
  980. else if (i!==0 && amount<=this.model.express.amount_interval[i-1])error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
  981. if (this.model.express.weight_interval[i].length>0){
  982. this.model.express.weight_interval[i].forEach((weight,j)=>{
  983. this.model.express.weight_interval[i][j] = parseFloat(this.model.express.weight_interval[i][j]);
  984. if (weight==="") error["weight_interval."+i+"."+j] = ["区间值不得为空"];
  985. else if (j!==0 && weight<=this.model.express.weight_interval[j-1])error["weight_interval."+i+"."+j] = ["阶梯区间应大于上一区间值"];
  986. })
  987. }
  988. });
  989. }
  990. if (JSON.stringify(error) !== "{}"){
  991. this.errors = error;
  992. return;
  993. }
  994. if (!this.model.express.isInterval){
  995. this.model.express.amount_interval = null;
  996. this.model.express.weight_interval = null;
  997. if (this.model.express.items.length>0){
  998. this.model.express.items.forEach((item,i)=>{
  999. this.model.express.items[i].initial_weight_price = [[parseFloat(item.initial_weight_price[0][0])]];
  1000. this.model.express.items[i].additional_weight_price = [[parseFloat(item.additional_weight_price[0][0])]];
  1001. });
  1002. }
  1003. }
  1004. let url = "{{url('maintenance/priceModel/apiStoreExpress')}}";
  1005. let params = this.model.express;
  1006. params.owner_id = this.ownerTemp.id;
  1007. window.tempTip.postBasicRequest(url,params,res=>{
  1008. if (res && res.errors){
  1009. this.errors = res.errors;
  1010. if (res.errors.owner_id)window.tempTip.show(res.errors.owner_id[0]);
  1011. return;
  1012. }
  1013. if (!this.model.express.amount_interval) this.model.express.amount_interval = [""];
  1014. if (!this.model.express.weight_interval) this.model.express.weight_interval = [[]];
  1015. this.model.express.items.forEach((item,i)=>{
  1016. item.id = res.details[i].id;
  1017. });
  1018. if (this.model.express.id){
  1019. if (res.operation) this.model.express.id = res.id;
  1020. this.selectedModel.express[this.model.express.index] = this.model.express;
  1021. }else{
  1022. this.model.express.id = res.id;
  1023. this.selectedModel.express.unshift(this.model.express);
  1024. }
  1025. this.model.express = {
  1026. name:"",
  1027. initial_weight:"",
  1028. additional_weight:"",
  1029. amount_interval:[""],
  1030. weight_interval:[[]],
  1031. items:[],
  1032. logistics:[],
  1033. };
  1034. this.errors = {};
  1035. this.importError = [];
  1036. $(".selectpicker").filter('.express').selectpicker('val',[]);
  1037. this.audit.express = true;
  1038. return "保存成功";
  1039. });
  1040. },
  1041. _verifyLogistic(){
  1042. let error = {};
  1043. if (!this.model.logistic.name) error.name = ["名称不得为空"];
  1044. if (!this.model.logistic.unit_id) error.unit_id = ["单位一不得为空"];
  1045. if (!this.model.logistic.unit_range) error.unit_range = ["区间值不得为空"];
  1046. if (!this.model.logistic.other_unit_id) error.other_unit_id = ["单位二不得为空"];
  1047. if (!this.model.logistic.other_unit_range) error.other_unit_range = ["区间值不得为空"];
  1048. if (JSON.stringify(error) !== "{}"){
  1049. this.errors = error;
  1050. return;
  1051. }
  1052. let url = "{{url('maintenance/priceModel/apiStoreLogistic')}}";
  1053. let params = this.model.logistic;
  1054. params.owner_id = this.ownerTemp.id;
  1055. window.tempTip.postBasicRequest(url,params,res=>{
  1056. if (res && res.errors){
  1057. this.errors = res.errors;
  1058. window.tempTip.show("检查您的子项详情列表是否完整");
  1059. return;
  1060. }
  1061. this.model.logistic.items.forEach((item,i)=>{
  1062. item.id = res.details[i].id;
  1063. });
  1064. if (this.model.logistic.id){
  1065. if (res.operation) this.model.logistic.id = res.id;
  1066. this.selectedModel.logistic[this.model.logistic.index] = this.model.logistic;
  1067. }else {
  1068. this.model.logistic.id = res.id;
  1069. this.selectedModel.logistic.unshift(this.model.logistic);
  1070. }
  1071. this.model.logistic = {
  1072. items:[],
  1073. other_ranges:[],
  1074. ranges:[],
  1075. logistics:[],
  1076. };
  1077. this.errors = {};
  1078. this.importError = [];
  1079. $(".selectpicker").filter('.logistic').selectpicker('val',[]);
  1080. this.audit.logistic = true;
  1081. return "保存成功";
  1082. });
  1083. },
  1084. _verifyDirectLogistic(){
  1085. let error = {};
  1086. if (!this.model.directLogistic.name) error.name = ["名称不得为空"];
  1087. if (!this.model.directLogistic.base_km) error.base_km = ["起步公里数不得为空"];
  1088. if (JSON.stringify(error) !== "{}"){
  1089. this.errors = error;
  1090. return;
  1091. }
  1092. let url = "{{url('maintenance/priceModel/apiStoreDirectLogistic')}}";
  1093. let params = this.model.directLogistic;
  1094. params.owner_id = this.ownerTemp.id;
  1095. window.tempTip.postBasicRequest(url,params,res=>{
  1096. if (res && res.errors){
  1097. this.errors = res.errors;
  1098. return;
  1099. }
  1100. this.model.directLogistic.items.forEach((item,i)=>{
  1101. item.id = res.details[i].id;
  1102. });
  1103. this.model.directLogistic.id = res.id;
  1104. this.selectedModel.directLogistic = this.model.directLogistic;
  1105. this.model.directLogistic = {
  1106. items:[],
  1107. };
  1108. this.errors = {};
  1109. this.importError = [];
  1110. this.audit.directLogistic = true;
  1111. return "保存成功";
  1112. });
  1113. },
  1114. //增加作业费特征子项
  1115. addOperationItem(strategy){
  1116. if (strategy!=='特征' && !this.model.operation.items.every(item=>{
  1117. if (item.strategy===strategy)return false;
  1118. return true;
  1119. }))return;
  1120. this.model.operation.items.push({
  1121. strategy:strategy,
  1122. discount_price:new Array(this.model.operation.discount_count.length).fill(""),
  1123. });
  1124. },
  1125. //删除作业费子项
  1126. delOperationItem(index){
  1127. this.$delete(this.model.operation.items,index);
  1128. },
  1129. //显示特征选择modal
  1130. showAddFeatureModal(index){
  1131. let types = {!! json_encode(\App\Feature::TYPE,JSON_UNESCAPED_UNICODE) !!};
  1132. let typeIn = {!! json_encode(array_keys(\App\Feature::MAPPING['store'])) !!};
  1133. let typeOut = {!! json_encode(array_keys(\App\Feature::MAPPING['order'])) !!};
  1134. let node = {!! json_encode(\App\Feature::TYPE_NODE) !!};
  1135. let temp = [];
  1136. if (this.model.operation.operation_type==='入库'){
  1137. if (index === -1)typeIn.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
  1138. else typeIn.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
  1139. }else{
  1140. if (index === -1)typeOut.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
  1141. else typeOut.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
  1142. }
  1143. this.pool.feature_type = temp;
  1144. if (index === -1){
  1145. if (!this.model.operation.feature){
  1146. this.model.operation.features = this._createFeature();
  1147. this.thisOperationItemIndex = index;
  1148. this.$forceUpdate();
  1149. $("#addFeatureModal").modal("show");
  1150. return;
  1151. }
  1152. if (this.model.operation.features) {
  1153. this.thisOperationItemIndex = index;
  1154. $("#addFeatureModal").modal("show");
  1155. return;
  1156. }
  1157. }else{
  1158. if (!this.model.operation.items[index].feature){
  1159. this.model.operation.items[index].features = this._createFeature();
  1160. this.thisOperationItemIndex = index;
  1161. this.$forceUpdate();
  1162. $("#addFeatureModal").modal("show");
  1163. return;
  1164. }
  1165. if (this.model.operation.items[index].features) {
  1166. this.thisOperationItemIndex = index;
  1167. $("#addFeatureModal").modal("show");
  1168. return;
  1169. }
  1170. }
  1171. let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
  1172. let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
  1173. window.tempTip.postBasicRequest(url,{feature:feature},res=>{
  1174. if (!res || res.length === 0){
  1175. res = this._createFeature();
  1176. }
  1177. if (index === -1) this.model.operation.features = res;
  1178. else this.model.operation.items[index].features = res;
  1179. this.thisOperationItemIndex = index;
  1180. this.$forceUpdate();
  1181. $("#addFeatureModal").modal("show");
  1182. });
  1183. },
  1184. //增加特征
  1185. addFeature(){
  1186. let obj = {
  1187. "strategyGroupStartSign": false,
  1188. "calculation" : "",
  1189. "type" : "",
  1190. "id" : "",
  1191. "logic" : "",
  1192. "describe" : "",
  1193. "strategyGroupEndSign" : false,
  1194. };
  1195. if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
  1196. else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
  1197. this.$forceUpdate();
  1198. },
  1199. _createFeature(){
  1200. return [{
  1201. "strategyGroupStartSign": false,
  1202. "calculation" : "",
  1203. "type" : "",
  1204. "id" : "",
  1205. "logic" : "",
  1206. "describe" : "",
  1207. "strategyGroupEndSign" : false,
  1208. }];
  1209. },
  1210. //删除特征
  1211. delFeature(index) {
  1212. if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
  1213. else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
  1214. this.$forceUpdate();
  1215. },
  1216. //提交特征更新现有
  1217. submitFeature(){
  1218. let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
  1219. let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
  1220. window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
  1221. if (this.thisOperationItemIndex === -1){
  1222. this.model.operation.feature = res.feature;
  1223. this.model.operation.featureFormat = res.featureFormat;
  1224. } else {
  1225. this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
  1226. this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
  1227. this.$forceUpdate();
  1228. }
  1229. $("#addFeatureModal").modal("hide");
  1230. return "已更新特征";
  1231. },true);
  1232. },
  1233. //移入移出时更改长文本显示效果
  1234. textClass(event,isOver){
  1235. event = event.target.children[0];
  1236. if (isOver) event.className = "text-overflow-warp-100";
  1237. else event.className = "cursor-pointer text-overflow-replace-100";
  1238. },
  1239. //展开子策略
  1240. showOperationItem(index){
  1241. let trId = "operation-tr-"+index;
  1242. let itemId = "operation-item-"+index;
  1243. if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
  1244. this.operationItems['_'+index] = false;
  1245. $("#"+itemId).slideUp(undefined,function () {
  1246. $("#"+trId).addClass("d-none");
  1247. });
  1248. }else {
  1249. $("#"+trId).removeClass("d-none");
  1250. this.operationItems['_'+index] = true;
  1251. $("#"+itemId).slideDown();
  1252. }
  1253. this.$forceUpdate();
  1254. },
  1255. //新增快递子项
  1256. addExpressItem(){
  1257. let arr = [];
  1258. this.model.express.amount_interval.forEach((amount,i)=>{
  1259. if (this.model.express.weight_interval[i].length>0){
  1260. let it = [];
  1261. this.model.express.weight_interval[i].forEach(weight=>{
  1262. it.push("");
  1263. });
  1264. arr.push(it);
  1265. }else arr.push([""]);
  1266. });
  1267. let re=[];
  1268. for(let i=0;i<arr.length;i++){
  1269. re.push(arr[i].slice(0));
  1270. }
  1271. this.model.express.items.unshift({
  1272. province_id : "",
  1273. initial_weight_price:arr,
  1274. additional_weight_price:re,
  1275. });
  1276. },
  1277. //删除快递子项
  1278. delExpressItem(index){
  1279. window.tempTip.confirm("确定要删除该子项吗?",res=>{
  1280. this.$delete(this.model.express.items,index);
  1281. })
  1282. },
  1283. //选择文件
  1284. selectFile(id){
  1285. this.importError = [];
  1286. $("#"+id).click();
  1287. },
  1288. _getExpressImportData(index,data){
  1289. let arr = [];
  1290. this.model.express.amount_interval.forEach((amount,i)=>{
  1291. if (this.model.express.weight_interval[i].length>0){
  1292. let it = [];
  1293. this.model.express.weight_interval[i].forEach(weight=>{
  1294. it.push(data[index] ? data[index] : "");
  1295. index++;
  1296. });
  1297. arr.push(it);
  1298. }else {
  1299. arr.push([data[index] ? data[index] : ""]);
  1300. index++;
  1301. }
  1302. });
  1303. return [arr,index];
  1304. },
  1305. //导入快递子项
  1306. importExpress(e){
  1307. let file=e.target.files[0];
  1308. window.tempTip.setDuration(3000);
  1309. if (!file){
  1310. window.tempTip.show("未选择文件");
  1311. return;
  1312. }
  1313. let formData = new FormData();
  1314. formData.append("file",file);
  1315. window.axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  1316. 'Content-Type':'multipart/form-data'
  1317. }).then(res=>{
  1318. if (res.data.success) {
  1319. res.data.data.data.forEach(data=>{
  1320. if(this.model.express.items.every(item=>{
  1321. if (data.province_id === item.province_id)return false;
  1322. return true;
  1323. })){
  1324. if (this.model.express.isInterval){
  1325. let result = this._getExpressImportData(1,data);
  1326. this.model.express.items.push({
  1327. province_id : data[0],
  1328. initial_weight_price:result[0],
  1329. additional_weight_price:this._getExpressImportData(result[1],data)[0],
  1330. });
  1331. }else this.model.express.items.push({
  1332. province_id : data[0],
  1333. initial_weight_price:[[data[1]]],
  1334. additional_weight_price:[[data[2]]],
  1335. });
  1336. }
  1337. });
  1338. this.importError = res.data.data.errors;
  1339. window.tempTip.setDuration(2000);
  1340. window.tempTip.showSuccess("导入成功!");
  1341. return;
  1342. }
  1343. window.tempTip.show(res.data.data);
  1344. }).catch(err=> {
  1345. window.tempTip.show("网络错误:"+err);
  1346. })
  1347. },
  1348. //物流详情列表modal
  1349. showDetailModal() {
  1350. $("#logisticModal").modal("show");
  1351. },
  1352. //新增物流详情
  1353. addLogisticDetail(){
  1354. this.model.logistic.items.unshift({});
  1355. },
  1356. //导入物流详情
  1357. importLogistic(e){
  1358. window.tempTip.setIndex(1099);
  1359. let file=e.target.files[0];
  1360. if (!file){
  1361. window.tempTip.setDuration(3000);
  1362. window.tempTip.show("未选择文件");
  1363. return;
  1364. }
  1365. let formData = new FormData();
  1366. formData.append("file",file);
  1367. window.axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  1368. 'Content-Type':'multipart/form-data'
  1369. }).then(res=>{
  1370. if (res.data.success) {
  1371. res.data.data.forEach(data=>{
  1372. //过滤非已选择单位的数据
  1373. let id = "";
  1374. if (data.unit_id === this.poolMapping.units[this.model.logistic.unit_id]) id = this.model.logistic.unit_id;
  1375. if (data.unit_id === this.poolMapping.units[this.model.logistic.other_unit_id]) id = this.model.logistic.other_unit_id;
  1376. if (id){
  1377. //过滤重复数据
  1378. let unique = this.model.logistic.items.every(item=>{
  1379. if (id === item.unit_id && data.range === item.range
  1380. && data.province_id === item.province_id && data.city_id === item.city_id)return false;
  1381. return true;
  1382. });
  1383. if (unique){
  1384. data.unit_id = id;
  1385. this.model.logistic.items.push(data);
  1386. }
  1387. }
  1388. });
  1389. this.importError = res.data.errors;
  1390. window.tempTip.setDuration(3000);
  1391. window.tempTip.showSuccess("导入成功!");
  1392. return;
  1393. }
  1394. window.tempTip.setDuration(3000);
  1395. window.tempTip.show(res.data.data);
  1396. }).catch(err=> {
  1397. window.tempTip.setDuration(3000);
  1398. window.tempTip.show("网络错误:"+err);
  1399. })
  1400. },
  1401. //删除物流子项
  1402. delLogisticItem(index){
  1403. this.$delete(this.model.logistic.items,index);
  1404. },
  1405. //改变物流区间时改变可选择项
  1406. changeRange(type){
  1407. if (type === 'ranges'){
  1408. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1409. }else{
  1410. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1411. }
  1412. },
  1413. //增加直发车子项
  1414. addDirectLogisticItem(){
  1415. this.model.directLogistic.items.unshift({
  1416. car_type_id : "",
  1417. base_fee:"",
  1418. additional_fee:"",
  1419. });
  1420. },
  1421. //导入直发车子项
  1422. importDirectLogistic(e){
  1423. window.tempTip.setIndex(1099);
  1424. let file=e.target.files[0];
  1425. if (!file){
  1426. window.tempTip.setDuration(3000);
  1427. window.tempTip.show("未选择文件");
  1428. return;
  1429. }
  1430. let formData = new FormData();
  1431. formData.append("file",file);
  1432. window.axios.post('{{url('maintenance/priceModel/directLogistic/import')}}',formData,{
  1433. 'Content-Type':'multipart/form-data'
  1434. }).then(res=>{
  1435. if (res.data.success) {
  1436. if (this.model.directLogistic.items.length > 0){
  1437. res.data.data.forEach(data=>{
  1438. let unique = this.model.directLogistic.items.every(item=>{
  1439. if (item.car_type_id === data.car_type_id)return false;
  1440. return true;
  1441. });
  1442. if (unique) this.model.directLogistic.items.unshift(data);
  1443. });
  1444. }else this.model.directLogistic.items = res.data.data;
  1445. this.importError = res.data.errors;
  1446. window.tempTip.setDuration(3000);
  1447. window.tempTip.showSuccess("导入成功!");
  1448. return;
  1449. }
  1450. window.tempTip.setDuration(3000);
  1451. window.tempTip.show(res.data.data);
  1452. }).catch(err=> {
  1453. window.tempTip.setDuration(3000);
  1454. window.tempTip.show("网络错误:"+err);
  1455. })
  1456. },
  1457. //删除直发车子项
  1458. delDirectLogisticItem(index){
  1459. this.$delete(this.model.directLogistic.items,index);
  1460. },
  1461. //改变客户
  1462. selectOwner(){
  1463. let id = this.owner.customer_id;
  1464. this.customers.some(customer=>{
  1465. if (id === customer.id){
  1466. this.owner.customer_name = customer.name;
  1467. return true;
  1468. }
  1469. });
  1470. },
  1471. //改变小组
  1472. selectGroup(){
  1473. let id = this.owner.owner_group_id;
  1474. this.ownerGroups.some(group=>{
  1475. if (id === group.id){
  1476. this.owner.owner_group_name = group.name;
  1477. return true;
  1478. }
  1479. });
  1480. },
  1481. //获取引入计费模型查询列表搜索
  1482. searchPriceModel(){
  1483. this.isSearch = true;
  1484. switch (this.type) {
  1485. case "storage":
  1486. this._getStoragePriceModel();
  1487. break;
  1488. case "operation":
  1489. this._getOperationPriceModel();
  1490. break;
  1491. case "express":
  1492. this._getExpressPriceModel();
  1493. break;
  1494. case "logistic":
  1495. this._getLogisticPriceModel();
  1496. break;
  1497. case "system":
  1498. this._getSystemPriceModel();
  1499. break;
  1500. default:
  1501. this._getDirectLogisticPriceModel();
  1502. }
  1503. },
  1504. _getStoragePriceModel(){
  1505. let url = "{{url('maintenance/priceModel/apiGetStorage')}}";
  1506. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1507. let result = [];
  1508. let mapping = {};
  1509. res.forEach(model=> {
  1510. let text = model.name+" ("+model.counting_type+"-"+model.using_type+")";
  1511. result.push({id:model.id,text:text});
  1512. mapping[model.id] = {
  1513. name : model.name,
  1514. counting_type : model.counting_type,
  1515. using_type : model.using_type,
  1516. minimum_area : model.minimum_area,
  1517. price : model.price,
  1518. discount_type : model.discount_type,
  1519. discount_value : model.discount_value,
  1520. amount_interval : model.amount_interval ? model.amount_interval : [""],
  1521. isInterval:!!model.amount_interval,
  1522. unit_id : model.unit_id,
  1523. };
  1524. });
  1525. this.searchResult = result;
  1526. this.searchResultMapping = mapping;
  1527. this.isSearch = false;
  1528. });
  1529. },
  1530. _getOperationPriceModel(){
  1531. let url = "{{url('maintenance/priceModel/apiGetOperation')}}";
  1532. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1533. let result = [];
  1534. let mapping = {};
  1535. res.forEach(model=> {
  1536. let text = model.name+" ("+model.operation_type+"-"+model.strategy+")";
  1537. result.push({id:model.id,text:text});
  1538. mapping[model.id] = {
  1539. name : model.name,
  1540. operation_type : model.operation_type,
  1541. strategy : model.strategy,
  1542. feature : model.feature,
  1543. featureFormat : model.featureFormat,
  1544. remark : model.remark,
  1545. type_mark : model.type_mark,
  1546. isRejected : model.type_mark==='0'||model.type_mark===0,
  1547. items:model.items,
  1548. };
  1549. });
  1550. this.searchResult = result;
  1551. this.searchResultMapping = mapping;
  1552. this.isSearch = false;
  1553. });
  1554. },
  1555. _getExpressPriceModel(){
  1556. let url = "{{url('maintenance/priceModel/apiGetExpress')}}";
  1557. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1558. let result = [];
  1559. let mapping = {};
  1560. res.forEach(model=> {
  1561. let text = model.name+" (首重:"+model.initial_weight+"KG 续重:"+model.additional_weight+"KG)";
  1562. result.push({id:model.id,text:text});
  1563. let logistics = [];
  1564. model.logistics.forEach(logistic=>{
  1565. logistics.push(logistic.id);
  1566. });
  1567. let items = [];
  1568. model.details.forEach(item=>{
  1569. items.push({
  1570. province_id:item.province_id,
  1571. initial_weight_price:item.initial_weight_price,
  1572. additional_weight_price:item.additional_weight_price,
  1573. });
  1574. });
  1575. mapping[model.id] = {
  1576. logistics : logistics,
  1577. name:model.name,
  1578. initial_weight:model.initial_weight,
  1579. additional_weight:model.additional_weight,
  1580. amount_interval:model.amount_interval ? model.amount_interval : [""],
  1581. weight_interval:model.weight_interval ? model.weight_interval : [[]],
  1582. isInterval:!!model.amount_interval,
  1583. items:items,
  1584. };
  1585. });
  1586. this.searchResult = result;
  1587. this.searchResultMapping = mapping;
  1588. this.isSearch = false;
  1589. });
  1590. },
  1591. _getSystemPriceModel(){
  1592. this.searchResult = [];
  1593. this.searchResultMapping = [];
  1594. this.isSearch = false;
  1595. },
  1596. _getLogisticPriceModel(){
  1597. let url = "{{url('maintenance/priceModel/apiGetLogistic')}}";
  1598. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1599. let result = [];
  1600. let mapping = {};
  1601. res.forEach(model=> {
  1602. let text = model.name+" (单位一:"+this.poolMapping.units[model.unit_id]+"["+model.unit_range+
  1603. "] 单位二:"+this.poolMapping.units[model.other_unit_id]+"["+model.other_unit_range+"])";
  1604. result.push({id:model.id,text:text});
  1605. let logistics = [];
  1606. model.logistics.forEach(logistic=>{
  1607. logistics.push(logistic.id);
  1608. });
  1609. let items = [];
  1610. model.details.forEach(item=>{
  1611. items.push({
  1612. unit_id:item.unit_id,
  1613. range:item.range,
  1614. province_id:item.province_id,
  1615. city_id:item.city_id,
  1616. unit_price:item.unit_price,
  1617. delivery_fee:item.delivery_fee,
  1618. initial_fee:item.initial_fee,
  1619. initial_amount:item.initial_amount,
  1620. rate:item.rate,
  1621. });
  1622. });
  1623. mapping[model.id] = {
  1624. logistics : logistics,
  1625. name:model.name,
  1626. unit_range:model.unit_range,
  1627. unit_id:model.unit_id,
  1628. other_unit_range:model.other_unit_range,
  1629. other_unit_id:model.other_unit_id,
  1630. pick_up_price:model.pick_up_price,
  1631. fuel_price:model.fuel_price,
  1632. service_price:model.service_price,
  1633. items:items,
  1634. };
  1635. });
  1636. this.searchResult = result;
  1637. this.searchResultMapping = mapping;
  1638. this.isSearch = false;
  1639. });
  1640. },
  1641. _getDirectLogisticPriceModel(){
  1642. let url = "{{url('maintenance/priceModel/apiGetDirectLogistic')}}";
  1643. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1644. let result = [];
  1645. let mapping = {};
  1646. res.forEach(model=> {
  1647. let text = model.name+" (起步数:"+model.base_km+"KM)";
  1648. result.push({id:model.id,text:text});
  1649. let items = [];
  1650. model.details.forEach(item=>{
  1651. items.push({
  1652. car_type_id:item.car_type_id,
  1653. base_fee:item.base_fee,
  1654. additional_fee:item.additional_fee,
  1655. });
  1656. });
  1657. mapping[model.id] = {
  1658. name:model.name,
  1659. base_km:model.base_km,
  1660. items:items,
  1661. };
  1662. });
  1663. this.searchResult = result;
  1664. this.searchResultMapping = mapping;
  1665. this.isSearch = false;
  1666. });
  1667. },
  1668. //提交引入
  1669. submitIntroduce(){
  1670. if (!this.selectedResult || !this.searchResultMapping[this.selectedResult]){
  1671. window.tempTip.setDuration(3000);
  1672. window.tempTip.show("尚未选择引入项,请单击选择列表,如列表为空则无结果");
  1673. return;
  1674. }
  1675. let model = this.searchResultMapping[this.selectedResult];
  1676. switch (this.type) {
  1677. case "storage":
  1678. this.model.storage = model;
  1679. break;
  1680. case "operation":
  1681. this.model.operation = model;
  1682. break;
  1683. case "express":
  1684. this.model.express = model;
  1685. break;
  1686. case "logistic":
  1687. this.model.logistic = model;
  1688. break;
  1689. default:
  1690. this.model.directLogistic = model;
  1691. break;
  1692. }
  1693. $("#introduce").modal('hide');
  1694. window.tempTip.setDuration(2000);
  1695. window.tempTip.showSuccess("引入成功");
  1696. },
  1697. //删除仓储
  1698. delStorage(item,index){
  1699. window.tempTip.confirm("您确定要删除仓储计费“"+item.name+"”吗?",()=>{
  1700. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelStorage')}}",{id:item.id},res=>{
  1701. this.$delete(this.selectedModel.storage,index);
  1702. this.audit.storage = true;
  1703. return "删除“"+item.name+"”成功";
  1704. });
  1705. });
  1706. },
  1707. //删除作业
  1708. delOperation(item,index){
  1709. window.tempTip.confirm("您确定要删除作业计费“"+item.name+"”吗?",()=>{
  1710. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperation')}}",{id:item.id},res=>{
  1711. this.$delete(this.selectedModel.operation,index);
  1712. this.audit.operation = true;
  1713. return "删除“"+item.name+"”成功";
  1714. });
  1715. });
  1716. },
  1717. //删除作业子项
  1718. deleteOperationItem(item,index,parentIndex){
  1719. window.tempTip.confirm("您确定要删除该作业子项吗?",()=>{
  1720. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperationItem')}}",{id:item.id},res=>{
  1721. if (res) this.$set(this.selectedModel.operation,parentIndex,this._overrideOperation(res));
  1722. else this.$delete(this.selectedModel.operation[parentIndex].items,index);
  1723. this.audit.operation = true;
  1724. return "删除成功";
  1725. });
  1726. });
  1727. },
  1728. //删除快递
  1729. delExpress(item,index){
  1730. window.tempTip.confirm("您确定要删除该快递计费“"+item.name+"”吗?",()=>{
  1731. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpress')}}",{id:item.id},res=>{
  1732. this.$delete(this.selectedModel.express,index);
  1733. this.audit.express = true;
  1734. return "删除“"+item.name+"”成功";
  1735. });
  1736. });
  1737. },
  1738. //删除快递子项
  1739. deleteExpressItem(item,index,parentIndex){
  1740. window.tempTip.confirm("您确定要删除该快递计费子项吗?",()=>{
  1741. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpressItem')}}",{id:item.id},res=>{
  1742. if (res) this.$set(this.selectedModel.express,parentIndex,this._overrideExpress(res));
  1743. else this.$delete(this.selectedModel.express[parentIndex].items,index);
  1744. this.audit.express = true;
  1745. return "删除成功";
  1746. });
  1747. });
  1748. },
  1749. //删除物流
  1750. delLogistic(item,index){
  1751. window.tempTip.confirm("您确定要删除该物流计费“"+item.name+"”吗?",()=>{
  1752. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogistic')}}",{id:item.id},res=>{
  1753. this.$delete(this.selectedModel.logistic,index);
  1754. this.audit.logistic = true;
  1755. return "删除“"+item.name+"”成功";
  1756. });
  1757. });
  1758. },
  1759. //删除物流子项
  1760. deleteLogisticItem(item,index,parentIndex){
  1761. window.tempTip.confirm("您确定要删除该物流计费子项吗?",()=>{
  1762. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogisticItem')}}",{id:item.id},res=>{
  1763. if (res) this.$set(this.selectedModel.logistic,parentIndex,this._overrideLogistic(res));
  1764. else this.$delete(this.selectedModel.logistic[parentIndex].items,index);
  1765. this.audit.logistic = true;
  1766. return "删除成功";
  1767. });
  1768. });
  1769. },
  1770. //删除直发车
  1771. delDirectLogistic(item){
  1772. window.tempTip.confirm("您确定要删除该直发车计费“"+item.name+"”吗?",()=>{
  1773. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogistic')}}",{id:item.id},res=>{
  1774. this.selectedModel.directLogistic = {};
  1775. this.audit.directLogistic = true;
  1776. return "删除“"+item.name+"”成功";
  1777. });
  1778. });
  1779. },
  1780. //删除直发车子项
  1781. deleteDirectLogisticItem(item,index){
  1782. window.tempTip.confirm("您确定要删除该直发车计费子项吗?",()=>{
  1783. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogisticItem')}}",{id:item.id},res=>{
  1784. if (res) this.$set(this.selectedModel,"directLogistic",this._overrideDirectLogistic(res));
  1785. else this.$delete(this.selectedModel.directLogistic.items,index);
  1786. this.audit.directLogistic = true;
  1787. return "删除成功";
  1788. });
  1789. });
  1790. },
  1791. //删除系统
  1792. deleteSystem(item){
  1793. window.tempTip.confirm("您确定要删除该系统计费吗?",()=>{
  1794. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelSystem')}}",{id:item.id},res=>{
  1795. this.$set(this.selectedModel,"system",{usage_fee:""});
  1796. this.audit.system = true;
  1797. return "删除成功";
  1798. });
  1799. });
  1800. },
  1801. //编辑仓储
  1802. editStorage(index){
  1803. this.switchType("storage");
  1804. this.model.storage = JSON.parse(JSON.stringify(this.selectedModel.storage[index]));
  1805. this.model.storage.index = index;
  1806. if (this.model.storage.amount_interval)this.model.storage.isInterval = true;
  1807. },
  1808. //编辑作业
  1809. editOperation(index){
  1810. this.switchType("operation");
  1811. this.model.operation = JSON.parse(JSON.stringify(this.selectedModel.operation[index]));
  1812. this.model.operation.index = index;
  1813. },
  1814. //编辑快递
  1815. editExpress(index){
  1816. this.switchType("express");
  1817. this.model.express = JSON.parse(JSON.stringify(this.selectedModel.express[index]));
  1818. this.model.express.index = index;
  1819. },
  1820. //编辑物流
  1821. editLogistic(index){
  1822. this.switchType("logistic");
  1823. this.model.logistic = JSON.parse(JSON.stringify(this.selectedModel.logistic[index]));
  1824. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1825. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1826. this.model.logistic.index = index;
  1827. },
  1828. //编辑直发车
  1829. editDirectLogistic(){
  1830. this.switchType("directLogistic");
  1831. this.model.directLogistic = JSON.parse(JSON.stringify(this.selectedModel.directLogistic));
  1832. },
  1833. //编辑系统
  1834. editSystem(){
  1835. this.switchType("system");
  1836. this.model.system = JSON.parse(JSON.stringify(this.selectedModel.system));
  1837. },
  1838. //搜索快递子项
  1839. searchExpress(e){
  1840. let val = e.target.value;
  1841. if (!val){
  1842. this.$set(this.searchItem,'express',null);
  1843. return;
  1844. }
  1845. let items = [];
  1846. this.model.express.items.forEach((item,i)=>{
  1847. if (this.poolMapping.provinces[item.province_id].indexOf(val) !== -1)items.push(i);
  1848. });
  1849. this.$set(this.searchItem,'express',items);
  1850. },
  1851. //搜索直发子项
  1852. searchDirectLogistic(e){
  1853. let val = e.target.value;
  1854. if (!val){
  1855. this.$set(this.searchItem,'directLogistic',null);
  1856. return;
  1857. }
  1858. let items = [];
  1859. this.model.directLogistic.items.forEach((item,i)=>{
  1860. if (this.poolMapping.cars[item.car_type_id].indexOf(val) !== -1)items.push(i);
  1861. });
  1862. this.$set(this.searchItem,'directLogistic',items);
  1863. },
  1864. //搜索物流子项
  1865. searchLogistic(e){
  1866. let val = e.target.value;
  1867. if (!val){
  1868. this.$set(this.searchItem,'logistic',null);
  1869. return;
  1870. }
  1871. let items = [];
  1872. this.model.logistic.items.forEach((item,i)=>{
  1873. if (item.unit_id || item.province_id || item.city_id){
  1874. if ((item.unit_id && this.poolMapping.units[item.unit_id].indexOf(val) !== -1) ||
  1875. (item.province_id && this.poolMapping.provinces[item.province_id].indexOf(val) !== -1) ||
  1876. (item.city_id && this.poolMapping.cities[item.city_id].indexOf(val) !== -1))items.push(i);
  1877. }
  1878. });
  1879. this.$set(this.searchItem,'logistic',items);
  1880. },
  1881. //增加阶梯满减阈值
  1882. addDiscount(arr){
  1883. this.model.operation.items.forEach(item=>{
  1884. item.discount_price.push('');
  1885. });
  1886. this.model.operation.total_discount_price.push("");
  1887. arr.push('');
  1888. },
  1889. //删除阶梯满减阈值
  1890. delDiscount(index){
  1891. this.model.operation.items.forEach((item,i)=>{
  1892. delete item.discount_price[index];
  1893. this.$set(this.model.operation.items,i,item);
  1894. });
  1895. this.$delete(this.model.operation.total_discount_price,index);
  1896. this.$delete(this.model.operation.discount_count,index);
  1897. },
  1898. //审核或恢复
  1899. auditOrRecoverModel(type,isAudit = true){
  1900. this.getPriceModelAudit(type,isAudit);
  1901. this.selectedAudit = type;
  1902. this.isAudit = isAudit;
  1903. setTimeout(function () {
  1904. $("#auditOrRecover").modal("show");
  1905. },100);
  1906. },
  1907. exeAuditOrRecoverModel(){
  1908. let url = "{{url('maintenance/priceModel/auditOrRecoverModel')}}";
  1909. let type = this.selectedAudit;
  1910. let isAudit = this.isAudit;
  1911. let param = {owner_id:this.ownerTemp.id,type:type,isAudit:isAudit};
  1912. window.tempTip.postBasicRequest(url,param,res=>{
  1913. switch (type){
  1914. case "storage":
  1915. this.selectedModel.storage = res;
  1916. break;
  1917. case "operation":
  1918. this._loadOperation();
  1919. res.forEach((operation,i)=>{res[i] = this._overrideOperation(operation);});
  1920. this.selectedModel.operation = res;
  1921. break;
  1922. case "express":
  1923. this._loadExpress();
  1924. res.forEach((express,i)=>{
  1925. res[i] = this._overrideExpress(express);
  1926. this.upList['express-item-'+i] = true;
  1927. });
  1928. this.selectedModel.express = res;
  1929. break;
  1930. case "logistic":
  1931. this._loadLogistic();
  1932. res.forEach((logistic,i)=>{
  1933. res[i] = this._overrideLogistic(logistic);
  1934. this.upList['logistic-item-'+i] = true;
  1935. });
  1936. this.selectedModel.logistic = res;
  1937. break;
  1938. case "directLogistic":
  1939. this._loadDirectLogistic();
  1940. this.upList["directLogistic-item"] = true;
  1941. this.selectedModel.directLogistic = this._overrideDirectLogistic(res[0]);
  1942. break;
  1943. case "system":
  1944. this.selectedModel.system = res;
  1945. break;
  1946. }
  1947. this.$set(this.audit,type,false);
  1948. $("#auditOrRecover").modal("hide");
  1949. return (isAudit ? '审核' : '恢复')+"成功!";
  1950. },true)
  1951. },
  1952. //增加数量区间
  1953. addStoreAmount(){
  1954. this.model.storage.amount_interval.push("");
  1955. this.model.storage.price.push("");
  1956. },
  1957. //删除数量区间
  1958. delStoreAmount(index){
  1959. if (this.model.storage.amount_interval.length<2)return;
  1960. this.$delete(this.model.storage.amount_interval,index);
  1961. this.$delete(this.model.storage.price,index);
  1962. },
  1963. //增加快递数量区间
  1964. addExpressAmount(){
  1965. this.model.express.amount_interval.push("");
  1966. this.model.express.weight_interval.push([]);
  1967. if (this.model.express.items.length>0){
  1968. this.model.express.items.forEach((item,i)=>{
  1969. this.$set(this.model.express.items[i],"initial_weight_price",[""]);
  1970. this.$set(this.model.express.items[i],"additional_weight_price",[""]);
  1971. })
  1972. }
  1973. },
  1974. //增加快递重量区间
  1975. addExpressWeight(index){
  1976. this.model.express.weight_interval[index].push("");
  1977. if (!this.model.express.maxDom || this.model.express.weight_interval[index].length > this.model.express.maxDom)
  1978. this.$set(this.model.express,'maxDom',this.model.express.weight_interval[index].length);
  1979. },
  1980. //删除快递数量区间
  1981. delExpressAmount(){
  1982. let len = this.model.express.amount_interval.length;
  1983. if (len>1){
  1984. this.$delete(this.model.express.amount_interval,len-1);
  1985. this.$delete(this.model.express.weight_interval,len-1);
  1986. if (this.model.express.items.length>0){
  1987. this.model.express.items.forEach((item,i)=>{
  1988. this.$delete(this.model.express.items[i]["initial_weight_price"],len-1);
  1989. this.$delete(this.model.express.items[i]["additional_weight_price"],len-1);
  1990. })
  1991. }
  1992. }
  1993. },
  1994. //删除快递重量区间
  1995. delExpressWeight(index){
  1996. let len = this.model.express.weight_interval[index].length;
  1997. this.$delete(this.model.express.weight_interval[index],len-1);
  1998. if (this.model.express.items.length>0){
  1999. this.model.express.items.forEach((item,i)=>{
  2000. this.$delete(this.model.express.items[i]["initial_weight_price"][index],len-1);
  2001. this.$delete(this.model.express.items[i]["additional_weight_price"][index],len-1);
  2002. })
  2003. }
  2004. },
  2005. filterCustomer(e){
  2006. let value = e.target.value;
  2007. if (!value)this.owner.customer_id = "";
  2008. this.customers.some(customer=>{
  2009. if (customer.name.indexOf(value)!==-1){
  2010. this.owner.customer_id = customer.id;
  2011. return true;
  2012. }
  2013. });
  2014. },
  2015. filterOwnerGroup(e){
  2016. let value = e.target.value;
  2017. if (!value)this.owner.owner_group_id = "";
  2018. this.ownerGroups.some(ownerGroup=>{
  2019. if (ownerGroup.name.indexOf(value)!==-1){
  2020. this.owner.owner_group_id = ownerGroup.id;
  2021. return true;
  2022. }
  2023. });
  2024. },
  2025. filterUserGroup(e){
  2026. let value = e.target.value;
  2027. if (!value)this.owner.user_workgroup_id = "";
  2028. this.userGroups.some(userGroup=>{
  2029. if (userGroup.name.indexOf(value)!==-1){
  2030. this.owner.user_workgroup_id = userGroup.id;
  2031. return true;
  2032. }
  2033. });
  2034. },
  2035. getPriceModelAudit(type,isAudit){
  2036. this.showAuditPiece = {
  2037. "C":false,"D":false,"U":false
  2038. };
  2039. this.auditList[type] = {};
  2040. let url="{{url('maintenance/priceModel/getPriceModelAudit')}}";
  2041. this.comparisonTemp = {};
  2042. switch (type) {
  2043. case "storage":
  2044. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2045. if (!res)return;
  2046. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonStorage(res[i],isAudit);
  2047. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonStorage(res[i],isAudit);
  2048. });
  2049. break;
  2050. case "operation":
  2051. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2052. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonOperation(res[i],isAudit);
  2053. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonOperation(res[i],isAudit);
  2054. });
  2055. break;
  2056. case "express":
  2057. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2058. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonExpress(res[i],isAudit);
  2059. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonExpress(res[i],isAudit);
  2060. });
  2061. break;
  2062. case "logistic":
  2063. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2064. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonLogistic(res[i],isAudit);
  2065. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonLogistic(res[i],isAudit);
  2066. });
  2067. break;
  2068. case "directLogistic":
  2069. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2070. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonDirectLogistic(res[i],isAudit);
  2071. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonDirectLogistic(res[i],isAudit);
  2072. });
  2073. break;
  2074. case "system":
  2075. window.tempTip.postBasicRequest(url,{type:type,owner_id:this.ownerTemp.id},res=>{
  2076. if (isAudit)for(let i=0;i<res.length;i++)this._AuditComparisonSystem(res[i],isAudit);
  2077. else for(let i=res.length-1;i>=0;i--)this._AuditComparisonSystem(res[i],isAudit);
  2078. });
  2079. break;
  2080. }
  2081. },
  2082. _pushAuditList(model,type,data){
  2083. if (this.auditList[model][type]){
  2084. this.auditList[model][type].push(data);
  2085. }else{
  2086. this.showAuditPiece[type] = true;
  2087. this.auditList[model][type] = [data];
  2088. }
  2089. },
  2090. _reverseAuditComparison(operation){
  2091. switch (operation) {
  2092. case "C":
  2093. return "D";
  2094. case "D":
  2095. return "C";
  2096. case "U":
  2097. return "";
  2098. default:
  2099. return "U";
  2100. }
  2101. },
  2102. _AuditComparisonStorage(data,isAudit){
  2103. if (!isAudit){
  2104. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2105. data.operation = this._reverseAuditComparison(data.operation);
  2106. }
  2107. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2108. data.time_unit_id = this.poolMapping.units ? this.poolMapping.units[data.time_unit_id] : '';
  2109. data.unit_id = this.poolMapping.units ? this.poolMapping.units[data.unit_id] : '';
  2110. switch (data.operation) {
  2111. case "C":
  2112. this._pushAuditList("storage","C",data);
  2113. break;
  2114. case "D":
  2115. this._pushAuditList("storage","D",data);
  2116. break;
  2117. case "U":
  2118. let result = this._formatComparisonData("storage",data);
  2119. if (result===null) this._pushAuditList("storage","C",data);
  2120. else this._pushAuditList("storage","U",result);
  2121. break;
  2122. default:
  2123. if (!this.auditList.storage.H)this.auditList.storage.H = {};
  2124. this.auditList.storage.H[data.id] = data;
  2125. break;
  2126. }
  2127. },
  2128. _AuditComparisonOperation(data,isAudit){
  2129. if (!isAudit){
  2130. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2131. data.operation = this._reverseAuditComparison(data.operation);
  2132. }
  2133. data.discount_count = data.discount_count ? data.discount_count.split(",") : [];
  2134. data.total_discount_price = data.total_discount_price ? data.total_discount_price.split(",") : [];
  2135. data.surcharge_unit_id = this.poolMapping.units ? this.poolMapping.units[data.surcharge_unit_id] : '';
  2136. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2137. data.items.forEach((item,j)=>{
  2138. data.items[j].discount_price = data.items[j].discount_price ? data.items[j].discount_price.split(",") : [];
  2139. data.items[j].unit_id = this.poolMapping.units ? this.poolMapping.units[data.items[j].unit_id] : '';
  2140. });
  2141. switch (data.operation) {
  2142. case "C":
  2143. this._pushAuditList("operation","C",data);
  2144. break;
  2145. case "D":
  2146. this._pushAuditList("operation","D",data);
  2147. break;
  2148. case "U":
  2149. let result = this._formatComparisonData("operation",data);
  2150. if (result===null) this._pushAuditList("operation","C",data);
  2151. else this._pushAuditList("operation","U",result);
  2152. break;
  2153. default:
  2154. if (!this.auditList.operation.H)this.auditList.operation.H = {};
  2155. this.auditList.operation.H[data.id] = data;
  2156. break;
  2157. }
  2158. },
  2159. _AuditComparisonExpress(data,isAudit){
  2160. if (!isAudit){
  2161. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2162. data.operation = this._reverseAuditComparison(data.operation);
  2163. }
  2164. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2165. data.logistics.forEach((logistic,j)=>{
  2166. data.logistics[j] = logistic.name;
  2167. });
  2168. data.details.forEach((detail,j)=>{
  2169. data.details[j].province_id = this.poolMapping.provinces ? this.poolMapping.provinces[data.details[j].province_id] : '';
  2170. });
  2171. switch (data.operation) {
  2172. case "C":
  2173. this._pushAuditList("express","C",data);
  2174. break;
  2175. case "D":
  2176. this._pushAuditList("express","D",data);
  2177. break;
  2178. case "U":
  2179. let result = this._formatComparisonData("express",data);
  2180. if (result===null) this._pushAuditList("express","C",data);
  2181. else this._pushAuditList("express","U",result);
  2182. break;
  2183. default:
  2184. if (!this.auditList.express.H)this.auditList.express.H = {};
  2185. this.auditList.express.H[data.id] = data;
  2186. break;
  2187. }
  2188. },
  2189. _AuditComparisonLogistic(data,isAudit){
  2190. if (!isAudit){
  2191. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2192. data.operation = this._reverseAuditComparison(data.operation);
  2193. }
  2194. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2195. data.logistics.forEach((logistic,j)=>{
  2196. data.logistics[j] = logistic.name;
  2197. });
  2198. data.other_unit_id = this.poolMapping.units ? this.poolMapping.units[data.other_unit_id] : '';
  2199. data.unit_id = this.poolMapping.units ? this.poolMapping.units[data.unit_id] : '';
  2200. data.unit_range = data.unit_range ? data.unit_range.split(",") : [];
  2201. data.other_unit_range = data.other_unit_range ? data.other_unit_range.split(",") : [];
  2202. data.details.forEach((detail,j)=>{
  2203. data.details[j].province_id = this.poolMapping.provinces ? this.poolMapping.provinces[data.details[j].province_id] : '';
  2204. data.details[j].city_id = this.poolMapping.cities ? this.poolMapping.cities[data.details[j].city_id] : '';
  2205. data.details[j].unit_id = this.poolMapping.units ? this.poolMapping.units[data.details[j].unit_id] : '';
  2206. });
  2207. switch (data.operation) {
  2208. case "C":
  2209. this._pushAuditList("logistic","C",data);
  2210. break;
  2211. case "D":
  2212. this._pushAuditList("logistic","D",data);
  2213. break;
  2214. case "U":
  2215. let result = this._formatComparisonData("logistic",data);
  2216. if (result===null) this._pushAuditList("logistic","C",data);
  2217. else this._pushAuditList("logistic","U",result);
  2218. break;
  2219. default:
  2220. if (!this.auditList.logistic.H)this.auditList.logistic.H = {};
  2221. this.auditList.logistic.H[data.id] = data;
  2222. break;
  2223. }
  2224. },
  2225. _AuditComparisonDirectLogistic(data,isAudit){
  2226. if (!isAudit){
  2227. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2228. data.operation = this._reverseAuditComparison(data.operation);
  2229. }
  2230. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2231. data.details.forEach((detail,j)=>{
  2232. data.details[j].car_type_id = this.poolMapping.cars ? this.poolMapping.cars[data.details[j].car_type_id] : '';
  2233. });
  2234. switch (data.operation) {
  2235. case "C":
  2236. this._pushAuditList("directLogistic","C",data);
  2237. break;
  2238. case "D":
  2239. this._pushAuditList("directLogistic","D",data);
  2240. break;
  2241. case "U":
  2242. let result = this._formatComparisonData("directLogistic",data);
  2243. if (result===null) this._pushAuditList("directLogistic","C",data);
  2244. else this._pushAuditList("directLogistic","U",result);
  2245. break;
  2246. default:
  2247. if (!this.auditList.directLogistic.H)this.auditList.directLogistic.H = {};
  2248. this.auditList.directLogistic.H[data.id] = data;
  2249. break;
  2250. }
  2251. },
  2252. _AuditComparisonSystem(data,isAudit){
  2253. if (!isAudit){
  2254. if (data.operation==='U' && data.target_id)this.comparisonTemp[data.target_id] = data.id;
  2255. data.operation = this._reverseAuditComparison(data.operation);
  2256. }
  2257. data.tax_rate_id = this.poolMapping.taxRates ? this.poolMapping.taxRates[data.tax_rate_id] : '';
  2258. switch (data.operation) {
  2259. case "C":
  2260. this.auditList.system.C = data;
  2261. this.showAuditPiece.C = true;
  2262. break;
  2263. case "D":
  2264. this.auditList.system.D = data;
  2265. this.showAuditPiece.D = true;
  2266. break;
  2267. case "U":
  2268. if (!this.auditList.system.H){
  2269. this.auditList.system.C = data;
  2270. this.showAuditPiece.C = true;
  2271. }else{
  2272. this.auditList.system.U = data;
  2273. this.showAuditPiece.U = true;
  2274. }
  2275. break;
  2276. default:
  2277. this.auditList.system.H = data;
  2278. break;
  2279. }
  2280. },
  2281. _formatComparisonData(type,data){
  2282. let temp = {"name":"名称"};
  2283. 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>";
  2284. let tar = null;
  2285. let itemTem;
  2286. let items;
  2287. let amount;
  2288. switch (type) {
  2289. case "storage":
  2290. tar = this.auditList.storage.H ? this.auditList.storage.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : null;
  2291. if (!tar)return null;
  2292. for (let key in this.auditList.mapping.storage){
  2293. if (String(data[key])!==String(tar[key])){
  2294. if (!temp[key]) temp[key] = this.auditList.mapping.storage[key];
  2295. data[key] = this.transformData(tar,key)+font+this.transformData(data,key,true)+"</div>";
  2296. }else data[key] = this.transformData(data,key);
  2297. }
  2298. if (String(data["price"])!==String(tar["price"]) && String(data["amount_interval"])===String(tar["amount_interval"])){
  2299. data["amount_interval"] = this.transformData(tar,"amount_interval")+font+this.transformData(data,"amount_interval",true)+"</div>";
  2300. }
  2301. break;
  2302. case "operation":
  2303. temp={"name":"名称",child:{strategy:"子策略"}};
  2304. itemTem = {};
  2305. items=[];
  2306. amount=0;
  2307. tar = this.auditList.operation.H ? this.auditList.operation.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
  2308. if (!tar)return null;
  2309. for (let key in this.auditList.mapping.operation){
  2310. if (String(data[key])!==String(tar[key])){
  2311. if (!temp[key]) temp[key] = this.auditList.mapping.operation[key];
  2312. data[key] = this.transformData(tar,key)+font+this.transformData(data,key,true)+"</div>";
  2313. }else data[key] = this.transformData(data,key);
  2314. }
  2315. tar.items.forEach(item=>{
  2316. if (!itemTem[item.strategy])itemTem[item.strategy] = [];
  2317. itemTem[item.strategy].push(item);
  2318. });
  2319. data.items.forEach(item=>{
  2320. if (itemTem[item.strategy]){
  2321. let mark = true;
  2322. for (let i=0;i<itemTem[item.strategy].length;i++){
  2323. for (let key in this.auditList.mapping.operation.child){
  2324. let oldStr = itemTem[item.strategy][i][key];
  2325. let newStr = item[key];
  2326. if (String(newStr)!==String(oldStr)){
  2327. mark = false;break;
  2328. }
  2329. }
  2330. if (mark){
  2331. item.operation = "H";
  2332. itemTem[item.strategy].splice(i,1);
  2333. if (itemTem[item.strategy].length===0)itemTem[item.strategy] = null;
  2334. break;
  2335. }
  2336. }
  2337. }//去重
  2338. });
  2339. data.items.forEach(item=>{
  2340. if (item.operation!=='H'){
  2341. if (!itemTem[item.strategy]){
  2342. for (let key in this.auditList.mapping.operation.child)item[key] = this.transformData(item,key);
  2343. item.operation = "C";
  2344. items.unshift(item);
  2345. amount++;
  2346. }else{
  2347. let tar = item.strategy;
  2348. for (let key in this.auditList.mapping.operation.child){
  2349. if (String(item[key])!==String(itemTem[tar][0][key])){
  2350. if (!temp.child[key]) temp.child[key] = this.auditList.mapping.operation.child[key];
  2351. item[key] = this.transformData(itemTem[tar][0],key)+font+this.transformData(item,key,true)+"</div>";
  2352. }else item[key] = this.transformData(item,key);
  2353. }
  2354. item.operation = "U";
  2355. items.push(item);
  2356. itemTem[tar].splice(0,1);
  2357. if (itemTem[tar].length===0) itemTem[tar] = null;
  2358. }
  2359. }
  2360. });
  2361. for (let key in itemTem){
  2362. if (itemTem[key]){
  2363. itemTem[key].forEach(item=>{
  2364. for (let key in this.auditList.mapping.operation.child)item[key] = this.transformData(item,key);
  2365. item.operation = "D";
  2366. items.splice(amount,0,item);
  2367. amount++;
  2368. });
  2369. }
  2370. }
  2371. data.items = items;
  2372. break;
  2373. case "express":
  2374. temp={"name":"名称",child:{province_id:"省"}};
  2375. itemTem={};
  2376. items=[];
  2377. amount=0;
  2378. tar = this.auditList.express.H ? this.auditList.express.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : null;
  2379. if (!tar)return null;
  2380. for (let key in this.auditList.mapping.express) {
  2381. if (String(data[key]) !== String(tar[key])) {
  2382. if (!temp[key]) temp[key] = this.auditList.mapping.express[key];
  2383. data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
  2384. } else data[key] = this.transformData(data, key);
  2385. if (String(data["amount_interval"])!==String(tar["amount_interval"]) && String(data["weight_interval"])===String(tar["weight_interval"])){
  2386. data["weight_interval"] = this.transformData(tar,"weight_interval")+font+this.transformData(data,"weight_interval",true)+"</div>";
  2387. }
  2388. }
  2389. tar.details.forEach(item => {itemTem[item.province_id] = item;});
  2390. data.details.forEach(item=>{
  2391. if (!itemTem[item.province_id]){
  2392. for (let key in this.auditList.mapping.express.child)item[key] = this.transformData(item,key);
  2393. item.operation = "C";
  2394. items.unshift(item);
  2395. amount++;
  2396. }else{
  2397. let mark = true;
  2398. for (let key in this.auditList.mapping.express.child){
  2399. if (String(item[key])!==String(itemTem[item.province_id][key])){
  2400. mark = false;break;
  2401. }
  2402. }
  2403. if (!mark){
  2404. let tar = item.province_id;
  2405. for (let key in this.auditList.mapping.express.child) {
  2406. if (String(item[key]) !== String(itemTem[tar][key])) {
  2407. if (!temp.child[key]) temp.child[key] = this.auditList.mapping.express.child[key];
  2408. item[key] = this.transformData(itemTem[tar], key) + font + this.transformData(item, key, true) + "</div>";
  2409. } else item[key] = this.transformData(item, key);
  2410. }
  2411. item.operation = "U";
  2412. items.push(item);
  2413. delete itemTem[tar];
  2414. }else delete itemTem[item.province_id];
  2415. }
  2416. });
  2417. for (let key in itemTem){
  2418. for (let k in this.auditList.mapping.express.child)itemTem[key][k] = this.transformData(itemTem[key],k);
  2419. itemTem[key].operation = "D";
  2420. items.splice(amount,0,itemTem[key]);
  2421. amount++;
  2422. }
  2423. data.details = items;
  2424. break;
  2425. case "logistic":
  2426. temp={name:"名称",child:{province_id:"省份",city_id:"城市"}};
  2427. tar = this.auditList.logistic.H ? this.auditList.logistic.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
  2428. if (!tar)return null;
  2429. for (let key in this.auditList.mapping.logistic) {
  2430. if (String(data[key]) !== String(tar[key])) {
  2431. if (!temp[key]) temp[key] = this.auditList.mapping.logistic[key];
  2432. data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
  2433. } else data[key] = this.transformData(data, key);
  2434. }
  2435. itemTem = this.logisticDataFormat(tar);
  2436. let dataTem = this.logisticDataFormat(data);
  2437. items = [];
  2438. for (let key in itemTem){
  2439. if (dataTem[key]){
  2440. for (let key2 in itemTem[key]){
  2441. if (dataTem[key][key2]){
  2442. for (let key3 in itemTem[key][key2]){
  2443. if (dataTem[key][key2][key3]){
  2444. for (let key4 in itemTem[key][key2][key3]){
  2445. if (dataTem[key][key2][key3][key4]){
  2446. let mark = true;
  2447. for (let key5 in this.auditList.mapping.logistic.child){
  2448. if (String(dataTem[key][key2][key3][key4][key5]) !== String(itemTem[key][key2][key3][key4][key5])){
  2449. if (!temp.child[key5]) temp.child[key5] = this.auditList.mapping.logistic.child[key5];
  2450. mark=false;
  2451. if (!temp.child[key5]) temp.child[key5] = this.auditList.mapping.logistic.child[key5];
  2452. 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>";
  2453. } else dataTem[key][key2][key3][key4][key5] = this.transformData(dataTem[key][key2][key3][key4], key5);
  2454. }
  2455. if (!mark){
  2456. dataTem[key][key2][key3][key4].operation = "U";
  2457. items.push(dataTem[key][key2][key3][key4])
  2458. }
  2459. delete dataTem[key][key2][key3][key4];
  2460. delete itemTem[key][key2][key3][key4];
  2461. }
  2462. }
  2463. }
  2464. }
  2465. }
  2466. }
  2467. }
  2468. }
  2469. dataTem = this.logisticDataRestore(dataTem,"C");
  2470. dataTem.push.apply(dataTem,this.logisticDataRestore(itemTem,"D"));
  2471. dataTem.push.apply(dataTem,items);
  2472. data.details = dataTem;
  2473. break;
  2474. case "directLogistic":
  2475. temp={name:"名称",child:{car_type_id:"车型"}};
  2476. itemTem={};
  2477. items=[];
  2478. amount=0;
  2479. tar = this.auditList.directLogistic.H ? this.auditList.directLogistic.H[data.target_id ? data.target_id : this.comparisonTemp[data.id]] : '';
  2480. if (!tar)return null;
  2481. for (let key in this.auditList.mapping.directLogistic) {
  2482. if (String(data[key]) !== String(tar[key])) {
  2483. if (!temp[key]) temp[key] = this.auditList.mapping.directLogistic[key];
  2484. data[key] = this.transformData(tar, key) + font + this.transformData(data, key, true) + "</div>";
  2485. } else data[key] = this.transformData(data, key);
  2486. }
  2487. tar.details.forEach(item => {itemTem[item.car_type_id] = item;});
  2488. data.details.forEach(item => {
  2489. if (itemTem[item.car_type_id]){
  2490. let car = item.car_type_id;
  2491. let mark = true;
  2492. for (let key in this.auditList.mapping.directLogistic.child) {
  2493. if (String(item[key]) !== String(itemTem[car][key])) {
  2494. mark = false;
  2495. if (!temp.child[key]) temp.child[key] = this.auditList.mapping.directLogistic.child[key];
  2496. item[key] = this.transformData(itemTem[car], key) + font + this.transformData(item, key, true) + "</div>";
  2497. } else item[key] = this.transformData(item, key);
  2498. }
  2499. if (!mark){
  2500. item.operation = "U";
  2501. items.push(item);
  2502. }
  2503. delete itemTem[car];
  2504. }else{
  2505. item.operation = "C";
  2506. items.unshift(item);
  2507. amount++;
  2508. }
  2509. for (let key in itemTem){
  2510. for (let k in this.auditList.mapping.directLogistic.child)itemTem[key][k] = this.transformData(itemTem[key],k);
  2511. itemTem[key].operation = "D";
  2512. items.splice(amount,0,itemTem[key]);
  2513. amount++;
  2514. }
  2515. });
  2516. data.details = items;
  2517. break;
  2518. }
  2519. this.auditList.mapping[type] = temp;
  2520. return data;
  2521. },
  2522. transformData(data,key,font=false){
  2523. if (!data[key])return;
  2524. let html = '<div class="float-left small ';
  2525. if (font)html += "text-primary font-weight-bold";
  2526. else html += "text-secondary";
  2527. html+='">';
  2528. switch (key) {
  2529. case "amount_interval":
  2530. data[key].forEach((am,i)=>{
  2531. if (i!==data[key].length-1) html += "<span>"+am+"-"+data[key][i+1]+"("+data["price"][i]+"元)<br></span>";
  2532. });
  2533. html += "<span>"+data[key][data[key].length-1]+" +("+data["price"][data[key].length-1]+"元)<br></span></div>";
  2534. return html;
  2535. case "total_discount_price":
  2536. data[key].forEach(am=>{
  2537. html += '<span>'+am+'元<br></span>'
  2538. });
  2539. return html+"</div>";
  2540. case "discount_price":
  2541. data[key].forEach(am=>{
  2542. html += '<span>'+am+'元<br></span>'
  2543. });
  2544. return html+"</div>";
  2545. case "discount_count":
  2546. data[key].forEach((am,i)=>{
  2547. if (i!==data[key].length-1)html += '<span>'+am+'-'+data[key][i+1]+'<br></span>'
  2548. });
  2549. html += '<span>'+data[key][data[key].length-1]+'&nbsp;+<br></span>';
  2550. return html+"</div>";
  2551. case "weight_interval":
  2552. data[key].forEach((arr,i)=>{
  2553. if (i!==data[key].length-1) html += '<span>'+data.amount_interval[i]+'-'+data.amount_interval[i+1]+'/单(';
  2554. arr.forEach((w,j)=>{
  2555. if (j!==arr.length-1)html += w+'-'+arr[j+1]+'/KG,';
  2556. });
  2557. html += (arr[arr.length-1] ? arr[arr.length-1] : 0)+'&nbsp;+/KG)<br></span>';
  2558. });
  2559. html += '<span>'+data.amount_interval[data.amount_interval.length-1]+'&nbsp;+/单(';
  2560. let arr = data.weight_interval[data.weight_interval.length-1];
  2561. arr.forEach((w,j)=>{
  2562. if (j!==arr.length-1)html += w+'-'+arr[j+1]+'/KG,';
  2563. });
  2564. html += (arr[arr.length-1] ? arr[arr.length-1] : 0)+'&nbsp;+/KG)<br></span>';
  2565. return html+"</div>";
  2566. case "initial_weight_price":
  2567. data[key].forEach(arr=>{
  2568. html += "<span class='small'>"+arr+"<br></span>";
  2569. });
  2570. return html+"</div>";
  2571. case "additional_weight_price":
  2572. data[key].forEach(arr=>{
  2573. html += "<span class='small'>"+arr+"<br></span>";
  2574. });
  2575. return html+"</div>";
  2576. case "unit_range":
  2577. data[key].forEach(r=>{
  2578. html += '<span class="small">'+r+'<br></span>';
  2579. });
  2580. return html+"</div>";
  2581. case "other_unit_range":
  2582. data[key].forEach(r=>{
  2583. html += '<span class="small">'+r+'<br></span>';
  2584. });
  2585. return html+"</div>";
  2586. }
  2587. return html+= data[key]+"</div>";
  2588. },
  2589. logisticDataFormat(tar){
  2590. let obj={};
  2591. tar.details.forEach(item => {
  2592. if (obj[item.province_id]){
  2593. if (obj[item.province_id][item.city_id]){
  2594. if (obj[item.province_id][item.city_id][item.unit_id]){
  2595. obj[item.province_id][item.city_id][item.unit_id][item.range] = item;
  2596. }else{
  2597. let arr1={};
  2598. arr1[item.range] = item;
  2599. obj[item.province_id][item.city_id][item.unit_id] = arr1;
  2600. }
  2601. }else{
  2602. let arr1={};
  2603. arr1[item.range] = item;
  2604. let arr2={};
  2605. arr2[item.unit_id] = arr1;
  2606. obj[item.province_id][item.city_id] = arr2;
  2607. }
  2608. }else{
  2609. let arr1={};
  2610. arr1[item.range] = item;
  2611. let arr2={};
  2612. arr2[item.unit_id] = arr1;
  2613. let arr3={};
  2614. arr3[item.city_id] = arr2;
  2615. obj[item.province_id] = arr3;
  2616. }
  2617. });
  2618. return obj;
  2619. },
  2620. logisticDataRestore(tar,type,items=[],count=0){
  2621. if (count===4){
  2622. tar["operation"] = type;
  2623. items.push(tar);
  2624. } else{
  2625. count++;
  2626. for (let key in tar){
  2627. this.logisticDataRestore(tar[key],type,items,count);
  2628. }
  2629. }
  2630. return items;
  2631. },
  2632. },
  2633. });
  2634. </script>
  2635. @stop