update the agent code for admin

This commit is contained in:
mahyargdz
2025-05-27 17:14:14 +03:30
parent d24481b598
commit 43e49f96f7
4 changed files with 139 additions and 12 deletions
+59 -2
View File
@@ -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: 'عملیات لغو شد'
})
}
}
}
}
+4 -3
View File
@@ -122,11 +122,11 @@
:class="validation.first_name ? 'err' : null"
/>
<CInput
v-model="registerData.representation_code"
v-model="registerData.agent_code"
label="کد نماینده"
horizontal
:description="validation.representation_code ? validation.representation_code.msg : null"
:class="validation.representation_code ? 'err' : null"
:description="validation.agent_code ? validation.agent_code.msg : null"
:class="validation.agent_code ? 'err' : null"
/>
<CInput
v-model="registerData.last_name"
@@ -294,6 +294,7 @@ export default {
registerData: {
userID: '',
first_name: '',
agent_code: '',
last_name: '',
national_code: '',
province_id: '',