|
@@ -21,7 +21,7 @@
|
|
|
<script setup>
|
|
|
import { onMounted, ref, render } from 'vue';
|
|
|
import ListPage from '@/views/components/ListPage/index.vue';
|
|
|
-import { add, list,delbanner } from "@/api/system/banner";
|
|
|
+import { add, update,list,delbanner } from "@/api/system/banner";
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
@@ -56,7 +56,7 @@ const listPageData = reactive({
|
|
|
label: '新增',
|
|
|
func: () => {
|
|
|
console.log('新增')
|
|
|
- openDialog();
|
|
|
+ openDialog(null,"add");
|
|
|
},
|
|
|
key: 'add',
|
|
|
hasPermi: ['banner:add'],
|
|
@@ -74,7 +74,7 @@ const listPageData = reactive({
|
|
|
key: 'edit',
|
|
|
func: (row) => {
|
|
|
console.log(row)
|
|
|
- openDialog(row);
|
|
|
+ openDialog(row,"update");
|
|
|
|
|
|
}
|
|
|
},
|
|
@@ -92,17 +92,21 @@ const listPageData = reactive({
|
|
|
})
|
|
|
|
|
|
const open = ref(false);
|
|
|
+const curDialogType = ref('');
|
|
|
const files = ref('');
|
|
|
+const curEditRow = ref(null);
|
|
|
const fileUpdata = (file) => {
|
|
|
console.log(file);
|
|
|
files.value = file;
|
|
|
}
|
|
|
|
|
|
-const openDialog = async (row) => {
|
|
|
+const openDialog = async (row,dialogType) => {
|
|
|
+ curDialogType.value = dialogType;
|
|
|
|
|
|
try {
|
|
|
if(row){
|
|
|
files.value = row.picture;
|
|
|
+ curEditRow.value = row;
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
@@ -126,14 +130,26 @@ const handleDelete = (ids) => {
|
|
|
const submitForm = () => {
|
|
|
console.log('submit', files.value);
|
|
|
const parmas = JSON.parse(JSON.stringify(files.value))
|
|
|
- add({picture: parmas }).then(res => {
|
|
|
+ if(curDialogType.value == "add"){
|
|
|
+ add({picture: parmas }).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
- proxy.$modal.msgSuccess("新增成功");
|
|
|
- cancel()
|
|
|
- return;
|
|
|
+ proxy.$modal.msgSuccess("编辑成功");
|
|
|
+ cancel()
|
|
|
+ return;
|
|
|
}
|
|
|
proxy.$modal.msgSuccess(res.msg);
|
|
|
- })
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ update({slideshowId: curEditRow.value.slideshowId, picture: parmas }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ proxy.$modal.msgSuccess("编辑成功");
|
|
|
+ cancel()
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ proxy.$modal.msgSuccess(res.msg);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
const cancel = () => {
|
|
|
userTableRef.value.resetForm();
|