|
|
@@ -1,28 +1,28 @@
|
|
|
<template>
|
|
|
- <div class="container">
|
|
|
- <div class="content">
|
|
|
- <el-form
|
|
|
- :model="form"
|
|
|
- :rules="rules"
|
|
|
- ref="form"
|
|
|
- label-position="left"
|
|
|
- label-width="200px"
|
|
|
- >
|
|
|
+ <div class="container" v-loading="loading">
|
|
|
+ <el-form
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ ref="form"
|
|
|
+ label-position="right"
|
|
|
+ label-width="180px">
|
|
|
+ <div class="content">
|
|
|
+ <div class="section-title">Fleet Company</div>
|
|
|
<el-form-item
|
|
|
prop="fleetCompanyName"
|
|
|
- label="Fleet Company Name:"
|
|
|
- >
|
|
|
+ label="Fleet Company Name:">
|
|
|
<el-input
|
|
|
v-model="form.fleetCompanyName"
|
|
|
+ class="add-text"
|
|
|
placeholder=""
|
|
|
- ></el-input>
|
|
|
+ maxlength="100"/>
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
prop="fleetCompanyType"
|
|
|
- label="Fleet Type:"
|
|
|
- >
|
|
|
+ label="Fleet Type:">
|
|
|
<el-select
|
|
|
v-model="form.fleetCompanyType"
|
|
|
+ class="add-text"
|
|
|
placeholder="">
|
|
|
<el-option
|
|
|
v-for="item in options.fleetCompanyType"
|
|
|
@@ -34,76 +34,113 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
prop="contactPerson"
|
|
|
- label="Contact Person:"
|
|
|
- >
|
|
|
+ label="Contact Person:">
|
|
|
<el-input
|
|
|
v-model="form.contactPerson"
|
|
|
+ class="add-text"
|
|
|
placeholder=""
|
|
|
- ></el-input>
|
|
|
+ maxlength="80"/>
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
prop="contactNumber"
|
|
|
- label="Contact Number:"
|
|
|
- >
|
|
|
+ label="Contact Number:">
|
|
|
<el-input
|
|
|
v-model="form.contactNumber"
|
|
|
+ class="add-text"
|
|
|
placeholder=""
|
|
|
- ></el-input>
|
|
|
+ maxlength="20"/>
|
|
|
</el-form-item>
|
|
|
- </el-form>
|
|
|
- <el-divider></el-divider>
|
|
|
- <div class="buttons">
|
|
|
- <el-button
|
|
|
- @click="onClickCancelButton"
|
|
|
- type="primary"
|
|
|
- class="cancel-button"
|
|
|
- >
|
|
|
- Cancel
|
|
|
- </el-button>
|
|
|
- <el-button
|
|
|
- @click="onClickConfirmButton"
|
|
|
- type="primary"
|
|
|
- :loading="confirmButtonLoading"
|
|
|
- >
|
|
|
- Save
|
|
|
- </el-button>
|
|
|
+ <el-form-item
|
|
|
+ label="Login ID:">
|
|
|
+ <el-input
|
|
|
+ v-model="form.loginId"
|
|
|
+ class="add-text"
|
|
|
+ placeholder=""
|
|
|
+ maxlength="50"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="Password Set:">
|
|
|
+ <el-input
|
|
|
+ v-model="form.password"
|
|
|
+ class="add-text"
|
|
|
+ type="password"
|
|
|
+ maxlength="20"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="Country:">
|
|
|
+ <el-select
|
|
|
+ v-model="form.countryCode"
|
|
|
+ class="add-text"
|
|
|
+ placeholder="">
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.countryOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <div class="content flexcr">
|
|
|
+ <div class="buttons">
|
|
|
+ <el-button
|
|
|
+ @click="onClickCancelButton"
|
|
|
+ type="primary"
|
|
|
+ class="cancel-button">
|
|
|
+ Cancel
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ @click="onClickConfirmButton"
|
|
|
+ type="primary">
|
|
|
+ Save
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="update-by"
|
|
|
+ v-if="isEdit">
|
|
|
+ <span
|
|
|
+ class="add-text"
|
|
|
+ :title='"CREATED BY " + form.createdBy + " ON " + form.createdOn'>
|
|
|
+ LAST UPDATED BY {{form.updatedBy}} TIMESTAMP: {{form.updatedOn}}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {
|
|
|
- addFleetCompany,
|
|
|
- fetchFleetCompanyDetail,
|
|
|
- fetchFleetCompanyType,
|
|
|
- updateFleetCompany
|
|
|
-} from '@/http/api/fleetCompany'
|
|
|
-
|
|
|
+import site from '@/http/api/site'
|
|
|
+import api from '@/http/api/fleetCompany'
|
|
|
+import setting from '../../settings.js'
|
|
|
export default {
|
|
|
name: "FleetCompanyDetail",
|
|
|
data() {
|
|
|
return {
|
|
|
+ loading: false,
|
|
|
form: {
|
|
|
fleetCompanyId: "",
|
|
|
fleetCompanyName: "",
|
|
|
fleetCompanyType: "",
|
|
|
contactPerson: "",
|
|
|
contactNumber: "",
|
|
|
+ loginId: "",
|
|
|
+ password: "",
|
|
|
+ countryCode: setting.defaultCountry
|
|
|
},
|
|
|
options: {
|
|
|
- fleetCompanyType: [],
|
|
|
+ countryOptions: [],
|
|
|
+ fleetCompanyType: []
|
|
|
},
|
|
|
- confirmButtonLoading: false,
|
|
|
-
|
|
|
+ isEdit: false,
|
|
|
rules: {
|
|
|
fleetCompanyType: [{
|
|
|
- message: "required",
|
|
|
+ message: "Please select company type",
|
|
|
trigger: "blur",
|
|
|
required: true,
|
|
|
}],
|
|
|
fleetCompanyName: [{
|
|
|
- message: "required",
|
|
|
+ message: "Please input company name",
|
|
|
trigger: "blur",
|
|
|
required: true,
|
|
|
}],
|
|
|
@@ -120,117 +157,151 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- computed: {
|
|
|
- isEdit() {
|
|
|
- return !!this.$route.query.id
|
|
|
+ created() {
|
|
|
+ this.getCountryList()
|
|
|
+ this.getFleetCompanyType()
|
|
|
+ if (this.$route.query.id) {
|
|
|
+ this.isEdit = true;
|
|
|
+ this.getFleetCompanyDetail()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ getCountryList() {
|
|
|
+ site.getCountryList().then(({ data }) => {
|
|
|
+ this.options.countryOptions = data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getFleetCompanyType() {
|
|
|
+ this.loading = true;
|
|
|
+ api.fetchFleetCompanyType().then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ this.options.fleetCompanyType = res.data
|
|
|
+ if (!this.isEdit) {
|
|
|
+ const defaultType = this.options.fleetCompanyType[0].value
|
|
|
+ this.form.fleetCompanyType = defaultType
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message({
|
|
|
+ message: error,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getFleetCompanyDetail() {
|
|
|
+ api.fetchFleetCompanyDetail({
|
|
|
+ fleetCompanyId: this.$route.query.id,
|
|
|
+ }).then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ this.form = res.data
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ message: err,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
onClickCancelButton() {
|
|
|
- this.$router.back()
|
|
|
+ this.$router.push({
|
|
|
+ path: "/fleetCompany"
|
|
|
+ })
|
|
|
},
|
|
|
onClickConfirmButton() {
|
|
|
this.$refs.form.validate(async (valid, fields) => {
|
|
|
if (valid) {
|
|
|
- this.confirmButtonLoading = true
|
|
|
- try {
|
|
|
- let result
|
|
|
- if (this.isEdit) {
|
|
|
- result = await updateFleetCompany({ ...this.form })
|
|
|
- } else {
|
|
|
- result = await addFleetCompany({ ...this.form })
|
|
|
- }
|
|
|
- if (result.success) {
|
|
|
- this.$notify.success(result.msg)
|
|
|
- this.$router.back()
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.$notify.error(error)
|
|
|
- }
|
|
|
- this.confirmButtonLoading = false
|
|
|
- } else {
|
|
|
- this.$notify.warning(fields[Object.keys(fields)[0]][0].message)
|
|
|
+ this.loading = true
|
|
|
+ this.isEdit ? this.onUpdateCompany() : this.onAddCompany();
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
- getFleetCompanyId() {
|
|
|
- if (this.isEdit) {
|
|
|
- return this.$route.query.id
|
|
|
- }
|
|
|
- return ''
|
|
|
- },
|
|
|
- async getFleetCompanyDetail() {
|
|
|
- if (this.isEdit) {
|
|
|
- const id = this.getFleetCompanyId()
|
|
|
- const params = { fleetCompanyId: id }
|
|
|
- try {
|
|
|
- const { success, data } = await fetchFleetCompanyDetail(params)
|
|
|
- if (success) {
|
|
|
- this.form.fleetCompanyId = data.fleetCompanyId
|
|
|
- this.form.fleetCompanyName = data.fleetCompanyName
|
|
|
- this.form.fleetCompanyType = data.fleetCompanyType
|
|
|
- this.form.contactNumber = data.contactNumber
|
|
|
- this.form.contactPerson = data.contactPerson
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.$notify.error(error)
|
|
|
- }
|
|
|
- }
|
|
|
+ onAddCompany() {
|
|
|
+ api.addFleetCompany(this.form).then(res => {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: "Add successfully!"
|
|
|
+ })
|
|
|
+ this.onClickCancelButton()
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
},
|
|
|
- async getFleetCompanyType() {
|
|
|
- try {
|
|
|
- const { success, data } = await fetchFleetCompanyType()
|
|
|
- if (success) {
|
|
|
- this.options.fleetCompanyType = data
|
|
|
- if (!this.isEdit) {
|
|
|
- const defaultType = this.options.fleetCompanyType[0].value
|
|
|
- this.form.fleetCompanyType = defaultType
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.$notify.error(error)
|
|
|
- }
|
|
|
+ onUpdateCompany() {
|
|
|
+ api.updateFleetCompany(this.form).then(res => {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: "Update successfully!"
|
|
|
+ })
|
|
|
+ this.onClickCancelButton()
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
}
|
|
|
- },
|
|
|
- async created() {
|
|
|
- await this.getFleetCompanyType()
|
|
|
- await this.getFleetCompanyDetail()
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-
|
|
|
@import '../../styles/variables.scss';
|
|
|
.container {
|
|
|
width: 100%;
|
|
|
- padding: 20px 50px;
|
|
|
+ padding: 20px 60px;
|
|
|
+ min-height: $mainAppMinHeight;
|
|
|
background-color: #F0F5FC;
|
|
|
}
|
|
|
.content {
|
|
|
- padding: 45px 0px;
|
|
|
+ margin: 0 8px 16px;
|
|
|
+ padding: 15px 80px;
|
|
|
border-radius: 6px;
|
|
|
- min-height: calc(#{$mainAppMinHeight} - (2 * 20px));
|
|
|
background-color: white;
|
|
|
- .el-select {
|
|
|
- width: 100%;
|
|
|
- }
|
|
|
- .el-form {
|
|
|
- padding: 0 45px;
|
|
|
- }
|
|
|
- ::v-deep .el-divider {
|
|
|
- margin: 80px 0 60px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .section-title {
|
|
|
+ color: #333;
|
|
|
+ margin-top: 20px;
|
|
|
+ margin-bottom: 30px;
|
|
|
+ font-size: 15px;
|
|
|
+ user-select: none;
|
|
|
+ line-height: 24px;
|
|
|
+ font-weight: bold;
|
|
|
+ font-family: sans-serif;
|
|
|
+ text-transform: uppercase;
|
|
|
+ }
|
|
|
+ .add-text {
|
|
|
+ width: 100%;
|
|
|
+ max-width: 300px;
|
|
|
+ }
|
|
|
+ .add-text ::v-deep .el-textarea__inner {
|
|
|
+ font-family: sans-serif;
|
|
|
+ }
|
|
|
+ .hr {
|
|
|
+ height: 2px;
|
|
|
+ margin: 10px -40px;
|
|
|
+ background-color: #F0F5FC;
|
|
|
+ }
|
|
|
+ .buttons {
|
|
|
+ padding-top: 15px;
|
|
|
+ padding-bottom: 15px;
|
|
|
+ }
|
|
|
+ @media screen and (max-width: 500px) {
|
|
|
+ .container {
|
|
|
+ padding: 0px;
|
|
|
}
|
|
|
- .buttons {
|
|
|
- padding: 0 45px;
|
|
|
- .cancelButton {
|
|
|
- color: #555;
|
|
|
- background: #FFFFFF;
|
|
|
- border: 1px solid #001489;
|
|
|
- box-sizing: border-box;
|
|
|
- border-radius: 4px;
|
|
|
- }
|
|
|
+ .content {
|
|
|
+ padding: 15px 30px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
</style>>
|