create.blade.php 146 KB

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