create.blade.php 39 KB

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