Просмотр исходного кода

管理后台调试变体图片上传接口 --- 调试接口

fogwind 6 дней назад
Родитель
Сommit
6d29f1735b

Разница между файлами не показана из-за своего большого размера
+ 257 - 100
packages/Longyi/Core/src/Resources/views/admin/catalog/products/edit/types/flexible_variant.blade.php


Разница между файлами не показана из-за своего большого размера
+ 191 - 0
packages/Longyi/Core/src/Resources/views/admin/catalog/products/edit/types/flexible_variant/mediaupload.blade copy.php


+ 188 - 0
packages/Longyi/Core/src/Resources/views/admin/catalog/products/edit/types/flexible_variant/mediaupload.blade.php

@@ -0,0 +1,188 @@
+<script type="text/x-template" id="flexiblevariant-uploaddialog-template">
+    <el-dialog title="Image Upload" width="660" class="flexiblevariant-uploaddialog"
+        :model-value="isShow" @update:model-value="$emit('update:isShow', $event)"
+    >
+        <div>
+             <el-upload
+                v-model:file-list="fileList"
+                ref="uploadRef"
+                :auto-upload="false"
+                :http-request="submitUpload"
+                list-type="picture"
+                :limit="1"
+                :on-change="uploadChange"
+                :on-exceed="uploadExceed"
+                :before-upload="beforeUpload"
+                action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d1"
+            >
+                
+                <template #trigger>
+                    <el-button type="primary">select file</el-button>
+                </template>
+                <template #tip>
+                    <div class="el-upload__tip">
+                        <p>Image files with a size less than 500kb.</p>
+                        <p>Only one image is allowed to be uploaded.</p>
+                    </div>
+                </template>
+                
+            </el-upload>
+        </div>
+
+     
+        <template #footer>
+            <div class="dialog-footer">
+                <el-button @click="cancelHandler">Cancel</el-button>
+                <el-button type="primary" @click="confirmHandler">Confirm</el-button>
+            </div>
+        </template>
+
+    </el-dialog>
+</script>
+<script type="module">
+
+        app.component('flexiblevariant-uploaddialog', {
+            template: '#flexiblevariant-uploaddialog-template',
+
+            props: {
+
+                variant: {
+                    type: Object,
+                    default: function() {
+                        return {};
+                    }
+                },
+                isShow: {
+                    type: Boolean,
+                    default: false
+                }
+                
+            },
+            emits: ['update:isShow','confirm'], // 显式声明事件(推荐)
+            data() {
+                return {
+                    fileList: [],
+                    form: {
+                        sku: '',
+                        name: '',
+                        price: 0,
+                        weight: 0,
+                        quantity: 0,
+                        // status: false,
+                    },
+              
+        
+    
+                };
+            },
+            watch: {
+                'variant.images':{
+                    handler(newVal, oldVal) {
+                        this.fileList = [];
+                        console.log(newVal);
+                    },
+                    
+                }
+            },
+
+            mounted() {
+                
+            },
+
+            methods: {
+               
+                getVariant(id) {
+                    let loading = this.$loading({
+                        target: '.flexiblevariant-eidtdialog'
+                    });
+                    axios.get(`/admin/flexible-variant/variants/${id}`).then((result) => {
+                        console.log(result);
+
+                        this.form = result.data.data;
+                        loading.close();
+                    }).catch((error) => {
+                        this.$message({
+                            message: error.message,
+                            type: 'error'
+                        });
+                        loading.close();
+                    });
+                },
+                uploadExceed(files) {
+                    this.$refs.uploadRef.clearFiles();
+                    const file = files[0];
+                    file.uid = this.$genFileId();
+                    this.$refs.uploadRef.handleStart(file);
+                },
+                uploadChange(addFile, fileList) {
+                    console.log(addFile.size,addFile,fileList);
+                },
+                beforeUpload(rawFile) {
+                    let res = true;
+                    if(rawFile.size > 500000) {
+                        this.$message({
+                            message: 'Image files with a size less than 500kb.',
+                            type: 'error'
+                        });
+                        res = false;
+                    }
+                    return res;
+                },
+                submitUpload(option) {
+                    console.log('submitUpload ---- ',option);
+                    let loading = this.$loading({
+                        target: '.flexiblevariant-uploaddialog'
+                    });
+                    axios.post(`/admin/variants/${this.variant.id}/images/upload`,{
+                        file: option.file
+                    }).then((result) => {
+                        console.log(result);
+
+                        
+                        loading.close();
+                    }).catch((error) => {
+                        this.$message({
+                            message: error.message,
+                            type: 'error'
+                        });
+                        loading.close();
+                    });
+
+                },
+                async saveVariant() {
+                    // /admin/flexible-variant/variants/{id}
+                    await this.$refs.variantFormRef.validate();
+                    let requestData = {
+                        sku: this.form.sku,
+                        name: this.form.name,
+                        price: this.form.price,
+                        weight: this.form.weight,
+                        quantity: this.form.quantity,
+                    }
+                    try {
+                        let res = await axios.put(`/admin/flexible-variant/variants/${this.variantId}`,requestData);
+                        this.$message({
+                            message: 'Save successfully.',
+                            type: 'success',
+                        });
+                        this.$emit('update:isShow', false);
+                        this.$emit('confirm', res.data.data);
+                    } catch(err) {
+                        this.$message({
+                            message: err.message,
+                            type: 'error',
+                        });
+                    }
+                    
+                },
+                confirmHandler() {
+                    this.$refs.uploadRef.submit()
+                },
+                cancelHandler() {
+                    this.$emit('update:isShow', false);
+                    this.$emit('cancel', {});
+                }
+            },
+
+        });
+</script>

+ 1 - 1
packages/Webkul/Admin/src/Resources/assets/css/app.css

@@ -577,7 +577,7 @@
 }
 
 .icon {
-  display: inline;
+  /* display: inline; */
   width: 1em;
   height: 1em;
   vertical-align: -0.15em;

+ 2 - 2
packages/Webkul/Admin/src/Resources/assets/js/app.js

@@ -128,7 +128,7 @@ import VeeValidate from "./plugins/vee-validate";
 import Draggable from "./plugins/draggable";
 import VueDraggablePlus from "./plugins/vuedraggableplus";
 // 引入element-plus组件库
-import ElementPlus from 'element-plus';
+import ElementPlus,{ genFileId } from 'element-plus';
 import 'element-plus/dist/index.css';
 import 'element-plus/theme-chalk/dark/css-vars.css';
 
@@ -138,7 +138,7 @@ import 'element-plus/theme-chalk/dark/css-vars.css';
 import VueCal from 'vue-cal';
 import 'vue-cal/dist/vuecal.css';
 
-
+app.config.globalProperties.$genFileId = genFileId; // 不得已只能挂在app上
 app.use(ElementPlus,{ zIndex: 12000 });
 app.component('vue-cal', VueCal);
 

+ 2 - 2
packages/Webkul/BagistoApi/src/State/LoginProcessor.php

@@ -20,7 +20,7 @@ class LoginProcessor implements ProcessorInterface
     public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = [])
     {
         if ($data instanceof LoginInput) {
-            if ($operation->getName() === 'create') {
+            // if ($operation->getName() === 'create') {
                 $this->validator->validateLoginInput($data);
 
                 $customer = Customer::where('email', $data->email)->first();
@@ -71,7 +71,7 @@ class LoginProcessor implements ProcessorInterface
                     'success'  => true,
                     'message'  => __('bagistoapi::app.graphql.login.successful'),
                 ];
-            }
+            // }
         }
 
         return (object) [

Разница между файлами не показана из-за своего большого размера
+ 0 - 1
public/themes/admin/default/build/assets/app-BoBmzsCW.css


Разница между файлами не показана из-за своего большого размера
+ 36 - 36
public/themes/admin/default/build/assets/app-D8rTgrvs.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
public/themes/admin/default/build/assets/app-CbKA8MhO.css


Разница между файлами не показана из-за своего большого размера
+ 1 - 0
public/themes/admin/default/build/assets/app-DvtzemP6.css


+ 3 - 3
public/themes/admin/default/build/manifest.json

@@ -264,7 +264,7 @@
     "isDynamicEntry": true
   },
   "src/Resources/assets/css/app.css": {
-    "file": "assets/app-BoBmzsCW.css",
+    "file": "assets/app-DvtzemP6.css",
     "src": "src/Resources/assets/css/app.css",
     "isEntry": true
   },
@@ -450,7 +450,7 @@
     "src": "src/Resources/assets/images/unpaid-invoices.svg"
   },
   "src/Resources/assets/js/app.js": {
-    "file": "assets/app-D8rTgrvs.js",
+    "file": "assets/app-CWWlRoqL.js",
     "name": "app",
     "src": "src/Resources/assets/js/app.js",
     "isEntry": true,
@@ -501,7 +501,7 @@
       "node_modules/vue-cal/dist/drag-and-drop.es.js"
     ],
     "css": [
-      "assets/app-CbKA8MhO.css"
+      "assets/app-CexndA5t.css"
     ]
   },
   "src/Resources/assets/js/chart.js": {