create.blade.php 74 KB

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