| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- @auth
- <script>
- new Vue({
- el: "#demand-div",
- data: {
- types: [{name:0,value:'需求'},{name:1,value:'问题'}],
- addDemand: {},
- authorities: [],
- authoritiesFilter: [],
- demandErrors: {}
- },
- created() {
- this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
- this.getAuthority();
- },
- mounted() {
- },
- methods: {
- /** 筛选 */
- filterAuth($e) {
- let value = $($e.target).val();
- let authorities = JSON.parse(JSON.stringify(this.authorities));
- if (value === null) {
- this.authoritiesFilter = authorities;
- return;
- }
- this.authoritiesFilter = authorities.filter(function (item) {
- return item['name'].includes(value);
- });
- if(this.authoritiesFilter.length > 0)
- this.addDemand.authority_id = this.authoritiesFilter[0]['id'];
- },
- /** 创建 */
- showAddDemand() {
- this.addDemand = {};
- this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
- $('#add-demand-auth-filter').val('');
- $('#add-demand').modal('show')
- if(this.authoritiesFilter.length === 0){
- if(this.authorities.length !==0)this.authoritiesFilter = JSON.parse(JSON.stringify(this.authorities));
- else this.getAuthority();
- }
- },
- /** 创建 */
- createDemand() {
- 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').files[0];
- formData.append('authority_id', this.addDemand['authority_id']);
- formData.append('type', this.addDemand['type']);
- formData.append('description', this.addDemand['description']);
- 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;
- }
- console.log(res.data.data);
- if(res.data.data)this.addDemand = res.data.data;
- 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.authoritiesFilter = res.data.data;
- this.$forceUpdate();
- }
- }).catch(err=>{
- window.tempTip.show(err);
- });
- },
- }
- });
- </script>
- @endauth
|