create.blade.php 145 KB

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