billConfirmation.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. @extends('layouts.app')
  2. @section('title')客户管理-账单确认@endsection
  3. @section('content')
  4. @component('customer.finance.menu')@endcomponent
  5. <div class="container-fluid" id="container">
  6. <div id="form_div"></div>
  7. <div class="mt-1">
  8. <button type="button" class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
  9. data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
  10. 导出Excel
  11. </button>
  12. <div class="dropdown-menu">
  13. <a class="dropdown-item" @click="billExport(false)" href="javascript:">导出勾选内容</a>
  14. <a class="dropdown-item" @click="billExport(true)" href="javascript:">导出所有页</a>
  15. </div>
  16. </div>
  17. <div>
  18. <label for="all" id="cloneCheckAll" class="d-none">
  19. <input id="all" type="checkbox" @click="checkAll($event)">全选
  20. </label>
  21. <table class="d-none" id="headerRoll"></table>
  22. <table class="table table-sm text-nowrap table-striped table-hover" id="headerParent">
  23. <tr id="header"></tr>
  24. <tr v-for="(bill,i) in bills">
  25. <td>
  26. <label><input type="checkbox" :value="bill.id" v-model="checkData"></label>
  27. </td>
  28. <td>@{{ i+1 }}</td>
  29. <td>@{{ bill.ownerGroupName }}</td>
  30. <td>@{{ bill.customerName }}</td>
  31. <td>@{{ bill.ownerName }}</td>
  32. <td>@{{ bill.countingMonth }}</td>
  33. <td>@{{ bill.updatedAt }}</td>
  34. <td class="font-weight-bold">@{{ bill.initialFee }}</td>
  35. <td>
  36. <label><input :id="'confirmFee-'+bill.id" @click="thisIndex=i" :readonly="thisIndex==i ? false : true" type="number" min="0" class="form-control form-control-sm" :value="bill.confirmFee"></label>
  37. <div v-if="thisIndex==i">
  38. <button class="btn btn-sm btn-success" @click="updateConfirmFee(bill)">确定</button>
  39. <button class="btn btn-sm btn-danger" @click="thisIndex='-1'">取消</button>
  40. </div>
  41. </td>
  42. <td>@{{ bill.difference }}</td>
  43. <td>
  44. <button class="btn btn-sm btn-outline-success" v-if="bill.confirmed == '否'" @click="billConfirm(bill)">确认</button>
  45. <label v-else class="text-success">已确认</label>
  46. </td>
  47. </tr>
  48. </table>
  49. </div>
  50. </div>
  51. @stop
  52. @section("lastScript")
  53. <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>
  54. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  55. <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
  56. <script>
  57. let vue = new Vue({
  58. el:"#container",
  59. data:{
  60. checkData:[],
  61. bills : [
  62. @foreach($bills as $bill)
  63. { id : "{{$bill->id}}",
  64. ownerGroupName : "{{$bill->owner ? ($bill->owner->userOwnerGroup ? $bill->owner->userOwnerGroup->name : '') : ''}}",
  65. customerName : "{{$bill->owner ? ($bill->owner->customer ? $bill->owner->customer->name : '') : ''}}",
  66. ownerName : "{{$bill->owner ? $bill->owner->name : ''}}",
  67. countingMonth : "{{$bill->counting_month}}",
  68. updatedAt : "{{$bill->updated_at}}",
  69. initialFee : "{{$bill->initial_fee}}",
  70. confirmFee : "{{$bill->confirm_fee}}",
  71. difference : "{{$bill->difference}}",
  72. confirmed : "{{$bill->confirmed}}",
  73. },
  74. @endforeach
  75. ],
  76. owners : [
  77. @foreach($owners as $owner)
  78. {name:"{{$owner->id}}",value:"{{$owner->name}}"},
  79. @endforeach
  80. ],
  81. ownerGroups : [
  82. @foreach($ownerGroups as $ownerGroup)
  83. {name:"{{$ownerGroup->id}}",value:"{{$ownerGroup->name}}"},
  84. @endforeach
  85. ],
  86. customers : [
  87. @foreach($customers as $customer)
  88. {name:"{{$customer->id}}",value:"{{$customer->name}}"},
  89. @endforeach
  90. ],
  91. thisIndex:"-1",
  92. sum : Number("{{ $bills->total() }}"),
  93. },
  94. watch:{
  95. checkData:{
  96. handler(){
  97. if (this.checkData.length === this.bills.length){
  98. document.querySelector('#all').checked = true;
  99. document.querySelector('#all_temp').checked = true;
  100. }else {
  101. document.querySelector('#all').checked = false;
  102. document.querySelector('#all_temp').checked = false;
  103. }
  104. },
  105. deep:true
  106. }
  107. },
  108. mounted(){
  109. let data=[
  110. [
  111. {name:'owner_group_id',type:'select',tip:'项目小组',placeholder: '项目小组',data:this.ownerGroups},
  112. {name:'counting_month_start',type:'dateMonth',tip:'起始结算月'},
  113. {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的项目'],
  114. placeholder:['项目','定位或多选项目'],data:this.owners},
  115. ],[
  116. {name:'customer_id',type:'select',tip:'客户',placeholder: '客户',data:this.customers},
  117. {name:'counting_month_end',type:'dateMonth',tip:'结束结算月'},
  118. ],
  119. ];
  120. this.form = new query({
  121. el:"#form_div",
  122. condition:data,
  123. });
  124. this.form.init();
  125. let column = [
  126. {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
  127. dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
  128. {name:'index',value: '序号', neglect: true},
  129. {name:'workgroup',value: '项目小组'},
  130. {name:'customer',value: '客户'},
  131. {name:'owner',value: '子项目'},
  132. {name:'counting_month',value: '结算月'},
  133. {name:'created_at',value: '录入日期'},
  134. {name:'initial_fee',value: '原始账单金额', neglect: true},
  135. {name:'confirm_fee',value: '确认账单金额', neglect: true},
  136. {name:'difference',value: '差额', neglect: true},
  137. {name:'operating',value: '操作', neglect: true},
  138. ];
  139. let _this=this;
  140. setTimeout(function () {
  141. let header = new Header({
  142. el: "#header",
  143. column: column,
  144. data: _this.reports,
  145. restorationColumn: 'id',
  146. fixedTop:($('#form_div').height())+2,
  147. offset:0.5,
  148. vue:vue
  149. });
  150. header.init();
  151. },0);
  152. },
  153. methods:{
  154. billExport(isAll){
  155. let url = '{{url('customer/finance/billConfirmation/export')}}';
  156. let token='{{ csrf_token() }}';
  157. excelExport(isAll,this.checkData,url,this.sum,token);
  158. },
  159. //全选事件
  160. checkAll(e){
  161. if (e.target.checked){
  162. this.checkData = [];
  163. this.bills.forEach((el)=>{
  164. this.checkData.push(el.id);
  165. });
  166. }else {
  167. this.checkData = [];
  168. }
  169. },
  170. updateConfirmFee(bill){
  171. let confirm_fee = $('#confirmFee-'+bill.id).val();
  172. if (confirm_fee === bill.fee){
  173. window.tempTip.setDuration(2000);
  174. window.tempTip.show("无更新");
  175. return;
  176. }
  177. window.tempTip.confirm("确定要更新账单确认金额为“"+confirm_fee+"”吗?",()=>{
  178. window.axios.post("{{url('customer/finance/updateBillReport')}}",{id:bill.id,confirm_fee:confirm_fee})
  179. .then(res=>{
  180. if (res.data.success){
  181. bill.confirmFee = confirm_fee;
  182. bill.difference = Number(confirm_fee) - Number(bill.initialFee);
  183. bill.updatedAt = res.data.data;
  184. this.thisIndex = '-1';
  185. window.tempTip.setDuration(2000);
  186. window.tempTip.showSuccess("修改成功");
  187. return;
  188. }
  189. window.tempTip.setDuration(3000);
  190. window.tempTip.show(res.data.data);
  191. }).catch(err=>{
  192. window.tempTip.setDuration(3000);
  193. window.tempTip.show("网络错误:"+err);
  194. })
  195. });
  196. },
  197. billConfirm(bill){
  198. window.tempTip.confirm("确定要完结该账单吗?",()=>{
  199. window.axios.post("{{url('customer/finance/billConfirm')}}",{id:bill.id})
  200. .then(res=>{
  201. if (res.data.success){
  202. bill.confirmed = "是";
  203. window.tempTip.setDuration(2000);
  204. window.tempTip.showSuccess("完结成功!");
  205. return;
  206. }
  207. window.tempTip.setDuration(3000);
  208. window.tempTip.show(res.data.data);
  209. }).catch(err=>{
  210. window.tempTip.setDuration(3000);
  211. window.tempTip.show("网络错误:"+err);
  212. })
  213. });
  214. }
  215. },
  216. });
  217. </script>
  218. @stop