create.blade.php 75 KB

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