123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- const requestFunc = async(url, method = "GET", data = null, token = null) => {
- apihost = 'http://schedule.tomtit.tomsk.ru/api'
- method = method.toLocaleUpperCase()
- let fullurl = `${apihost}${url}`;
- let options = {
- method: method,
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${token}`,
- },
- };
- switch(method) {
- case "PUT":
- delete options.headers["Content-Type"];
- options.body = data;
- break;
- case "POST": case "PATCH": case "DELETE":
- options.body = JSON.stringify(data);
- break;
- }
- const res = await fetch(fullurl, options);
- return await res.json();
- };
- <<<<<<< HEAD
- <<<<<<< HEAD
- var app = new Vue({
- =======
- var vueApp = new Vue({
- >>>>>>> master
- =======
- var app = new Vue({
- >>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
- el: '#app',
- delimiters: ['${', '}'],
- data: {
- specialties:[],
- <<<<<<< HEAD
- <<<<<<< HEAD
- },
- methods: {
- showSpecialties() {
- console.log(this.specialty)
- },
- async getSpecialties(){
- this.specialties = await requestFunc("/specialty", "GET")
- },
-
- =======
- selectedRow: {
- "Code": "",
- "Name": "",
- "IDDuration": 0,
- "ID": ""
- },
- requestType: null
- =======
- >>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
- },
- methods: {
- showSpecialties() {
- console.log(this.specialty)
- },
- async getSpecialties(){
- this.specialties = await requestFunc("/specialty", "GET")
- },
- <<<<<<< HEAD
- selectRow(row, index){
- let rows = document.querySelectorAll('.clickHover')
- this.selectedRow = row;
- // empty string
- if(rows[index].style.backgroundColor != 'red'){
- rows[index].style.backgroundColor = 'red'
- }
- else{
- rows[index].style.backgroundColor = 'white'
- this.clearSelectedRow()
- }
- },
- clearSelectedRow(){
- this.selectedRow = {
- "Code": "",
- "Name": "",
- "IDDuration": 0
- }
- },
- changeRequestType(requestType){
- this.requestType = requestType
- },
- modalClick(add, requestType) {
- if(add==='yes') {
- this.clearSelectedRow();
- }
- this.changeRequestType(requestType);
- }
- >>>>>>> master
- =======
-
- >>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
- },
- mounted() {
- this.getSpecialties()
- }
- <<<<<<< HEAD
- <<<<<<< HEAD
- });
- =======
- });
- addSpecialty = (requestType)=>{
- let code = document.querySelector('.code').value
- let name = document.querySelector('.name').value
- let duration = document.querySelectorAll('.duration-radio');
- let radioValue
- for(let i=0; i<duration.length; i++ ){
- if (duration[i].checked) {
- radioValue = duration[i].value
- }
- }
- var myHeaders = new Headers();
- myHeaders.append("Content-Type", "application/json");
- var raw = {"Code":code,"Name":name,"IDDuration":Number(radioValue)};
- if (vueApp.requestType=== 'PATCH') {
- let ID = document.querySelector('.ID').value
- console.log(ID)
- raw.ID= Number(ID)
-
- }
- requestFunc(url="/specialty/", method=vueApp.requestType, data=raw)
- alert("Добавлено")
- }
- >>>>>>> master
- =======
- });
- >>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
|