diff --git a/src/api/lb-purchase-apply.js b/src/api/lb-purchase-apply.js
index 416b10b..019bcad 100644
--- a/src/api/lb-purchase-apply.js
+++ b/src/api/lb-purchase-apply.js
@@ -30,3 +30,11 @@ export function deleteLbPurchaseApply(id) {
method: 'delete'
})
}
+
+export function needPrivilegeRecommenders(params) {
+ return request({
+ url: '/lbPurchaseApply/needPrivilegeRecommenders',
+ method: 'get',
+ params
+ })
+}
diff --git a/src/views/lb-business/purchase-apply/index.vue b/src/views/lb-business/purchase-apply/index.vue
index a6d60f0..a84bc96 100644
--- a/src/views/lb-business/purchase-apply/index.vue
+++ b/src/views/lb-business/purchase-apply/index.vue
@@ -33,6 +33,18 @@
新增
+
+
+ 查看特权
+
@@ -119,6 +131,22 @@
确定
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -127,20 +155,26 @@ import {
addLbPurchaseApply,
deleteLbPurchaseApply,
getLbPurchaseApplyList,
+ needPrivilegeRecommenders,
updateLbPurchaseApply
} from '@/api/lb-purchase-apply'
export default {
name: 'LbPurchaseApply',
data() {
+ const today = this.getCurrentDate()
return {
loading: false,
submitLoading: false,
list: [],
total: 0,
dialogVisible: false,
+ privilegeDialogVisible: false,
dialogTitle: '',
isEdit: false,
+ privilegeLoading: false,
+ privilegeDateRange: [today, today],
+ privilegeList: [],
queryParams: {
current: 1,
size: 10,
@@ -168,6 +202,13 @@ export default {
this.fetchList()
},
methods: {
+ getCurrentDate() {
+ const date = new Date()
+ const year = date.getFullYear()
+ const month = String(date.getMonth() + 1).padStart(2, '0')
+ const day = String(date.getDate()).padStart(2, '0')
+ return `${year}-${month}-${day}`
+ },
fetchList() {
this.loading = true
getLbPurchaseApplyList(this.buildListParams())
@@ -238,6 +279,57 @@ export default {
this.$refs.dataForm && this.$refs.dataForm.clearValidate()
})
},
+ handleViewPrivilege() {
+ if (!Array.isArray(this.privilegeDateRange) || this.privilegeDateRange.length !== 2) {
+ this.$message.warning('请选择开始日期和结束日期')
+ return
+ }
+ const [startDate, endDate] = this.privilegeDateRange
+ if (!startDate || !endDate) {
+ this.$message.warning('请选择开始日期和结束日期')
+ return
+ }
+ this.privilegeLoading = true
+ needPrivilegeRecommenders({ startDate, endDate })
+ .then((res) => {
+ const result = this.normalizePrivilegeResponse(res)
+ const isSuccess = result && (result.success === true || result.code === 200 || result.code === 20000)
+ if (!isSuccess) {
+ this.$message.error((result && result.message) || '查询失败')
+ return
+ }
+ const list = this.extractPrivilegeList(result)
+ this.privilegeList = list
+ this.privilegeDialogVisible = true
+ if (!list.length) {
+ this.$message.info('该日期范围内暂无需要添加特权的推荐人')
+ }
+ })
+ .finally(() => {
+ this.privilegeLoading = false
+ })
+ },
+ normalizePrivilegeResponse(res) {
+ if (!res || typeof res !== 'object') return {}
+ if (res.data && typeof res.data === 'object' && !Array.isArray(res.data)) {
+ if (res.data.success !== undefined || Array.isArray(res.data.data) || Array.isArray(res.data.list)) {
+ return res.data
+ }
+ }
+ return res
+ },
+ extractPrivilegeList(res) {
+ let rawList = []
+ if (Array.isArray(res.data)) rawList = res.data
+ else if (res.data && Array.isArray(res.data.list)) rawList = res.data.list
+ else if (res.data && Array.isArray(res.data.rows)) rawList = res.data.rows
+ else if (res.data && Array.isArray(res.data.records)) rawList = res.data.records
+ else if (res.data && res.data.data && Array.isArray(res.data.data)) rawList = res.data.data
+ else if (Array.isArray(res.list)) rawList = res.list
+ else if (Array.isArray(res.rows)) rawList = res.rows
+ else if (Array.isArray(res.records)) rawList = res.records
+ return rawList
+ },
handleEdit(row) {
this.dialogTitle = '编辑进货申请'
this.isEdit = true
@@ -309,6 +401,9 @@ export default {
applyDate: ''
}
},
+ resetPrivilegeDialog() {
+ this.privilegeList = []
+ },
formatDateTime(dateTime) {
if (!dateTime) return '-'
const date = new Date(String(dateTime).replace('T', ' '))
@@ -341,5 +436,6 @@ export default {
text-align: right;
}
}
+
}