billConfirmation.blade.php 12 KB

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