create.blade.php 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851
  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:{!! json_encode(\App\Feature::TYPE,JSON_UNESCAPED_UNICODE) !!},
  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.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.isSingle){
  740. for (let i=0;i<this.model.operation.items.length;i++){
  741. if (this._verifyOperationItem(i))return;
  742. }
  743. this.model.operation.total_price = "";
  744. }else this.$set(this.model.operation,"items",[]);
  745. if (!this.model.operation.isDiscount) {
  746. this.model.operation.discount_count = [""];
  747. this.model.operation.total_discount_price = [""];
  748. }
  749. if (this.model.operation.isRejected)this.model.operation.type_mark = 0;
  750. let url = "{{url('maintenance/priceModel/apiStoreOperation')}}";
  751. let params = this.model.operation;
  752. params.owner_id = this.ownerTemp.id;
  753. window.tempTip.postBasicRequest(url,params,res=>{
  754. if (res && res.errors){
  755. if (res.errors.owner_id){
  756. window.tempTip.show(res.errors.owner_id[0]);
  757. return;
  758. }
  759. this.errors = res.errors;
  760. return;
  761. }
  762. res.features = this.model.operation.features;
  763. res.featureFormat = this.model.operation.featureFormat;
  764. for (let i=0;i<res.items.length;i++){
  765. res.items[i].features = this.model.operation.items[i]['features'];
  766. res.items[i].featureFormat = this.model.operation.items[i]['featureFormat'];
  767. res.items[i].type = this.model.operation.items[i]['type'];
  768. res.items[i].discount_price = res.items[i].discount_price ? res.items[i].discount_price.split(",") : [""];
  769. }
  770. if (res.discount_count)res.isDiscount = true;
  771. if (res.total_price)res.isSingle = true;
  772. res.discount_count = res.discount_count ? res.discount_count.split(",") : [""];
  773. res.total_discount_price = res.total_discount_price ? res.total_discount_price.split(",") : [""];
  774. res.isRejected = this.model.operation.type_mark==='0'||this.model.operation.type_mark===0;
  775. if (params.id) this.selectedModel.operation[params.index] = res;
  776. else this.selectedModel.operation.push(res);
  777. this._resetOperation();
  778. this.errors = {};
  779. this.audit.operation = true;
  780. });
  781. },
  782. _verifyOperationItem(itemIndex){//验证作业费子项信息完整
  783. let obj = this.model.operation.items[itemIndex];
  784. let sign = false;
  785. if (obj.strategy === '特征' && !obj.feature) {
  786. this.errors['items.' + itemIndex + '.feature'] = ["必须选择特征"];
  787. sign = true;
  788. }
  789. if (obj.strategy!=='起步' && !obj.amount){
  790. this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
  791. sign = true;
  792. }else if (!obj.amount) obj.amount = 0;
  793. if (obj.strategy!=='起步' && !obj.unit_id){
  794. this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
  795. sign = true;
  796. }else if (!obj.unit_id) obj.unit_id = 0;
  797. if (!obj.unit_price){
  798. this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
  799. sign = true;
  800. }
  801. if (this.model.operation.isDiscount){
  802. if (!obj.discount_price[0]){
  803. this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
  804. sign = true;
  805. }else{
  806. obj.discount_price.forEach((item,i)=>{
  807. if (i!==0&&!item) obj.discount_price[i]=obj.discount_price[i-1];
  808. })
  809. }
  810. }
  811. if (sign)this.$forceUpdate();
  812. return sign;
  813. },
  814. _verifyExpress(){
  815. let error = {};
  816. if (!this.model.express.name)error.name = ["名称不得为空"];
  817. if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
  818. if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
  819. if (this.model.express.items.length>0){
  820. this.model.express.items.forEach((item,index)=>{
  821. if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
  822. if (!this.model.express.isInterval){
  823. if (!item.initial_weight_price[0][0])error["item."+index+".initial_weight_price.0.0"] = ["不存在"];
  824. if (!item.additional_weight_price[0][0])error["item."+index+".additional_weight_price.0.0"] = ["不存在"];
  825. }else{
  826. item.initial_weight_price.forEach((arr,i)=>{
  827. arr.forEach((price,j)=>{
  828. if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
  829. });
  830. });
  831. item.additional_weight_price.forEach((arr,i)=>{
  832. arr.forEach((price,j)=>{
  833. if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
  834. });
  835. });
  836. }
  837. });
  838. }
  839. if (this.model.express.isInterval){
  840. this.model.express.amount_interval.forEach((amount,i)=>{
  841. if (amount==="") error["amount_interval."+i] = ["区间值不得为空"];
  842. else if (i!==0 && amount<=this.model.express.amount_interval[i-1])error["amount_interval."+i] = ["阶梯区间应大于上一区间值"];
  843. if (this.model.express.weight_interval[i].length>0){
  844. this.model.express.weight_interval[i].forEach((weight,j)=>{
  845. if (weight==="") error["weight_interval."+i+"."+j] = ["区间值不得为空"];
  846. else if (j!==0 && weight<=this.model.express.weight_interval[j-1])error["weight_interval."+i+"."+j] = ["阶梯区间应大于上一区间值"];
  847. })
  848. }
  849. });
  850. }
  851. if (JSON.stringify(error) !== "{}"){
  852. this.errors = error;
  853. return;
  854. }
  855. if (!this.model.express.isInterval){
  856. this.model.express.amount_interval = null;
  857. this.model.express.weight_interval = null;
  858. if (this.model.express.items.length>0){
  859. this.model.express.items.forEach((item,i)=>{
  860. this.model.express.items[i].initial_weight_price = [[Number(item.initial_weight_price[0][0])]];
  861. this.model.express.items[i].additional_weight_price = [[Number(item.additional_weight_price[0][0])]];
  862. });
  863. }
  864. }
  865. let url = "{{url('maintenance/priceModel/apiStoreExpress')}}";
  866. let params = this.model.express;
  867. params.owner_id = this.ownerTemp.id;
  868. window.tempTip.postBasicRequest(url,params,res=>{
  869. if (res && res.errors){
  870. this.errors = res.errors;
  871. if (res.errors.owner_id)window.tempTip.show(res.errors.owner_id[0]);
  872. return;
  873. }
  874. if (!this.model.express.amount_interval) this.model.express.amount_interval = [""];
  875. if (!this.model.express.weight_interval) this.model.express.weight_interval = [[]];
  876. this.model.express.items.forEach((item,i)=>{
  877. item.id = res.details[i].id;
  878. });
  879. if (this.model.express.id){
  880. if (res.operation) this.model.express.id = res.id;
  881. this.selectedModel.express[this.model.express.index] = this.model.express;
  882. }else{
  883. this.model.express.id = res.id;
  884. this.selectedModel.express.unshift(this.model.express);
  885. }
  886. this.model.express = {
  887. name:"",
  888. initial_weight:"",
  889. additional_weight:"",
  890. amount_interval:[""],
  891. weight_interval:[[]],
  892. items:[],
  893. logistics:[],
  894. };
  895. this.errors = {};
  896. this.importError = [];
  897. $(".selectpicker").filter('.express').selectpicker('val',[]);
  898. this.audit.express = true;
  899. });
  900. },
  901. _verifyLogistic(){
  902. let error = {};
  903. if (!this.model.logistic.name) error.name = ["名称不得为空"];
  904. if (!this.model.logistic.unit_id) error.unit_id = ["单位一不得为空"];
  905. if (!this.model.logistic.unit_range) error.unit_range = ["区间值不得为空"];
  906. if (!this.model.logistic.other_unit_id) error.other_unit_id = ["单位二不得为空"];
  907. if (!this.model.logistic.other_unit_range) error.other_unit_range = ["区间值不得为空"];
  908. if (JSON.stringify(error) !== "{}"){
  909. this.errors = error;
  910. return;
  911. }
  912. let url = "{{url('maintenance/priceModel/apiStoreLogistic')}}";
  913. let params = this.model.logistic;
  914. params.owner_id = this.ownerTemp.id;
  915. window.tempTip.postBasicRequest(url,params,res=>{
  916. if (res && res.errors){
  917. this.errors = res.errors;
  918. window.tempTip.show("检查您的子项详情列表是否完整");
  919. return;
  920. }
  921. this.model.logistic.items.forEach((item,i)=>{
  922. item.id = res.details[i].id;
  923. });
  924. if (this.model.logistic.id){
  925. if (res.operation) this.model.logistic.id = res.id;
  926. this.selectedModel.logistic[this.model.logistic.index] = this.model.logistic;
  927. }else {
  928. this.model.logistic.id = res.id;
  929. this.selectedModel.logistic.unshift(this.model.logistic);
  930. }
  931. this.model.logistic = {
  932. items:[],
  933. other_ranges:[],
  934. ranges:[],
  935. logistics:[],
  936. };
  937. this.errors = {};
  938. this.importError = [];
  939. $(".selectpicker").filter('.logistic').selectpicker('val',[]);
  940. this.audit.logistic = true;
  941. });
  942. },
  943. _verifyDirectLogistic(){
  944. let error = {};
  945. if (!this.model.directLogistic.name) error.name = ["名称不得为空"];
  946. if (!this.model.directLogistic.base_km) error.base_km = ["起步公里数不得为空"];
  947. if (JSON.stringify(error) !== "{}"){
  948. this.errors = error;
  949. return;
  950. }
  951. let url = "{{url('maintenance/priceModel/apiStoreDirectLogistic')}}";
  952. let params = this.model.directLogistic;
  953. params.owner_id = this.ownerTemp.id;
  954. window.tempTip.postBasicRequest(url,params,res=>{
  955. if (res && res.errors){
  956. this.errors = res.errors;
  957. return;
  958. }
  959. this.model.directLogistic.items.forEach((item,i)=>{
  960. item.id = res.details[i].id;
  961. });
  962. this.model.directLogistic.id = res.id;
  963. this.selectedModel.directLogistic = this.model.directLogistic;
  964. this.model.directLogistic = {
  965. items:[],
  966. };
  967. this.errors = {};
  968. this.importError = [];
  969. this.audit.directLogistic = true;
  970. });
  971. },
  972. //增加作业费特征子项
  973. addOperationItem(strategy){
  974. if (strategy!=='特征' && !this.model.operation.items.every(item=>{
  975. if (item.strategy===strategy)return false;
  976. return true;
  977. }))return;
  978. this.model.operation.items.push({
  979. strategy:strategy,
  980. discount_price:new Array(this.model.operation.discount_count.length).fill(""),
  981. });
  982. },
  983. //删除作业费子项
  984. delOperationItem(index){
  985. this.$delete(this.model.operation.items,index);
  986. },
  987. //显示特征选择modal
  988. showAddFeatureModal(index){
  989. if (index === -1){
  990. if (!this.model.operation.feature){
  991. this.model.operation.features = this._createFeature();
  992. this.thisOperationItemIndex = index;
  993. this.$forceUpdate();
  994. $("#addFeatureModal").modal("show");
  995. return;
  996. }
  997. if (this.model.operation.features) {
  998. this.thisOperationItemIndex = index;
  999. $("#addFeatureModal").modal("show");
  1000. return;
  1001. }
  1002. }else{
  1003. if (!this.model.operation.items[index].feature){
  1004. this.model.operation.items[index].features = this._createFeature();
  1005. this.thisOperationItemIndex = index;
  1006. this.$forceUpdate();
  1007. $("#addFeatureModal").modal("show");
  1008. return;
  1009. }
  1010. if (this.model.operation.items[index].features) {
  1011. this.thisOperationItemIndex = index;
  1012. $("#addFeatureModal").modal("show");
  1013. return;
  1014. }
  1015. }
  1016. let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
  1017. let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
  1018. window.tempTip.postBasicRequest(url,{feature:feature},res=>{
  1019. if (!res || res.length === 0){
  1020. res = this._createFeature();
  1021. }
  1022. if (index === -1) this.model.operation.features = res;
  1023. else this.model.operation.items[index].features = res;
  1024. this.thisOperationItemIndex = index;
  1025. this.$forceUpdate();
  1026. $("#addFeatureModal").modal("show");
  1027. });
  1028. },
  1029. //增加特征
  1030. addFeature(){
  1031. let obj = {
  1032. "strategyGroupStartSign": false,
  1033. "calculation" : "",
  1034. "type" : "",
  1035. "id" : "",
  1036. "logic" : "",
  1037. "describe" : "",
  1038. "strategyGroupEndSign" : false,
  1039. };
  1040. if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
  1041. else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
  1042. this.$forceUpdate();
  1043. },
  1044. _createFeature(){
  1045. return [{
  1046. "strategyGroupStartSign": false,
  1047. "calculation" : "",
  1048. "type" : "",
  1049. "id" : "",
  1050. "logic" : "",
  1051. "describe" : "",
  1052. "strategyGroupEndSign" : false,
  1053. }];
  1054. },
  1055. //删除特征
  1056. delFeature(index) {
  1057. if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
  1058. else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
  1059. this.$forceUpdate();
  1060. },
  1061. //提交特征更新现有
  1062. submitFeature(){
  1063. let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
  1064. let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
  1065. window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
  1066. if (this.thisOperationItemIndex === -1){
  1067. this.model.operation.feature = res.feature;
  1068. this.model.operation.featureFormat = res.featureFormat;
  1069. } else {
  1070. this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
  1071. this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
  1072. this.$forceUpdate();
  1073. }
  1074. $("#addFeatureModal").modal("hide");
  1075. return "已更新特征";
  1076. },true);
  1077. },
  1078. //移入移出时更改长文本显示效果
  1079. textClass(event,isOver){
  1080. event = event.target.children[0];
  1081. if (isOver) event.className = "text-overflow-warp-100";
  1082. else event.className = "cursor-pointer text-overflow-replace-100";
  1083. },
  1084. //展开子策略
  1085. showOperationItem(index){
  1086. let trId = "operation-tr-"+index;
  1087. let itemId = "operation-item-"+index;
  1088. if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
  1089. this.operationItems['_'+index] = false;
  1090. $("#"+itemId).slideUp(undefined,function () {
  1091. $("#"+trId).addClass("d-none");
  1092. });
  1093. }else {
  1094. $("#"+trId).removeClass("d-none");
  1095. this.operationItems['_'+index] = true;
  1096. $("#"+itemId).slideDown();
  1097. }
  1098. this.$forceUpdate();
  1099. },
  1100. //新增快递子项
  1101. addExpressItem(){
  1102. let arr = [];
  1103. this.model.express.amount_interval.forEach((amount,i)=>{
  1104. if (this.model.express.weight_interval[i].length>0){
  1105. let it = [];
  1106. this.model.express.weight_interval[i].forEach(weight=>{
  1107. it.push("");
  1108. });
  1109. arr.push(it);
  1110. }else arr.push([""]);
  1111. });
  1112. let re=[];
  1113. for(let i=0;i<arr.length;i++){
  1114. re.push(arr[i].slice(0));
  1115. }
  1116. this.model.express.items.unshift({
  1117. province_id : "",
  1118. initial_weight_price:arr,
  1119. additional_weight_price:re,
  1120. });
  1121. },
  1122. //删除快递子项
  1123. delExpressItem(index){
  1124. window.tempTip.confirm("确定要删除该子项吗?",res=>{
  1125. this.$delete(this.model.express.items,index);
  1126. })
  1127. },
  1128. //选择文件
  1129. selectFile(id){
  1130. this.importError = [];
  1131. $("#"+id).click();
  1132. },
  1133. _getExpressImportData(index,data){
  1134. let arr = [];
  1135. this.model.express.amount_interval.forEach((amount,i)=>{
  1136. if (this.model.express.weight_interval[i].length>0){
  1137. let it = [];
  1138. this.model.express.weight_interval[i].forEach(weight=>{
  1139. it.push(data[index] ? data[index] : "");
  1140. index++;
  1141. });
  1142. arr.push(it);
  1143. }else {
  1144. arr.push([data[index] ? data[index] : ""]);
  1145. index++;
  1146. }
  1147. });
  1148. return [arr,index];
  1149. },
  1150. //导入快递子项
  1151. importExpress(e){
  1152. let file=e.target.files[0];
  1153. window.tempTip.setDuration(3000);
  1154. if (!file){
  1155. window.tempTip.show("未选择文件");
  1156. return;
  1157. }
  1158. let formData = new FormData();
  1159. formData.append("file",file);
  1160. window.axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  1161. 'Content-Type':'multipart/form-data'
  1162. }).then(res=>{
  1163. if (res.data.success) {
  1164. res.data.data.data.forEach(data=>{
  1165. if(this.model.express.items.every(item=>{
  1166. if (data.province_id === item.province_id)return false;
  1167. return true;
  1168. })){
  1169. if (this.model.express.isInterval){
  1170. let result = this._getExpressImportData(1,data);
  1171. this.model.express.items.push({
  1172. province_id : data[0],
  1173. initial_weight_price:result[0],
  1174. additional_weight_price:this._getExpressImportData(result[1],data)[0],
  1175. });
  1176. }else this.model.express.items.push({
  1177. province_id : data[0],
  1178. initial_weight_price:[[data[1]]],
  1179. additional_weight_price:[[data[2]]],
  1180. });
  1181. }
  1182. });
  1183. this.importError = res.data.data.errors;
  1184. window.tempTip.setDuration(2000);
  1185. window.tempTip.showSuccess("导入成功!");
  1186. return;
  1187. }
  1188. window.tempTip.show(res.data.data);
  1189. }).catch(err=> {
  1190. window.tempTip.show("网络错误:"+err);
  1191. })
  1192. },
  1193. //物流详情列表modal
  1194. showDetailModal() {
  1195. $("#logisticModal").modal("show");
  1196. },
  1197. //新增物流详情
  1198. addLogisticDetail(){
  1199. this.model.logistic.items.unshift({});
  1200. },
  1201. //导入物流详情
  1202. importLogistic(e){
  1203. window.tempTip.setIndex(1099);
  1204. let file=e.target.files[0];
  1205. if (!file){
  1206. window.tempTip.setDuration(3000);
  1207. window.tempTip.show("未选择文件");
  1208. return;
  1209. }
  1210. let formData = new FormData();
  1211. formData.append("file",file);
  1212. window.axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  1213. 'Content-Type':'multipart/form-data'
  1214. }).then(res=>{
  1215. if (res.data.success) {
  1216. res.data.data.forEach(data=>{
  1217. //过滤非已选择单位的数据
  1218. let id = "";
  1219. if (data.unit_id === this.poolMapping.units[this.model.logistic.unit_id]) id = this.model.logistic.unit_id;
  1220. if (data.unit_id === this.poolMapping.units[this.model.logistic.other_unit_id]) id = this.model.logistic.other_unit_id;
  1221. if (id){
  1222. //过滤重复数据
  1223. let unique = this.model.logistic.items.every(item=>{
  1224. if (id === item.unit_id && data.range === item.range
  1225. && data.province_id === item.province_id && data.city_id === item.city_id)return false;
  1226. return true;
  1227. });
  1228. if (unique){
  1229. data.unit_id = id;
  1230. this.model.logistic.items.push(data);
  1231. }
  1232. }
  1233. });
  1234. this.importError = res.data.errors;
  1235. window.tempTip.setDuration(3000);
  1236. window.tempTip.showSuccess("导入成功!");
  1237. return;
  1238. }
  1239. window.tempTip.setDuration(3000);
  1240. window.tempTip.show(res.data.data);
  1241. }).catch(err=> {
  1242. window.tempTip.setDuration(3000);
  1243. window.tempTip.show("网络错误:"+err);
  1244. })
  1245. },
  1246. //删除物流子项
  1247. delLogisticItem(index){
  1248. this.$delete(this.model.logistic.items,index);
  1249. },
  1250. //改变物流区间时改变可选择项
  1251. changeRange(type){
  1252. if (type === 'ranges'){
  1253. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1254. }else{
  1255. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1256. }
  1257. },
  1258. //增加直发车子项
  1259. addDirectLogisticItem(){
  1260. this.model.directLogistic.items.unshift({
  1261. car_type_id : "",
  1262. base_fee:"",
  1263. additional_fee:"",
  1264. });
  1265. },
  1266. //导入直发车子项
  1267. importDirectLogistic(e){
  1268. window.tempTip.setIndex(1099);
  1269. let file=e.target.files[0];
  1270. if (!file){
  1271. window.tempTip.setDuration(3000);
  1272. window.tempTip.show("未选择文件");
  1273. return;
  1274. }
  1275. let formData = new FormData();
  1276. formData.append("file",file);
  1277. window.axios.post('{{url('maintenance/priceModel/directLogistic/import')}}',formData,{
  1278. 'Content-Type':'multipart/form-data'
  1279. }).then(res=>{
  1280. if (res.data.success) {
  1281. if (this.model.directLogistic.items.length > 0){
  1282. res.data.data.forEach(data=>{
  1283. let unique = this.model.directLogistic.items.every(item=>{
  1284. if (item.car_type_id === data.car_type_id)return false;
  1285. return true;
  1286. });
  1287. if (unique) this.model.directLogistic.items.unshift(data);
  1288. });
  1289. }else this.model.directLogistic.items = res.data.data;
  1290. this.importError = res.data.errors;
  1291. window.tempTip.setDuration(3000);
  1292. window.tempTip.showSuccess("导入成功!");
  1293. return;
  1294. }
  1295. window.tempTip.setDuration(3000);
  1296. window.tempTip.show(res.data.data);
  1297. }).catch(err=> {
  1298. window.tempTip.setDuration(3000);
  1299. window.tempTip.show("网络错误:"+err);
  1300. })
  1301. },
  1302. //删除直发车子项
  1303. delDirectLogisticItem(index){
  1304. this.$delete(this.model.directLogistic.items,index);
  1305. },
  1306. //改变客户
  1307. selectOwner(){
  1308. let id = this.owner.customer_id;
  1309. this.customers.some(customer=>{
  1310. if (id === customer.id){
  1311. this.owner.customer_name = customer.name;
  1312. return true;
  1313. }
  1314. });
  1315. },
  1316. //改变小组
  1317. selectGroup(){
  1318. let id = this.owner.owner_group_id;
  1319. this.ownerGroups.some(group=>{
  1320. if (id === group.id){
  1321. this.owner.owner_group_name = group.name;
  1322. return true;
  1323. }
  1324. });
  1325. },
  1326. //获取引入计费模型查询列表搜索
  1327. searchPriceModel(){
  1328. this.isSearch = true;
  1329. switch (this.type) {
  1330. case "storage":
  1331. this._getStoragePriceModel();
  1332. break;
  1333. case "operation":
  1334. this._getOperationPriceModel();
  1335. break;
  1336. case "express":
  1337. this._getExpressPriceModel();
  1338. break;
  1339. case "logistic":
  1340. this._getLogisticPriceModel();
  1341. break;
  1342. default:
  1343. this._getDirectLogisticPriceModel();
  1344. }
  1345. },
  1346. _getStoragePriceModel(){
  1347. let url = "{{url('maintenance/priceModel/apiGetStorage')}}";
  1348. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1349. let result = [];
  1350. let mapping = {};
  1351. res.forEach(model=> {
  1352. let text = model.name+" ("+model.counting_type+"-"+model.using_type+")";
  1353. result.push({id:model.id,text:text});
  1354. mapping[model.id] = {
  1355. name : model.name,
  1356. counting_type : model.counting_type,
  1357. using_type : model.using_type,
  1358. minimum_area : model.minimum_area,
  1359. price : model.price,
  1360. discount_type : model.discount_type,
  1361. discount_value : model.discount_value,
  1362. amount_interval : model.amount_interval ? model.amount_interval : [""],
  1363. isInterval:!!model.amount_interval,
  1364. unit_id : model.unit_id,
  1365. };
  1366. });
  1367. this.searchResult = result;
  1368. this.searchResultMapping = mapping;
  1369. this.isSearch = false;
  1370. });
  1371. },
  1372. _getOperationPriceModel(){
  1373. let url = "{{url('maintenance/priceModel/apiGetOperation')}}";
  1374. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1375. let result = [];
  1376. let mapping = {};
  1377. res.forEach(model=> {
  1378. let text = model.name+" ("+model.operation_type+"-"+model.strategy+")";
  1379. result.push({id:model.id,text:text});
  1380. mapping[model.id] = {
  1381. name : model.name,
  1382. operation_type : model.operation_type,
  1383. strategy : model.strategy,
  1384. feature : model.feature,
  1385. featureFormat : model.featureFormat,
  1386. remark : model.remark,
  1387. type_mark : model.type_mark,
  1388. isRejected : model.type_mark==='0'||model.type_mark===0,
  1389. items:model.items,
  1390. };
  1391. });
  1392. this.searchResult = result;
  1393. this.searchResultMapping = mapping;
  1394. this.isSearch = false;
  1395. });
  1396. },
  1397. _getExpressPriceModel(){
  1398. let url = "{{url('maintenance/priceModel/apiGetExpress')}}";
  1399. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1400. let result = [];
  1401. let mapping = {};
  1402. res.forEach(model=> {
  1403. let text = model.name+" (首重:"+model.initial_weight+"KG 续重:"+model.additional_weight+"KG)";
  1404. result.push({id:model.id,text:text});
  1405. let logistics = [];
  1406. model.logistics.forEach(logistic=>{
  1407. logistics.push(logistic.id);
  1408. });
  1409. let items = [];
  1410. model.details.forEach(item=>{
  1411. items.push({
  1412. province_id:item.province_id,
  1413. initial_weight_price:item.initial_weight_price,
  1414. additional_weight_price:item.additional_weight_price,
  1415. });
  1416. });
  1417. mapping[model.id] = {
  1418. logistics : logistics,
  1419. name:model.name,
  1420. initial_weight:model.initial_weight,
  1421. additional_weight:model.additional_weight,
  1422. amount_interval:model.amount_interval ? model.amount_interval : [""],
  1423. weight_interval:model.weight_interval ? model.weight_interval : [[]],
  1424. isInterval:!!model.amount_interval,
  1425. items:items,
  1426. };
  1427. });
  1428. this.searchResult = result;
  1429. this.searchResultMapping = mapping;
  1430. this.isSearch = false;
  1431. });
  1432. },
  1433. _getLogisticPriceModel(){
  1434. let url = "{{url('maintenance/priceModel/apiGetLogistic')}}";
  1435. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1436. let result = [];
  1437. let mapping = {};
  1438. res.forEach(model=> {
  1439. let text = model.name+" (单位一:"+this.poolMapping.units[model.unit_id]+"["+model.unit_range+
  1440. "] 单位二:"+this.poolMapping.units[model.other_unit_id]+"["+model.other_unit_range+"])";
  1441. result.push({id:model.id,text:text});
  1442. let logistics = [];
  1443. model.logistics.forEach(logistic=>{
  1444. logistics.push(logistic.id);
  1445. });
  1446. let items = [];
  1447. model.details.forEach(item=>{
  1448. items.push({
  1449. unit_id:item.unit_id,
  1450. range:item.range,
  1451. province_id:item.province_id,
  1452. city_id:item.city_id,
  1453. unit_price:item.unit_price,
  1454. delivery_fee:item.delivery_fee,
  1455. initial_fee:item.initial_fee,
  1456. initial_amount:item.initial_amount,
  1457. rate:item.rate,
  1458. });
  1459. });
  1460. mapping[model.id] = {
  1461. logistics : logistics,
  1462. name:model.name,
  1463. unit_range:model.unit_range,
  1464. unit_id:model.unit_id,
  1465. other_unit_range:model.other_unit_range,
  1466. other_unit_id:model.other_unit_id,
  1467. pick_up_price:model.pick_up_price,
  1468. fuel_price:model.fuel_price,
  1469. service_price:model.service_price,
  1470. items:items,
  1471. };
  1472. });
  1473. this.searchResult = result;
  1474. this.searchResultMapping = mapping;
  1475. this.isSearch = false;
  1476. });
  1477. },
  1478. _getDirectLogisticPriceModel(){
  1479. let url = "{{url('maintenance/priceModel/apiGetDirectLogistic')}}";
  1480. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1481. let result = [];
  1482. let mapping = {};
  1483. res.forEach(model=> {
  1484. let text = model.name+" (起步数:"+model.base_km+"KM)";
  1485. result.push({id:model.id,text:text});
  1486. let items = [];
  1487. model.details.forEach(item=>{
  1488. items.push({
  1489. car_type_id:item.car_type_id,
  1490. base_fee:item.base_fee,
  1491. additional_fee:item.additional_fee,
  1492. });
  1493. });
  1494. mapping[model.id] = {
  1495. name:model.name,
  1496. base_km:model.base_km,
  1497. items:items,
  1498. };
  1499. });
  1500. this.searchResult = result;
  1501. this.searchResultMapping = mapping;
  1502. this.isSearch = false;
  1503. });
  1504. },
  1505. //提交引入
  1506. submitIntroduce(){
  1507. if (!this.selectedResult || !this.searchResultMapping[this.selectedResult]){
  1508. window.tempTip.setDuration(3000);
  1509. window.tempTip.show("尚未选择引入项,请单击选择列表,如列表为空则无结果");
  1510. return;
  1511. }
  1512. let model = this.searchResultMapping[this.selectedResult];
  1513. switch (this.type) {
  1514. case "storage":
  1515. this.model.storage = model;
  1516. break;
  1517. case "operation":
  1518. this.model.operation = model;
  1519. break;
  1520. case "express":
  1521. this.model.express = model;
  1522. break;
  1523. case "logistic":
  1524. this.model.logistic = model;
  1525. break;
  1526. default:
  1527. this.model.directLogistic = model;
  1528. break;
  1529. }
  1530. $("#introduce").modal('hide');
  1531. window.tempTip.setDuration(2000);
  1532. window.tempTip.showSuccess("引入成功");
  1533. },
  1534. //删除仓储
  1535. delStorage(item,index){
  1536. window.tempTip.confirm("您确定要删除仓储计费“"+item.name+"”吗?",()=>{
  1537. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelStorage')}}",{id:item.id},res=>{
  1538. this.$delete(this.selectedModel.storage,index);
  1539. this.audit.storage = true;
  1540. return "删除“"+item.name+"”成功";
  1541. });
  1542. });
  1543. },
  1544. //删除作业
  1545. delOperation(item,index){
  1546. window.tempTip.confirm("您确定要删除作业计费“"+item.name+"”吗?",()=>{
  1547. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperation')}}",{id:item.id},res=>{
  1548. this.$delete(this.selectedModel.operation,index);
  1549. this.audit.operation = true;
  1550. return "删除“"+item.name+"”成功";
  1551. });
  1552. });
  1553. },
  1554. //删除作业子项
  1555. deleteOperationItem(item,index,parentIndex){
  1556. window.tempTip.confirm("您确定要删除该作业子项吗?",()=>{
  1557. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperationItem')}}",{id:item.id},res=>{
  1558. if (res) this.$set(this.selectedModel.operation,parentIndex,this._overrideOperation(res));
  1559. else this.$delete(this.selectedModel.operation[parentIndex].items,index);
  1560. this.audit.operation = true;
  1561. return "删除成功";
  1562. });
  1563. });
  1564. },
  1565. //删除快递
  1566. delExpress(item,index){
  1567. window.tempTip.confirm("您确定要删除该快递计费“"+item.name+"”吗?",()=>{
  1568. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpress')}}",{id:item.id},res=>{
  1569. this.$delete(this.selectedModel.express,index);
  1570. this.audit.express = true;
  1571. return "删除“"+item.name+"”成功";
  1572. });
  1573. });
  1574. },
  1575. //删除快递子项
  1576. deleteExpressItem(item,index,parentIndex){
  1577. window.tempTip.confirm("您确定要删除该快递计费子项吗?",()=>{
  1578. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpressItem')}}",{id:item.id},res=>{
  1579. if (res) this.$set(this.selectedModel.express,parentIndex,this._overrideExpress(res));
  1580. else this.$delete(this.selectedModel.express[parentIndex].items,index);
  1581. this.audit.express = true;
  1582. return "删除成功";
  1583. });
  1584. });
  1585. },
  1586. //删除物流
  1587. delLogistic(item,index){
  1588. window.tempTip.confirm("您确定要删除该物流计费“"+item.name+"”吗?",()=>{
  1589. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogistic')}}",{id:item.id},res=>{
  1590. this.$delete(this.selectedModel.logistic,index);
  1591. this.audit.logistic = true;
  1592. return "删除“"+item.name+"”成功";
  1593. });
  1594. });
  1595. },
  1596. //删除物流子项
  1597. deleteLogisticItem(item,index,parentIndex){
  1598. window.tempTip.confirm("您确定要删除该物流计费子项吗?",()=>{
  1599. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogisticItem')}}",{id:item.id},res=>{
  1600. if (res) this.$set(this.selectedModel.logistic,parentIndex,this._overrideLogistic(res));
  1601. else this.$delete(this.selectedModel.logistic[parentIndex].items,index);
  1602. this.audit.logistic = true;
  1603. return "删除成功";
  1604. });
  1605. });
  1606. },
  1607. //删除直发车
  1608. delDirectLogistic(item){
  1609. window.tempTip.confirm("您确定要删除该直发车计费“"+item.name+"”吗?",()=>{
  1610. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogistic')}}",{id:item.id},res=>{
  1611. this.selectedModel.directLogistic = {};
  1612. this.audit.directLogistic = true;
  1613. return "删除“"+item.name+"”成功";
  1614. });
  1615. });
  1616. },
  1617. //删除直发车子项
  1618. deleteDirectLogisticItem(item,index){
  1619. window.tempTip.confirm("您确定要删除该直发车计费子项吗?",()=>{
  1620. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogisticItem')}}",{id:item.id},res=>{
  1621. if (res) this.$set(this.selectedModel,"directLogistic",this._overrideDirectLogistic(res));
  1622. else this.$delete(this.selectedModel.directLogistic.items,index);
  1623. this.audit.directLogistic = true;
  1624. return "删除成功";
  1625. });
  1626. });
  1627. },
  1628. //编辑仓储
  1629. editStorage(index){
  1630. this.switchType("storage");
  1631. this.model.storage = JSON.parse(JSON.stringify(this.selectedModel.storage[index]));
  1632. this.model.storage.index = index;
  1633. },
  1634. //编辑作业
  1635. editOperation(index){
  1636. this.switchType("operation");
  1637. this.model.operation = JSON.parse(JSON.stringify(this.selectedModel.operation[index]));
  1638. this.model.operation.index = index;
  1639. },
  1640. //编辑快递
  1641. editExpress(index){
  1642. this.switchType("express");
  1643. this.model.express = JSON.parse(JSON.stringify(this.selectedModel.express[index]));
  1644. this.model.express.index = index;
  1645. },
  1646. //编辑物流
  1647. editLogistic(index){
  1648. this.switchType("logistic");
  1649. this.model.logistic = JSON.parse(JSON.stringify(this.selectedModel.logistic[index]));
  1650. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1651. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1652. this.model.logistic.index = index;
  1653. },
  1654. //编辑直发车
  1655. editDirectLogistic(){
  1656. this.switchType("directLogistic");
  1657. this.model.directLogistic = JSON.parse(JSON.stringify(this.selectedModel.directLogistic));
  1658. },
  1659. //搜索快递子项
  1660. searchExpress(e){
  1661. let val = e.target.value;
  1662. if (!val){
  1663. this.$set(this.searchItem,'express',null);
  1664. return;
  1665. }
  1666. let items = [];
  1667. this.model.express.items.forEach((item,i)=>{
  1668. if (this.poolMapping.provinces[item.province_id].indexOf(val) !== -1)items.push(i);
  1669. });
  1670. this.$set(this.searchItem,'express',items);
  1671. },
  1672. //搜索直发子项
  1673. searchDirectLogistic(e){
  1674. let val = e.target.value;
  1675. if (!val){
  1676. this.$set(this.searchItem,'directLogistic',null);
  1677. return;
  1678. }
  1679. let items = [];
  1680. this.model.directLogistic.items.forEach((item,i)=>{
  1681. if (this.poolMapping.cars[item.car_type_id].indexOf(val) !== -1)items.push(i);
  1682. });
  1683. this.$set(this.searchItem,'directLogistic',items);
  1684. },
  1685. //搜索物流子项
  1686. searchLogistic(e){
  1687. let val = e.target.value;
  1688. if (!val){
  1689. this.$set(this.searchItem,'logistic',null);
  1690. return;
  1691. }
  1692. let items = [];
  1693. this.model.logistic.items.forEach((item,i)=>{
  1694. if (item.unit_id || item.province_id || item.city_id){
  1695. if ((item.unit_id && this.poolMapping.units[item.unit_id].indexOf(val) !== -1) ||
  1696. (item.province_id && this.poolMapping.provinces[item.province_id].indexOf(val) !== -1) ||
  1697. (item.city_id && this.poolMapping.cities[item.city_id].indexOf(val) !== -1))items.push(i);
  1698. }
  1699. });
  1700. this.$set(this.searchItem,'logistic',items);
  1701. },
  1702. //增加阶梯满减阈值
  1703. addDiscount(arr){
  1704. this.model.operation.items.forEach(item=>{
  1705. item.discount_price.push('');
  1706. });
  1707. this.model.operation.total_discount_price.push("");
  1708. arr.push('');
  1709. },
  1710. //删除阶梯满减阈值
  1711. delDiscount(index){
  1712. this.model.operation.items.forEach((item,i)=>{
  1713. delete item.discount_price[index];
  1714. this.$set(this.model.operation.items,i,item);
  1715. });
  1716. this.$delete(this.model.operation.total_discount_price,index);
  1717. this.$delete(this.model.operation.discount_count,index);
  1718. },
  1719. //审核或恢复
  1720. auditOrRecoverModel(type,isAudit = true){
  1721. let url = "{{url('maintenance/priceModel/auditOrRecoverModel')}}";
  1722. let param = {owner_id:this.ownerTemp.id,type:type,isAudit:isAudit};
  1723. window.tempTip.confirm("确定要"+(isAudit ? '审核' : '恢复')+"上次的全部操作吗?",()=>{
  1724. window.tempTip.postBasicRequest(url,param,res=>{
  1725. switch (type){
  1726. case "storage":
  1727. this.selectedModel.storage = res;
  1728. break;
  1729. case "operation":
  1730. this._loadOperation();
  1731. res.forEach((operation,i)=>{res[i] = this._overrideOperation(operation);});
  1732. this.selectedModel.operation = res;
  1733. break;
  1734. case "express":
  1735. this._loadExpress();
  1736. res.forEach((express,i)=>{
  1737. res[i] = this._overrideExpress(express);
  1738. this.upList['express-item-'+i] = true;
  1739. });
  1740. this.selectedModel.express = res;
  1741. break;
  1742. case "logistic":
  1743. this._loadLogistic();
  1744. res.forEach((logistic,i)=>{
  1745. res[i] = this._overrideLogistic(logistic);
  1746. this.upList['logistic-item-'+i] = true;
  1747. });
  1748. this.selectedModel.logistic = res;
  1749. break;
  1750. case "directLogistic":
  1751. this._loadDirectLogistic();
  1752. this.upList["directLogistic-item"] = true;
  1753. this.selectedModel.directLogistic = this._overrideDirectLogistic(res[0]);
  1754. break;
  1755. }
  1756. this.$set(this.audit,type,false);
  1757. })
  1758. })
  1759. },
  1760. //增加数量区间
  1761. addStoreAmount(){
  1762. this.model.storage.amount_interval.push("");
  1763. this.model.storage.price.push("");
  1764. },
  1765. //删除数量区间
  1766. delStoreAmount(index){
  1767. if (this.model.storage.amount_interval.length<2)return;
  1768. this.$delete(this.model.storage.amount_interval,index);
  1769. this.$delete(this.model.storage.price,index);
  1770. },
  1771. //增加快递数量区间
  1772. addExpressAmount(){
  1773. this.model.express.amount_interval.push("");
  1774. this.model.express.weight_interval.push([]);
  1775. if (this.model.express.items.length>0){
  1776. this.model.express.items.forEach((item,i)=>{
  1777. this.$set(this.model.express.items[i],"initial_weight_price",[""]);
  1778. this.$set(this.model.express.items[i],"additional_weight_price",[""]);
  1779. })
  1780. }
  1781. },
  1782. //增加快递重量区间
  1783. addExpressWeight(index){
  1784. this.model.express.weight_interval[index].push("");
  1785. if (!this.model.express.maxDom || this.model.express.weight_interval[index].length > this.model.express.maxDom)
  1786. this.$set(this.model.express,'maxDom',this.model.express.weight_interval[index].length);
  1787. },
  1788. //删除快递数量区间
  1789. delExpressAmount(){
  1790. let len = this.model.express.amount_interval.length;
  1791. if (len>1){
  1792. this.$delete(this.model.express.amount_interval,len-1);
  1793. this.$delete(this.model.express.weight_interval,len-1);
  1794. if (this.model.express.items.length>0){
  1795. this.model.express.items.forEach((item,i)=>{
  1796. this.$delete(this.model.express.items[i]["initial_weight_price"],len-1);
  1797. this.$delete(this.model.express.items[i]["additional_weight_price"],len-1);
  1798. })
  1799. }
  1800. }
  1801. },
  1802. //删除快递重量区间
  1803. delExpressWeight(index){
  1804. let len = this.model.express.weight_interval[index].length;
  1805. this.$delete(this.model.express.weight_interval[index],len-1);
  1806. if (this.model.express.items.length>0){
  1807. this.model.express.items.forEach((item,i)=>{
  1808. this.$delete(this.model.express.items[i]["initial_weight_price"][index],len-1);
  1809. this.$delete(this.model.express.items[i]["additional_weight_price"][index],len-1);
  1810. })
  1811. }
  1812. },
  1813. filterCustomer(e){
  1814. let value = $(e.target).val();
  1815. if (value===""){
  1816. this.filterCustomers=JSON.parse(JSON.stringify(this.customers));
  1817. return;
  1818. }
  1819. this.filterCustomers = this.customers.filter(function(item){
  1820. return item.name.includes(value);
  1821. })
  1822. },
  1823. filterOwnerGroup(e){
  1824. let value = $(e.target).val();
  1825. if (value===""){
  1826. this.filterOwnerGroups=JSON.parse(JSON.stringify(this.ownerGroups));
  1827. return;
  1828. }
  1829. this.filterOwnerGroups = this.ownerGroups.filter(function(item){
  1830. return item.name.includes(value);
  1831. })
  1832. },
  1833. filterUserGroup(e){
  1834. let value = $(e.target).val();
  1835. if (value===""){
  1836. this.filterCustomers=JSON.parse(JSON.stringify(this.customers));
  1837. return;
  1838. }
  1839. this.filterCustomers = this.customers.filter(function(item){
  1840. return item.name.includes(value);
  1841. })
  1842. },
  1843. },
  1844. });
  1845. </script>
  1846. @stop