| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- @auth
- <script>
- new Vue({
- el: "#demand-div",
- data: {
- types: [{name:'0',value:'需求'},{name:'1',value:'问题'}],
- authorities: [],
- addDemand: {
- authority_id:null
- },
- filterAuthority: null,
- demandErrors: {},
- ratio:{
- unClaimCount:null,
- ClaimCount:null,
- }
- },
- created() {
- this.getAuthority();
- this.setUnClaimDemandRatio();
- $('#demand-div').removeClass('d-none');
- },
- mounted() {
- },
- computed: {
- authoritiesFilter:function(){
- let authorities = JSON.parse(JSON.stringify(this.authorities));
- if (!this.filterAuthority) {
- this.$set(this.addDemand,'authority_id',lastAuthority);
- return authorities;
- }
- let self = this;
- let authoritiesFilter = authorities.filter(function(item){
- return item['name'].includes(self.filterAuthority);
- });
- if (authoritiesFilter.length >0 && authoritiesFilter.length < authorities.length){
- this.addDemand.authority_id =authoritiesFilter[0]['id']
- }
- this.$forceUpdate()
- return authoritiesFilter;
- },
- },
- methods: {
- /** 创建 */
- showAddDemand() {
- this.addDemand = {};
- $('#add-demand-auth-filter').val('');
- $('#add-demand').modal('show')
- },
- /** 创建 */
- createDemand() {
- this.addDemand['route']=window.location.href;
- this.addDemand['title']=document.title.replace('BsWAS','');
- let url = '{{url('apiLocal/demand/store')}}';
- window.tempTip.setIndex(1999);
- window.tempTip.setDuration(3000);
- let formData = new FormData();
- let file = document.querySelector('#add-demand-file-create').files[0];
- if(this.addDemand['authority_id'])formData.append('authority_id', this.addDemand['authority_id']);
- if(this.addDemand['type'])formData.append('type', this.addDemand['type']);
- if(this.addDemand['route'])formData.append('route', this.addDemand['route']);
- if(this.addDemand['title'])formData.append('title', this.addDemand['title']);
- if(this.addDemand['description'])formData.append('description', this.addDemand['description']);
- if(file)formData.append('file', file);
- window.axios.post(url, formData, {
- 'Content-Type': 'multipart/form-data'
- }).then(res => {
- if (res.data.success) {
- window.tempTip.showSuccess('问题提交成功');
- $('#add-demand').modal('hide')
- return;
- }
- if(res.data.errors) this.demandErrors = res.data.errors;
- else window.tempTip.show('问题提交失败');
- }).catch(err => {
- window.tempTip.show(err);
- });
- },
- getAuthority(){
- let url = '{{url('apiLocal/authority/get')}}';
- window.axios.get(url).then(res=>{
- if(res.data.success){
- this.authorities = res.data.data;
- this.filterAuthority = null;
- this.$forceUpdate();
- }
- }).catch(err=>{
- window.tempTip.show(err);
- });
- },
- setUnClaimDemandRatio(){
- let url = '{{url('apiLocal/demand/unClaimDemandRatio')}}';
- window.axios.get(url).then(res=>{
- if(res.data.data){
- this.$set(this.ratio,'unClaimCount',res.data.data['unClaimCount']);
- this.$set(this.ratio,'ClaimCount',res.data.data['ClaimCount']);
- return;
- }
- this.$set(this.ratio,'unClaimCount',null);
- this.$set(this.ratio,'unDoneCount',null);
- }).catch(error=>{
- });
- }
- }
- });
- </script>
- @endauth
|