create.blade.php 146 KB

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