create.blade.php 98 KB

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