index.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. @extends('layouts.app')
  2. @section('title')项目列表-项目管理@endsection
  3. @section('content')
  4. @component('customer.project.menu')@endcomponent
  5. <div class="container-fluid d-none" id="container">
  6. <div id="form_div"></div>
  7. <div class="modal fade" tabindex="-1" role="dialog" id="modal">
  8. <div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">
  9. <div class="modal-content">
  10. <div class="modal-body">
  11. <div class="container-fluid" v-if="priceModel[thisClickIndex]">
  12. <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerStoragePriceModels']">
  13. <label class="text-dark font-weight-bold col-3"><span v-if="i==0">仓储:</span></label>
  14. <a target="_blank" @can("计费模型-仓储-录入"):href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=storage'" @endcan class="text-decoration-none">@{{ model.counting_type }}-@{{ model.using_type }}</a>
  15. </div>
  16. <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceOperations'].length>0">
  17. <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceOperations']">
  18. <label class="text-dark font-weight-bold col-3"><span v-if="i==0">作业:</span></label>
  19. <a target="_blank" @can("计费模型-作业-录入"):href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=operation'" @endcan class="text-decoration-none">@{{ model.name }}</a>
  20. </div>
  21. <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceExpresses'].length>0">
  22. <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceExpresses']">
  23. <label class="text-dark font-weight-bold col-3"><span v-if="i==0">快递:</span></label>
  24. <a target="_blank" @can("计费模型-快递-录入"):href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=express'" @endcan class="text-decoration-none">@{{ model.name }}</a>
  25. </div>
  26. <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceLogistics'].length>0">
  27. <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceLogistics']">
  28. <label class="text-dark font-weight-bold col-3"><span v-if="i==0">物流:</span></label>
  29. <a target="_blank" @can("计费模型-物流-录入"):href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=logistic'" @endcan class="text-decoration-none">@{{ model.name }}</a>
  30. </div>
  31. <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceDirectLogistics'].length>0">
  32. <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceDirectLogistics']">
  33. <label class="text-dark font-weight-bold col-3"><span v-if="i==0">直发车:</span></label>
  34. <a target="_blank" @can("计费模型-直发-录入"):href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=directLogistic'" @endcan class="text-decoration-none">@{{ model.name }}</a>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="modal-footer">
  39. <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="mt-1">
  45. <button type="button" class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
  46. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
  47. 导出Excel
  48. </button>
  49. <div class="dropdown-menu">
  50. <a class="dropdown-item" @click="executeExport(false)" href="javascript:">导出勾选内容</a>
  51. <a class="dropdown-item" @click="executeExport(true)" href="javascript:">导出所有页</a>
  52. </div>
  53. </div>
  54. @if(Session::has('successTip'))
  55. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  56. @endif
  57. <div>
  58. <label for="all" id="cloneCheckAll" class="d-none">
  59. <input id="all" type="checkbox" @click="checkAll($event)">全选
  60. </label>
  61. <table class="d-none" id="headerRoll"></table>
  62. <table class="table table-sm text-nowrap table-striped table-hover" id="headerParent">
  63. <tr id="header"></tr>
  64. <tr v-for="(owner,i) in owners" :class="owner.id==id ? 'focusing' : ''" @click="(selectTableRow(owner.id,$event)) && (id=owner.id)">
  65. <td>
  66. <label><input type="checkbox" :value="owner.id" v-model="checkData"></label>
  67. </td>
  68. <td>@{{ i+1 }}</td>
  69. <td>@{{ owner.name }}</td>
  70. <td>@{{ owner.customer_name }}</td>
  71. <td>@{{ owner.user_owner_group_name }}</td>
  72. <td>@{{ owner.user_work_group_name }}</td>
  73. <td><b>@{{owner.relevance ? owner.relevance.length : 0}}</b>/5</td>
  74. <td>@{{ owner.created_at }}</td>
  75. <td>@{{ owner.customer_company_name }}</td>
  76. <td>@{{ ownerSubjection[owner.subjection] }}</td>
  77. <td>@{{ owner.is_activation }}</td>
  78. <td>
  79. <button class="btn btn-sm btn-info text-white" @click="showModal(owner)">各项计价</button>
  80. </td>
  81. <td>
  82. <a :href="'{{url('customer/project')}}/'+owner.id+'/edit'"><button class="btn btn-sm btn0sm btn-outline-info">编辑</button></a>
  83. @can('客户管理-项目-停用')
  84. <button class="btn btn-sm btn-outline-danger" @click="destroy(owner)">停用</button>
  85. @endcan
  86. </td>
  87. </tr>
  88. </table>
  89. {{$owners->appends($params)->links()}}
  90. </div>
  91. </div>
  92. @endsection
  93. @section('lastScript')
  94. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>
  95. <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
  96. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  97. <script>
  98. let vue = new Vue({
  99. el:"#container",
  100. data:{
  101. owners : [
  102. @foreach($owners as $owner)
  103. { id : "{{$owner->id}}",
  104. relevance:@json($owner->relevance),
  105. customer_name:"{{$owner->customer ? $owner->customer->name : ''}}",
  106. name : "{{$owner->name}}",
  107. created_at : "{{$owner->created_at}}",
  108. subjection : "{{$owner->subjection}}",
  109. /*contracts : [
  110. {{--@foreach($owner->contracts as $contract)
  111. { number:"{{$contract->contract_number}}",salesman:"{{$contract->salesman}}" },
  112. @endforeach--}}
  113. ],*/
  114. customer_company_name:"{{$owner->customer ? $owner->customer->company_name : ''}}",
  115. user_owner_group_name:"{{$owner->userOwnerGroup ? $owner->userOwnerGroup->name : ''}}",
  116. user_work_group_name:"{{$owner->userWorkGroup ? $owner->userWorkGroup->name : ''}}",
  117. is_activation : "{{$owner->deleted_at ? '否' : '是'}}",
  118. ownerStoragePriceModels : {!! $owner->ownerStoragePriceModels !!},
  119. },
  120. @endforeach
  121. ],
  122. checkData : [],
  123. sum : Number("{{ $owners->total() }}"),
  124. priceModel : {},
  125. thisClickIndex : "",
  126. models:[
  127. @foreach($models as $model)
  128. {name:"{{$model->id}}",value:"{{$model->name}}"},
  129. @endforeach
  130. ],
  131. customers:[
  132. @foreach($customers as $customer)
  133. {name:"{{$customer->id}}",value:"{{$customer->name}}"},
  134. @endforeach
  135. ],
  136. ownerGroups:[
  137. @foreach($ownerGroups as $ownerGroup)
  138. {name:"{{$ownerGroup->id}}",value:"{{$ownerGroup->name}}"},
  139. @endforeach
  140. ],
  141. ownerSubjection:{!! json_encode(\App\Owner::subjection,JSON_UNESCAPED_UNICODE) !!},
  142. selectTr:'',
  143. id:"",
  144. },
  145. mounted(){
  146. $('#container').removeClass('d-none');
  147. let data=[
  148. [
  149. {name:'user_owner_group_id',type:'select',tip:'项目小组',placeholder: '项目小组',data:this.ownerGroups},
  150. {name:'created_at_start',type:'time',tip:['选择显示创建日期的起始时间','']},
  151. {name:'id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的项目'],
  152. placeholder:['项目','定位或多选项目'],data:this.models},
  153. {name:'contract_number',type:'input',tip: '合同号:可在左侧增加百分号(%)进行模糊搜索',placeholder: '合同号'},
  154. ],[
  155. {name:'customer_id',type:'select_multiple_select',tip:['客户','定位或多选项目'],placeholder: ['客户','定位或多选项目'],data:this.customers},
  156. {name:'created_at_end',type:'time',tip:['选择显示创建日期的结束时间','']},
  157. {name:'using_type',type:'select',placeholder: '用仓类型',data:[{name:"常温",value:"常温"},{name:"恒温",value:"恒温"}]},
  158. ],
  159. ];
  160. this.form = new query({
  161. el:"#form_div",
  162. condition:data,
  163. });
  164. this.form.init();
  165. let column = [
  166. {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
  167. dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
  168. {name:'index',value: '序号', neglect: true},
  169. {name:'name',value: '项目'},
  170. {name:'customer',value: '客户'},
  171. {name:'user_owner_group_name',value: '项目小组'},
  172. {name:'user_work_group_name',value: '仓库小组'},
  173. {name:'relevance', neglect: true,value: '计费模型填写情况'},
  174. {name:'created_at',value: '创建日期'},
  175. {name:'customer_full_name',value: '公司全称'},
  176. {name:'subjection',value: '主体公司'},
  177. {name:'is_activating',value: '是否激活', neglect: true},
  178. {name:'relating_price',value: '关联报价', neglect: true},
  179. {name:'operating',value: '操作', neglect: true},
  180. ];
  181. let _this=this;
  182. setTimeout(function () {
  183. let header = new Header({
  184. el: "#header",
  185. column: column,
  186. data: _this.owners,
  187. restorationColumn: 'id',
  188. fixedTop:($('#form_div').height())+2,
  189. offset:0.5,
  190. vue:vue
  191. });
  192. header.init();
  193. },0);
  194. },
  195. watch:{
  196. checkData:{
  197. handler(){
  198. if (this.checkData.length === this.owners.length){
  199. document.querySelector('#all').checked = true;
  200. document.querySelector('#all_temp').checked = true;
  201. }else {
  202. document.querySelector('#all').checked = false;
  203. document.querySelector('#all_temp').checked = false;
  204. }
  205. },
  206. deep:true
  207. }
  208. },
  209. methods:{
  210. selectTableRow(id,e){
  211. $('#headerParent tr[class=focusing]').removeClass('focusing')
  212. if (id === this.selectTr) {
  213. this.selectTr = '';
  214. return;
  215. }
  216. this.selectTr = id;
  217. $(e.target).parent('tr').addClass('focusing')
  218. },
  219. executeExport(isAll){
  220. let url = '{{url('customer/project/index/export')}}';
  221. let token='{{ csrf_token() }}';
  222. //excelExport 定义在 js/queryForm/export.js
  223. excelExport(isAll,this.checkData,url,this.sum,token);
  224. },
  225. //全选事件
  226. checkAll(e){
  227. if (e.target.checked){
  228. this.checkData = [];
  229. this.owners.forEach((el)=>{
  230. this.checkData.push(el.id);
  231. });
  232. }else {
  233. this.checkData = [];
  234. }
  235. },
  236. showModal(owner){
  237. if (this.priceModel[owner.id]){
  238. this.thisClickIndex = owner.id;
  239. $("#modal").modal('show');
  240. return;
  241. }
  242. window.axios.post('{{url('customer/project/getOwnerPriceModel')}}',{id:owner.id})
  243. .then(res=>{
  244. if (res.data.success){
  245. let model = res.data.data;
  246. model["ownerStoragePriceModels"] = owner.ownerStoragePriceModels;
  247. delete owner.ownerStoragePriceModels;
  248. this.priceModel[owner.id] = model;
  249. this.thisClickIndex = owner.id;
  250. $("#modal").modal('show');
  251. return;
  252. }
  253. window.tempTip.setDuration(3000);
  254. window.tempTip.showSuccess(res.data.data);
  255. }).catch(err=>{
  256. window.tempTip.setDuration(3000);
  257. window.tempTip.show("网络错误:"+err);
  258. });
  259. },
  260. destroy:function(owner){
  261. confirm('确定要停用项目“' + owner.name + '”吗?');
  262. let data=this;
  263. let url = "{{url('maintenance/owner')}}/"+owner.id;
  264. axios.delete(url,{id:owner.id})
  265. .then(function (response) {
  266. if(response.data.success){
  267. for (let i = 0; i < data.owners.length; i++) {
  268. if (data.owners[i].id===owner.id){
  269. data.owners.splice(i,1);
  270. break;
  271. }
  272. }
  273. tempTip.setDuration(1000);
  274. tempTip.showSuccess('停用项目"'+owner.name+'"成功!')
  275. }else{
  276. tempTip.setDuration(1000);
  277. tempTip.show('停用项目"'+owner.name+'"失败!')
  278. }
  279. })
  280. .catch(function (err) {
  281. tempTip.setDuration(3000);
  282. tempTip.show('停用项目失败!'+'网络错误:' + err);
  283. });
  284. },
  285. },
  286. });
  287. </script>
  288. @endsection