_createjs.blade.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. @auth
  2. <script>
  3. new Vue({
  4. el: "#demand-div",
  5. data: {
  6. types: [{name:'0',value:'需求'},{name:'1',value:'问题'}],
  7. authorities: [],
  8. addDemand: {
  9. authority_id:null
  10. },
  11. filterAuthority: null,
  12. demandErrors: {},
  13. ratio:{
  14. unClaimCount:null,
  15. ClaimCount:null,
  16. }
  17. },
  18. created() {
  19. this.getAuthority();
  20. this.setUnClaimDemandRatio();
  21. $('#demand-div').removeClass('d-none');
  22. },
  23. mounted() {
  24. },
  25. computed: {
  26. authoritiesFilter:function(){
  27. let authorities = JSON.parse(JSON.stringify(this.authorities));
  28. if (!this.filterAuthority) {
  29. this.$set(this.addDemand,'authority_id',lastAuthority);
  30. return authorities;
  31. }
  32. let self = this;
  33. let authoritiesFilter = authorities.filter(function(item){
  34. return item['name'].includes(self.filterAuthority);
  35. });
  36. if (authoritiesFilter.length >0 && authoritiesFilter.length < authorities.length){
  37. this.addDemand.authority_id =authoritiesFilter[0]['id']
  38. }
  39. this.$forceUpdate()
  40. return authoritiesFilter;
  41. },
  42. },
  43. methods: {
  44. /** 创建 */
  45. showAddDemand() {
  46. this.addDemand = {};
  47. $('#add-demand-auth-filter').val('');
  48. $('#add-demand').modal('show')
  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.filterAuthority = null;
  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. return;
  94. }
  95. this.$set(this.ratio,'unClaimCount',null);
  96. this.$set(this.ratio,'unDoneCount',null);
  97. }).catch(error=>{
  98. });
  99. }
  100. }
  101. });
  102. </script>
  103. @endauth