create.blade.php 97 KB

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