create.blade.php 76 KB

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