Commit 1b75b354 authored by Kittisak Maneewong's avatar Kittisak Maneewong

add configemployer

parent bc039636
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Company; use App\Company;
use App\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class CompanyController extends Controller class CompanyController extends Controller
...@@ -12,9 +13,21 @@ class CompanyController extends Controller ...@@ -12,9 +13,21 @@ class CompanyController extends Controller
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function check($id)
{
$exists = Company::where('user_id', $id)->exists();
return response()->json(['exists' => $exists]);
}
public function config($id)
{
$company = User::where('id', $id)->get();
return response()->json(['company' => $company]);
}
public function index() public function index()
{ {
//
} }
/** /**
...@@ -83,7 +96,6 @@ class CompanyController extends Controller ...@@ -83,7 +96,6 @@ class CompanyController extends Controller
*/ */
public function show($id) public function show($id)
{ {
//
} }
/** /**
...@@ -94,7 +106,13 @@ class CompanyController extends Controller ...@@ -94,7 +106,13 @@ class CompanyController extends Controller
*/ */
public function edit($id) public function edit($id)
{ {
// $exists = Company::where('user_id', $id)->exists();
if ($exists) {
$data = Company::where('user_id', $id)->get();
} else {
$data = User::where('id', $id)->get();
}
return response()->json(['check' => $exists, 'data' => $data]);
} }
/** /**
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,6 +3,16 @@ window.Vue = require('vue'); ...@@ -3,6 +3,16 @@ window.Vue = require('vue');
window._ = require('lodash'); window._ = require('lodash');
window.axios = require('axios'); window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
let token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
window.axios.defaults.baseUrl = 'http://localhost:8000/'; window.axios.defaults.baseUrl = 'http://localhost:8000/';
......
...@@ -27,7 +27,7 @@ export default { ...@@ -27,7 +27,7 @@ export default {
Footer, Footer,
Snackbar Snackbar
}, },
created () { beforeMount () {
this.$store.dispatch('checkUser') this.$store.dispatch('checkUser')
} }
} }
......
...@@ -27,7 +27,7 @@ export default { ...@@ -27,7 +27,7 @@ export default {
Footer, Footer,
Snackbar Snackbar
}, },
created () { beforeMount () {
this.$store.dispatch('checkEmployer') this.$store.dispatch('checkEmployer')
} }
} }
......
...@@ -14,8 +14,10 @@ import LoginEmployer from './views/LoginEmployer.vue'; ...@@ -14,8 +14,10 @@ import LoginEmployer from './views/LoginEmployer.vue';
import PageNotFound from './views/PageNotFound.vue'; import PageNotFound from './views/PageNotFound.vue';
import EditCompany from './views/EditCompany.vue'; import EditCompany from './views/EditCompany.vue';
import RegisterEmployer from './views/RegisterEmployer'; import RegisterEmployer from './views/RegisterEmployer';
import ManagejobEmployer from './views/managejob.vue' import ManagejobEmployer from './views/managejob.vue';
import ConfigCompany from './views/ConfigCompany.vue';
import AddJob from './views/AddJob.vue'; import AddJob from './views/AddJob.vue';
import Axios from 'axios';
const router = new VueRouter({ const router = new VueRouter({
mode: 'history', mode: 'history',
...@@ -28,7 +30,11 @@ const router = new VueRouter({ ...@@ -28,7 +30,11 @@ const router = new VueRouter({
{ {
path: '', path: '',
name: 'Employer', name: 'Employer',
component: Employer component: Employer,
meta: {
loginEmployer: true,
configProfile: true
}
}, },
{ {
path: 'login', path: 'login',
...@@ -43,17 +49,34 @@ const router = new VueRouter({ ...@@ -43,17 +49,34 @@ const router = new VueRouter({
{ {
path: 'managejob', path: 'managejob',
name: 'managejobEmployer', name: 'managejobEmployer',
component: ManagejobEmployer component: ManagejobEmployer,
meta: {
loginEmployer: true,
configProfile: true
}
}, },
{ {
path: 'editcompany', path: 'editcompany',
name: 'editcompany', name: 'editcompany',
component: EditCompany component: EditCompany,
meta: {
loginEmployer: true,
configProfile: true
}
}, },
{ {
path: 'addjob', path: 'addjob',
name: 'addjob', name: 'addjob',
component: AddJob component: AddJob,
meta: {
loginEmployer: true,
configProfile: true
}
},
{
path: 'configcompany',
name: 'configcompany',
component: ConfigCompany
}, },
{ {
path: '*', path: '*',
...@@ -98,6 +121,30 @@ router.beforeEach((to, from, next) => { ...@@ -98,6 +121,30 @@ router.beforeEach((to, from, next) => {
} else { } else {
next() next()
} }
} else if (to.matched.some(record => record.meta.loginEmployer)) {
if(!localStorage.getItem('access_token_employer')) {
next('/employer/login')
} else if (to.matched.some(record => record.meta.configProfile)) {
axios.get('/api/auth/current', {
headers: {
Authorization: `Bearer ${localStorage.getItem('access_token_employer')}`
}
})
.then(res => {
axios.get(`/api/companys/${res.data.user.id}/check`)
.then(res => {
if (res.data.exists) {
next()
} else {
next('/employer/configcompany')
}
})
.catch(err => {next()})
})
.catch(err => {next()})
} else {
next()
}
} else { } else {
next() next()
} }
......
...@@ -196,6 +196,7 @@ export default new Vuex.Store({ ...@@ -196,6 +196,7 @@ export default new Vuex.Store({
} }
}, },
checkEmployer ({commit}) { checkEmployer ({commit}) {
return new Promise((resolve, reject) => {
if (!!localStorage.getItem('access_token_employer')) { if (!!localStorage.getItem('access_token_employer')) {
axios.get('/api/auth/current', { axios.get('/api/auth/current', {
headers: { headers: {
...@@ -203,6 +204,7 @@ export default new Vuex.Store({ ...@@ -203,6 +204,7 @@ export default new Vuex.Store({
} }
}) })
.then(res => { .then(res => {
resolve(res.data.user)
commit('setEmployer', { commit('setEmployer', {
id: res.data.user.id, id: res.data.user.id,
username: res.data.user.username, username: res.data.user.username,
...@@ -222,8 +224,10 @@ export default new Vuex.Store({ ...@@ -222,8 +224,10 @@ export default new Vuex.Store({
}) })
.catch(err => { .catch(err => {
console.log(err.response) console.log(err.response)
reject(err.response)
}) })
} }
})
} }
}, },
getters: { getters: {
......
<template>
<div>
<v-layout row wrap class=" pa-0 my-3">
<v-flex xs12 sm12 class="pa-3 font-weight-bold title">
<v-icon color="black">business</v-icon> ข้อมูลบริษัท
<v-divider></v-divider>
</v-flex>
<v-form enctype="multipart/form-data" @submit.prevent="createJob()" ref="create">
<v-flex sm12 xs12>
<v-layout row wrap class="ป pa-3">
<v-flex sm4 xs12 class="px-3">
<v-layout align-center justify-center fill-height>
<input type="file" accept="image/*" class="input-file" ref="inputFile" @change="selectFile">
<v-tooltip right>
<template v-slot:activator="{ on }">
<v-layout column align-center>
<img v-on="on" class="img" @click="$refs.inputFile.click()" :src="company_data.imageCompany" alt="" width="200">
<v-btn color="error" v-if="company_data.imageCompany !== 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png'" @click="company_data.imageCompany = 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png';status = 'ยังไม่ได้เลือกไฟล์'">ลบรูปภาพ</v-btn>
</v-layout>
</template>
<span>{{ status }}</span>
</v-tooltip>
</v-layout>
</v-flex>
<v-flex sm4 xs12 class="px-3">
<label class="font-weight-bold">ชื่อบริษัท <span class="red--text">&nbsp;*</span></label>
<v-text-field
readonly
outline
label="ชื่อบริษัท"
:rules="[rules.required]"
v-model="company_data.company_name"
class="my-ip"
></v-text-field>
<label class="font-weight-bold">ชื่อผู้ติดต่อ <span class="red--text">&nbsp;*</span></label>
<v-text-field
outline
label="ชื่อผู้ติดต่อ"
v-model="company_data.company_owner"
:rules="[rules.required]"
class="my-ip"
></v-text-field>
<label class="font-weight-bold">เบอร์ผู้ติดต่อ <span class="red--text">&nbsp;*</span></label>
<v-text-field
outline
label="เบอร์ผู้ติดต่อ"
v-model="company_data.phone_no"
:rules="[rules.required]"
class="my-ip"
></v-text-field>
</v-flex>
<v-flex sm4 xs12 class="px-3">
<label class="font-weight-bold">อีเมล <span class="red--text">&nbsp;*</span></label>
<v-text-field
readonly
outline
label="อีเมล"
v-model="company_data.email"
:rules="[rules.required, rules.email]"
class="my-ip"
></v-text-field>
<label class="font-weight-bold">Fax <span class="red--text"></span></label>
<v-text-field
outline
label="Fax"
class="my-ip"
v-model="company_data.fax"
></v-text-field>
<label class="font-weight-bold">เว็บไซต์ <span class="red--text"></span></label>
<v-text-field
outline
label="เว็บไซต์"
class="my-ip"
v-model="company_data.website"
></v-text-field>
</v-flex>
</v-layout>
</v-flex>
<v-flex sm12>
<v-flex sm12 xs12 class="pa-3">
<h2 class="font-weight-bold subheading"><span class="red--text">&nbsp;ข้อมูลสำหรับติดต่อ</span></h2>
</v-flex>
<v-layout row wrap class="pa-3">
<v-flex sm6 xs12 class="px-3">
<label class="font-weight-bold">ที่อยู่ <span class="red--text">&nbsp;*</span></label>
<v-textarea
outline
label="ที่อยู่"
:rules="[rules.required]"
v-model="company_data.addr"
class="my-1"
></v-textarea>
<label class="font-weight-bold">จังหวัด <span class="red--text">&nbsp;*</span></label>
<v-select
:items="provinces"
item-text="province"
v-model="province"
label="เลือกจังหวัด"
:rules="[rules.required]"
return-object
@change="showAmphoes()"
></v-select>
<label class="font-weight-bold">เขต/อำเภอ <span class="red--text">&nbsp;*</span></label>
<v-select
:items="amphoes"
item-text="amphoe"
label="เลือกเขต/อำเภอ"
return-object
v-model="amphoe"
no-data-text="กรุณาเลือกจังหวัด"
:disabled="!openAmphoe"
:rules="[rules.required]"
@change="showTumbons()"
></v-select>
<label class="font-weight-bold">เกี่ยวกับบริษัท</label>
<v-textarea
outline
label="เกี่ยวกับบริษัท"
class="my-1"
v-model="company_data.about"
></v-textarea>
</v-flex>
<v-flex sm6 xs12 class="px-3">
<label class="font-weight-bold">แขวง/ตำบล<span class="red--text">&nbsp;*</span></label>
<v-select
:items="tumbons"
item-text="tumbon"
return-object
v-model="tumbon"
no-data-text="กรุณาเลือกอำเภอ"
:rules="[rules.required]"
:disabled="!openTumbon"
label="เลือกแขวง/ตำบล"
@change = "showDetail()"
></v-select>
<label class="font-weight-bold">รหัสไปรษณีย์<span class="red--text">&nbsp;*</span></label>
<v-text-field
:disabled="!openZipCode"
label="รหัสไปรษณีย์"
v-model="company_data.zip_code"
:rules="[rules.required]"
class="my-ip"
></v-text-field>
<label class="font-weight-bold">แผนที่บริษัท</label>
<v-layout row wrap class="pa-2">
<v-flex sm12 xs12>
<label>รูปภาพแผนที่</label>
</v-flex>
<v-flex sm12 xs12>
<input type="file" accept="image/*" class="input-file" ref="inputFileMap" @change="selectFileMap">
<v-btn color="deep-orange darken-4" class="px-2" small outline @click="$refs.inputFileMap.click()"><v-icon>file_copy</v-icon>&nbsp;เลือกไฟล์</v-btn>
{{ nameImage }}
<v-btn v-if="nameImage" flat icon color="error" @click="nameImage = null; company_data.imageMap = null">
<v-icon>close</v-icon>
</v-btn>
</v-flex>
<v-flex sm12 xs12>
<GmapAutocomplete class="form-control form-control-sm my-1" placeholder="ป้อนตำแหน่งใกล้เคียง" @place_changed="setPlace">
</GmapAutocomplete>
</v-flex>
<v-flex sm12 xs12>
<GmapMap v-if="this.place" style="width: 100%; height: 200px;" :zoom="15" :center="{lat: company_data.lat, lng: company_data.lng}">
<GmapMarker
:position="{lat: company_data.lat, lng: company_data.lng}"
:draggable="true"
@dragend="dragMarker"
/>
</GmapMap>
</v-flex>
<v-flex sm12 xs12>
<p class="text-xs-center" v-if="this.place"><v-btn color="error" @click="place = null;company_data.lat = null;company_data.lng = null">
ลบเเผนที่
</v-btn></p>
</v-flex>
</v-layout>
</v-flex>
</v-layout>
<v-layout row wrap class="borderbottom pa-3">
<v-flex sm12>
<h2 class="font-weight-bold subheading"><span class="red--text">&nbsp;การเดินทาง</span></h2>
</v-flex>
<v-flex sm3 xs12 class="px-3">
<label class="font-weight-bold my-2">ใกล้ BTS</label>
<v-select
label="เลือก"
:items="bts"
v-model="company_data.bts"
></v-select>
</v-flex>
<v-flex sm3 xs12 class="px-3">
<label class="font-weight-bold">ใกล้ MRT</label>
<v-select
label="เลือก"
:items="mrt"
v-model="company_data.mrt"
></v-select>
</v-flex>
<v-flex sm3 xs12 class="px-3">
<label class="font-weight-bold">ใกล้ ARL</label>
<v-select
label="เลือก"
:items="arl"
v-model="company_data.arl"
></v-select>
</v-flex>
<v-flex sm3 xs12 class="px-3">
<label class="font-weight-bold">สายรถเมล์</label>
<VTextField
label="สายรถเมล์"
v-model="company_data.bus"
></VTextField>
</v-flex>
<v-flex sm12 class="px-3">
<label class="font-weight-bold">การเดินทางเพิ่มเติม</label>
</v-flex>
<v-flex sm6 xs12 class="px-3">
<v-textarea
outline
label=""
class="my-2"
v-model="company_data.another"
></v-textarea>
</v-flex>
<v-flex sm6 xs12 class="px-3 py-3 detail">
<span class="red--text">หมายเหตุ : </span>
<span >เพื่อความสะดวกในการเดินทางของผู้สมัครงาน กรุณาระบุสถานีรถไฟฟ้าที่ใกล้กับสถานที่ปฏิบัติงาน (ถ้ามี) หรือระบุสายรถเมล์ที่ผ่านสถานที่ประกอบการ และระบุการเดินทางเพิ่มเติม เพื่อให้เข้าใจในการเดินทางมากยิ่งขึ้น</span>
</v-flex>
<v-layout row wrap justify-center class="my-2">
<v-btn color="red" dark="" type="submit" :loading="loading">บันทึกข้อมูล</v-btn>
</v-layout>
</v-layout>
</v-flex>
</v-form>
</v-layout>
</div>
</template>
<script>
export default {
data () {
return {
loading: false,
status: 'ยังไม่ได้เลือกไฟล์',
nameImage: null,
company_data: {
user_id: null,
imageCompany: 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png',
company_name: '',
company_owner: '',
phone_no: '',
email: '',
fax: '',
website: '',
addr: '',
province: '',
amphoe: '',
tumbon: '',
zip_code: '',
about: '',
imageMap: null,
lat: null,
lng: null,
bts: '',
mrt: '',
arl: '',
bus: '',
another: ''
},
rules: {
required: v => !!v || 'จำเป็นต้องกรอก',
email: v => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v) || 'รูปแบบอีเมลล์ไม่ถูกต้อง'
},
timeFrom: null,
timeTo: null,
showTimeFrom: false,
showTimeTo: false,
provinces: [],
amphoes: [],
tumbons: [],
province: '',
amphoe: '',
tumbon: '',
openAmphoe: false,
openTumbon: false,
openZipCode: false,
bts: [
'หมอชิต',
'สะพานควาย',
'อารีย์',
'สนามเป้า',
'อนุสาวรีย์ชัยสมรภูมิ',
'พญาไท',
'ราชเทวี',
'สยาม',
'ชิดลม',
'เพลินจิต',
'นานา',
'อโศก',
'พร้อมพงษ์',
'ทองหล่อ',
'เอกมัย',
'พระโขนง',
'อ่อนนุช',
'บางจาก',
'ปุณณวิถี',
'อุดมสุข',
'บางนา',
'สนามกีฬาแห่งชาติ',
'ราชดำริ',
'ศาลาแดง',
'ช่องนนทรี',
'สุรศักดิ์',
'สะพานตากสิน',
'กรุงธนบุรี',
'วงเวียนใหญ่',
'โพธิ์นิมิตร',
'ตลาดพลู',
'วุฒากาศ',
'บางหว้า',
'แบริ่ง'
],
mrt: [
'หัวลำโพง',
'สามย่าน',
'สีลม',
'ลุมพินี',
'คลองเตย',
'ศูนย์การประชุมแห่งชาติสิริกิติ์',
'สุขุมวิท',
'เพชรบุรี',
'พระราม 9',
'ศูนย์วัฒนธรรมแห่งประเทศไทย',
'ห้วยขวาง',
'สุทธิสาร',
'รัชดาภิเษก',
'ลาดพร้าว',
'พหลโยธิน',
'สวนจตุจักร',
'กำแพงเพชร',
'บางซื่อ',
'เตาปูน',
'บางซ่อน',
'วงศสว่าง',
'แยกติวานนท์',
'กระทรวงสาธารณะสุข',
'ศูนย์ราชการนนทบุรี',
'บางกระสอ',
'แยกนนทบุรี 1',
'สะพานพระนั่งเกล้า',
'ไทรม้า',
'บางรักน้อยท่าอิฐ',
'บางรักใหญ่',
'บางพลู',
'สามแยกบางใหญ่',
'ตลาดบางใหญ่',
'คลองบางไผ่'
],
arl: [
'สุวรรณภูมิ',
'ลาดกระบัง',
'บ้านทับช้าง',
'หัวหมาก',
'รามคำแหง',
'มักกะสัน',
'ราชปรารภ',
'พญาไท'
],
place: null
}
},
methods: {
dragMarker (e) {
this.company_data.lat = e.latLng.lat()
this.company_data.lng = e.latLng.lng()
},
setPlace(place) {
this.place = place
this.company_data.lat = this.place.geometry.location.lat()
this.company_data.lng = this.place.geometry.location.lng()
},
selectFile (e) {
const file = e.target.files
this.status = file[0].name
if (!file.length) {
return
}
const fileReader = new FileReader()
fileReader.readAsDataURL(file[0])
fileReader.onload = e => {
this.company_data.imageCompany = e.target.result
}
},
selectFileMap (e) {
const file = e.target.files
this.nameImage = file[0].name
if (!file.length) {
return
}
const fileReader = new FileReader()
fileReader.readAsDataURL(file[0])
fileReader.onload = e => {
this.company_data.imageMap = e.target.result
}
},
createJob () {
this.loading = true
if (this.amphoes.findIndex(x => x.amphoe_code === this.amphoe.amphoe_code) === -1) {this.amphoe = ''}
if (this.tumbons.findIndex(x => x.tumbon_code === this.tumbon.tumbon_code) === -1) {this.tumbon = ''}
if (this.company_data.zip_code === ' ') {this.company_data.zip_code = ''}
if (this.$refs.create.validate()) {
this.company_data.province = this.province.province
this.company_data.amphoe = this.amphoe.amphoe
this.company_data.tumbon = this.tumbon.tumbon
axios.post('/api/companys', this.company_data)
.then(res => {
this.loading = false
this.$router.push('/employer')
console.log(res)
})
.catch(err => {
console.log(err.response)
this.loading = false
})
} else {
this.$Loading.error()
this.loading = false
}
},
showProvinces () {
axios.get('/api/province')
.then(res => {
res.data.forEach(data => {
this.provinces.push({
province: data.province,
province_code: data.province_code
})
});
})
.catch(err => {
console.log(err.response)
})
},
showAmphoes () {
this.amphoes = []
this.company_data.zip_code = ''
this.openAmphoe = true
this.openTumbon = false
this.openZipCode = false
axios.get(`/api/province/${this.province.province_code}/amphoe`)
.then(res => {
res.data.forEach(data => {
this.amphoes.push({
amphoe: data.amphoe,
amphoe_code: data.amphoe_code
})
})
})
.catch(err => {
console.log(err.response)
})
},
showTumbons () {
this.tumbons = []
this.company_data.zip_code = ' '
this.openTumbon = true
this.openZipCode = false
axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district`)
.then(res => {
res.data.forEach(data => {
this.tumbons.push({
tumbon: data.district,
tumbon_code: data.district_code
})
})
})
.catch(err => {
console.log(err.response)
})
},
showDetail () {
this.openZipCode = true
axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district/${this.tumbon.tumbon_code}`)
.then(res => {
this.company_data.zip_code = res.data[0].zipcode
})
.catch(err => {
console.log(err.resonse)
})
}
},
mounted() {
this.showProvinces()
},
beforeMount() {
this.$store.dispatch('checkEmployer')
.then(res => {
this.company_data.company_name = res.company_name
this.company_data.email = res.email_employers
this.company_data.phone_no = res.tel
this.company_data.user_id = res.id
})
}
}
</script>
<style lang="scss" scoped>
// .my-job{
// height: 70px;
// }
// .my-ip{
// height: 65px;
// }
.detail {
color: #276f86;
background-color: #f8ffff;
border:1px solid #a9d5de;
border-radius: 5px;
display: inline-block;
line-height: 26px;
}
.borderbottom{
border-bottom: 1px dotted #dcdcdc ;
}
.border-div{
border:1px solid #dcdcdc;
border-radius: 5px;
}
input {
overflow: visible;
}
.bd-example>.form-control+.form-control {
margin-top: .5rem;
}
.form-control-plaintext.form-control-sm, .form-control-plaintext.form-control-lg {
padding-right: 0;
padding-left: 0;
}
.form-control-sm {
height: calc(1.0em + 0.5rem + 1px);
padding: 0.15rem 0.5rem;
font-size: 0.7rem;
line-height: 1.5;
border-radius: 0.3rem;
}
.form-control {
display: block;
width: 100%;
height: calc(1.5em + 0.75rem + 2px);
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
.form-control {
transition: none;
}
}
.form-control::-ms-expand {
background-color: transparent;
border: 0;
}
.form-control:focus {
color: #495057;
background-color: #fff;
border-color: #80bdff;
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
.form-control::-webkit-input-placeholder {
color: #6c757d;
opacity: 1;
}
.form-control::-moz-placeholder {
color: #6c757d;
opacity: 1;
}
.form-control:-ms-input-placeholder {
color: #6c757d;
opacity: 1;
}
.form-control::-ms-input-placeholder {
color: #6c757d;
opacity: 1;
}
.form-control::placeholder {
color: #6c757d;
opacity: 1;
}
.form-control:disabled, .form-control[readonly] {
background-color: #e9ecef;
opacity: 1;
}
select.form-control:focus::-ms-value {
color: #495057;
background-color: #fff;
}
.form-control-file,
.form-control-range {
display: block;
width: 100%;
}
.img {
cursor: pointer;
border: 1px solid;
}
.input-file {
display: none;
}
</style>
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
<v-flex sm4 xs12 class="px-3"> <v-flex sm4 xs12 class="px-3">
<label class="font-weight-bold">ชื่อบริษัท <span class="red--text">&nbsp;*</span></label> <label class="font-weight-bold">ชื่อบริษัท <span class="red--text">&nbsp;*</span></label>
<v-text-field <v-text-field
readonly
outline outline
label="ชื่อบริษัท" label="ชื่อบริษัท"
:rules="[rules.required]" :rules="[rules.required]"
...@@ -51,6 +52,7 @@ ...@@ -51,6 +52,7 @@
<v-flex sm4 xs12 class="px-3"> <v-flex sm4 xs12 class="px-3">
<label class="font-weight-bold">อีเมล <span class="red--text">&nbsp;*</span></label> <label class="font-weight-bold">อีเมล <span class="red--text">&nbsp;*</span></label>
<v-text-field <v-text-field
readonly
outline outline
label="อีเมล" label="อีเมล"
v-model="company_data.email" v-model="company_data.email"
...@@ -227,7 +229,7 @@ ...@@ -227,7 +229,7 @@
<span >เพื่อความสะดวกในการเดินทางของผู้สมัครงาน กรุณาระบุสถานีรถไฟฟ้าที่ใกล้กับสถานที่ปฏิบัติงาน (ถ้ามี) หรือระบุสายรถเมล์ที่ผ่านสถานที่ประกอบการ และระบุการเดินทางเพิ่มเติม เพื่อให้เข้าใจในการเดินทางมากยิ่งขึ้น</span> <span >เพื่อความสะดวกในการเดินทางของผู้สมัครงาน กรุณาระบุสถานีรถไฟฟ้าที่ใกล้กับสถานที่ปฏิบัติงาน (ถ้ามี) หรือระบุสายรถเมล์ที่ผ่านสถานที่ประกอบการ และระบุการเดินทางเพิ่มเติม เพื่อให้เข้าใจในการเดินทางมากยิ่งขึ้น</span>
</v-flex> </v-flex>
<v-layout row wrap justify-center class="my-2"> <v-layout row wrap justify-center class="my-2">
<v-btn color="red" dark="" type="submit">บันทึกข้อมูล</v-btn> <v-btn color="red" dark="" type="submit" :loading="loading">บันทึกข้อมูล</v-btn>
</v-layout> </v-layout>
</v-layout> </v-layout>
</v-flex> </v-flex>
...@@ -240,6 +242,7 @@ ...@@ -240,6 +242,7 @@
export default { export default {
data () { data () {
return { return {
loading: false,
status: 'ยังไม่ได้เลือกไฟล์', status: 'ยังไม่ได้เลือกไฟล์',
nameImage: null, nameImage: null,
company_data: { company_data: {
...@@ -264,7 +267,8 @@ export default { ...@@ -264,7 +267,8 @@ export default {
mrt: '', mrt: '',
arl: '', arl: '',
bus: '', bus: '',
another: '' another: '',
check: false
}, },
rules: { rules: {
required: v => !!v || 'จำเป็นต้องกรอก', required: v => !!v || 'จำเป็นต้องกรอก',
...@@ -403,22 +407,25 @@ export default { ...@@ -403,22 +407,25 @@ export default {
} }
}, },
createJob () { createJob () {
this.loading = true
if (this.amphoes.findIndex(x => x.amphoe_code === this.amphoe.amphoe_code) === -1) {this.amphoe = ''} if (this.amphoes.findIndex(x => x.amphoe_code === this.amphoe.amphoe_code) === -1) {this.amphoe = ''}
if (this.tumbons.findIndex(x => x.tumbon_code === this.tumbon.tumbon_code) === -1) {this.tumbon = ''} if (this.tumbons.findIndex(x => x.tumbon_code === this.tumbon.tumbon_code) === -1) {this.tumbon = ''}
if (this.company_data.zip_code === ' ') {this.company_data.zip_code = ''} if (this.company_data.zip_code === ' ') {this.company_data.zip_code = ''}
if (this.$refs.create.validate()) { if (this.$refs.create.validate()) {
this.company_data.user_id = this.$store.getters.getEmployer.id
this.company_data.province = this.province.province this.company_data.province = this.province.province
this.company_data.amphoe = this.amphoe.amphoe this.company_data.amphoe = this.amphoe.amphoe
this.company_data.tumbon = this.tumbon.tumbon this.company_data.tumbon = this.tumbon.tumbon
axios.post('/companys', this.company_data) axios.post('/api/companys', this.company_data)
.then(res => { .then(res => {
console.log(res) this.loading = false
this.$router.push('/employer')
}) })
.catch(err => { .catch(err => {
console.log(err.response) console.log(err.response)
this.loading = false
}) })
} else { } else {
this.loading = false
this.$Loading.error() this.$Loading.error()
} }
}, },
...@@ -484,8 +491,51 @@ export default { ...@@ -484,8 +491,51 @@ export default {
}) })
} }
}, },
mounted() { beforeMount() {
this.showProvinces() this.showProvinces()
this.$store.dispatch('checkEmployer')
.then(res => {
axios.get(`/api/companys/${res.id}/edit`)
.then(res => {
if(res.data.check) {
console.log(res.data)
this.company_data = {
user_id: res.data.data[0].user_id,
imageCompany: res.data.data[0].imageCompany,
company_name: res.data.data[0].company_name,
company_owner: res.data.data[0].company_owner,
phone_no: res.data.data[0].phone_no,
email: res.data.data[0].email,
fax: res.data.data[0].fax,
website: res.data.data[0].website,
addr: res.data.data[0].addr,
province: res.data.data[0].province,
amphoe: res.data.data[0].amphoe,
tumbon: res.data.data[0].tambon,
zip_code: res.data.data[0].zipcode,
about: res.data.data[0].about,
imageMap: res.data.data[0].imageMap,
lat: res.data.data[0].lat,
lng: res.data.data[0].lng,
bts: res.data.data[0].bts,
mrt: res.data.data[0].mrt,
arl: res.data.data[0].arl,
bus: res.data.data[0].bus,
another: res.data.data[0].another,
check: true
}
} else {
this.company_data.user_id = res.data.data[0].id
this.company_data.company_name = res.data.data[0].company_name
this.company_data.email = res.data.data[0].email_employers
this.company_data.phone_no = res.data.data[0].tel
this.company_data.check = false
}
})
.catch(err => {
console.log(err.response)
})
})
} }
} }
</script> </script>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> --> <!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<meta name="csrf-token" content="{{ csrf_token() }}">
<!-- <meta name="csrf-token" content="{{ csrf_token() }}"> --> <!-- <meta name="csrf-token" content="{{ csrf_token() }}"> -->
<title>CO-OP Search</title> <title>CO-OP Search</title>
......
...@@ -19,6 +19,10 @@ Route::group(['prefix' => 'auth'], function ($router) { ...@@ -19,6 +19,10 @@ Route::group(['prefix' => 'auth'], function ($router) {
Route::get('current', 'AuthController@getAuthenticatedUser'); Route::get('current', 'AuthController@getAuthenticatedUser');
}); });
Route::resource('/companys', 'CompanyController');
Route::get('/companys/{company}/check', 'CompanyController@check')->name('companys.check');
Route::get('/companys/{company}/config', 'CompanyController@config')->name('companys.config');
Route::get('/province','DistrictController@provinces'); Route::get('/province','DistrictController@provinces');
Route::get('/province/{province_code}/amphoe','DistrictController@amphoes'); Route::get('/province/{province_code}/amphoe','DistrictController@amphoes');
Route::get('/province/{province_code}/amphoe/{amphoe_code}/district','DistrictController@districts'); Route::get('/province/{province_code}/amphoe/{amphoe_code}/district','DistrictController@districts');
......
...@@ -12,5 +12,3 @@ ...@@ -12,5 +12,3 @@
*/ */
Route::get('/{any}', 'AppController@index')->where('any', '.*'); Route::get('/{any}', 'AppController@index')->where('any', '.*');
Route::resource('/companys', 'CompanyController');
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment