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->tax_rate_id ?? ''}}",
  100. linkman : "{{$owner->linkman ?? ''}}",
  101. phone_number : "{{$owner->phone_number ?? ''}}",
  102. description : "{{$owner->description ?? ''}}",
  103. waring_line_on : "{{$owner->waring_line_on ?? ''}}",
  104. subjection : "{{$owner->subjection ?? ''}}",
  105. },
  106. ownerTemp : {},
  107. customers : [
  108. @foreach($customers as $customer)
  109. {id:"{{$customer->id}}",name:"{{$customer->name}}"},
  110. @endforeach
  111. ],
  112. ownerGroups : [
  113. @foreach($ownerGroups as $ownerGroup)
  114. {id:"{{$ownerGroup->id}}",name:"{{$ownerGroup->name}}"},
  115. @endforeach
  116. ],
  117. userGroups : [
  118. @foreach($userGroups as $userGroup)
  119. {id:"{{$userGroup->id}}",name:"{{$userGroup->name}}",warehouse_id:"{{$userGroup->warehouse_id}}"},
  120. @endforeach
  121. ],
  122. warehouses:[
  123. @foreach($warehouses as $warehouse)
  124. {id:"{{$warehouse->id}}",name:"{{$warehouse->name}}"},
  125. @endforeach
  126. ],
  127. style : '',
  128. errors : {!! $errors !!}, //全部的错误提示
  129. upList:{ //控制元素的渐入展开与收起
  130. storage : false,
  131. },
  132. type:"storage",//当前编辑类型 仓储,作业,物流...
  133. currentInputting:{
  134. edittingOperation:null,
  135. },
  136. model:{ //编辑元素绑定值
  137. storage:{
  138. counting_type : "",
  139. using_type : "",
  140. minimum_area : "",
  141. price : [""],
  142. amount_interval : [""],
  143. discount_type : "无减免",
  144. discount_value : "",
  145. unit_id : "",
  146. time_unit_id : "",
  147. },
  148. operation:{},
  149. express:{
  150. name:"",
  151. initial_weight:"",
  152. additional_weight:"",
  153. amount_interval:[""],
  154. weight_interval:[[]],
  155. items:[],
  156. logistics:[],
  157. },
  158. logistic:{
  159. items:[],
  160. other_ranges:[],
  161. ranges:[],
  162. logistics:[],
  163. },
  164. directLogistic:{
  165. items:[],
  166. },
  167. system:{
  168. usage_fee:""
  169. },
  170. },
  171. pool:{//基础数据选择池,以方便异步懒加载而非即时加载 例:units,owners等
  172. counting_type:[
  173. "包仓","灵活用仓","统单价"
  174. ],
  175. using_type:[
  176. "常温","恒温"
  177. ],
  178. discount_type:[
  179. "无减免","按单减免","固定减免"
  180. ],
  181. feature_type:[],
  182. logic : ['包含','不包含','等于',"大于","大于等于","小于","小于等于"],
  183. },
  184. poolMapping:{},//基础数据选择池的映射对象 供展示使用
  185. selectedModel:{//已选定的计费模型
  186. storage:[],
  187. operation:[],
  188. express:[],
  189. logistic:[],
  190. directLogistic:{},
  191. system:{},
  192. },
  193. thisOperationItemIndex:-1,//当前选中的作业费子项下标,用以唤起特征模态框
  194. operationItems:{},//控制作业费子项的渐入展开
  195. importError:[],//导入时的错误数据原因
  196. isShowError:false,//是否展开导入错误信息
  197. isExist:Boolean("{{$isExist ?? false}}"),
  198. isLoad:false,//全局加载标记,符合条件时确保仅加载一次
  199. introduce:{},//引入model
  200. isSearch:false,//是否查询,用于加载动画显示
  201. searchResult:[],//查询结果
  202. searchResultMapping:{},//查询结果映射
  203. selectedResult:"",
  204. searchItem:{},//搜索子项集
  205. searchBase:5,//搜索基数
  206. hover:{},//可悬浮列表
  207. audit:{},//审核按钮
  208. auditList:{
  209. storage:{},operation:{},express:{},logistic:{},directLogistic:{},system:{},
  210. mapping: {
  211. "storage": {
  212. "name": "名称",
  213. "counting_type": "计费类型",
  214. "using_type": "用仓类型",
  215. "minimum_area": "最低起租面积",
  216. "discount_type": "减免类型",
  217. "discount_value": "减免值",
  218. "unit_id": "单位",
  219. "time_unit_id": "计时单位",
  220. "amount_interval": "数量-单价",
  221. "tax_rate_id": "税率",
  222. },
  223. "operation": {
  224. name: "名称",
  225. operation_type: "作业类型",
  226. strategy: "策略",
  227. feature: "特征",
  228. total_price: "按单价",
  229. total_discount_price: "按单减免单价",
  230. discount_count: "减免值",
  231. type_mark: "类型",
  232. surcharge: "附加费",
  233. surcharge_unit_id: "附加费单位",
  234. max_fee: "封顶费",
  235. remark: "备注",
  236. tax_rate_id: "税率",
  237. child: {
  238. strategy: "子策略",
  239. amount: "起步数",
  240. unit_id: "单位",
  241. unit_price: "单价",
  242. feature: "特征",
  243. discount_price: "减免单价",
  244. odd_price: "零头价",
  245. }
  246. },
  247. "express": {
  248. name: "名称",
  249. initial_weight: "首重",
  250. additional_weight: "续重",
  251. weight_interval: "数量-重量",
  252. tax_rate_id: "税率",
  253. child: {
  254. province_id: "省",
  255. initial_weight_price: "初始单价",
  256. additional_weight_price: "续重单价",
  257. },
  258. },
  259. "logistic": {
  260. name: "名称",
  261. unit_id: "单位一",
  262. unit_range: "单位一区间",
  263. other_unit_id: "单位二",
  264. other_unit_range: "单位二区间",
  265. pick_up_price: "提货费",
  266. fuel_price: "燃油附加费",
  267. service_price: "服务费",
  268. tax_rate_id: "税率",
  269. child: {
  270. unit_id: "单位",
  271. range: "区间",
  272. province_id: "省份",
  273. city_id: "城市",
  274. unit_price: "单价",
  275. delivery_fee: "送货费",
  276. initial_fee: "起始计费",
  277. initial_amount: "起始计数",
  278. rate: "费率",
  279. },
  280. },
  281. "directLogistic": {
  282. name: "名称",
  283. base_km: "起步公里数",
  284. tax_rate_id: "税率",
  285. child: {
  286. car_type_id: "车型",
  287. base_fee: "起步费",
  288. additional_fee: "续费(元/KM)"
  289. }
  290. },
  291. }
  292. },//审核对比
  293. selectedAudit:"",//当前选择对比项
  294. showAuditPiece:{
  295. "C":false,"D":false,"U":false
  296. },//显示审核块
  297. isAudit:true,
  298. comparisonTemp:{},
  299. },
  300. created(){
  301. this.filterCustomers = JSON.parse(JSON.stringify(this.customers));
  302. this.filterOwnerGroups = JSON.parse(JSON.stringify(this.ownerGroups));
  303. this.filterUserGroups = JSON.parse(JSON.stringify(this.userGroups));
  304. },
  305. mounted(){
  306. let type = "{{$type ?? ''}}";
  307. this._resetOperation();
  308. this.ownerTemp = JSON.parse(JSON.stringify(this.owner));
  309. if (type){
  310. this.switchBase("three");
  311. this.type = "";
  312. setTimeout(()=>{
  313. this.switchType(type);
  314. if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
  315. if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
  316. },0);
  317. }
  318. $('[data-toggle="tooltip"]').tooltip();
  319. $("#container").removeClass("d-none");
  320. },
  321. methods:{
  322. //重置作业计费数据
  323. _resetOperation(){
  324. this.model.operation = {
  325. operation_type:"入库",
  326. strategy:"默认",
  327. discount_count:[''],
  328. name:"",
  329. isRejected:false,
  330. feature:"",
  331. total_discount_price:[''],
  332. items : [
  333. {strategy:"起步",type:"0",discount_price:['']},
  334. {strategy:"默认",discount_price:['']},
  335. {strategy:"特征",discount_price:['']},
  336. ],
  337. };
  338. },
  339. //悬浮效果
  340. hoverEffect(key,val){
  341. this.$set(this.hover,key,val);
  342. },
  343. //收起展开
  344. show(id){
  345. if (this.upList[id])$("#"+id).slideDown();
  346. else $("#"+id).slideUp();
  347. this.upList[id] = !this.upList[id];
  348. this.$forceUpdate();
  349. },
  350. //清除垃圾数据
  351. _clearRefuse(){
  352. this.errors = {};
  353. this.importError = [];
  354. this.selectedResult = "";
  355. this.searchResult = [];
  356. this.searchResultMapping = {};
  357. this.introduce = {};
  358. },
  359. //切换选项
  360. switchBase(base){
  361. if (!this.owner.id)return;
  362. if (base === this.base)return;
  363. if (base === 'three'){
  364. if (!this.pool.taxRates) this._getTaxRates();
  365. this._loadStorage();
  366. }
  367. if (base === 'two')if (!this.pool.taxRates) this._getTaxRates();
  368. this.base = base;
  369. },
  370. //切换类型
  371. switchType(type){
  372. if (type === this.type)return;//相同终止是为了减少重复加载动作
  373. this._clearRefuse();//清除垃圾数据
  374. let parent = $("#parent");
  375. let dom = "";
  376. switch (type) {
  377. case "storage":
  378. this._loadStorage();
  379. dom = $("#storage-card");
  380. break;
  381. case "operation":
  382. this._loadOperation();
  383. dom = $("#operation-card");
  384. break;
  385. case "express":
  386. this._loadExpress();
  387. dom = $("#express-card");
  388. $("#expressImport").tooltip();
  389. break;
  390. case "logistic":
  391. this._loadLogistic();
  392. dom = $("#logistic-card");
  393. break;
  394. case "directLogistic":
  395. this._loadDirectLogistic();
  396. dom = $("#directLogistic-card");
  397. break;
  398. case "system":
  399. dom = $("#system-card");
  400. if(this.selectedModel.system && this.selectedModel.system.id)this.model.system = this.selectedModel.system;
  401. break;
  402. }
  403. dom.addClass("animation-translation");
  404. dom.fadeOut(500);
  405. setTimeout(function(){
  406. dom.removeClass("animation-translation");
  407. parent.prepend(dom);
  408. dom.fadeIn();
  409. },400);
  410. this.type = type;
  411. },
  412. //下一步
  413. next(){
  414. switch (this.base) {
  415. case "one":
  416. this._verifyOne(()=>{
  417. this.switchBase('two');
  418. });
  419. break;
  420. case "two":
  421. if (this._verifyTwo()){
  422. this.switchBase('three');
  423. }
  424. break;
  425. }
  426. },
  427. //完成
  428. success(){
  429. switch (this.base) {
  430. case "one":
  431. this._verifyOne(()=>{
  432. window.location.href = "{{url('customer/project/index')}}";
  433. });
  434. break;
  435. case "two":
  436. if (this._verifyTwo())window.location.href = "{{url('customer/project/index')}}";
  437. break;
  438. default:
  439. window.tempTip.confirm("<span class='text-danger'>确定后计费模型未保存项将被抛弃,您确认仍要完成吗?</span>",()=>{
  440. window.location.href = "{{url('customer/project/index')}}";
  441. });
  442. break;
  443. }
  444. },
  445. //重置
  446. reset(){
  447. switch (this.base) {
  448. case "one":
  449. this.owner = this.ownerTemp;
  450. break;
  451. case "two":
  452. this.owner = this.ownerTemp;
  453. break;
  454. }
  455. },
  456. //验证基础信息
  457. _verifyOne(func){
  458. if (!this.owner.code){
  459. this.$set(this.errors,"code",["项目代码为必填项"]);
  460. return false;
  461. }
  462. if (!this.owner.name){
  463. this.$set(this.errors,"name",["项目名称为必填项"]);
  464. return false;
  465. }
  466. if (this.owner.name !== this.ownerTemp.name || this.owner.code !== this.ownerTemp.code){
  467. let url = "{{url('maintenance/owner/apiStore')}}";
  468. let params = {name:this.owner.name,code:this.owner.code,id:this.owner.id};
  469. window.tempTip.postBasicRequest(url,params,res=>{
  470. if (res.errors){
  471. this.errors = res.errors;
  472. return;
  473. }
  474. this.errors = {};
  475. this.owner.id = res.id;
  476. this.ownerTemp.id = res.id;
  477. this.ownerTemp.name = res.name;
  478. this.ownerTemp.code = res.code;
  479. func();
  480. });
  481. }else func();
  482. },
  483. //验证详细描述
  484. _verifyTwo(){
  485. let error = {};
  486. if (!this.owner.customer_id) error["customer_id"] = ["必须选择客户"];
  487. if (!this.owner.owner_group_id) error["owner_group_id"] = ["必须选择项目小组"];
  488. if (!this.owner.warehouse_id) error["warehouse_id"] = ["必须选择仓库"];
  489. if (!this.owner.user_workgroup_id) error["user_workgroup_id"] = ["必须选择仓库小组"];
  490. if (!this.owner.tax_rate_id) error["tax_rate_id"] = ["必须选择税率"];
  491. if (JSON.stringify(error) !== "{}"){
  492. this.errors = error;
  493. return;
  494. }
  495. let url = "{{url('customer/project/projectUpdate')}}";
  496. let params = this.owner;
  497. let old = this.ownerTemp;
  498. if (params.customer_id !== old.customer_id ||
  499. params.owner_group_id !== old.owner_group_id ||
  500. params.user_workgroup_id !== old.user_workgroup_id ||
  501. params.warehouse_id !== old.warehouse_id ||
  502. params.tax_rate_id !== old.tax_rate_id ||
  503. params.waring_line_on !== old.waring_line_on ||
  504. params.phone_number !== old.phone_number ||
  505. params.subjection !== old.subjection ||
  506. params.description !== old.description){
  507. let result = undefined;
  508. window.tempTip.postBasicRequest(url,params,res=>{
  509. if (res.errors){
  510. this.errors = res.errors;
  511. result = false;
  512. return;
  513. }
  514. this.errors = [];
  515. this.ownerTemp.customer_id = res.customer_id;
  516. this.ownerTemp.owner_group_id = res.owner_group_id;
  517. this.ownerTemp.user_workgroup_id = res.user_workgroup_id;
  518. this.ownerTemp.warehouse_id = res.warehouse_id;
  519. this.ownerTemp.tax_rate_id = res.tax_rate_id;
  520. this.ownerTemp.waring_line_on = res.waring_line_on;
  521. this.ownerTemp.phone_number = res.phone_number;
  522. this.ownerTemp.description = res.description;
  523. this.ownerTemp.customer_name = params.customer_name;
  524. this.ownerTemp.owner_group_name = params.owner_group_name;
  525. this.ownerTemp.subjection = params.subjection;
  526. result = true;
  527. });
  528. while (result){
  529. if (typeof result !== "undefined")return result;
  530. }
  531. }
  532. return true;
  533. },
  534. //上一步
  535. back(){
  536. switch (this.base) {
  537. case "two":
  538. this.base = 'one';
  539. break;
  540. case "three":
  541. this.base = 'two';
  542. break;
  543. }
  544. },
  545. //重载作业费
  546. _overrideOperation(operation){
  547. if (operation.discount_count){
  548. if (operation.discount_count) operation.discount_count = operation.discount_count.split(",");
  549. if (operation.total_discount_price) operation.total_discount_price = operation.total_discount_price.split(",");
  550. operation.isDiscount = true;
  551. }
  552. operation.items.forEach((item,j)=>{
  553. if (item.discount_price) operation.items[j].discount_price = item.discount_price.split(",");
  554. });
  555. if (operation.total_price)operation.isSingle = true;
  556. if (operation.type_mark===0 || operation.type_mark==='0')operation.isRejected = true;
  557. return operation;
  558. },
  559. //重载快递费
  560. _overrideExpress(express){
  561. express.logistics.forEach((logistic,j)=>{
  562. express.logistics[j] = logistic.id;
  563. });
  564. if (!express.amount_interval || !express.weight_interval){
  565. express.amount_interval = [""];
  566. express.weight_interval = [[]];
  567. }else express.isInterval = true;
  568. return JSON.parse(JSON.stringify(express).replace(/details/g,"items"));
  569. },
  570. //重载物流费
  571. _overrideLogistic(logistic){
  572. logistic.logistics.forEach((l,j)=>{
  573. logistic.logistics[j] = l.id;
  574. });
  575. return JSON.parse(JSON.stringify(logistic).replace(/details/g,"items"));
  576. },
  577. //重载直发费
  578. _overrideDirectLogistic(directLogistic){
  579. return JSON.parse(JSON.stringify(directLogistic).replace(/details/g,"items"));
  580. },
  581. //加载计费模型
  582. _loadPriceModel(){
  583. let url = "{{url('customer/project/getPriceModel')}}";
  584. let params = {id:this.ownerTemp.id};
  585. window.tempTip.postBasicRequest(url,params,res=>{
  586. let audit = {};
  587. if (res.storage_audit_count)audit.storage = true;
  588. if (res.operation_audit_count)audit.operation = true;
  589. if (res.express_audit_count)audit.express = true;
  590. if (res.logistic_audit_count)audit.logistic = true;
  591. if (res.direct_logistic_audit_count)audit.directLogistic = true;
  592. if (res.system_audit_count)audit.system = true;
  593. this.audit = audit;
  594. if (res.owner_storage_price_models.length>0)this.selectedModel.storage = res.owner_storage_price_models;
  595. if (res.owner_price_operations.length>0){
  596. this._loadOperation();
  597. res.owner_price_operations.forEach((operation,i)=>{res.owner_price_operations[i] = this._overrideOperation(operation);});
  598. this.selectedModel.operation = res.owner_price_operations;
  599. }
  600. if (res.owner_price_expresses.length>0){
  601. this._loadExpress();
  602. res.owner_price_expresses.forEach((express,i)=>{
  603. res.owner_price_expresses[i] = this._overrideExpress(express);
  604. this.upList['express-item-'+i] = true;
  605. });
  606. this.selectedModel.express = res.owner_price_expresses;
  607. }
  608. if (res.owner_price_logistics.length>0){
  609. if (res.owner_price_expresses.length===0)this._loadLogistic();
  610. else {this._getUnits();this._getCities();}
  611. res.owner_price_logistics.forEach((logistic,i)=>{
  612. res.owner_price_logistics[i] = this._overrideLogistic(logistic);
  613. this.upList['logistic-item-'+i] = true;
  614. });
  615. this.selectedModel.logistic = res.owner_price_logistics;
  616. }
  617. if (res.owner_price_direct_logistics.length>0){
  618. this._loadDirectLogistic();
  619. this.upList["directLogistic-item"] = true;
  620. this.selectedModel.directLogistic = this._overrideDirectLogistic(res.owner_price_direct_logistics[0]);
  621. }
  622. if (res.owner_price_system)this.selectedModel.system = res.owner_price_system;
  623. setTimeout(()=> {
  624. $(".up").slideUp();
  625. this.isLoad = true;
  626. },0)
  627. });
  628. },
  629. //加载仓储所需基础信息
  630. _loadStorage(){
  631. if (!this.pool.units)this._getUnits();
  632. if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
  633. if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
  634. },
  635. //加载作业
  636. _loadOperation(){
  637. if (!this.pool.units)this._getUnits();
  638. },
  639. //加载快递
  640. _loadExpress(){
  641. if (!this.pool.provinces)this._getProvinces();
  642. if (!this.pool.logistics)this._getLogistics();
  643. },
  644. //加载物流
  645. _loadLogistic(){
  646. if (!this.pool.units) this._getUnits();
  647. if (!this.pool.provinces)this._getProvinces();
  648. if (!this.pool.cities)this._getCities();
  649. if (!this.pool.logistics)this._getLogistics();
  650. },
  651. //加载直发车
  652. _loadDirectLogistic(){
  653. if (!this.pool.cars)this._getCars();
  654. },
  655. //加载引入
  656. loadIntroduce(){
  657. if (!this.pool.owners)this._getOwners();
  658. if (!this.pool.logistics)this._getLogistics();
  659. },
  660. _setModelData(key,val,column='name',append=""){
  661. if (!val)return;
  662. let mapping = [];
  663. val.forEach(item=>{
  664. mapping[item.id] = item[column]+append;
  665. });
  666. this.$set(this.pool,key,val);
  667. this.$set(this.poolMapping,key,mapping);
  668. },
  669. //获取项目
  670. _getOwners(){
  671. let url = "{{url('maintenance/owner/get')}}";
  672. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("owners",res);});
  673. },
  674. //获取单位
  675. _getUnits(){
  676. let url = "{{url('maintenance/unit/getUnits')}}";
  677. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("units",res);});
  678. },
  679. //获取省份
  680. _getProvinces(){
  681. let url = "{{url('maintenance/province/get')}}";
  682. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("provinces",res);});
  683. },
  684. //获取城市
  685. _getCities(){
  686. let url = "{{url('maintenance/city/get')}}";
  687. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("cities",res);});
  688. },
  689. //获取承运商
  690. _getLogistics(){
  691. let url = "{{url('maintenance/logistic/get')}}";
  692. window.tempTip.postBasicRequest(url,{type:''},res=>{
  693. this._setModelData("logistics",res);
  694. setTimeout(()=>{
  695. $(".selectpicker").selectpicker('refresh');
  696. },100);
  697. });
  698. },
  699. //获取车型
  700. _getCars(){
  701. let url = "{{url('maintenance/carType/get')}}";
  702. window.axios.post(url).then(res=>{this._setModelData("cars",res.data);});
  703. },
  704. //获取税率
  705. _getTaxRates(){
  706. let url = "{{url('maintenance/taxRate/get')}}";
  707. window.axios.post(url).then(res=>{this._setModelData("taxRates",res.data,"value","%");});
  708. },
  709. //保存模型
  710. saveModel(){
  711. this._clearRefuse();
  712. switch (this.type) {
  713. case "storage":
  714. this._verifyStorage();
  715. break;
  716. case "operation":
  717. this._verifyOperation();
  718. break;
  719. case "express":
  720. this._verifyExpress();
  721. break;
  722. case "logistic":
  723. this._verifyLogistic();
  724. break;
  725. case "directLogistic":
  726. this._verifyDirectLogistic();
  727. break;
  728. case "system":
  729. this._verifySystem();
  730. break;
  731. }
  732. },
  733. _verifySystem(){
  734. if (this.model.system.usage_fee<0){
  735. this.errors = {usage_fee:["费用不得小于0"]};
  736. return;
  737. }
  738. if (!this.model.system.time_unit_id){
  739. this.errors = {time_unit_id:["未选择计时单位"]};
  740. return;
  741. }
  742. if(this.owner.tax_rate_id && this.model.system.tax_rate_id){
  743. this.errors = {tax_rate_id:["总项税率已存在"]};
  744. return;
  745. }
  746. if(!this.owner.tax_rate_id && !this.model.system.tax_rate_id){
  747. this.errors = {tax_rate_id:["总项税率不存在,子项税率必填"]};
  748. return;
  749. }
  750. let url = "{{url('maintenance/priceModel/apiStoreSystem')}}";
  751. let params = this.model.system;
  752. params.owner_id = this.ownerTemp.id;
  753. window.tempTip.postBasicRequest(url,params,res=>{
  754. if (res && res.errors){
  755. this.errors = res.errors;
  756. return;
  757. }
  758. this.selectedModel.system = res;
  759. this.model.system = {
  760. usage_fee:"",
  761. };
  762. this.errors = {};
  763. this.audit.system = true;
  764. });
  765. },
  766. _verifyStorage(){
  767. let error = {};
  768. if (!this.model.storage.counting_type)error["counting_type"] = ["未选择计费类型"];
  769. if (!this.model.storage.name)error["name"] = ["未填写名称"];
  770. if (!this.model.storage.using_type)error["using_type"] = ["未选择用仓类型"];
  771. if (!this.model.storage.price[0])error["price.0"] = ["未输入单价"];
  772. if (!this.model.storage.discount_type)error["discount_type"] = ["未选择减免类型"];
  773. if (!this.model.storage.unit_id)error["unit_id"] = ["未选择单位"];
  774. if (!this.model.storage.time_unit_id)error["time_unit_id"] = ["未选择计时单位"];
  775. if(this.owner.tax_rate_id && this.model.storage.tax_rate_id)error = {tax_rate_id:["总项税率已存在"]};
  776. if(!this.owner.tax_rate_id && !this.model.storage.tax_rate_id)error = {tax_rate_id:["总项税率不存在,子项税率必填"]};
  777. if (this.model.storage.isInterval){
  778. if (this.model.storage.amount_interval.length<1 || this.model.storage.price.length<1){
  779. error["amount_interval.0"] = ["未设定数量区间"];
  780. error["price.0"] = ["未输入单价"];
  781. }else{
  782. this.model.storage.amount_interval.forEach((amount,i)=>{
  783. if (amount==="")error["amount_interval."+i] = ["未设定数量区间"];
  784. else if (i!==0 && amount<=this.model.storage.amount_interval[i-1])
  785. error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
  786. this.model.storage.amount_interval[i] = parseFloat(this.model.storage.amount_interval[i]);
  787. });
  788. this.model.storage.price.forEach((price,i)=>{
  789. if (price==="")error["price."+i] = ["未输入单价"];
  790. this.model.storage.price[i] = parseFloat(this.model.storage.price[i]);
  791. });
  792. }
  793. }
  794. if (JSON.stringify(error) !== "{}"){
  795. this.errors = error;
  796. return;
  797. }
  798. if (!this.model.storage.isInterval){
  799. this.model.storage.amount_interval = null;
  800. this.model.storage.price = [parseFloat(this.model.storage.price[0])];
  801. }
  802. let url = "{{url('maintenance/priceModel/apiStoreStorage')}}";
  803. let params = this.model.storage;
  804. params.owner_id = this.ownerTemp.id;
  805. window.tempTip.postBasicRequest(url,params,res=>{
  806. if (res && res.errors){
  807. this.errors = res.errors;
  808. return;
  809. }
  810. if (this.model.storage.id){
  811. if (!res) this.selectedModel.storage[this.model.storage.index] = this.model.storage;
  812. else this.$set(this.selectedModel.storage,this.model.storage.index,res);
  813. }else {
  814. this.model.storage.id = res;
  815. this.selectedModel.storage.unshift(this.model.storage);
  816. }
  817. this.model.storage = {
  818. name : "",
  819. counting_type : "",
  820. using_type : "",
  821. minimum_area : "",
  822. price : [""],
  823. amount_interval : [""],
  824. discount_type : "无减免",
  825. discount_value : "",
  826. unit_id : "",
  827. time_unit_id : "",
  828. };
  829. this.errors = {};
  830. this.audit.storage = true;
  831. return "保存成功";
  832. });
  833. },
  834. _verifyOperation() {
  835. if (this.selectedModel.operation.length>0 && !this.model.operation.id){
  836. if (this.model.operation.strategy!=='特征'){
  837. if (!this.selectedModel.operation.every(operation=>{
  838. if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
  839. this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
  840. this.$forceUpdate();
  841. return false;
  842. }
  843. return true;
  844. }))return;
  845. }
  846. }
  847. if (!this.model.operation.name){
  848. this.$set(this.errors,"name",["名称不得为空"]);
  849. return;
  850. }
  851. if(this.owner.tax_rate_id && this.model.operation.tax_rate_id){
  852. this.error = {tax_rate_id:["总项税率已存在"]};return;
  853. }
  854. if(!this.owner.tax_rate_id && !this.model.operation.tax_rate_id){
  855. this.error = {tax_rate_id:["总项税率不存在,子项税率必填"]};return;
  856. }
  857. if (this.model.operation.isDiscount){
  858. let sign = false;
  859. this.model.operation.discount_count.forEach((item,i)=>{
  860. if (!item || (i!==0 && parseFloat(item)<=parseFloat(this.model.operation.discount_count[i-1]))){
  861. this.$set(this.errors,"discount_count_"+i,["非法满减值"]);
  862. sign = true;
  863. }
  864. });
  865. if (sign){
  866. this.$forceUpdate();
  867. return;
  868. }
  869. }
  870. if (!this.model.operation.isRejected && this.model.operation.strategy === '特征' && !this.model.operation.feature){
  871. this.$set(this.errors,"feature",["特征未填写"]);
  872. return;
  873. }
  874. if (this.model.operation.isSingle && !this.model.operation.total_price){
  875. this.$set(this.errors,"total_price",["按单价格不存在"]);
  876. return;
  877. }
  878. if (this.model.operation.isDiscount && this.model.operation.isSingle){
  879. if (!this.model.operation.total_discount_price[0]){
  880. this.$set(this.errors,"total_discount_price",["满减价格不存在"]);
  881. return;
  882. }
  883. this.model.operation.total_discount_price.forEach((item,i)=>{
  884. if (i!==0 && !item)this.model.operation.total_discount_price[i] = this.model.operation.total_discount_price[i-1];
  885. })
  886. }
  887. if (this.model.operation.surcharge && !this.model.operation.surcharge_unit_id){
  888. this.$set(this.errors,"surcharge_unit_id",["耗材附加费单位未选择"]);
  889. return;
  890. }
  891. if (this.model.operation.surcharge_unit_id && !this.model.operation.surcharge){
  892. this.$set(this.errors,"surcharge_unit_id",["耗材附加费未填写"]);
  893. return;
  894. }
  895. if (!this.model.operation.isSingle){
  896. for (let i=0;i<this.model.operation.items.length;i++){
  897. if (this._verifyOperationItem(i))return;
  898. }
  899. this.model.operation.total_discount_price = [];
  900. this.model.operation.total_price = "";
  901. }else this.$set(this.model.operation,"items",[]);
  902. if (!this.model.operation.isDiscount) {
  903. this.model.operation.discount_count = [""];
  904. this.model.operation.total_discount_price = [""];
  905. }
  906. if (this.model.operation.isRejected)this.model.operation.type_mark = 0;
  907. let url = "{{url('maintenance/priceModel/apiStoreOperation')}}";
  908. let params = this.model.operation;
  909. params.owner_id = this.ownerTemp.id;
  910. window.tempTip.postBasicRequest(url,params,res=>{
  911. if (res && res.errors){
  912. if (res.errors.owner_id){
  913. window.tempTip.show(res.errors.owner_id[0]);
  914. return;
  915. }
  916. this.errors = res.errors;
  917. return;
  918. }
  919. res.features = this.model.operation.features;
  920. res.featureFormat = this.model.operation.featureFormat;
  921. for (let i=0;i<res.items.length;i++){
  922. res.items[i].features = this.model.operation.items[i]['features'];
  923. res.items[i].featureFormat = this.model.operation.items[i]['featureFormat'];
  924. res.items[i].type = this.model.operation.items[i]['type'];
  925. res.items[i].discount_price = res.items[i].discount_price ? res.items[i].discount_price.split(",") : [""];
  926. }
  927. if (res.discount_count)res.isDiscount = true;
  928. if (res.total_price)res.isSingle = true;
  929. res.discount_count = res.discount_count ? res.discount_count.split(",") : [""];
  930. res.total_discount_price = res.total_discount_price ? res.total_discount_price.split(",") : [""];
  931. res.isRejected = this.model.operation.type_mark==='0'||this.model.operation.type_mark===0;
  932. if (params.id) this.selectedModel.operation[params.index] = res;
  933. else this.selectedModel.operation.push(res);
  934. this._resetOperation();
  935. this.errors = {};
  936. this.audit.operation = true;
  937. return "保存成功";
  938. });
  939. },
  940. _verifyOperationItem(itemIndex){//验证作业费子项信息完整
  941. let obj = this.model.operation.items[itemIndex];
  942. let sign = false;
  943. if (!this.model.operation.isRejected && obj.strategy === '特征' && !obj.feature) {
  944. this.errors['items.' + itemIndex + '.feature'] = ["必须选择特征"];
  945. sign = true;
  946. }
  947. if (obj.strategy!=='起步' && !obj.amount){
  948. this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
  949. sign = true;
  950. }else if (!obj.amount) obj.amount = 0;
  951. if (obj.strategy!=='起步' && !obj.unit_id){
  952. this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
  953. sign = true;
  954. }else if (!obj.unit_id) obj.unit_id = 0;
  955. if (!obj.unit_price){
  956. this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
  957. sign = true;
  958. }
  959. if (this.model.operation.isDiscount){
  960. if (!obj.discount_price[0]){
  961. this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
  962. sign = true;
  963. }else{
  964. obj.discount_price.forEach((item,i)=>{
  965. if (i!==0&&!item) obj.discount_price[i]=obj.discount_price[i-1];
  966. })
  967. }
  968. }
  969. if (sign)this.$forceUpdate();
  970. return sign;
  971. },
  972. _verifyExpress(){
  973. let error = {};
  974. if (!this.model.express.name)error.name = ["名称不得为空"];
  975. if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
  976. if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
  977. if(this.owner.tax_rate_id && this.model.express.tax_rate_id)error = {tax_rate_id:["总项税率已存在"]};
  978. if(!this.owner.tax_rate_id && !this.model.express.tax_rate_id)error = {tax_rate_id:["总项税率不存在,子项税率必填"]};
  979. if (this.model.express.items.length>0){
  980. this.model.express.items.forEach((item,index)=>{
  981. if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
  982. if (!this.model.express.isInterval){
  983. if (!item.initial_weight_price[0][0])error["item."+index+".initial_weight_price.0.0"] = ["不存在"];
  984. if (!item.additional_weight_price[0][0])error["item."+index+".additional_weight_price.0.0"] = ["不存在"];
  985. }else{
  986. item.initial_weight_price.forEach((arr,i)=>{
  987. arr.forEach((price,j)=>{
  988. if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
  989. });
  990. });
  991. item.additional_weight_price.forEach((arr,i)=>{
  992. arr.forEach((price,j)=>{
  993. if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
  994. });
  995. });
  996. }
  997. });
  998. }
  999. if (this.model.express.isInterval){
  1000. this.model.express.amount_interval.forEach((amount,i)=>{
  1001. if (amount==="") error["amount_interval."+i] = ["区间值不得为空"];
  1002. else if (i!==0 && amount<=this.model.express.amount_interval[i-1])error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
  1003. if (this.model.express.weight_interval[i].length>0){
  1004. this.model.express.weight_interval[i].forEach((weight,j)=>{
  1005. this.model.express.weight_interval[i][j] = parseFloat(this.model.express.weight_interval[i][j]);
  1006. if (weight==="") error["weight_interval."+i+"."+j] = ["区间值不得为空"];
  1007. else if (j!==0 && weight<=this.model.express.weight_interval[j-1])error["weight_interval."+i+"."+j] = ["阶梯区间应大于上一区间值"];
  1008. })
  1009. }
  1010. });
  1011. }
  1012. if (JSON.stringify(error) !== "{}"){
  1013. this.errors = error;
  1014. return;
  1015. }
  1016. if (!this.model.express.isInterval){
  1017. this.model.express.amount_interval = null;
  1018. this.model.express.weight_interval = null;
  1019. if (this.model.express.items.length>0){
  1020. this.model.express.items.forEach((item,i)=>{
  1021. this.model.express.items[i].initial_weight_price = [[parseFloat(item.initial_weight_price[0][0])]];
  1022. this.model.express.items[i].additional_weight_price = [[parseFloat(item.additional_weight_price[0][0])]];
  1023. });
  1024. }
  1025. }
  1026. let url = "{{url('maintenance/priceModel/apiStoreExpress')}}";
  1027. let params = this.model.express;
  1028. params.owner_id = this.ownerTemp.id;
  1029. window.tempTip.postBasicRequest(url,params,res=>{
  1030. if (res && res.errors){
  1031. this.errors = res.errors;
  1032. if (res.errors.owner_id)window.tempTip.show(res.errors.owner_id[0]);
  1033. return;
  1034. }
  1035. if (!this.model.express.amount_interval) this.model.express.amount_interval = [""];
  1036. if (!this.model.express.weight_interval) this.model.express.weight_interval = [[]];
  1037. this.model.express.items.forEach((item,i)=>{
  1038. item.id = res.details[i].id;
  1039. });
  1040. if (this.model.express.id){
  1041. if (res.operation) this.model.express.id = res.id;
  1042. this.selectedModel.express[this.model.express.index] = this.model.express;
  1043. }else{
  1044. this.model.express.id = res.id;
  1045. this.selectedModel.express.unshift(this.model.express);
  1046. }
  1047. this.model.express = {
  1048. name:"",
  1049. initial_weight:"",
  1050. additional_weight:"",
  1051. amount_interval:[""],
  1052. weight_interval:[[]],
  1053. items:[],
  1054. logistics:[],
  1055. };
  1056. this.errors = {};
  1057. this.importError = [];
  1058. $(".selectpicker").filter('.express').selectpicker('val',[]);
  1059. this.audit.express = true;
  1060. return "保存成功";
  1061. });
  1062. },
  1063. _verifyLogistic(){
  1064. let error = {};
  1065. if (!this.model.logistic.name) error.name = ["名称不得为空"];
  1066. if (!this.model.logistic.unit_id) error.unit_id = ["单位一不得为空"];
  1067. if (!this.model.logistic.unit_range) error.unit_range = ["区间值不得为空"];
  1068. if (!this.model.logistic.other_unit_id) error.other_unit_id = ["单位二不得为空"];
  1069. if (!this.model.logistic.other_unit_range) error.other_unit_range = ["区间值不得为空"];
  1070. if(this.owner.tax_rate_id && this.model.logistic.tax_rate_id)error = {tax_rate_id:["总项税率已存在"]};
  1071. if(!this.owner.tax_rate_id && !this.model.logistic.tax_rate_id)error = {tax_rate_id:["总项税率不存在,子项税率必填"]};
  1072. if (JSON.stringify(error) !== "{}"){
  1073. this.errors = error;
  1074. return;
  1075. }
  1076. let url = "{{url('maintenance/priceModel/apiStoreLogistic')}}";
  1077. let params = this.model.logistic;
  1078. params.owner_id = this.ownerTemp.id;
  1079. window.tempTip.postBasicRequest(url,params,res=>{
  1080. if (res && res.errors){
  1081. this.errors = res.errors;
  1082. window.tempTip.show("检查您的子项详情列表是否完整");
  1083. return;
  1084. }
  1085. this.model.logistic.items.forEach((item,i)=>{
  1086. item.id = res.details[i].id;
  1087. });
  1088. if (this.model.logistic.id){
  1089. if (res.operation) this.model.logistic.id = res.id;
  1090. this.selectedModel.logistic[this.model.logistic.index] = this.model.logistic;
  1091. }else {
  1092. this.model.logistic.id = res.id;
  1093. this.selectedModel.logistic.unshift(this.model.logistic);
  1094. }
  1095. this.model.logistic = {
  1096. items:[],
  1097. other_ranges:[],
  1098. ranges:[],
  1099. logistics:[],
  1100. };
  1101. this.errors = {};
  1102. this.importError = [];
  1103. $(".selectpicker").filter('.logistic').selectpicker('val',[]);
  1104. this.audit.logistic = true;
  1105. return "保存成功";
  1106. });
  1107. },
  1108. _verifyDirectLogistic(){
  1109. let error = {};
  1110. if (!this.model.directLogistic.name) error.name = ["名称不得为空"];
  1111. if (!this.model.directLogistic.base_km) error.base_km = ["起步公里数不得为空"];
  1112. if(this.owner.tax_rate_id && this.model.directLogistic.tax_rate_id)error = {tax_rate_id:["总项税率已存在"]};
  1113. if(!this.owner.tax_rate_id && !this.model.directLogistic.tax_rate_id)error = {tax_rate_id:["总项税率不存在,子项税率必填"]};
  1114. if (JSON.stringify(error) !== "{}"){
  1115. this.errors = error;
  1116. return;
  1117. }
  1118. let url = "{{url('maintenance/priceModel/apiStoreDirectLogistic')}}";
  1119. let params = this.model.directLogistic;
  1120. params.owner_id = this.ownerTemp.id;
  1121. window.tempTip.postBasicRequest(url,params,res=>{
  1122. if (res && res.errors){
  1123. this.errors = res.errors;
  1124. return;
  1125. }
  1126. this.model.directLogistic.items.forEach((item,i)=>{
  1127. item.id = res.details[i].id;
  1128. });
  1129. this.model.directLogistic.id = res.id;
  1130. this.selectedModel.directLogistic = this.model.directLogistic;
  1131. this.model.directLogistic = {
  1132. items:[],
  1133. };
  1134. this.errors = {};
  1135. this.importError = [];
  1136. this.audit.directLogistic = true;
  1137. return "保存成功";
  1138. });
  1139. },
  1140. //增加作业费特征子项
  1141. addOperationItem(strategy){
  1142. if (strategy!=='特征' && !this.model.operation.items.every(item=>{
  1143. if (item.strategy===strategy)return false;
  1144. return true;
  1145. }))return;
  1146. this.model.operation.items.push({
  1147. strategy:strategy,
  1148. discount_price:new Array(this.model.operation.discount_count.length).fill(""),
  1149. });
  1150. },
  1151. //删除作业费子项
  1152. delOperationItem(index){
  1153. this.$delete(this.model.operation.items,index);
  1154. },
  1155. //显示特征选择modal
  1156. showAddFeatureModal(index){
  1157. let types = {!! json_encode(\App\Feature::TYPE,JSON_UNESCAPED_UNICODE) !!};
  1158. let typeIn = {!! json_encode(array_keys(\App\Feature::MAPPING['store'])) !!};
  1159. let typeOut = {!! json_encode(array_keys(\App\Feature::MAPPING['order'])) !!};
  1160. let node = {!! json_encode(\App\Feature::TYPE_NODE) !!};
  1161. let temp = [];
  1162. if (this.model.operation.operation_type==='入库'){
  1163. if (index === -1)typeIn.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
  1164. else typeIn.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
  1165. }else{
  1166. if (index === -1)typeOut.forEach(t=>{if (types[t] && node.indexOf(t)===-1) temp.push(types[t]);});
  1167. else typeOut.forEach(t=>{if (types[t] && node.indexOf(t)!==-1) temp.push(types[t]);});
  1168. }
  1169. this.pool.feature_type = temp;
  1170. if (index === -1){
  1171. if (!this.model.operation.feature){
  1172. this.model.operation.features = this._createFeature();
  1173. this.thisOperationItemIndex = index;
  1174. this.$forceUpdate();
  1175. $("#addFeatureModal").modal("show");
  1176. return;
  1177. }
  1178. if (this.model.operation.features) {
  1179. this.thisOperationItemIndex = index;
  1180. $("#addFeatureModal").modal("show");
  1181. return;
  1182. }
  1183. }else{
  1184. if (!this.model.operation.items[index].feature){
  1185. this.model.operation.items[index].features = this._createFeature();
  1186. this.thisOperationItemIndex = index;
  1187. this.$forceUpdate();
  1188. $("#addFeatureModal").modal("show");
  1189. return;
  1190. }
  1191. if (this.model.operation.items[index].features) {
  1192. this.thisOperationItemIndex = index;
  1193. $("#addFeatureModal").modal("show");
  1194. return;
  1195. }
  1196. }
  1197. let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
  1198. let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
  1199. window.tempTip.postBasicRequest(url,{feature:feature},res=>{
  1200. if (!res || res.length === 0){
  1201. res = this._createFeature();
  1202. }
  1203. if (index === -1) this.model.operation.features = res;
  1204. else this.model.operation.items[index].features = res;
  1205. this.thisOperationItemIndex = index;
  1206. this.$forceUpdate();
  1207. $("#addFeatureModal").modal("show");
  1208. });
  1209. },
  1210. //增加特征
  1211. addFeature(){
  1212. let obj = {
  1213. "strategyGroupStartSign": false,
  1214. "calculation" : "",
  1215. "type" : "",
  1216. "id" : "",
  1217. "logic" : "",
  1218. "describe" : "",
  1219. "strategyGroupEndSign" : false,
  1220. };
  1221. if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
  1222. else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
  1223. this.$forceUpdate();
  1224. },
  1225. _createFeature(){
  1226. return [{
  1227. "strategyGroupStartSign": false,
  1228. "calculation" : "",
  1229. "type" : "",
  1230. "id" : "",
  1231. "logic" : "",
  1232. "describe" : "",
  1233. "strategyGroupEndSign" : false,
  1234. }];
  1235. },
  1236. //删除特征
  1237. delFeature(index) {
  1238. if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
  1239. else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
  1240. this.$forceUpdate();
  1241. },
  1242. //提交特征更新现有
  1243. submitFeature(){
  1244. let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
  1245. let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
  1246. window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
  1247. if (this.thisOperationItemIndex === -1){
  1248. this.model.operation.feature = res.feature;
  1249. this.model.operation.featureFormat = res.featureFormat;
  1250. } else {
  1251. this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
  1252. this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
  1253. this.$forceUpdate();
  1254. }
  1255. $("#addFeatureModal").modal("hide");
  1256. return "已更新特征";
  1257. },true);
  1258. },
  1259. //移入移出时更改长文本显示效果
  1260. textClass(event,isOver){
  1261. event = event.target.children[0];
  1262. if (isOver) event.className = "text-overflow-warp-100";
  1263. else event.className = "cursor-pointer text-overflow-replace-100";
  1264. },
  1265. //展开子策略
  1266. showOperationItem(index){
  1267. let trId = "operation-tr-"+index;
  1268. let itemId = "operation-item-"+index;
  1269. if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
  1270. this.operationItems['_'+index] = false;
  1271. $("#"+itemId).slideUp(undefined,function () {
  1272. $("#"+trId).addClass("d-none");
  1273. });
  1274. }else {
  1275. $("#"+trId).removeClass("d-none");
  1276. this.operationItems['_'+index] = true;
  1277. $("#"+itemId).slideDown();
  1278. }
  1279. this.$forceUpdate();
  1280. },
  1281. //新增快递子项
  1282. addExpressItem(){
  1283. let arr = [];
  1284. this.model.express.amount_interval.forEach((amount,i)=>{
  1285. if (this.model.express.weight_interval[i].length>0){
  1286. let it = [];
  1287. this.model.express.weight_interval[i].forEach(weight=>{
  1288. it.push("");
  1289. });
  1290. arr.push(it);
  1291. }else arr.push([""]);
  1292. });
  1293. let re=[];
  1294. for(let i=0;i<arr.length;i++){
  1295. re.push(arr[i].slice(0));
  1296. }
  1297. this.model.express.items.unshift({
  1298. province_id : "",
  1299. initial_weight_price:arr,
  1300. additional_weight_price:re,
  1301. });
  1302. },
  1303. //删除快递子项
  1304. delExpressItem(index){
  1305. window.tempTip.confirm("确定要删除该子项吗?",res=>{
  1306. this.$delete(this.model.express.items,index);
  1307. })
  1308. },
  1309. //选择文件
  1310. selectFile(id){
  1311. this.importError = [];
  1312. $("#"+id).click();
  1313. },
  1314. _getExpressImportData(index,data){
  1315. let arr = [];
  1316. this.model.express.amount_interval.forEach((amount,i)=>{
  1317. if (this.model.express.weight_interval[i].length>0){
  1318. let it = [];
  1319. this.model.express.weight_interval[i].forEach(weight=>{
  1320. it.push(data[index] ? data[index] : "");
  1321. index++;
  1322. });
  1323. arr.push(it);
  1324. }else {
  1325. arr.push([data[index] ? data[index] : ""]);
  1326. index++;
  1327. }
  1328. });
  1329. return [arr,index];
  1330. },
  1331. //导入快递子项
  1332. importExpress(e){
  1333. let file=e.target.files[0];
  1334. window.tempTip.setDuration(3000);
  1335. if (!file){
  1336. window.tempTip.show("未选择文件");
  1337. return;
  1338. }
  1339. let formData = new FormData();
  1340. formData.append("file",file);
  1341. window.axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  1342. 'Content-Type':'multipart/form-data'
  1343. }).then(res=>{
  1344. if (res.data.success) {
  1345. res.data.data.data.forEach(data=>{
  1346. if(this.model.express.items.every(item=>{
  1347. if (data.province_id === item.province_id)return false;
  1348. return true;
  1349. })){
  1350. if (this.model.express.isInterval){
  1351. let result = this._getExpressImportData(1,data);
  1352. this.model.express.items.push({
  1353. province_id : data[0],
  1354. initial_weight_price:result[0],
  1355. additional_weight_price:this._getExpressImportData(result[1],data)[0],
  1356. });
  1357. }else this.model.express.items.push({
  1358. province_id : data[0],
  1359. initial_weight_price:[[data[1]]],
  1360. additional_weight_price:[[data[2]]],
  1361. });
  1362. }
  1363. });
  1364. this.importError = res.data.data.errors;
  1365. window.tempTip.setDuration(2000);
  1366. window.tempTip.showSuccess("导入成功!");
  1367. return;
  1368. }
  1369. window.tempTip.show(res.data.data);
  1370. }).catch(err=> {
  1371. window.tempTip.show("网络错误:"+err);
  1372. })
  1373. },
  1374. //物流详情列表modal
  1375. showDetailModal() {
  1376. $("#logisticModal").modal("show");
  1377. },
  1378. //新增物流详情
  1379. addLogisticDetail(){
  1380. this.model.logistic.items.unshift({});
  1381. },
  1382. //导入物流详情
  1383. importLogistic(e){
  1384. window.tempTip.setIndex(1099);
  1385. let file=e.target.files[0];
  1386. if (!file){
  1387. window.tempTip.setDuration(3000);
  1388. window.tempTip.show("未选择文件");
  1389. return;
  1390. }
  1391. let formData = new FormData();
  1392. formData.append("file",file);
  1393. window.axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  1394. 'Content-Type':'multipart/form-data'
  1395. }).then(res=>{
  1396. if (res.data.success) {
  1397. res.data.data.forEach(data=>{
  1398. //过滤非已选择单位的数据
  1399. let id = "";
  1400. if (data.unit_id === this.poolMapping.units[this.model.logistic.unit_id]) id = this.model.logistic.unit_id;
  1401. if (data.unit_id === this.poolMapping.units[this.model.logistic.other_unit_id]) id = this.model.logistic.other_unit_id;
  1402. if (id){
  1403. //过滤重复数据
  1404. let unique = this.model.logistic.items.every(item=>{
  1405. if (id === item.unit_id && data.range === item.range
  1406. && data.province_id === item.province_id && data.city_id === item.city_id)return false;
  1407. return true;
  1408. });
  1409. if (unique){
  1410. data.unit_id = id;
  1411. this.model.logistic.items.push(data);
  1412. }
  1413. }
  1414. });
  1415. this.importError = res.data.errors;
  1416. window.tempTip.setDuration(3000);
  1417. window.tempTip.showSuccess("导入成功!");
  1418. return;
  1419. }
  1420. window.tempTip.setDuration(3000);
  1421. window.tempTip.show(res.data.data);
  1422. }).catch(err=> {
  1423. window.tempTip.setDuration(3000);
  1424. window.tempTip.show("网络错误:"+err);
  1425. })
  1426. },
  1427. //删除物流子项
  1428. delLogisticItem(index){
  1429. this.$delete(this.model.logistic.items,index);
  1430. },
  1431. //改变物流区间时改变可选择项
  1432. changeRange(type){
  1433. if (type === 'ranges'){
  1434. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1435. }else{
  1436. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1437. }
  1438. },
  1439. //增加直发车子项
  1440. addDirectLogisticItem(){
  1441. this.model.directLogistic.items.unshift({
  1442. car_type_id : "",
  1443. base_fee:"",
  1444. additional_fee:"",
  1445. });
  1446. },
  1447. //导入直发车子项
  1448. importDirectLogistic(e){
  1449. window.tempTip.setIndex(1099);
  1450. let file=e.target.files[0];
  1451. if (!file){
  1452. window.tempTip.setDuration(3000);
  1453. window.tempTip.show("未选择文件");
  1454. return;
  1455. }
  1456. let formData = new FormData();
  1457. formData.append("file",file);
  1458. window.axios.post('{{url('maintenance/priceModel/directLogistic/import')}}',formData,{
  1459. 'Content-Type':'multipart/form-data'
  1460. }).then(res=>{
  1461. if (res.data.success) {
  1462. if (this.model.directLogistic.items.length > 0){
  1463. res.data.data.forEach(data=>{
  1464. let unique = this.model.directLogistic.items.every(item=>{
  1465. if (item.car_type_id === data.car_type_id)return false;
  1466. return true;
  1467. });
  1468. if (unique) this.model.directLogistic.items.unshift(data);
  1469. });
  1470. }else this.model.directLogistic.items = res.data.data;
  1471. this.importError = res.data.errors;
  1472. window.tempTip.setDuration(3000);
  1473. window.tempTip.showSuccess("导入成功!");
  1474. return;
  1475. }
  1476. window.tempTip.setDuration(3000);
  1477. window.tempTip.show(res.data.data);
  1478. }).catch(err=> {
  1479. window.tempTip.setDuration(3000);
  1480. window.tempTip.show("网络错误:"+err);
  1481. })
  1482. },
  1483. //删除直发车子项
  1484. delDirectLogisticItem(index){
  1485. this.$delete(this.model.directLogistic.items,index);
  1486. },
  1487. //改变客户
  1488. selectOwner(){
  1489. let id = this.owner.customer_id;
  1490. this.customers.some(customer=>{
  1491. if (id === customer.id){
  1492. this.owner.customer_name = customer.name;
  1493. return true;
  1494. }
  1495. });
  1496. },
  1497. //改变小组
  1498. selectGroup(){
  1499. let id = this.owner.owner_group_id;
  1500. this.ownerGroups.some(group=>{
  1501. if (id === group.id){
  1502. this.owner.owner_group_name = group.name;
  1503. return true;
  1504. }
  1505. });
  1506. },
  1507. //获取引入计费模型查询列表搜索
  1508. searchPriceModel(){
  1509. this.isSearch = true;
  1510. switch (this.type) {
  1511. case "storage":
  1512. this._getStoragePriceModel();
  1513. break;
  1514. case "operation":
  1515. this._getOperationPriceModel();
  1516. break;
  1517. case "express":
  1518. this._getExpressPriceModel();
  1519. break;
  1520. case "logistic":
  1521. this._getLogisticPriceModel();
  1522. break;
  1523. case "system":
  1524. this._getSystemPriceModel();
  1525. break;
  1526. default:
  1527. this._getDirectLogisticPriceModel();
  1528. }
  1529. },
  1530. _getStoragePriceModel(){
  1531. let url = "{{url('maintenance/priceModel/apiGetStorage')}}";
  1532. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1533. let result = [];
  1534. let mapping = {};
  1535. res.forEach(model=> {
  1536. let text = model.name+" ("+model.counting_type+"-"+model.using_type+")";
  1537. result.push({id:model.id,text:text});
  1538. mapping[model.id] = {
  1539. name : model.name,
  1540. counting_type : model.counting_type,
  1541. using_type : model.using_type,
  1542. minimum_area : model.minimum_area,
  1543. price : model.price,
  1544. discount_type : model.discount_type,
  1545. discount_value : model.discount_value,
  1546. amount_interval : model.amount_interval ? model.amount_interval : [""],
  1547. isInterval:!!model.amount_interval,
  1548. unit_id : model.unit_id,
  1549. };
  1550. });
  1551. this.searchResult = result;
  1552. this.searchResultMapping = mapping;
  1553. this.isSearch = false;
  1554. });
  1555. },
  1556. _getOperationPriceModel(){
  1557. let url = "{{url('maintenance/priceModel/apiGetOperation')}}";
  1558. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1559. let result = [];
  1560. let mapping = {};
  1561. res.forEach(model=> {
  1562. let text = model.name+" ("+model.operation_type+"-"+model.strategy+")";
  1563. result.push({id:model.id,text:text});
  1564. mapping[model.id] = {
  1565. name : model.name,
  1566. operation_type : model.operation_type,
  1567. strategy : model.strategy,
  1568. feature : model.feature,
  1569. featureFormat : model.featureFormat,
  1570. remark : model.remark,
  1571. type_mark : model.type_mark,
  1572. isRejected : model.type_mark==='0'||model.type_mark===0,
  1573. items:model.items,
  1574. };
  1575. });
  1576. this.searchResult = result;
  1577. this.searchResultMapping = mapping;
  1578. this.isSearch = false;
  1579. });
  1580. },
  1581. _getExpressPriceModel(){
  1582. let url = "{{url('maintenance/priceModel/apiGetExpress')}}";
  1583. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1584. let result = [];
  1585. let mapping = {};
  1586. res.forEach(model=> {
  1587. let text = model.name+" (首重:"+model.initial_weight+"KG 续重:"+model.additional_weight+"KG)";
  1588. result.push({id:model.id,text:text});
  1589. let logistics = [];
  1590. model.logistics.forEach(logistic=>{
  1591. logistics.push(logistic.id);
  1592. });
  1593. let items = [];
  1594. model.details.forEach(item=>{
  1595. items.push({
  1596. province_id:item.province_id,
  1597. initial_weight_price:item.initial_weight_price,
  1598. additional_weight_price:item.additional_weight_price,
  1599. });
  1600. });
  1601. mapping[model.id] = {
  1602. logistics : logistics,
  1603. name:model.name,
  1604. initial_weight:model.initial_weight,
  1605. additional_weight:model.additional_weight,
  1606. amount_interval:model.amount_interval ? model.amount_interval : [""],
  1607. weight_interval:model.weight_interval ? model.weight_interval : [[]],
  1608. isInterval:!!model.amount_interval,
  1609. items:items,
  1610. };
  1611. });
  1612. this.searchResult = result;
  1613. this.searchResultMapping = mapping;
  1614. this.isSearch = false;
  1615. });
  1616. },
  1617. _getSystemPriceModel(){
  1618. this.searchResult = [];
  1619. this.searchResultMapping = [];
  1620. this.isSearch = false;
  1621. },
  1622. _getLogisticPriceModel(){
  1623. let url = "{{url('maintenance/priceModel/apiGetLogistic')}}";
  1624. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1625. let result = [];
  1626. let mapping = {};
  1627. res.forEach(model=> {
  1628. let text = model.name+" (单位一:"+this.poolMapping.units[model.unit_id]+"["+model.unit_range+
  1629. "] 单位二:"+this.poolMapping.units[model.other_unit_id]+"["+model.other_unit_range+"])";
  1630. result.push({id:model.id,text:text});
  1631. let logistics = [];
  1632. model.logistics.forEach(logistic=>{
  1633. logistics.push(logistic.id);
  1634. });
  1635. let items = [];
  1636. model.details.forEach(item=>{
  1637. items.push({
  1638. unit_id:item.unit_id,
  1639. range:item.range,
  1640. province_id:item.province_id,
  1641. city_id:item.city_id,
  1642. unit_price:item.unit_price,
  1643. delivery_fee:item.delivery_fee,
  1644. initial_fee:item.initial_fee,
  1645. initial_amount:item.initial_amount,
  1646. rate:item.rate,
  1647. });
  1648. });
  1649. mapping[model.id] = {
  1650. logistics : logistics,
  1651. name:model.name,
  1652. unit_range:model.unit_range,
  1653. unit_id:model.unit_id,
  1654. other_unit_range:model.other_unit_range,
  1655. other_unit_id:model.other_unit_id,
  1656. pick_up_price:model.pick_up_price,
  1657. fuel_price:model.fuel_price,
  1658. service_price:model.service_price,
  1659. items:items,
  1660. };
  1661. });
  1662. this.searchResult = result;
  1663. this.searchResultMapping = mapping;
  1664. this.isSearch = false;
  1665. });
  1666. },
  1667. _getDirectLogisticPriceModel(){
  1668. let url = "{{url('maintenance/priceModel/apiGetDirectLogistic')}}";
  1669. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1670. let result = [];
  1671. let mapping = {};
  1672. res.forEach(model=> {
  1673. let text = model.name+" (起步数:"+model.base_km+"KM)";
  1674. result.push({id:model.id,text:text});
  1675. let items = [];
  1676. model.details.forEach(item=>{
  1677. items.push({
  1678. car_type_id:item.car_type_id,
  1679. base_fee:item.base_fee,
  1680. additional_fee:item.additional_fee,
  1681. });
  1682. });
  1683. mapping[model.id] = {
  1684. name:model.name,
  1685. base_km:model.base_km,
  1686. items:items,
  1687. };
  1688. });
  1689. this.searchResult = result;
  1690. this.searchResultMapping = mapping;
  1691. this.isSearch = false;
  1692. });
  1693. },
  1694. //提交引入
  1695. submitIntroduce(){
  1696. if (!this.selectedResult || !this.searchResultMapping[this.selectedResult]){
  1697. window.tempTip.setDuration(3000);
  1698. window.tempTip.show("尚未选择引入项,请单击选择列表,如列表为空则无结果");
  1699. return;
  1700. }
  1701. let model = this.searchResultMapping[this.selectedResult];
  1702. switch (this.type) {
  1703. case "storage":
  1704. this.model.storage = model;
  1705. break;
  1706. case "operation":
  1707. this.model.operation = model;
  1708. break;
  1709. case "express":
  1710. this.model.express = model;
  1711. break;
  1712. case "logistic":
  1713. this.model.logistic = model;
  1714. break;
  1715. default:
  1716. this.model.directLogistic = model;
  1717. break;
  1718. }
  1719. $("#introduce").modal('hide');
  1720. window.tempTip.setDuration(2000);
  1721. window.tempTip.showSuccess("引入成功");
  1722. },
  1723. //删除仓储
  1724. delStorage(item,index){
  1725. window.tempTip.confirm("您确定要删除仓储计费“"+item.name+"”吗?",()=>{
  1726. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelStorage')}}",{id:item.id},res=>{
  1727. this.$delete(this.selectedModel.storage,index);
  1728. this.audit.storage = true;
  1729. return "删除“"+item.name+"”成功";
  1730. });
  1731. });
  1732. },
  1733. //删除作业
  1734. delOperation(item,index){
  1735. window.tempTip.confirm("您确定要删除作业计费“"+item.name+"”吗?",()=>{
  1736. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperation')}}",{id:item.id},res=>{
  1737. this.$delete(this.selectedModel.operation,index);
  1738. this.audit.operation = true;
  1739. return "删除“"+item.name+"”成功";
  1740. });
  1741. });
  1742. },
  1743. //删除作业子项
  1744. deleteOperationItem(item,index,parentIndex){
  1745. window.tempTip.confirm("您确定要删除该作业子项吗?",()=>{
  1746. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperationItem')}}",{id:item.id},res=>{
  1747. if (res) this.$set(this.selectedModel.operation,parentIndex,this._overrideOperation(res));
  1748. else this.$delete(this.selectedModel.operation[parentIndex].items,index);
  1749. this.audit.operation = true;
  1750. return "删除成功";
  1751. });
  1752. });
  1753. },
  1754. //删除快递
  1755. delExpress(item,index){
  1756. window.tempTip.confirm("您确定要删除该快递计费“"+item.name+"”吗?",()=>{
  1757. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpress')}}",{id:item.id},res=>{
  1758. this.$delete(this.selectedModel.express,index);
  1759. this.audit.express = true;
  1760. return "删除“"+item.name+"”成功";
  1761. });
  1762. });
  1763. },
  1764. //删除快递子项
  1765. deleteExpressItem(item,index,parentIndex){
  1766. window.tempTip.confirm("您确定要删除该快递计费子项吗?",()=>{
  1767. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpressItem')}}",{id:item.id},res=>{
  1768. if (res) this.$set(this.selectedModel.express,parentIndex,this._overrideExpress(res));
  1769. else this.$delete(this.selectedModel.express[parentIndex].items,index);
  1770. this.audit.express = true;
  1771. return "删除成功";
  1772. });
  1773. });
  1774. },
  1775. //删除物流
  1776. delLogistic(item,index){
  1777. window.tempTip.confirm("您确定要删除该物流计费“"+item.name+"”吗?",()=>{
  1778. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogistic')}}",{id:item.id},res=>{
  1779. this.$delete(this.selectedModel.logistic,index);
  1780. this.audit.logistic = true;
  1781. return "删除“"+item.name+"”成功";
  1782. });
  1783. });
  1784. },
  1785. //删除物流子项
  1786. deleteLogisticItem(item,index,parentIndex){
  1787. window.tempTip.confirm("您确定要删除该物流计费子项吗?",()=>{
  1788. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogisticItem')}}",{id:item.id},res=>{
  1789. if (res) this.$set(this.selectedModel.logistic,parentIndex,this._overrideLogistic(res));
  1790. else this.$delete(this.selectedModel.logistic[parentIndex].items,index);
  1791. this.audit.logistic = true;
  1792. return "删除成功";
  1793. });
  1794. });
  1795. },
  1796. //删除直发车
  1797. delDirectLogistic(item){
  1798. window.tempTip.confirm("您确定要删除该直发车计费“"+item.name+"”吗?",()=>{
  1799. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogistic')}}",{id:item.id},res=>{
  1800. this.selectedModel.directLogistic = {};
  1801. this.audit.directLogistic = true;
  1802. return "删除“"+item.name+"”成功";
  1803. });
  1804. });
  1805. },
  1806. //删除直发车子项
  1807. deleteDirectLogisticItem(item,index){
  1808. window.tempTip.confirm("您确定要删除该直发车计费子项吗?",()=>{
  1809. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogisticItem')}}",{id:item.id},res=>{
  1810. if (res) this.$set(this.selectedModel,"directLogistic",this._overrideDirectLogistic(res));
  1811. else this.$delete(this.selectedModel.directLogistic.items,index);
  1812. this.audit.directLogistic = true;
  1813. return "删除成功";
  1814. });
  1815. });
  1816. },
  1817. //删除系统
  1818. deleteSystem(item){
  1819. window.tempTip.confirm("您确定要删除该系统计费吗?",()=>{
  1820. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelSystem')}}",{id:item.id},res=>{
  1821. this.$set(this.selectedModel,"system",{usage_fee:""});
  1822. this.audit.system = true;
  1823. return "删除成功";
  1824. });
  1825. });
  1826. },
  1827. //编辑仓储
  1828. editStorage(index){
  1829. this.switchType("storage");
  1830. this.model.storage = JSON.parse(JSON.stringify(this.selectedModel.storage[index]));
  1831. this.model.storage.index = index;
  1832. if (this.model.storage.amount_interval)this.model.storage.isInterval = true;
  1833. },
  1834. //编辑作业
  1835. editOperation(index){
  1836. this.switchType("operation");
  1837. this.model.operation = JSON.parse(JSON.stringify(this.selectedModel.operation[index]));
  1838. this.model.operation.index = index;
  1839. },
  1840. //编辑快递
  1841. editExpress(index){
  1842. this.switchType("express");
  1843. this.model.express = JSON.parse(JSON.stringify(this.selectedModel.express[index]));
  1844. this.model.express.index = index;
  1845. },
  1846. //编辑物流
  1847. editLogistic(index){
  1848. this.switchType("logistic");
  1849. this.model.logistic = JSON.parse(JSON.stringify(this.selectedModel.logistic[index]));
  1850. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1851. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1852. this.model.logistic.index = index;
  1853. },
  1854. //编辑直发车
  1855. editDirectLogistic(){
  1856. this.switchType("directLogistic");
  1857. this.model.directLogistic = JSON.parse(JSON.stringify(this.selectedModel.directLogistic));
  1858. },
  1859. //编辑系统
  1860. editSystem(){
  1861. this.switchType("system");
  1862. this.model.system = JSON.parse(JSON.stringify(this.selectedModel.system));
  1863. },
  1864. //搜索快递子项
  1865. searchExpress(e){
  1866. let val = e.target.value;
  1867. if (!val){
  1868. this.$set(this.searchItem,'express',null);
  1869. return;
  1870. }
  1871. let items = [];
  1872. this.model.express.items.forEach((item,i)=>{
  1873. if (this.poolMapping.provinces[item.province_id].indexOf(val) !== -1)items.push(i);
  1874. });
  1875. this.$set(this.searchItem,'express',items);
  1876. },
  1877. //搜索直发子项
  1878. searchDirectLogistic(e){
  1879. let val = e.target.value;
  1880. if (!val){
  1881. this.$set(this.searchItem,'directLogistic',null);
  1882. return;
  1883. }
  1884. let items = [];
  1885. this.model.directLogistic.items.forEach((item,i)=>{
  1886. if (this.poolMapping.cars[item.car_type_id].indexOf(val) !== -1)items.push(i);
  1887. });
  1888. this.$set(this.searchItem,'directLogistic',items);
  1889. },
  1890. //搜索物流子项
  1891. searchLogistic(e){
  1892. let val = e.target.value;
  1893. if (!val){
  1894. this.$set(this.searchItem,'logistic',null);
  1895. return;
  1896. }
  1897. let items = [];
  1898. this.model.logistic.items.forEach((item,i)=>{
  1899. if (item.unit_id || item.province_id || item.city_id){
  1900. if ((item.unit_id && this.poolMapping.units[item.unit_id].indexOf(val) !== -1) ||
  1901. (item.province_id && this.poolMapping.provinces[item.province_id].indexOf(val) !== -1) ||
  1902. (item.city_id && this.poolMapping.cities[item.city_id].indexOf(val) !== -1))items.push(i);
  1903. }
  1904. });
  1905. this.$set(this.searchItem,'logistic',items);
  1906. },
  1907. //增加阶梯满减阈值
  1908. addDiscount(arr){
  1909. this.model.operation.items.forEach(item=>{
  1910. item.discount_price.push('');
  1911. });
  1912. this.model.operation.total_discount_price.push("");
  1913. arr.push('');
  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