create.blade.php 73 KB

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