create.blade.php 71 KB

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