|
|
@@ -8,15 +8,17 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, computed } from 'vue';
|
|
|
+import { ref, computed, nextTick } from 'vue';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import SimpleFormModal from '@/components/CommonPage/SimpleFormModal.vue';
|
|
|
import request from '@/utils/request';
|
|
|
+import { useDictData } from '@/utils/use-dict-data';
|
|
|
|
|
|
const emit = defineEmits(['success']);
|
|
|
const editRef = ref(null);
|
|
|
const title = ref('添加图书');
|
|
|
const currentId = ref(null);
|
|
|
+const [complaint_reason] = useDictData(['complaint_reason']);
|
|
|
|
|
|
const formItems = computed(() => [
|
|
|
{
|
|
|
@@ -42,11 +44,10 @@ const formItems = computed(() => [
|
|
|
label: '易投诉原因:',
|
|
|
prop: 'reasonList',
|
|
|
required: true,
|
|
|
- options: [
|
|
|
- { label: '出版社投诉', value: '出版社投诉' },
|
|
|
- { label: '价格投诉', value: '价格投诉' },
|
|
|
- { label: '质量投诉', value: '质量投诉' }
|
|
|
- ]
|
|
|
+ options: complaint_reason.value.map(item => ({
|
|
|
+ label: item.dictLabel,
|
|
|
+ value: item.dictValue
|
|
|
+ }))
|
|
|
}
|
|
|
]);
|
|
|
|
|
|
@@ -58,25 +59,26 @@ const handleOpen = (row) => {
|
|
|
if (row) {
|
|
|
title.value = '编辑图书';
|
|
|
currentId.value = row.id;
|
|
|
- // Fetch details if needed or use row data
|
|
|
- // API doc says /shop/complaintBook/getInfo/{id} for details, but row might have enough info.
|
|
|
- // Let's implement getInfo as per requirement.
|
|
|
request.get(`/shop/complaintBook/getInfo/${row.id}`).then(res => {
|
|
|
- const data = res.data;
|
|
|
- editRef.value?.handleOpen({
|
|
|
- id: data.id,
|
|
|
- isbn: data.isbn,
|
|
|
- platformList: data.platformList || [],
|
|
|
- reasonList: data.reasonList || []
|
|
|
+ const data = res.data.data || res.data;
|
|
|
+ nextTick(() => {
|
|
|
+ editRef.value?.handleOpen({
|
|
|
+ id: data.id,
|
|
|
+ isbn: data.isbn,
|
|
|
+ platformList: data.platformList || [],
|
|
|
+ reasonList: data.reasonList || []
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
} else {
|
|
|
title.value = '添加图书';
|
|
|
currentId.value = null;
|
|
|
- editRef.value?.handleOpen({
|
|
|
- isbn: '',
|
|
|
- platformList: [],
|
|
|
- reasonList: []
|
|
|
+ nextTick(() => {
|
|
|
+ editRef.value?.handleOpen({
|
|
|
+ isbn: '',
|
|
|
+ platformList: [],
|
|
|
+ reasonList: []
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
};
|