create.blade.php 36 KB

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