create.blade.php 37 KB

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