create.blade.php 70 KB

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