create.blade.php 144 KB

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