_createjs.blade.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. @auth
  2. <script>
  3. new Vue({
  4. el: "#demand-div",
  5. data: {
  6. types: [{name:'0',value:'需求'},{name:'1',value:'问题'}],
  7. addDemand: {},
  8. authorities: [],
  9. authoritiesFilter: [],
  10. demandErrors: {},
  11. ratio:{
  12. unClaimCount:null,
  13. ClaimCount:null,
  14. }
  15. },
  16. created() {
  17. this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
  18. this.getAuthority();
  19. this.setUnClaimDemandRatio();
  20. $('#demand-div').removeClass('d-none');
  21. },
  22. mounted() {
  23. },
  24. methods: {
  25. /** 筛选 */
  26. filterAuth($e) {
  27. let value = $($e.target).val();
  28. let authorities = JSON.parse(JSON.stringify(this.authorities));
  29. if (value === null) {
  30. this.authoritiesFilter = authorities;
  31. return;
  32. }
  33. this.authoritiesFilter = authorities.filter(function (item) {
  34. return item['name'].includes(value);
  35. });
  36. if(this.authoritiesFilter.length > 0)
  37. this.addDemand.authority_id = this.authoritiesFilter[0]['id'];
  38. },
  39. /** 创建 */
  40. showAddDemand() {
  41. this.addDemand = {};
  42. this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
  43. $('#add-demand-auth-filter').val('');
  44. $('#add-demand').modal('show')
  45. if(this.authoritiesFilter.length === 0){
  46. if(this.authorities.length !==0)this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
  47. else this.getAuthority();
  48. }
  49. },
  50. /** 创建 */
  51. createDemand() {
  52. let url = '{{url('apiLocal/demand/store')}}';
  53. window.tempTip.setIndex(1999);
  54. window.tempTip.setDuration(3000);
  55. let formData = new FormData();
  56. let file = document.querySelector('#add-demand-file-create').files[0];
  57. if(this.addDemand['authority_id'])formData.append('authority_id', this.addDemand['authority_id']);
  58. if(this.addDemand['type'])formData.append('type', this.addDemand['type']);
  59. if(this.addDemand['description'])formData.append('description', this.addDemand['description']);
  60. if(file)formData.append('file', file);
  61. window.axios.post(url, formData, {
  62. 'Content-Type': 'multipart/form-data'
  63. }).then(res => {
  64. if (res.data.success) {
  65. window.tempTip.showSuccess('问题提交成功');
  66. $('#add-demand').modal('hide')
  67. return;
  68. }
  69. if(res.data.errors) this.demandErrors = res.data.errors;
  70. else window.tempTip.show('问题提交失败');
  71. }).catch(err => {
  72. window.tempTip.show(err);
  73. });
  74. },
  75. getAuthority(){
  76. let url = '{{url('apiLocal/authority/get')}}';
  77. window.axios.get(url).then(res=>{
  78. if(res.data.success){
  79. this.authorities = res.data.data;
  80. this.authoritiesFilter = res.data.data;
  81. this.$forceUpdate();
  82. }
  83. }).catch(err=>{
  84. window.tempTip.show(err);
  85. });
  86. },
  87. setUnClaimDemandRatio(){
  88. let url = '{{url('apiLocal/demand/unClaimDemandRatio')}}';
  89. window.axios.get(url).then(res=>{
  90. if(res.data.data){
  91. this.$set(this.ratio,'unClaimCount',res.data.data['unClaimCount']);
  92. this.$set(this.ratio,'ClaimCount',res.data.data['ClaimCount']);
  93. console.log(this.ratio);
  94. return;
  95. }
  96. this.$set(this.ratio,'unClaimCount',null);
  97. this.$set(this.ratio,'unDoneCount',null);
  98. }).catch(error=>{
  99. });
  100. }
  101. }
  102. });
  103. </script>
  104. @endauth