update the agent code for admin
This commit is contained in:
@@ -160,6 +160,24 @@
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
<CCol lg="12">
|
||||
<CCard>
|
||||
<CCardBody>
|
||||
<h6>تغییر کد نمایندگی</h6>
|
||||
<el-divider></el-divider>
|
||||
<CForm @submit.prevent="updateAgentCode">
|
||||
<CRow>
|
||||
<CCol md="6">
|
||||
<CInput v-model="newAgentCode" placeholder="کد نمایندگی جدید" />
|
||||
</CCol>
|
||||
<CCol md="6">
|
||||
<CButton color="primary" type="submit"> ثبت کد جدید </CButton>
|
||||
</CCol>
|
||||
</CRow>
|
||||
</CForm>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
|
||||
<CCol lg="6">
|
||||
<CCard>
|
||||
@@ -414,13 +432,14 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
title: 'مشاهده درخواست نمایندگی',
|
||||
agent: null,
|
||||
agent: {},
|
||||
agentInbox: null,
|
||||
agentBr: null,
|
||||
agentOpr: null,
|
||||
agentPr: null,
|
||||
editFiles: '',
|
||||
validation: {}
|
||||
validation: {},
|
||||
newAgentCode: ''
|
||||
}
|
||||
},
|
||||
head() {
|
||||
@@ -480,6 +499,11 @@ export default {
|
||||
this.$nuxt.refresh()
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.agent && this.agent.agent_code) {
|
||||
this.newAgentCode = this.agent.agent_code
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goToUpdatePage() {
|
||||
const title = 'هشدار'
|
||||
@@ -615,6 +639,39 @@ export default {
|
||||
},
|
||||
toggleEditFiles(fieldName) {
|
||||
this.editFiles === fieldName ? (this.editFiles = '') : (this.editFiles = fieldName)
|
||||
},
|
||||
async updateAgentCode() {
|
||||
try {
|
||||
const title = 'هشدار'
|
||||
const msg = 'آیا از تغییر کد نمایندگی اطمینان دارید؟'
|
||||
|
||||
await this.$confirm(msg, title, {
|
||||
confirmButtonText: 'ثبت کد جدید',
|
||||
cancelButtonText: 'لغو',
|
||||
type: 'warning'
|
||||
})
|
||||
|
||||
await this.$axios
|
||||
.put(`/api/admin/updateAgentCode/${this.agent._id}`, { newAgentCode: this.newAgentCode })
|
||||
.then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: res.data.message
|
||||
})
|
||||
this.$nuxt.refresh()
|
||||
})
|
||||
.catch(err => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: err.response.data.message
|
||||
})
|
||||
})
|
||||
} catch (e) {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: 'عملیات لغو شد'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user