create.blade.php 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523
  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-2">
  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. warehouse_id : "{{ $owner->warehouse_id ?? ''}}",
  97. tax_rate : "{{$owner->tax_rate ?? ''}}",
  98. linkman : "{{$owner->linkman ?? ''}}",
  99. phone_number : "{{$owner->phone_number ?? ''}}",
  100. description : "{{$owner->description ?? ''}}",
  101. waring_line_on : "{{$owner->waring_line_on ?? ''}}",
  102. },
  103. ownerTemp : {},
  104. customers : [
  105. @foreach($customers as $customer)
  106. {id:"{{$customer->id}}",name:"{{$customer->name}}"},
  107. @endforeach
  108. ],
  109. ownerGroups : [
  110. @foreach($ownerGroups as $ownerGroup)
  111. {id:"{{$ownerGroup->id}}",name:"{{$ownerGroup->name}}"},
  112. @endforeach
  113. ],
  114. warehouses:[
  115. @foreach($warehouses as $warehouse)
  116. {id:"{{$warehouse->id}}",name:"{{$warehouse->name}}"},
  117. @endforeach
  118. ],
  119. style : '',
  120. errors : {!! $errors !!}, //全部的错误提示
  121. upList:{ //控制元素的渐入展开与收起
  122. storage : false,
  123. },
  124. type:"storage",//当前编辑类型 仓储,作业,物流...
  125. currentInputting:{
  126. edittingOperation:null,
  127. },
  128. model:{ //编辑元素绑定值
  129. storage:{
  130. counting_type : "",
  131. using_type : "",
  132. minimum_area : "",
  133. price : "",
  134. discount_type : "无减免",
  135. discount_value : "",
  136. unit_id : "",
  137. time_unit_id : "",
  138. },
  139. operation:{
  140. operation_type:"入库",
  141. strategy:"默认",
  142. name:"",
  143. feature:"",
  144. items : [
  145. {strategy:"起步",type:"0"},
  146. {strategy:"默认"},
  147. {strategy:"特征"},
  148. ],
  149. },
  150. express:{
  151. name:"",
  152. initial_weight:"",
  153. additional_weight:"",
  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. },
  203. mounted(){
  204. let type = "{{$type}}";
  205. if (type){
  206. this.base = "three";
  207. setTimeout(()=>{
  208. this.switchType(type);
  209. if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
  210. if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
  211. },0);
  212. }
  213. this.ownerTemp = JSON.parse(JSON.stringify(this.owner));
  214. $('[data-toggle="tooltip"]').tooltip();
  215. $("#container").removeClass("d-none");
  216. },
  217. methods:{
  218. //悬浮效果
  219. hoverEffect(key,val){
  220. this.$set(this.hover,key,val);
  221. },
  222. //收起展开
  223. show(id){
  224. if (this.upList[id])$("#"+id).slideDown();
  225. else $("#"+id).slideUp();
  226. this.upList[id] = !this.upList[id];
  227. this.$forceUpdate();
  228. },
  229. //清除垃圾数据
  230. _clearRefuse(){
  231. this.errors = [];
  232. this.importError = [];
  233. this.selectedResult = "";
  234. this.searchResult = [];
  235. this.searchResultMapping = {};
  236. this.introduce = {};
  237. },
  238. //切换选项
  239. switchBase(base){
  240. if (!this.owner.id)return;
  241. if (base === this.base)return;
  242. if (base === 'three') this._loadStorage();
  243. this.base = base;
  244. },
  245. //切换类型
  246. switchType(type){
  247. if (type === this.type)return;//相同终止是为了减少重复加载动作
  248. this._clearRefuse();//清除垃圾数据
  249. let parent = $("#parent");
  250. let dom = "";
  251. switch (type) {
  252. case "storage":
  253. this._loadStorage();
  254. dom = $("#storage-card");
  255. break;
  256. case "operation":
  257. this._loadOperation();
  258. dom = $("#operation-card");
  259. break;
  260. case "express":
  261. this._loadExpress();
  262. dom = $("#express-card");
  263. break;
  264. case "logistic":
  265. this._loadLogistic();
  266. dom = $("#logistic-card");
  267. break;
  268. case "directLogistic":
  269. this._loadDirectLogistic();
  270. dom = $("#directLogistic-card");
  271. break;
  272. }
  273. dom.addClass("animation-translation");
  274. dom.fadeOut(500);
  275. setTimeout(function(){
  276. dom.removeClass("animation-translation");
  277. parent.prepend(dom);
  278. dom.fadeIn();
  279. },400);
  280. this.type = type;
  281. },
  282. //下一步
  283. next(){
  284. switch (this.base) {
  285. case "one":
  286. if (this._verifyOne())this.base = "two";
  287. break;
  288. case "two":
  289. if (this._verifyTwo())this.base = "three";
  290. this._loadStorage();
  291. break;
  292. }
  293. },
  294. //完成
  295. success(){
  296. switch (this.base) {
  297. case "one":
  298. if (this._verifyOne())window.location.href = "{{url('customer/project/index')}}";
  299. break;
  300. case "two":
  301. if (this._verifyTwo())window.location.href = "{{url('customer/project/index')}}";
  302. break;
  303. default:
  304. window.tempTip.confirm("<span class='text-danger'>确定后计费模型未保存项将被抛弃,您确认仍要完成吗?</span>",()=>{
  305. window.location.href = "{{url('customer/project/index')}}";
  306. });
  307. break;
  308. }
  309. },
  310. //重置
  311. reset(){
  312. switch (this.base) {
  313. case "one":
  314. this.owner = this.ownerTemp;
  315. break;
  316. case "two":
  317. this.owner = this.ownerTemp;
  318. break;
  319. }
  320. },
  321. //验证基础信息
  322. _verifyOne(){
  323. if (!this.owner.name){
  324. this.errors["name"] = ["项目名称为必填项"];
  325. this.$forceUpdate();
  326. return false;
  327. }
  328. if (!this.owner.code){
  329. this.errors["code"] = ["项目代码为必填项"];
  330. this.$forceUpdate();
  331. return false;
  332. }
  333. if (this.owner.name !== this.ownerTemp.name || this.owner.code !== this.ownerTemp.code){
  334. let url = "{{url('maintenance/owner/apiStore')}}";
  335. let params = {name:this.owner.name,code:this.owner.code,id:this.owner.id};
  336. let result = undefined;
  337. window.tempTip.postBasicRequest(url,params,res=>{
  338. if (res.errors){
  339. this.errors = res.errors;
  340. this.$forceUpdate();
  341. result = false;
  342. return;
  343. }
  344. this.errors = [];
  345. this.owner.id = res.id;
  346. this.ownerTemp.name = res.name;
  347. this.ownerTemp.code = res.code;
  348. result = true;
  349. });
  350. while (result){
  351. if (typeof result !== "undefined")return result;
  352. }
  353. }
  354. return true;
  355. },
  356. //验证详细描述
  357. _verifyTwo(){
  358. let error = {};
  359. if (!this.owner.customer_id) error["customer_id"] = ["必须选择客户"];
  360. if (!this.owner.owner_group_id) error["owner_group_id"] = ["必须选择项目小组"];
  361. if (!this.owner.warehouse_id) error["warehouse_id"] = ["必须选择仓库"];
  362. if (JSON.stringify(error) !== "{}"){
  363. this.errors = error;
  364. this.$forceUpdate();
  365. return;
  366. }
  367. let url = "{{url('customer/project/projectUpdate')}}";
  368. let params = this.owner;
  369. let old = this.ownerTemp;
  370. if (params.customer_id !== old.customer_id ||
  371. params.owner_group_id !== old.owner_group_id ||
  372. params.warehouse_id !== old.warehouse_id ||
  373. params.tax_rate !== old.tax_rate ||
  374. params.waring_line_on !== old.waring_line_on ||
  375. params.phone_number !== old.phone_number ||
  376. params.description !== old.description){
  377. let result = undefined;
  378. window.tempTip.postBasicRequest(url,params,res=>{
  379. if (res.errors){
  380. this.errors = res.errors;
  381. this.$forceUpdate();
  382. result = false;
  383. return;
  384. }
  385. this.errors = [];
  386. this.ownerTemp.customer_id = res.customer_id;
  387. this.ownerTemp.owner_group_id = res.owner_group_id;
  388. this.ownerTemp.warehouse_id = res.warehouse_id;
  389. this.ownerTemp.tax_rate = res.tax_rate;
  390. this.ownerTemp.waring_line_on = res.waring_line_on;
  391. this.ownerTemp.phone_number = res.phone_number;
  392. this.ownerTemp.description = res.description;
  393. this.ownerTemp.customer_name = params.customer_name;
  394. this.ownerTemp.owner_group_name = params.owner_group_name;
  395. result = true;
  396. });
  397. while (result){
  398. if (typeof result !== "undefined")return result;
  399. }
  400. }
  401. return true;
  402. },
  403. //上一步
  404. back(){
  405. switch (this.base) {
  406. case "two":
  407. this.base = 'one';
  408. break;
  409. case "three":
  410. this.base = 'two';
  411. break;
  412. }
  413. },
  414. //加载计费模型
  415. _loadPriceModel(){
  416. let url = "{{url('customer/project/getPriceModel')}}";
  417. let params = {id:this.ownerTemp.id};
  418. window.tempTip.postBasicRequest(url,params,res=>{
  419. if (res.owner_storage_price_models.length>0)this.selectedModel.storage = res.owner_storage_price_models;
  420. if (res.owner_price_operations.length>0){
  421. this._loadOperation();
  422. res.owner_price_operations.forEach((operation)=>{
  423. if (operation.discount_count)operation.isDiscount = true;
  424. if (operation.total_price)operation.isSingle = true;
  425. });
  426. this.selectedModel.operation = res.owner_price_operations;
  427. }
  428. if (res.owner_price_expresses.length>0){
  429. this._loadExpress();
  430. res.owner_price_expresses.forEach((express,i)=>{
  431. express.logistics.forEach((logistic,j)=>{
  432. express.logistics[j] = logistic.id;
  433. });
  434. res.owner_price_expresses[i] = JSON.parse(JSON.stringify(express).replace(/details/g,"items"));
  435. this.upList['express-item-'+i] = true;
  436. });
  437. this.selectedModel.express = res.owner_price_expresses;
  438. }
  439. if (res.owner_price_logistics.length>0){
  440. if (res.owner_price_expresses.length===0)this._loadLogistic();
  441. else {
  442. this._getUnits();
  443. this._getCities();
  444. }
  445. res.owner_price_logistics.forEach((logistic,i)=>{
  446. logistic.logistics.forEach((l,j)=>{
  447. logistic.logistics[j] = l.id;
  448. });
  449. res.owner_price_logistics[i] = JSON.parse(JSON.stringify(logistic).replace(/details/g,"items"));
  450. this.upList['logistic-item-'+i] = true;
  451. });
  452. this.selectedModel.logistic = res.owner_price_logistics;
  453. }
  454. if (res.owner_price_direct_logistics.length>0){
  455. this.upList["directLogistic-item"] = true;
  456. this.selectedModel.directLogistic = JSON.parse(JSON.stringify(res.owner_price_direct_logistics[0]).replace(/details/g,"items"));
  457. }
  458. setTimeout(()=> {
  459. $(".up").slideUp();
  460. this.isLoad = true;
  461. },0)
  462. });
  463. },
  464. //加载仓储所需基础信息
  465. _loadStorage(){
  466. if (!this.pool.units)this._getUnits();
  467. if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
  468. if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
  469. },
  470. //加载作业
  471. _loadOperation(){
  472. if (!this.pool.units)this._getUnits();
  473. },
  474. //加载快递
  475. _loadExpress(){
  476. if (!this.pool.provinces)this._getProvinces();
  477. if (!this.pool.logistics)this._getLogistics();
  478. },
  479. //加载物流
  480. _loadLogistic(){
  481. if (!this.pool.units) this._getUnits();
  482. if (!this.pool.provinces)this._getProvinces();
  483. if (!this.pool.cities)this._getCities();
  484. if (!this.pool.logistics)this._getLogistics();
  485. },
  486. //加载直发车
  487. _loadDirectLogistic(){
  488. if (!this.pool.cars)this._getCars();
  489. },
  490. //加载引入
  491. loadIntroduce(){
  492. if (!this.pool.owners)this._getOwners();
  493. if (!this.pool.logistics)this._getLogistics();
  494. },
  495. _setModelData(key,val){
  496. if (!val)return;
  497. let mapping = [];
  498. val.forEach(item=>{
  499. mapping[item.id] = item.name;
  500. });
  501. this.$set(this.pool,key,val);
  502. this.$set(this.poolMapping,key,mapping);
  503. },
  504. //获取项目
  505. _getOwners(){
  506. let url = "{{url('maintenance/owner/get')}}";
  507. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("owners",res);});
  508. },
  509. //获取单位
  510. _getUnits(){
  511. let url = "{{url('maintenance/unit/getUnits')}}";
  512. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("units",res);});
  513. },
  514. //获取省份
  515. _getProvinces(){
  516. let url = "{{url('maintenance/province/get')}}";
  517. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("provinces",res);});
  518. },
  519. //获取城市
  520. _getCities(){
  521. let url = "{{url('maintenance/city/get')}}";
  522. window.tempTip.postBasicRequest(url,{},res=>{this._setModelData("cities",res);});
  523. },
  524. //获取承运商
  525. _getLogistics(){
  526. let url = "{{url('maintenance/logistic/get')}}";
  527. window.tempTip.postBasicRequest(url,{type:''},res=>{
  528. this._setModelData("logistics",res);
  529. setTimeout(()=>{
  530. $(".selectpicker").selectpicker('refresh');
  531. },0);
  532. });
  533. },
  534. //获取车型
  535. _getCars(){
  536. let url = "{{url('maintenance/carType/get')}}";
  537. window.axios.post(url).then(res=>{this._setModelData("cars",res.data);});
  538. },
  539. //保存模型
  540. saveModel(){
  541. switch (this.type) {
  542. case "storage":
  543. this._verifyStorage();
  544. break;
  545. case "operation":
  546. this._verifyOperation();
  547. break;
  548. case "express":
  549. this._verifyExpress();
  550. break;
  551. case "logistic":
  552. this._verifyLogistic();
  553. break;
  554. case "directLogistic":
  555. this._verifyDirectLogistic();
  556. break;
  557. }
  558. },
  559. _verifyStorage(){
  560. let error = {};
  561. if (!this.model.storage.counting_type)error["counting_type"] = ["未选择计费类型"];
  562. if (!this.model.storage.name)error["name"] = ["未填写名称"];
  563. if (!this.model.storage.using_type)error["using_type"] = ["未选择用仓类型"];
  564. if (!this.model.storage.price)error["price"] = ["未输入单价"];
  565. if (!this.model.storage.discount_type)error["discount_type"] = ["未选择减免类型"];
  566. if (!this.model.storage.unit_id)error["unit_id"] = ["未选择单位"];
  567. if (!this.model.storage.time_unit_id)error["time_unit_id"] = ["未选择计时单位"];
  568. if (JSON.stringify(error) !== "{}"){
  569. this.errors = error;
  570. this.$forceUpdate();
  571. return;
  572. }
  573. let url = "{{url('maintenance/priceModel/apiStoreStorage')}}";
  574. let params = this.model.storage;
  575. params.owner_id = this.ownerTemp.id;
  576. window.tempTip.postBasicRequest(url,params,res=>{
  577. if (res && res.errors){
  578. this.errors = res.errors;
  579. return;
  580. }
  581. if (this.model.storage.id) this.selectedModel.storage[this.model.storage.index] = this.model.storage;
  582. else {
  583. this.model.storage.id = res;
  584. this.selectedModel.storage.unshift(this.model.storage);
  585. }
  586. this.model.storage = {
  587. name : "",
  588. counting_type : "",
  589. using_type : "",
  590. minimum_area : "",
  591. price : "",
  592. discount_type : "无减免",
  593. discount_value : "",
  594. unit_id : "",
  595. time_unit_id : "",
  596. };
  597. this.errors = [];
  598. });
  599. },
  600. _verifyOperation() {
  601. if (this.selectedModel.operation.length>0 && !this.model.operation.id){
  602. if (this.model.operation.strategy!=='特征'){
  603. if (!this.selectedModel.operation.every(operation=>{
  604. if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
  605. this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
  606. this.$forceUpdate();
  607. return false;
  608. }
  609. return true;
  610. }))return;
  611. }
  612. }
  613. if (!this.model.operation.name){
  614. this.errors["name"] = ["名称不得为空"];
  615. this.$forceUpdate();
  616. return;
  617. }
  618. if (this.model.operation.isDiscount && !this.model.operation.discount_count){
  619. this.errors["discount_count"] = ["满减值不存在"];
  620. this.$forceUpdate();
  621. return;
  622. }
  623. if (this.model.operation.isSingle && !this.model.operation.total_price){
  624. this.errors["total_price"] = ["按单价格不存在"];
  625. this.$forceUpdate();
  626. return;
  627. }
  628. if (this.model.operation.isDiscount && this.model.operation.isSingle && !this.model.operation.total_discount_price){
  629. this.errors["total_discount_price"] = ["满减价格不存在"];
  630. this.$forceUpdate();
  631. return;
  632. }
  633. if (!this.model.operation.isSingle){
  634. if ((this.model.operation.operation_type === '出库' && this._verifyOperationItem(0)) || this._verifyOperationItem(1))return;
  635. if (this.model.operation.items.length>2){
  636. for (let i=2;i<this.model.operation.items.length;i++){
  637. if (this._verifyOperationItem(i))return;
  638. }
  639. }
  640. this.model.operation.total_price = "";
  641. }else this.$set(this.model.operation,"items",[]);
  642. if (!this.model.operation.isDiscount) {
  643. this.model.operation.discount_count = "";
  644. this.model.operation.total_discount_price = "";
  645. }
  646. let url = "{{url('maintenance/priceModel/apiStoreOperation')}}";
  647. let params = this.model.operation;
  648. params.owner_id = this.ownerTemp.id;
  649. window.tempTip.postBasicRequest(url,params,res=>{
  650. if (res && res.errors){
  651. if (res.errors.owner_id){
  652. window.tempTip.show(res.errors.owner_id[0]);
  653. return;
  654. }
  655. this.errors = res.errors;
  656. return;
  657. }
  658. res.features = this.model.operation.features;
  659. res.featureFormat = this.model.operation.featureFormat;
  660. let sign = 0;
  661. if (res.operation_type === '入库') sign++;
  662. for (let i=0;i<res.items.length;i++){
  663. res.items[i].features = this.model.operation.items[sign]['features'];
  664. res.items[i].featureFormat = this.model.operation.items[sign]['featureFormat'];
  665. res.items[i].type = this.model.operation.items[sign]['type'];
  666. sign++;
  667. }
  668. if (res.discount_count)res.isDiscount = true;
  669. if (res.total_price)res.isSingle = true;
  670. if (params.id) this.selectedModel.operation[params.index] = res;
  671. else this.selectedModel.operation.push(res);
  672. this.model.operation = {
  673. operation_type:"入库",
  674. strategy:"默认",
  675. name:"",
  676. feature:"",
  677. items : [
  678. {strategy:"起步",type:"0"},
  679. {strategy:"默认"},
  680. {strategy:"特征"},
  681. ],
  682. };
  683. this.errors = [];
  684. });
  685. },
  686. _verifyOperationItem(itemIndex){//验证作业费子项信息完整
  687. let obj = this.model.operation.items[itemIndex];
  688. let sign = false;
  689. if (obj.strategy === '特征' && !obj.feature){
  690. this.errors['items.'+itemIndex+'.feature'] = ["必须选择特征"];
  691. sign = true;
  692. }
  693. if (this.model.operation.isDiscount && !obj.discount_price){
  694. this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
  695. sign = true;
  696. }
  697. if (obj.strategy!=='起步' && !obj.amount){
  698. this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
  699. sign = true;
  700. }else if (!obj.amount) obj.amount = 0;
  701. if (obj.strategy!=='起步' && !obj.unit_id){
  702. this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
  703. sign = true;
  704. }else if (!obj.unit_id) obj.unit_id = 0;
  705. if (!obj.unit_price){
  706. this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
  707. }
  708. if (this.model.operation.isDiscount && !obj.discount_price){
  709. this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
  710. }
  711. if (sign)this.$forceUpdate();
  712. return sign;
  713. },
  714. _verifyExpress(){
  715. let error = {};
  716. if (!this.model.express.name)error.name = ["名称不得为空"];
  717. if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
  718. if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
  719. if (this.model.express.items.length>0){
  720. this.model.express.items.forEach((item,index)=>{
  721. if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
  722. if (!item.initial_weight_price)error["item."+index+".initial_weight_price"] = ["不存在"];
  723. if (!item.additional_weight_price)error["item."+index+".additional_weight_price"] = ["不存在"];
  724. });
  725. }
  726. if (JSON.stringify(error) !== "{}"){
  727. this.errors = error;
  728. this.$forceUpdate();
  729. return;
  730. }
  731. let url = "{{url('maintenance/priceModel/apiStoreExpress')}}";
  732. let params = this.model.express;
  733. params.owner_id = this.ownerTemp.id;
  734. window.tempTip.postBasicRequest(url,params,res=>{
  735. if (res && res.errors){
  736. this.errors = res.errors;
  737. if (res.errors.owner_id)window.tempTip.show(res.errors.owner_id[0]);
  738. return;
  739. }
  740. this.model.express.items.forEach((item,i)=>{
  741. item.id = res.details[i].id;
  742. });
  743. if (this.model.express.id) this.selectedModel.express[this.model.express.index] = this.model.express;
  744. else{
  745. this.model.express.id = res.id;
  746. this.selectedModel.express.unshift(this.model.express);
  747. }
  748. this.model.express = {
  749. name:"",
  750. logistics:[],
  751. initial_weight:"",
  752. additional_weight:"",
  753. items:[],
  754. };
  755. this.errors = [];
  756. this.importError = [];
  757. $(".selectpicker").filter('.express').selectpicker('val',[]);
  758. });
  759. },
  760. _verifyLogistic(){
  761. let error = {};
  762. if (!this.model.logistic.name) error.name = ["名称不得为空"];
  763. if (!this.model.logistic.unit_id) error.unit_id = ["单位一不得为空"];
  764. if (!this.model.logistic.unit_range) error.unit_range = ["区间值不得为空"];
  765. if (!this.model.logistic.other_unit_id) error.other_unit_id = ["单位二不得为空"];
  766. if (!this.model.logistic.other_unit_range) error.other_unit_range = ["区间值不得为空"];
  767. if (JSON.stringify(error) !== "{}"){
  768. this.errors = error;
  769. this.$forceUpdate();
  770. return;
  771. }
  772. let url = "{{url('maintenance/priceModel/apiStoreLogistic')}}";
  773. let params = this.model.logistic;
  774. params.owner_id = this.ownerTemp.id;
  775. window.tempTip.postBasicRequest(url,params,res=>{
  776. if (res && res.errors){
  777. this.errors = res.errors;
  778. window.tempTip.show("检查您的子项详情列表是否完整");
  779. return;
  780. }
  781. this.model.logistic.items.forEach((item,i)=>{
  782. item.id = res.details[i].id;
  783. });
  784. if (this.model.logistic.id) this.selectedModel.logistic[this.model.logistic.index] = this.model.logistic;
  785. else {
  786. this.model.logistic.id = res.id;
  787. this.selectedModel.logistic.unshift(this.model.logistic);
  788. }
  789. this.model.logistic = {
  790. items:[],
  791. other_ranges:[],
  792. ranges:[],
  793. logistics:[],
  794. };
  795. this.errors = [];
  796. this.importError = [];
  797. $(".selectpicker").filter('.logistic').selectpicker('val',[]);
  798. });
  799. },
  800. _verifyDirectLogistic(){
  801. let error = {};
  802. if (!this.model.directLogistic.name) error.name = ["名称不得为空"];
  803. if (!this.model.directLogistic.base_km) error.base_km = ["起步公里数不得为空"];
  804. if (JSON.stringify(error) !== "{}"){
  805. this.errors = error;
  806. this.$forceUpdate();
  807. return;
  808. }
  809. let url = "{{url('maintenance/priceModel/apiStoreDirectLogistic')}}";
  810. let params = this.model.directLogistic;
  811. params.owner_id = this.ownerTemp.id;
  812. window.tempTip.postBasicRequest(url,params,res=>{
  813. if (res && res.errors){
  814. this.errors = res.errors;
  815. return;
  816. }
  817. this.model.directLogistic.items.forEach((item,i)=>{
  818. item.id = res.details[i].id;
  819. });
  820. this.model.directLogistic.id = res.id;
  821. this.selectedModel.directLogistic = this.model.directLogistic;
  822. this.model.directLogistic = {
  823. items:[],
  824. };
  825. this.errors = [];
  826. this.importError = [];
  827. });
  828. },
  829. //增加作业费特征子项
  830. addOperationItem(){
  831. this.model.operation.items.push({
  832. strategy:"特征"
  833. });
  834. },
  835. //删除作业费子项
  836. delOperationItem(index){
  837. this.$delete(this.model.operation.items,index);
  838. },
  839. //显示特征选择modal
  840. showAddFeatureModal(index){
  841. if (index === -1){
  842. if (!this.model.operation.feature){
  843. this.model.operation.features = this._createFeature();
  844. this.thisOperationItemIndex = index;
  845. this.$forceUpdate();
  846. $("#addFeatureModal").modal("show");
  847. return;
  848. }
  849. if (this.model.operation.features) {
  850. this.thisOperationItemIndex = index;
  851. $("#addFeatureModal").modal("show");
  852. return;
  853. }
  854. }else{
  855. if (!this.model.operation.items[index].feature){
  856. this.model.operation.items[index].features = this._createFeature();
  857. this.thisOperationItemIndex = index;
  858. this.$forceUpdate();
  859. $("#addFeatureModal").modal("show");
  860. return;
  861. }
  862. if (this.model.operation.items[index].features) {
  863. this.thisOperationItemIndex = index;
  864. $("#addFeatureModal").modal("show");
  865. return;
  866. }
  867. }
  868. let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
  869. let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
  870. window.tempTip.postBasicRequest(url,{feature:feature},res=>{
  871. if (!res || res.length === 0){
  872. res = this._createFeature();
  873. }
  874. if (index === -1) this.model.operation.features = res;
  875. else this.model.operation.items[index].features = res;
  876. this.thisOperationItemIndex = index;
  877. this.$forceUpdate();
  878. $("#addFeatureModal").modal("show");
  879. });
  880. },
  881. //增加特征
  882. addFeature(){
  883. let obj = {
  884. "strategyGroupStartSign": false,
  885. "calculation" : "",
  886. "type" : "",
  887. "id" : "",
  888. "logic" : "",
  889. "describe" : "",
  890. "strategyGroupEndSign" : false,
  891. };
  892. if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
  893. else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
  894. this.$forceUpdate();
  895. },
  896. _createFeature(){
  897. return [{
  898. "strategyGroupStartSign": false,
  899. "calculation" : "",
  900. "type" : "",
  901. "id" : "",
  902. "logic" : "",
  903. "describe" : "",
  904. "strategyGroupEndSign" : false,
  905. }];
  906. },
  907. //删除特征
  908. delFeature(index) {
  909. if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
  910. else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
  911. this.$forceUpdate();
  912. },
  913. //提交特征更新现有
  914. submitFeature(){
  915. let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
  916. let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
  917. window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
  918. if (this.thisOperationItemIndex === -1){
  919. this.model.operation.feature = res.feature;
  920. this.model.operation.featureFormat = res.featureFormat;
  921. } else {
  922. this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
  923. this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
  924. this.$forceUpdate();
  925. }
  926. $("#addFeatureModal").modal("hide");
  927. return "已更新特征";
  928. },true);
  929. },
  930. /*//渲染作业费子项
  931. _renderingOperationItem(index){
  932. let domId = "operation-"+index;
  933. let trId = "operation-tr-"+index;
  934. let itemId = "operation-item-"+index;
  935. let html = "<tr class='d-none' id='"+trId+"'><td></td><td colspan='5'>"+
  936. "<div id='"+itemId+"'><table class='table table-sm'>"+
  937. "<th>子策略</th><th>数量</th><th>单位</th><th>单价</th><th>特征</th></th>";
  938. this.selectedModel.operation[index].items.forEach(item=> {
  939. html = this._createOperationItemList(html,item.strategy,item.amount,this.poolMapping.units[item.unit_id],item.unit_price,item.featureFormat ? item.featureFormat : '');
  940. });
  941. html += "</table></div></td></tr>";
  942. $("#"+domId).after(html);
  943. $("#"+itemId).slideUp();
  944. },
  945. _createOperationItemList(html,strategy,amount,unit,unit_price,feature){
  946. html += "<tr><td>"+strategy+"</td><td>"+amount+"</td><td>"+unit+"</td><td>"+unit_price+"</td><td><div class='text-overflow-warp-100'>"+feature+"</div></td></tr>";
  947. return html;
  948. },*/
  949. //移入移出时更改长文本显示效果
  950. textClass(event,isOver){
  951. event = event.target.children[0];
  952. if (isOver) event.className = "text-overflow-warp-100";
  953. else event.className = "cursor-pointer text-overflow-replace-100";
  954. },
  955. //展开子策略
  956. showOperationItem(index){
  957. let trId = "operation-tr-"+index;
  958. let itemId = "operation-item-"+index;
  959. if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
  960. this.operationItems['_'+index] = false;
  961. $("#"+itemId).slideUp(undefined,function () {
  962. $("#"+trId).addClass("d-none");
  963. });
  964. }else {
  965. $("#"+trId).removeClass("d-none");
  966. this.operationItems['_'+index] = true;
  967. $("#"+itemId).slideDown();
  968. }
  969. this.$forceUpdate();
  970. },
  971. //新增快递子项
  972. addExpressItem(){
  973. this.model.express.items.unshift({
  974. province_id : "",
  975. initial_weight_price:"",
  976. additional_weight_price:"",
  977. });
  978. },
  979. //删除快递子项
  980. delExpressItem(index){
  981. this.$delete(this.model.express.items,index);
  982. },
  983. //选择文件
  984. selectFile(id){
  985. this.importError = [];
  986. $("#"+id).click();
  987. },
  988. //导入快递子项
  989. importExpress(e){
  990. let file=e.target.files[0];
  991. if (!file){
  992. tempTip.setDuration(3000);
  993. tempTip.show("未选择文件");
  994. return;
  995. }
  996. let formData = new FormData();
  997. formData.append("file",file);
  998. axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  999. 'Content-Type':'multipart/form-data'
  1000. }).then(res=>{
  1001. if (res.data.success) {
  1002. res.data.data.forEach(data=>{
  1003. let unique = this.model.express.items.every(item=>{
  1004. if (data.province_id === item.province_id)return false;
  1005. return true;
  1006. });
  1007. if (unique)this.model.express.items.push(data);
  1008. });
  1009. this.importError = res.data.errors;
  1010. tempTip.setDuration(3000);
  1011. tempTip.showSuccess("导入成功!");
  1012. return;
  1013. }
  1014. tempTip.setDuration(3000);
  1015. tempTip.show(res.data.data);
  1016. }).catch(err=> {
  1017. tempTip.setDuration(3000);
  1018. tempTip.show("网络错误:"+err);
  1019. })
  1020. },
  1021. //物流详情列表modal
  1022. showDetailModal() {
  1023. $("#logisticModal").modal("show");
  1024. },
  1025. //新增物流详情
  1026. addLogisticDetail(){
  1027. this.model.logistic.items.unshift({});
  1028. },
  1029. //导入物流详情
  1030. importLogistic(e){
  1031. window.tempTip.setIndex(1099);
  1032. let file=e.target.files[0];
  1033. if (!file){
  1034. window.tempTip.setDuration(3000);
  1035. window.tempTip.show("未选择文件");
  1036. return;
  1037. }
  1038. let formData = new FormData();
  1039. formData.append("file",file);
  1040. window.axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  1041. 'Content-Type':'multipart/form-data'
  1042. }).then(res=>{
  1043. if (res.data.success) {
  1044. res.data.data.forEach(data=>{
  1045. //过滤非已选择单位的数据
  1046. let id = "";
  1047. if (data.unit_id === this.poolMapping.units[this.model.logistic.unit_id]) id = this.model.logistic.unit_id;
  1048. if (data.unit_id === this.poolMapping.units[this.model.logistic.other_unit_id]) id = this.model.logistic.other_unit_id;
  1049. if (id){
  1050. //过滤重复数据
  1051. let unique = this.model.logistic.items.every(item=>{
  1052. if (id === item.unit_id && data.range === item.range
  1053. && data.province_id === item.province_id && data.city_id === item.city_id)return false;
  1054. return true;
  1055. });
  1056. if (unique){
  1057. data.unit_id = id;
  1058. this.model.logistic.items.push(data);
  1059. }
  1060. }
  1061. });
  1062. this.importError = res.data.errors;
  1063. window.tempTip.setDuration(3000);
  1064. window.tempTip.showSuccess("导入成功!");
  1065. return;
  1066. }
  1067. window.tempTip.setDuration(3000);
  1068. window.tempTip.show(res.data.data);
  1069. }).catch(err=> {
  1070. window.tempTip.setDuration(3000);
  1071. window.tempTip.show("网络错误:"+err);
  1072. })
  1073. },
  1074. //删除物流子项
  1075. delLogisticItem(index){
  1076. this.$delete(this.model.logistic.items,index);
  1077. },
  1078. //改变物流区间时改变可选择项
  1079. changeRange(type){
  1080. if (type === 'ranges'){
  1081. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1082. }else{
  1083. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1084. }
  1085. },
  1086. //增加直发车子项
  1087. addDirectLogisticItem(){
  1088. this.model.directLogistic.items.unshift({
  1089. car_type_id : "",
  1090. base_fee:"",
  1091. additional_fee:"",
  1092. });
  1093. },
  1094. //导入直发车子项
  1095. importDirectLogistic(e){
  1096. window.tempTip.setIndex(1099);
  1097. let file=e.target.files[0];
  1098. if (!file){
  1099. window.tempTip.setDuration(3000);
  1100. window.tempTip.show("未选择文件");
  1101. return;
  1102. }
  1103. let formData = new FormData();
  1104. formData.append("file",file);
  1105. window.axios.post('{{url('maintenance/priceModel/directLogistic/import')}}',formData,{
  1106. 'Content-Type':'multipart/form-data'
  1107. }).then(res=>{
  1108. if (res.data.success) {
  1109. if (this.model.directLogistic.items.length > 0){
  1110. res.data.data.forEach(data=>{
  1111. let unique = this.model.directLogistic.items.every(item=>{
  1112. if (item.car_type_id === data.car_type_id)return false;
  1113. return true;
  1114. });
  1115. if (unique) this.model.directLogistic.items.unshift(data);
  1116. });
  1117. }else this.model.directLogistic.items = res.data.data;
  1118. this.importError = res.data.errors;
  1119. window.tempTip.setDuration(3000);
  1120. window.tempTip.showSuccess("导入成功!");
  1121. return;
  1122. }
  1123. window.tempTip.setDuration(3000);
  1124. window.tempTip.show(res.data.data);
  1125. }).catch(err=> {
  1126. window.tempTip.setDuration(3000);
  1127. window.tempTip.show("网络错误:"+err);
  1128. })
  1129. },
  1130. //删除直发车子项
  1131. delDirectLogisticItem(index){
  1132. this.$delete(this.model.directLogistic.items,index);
  1133. },
  1134. //改变客户
  1135. selectOwner(){
  1136. let id = this.owner.customer_id;
  1137. this.customers.some(customer=>{
  1138. if (id === customer.id){
  1139. this.owner.customer_name = customer.name;
  1140. return true;
  1141. }
  1142. });
  1143. },
  1144. //改变小组
  1145. selectGroup(){
  1146. let id = this.owner.owner_group_id;
  1147. this.ownerGroups.some(group=>{
  1148. if (id === group.id){
  1149. this.owner.owner_group_name = group.name;
  1150. return true;
  1151. }
  1152. });
  1153. },
  1154. //获取引入计费模型查询列表搜索
  1155. searchPriceModel(){
  1156. this.isSearch = true;
  1157. switch (this.type) {
  1158. case "storage":
  1159. this._getStoragePriceModel();
  1160. break;
  1161. case "operation":
  1162. this._getOperationPriceModel();
  1163. break;
  1164. case "express":
  1165. this._getExpressPriceModel();
  1166. break;
  1167. case "logistic":
  1168. this._getLogisticPriceModel();
  1169. break;
  1170. default:
  1171. this._getDirectLogisticPriceModel();
  1172. }
  1173. },
  1174. _getStoragePriceModel(){
  1175. let url = "{{url('maintenance/priceModel/apiGetStorage')}}";
  1176. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1177. let result = [];
  1178. let mapping = {};
  1179. res.forEach(model=> {
  1180. let text = model.name+" ("+model.counting_type+"-"+model.using_type+")";
  1181. result.push({id:model.id,text:text});
  1182. mapping[model.id] = {
  1183. name : model.name,
  1184. counting_type : model.counting_type,
  1185. using_type : model.using_type,
  1186. minimum_area : model.minimum_area,
  1187. price : model.price,
  1188. discount_type : model.discount_type,
  1189. discount_value : model.discount_value,
  1190. unit_id : model.unit_id,
  1191. };
  1192. });
  1193. this.searchResult = result;
  1194. this.searchResultMapping = mapping;
  1195. this.isSearch = false;
  1196. });
  1197. },
  1198. _getOperationPriceModel(){
  1199. let url = "{{url('maintenance/priceModel/apiGetOperation')}}";
  1200. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1201. let result = [];
  1202. let mapping = {};
  1203. res.forEach(model=> {
  1204. let text = model.name+" ("+model.operation_type+"-"+model.strategy+")";
  1205. result.push({id:model.id,text:text});
  1206. mapping[model.id] = {
  1207. name : model.name,
  1208. operation_type : model.operation_type,
  1209. strategy : model.strategy,
  1210. feature : model.feature,
  1211. featureFormat : model.featureFormat,
  1212. remark : model.remark,
  1213. items:model.items,
  1214. };
  1215. });
  1216. this.searchResult = result;
  1217. this.searchResultMapping = mapping;
  1218. this.isSearch = false;
  1219. });
  1220. },
  1221. _getExpressPriceModel(){
  1222. let url = "{{url('maintenance/priceModel/apiGetExpress')}}";
  1223. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1224. let result = [];
  1225. let mapping = {};
  1226. res.forEach(model=> {
  1227. let text = model.name+" (首重:"+model.initial_weight+"KG 续重:"+model.additional_weight+"KG)";
  1228. result.push({id:model.id,text:text});
  1229. let logistics = [];
  1230. model.logistics.forEach(logistic=>{
  1231. logistics.push(logistic.id);
  1232. });
  1233. let items = [];
  1234. model.details.forEach(item=>{
  1235. items.push({
  1236. province_id:item.province_id,
  1237. initial_weight_price:item.initial_weight_price,
  1238. additional_weight_price:item.additional_weight_price,
  1239. });
  1240. });
  1241. mapping[model.id] = {
  1242. logistics : logistics,
  1243. name:model.name,
  1244. initial_weight:model.initial_weight,
  1245. additional_weight:model.additional_weight,
  1246. items:items,
  1247. };
  1248. });
  1249. this.searchResult = result;
  1250. this.searchResultMapping = mapping;
  1251. this.isSearch = false;
  1252. });
  1253. },
  1254. _getLogisticPriceModel(){
  1255. let url = "{{url('maintenance/priceModel/apiGetLogistic')}}";
  1256. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1257. let result = [];
  1258. let mapping = {};
  1259. res.forEach(model=> {
  1260. let text = model.name+" (单位一:"+this.poolMapping.units[model.unit_id]+"["+model.unit_range+
  1261. "] 单位二:"+this.poolMapping.units[model.other_unit_id]+"["+model.other_unit_range+"])";
  1262. result.push({id:model.id,text:text});
  1263. let logistics = [];
  1264. model.logistics.forEach(logistic=>{
  1265. logistics.push(logistic.id);
  1266. });
  1267. let items = [];
  1268. model.details.forEach(item=>{
  1269. items.push({
  1270. unit_id:item.unit_id,
  1271. range:item.range,
  1272. province_id:item.province_id,
  1273. city_id:item.city_id,
  1274. unit_price:item.unit_price,
  1275. delivery_fee:item.delivery_fee,
  1276. initial_fee:item.initial_fee,
  1277. initial_amount:item.initial_amount,
  1278. rate:item.rate,
  1279. });
  1280. });
  1281. mapping[model.id] = {
  1282. logistics : logistics,
  1283. name:model.name,
  1284. unit_range:model.unit_range,
  1285. unit_id:model.unit_id,
  1286. other_unit_range:model.other_unit_range,
  1287. other_unit_id:model.other_unit_id,
  1288. pick_up_price:model.pick_up_price,
  1289. fuel_price:model.fuel_price,
  1290. service_price:model.service_price,
  1291. items:items,
  1292. };
  1293. });
  1294. this.searchResult = result;
  1295. this.searchResultMapping = mapping;
  1296. this.isSearch = false;
  1297. });
  1298. },
  1299. _getDirectLogisticPriceModel(){
  1300. let url = "{{url('maintenance/priceModel/apiGetDirectLogistic')}}";
  1301. window.tempTip.postBasicRequest(url,this.introduce,res=>{
  1302. let result = [];
  1303. let mapping = {};
  1304. res.forEach(model=> {
  1305. let text = model.name+" (起步数:"+model.base_km+"KM)";
  1306. result.push({id:model.id,text:text});
  1307. let items = [];
  1308. model.details.forEach(item=>{
  1309. items.push({
  1310. car_type_id:item.car_type_id,
  1311. base_fee:item.base_fee,
  1312. additional_fee:item.additional_fee,
  1313. });
  1314. });
  1315. mapping[model.id] = {
  1316. name:model.name,
  1317. base_km:model.base_km,
  1318. items:items,
  1319. };
  1320. });
  1321. this.searchResult = result;
  1322. this.searchResultMapping = mapping;
  1323. this.isSearch = false;
  1324. });
  1325. },
  1326. //提交引入
  1327. submitIntroduce(){
  1328. if (!this.selectedResult || !this.searchResultMapping[this.selectedResult]){
  1329. window.tempTip.setDuration(3000);
  1330. window.tempTip.show("尚未选择引入项,请单击选择列表,如列表为空则无结果");
  1331. return;
  1332. }
  1333. let model = this.searchResultMapping[this.selectedResult];
  1334. switch (this.type) {
  1335. case "storage":
  1336. this.model.storage = model;
  1337. break;
  1338. case "operation":
  1339. this.model.operation = model;
  1340. break;
  1341. case "express":
  1342. this.model.express = model;
  1343. break;
  1344. case "logistic":
  1345. this.model.logistic = model;
  1346. break;
  1347. default:
  1348. this.model.directLogistic = model;
  1349. break;
  1350. }
  1351. $("#introduce").modal('hide');
  1352. window.tempTip.setDuration(2000);
  1353. window.tempTip.showSuccess("引入成功");
  1354. },
  1355. //删除仓储
  1356. delStorage(item,index){
  1357. window.tempTip.confirm("您确定要删除仓储计费“"+item.name+"”吗?",()=>{
  1358. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelStorage')}}",{id:item.id},res=>{
  1359. this.$delete(this.selectedModel.storage,index);
  1360. return "删除“"+item.name+"”成功";
  1361. });
  1362. });
  1363. },
  1364. //删除作业
  1365. delOperation(item,index){
  1366. window.tempTip.confirm("您确定要删除作业计费“"+item.name+"”吗?",()=>{
  1367. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperation')}}",{id:item.id},res=>{
  1368. this.$delete(this.selectedModel.operation,index);
  1369. return "删除“"+item.name+"”成功";
  1370. });
  1371. });
  1372. },
  1373. //删除作业子项
  1374. deleteOperationItem(item,index,parentIndex){
  1375. window.tempTip.confirm("您确定要删除该作业子项吗?",()=>{
  1376. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelOperationItem')}}",{id:item.id},res=>{
  1377. this.$delete(this.selectedModel.operation[parentIndex].items,index);
  1378. return "删除成功";
  1379. });
  1380. });
  1381. },
  1382. //删除快递
  1383. delExpress(item,index){
  1384. window.tempTip.confirm("您确定要删除该快递计费“"+item.name+"”吗?",()=>{
  1385. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpress')}}",{id:item.id},res=>{
  1386. this.$delete(this.selectedModel.express,index);
  1387. return "删除“"+item.name+"”成功";
  1388. });
  1389. });
  1390. },
  1391. //删除快递子项
  1392. deleteExpressItem(item,index,parentIndex){
  1393. window.tempTip.confirm("您确定要删除该快递计费子项吗?",()=>{
  1394. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelExpressItem')}}",{id:item.id},res=>{
  1395. this.$delete(this.selectedModel.express[parentIndex].items,index);
  1396. return "删除成功";
  1397. });
  1398. });
  1399. },
  1400. //删除物流
  1401. delLogistic(item,index){
  1402. window.tempTip.confirm("您确定要删除该物流计费“"+item.name+"”吗?",()=>{
  1403. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogistic')}}",{id:item.id},res=>{
  1404. this.$delete(this.selectedModel.logistic,index);
  1405. return "删除“"+item.name+"”成功";
  1406. });
  1407. });
  1408. },
  1409. //删除物流子项
  1410. deleteLogisticItem(item,index,parentIndex){
  1411. window.tempTip.confirm("您确定要删除该物流计费子项吗?",()=>{
  1412. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelLogisticItem')}}",{id:item.id},res=>{
  1413. this.$delete(this.selectedModel.logistic[parentIndex].items,index);
  1414. return "删除成功";
  1415. });
  1416. });
  1417. },
  1418. //删除直发车
  1419. delDirectLogistic(item){
  1420. window.tempTip.confirm("您确定要删除该直发车计费“"+item.name+"”吗?",()=>{
  1421. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogistic')}}",{id:item.id},res=>{
  1422. this.selectedModel.directLogistic = {};
  1423. return "删除“"+item.name+"”成功";
  1424. });
  1425. });
  1426. },
  1427. //删除直发车子项
  1428. deleteDirectLogisticItem(item,index){
  1429. window.tempTip.confirm("您确定要删除该直发车计费子项吗?",()=>{
  1430. window.tempTip.postBasicRequest("{{url('maintenance/priceModel/apiDelDirectLogisticItem')}}",{id:item.id},res=>{
  1431. this.$delete(this.selectedModel.directLogistic.items,index);
  1432. return "删除成功";
  1433. });
  1434. });
  1435. },
  1436. //编辑仓储
  1437. editStorage(index){
  1438. this.switchType("storage");
  1439. this.model.storage = JSON.parse(JSON.stringify(this.selectedModel.storage[index]));
  1440. this.model.storage.index = index;
  1441. },
  1442. //编辑作业
  1443. editOperation(index){
  1444. this.switchType("operation");
  1445. this.model.operation = JSON.parse(JSON.stringify(this.selectedModel.operation[index]));
  1446. if (this.model.operation.operation_type==='入库') this.model.operation.items.unshift({});
  1447. this.model.operation.index = index;
  1448. if (this.model.operation.items.length == 0){
  1449. this.model.operation.items = [
  1450. {strategy:"起步",type:"0"},
  1451. {strategy:"默认"},
  1452. {strategy:"特征"},
  1453. ];
  1454. }
  1455. },
  1456. //编辑快递
  1457. editExpress(index){
  1458. this.switchType("express");
  1459. this.model.express = JSON.parse(JSON.stringify(this.selectedModel.express[index]));
  1460. this.model.express.index = index;
  1461. },
  1462. //编辑物流
  1463. editLogistic(index){
  1464. this.switchType("logistic");
  1465. this.model.logistic = JSON.parse(JSON.stringify(this.selectedModel.logistic[index]));
  1466. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  1467. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  1468. this.model.logistic.index = index;
  1469. },
  1470. //编辑直发车
  1471. editDirectLogistic(){
  1472. this.switchType("directLogistic");
  1473. this.model.directLogistic = JSON.parse(JSON.stringify(this.selectedModel.directLogistic));
  1474. },
  1475. //搜索快递子项
  1476. searchExpress(e){
  1477. let val = e.target.value;
  1478. if (!val){
  1479. this.$set(this.searchItem,'express',null);
  1480. return;
  1481. }
  1482. let items = [];
  1483. this.model.express.items.forEach((item,i)=>{
  1484. if (this.poolMapping.provinces[item.province_id].indexOf(val) !== -1)items.push(i);
  1485. });
  1486. this.$set(this.searchItem,'express',items);
  1487. },
  1488. //搜索直发子项
  1489. searchDirectLogistic(e){
  1490. let val = e.target.value;
  1491. if (!val){
  1492. this.$set(this.searchItem,'directLogistic',null);
  1493. return;
  1494. }
  1495. let items = [];
  1496. this.model.directLogistic.items.forEach((item,i)=>{
  1497. if (this.poolMapping.cars[item.car_type_id].indexOf(val) !== -1)items.push(i);
  1498. });
  1499. this.$set(this.searchItem,'directLogistic',items);
  1500. },
  1501. //搜索物流子项
  1502. searchLogistic(e){
  1503. let val = e.target.value;
  1504. if (!val){
  1505. this.$set(this.searchItem,'logistic',null);
  1506. return;
  1507. }
  1508. let items = [];
  1509. this.model.logistic.items.forEach((item,i)=>{
  1510. if (item.unit_id || item.province_id || item.city_id){
  1511. if ((item.unit_id && this.poolMapping.units[item.unit_id].indexOf(val) !== -1) ||
  1512. (item.province_id && this.poolMapping.provinces[item.province_id].indexOf(val) !== -1) ||
  1513. (item.city_id && this.poolMapping.cities[item.city_id].indexOf(val) !== -1))items.push(i);
  1514. }
  1515. });
  1516. this.$set(this.searchItem,'logistic',items);
  1517. },
  1518. },
  1519. });
  1520. </script>
  1521. @stop