_createjs.blade.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. this.addDemand['route']=window.location.href;
  53. this.addDemand['title']=document.title.replace('BsWAS','');
  54. let url = '{{url('apiLocal/demand/store')}}';
  55. window.tempTip.setIndex(1999);
  56. window.tempTip.setDuration(3000);
  57. let formData = new FormData();
  58. let file = document.querySelector('#add-demand-file-create').files[0];
  59. if(this.addDemand['authority_id'])formData.append('authority_id', this.addDemand['authority_id']);
  60. if(this.addDemand['type'])formData.append('type', this.addDemand['type']);
  61. if(this.addDemand['route'])formData.append('route', this.addDemand['route']);
  62. if(this.addDemand['title'])formData.append('title', this.addDemand['title']);
  63. if(this.addDemand['description'])formData.append('description', this.addDemand['description']);
  64. if(file)formData.append('file', file);
  65. window.axios.post(url, formData, {
  66. 'Content-Type': 'multipart/form-data'
  67. }).then(res => {
  68. if (res.data.success) {
  69. window.tempTip.showSuccess('问题提交成功');
  70. $('#add-demand').modal('hide')
  71. return;
  72. }
  73. if(res.data.errors) this.demandErrors = res.data.errors;
  74. else window.tempTip.show('问题提交失败');
  75. }).catch(err => {
  76. window.tempTip.show(err);
  77. });
  78. },
  79. getAuthority(){
  80. let url = '{{url('apiLocal/authority/get')}}';
  81. window.axios.get(url).then(res=>{
  82. if(res.data.success){
  83. this.authorities = res.data.data;
  84. this.filterAuthority = null;
  85. this.$forceUpdate();
  86. }
  87. }).catch(err=>{
  88. window.tempTip.show(err);
  89. });
  90. },
  91. setUnClaimDemandRatio(){
  92. let url = '{{url('apiLocal/demand/unClaimDemandRatio')}}';
  93. window.axios.get(url).then(res=>{
  94. if(res.data.data){
  95. this.$set(this.ratio,'unClaimCount',res.data.data['unClaimCount']);
  96. this.$set(this.ratio,'ClaimCount',res.data.data['ClaimCount']);
  97. return;
  98. }
  99. this.$set(this.ratio,'unClaimCount',null);
  100. this.$set(this.ratio,'unDoneCount',null);
  101. }).catch(error=>{
  102. });
  103. }
  104. }
  105. });
  106. </script>
  107. @endauth