create.blade.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. @extends('layouts.app')
  2. @section('title')客户管理-项目录入@endsection
  3. @section('content')
  4. @component('customer.project.menu')
  5. @if($owner)
  6. <li class="nav-item">
  7. <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">编辑</a>
  8. </li>
  9. @endif
  10. @endcomponent
  11. <div class="container-fluid card" id="container">
  12. <div class="card-body offset-2">
  13. <div class="row">
  14. <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('one')">
  15. <div class="h-100 w-25">
  16. <div class="h1 fillet text-center" :class="[base == 'one' ? 'sign' : '', (base!=='one' && !owner.name) ? 'bg-secondary border-secondary' : 'bg-info']">
  17. <span class="fa fa-edit ml-1 text-white"></span>
  18. </div>
  19. </div>
  20. <div class="h-100 w-75">
  21. <span class="font-weight-bold ml-1">基础信息</span><br>
  22. <span class="small ml-1">名称:@{{ owner.name }}</span><br>
  23. <span class="small ml-1">代码:@{{ owner.code }}</span><br>
  24. </div>
  25. </div>
  26. <div class="col-2">
  27. <hr class="w-100 mt-4 hr-info">
  28. </div>
  29. <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('two')">
  30. <div class="h-100 w-25">
  31. <div class="h1 fillet text-center" :class="[base == 'two' ? 'sign' : '', (base!=='two' && !owner.customer_id) ? 'bg-secondary border-secondary' : 'bg-info']">
  32. <span class="fa fa-book ml-1 text-white"></span>
  33. </div>
  34. </div>
  35. <div class="h-100 w-75">
  36. <span class="font-weight-bold ml-1">详细描述</span><br>
  37. <span class="small ml-1">客户:@{{ owner.customer_name }}</span><br>
  38. <span class="small ml-1">小组:@{{ owner.owner_group_name }}</span><br>
  39. </div>
  40. </div>
  41. <div class="col-2">
  42. <hr class="w-100 mt-4 hr-info">
  43. </div>
  44. <div class="col-2 form-inline cursor-pointer text-dark" @click="switchBase('three')">
  45. <div class="h-100 w-25">
  46. <div class="h1 fillet text-center" :class="[base == 'three' ? 'sign' : '', (base!=='three' && !owner.ownerStoragePriceModels) ? 'bg-secondary border-secondary' : 'bg-info']">
  47. <span class="fa fa-rmb ml-1 text-white "></span>
  48. </div>
  49. </div>
  50. <div class="h-100 w-75">
  51. <div class="font-weight-bold ml-1 h-100 mt-3">计费模型</div>
  52. </div>
  53. </div>
  54. </div>
  55. <form method="POST" action="{{url('customer/project/store')}}" class="mt-5">
  56. @csrf
  57. <div v-if="base == 'one'">
  58. @include("customer.project.part._one")
  59. </div>
  60. <div v-if="base == 'two'">
  61. @include("customer.project.part._two")
  62. </div>
  63. <div v-if="base == 'three'">
  64. @include("customer.project.part._three")
  65. </div>
  66. <div class="row mt-3">
  67. <div class="pull-right offset-7">
  68. <button type="button" class="btn btn-info ml-1 text-white" v-show="base !== 'one'" @click="back()">上一步</button>
  69. <button type="button" class="btn btn-info ml-1 text-white" v-show="base !== 'three'" @click="next()">下一步</button>
  70. <button type="button" class="btn btn-success ml-1">完成</button>
  71. <button type="button" class="btn btn-secondary ml-1">重置</button>
  72. </div>
  73. </div>
  74. </form>
  75. </div>
  76. </div>
  77. @stop
  78. @section('lastScript')
  79. <script>
  80. new Vue({
  81. el:"#container",
  82. data:{
  83. base:"three",
  84. owner : {
  85. id:"{{old('id') ?? ($owner->id ?? '') }}",
  86. name : "{{old('name') ?? ($owner->name ?? '')}}",
  87. code : "{{old('code') ?? ($owner->code ?? '')}}",
  88. customer_id : "{{old('customer_id') ?? ($owner->customer_id ?? '')}}",
  89. customer_name : "{{ isset($owner) ? ($owner->customer ? $owner->customer->name : '') : ''}}",
  90. owner_group_name : "{{ isset($owner) ? ($owner->userOwnerGroup ? $owner->userOwnerGroup->name : '') : ''}}",
  91. owner_group_id : "{{old('owner_group_id') ?? ($owner->user_owner_group_id ?? '')}}",
  92. tax_rate : "{{old('tax_rate') ?? ($owner->tax_rate ?? '')}}",
  93. linkman : "{{old('linkman') ?? ($owner->linkman ?? '')}}",
  94. phone_number : "{{old('phone_number') ?? ($owner->phone_number ?? '')}}",
  95. description : "{{old('description') ?? ($owner->description ?? '')}}",
  96. waring_line_on : "{{old('waring_line_on') ?? ($owner->waring_line_on ?? '')}}",
  97. },
  98. ownerTemp : {
  99. id:"{{$owner->id ?? ''}}",
  100. name : "{{$owner->name ?? ''}}",
  101. code : "{{$owner->code ?? ''}}",
  102. customer_id : "{{$owner->customer_id ?? ''}}",
  103. customer_name : "{{ isset($owner) ? ($owner->customer ? $owner->customer->name : '') : ''}}",
  104. owner_group_name : "{{ isset($owner) ? ($owner->userOwnerGroup ? $owner->userOwnerGroup->name : '') : ''}}",
  105. owner_group_id : "{{$owner->user_owner_group_id ?? ''}}",
  106. owner_storage_price_model_id : "{{$owner->owner_storage_price_model_id ?? ''}}".split(','),
  107. tax_rate : "{{$owner->tax_rate ?? ''}}",
  108. linkman : "{{$owner->linkman ?? ''}}",
  109. phone_number : "{{$owner->phone_number ?? ''}}",
  110. description : "{{$owner->description ?? ''}}",
  111. waring_line_on : "{{$owner->waring_line_on ?? ''}}",
  112. },
  113. storagePriceModels : [
  114. @foreach($storagePriceModels as $storagePriceModel)
  115. { id:"{{$storagePriceModel->id}}",
  116. counting_type : "{{$storagePriceModel->counting_type}}",
  117. using_type : "{{$storagePriceModel->using_type}}",
  118. minimum_area : "{{$storagePriceModel->minimum_area}}",
  119. price : "{{$storagePriceModel->price}}",
  120. unit_name : "{{$storagePriceModel->unit ? $storagePriceModel->unit->name : ''}}",
  121. },
  122. @endforeach
  123. ],
  124. customers : [
  125. @foreach($customers as $customer)
  126. {id:"{{$customer->id}}",name:"{{$customer->name}}"},
  127. @endforeach
  128. ],
  129. ownerGroups : [
  130. @foreach($ownerGroups as $ownerGroup)
  131. {id:"{{$ownerGroup->id}}",name:"{{$ownerGroup->name}}"},
  132. @endforeach
  133. ],
  134. style : '',
  135. errors : {!! $errors !!}, //全部的错误提示
  136. display:false,
  137. upList:{ //控制元素的渐入展开与收起
  138. storage : false,
  139. },
  140. type:"storage",//当前编辑类型 仓储,作业,物流...
  141. model:{ //编辑元素绑定值
  142. storage:{
  143. counting_type : "",
  144. using_type : "",
  145. minimum_area : "",
  146. price : "",
  147. discount_type : "无减免",
  148. discount_value : "",
  149. unit_id : "",
  150. },
  151. operation:{
  152. operation_type:"入库",
  153. strategy:"默认",
  154. name:"",
  155. feature:"",
  156. items : [
  157. {strategy:"起步"},
  158. {strategy:"默认"},
  159. {strategy:"特征"},
  160. ],
  161. },
  162. express:{
  163. name:"",
  164. initial_weight:"",
  165. additional_weight:"",
  166. items:[],
  167. },
  168. logistic:{},
  169. },
  170. pool:{//基础数据选择池,以方便异步懒加载而非即时加载 例:units,owners等
  171. counting_type:[
  172. "包仓","灵活用仓","统单价"
  173. ],
  174. using_type:[
  175. "常温","恒温"
  176. ],
  177. discount_type:[
  178. "无减免","按单减免","固定减免"
  179. ],
  180. feature_type:['商品名称','订单类型','承运商','店铺类型'],
  181. logic : ['包含','不包含','等于'],
  182. },
  183. poolMapping:{//基础数据选择池的映射对象 供展示使用
  184. },
  185. selectedModel:{//已选定的计费模型
  186. storage:[],
  187. operation:[],
  188. express:{},
  189. },
  190. thisOperationItemIndex:-1,//当前选中的作业费子项下标,用以唤起特征模态框
  191. operationItems:{},//控制作业费子项的渐入展开
  192. importError:[],//导入时的错误数据原因
  193. isShowError:false,//是否展开导入错误信息
  194. },
  195. mounted(){
  196. $('[data-toggle="tooltip"]').tooltip();
  197. if (this.errors.length===0 && this.owner.id){
  198. this.display = true;
  199. }
  200. },
  201. methods:{
  202. //收起展开
  203. show(id){
  204. if (this.upList[id])$("#"+id).slideDown();
  205. else $("#"+id).slideUp();
  206. this.upList[id] = !this.upList[id];
  207. },
  208. //切换选项
  209. switchBase(base){
  210. if (base === 'three') this._loadStorage();
  211. if (base === this.base)return;
  212. this.base = base;
  213. },
  214. //切换类型
  215. switchType(type){
  216. if (type === this.type)return;//相同终止是为了减少重复加载动作
  217. switch (type) {
  218. case "storage":
  219. this._loadStorage();
  220. break;
  221. case "operation":
  222. this._loadOperation();
  223. break;
  224. case "express":
  225. this._loadExpress();
  226. break;
  227. case "logistic":
  228. this._loadLogistic();
  229. break;
  230. }
  231. this.type = type;
  232. },
  233. //下一步
  234. next(){
  235. switch (this.base) {
  236. case "one":
  237. this._verifyOne();
  238. break;
  239. case "two":
  240. this._verifyTwo();
  241. break;
  242. default:
  243. this._loadStorage();
  244. break;
  245. }
  246. },
  247. //验证基础信息
  248. _verifyOne(){
  249. if (!this.owner.name){
  250. this.errors["name"] = ["项目名称为必填项"];
  251. this.$forceUpdate();
  252. return;
  253. }
  254. if (!this.owner.code){
  255. this.errors["code"] = ["项目代码为必填项"];
  256. this.$forceUpdate();
  257. return;
  258. }
  259. this._requestRequest({name:this.owner.name,code:this.owner.code},"two")
  260. },
  261. //验证详细描述
  262. _verifyTwo(){
  263. if (!this.owner.customer_id){
  264. this.errors["customer_id"] = ["必须选择客户"];
  265. this.$forceUpdate();
  266. }
  267. if (!this.owner.owner_group_id){
  268. this.errors["owner_group_id"] = ["必须选择项目小组"];
  269. this.$forceUpdate();
  270. }
  271. },
  272. //上一步
  273. back(){
  274. switch (this.base) {
  275. case "two":
  276. this.base = 'one';
  277. break;
  278. case "three":
  279. this.base = 'two';
  280. break;
  281. }
  282. },
  283. //请求验证
  284. _requestRequest(params, next){
  285. let url = "{{url('customer/project/verify')}}";
  286. window.tempTip.postBasicRequest(url,params,res=>{
  287. if (res.length > 0){
  288. this.errors = res;
  289. this.$forceUpdate();
  290. }else{
  291. this.base = next;
  292. this.errors = [];
  293. }
  294. });
  295. },
  296. //加载仓储所需基础信息
  297. _loadStorage(){
  298. if (!this.pool.units)this._getUnits();
  299. },
  300. //加载作业
  301. _loadOperation(){
  302. if (!this.pool.units)this._getUnits();
  303. },
  304. //加载快递
  305. _loadExpress(){
  306. if (!this.pool.provinces)this._getProvinces();
  307. },
  308. //加载物流
  309. _loadLogistic(){
  310. if (!this.pool.units) this._getUnits();
  311. },
  312. //获取单位
  313. _getUnits(){
  314. let url = "{{url('maintenance/unit/getUnits')}}";
  315. window.tempTip.postBasicRequest(url,{},res=>{
  316. this.pool.units = res;
  317. let mapping = [];
  318. res.forEach(unit=>{
  319. mapping[unit.id] = unit.name;
  320. });
  321. this.poolMapping.units = mapping;
  322. this.$forceUpdate();
  323. });
  324. },
  325. //获取省份
  326. _getProvinces(){
  327. let url = "{{url('maintenance/province/get')}}";
  328. window.tempTip.postBasicRequest(url,{},res=>{
  329. this.pool.provinces = res;
  330. let mapping = [];
  331. res.forEach(province=>{
  332. mapping[province.id] = province.name;
  333. });
  334. this.poolMapping.provinces = mapping;
  335. this.$forceUpdate();
  336. });
  337. },
  338. //保存模型
  339. saveModel(){
  340. switch (this.type) {
  341. case "storage":
  342. this._verifyStorage();
  343. break;
  344. case "operation":
  345. this._verifyOperation();
  346. break;
  347. case "express":
  348. this._verifyExpress();
  349. break;
  350. }
  351. },
  352. _verifyStorage(){
  353. if (!this.model.storage.counting_type){
  354. this.errors["counting_type"] = ["未选择计费类型"];
  355. this.$forceUpdate();
  356. return;
  357. }
  358. if (!this.model.storage.using_type){
  359. this.errors["using_type"] = ["未选择用仓类型"];
  360. this.$forceUpdate();
  361. return;
  362. }
  363. if (!this.model.storage.price){
  364. this.errors["price"] = ["未输入单价"];
  365. this.$forceUpdate();
  366. return;
  367. }
  368. if (!this.model.storage.discount_type){
  369. this.errors["discount_type"] = ["未选择减免类型"];
  370. this.$forceUpdate();
  371. return;
  372. }
  373. this.selectedModel.storage.unshift(this.model.storage);
  374. this.model.storage = {
  375. counting_type : "",
  376. using_type : "",
  377. minimum_area : "",
  378. price : "",
  379. discount_type : "无减免",
  380. discount_value : "",
  381. unit_id : "",
  382. };
  383. this.errors = [];
  384. },
  385. _verifyOperation() {
  386. if (this.selectedModel.operation.length>0){
  387. this.selectedModel.operation.forEach(operation=>{
  388. if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
  389. this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
  390. this.$forceUpdate();
  391. return;
  392. }
  393. });
  394. }
  395. if (!this.model.operation.name){
  396. this.errors["name"] = ["名称不得为空"];
  397. this.$forceUpdate();
  398. return;
  399. }
  400. if ((this.model.operation.operation_type === '出库' && this._verifyOperationItem(0)) || this._verifyOperationItem(1))return;
  401. if (this.model.operation.items.length>2){
  402. for (let i=2;i<this.model.operation.items.length;i++){
  403. if (this._verifyOperationItem(i))return;
  404. }
  405. }
  406. if (this.model.operation.operation_type === '入库')this.$delete(this.model.operation.items,0);//入库时干掉起步子项
  407. this.selectedModel.operation.push(this.model.operation);
  408. setTimeout(()=>{
  409. this._renderingOperationItem(this.selectedModel.operation.length-1);
  410. },100);
  411. this.model.operation = {
  412. operation_type:"入库",
  413. strategy:"默认",
  414. name:"",
  415. feature:"",
  416. items : [
  417. {strategy:"起步"},
  418. {strategy:"默认"},
  419. {strategy:"特征"},
  420. ],
  421. };
  422. this.errors = [];
  423. },
  424. _verifyOperationItem(itemIndex){//验证作业费子项信息完整
  425. let obj = this.model.operation.items[itemIndex];
  426. let sign = false;
  427. if (!obj.amount){
  428. this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
  429. sign = true;
  430. }
  431. if (!obj.unit_id){
  432. this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
  433. sign = true;
  434. }
  435. if (!obj.unit_price){
  436. this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
  437. }
  438. if (sign)this.$forceUpdate();
  439. return sign;
  440. },
  441. _verifyExpress(){
  442. let error = {};
  443. if (!this.model.express.name)error.name = ["名称不得为空"];
  444. if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
  445. if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
  446. if (this.model.express.items.length>0){
  447. this.model.express.items.forEach((item,index)=>{
  448. if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
  449. if (!item.initial_weight_price)error["item."+index+".initial_weight_price"] = ["不存在"];
  450. if (!item.additional_weight_price)error["item."+index+".additional_weight_price"] = ["不存在"];
  451. });
  452. }
  453. if (JSON.stringify(error) !== "{}"){
  454. this.errors = error;
  455. this.$forceUpdate();
  456. return;
  457. }
  458. this.selectedModel.express = this.model.express;
  459. this.model.express = {
  460. name:"",
  461. initial_weight:"",
  462. additional_weight:"",
  463. items:[],
  464. };
  465. this.errors = [];
  466. this.importError = [];
  467. },
  468. //增加作业费特征子项
  469. addOperationItem(){
  470. this.model.operation.items.push({
  471. strategy:"特征"
  472. });
  473. },
  474. //删除作业费子项
  475. delOperationItem(index){
  476. this.$delete(this.model.operation.items,index);
  477. },
  478. //显示特征选择modal
  479. showAddFeatureModal(index){
  480. if (index === -1){
  481. if (!this.model.operation.feature){
  482. this.model.operation.features = this._createFeature();
  483. this.thisOperationItemIndex = index;
  484. this.$forceUpdate();
  485. $("#addFeatureModal").modal("show");
  486. return;
  487. }
  488. if (this.model.operation.features) {
  489. this.thisOperationItemIndex = index;
  490. $("#addFeatureModal").modal("show");
  491. return;
  492. }
  493. }else{
  494. if (!this.model.operation.items[index].feature){
  495. this.model.operation.items[index].features = this._createFeature();
  496. this.thisOperationItemIndex = index;
  497. $("#addFeatureModal").modal("show");
  498. return;
  499. }
  500. if (this.model.operation.items[index].features) {
  501. this.thisOperationItemIndex = index;
  502. $("#addFeatureModal").modal("show");
  503. return;
  504. }
  505. }
  506. let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
  507. let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
  508. window.tempTip.postBasicRequest(url,{feature:feature},res=>{
  509. if (!res.data.data || res.data.data.length === 0){
  510. res.data.data = this._createFeature();
  511. }
  512. if (index === -1) this.model.operation.features = res.data.data;
  513. else this.model.operation.items[index].features = res.data.data;
  514. this.thisOperationItemIndex = index;
  515. $("#addFeatureModal").modal("show");
  516. });
  517. },
  518. //增加特征
  519. addFeature(){
  520. let obj = {
  521. "strategyGroupStartSign": false,
  522. "calculation" : "",
  523. "type" : "",
  524. "id" : "",
  525. "logic" : "",
  526. "describe" : "",
  527. "strategyGroupEndSign" : false,
  528. };
  529. if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
  530. else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
  531. this.$forceUpdate();
  532. },
  533. _createFeature(){
  534. return [{
  535. "strategyGroupStartSign": false,
  536. "calculation" : "",
  537. "type" : "",
  538. "id" : "",
  539. "logic" : "",
  540. "describe" : "",
  541. "strategyGroupEndSign" : false,
  542. }];
  543. },
  544. //删除特征
  545. delFeature(index) {
  546. if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
  547. else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
  548. this.$forceUpdate();
  549. },
  550. //提交特征更新现有
  551. submitFeature(){
  552. let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
  553. let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
  554. window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
  555. if (this.thisOperationItemIndex === -1){
  556. this.model.operation.feature = res.feature;
  557. this.model.operation.featureFormat = res.featureFormat;
  558. } else {
  559. this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
  560. this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
  561. this.$forceUpdate();
  562. }
  563. $("#addFeatureModal").modal("hide");
  564. return "已更新特征";
  565. },true);
  566. },
  567. //渲染作业费子项
  568. _renderingOperationItem(index){
  569. let domId = "operation-"+index;
  570. let trId = "operation-tr-"+index;
  571. let itemId = "operation-item-"+index;
  572. let html = "<tr class='d-none' id='"+trId+"'><td></td><td colspan='5'>"+
  573. "<div id='"+itemId+"'><table class='table table-sm'>"+
  574. "<th>子策略</th><th>数量</th><th>单位</th><th>单价</th><th>特征</th></th>";
  575. this.selectedModel.operation[index].items.forEach(item=> {
  576. html = this._createOperationItemList(html,item.strategy,item.amount,this.poolMapping.units[item.unit_id],item.unit_price,item.featureFormat ? item.featureFormat : '');
  577. });
  578. html += "</table></div></td></tr>";
  579. $("#"+domId).after(html);
  580. $("#"+itemId).slideUp();
  581. },
  582. _createOperationItemList(html,strategy,amount,unit,unit_price,feature){
  583. 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>";
  584. return html;
  585. },
  586. //移入移出时更改长文本显示效果
  587. textClass(event,isOver){
  588. event = event.target.children[0];
  589. if (isOver) event.className = "text-overflow-warp-100";
  590. else event.className = "cursor-pointer text-overflow-replace-100";
  591. },
  592. //展开子策略
  593. showOperationItem(index){
  594. let trId = "operation-tr-"+index;
  595. let itemId = "operation-item-"+index;
  596. if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
  597. this.operationItems['_'+index] = false;
  598. $("#"+itemId).slideUp(undefined,function () {
  599. $("#"+trId).addClass("d-none");
  600. });
  601. }else {
  602. $("#"+trId).removeClass("d-none");
  603. this.operationItems['_'+index] = true;
  604. $("#"+itemId).slideDown();
  605. }
  606. this.$forceUpdate();
  607. },
  608. //新增快递子项
  609. addExpressItem(){
  610. this.model.express.items.unshift({
  611. province_id : "",
  612. initial_weight_price:"",
  613. additional_weight_price:"",
  614. });
  615. },
  616. //删除快递子项
  617. delExpressItem(index){
  618. this.$delete(this.model.express.items,index);
  619. },
  620. //选择文件
  621. selectFile(id){
  622. this.importError = [];
  623. $("#"+id).click();
  624. },
  625. //导入快递子项
  626. importExpress(e){
  627. let file=e.target.files[0];
  628. if (!file){
  629. tempTip.setDuration(3000);
  630. tempTip.show("未选择文件");
  631. return;
  632. }
  633. let formData = new FormData();
  634. formData.append("file",file);
  635. axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  636. 'Content-Type':'multipart/form-data'
  637. }).then(res=>{
  638. if (res.data.success) {
  639. res.data.data.forEach(data=>{
  640. let unique = this.model.express.items.every(item=>{
  641. if (data.province_id === item.province_id)return false;
  642. return true;
  643. });
  644. if (unique)this.model.express.items.push(data);
  645. });
  646. this.importError = res.data.errors;
  647. tempTip.setDuration(3000);
  648. tempTip.showSuccess("导入成功!");
  649. return;
  650. }
  651. tempTip.setDuration(3000);
  652. tempTip.show(res.data.data);
  653. }).catch(err=> {
  654. tempTip.setDuration(3000);
  655. tempTip.show("网络错误:"+err);
  656. })
  657. },
  658. //物流详情列表modal
  659. showDetailModal() {
  660. $("#logisticModal").modal("show");
  661. },
  662. //新增物流详情
  663. addLogisticDetail(){
  664. this.model.logistic.items.unshift({
  665. "edit" : true,
  666. });
  667. },
  668. //导入物流详情
  669. importLogistic(event){
  670. console.log(event);
  671. },
  672. },
  673. });
  674. </script>
  675. @stop