create.blade.php 74 KB

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