create.blade.php 100 KB

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