create.blade.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  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. currentInputting:{
  142. edittingOperation:null,
  143. },
  144. model:{ //编辑元素绑定值
  145. storage:{
  146. counting_type : "",
  147. using_type : "",
  148. minimum_area : "",
  149. price : "",
  150. discount_type : "无减免",
  151. discount_value : "",
  152. unit_id : "",
  153. },
  154. operation:{
  155. operation_type:"入库",
  156. strategy:"默认",
  157. name:"",
  158. feature:"",
  159. items : [
  160. {strategy:"起步"},
  161. {strategy:"默认"},
  162. {strategy:"特征"},
  163. ],
  164. },
  165. express:{
  166. name:"",
  167. initial_weight:"",
  168. additional_weight:"",
  169. items:[],
  170. },
  171. logistic:{
  172. items:[],
  173. other_ranges:[],
  174. ranges:[],
  175. },
  176. },
  177. pool:{//基础数据选择池,以方便异步懒加载而非即时加载 例:units,owners等
  178. counting_type:[
  179. "包仓","灵活用仓","统单价"
  180. ],
  181. using_type:[
  182. "常温","恒温"
  183. ],
  184. discount_type:[
  185. "无减免","按单减免","固定减免"
  186. ],
  187. feature_type:['商品名称','订单类型','承运商','店铺类型'],
  188. logic : ['包含','不包含','等于'],
  189. },
  190. poolMapping:{//基础数据选择池的映射对象 供展示使用
  191. },
  192. selectedModel:{//已选定的计费模型
  193. storage:[],
  194. operation:[],
  195. express:{},
  196. logistic:{},
  197. },
  198. thisOperationItemIndex:-1,//当前选中的作业费子项下标,用以唤起特征模态框
  199. operationItems:{},//控制作业费子项的渐入展开
  200. importError:[],//导入时的错误数据原因
  201. isShowError:false,//是否展开导入错误信息
  202. },
  203. mounted(){
  204. $('[data-toggle="tooltip"]').tooltip();
  205. if (this.errors.length===0 && this.owner.id){
  206. this.display = true;
  207. }
  208. },
  209. methods:{
  210. //收起展开
  211. show(id){
  212. if (this.upList[id])$("#"+id).slideDown();
  213. else $("#"+id).slideUp();
  214. this.upList[id] = !this.upList[id];
  215. },
  216. //切换选项
  217. switchBase(base){
  218. if (base === 'three') this._loadStorage();
  219. if (base === this.base)return;
  220. this.base = base;
  221. },
  222. //切换类型
  223. switchType(type){
  224. if (type === this.type)return;//相同终止是为了减少重复加载动作
  225. let parent = $("#parent");
  226. switch (type) {
  227. case "storage":
  228. this._loadStorage();
  229. parent.prepend($("#storage-card"));
  230. break;
  231. case "operation":
  232. this._loadOperation();
  233. parent.prepend($("#operation-card"));
  234. break;
  235. case "express":
  236. this._loadExpress();
  237. parent.prepend($("#express-card"));
  238. break;
  239. case "logistic":
  240. this._loadLogistic();
  241. parent.prepend($("#logistic-card"));
  242. break;
  243. }
  244. this.type = type;
  245. },
  246. //下一步
  247. next(){
  248. switch (this.base) {
  249. case "one":
  250. this._verifyOne();
  251. break;
  252. case "two":
  253. this._verifyTwo();
  254. break;
  255. default:
  256. this._loadStorage();
  257. break;
  258. }
  259. },
  260. //验证基础信息
  261. _verifyOne(){
  262. if (!this.owner.name){
  263. this.errors["name"] = ["项目名称为必填项"];
  264. this.$forceUpdate();
  265. return;
  266. }
  267. if (!this.owner.code){
  268. this.errors["code"] = ["项目代码为必填项"];
  269. this.$forceUpdate();
  270. return;
  271. }
  272. this._requestRequest({name:this.owner.name,code:this.owner.code},"two")
  273. },
  274. //验证详细描述
  275. _verifyTwo(){
  276. if (!this.owner.customer_id){
  277. this.errors["customer_id"] = ["必须选择客户"];
  278. this.$forceUpdate();
  279. }
  280. if (!this.owner.owner_group_id){
  281. this.errors["owner_group_id"] = ["必须选择项目小组"];
  282. this.$forceUpdate();
  283. }
  284. },
  285. //上一步
  286. back(){
  287. switch (this.base) {
  288. case "two":
  289. this.base = 'one';
  290. break;
  291. case "three":
  292. this.base = 'two';
  293. break;
  294. }
  295. },
  296. //请求验证
  297. _requestRequest(params, next){
  298. let url = "{{url('customer/project/verify')}}";
  299. window.tempTip.postBasicRequest(url,params,res=>{
  300. if (res.length > 0){
  301. this.errors = res;
  302. this.$forceUpdate();
  303. }else{
  304. this.base = next;
  305. this.errors = [];
  306. }
  307. });
  308. },
  309. //加载仓储所需基础信息
  310. _loadStorage(){
  311. if (!this.pool.units)this._getUnits();
  312. },
  313. //加载作业
  314. _loadOperation(){
  315. if (!this.pool.units)this._getUnits();
  316. },
  317. //加载快递
  318. _loadExpress(){
  319. if (!this.pool.provinces)this._getProvinces();
  320. },
  321. //加载物流
  322. _loadLogistic(){
  323. if (!this.pool.units) this._getUnits();
  324. if (!this.pool.provinces)this._getProvinces();
  325. if (!this.pool.cities)this._getCities();
  326. },
  327. //获取单位
  328. _getUnits(){
  329. let url = "{{url('maintenance/unit/getUnits')}}";
  330. window.tempTip.postBasicRequest(url,{},res=>{
  331. this.pool.units = res;
  332. let mapping = [];
  333. res.forEach(unit=>{
  334. mapping[unit.id] = unit.name;
  335. });
  336. this.poolMapping.units = mapping;
  337. this.$forceUpdate();
  338. });
  339. },
  340. //获取省份
  341. _getProvinces(){
  342. let url = "{{url('maintenance/province/get')}}";
  343. window.tempTip.postBasicRequest(url,{},res=>{
  344. this.pool.provinces = res;
  345. let mapping = [];
  346. res.forEach(province=>{
  347. mapping[province.id] = province.name;
  348. });
  349. this.poolMapping.provinces = mapping;
  350. this.$forceUpdate();
  351. });
  352. },
  353. //获取城市
  354. _getCities(){
  355. let url = "{{url('maintenance/city/get')}}";
  356. window.tempTip.postBasicRequest(url,{},res=>{
  357. this.pool.cities = res;
  358. let mapping = [];
  359. res.forEach(city=>{
  360. mapping[city.id] = city.name;
  361. });
  362. this.poolMapping.cities = mapping;
  363. this.$forceUpdate();
  364. });
  365. },
  366. //保存模型
  367. saveModel(){
  368. switch (this.type) {
  369. case "storage":
  370. this._verifyStorage();
  371. break;
  372. case "operation":
  373. this._verifyOperation();
  374. break;
  375. case "express":
  376. this._verifyExpress();
  377. break;
  378. }
  379. },
  380. _verifyStorage(){
  381. if (!this.model.storage.counting_type){
  382. this.errors["counting_type"] = ["未选择计费类型"];
  383. this.$forceUpdate();
  384. return;
  385. }
  386. if (!this.model.storage.using_type){
  387. this.errors["using_type"] = ["未选择用仓类型"];
  388. this.$forceUpdate();
  389. return;
  390. }
  391. if (!this.model.storage.price){
  392. this.errors["price"] = ["未输入单价"];
  393. this.$forceUpdate();
  394. return;
  395. }
  396. if (!this.model.storage.discount_type){
  397. this.errors["discount_type"] = ["未选择减免类型"];
  398. this.$forceUpdate();
  399. return;
  400. }
  401. this.selectedModel.storage.unshift(this.model.storage);
  402. this.model.storage = {
  403. counting_type : "",
  404. using_type : "",
  405. minimum_area : "",
  406. price : "",
  407. discount_type : "无减免",
  408. discount_value : "",
  409. unit_id : "",
  410. };
  411. this.errors = [];
  412. },
  413. _verifyOperation() {
  414. if (this.selectedModel.operation.length>0){
  415. this.selectedModel.operation.forEach(operation=>{
  416. if (operation.operation_type === this.model.operation.operation_type && operation.strategy === this.model.operation.strategy){
  417. this.errors["operation_type"] = ["已存在同类型的"+operation.operation_type+"作业计费模型"];
  418. this.$forceUpdate();
  419. return;
  420. }
  421. });
  422. }
  423. if (!this.model.operation.name){
  424. this.errors["name"] = ["名称不得为空"];
  425. this.$forceUpdate();
  426. return;
  427. }
  428. if ((this.model.operation.operation_type === '出库' && this._verifyOperationItem(0)) || this._verifyOperationItem(1))return;
  429. if (this.model.operation.items.length>2){
  430. for (let i=2;i<this.model.operation.items.length;i++){
  431. if (this._verifyOperationItem(i))return;
  432. }
  433. }
  434. if (this.model.operation.operation_type === '入库')this.$delete(this.model.operation.items,0);//入库时干掉起步子项
  435. this.selectedModel.operation.push(this.model.operation);
  436. setTimeout(()=>{
  437. this._renderingOperationItem(this.selectedModel.operation.length-1);
  438. },100);
  439. this.model.operation = {
  440. operation_type:"入库",
  441. strategy:"默认",
  442. name:"",
  443. feature:"",
  444. items : [
  445. {strategy:"起步"},
  446. {strategy:"默认"},
  447. {strategy:"特征"},
  448. ],
  449. };
  450. this.errors = [];
  451. },
  452. _verifyOperationItem(itemIndex){//验证作业费子项信息完整
  453. let obj = this.model.operation.items[itemIndex];
  454. let sign = false;
  455. if (!obj.amount){
  456. this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
  457. sign = true;
  458. }
  459. if (!obj.unit_id){
  460. this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
  461. sign = true;
  462. }
  463. if (!obj.unit_price){
  464. this.errors['items.'+itemIndex+'.unit_price'] = ["单价不得为空"];
  465. }
  466. if (sign)this.$forceUpdate();
  467. return sign;
  468. },
  469. _verifyExpress(){
  470. let error = {};
  471. if (!this.model.express.name)error.name = ["名称不得为空"];
  472. if (!this.model.express.initial_weight)error.initial_weight = ["首重不得为空"];
  473. if (!this.model.express.additional_weight)error.additional_weight = ["续重不得为空"];
  474. if (this.model.express.items.length>0){
  475. this.model.express.items.forEach((item,index)=>{
  476. if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
  477. if (!item.initial_weight_price)error["item."+index+".initial_weight_price"] = ["不存在"];
  478. if (!item.additional_weight_price)error["item."+index+".additional_weight_price"] = ["不存在"];
  479. });
  480. }
  481. if (JSON.stringify(error) !== "{}"){
  482. this.errors = error;
  483. this.$forceUpdate();
  484. return;
  485. }
  486. this.selectedModel.express = this.model.express;
  487. this.model.express = {
  488. name:"",
  489. initial_weight:"",
  490. additional_weight:"",
  491. items:[],
  492. };
  493. this.errors = [];
  494. this.importError = [];
  495. },
  496. //增加作业费特征子项
  497. addOperationItem(){
  498. this.model.operation.items.push({
  499. strategy:"特征"
  500. });
  501. },
  502. //删除作业费子项
  503. delOperationItem(index){
  504. this.$delete(this.model.operation.items,index);
  505. },
  506. //显示特征选择modal
  507. showAddFeatureModal(index){
  508. if (index === -1){
  509. if (!this.model.operation.feature){
  510. this.model.operation.features = this._createFeature();
  511. this.thisOperationItemIndex = index;
  512. this.$forceUpdate();
  513. $("#addFeatureModal").modal("show");
  514. return;
  515. }
  516. if (this.model.operation.features) {
  517. this.thisOperationItemIndex = index;
  518. $("#addFeatureModal").modal("show");
  519. return;
  520. }
  521. }else{
  522. if (!this.model.operation.items[index].feature){
  523. this.model.operation.items[index].features = this._createFeature();
  524. this.thisOperationItemIndex = index;
  525. $("#addFeatureModal").modal("show");
  526. return;
  527. }
  528. if (this.model.operation.items[index].features) {
  529. this.thisOperationItemIndex = index;
  530. $("#addFeatureModal").modal("show");
  531. return;
  532. }
  533. }
  534. let url = "{{url('maintenance/priceModel/operation/getFeatures')}}";
  535. let feature = index===-1 ? this.model.operation.feature : this.model.operation.items[index].feature;
  536. window.tempTip.postBasicRequest(url,{feature:feature},res=>{
  537. if (!res.data.data || res.data.data.length === 0){
  538. res.data.data = this._createFeature();
  539. }
  540. if (index === -1) this.model.operation.features = res.data.data;
  541. else this.model.operation.items[index].features = res.data.data;
  542. this.thisOperationItemIndex = index;
  543. $("#addFeatureModal").modal("show");
  544. });
  545. },
  546. //增加特征
  547. addFeature(){
  548. let obj = {
  549. "strategyGroupStartSign": false,
  550. "calculation" : "",
  551. "type" : "",
  552. "id" : "",
  553. "logic" : "",
  554. "describe" : "",
  555. "strategyGroupEndSign" : false,
  556. };
  557. if (this.thisOperationItemIndex === -1)this.model.operation.features.push(obj);
  558. else this.model.operation.items[this.thisOperationItemIndex].features.push(obj);
  559. this.$forceUpdate();
  560. },
  561. _createFeature(){
  562. return [{
  563. "strategyGroupStartSign": false,
  564. "calculation" : "",
  565. "type" : "",
  566. "id" : "",
  567. "logic" : "",
  568. "describe" : "",
  569. "strategyGroupEndSign" : false,
  570. }];
  571. },
  572. //删除特征
  573. delFeature(index) {
  574. if (this.thisOperationItemIndex === -1)this.$delete(this.model.operation.features,index);
  575. else this.$delete(this.model.operation.items[this.thisOperationItemIndex].features,index);
  576. this.$forceUpdate();
  577. },
  578. //提交特征更新现有
  579. submitFeature(){
  580. let url = "{{url('maintenance/priceModel/operation/getFeature')}}";
  581. let features = this.thisOperationItemIndex === -1 ? this.model.operation.features : this.model.operation.items[this.thisOperationItemIndex].features;
  582. window.tempTip.postBasicRequest(url,{features:features,isFormat:true},res=>{
  583. if (this.thisOperationItemIndex === -1){
  584. this.model.operation.feature = res.feature;
  585. this.model.operation.featureFormat = res.featureFormat;
  586. } else {
  587. this.model.operation.items[this.thisOperationItemIndex].feature = res.feature;
  588. this.model.operation.items[this.thisOperationItemIndex].featureFormat = res.featureFormat;
  589. this.$forceUpdate();
  590. }
  591. $("#addFeatureModal").modal("hide");
  592. return "已更新特征";
  593. },true);
  594. },
  595. //渲染作业费子项
  596. _renderingOperationItem(index){
  597. let domId = "operation-"+index;
  598. let trId = "operation-tr-"+index;
  599. let itemId = "operation-item-"+index;
  600. let html = "<tr class='d-none' id='"+trId+"'><td></td><td colspan='5'>"+
  601. "<div id='"+itemId+"'><table class='table table-sm'>"+
  602. "<th>子策略</th><th>数量</th><th>单位</th><th>单价</th><th>特征</th></th>";
  603. this.selectedModel.operation[index].items.forEach(item=> {
  604. html = this._createOperationItemList(html,item.strategy,item.amount,this.poolMapping.units[item.unit_id],item.unit_price,item.featureFormat ? item.featureFormat : '');
  605. });
  606. html += "</table></div></td></tr>";
  607. $("#"+domId).after(html);
  608. $("#"+itemId).slideUp();
  609. },
  610. _createOperationItemList(html,strategy,amount,unit,unit_price,feature){
  611. 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>";
  612. return html;
  613. },
  614. //移入移出时更改长文本显示效果
  615. textClass(event,isOver){
  616. event = event.target.children[0];
  617. if (isOver) event.className = "text-overflow-warp-100";
  618. else event.className = "cursor-pointer text-overflow-replace-100";
  619. },
  620. //展开子策略
  621. showOperationItem(index){
  622. let trId = "operation-tr-"+index;
  623. let itemId = "operation-item-"+index;
  624. if (this.operationItems['_'+index] && this.operationItems['_'+index]===true){
  625. this.operationItems['_'+index] = false;
  626. $("#"+itemId).slideUp(undefined,function () {
  627. $("#"+trId).addClass("d-none");
  628. });
  629. }else {
  630. $("#"+trId).removeClass("d-none");
  631. this.operationItems['_'+index] = true;
  632. $("#"+itemId).slideDown();
  633. }
  634. this.$forceUpdate();
  635. },
  636. //新增快递子项
  637. addExpressItem(){
  638. this.model.express.items.unshift({
  639. province_id : "",
  640. initial_weight_price:"",
  641. additional_weight_price:"",
  642. });
  643. },
  644. //删除快递子项
  645. delExpressItem(index){
  646. this.$delete(this.model.express.items,index);
  647. },
  648. //选择文件
  649. selectFile(id){
  650. this.importError = [];
  651. $("#"+id).click();
  652. },
  653. //导入快递子项
  654. importExpress(e){
  655. let file=e.target.files[0];
  656. if (!file){
  657. tempTip.setDuration(3000);
  658. tempTip.show("未选择文件");
  659. return;
  660. }
  661. let formData = new FormData();
  662. formData.append("file",file);
  663. axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  664. 'Content-Type':'multipart/form-data'
  665. }).then(res=>{
  666. if (res.data.success) {
  667. res.data.data.forEach(data=>{
  668. let unique = this.model.express.items.every(item=>{
  669. if (data.province_id === item.province_id)return false;
  670. return true;
  671. });
  672. if (unique)this.model.express.items.push(data);
  673. });
  674. this.importError = res.data.errors;
  675. tempTip.setDuration(3000);
  676. tempTip.showSuccess("导入成功!");
  677. return;
  678. }
  679. tempTip.setDuration(3000);
  680. tempTip.show(res.data.data);
  681. }).catch(err=> {
  682. tempTip.setDuration(3000);
  683. tempTip.show("网络错误:"+err);
  684. })
  685. },
  686. //物流详情列表modal
  687. showDetailModal() {
  688. $("#logisticModal").modal("show");
  689. },
  690. //新增物流详情
  691. addLogisticDetail(){
  692. this.model.logistic.items.unshift({
  693. });
  694. },
  695. //导入物流详情
  696. importLogistic(e){
  697. tempTip.setIndex(1099);
  698. let file=e.target.files[0];
  699. if (!file){
  700. tempTip.setDuration(3000);
  701. tempTip.show("未选择文件");
  702. return;
  703. }
  704. let formData = new FormData();
  705. formData.append("file",file);
  706. axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  707. 'Content-Type':'multipart/form-data'
  708. }).then(res=>{
  709. if (res.data.success) {
  710. res.data.data.forEach(data=>{
  711. //过滤非已选择单位的数据
  712. let id = "";
  713. if (data.unit_id === this.poolMapping.units[this.model.logistic.unit_id]) id = this.model.logistic.unit_id;
  714. if (data.unit_id === this.poolMapping.units[this.model.logistic.other_unit_id]) id = this.model.logistic.other_unit_id;
  715. if (id){
  716. //过滤重复数据
  717. let unique = this.model.logistic.items.every(item=>{
  718. if (id === item.unit_id && data.range === item.range
  719. && data.province_id === item.province_id && data.city_id === item.city_id)return false;
  720. return true;
  721. });
  722. if (unique){
  723. data.unit_id = id;
  724. this.model.logistic.items.push(data);
  725. }
  726. }
  727. });
  728. this.importError = res.data.errors;
  729. tempTip.setDuration(3000);
  730. tempTip.showSuccess("导入成功!");
  731. return;
  732. }
  733. tempTip.setDuration(3000);
  734. tempTip.show(res.data.data);
  735. }).catch(err=> {
  736. tempTip.setDuration(3000);
  737. tempTip.show("网络错误:"+err);
  738. })
  739. },
  740. //删除物流子项
  741. delLogisticItem(index){
  742. this.$delete(this.model.logistic.items,index);
  743. },
  744. //改变物流区间时改变可选择项
  745. changeRange(type){
  746. if (type === 'ranges'){
  747. this.model.logistic.ranges = this.model.logistic.unit_range.split(",");
  748. }else{
  749. this.model.logistic.other_ranges = this.model.logistic.other_unit_range.split(",");
  750. }
  751. }
  752. },
  753. });
  754. </script>
  755. @stop