create.blade.php 74 KB

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